mshtml: Added support for IHTMLScriptElement::put_src calls during parser callback.

This commit is contained in:
Jacek Caban 2012-10-16 17:08:25 +02:00 committed by Alexandre Julliard
parent fdbbaa1ff5
commit ccbee09f7e
6 changed files with 44 additions and 2 deletions

View File

@ -123,8 +123,17 @@ static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR
} }
if(window->parser_callback_cnt) { if(window->parser_callback_cnt) {
FIXME("execution inside parser not supported\n"); script_queue_entry_t *queue;
return E_NOTIMPL;
queue = heap_alloc(sizeof(*queue));
if(!queue)
return E_OUTOFMEMORY;
IHTMLScriptElement_AddRef(&This->IHTMLScriptElement_iface);
queue->script = This;
list_add_tail(&window->script_queue, &queue->entry);
return S_OK;
} }
nsres = nsIDOMHTMLScriptElement_GetParentNode(This->nsscript, &parent); nsres = nsIDOMHTMLScriptElement_GetParentNode(This->nsscript, &parent);

View File

@ -25,6 +25,11 @@ typedef struct {
BOOL parsed; BOOL parsed;
} HTMLScriptElement; } HTMLScriptElement;
typedef struct {
struct list entry;
HTMLScriptElement *script;
} script_queue_entry_t;
HRESULT script_elem_from_nsscript(HTMLDocumentNode*,nsIDOMHTMLScriptElement*,HTMLScriptElement**) DECLSPEC_HIDDEN; HRESULT script_elem_from_nsscript(HTMLDocumentNode*,nsIDOMHTMLScriptElement*,HTMLScriptElement**) DECLSPEC_HIDDEN;
void bind_event_scripts(HTMLDocumentNode*) DECLSPEC_HIDDEN; void bind_event_scripts(HTMLDocumentNode*) DECLSPEC_HIDDEN;

View File

@ -2720,6 +2720,7 @@ static HRESULT create_inner_window(HTMLOuterWindow *outer_window, IMoniker *mon,
list_init(&window->script_hosts); list_init(&window->script_hosts);
list_init(&window->bindings); list_init(&window->bindings);
list_init(&window->script_queue);
window->base.outer_window = outer_window; window->base.outer_window = outer_window;
window->base.inner_window = window; window->base.inner_window = window;

View File

@ -400,6 +400,7 @@ struct HTMLInnerWindow {
IHTMLStorage *session_storage; IHTMLStorage *session_storage;
unsigned parser_callback_cnt; unsigned parser_callback_cnt;
struct list script_queue;
global_prop_t *global_props; global_prop_t *global_props;
DWORD global_prop_cnt; DWORD global_prop_cnt;

View File

@ -298,6 +298,7 @@ static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_ifa
nsIDOMHTMLScriptElement *nsscript; nsIDOMHTMLScriptElement *nsscript;
HTMLScriptElement *script_elem; HTMLScriptElement *script_elem;
nsIParser *nsparser = NULL; nsIParser *nsparser = NULL;
script_queue_entry_t *iter;
HTMLInnerWindow *window; HTMLInnerWindow *window;
nsresult nsres; nsresult nsres;
HRESULT hres; HRESULT hres;
@ -332,8 +333,20 @@ static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_ifa
window->parser_callback_cnt++; window->parser_callback_cnt++;
} }
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
doc_insert_script(window, script_elem); doc_insert_script(window, script_elem);
while(!list_empty(&window->script_queue)) {
iter = LIST_ENTRY(list_head(&window->script_queue), script_queue_entry_t, entry);
list_remove(&iter->entry);
doc_insert_script(window, iter->script);
IHTMLScriptElement_Release(&iter->script->IHTMLScriptElement_iface);
heap_free(iter);
}
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
if(nsparser) { if(nsparser) {
window->parser_callback_cnt--; window->parser_callback_cnt--;
nsIParser_EndEvaluatingParserInsertedScript(nsparser); nsIParser_EndEvaluatingParserInsertedScript(nsparser);
@ -341,6 +354,7 @@ static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_ifa
} }
IHTMLScriptElement_Release(&script_elem->IHTMLScriptElement_iface); IHTMLScriptElement_Release(&script_elem->IHTMLScriptElement_iface);
return NS_OK; return NS_OK;
} }

View File

@ -915,6 +915,9 @@ void doc_insert_script(HTMLInnerWindow *window, HTMLScriptElement *script_elem)
{ {
ScriptHost *script_host; ScriptHost *script_host;
if(script_elem->parsed)
return;
script_host = get_elem_script_host(window, script_elem); script_host = get_elem_script_host(window, script_elem);
if(!script_host) if(!script_host)
return; return;
@ -1309,8 +1312,17 @@ void set_script_mode(HTMLOuterWindow *window, SCRIPTMODE mode)
void release_script_hosts(HTMLInnerWindow *window) void release_script_hosts(HTMLInnerWindow *window)
{ {
script_queue_entry_t *queue_iter;
ScriptHost *iter; ScriptHost *iter;
while(!list_empty(&window->script_queue)) {
queue_iter = LIST_ENTRY(list_head(&window->script_queue), script_queue_entry_t, entry);
list_remove(&queue_iter->entry);
IHTMLScriptElement_Release(&queue_iter->script->IHTMLScriptElement_iface);
heap_free(queue_iter);
}
while(!list_empty(&window->script_hosts)) { while(!list_empty(&window->script_hosts)) {
iter = LIST_ENTRY(list_head(&window->script_hosts), ScriptHost, entry); iter = LIST_ENTRY(list_head(&window->script_hosts), ScriptHost, entry);