Commit 4503edd6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Store information if script was already parsed in script element object.

parent a420b5da
...@@ -32,14 +32,6 @@ ...@@ -32,14 +32,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml); WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
typedef struct {
HTMLElement element;
IHTMLScriptElement IHTMLScriptElement_iface;
nsIDOMHTMLScriptElement *nsscript;
} HTMLScriptElement;
static inline HTMLScriptElement *impl_from_IHTMLScriptElement(IHTMLScriptElement *iface) static inline HTMLScriptElement *impl_from_IHTMLScriptElement(IHTMLScriptElement *iface)
{ {
return CONTAINING_RECORD(iface, HTMLScriptElement, IHTMLScriptElement_iface); return CONTAINING_RECORD(iface, HTMLScriptElement, IHTMLScriptElement_iface);
...@@ -327,6 +319,20 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = { ...@@ -327,6 +319,20 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = {
HTMLScriptElement_get_readystate HTMLScriptElement_get_readystate
}; };
HRESULT script_elem_from_nsscript(HTMLDocumentNode *doc, nsIDOMHTMLScriptElement *nsscript, HTMLScriptElement **ret)
{
HTMLDOMNode *node;
HRESULT hres;
hres = get_node(doc, (nsIDOMNode*)nsscript, TRUE, &node);
if(FAILED(hres))
return hres;
assert(node->vtbl == &HTMLScriptElementImplVtbl);
*ret = impl_from_HTMLDOMNode(node);
return S_OK;
}
static const tid_t HTMLScriptElement_iface_tids[] = { static const tid_t HTMLScriptElement_iface_tids[] = {
HTMLELEMENT_TIDS, HTMLELEMENT_TIDS,
IHTMLScriptElement_tid, IHTMLScriptElement_tid,
......
...@@ -741,6 +741,17 @@ void init_binding_ui(HTMLDocumentObj*) DECLSPEC_HIDDEN; ...@@ -741,6 +741,17 @@ void init_binding_ui(HTMLDocumentObj*) DECLSPEC_HIDDEN;
void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*) DECLSPEC_HIDDEN; void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*) DECLSPEC_HIDDEN;
typedef struct {
HTMLElement element;
IHTMLScriptElement IHTMLScriptElement_iface;
nsIDOMHTMLScriptElement *nsscript;
BOOL parsed;
} HTMLScriptElement;
HRESULT script_elem_from_nsscript(HTMLDocumentNode*,nsIDOMHTMLScriptElement*,HTMLScriptElement**) DECLSPEC_HIDDEN;
HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**) DECLSPEC_HIDDEN; HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**) DECLSPEC_HIDDEN;
void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*) DECLSPEC_HIDDEN; void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*) DECLSPEC_HIDDEN;
...@@ -904,7 +915,7 @@ HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement*) DECLSPEC_HIDDEN; ...@@ -904,7 +915,7 @@ HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement*) DECLSPEC_HIDDEN;
void release_script_hosts(HTMLInnerWindow*) DECLSPEC_HIDDEN; void release_script_hosts(HTMLInnerWindow*) DECLSPEC_HIDDEN;
void connect_scripts(HTMLInnerWindow*) DECLSPEC_HIDDEN; void connect_scripts(HTMLInnerWindow*) DECLSPEC_HIDDEN;
void doc_insert_script(HTMLInnerWindow*,nsIDOMHTMLScriptElement*) DECLSPEC_HIDDEN; void doc_insert_script(HTMLInnerWindow*,HTMLScriptElement*) DECLSPEC_HIDDEN;
IDispatch *script_parse_event(HTMLInnerWindow*,LPCWSTR) DECLSPEC_HIDDEN; IDispatch *script_parse_event(HTMLInnerWindow*,LPCWSTR) DECLSPEC_HIDDEN;
HRESULT exec_script(HTMLInnerWindow*,const WCHAR*,const WCHAR*,VARIANT*) DECLSPEC_HIDDEN; HRESULT exec_script(HTMLInnerWindow*,const WCHAR*,const WCHAR*,VARIANT*) DECLSPEC_HIDDEN;
void set_script_mode(HTMLOuterWindow*,SCRIPTMODE) DECLSPEC_HIDDEN; void set_script_mode(HTMLOuterWindow*,SCRIPTMODE) DECLSPEC_HIDDEN;
......
...@@ -294,8 +294,10 @@ static nsresult run_end_load(HTMLDocumentNode *This, nsISupports *arg1, nsISuppo ...@@ -294,8 +294,10 @@ static nsresult run_end_load(HTMLDocumentNode *This, nsISupports *arg1, nsISuppo
static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_iface, nsISupports *parser_iface) static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_iface, nsISupports *parser_iface)
{ {
nsIDOMHTMLScriptElement *nsscript; nsIDOMHTMLScriptElement *nsscript;
HTMLScriptElement *script_elem;
nsIParser *nsparser = NULL; nsIParser *nsparser = NULL;
nsresult nsres; nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", doc, script_iface); TRACE("(%p)->(%p)\n", doc, script_iface);
...@@ -313,17 +315,22 @@ static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_ifa ...@@ -313,17 +315,22 @@ static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_ifa
} }
} }
hres = script_elem_from_nsscript(doc, nsscript, &script_elem);
nsIDOMHTMLScriptElement_Release(nsscript);
if(FAILED(hres))
return NS_ERROR_FAILURE;
if(nsparser) if(nsparser)
nsIParser_BeginEvaluatingParserInsertedScript(nsparser); nsIParser_BeginEvaluatingParserInsertedScript(nsparser);
doc_insert_script(doc->window, nsscript); doc_insert_script(doc->window, script_elem);
if(nsparser) { if(nsparser) {
nsIParser_EndEvaluatingParserInsertedScript(nsparser); nsIParser_EndEvaluatingParserInsertedScript(nsparser);
nsIParser_Release(nsparser); nsIParser_Release(nsparser);
} }
nsIDOMHTMLScriptElement_Release(nsscript); IHTMLScriptElement_Release(&script_elem->IHTMLScriptElement_iface);
return NS_OK; return NS_OK;
} }
......
...@@ -731,34 +731,34 @@ static void parse_extern_script(ScriptHost *script_host, LPCWSTR src) ...@@ -731,34 +731,34 @@ static void parse_extern_script(ScriptHost *script_host, LPCWSTR src)
heap_free(text); heap_free(text);
} }
static void parse_inline_script(ScriptHost *script_host, nsIDOMHTMLScriptElement *nsscript) static void parse_inline_script(ScriptHost *script_host, HTMLScriptElement *script_elem)
{ {
const PRUnichar *text; const PRUnichar *text;
nsAString text_str; nsAString text_str;
nsresult nsres; nsresult nsres;
nsAString_Init(&text_str, NULL); nsAString_Init(&text_str, NULL);
nsres = nsIDOMHTMLScriptElement_GetText(script_elem->nsscript, &text_str);
nsAString_GetData(&text_str, &text);
nsres = nsIDOMHTMLScriptElement_GetText(nsscript, &text_str); if(NS_FAILED(nsres)) {
if(NS_SUCCEEDED(nsres)) {
nsAString_GetData(&text_str, &text);
parse_text(script_host, text);
}else {
ERR("GetText failed: %08x\n", nsres); ERR("GetText failed: %08x\n", nsres);
}else if(*text) {
script_elem->parsed = TRUE;
parse_text(script_host, text);
} }
nsAString_Finish(&text_str); nsAString_Finish(&text_str);
} }
static void parse_script_elem(ScriptHost *script_host, nsIDOMHTMLScriptElement *nsscript) static void parse_script_elem(ScriptHost *script_host, HTMLScriptElement *script_elem)
{ {
nsAString src_str, event_str; nsAString src_str, event_str;
const PRUnichar *src; const PRUnichar *src;
nsresult nsres; nsresult nsres;
nsAString_Init(&event_str, NULL); nsAString_Init(&event_str, NULL);
nsres = nsIDOMHTMLScriptElement_GetEvent(nsscript, &event_str); nsres = nsIDOMHTMLScriptElement_GetEvent(script_elem->nsscript, &event_str);
if(NS_SUCCEEDED(nsres)) { if(NS_SUCCEEDED(nsres)) {
const PRUnichar *event; const PRUnichar *event;
...@@ -774,15 +774,17 @@ static void parse_script_elem(ScriptHost *script_host, nsIDOMHTMLScriptElement * ...@@ -774,15 +774,17 @@ static void parse_script_elem(ScriptHost *script_host, nsIDOMHTMLScriptElement *
nsAString_Finish(&event_str); nsAString_Finish(&event_str);
nsAString_Init(&src_str, NULL); nsAString_Init(&src_str, NULL);
nsres = nsIDOMHTMLScriptElement_GetSrc(nsscript, &src_str); nsres = nsIDOMHTMLScriptElement_GetSrc(script_elem->nsscript, &src_str);
nsAString_GetData(&src_str, &src); nsAString_GetData(&src_str, &src);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres)) {
ERR("GetSrc failed: %08x\n", nsres); ERR("GetSrc failed: %08x\n", nsres);
else if(*src) }else if(*src) {
script_elem->parsed = TRUE;
parse_extern_script(script_host, src); parse_extern_script(script_host, src);
else }else {
parse_inline_script(script_host, nsscript); parse_inline_script(script_host, script_elem);
}
nsAString_Finish(&src_str); nsAString_Finish(&src_str);
} }
...@@ -887,12 +889,12 @@ static ScriptHost *get_script_host(HTMLInnerWindow *window, const GUID *guid) ...@@ -887,12 +889,12 @@ static ScriptHost *get_script_host(HTMLInnerWindow *window, const GUID *guid)
return create_script_host(window, guid); return create_script_host(window, guid);
} }
void doc_insert_script(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *nsscript) void doc_insert_script(HTMLInnerWindow *window, HTMLScriptElement *script_elem)
{ {
ScriptHost *script_host; ScriptHost *script_host;
GUID guid; GUID guid;
if(!get_script_guid(window, nsscript, &guid)) { if(!get_script_guid(window, script_elem->nsscript, &guid)) {
WARN("Could not find script GUID\n"); WARN("Could not find script GUID\n");
return; return;
} }
...@@ -908,7 +910,7 @@ void doc_insert_script(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *nsscrip ...@@ -908,7 +910,7 @@ void doc_insert_script(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *nsscrip
return; return;
if(script_host->parse) if(script_host->parse)
parse_script_elem(script_host, nsscript); parse_script_elem(script_host, script_elem);
} }
IDispatch *script_parse_event(HTMLInnerWindow *window, LPCWSTR text) IDispatch *script_parse_event(HTMLInnerWindow *window, LPCWSTR text)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment