mshtml: Delay onreadystateevent notification if script elemenet is not added by parser.

This commit is contained in:
Jacek Caban 2014-12-24 13:10:21 +01:00 committed by Alexandre Julliard
parent 71ce8aaafe
commit f4b6852278
2 changed files with 49 additions and 2 deletions

View File

@ -24,6 +24,7 @@ typedef struct {
nsIDOMHTMLScriptElement *nsscript;
BOOL parsed;
BOOL parse_on_bind;
BOOL pending_readystatechange_event;
READYSTATE readystate;
} HTMLScriptElement;

View File

@ -702,12 +702,58 @@ static ScriptHost *create_script_host(HTMLInnerWindow *window, const GUID *guid)
return ret;
}
typedef struct {
task_t header;
HTMLScriptElement *elem;
} fire_readystatechange_task_t;
static void fire_readystatechange_proc(task_t *_task)
{
fire_readystatechange_task_t *task = (fire_readystatechange_task_t*)_task;
if(!task->elem->pending_readystatechange_event)
return;
task->elem->pending_readystatechange_event = FALSE;
fire_event(task->elem->element.node.doc, EVENTID_READYSTATECHANGE, FALSE, task->elem->element.node.nsnode, NULL, NULL);
}
static void fire_readystatechange_task_destr(task_t *_task)
{
fire_readystatechange_task_t *task = (fire_readystatechange_task_t*)_task;
IHTMLScriptElement_Release(&task->elem->IHTMLScriptElement_iface);
}
static void set_script_elem_readystate(HTMLScriptElement *script_elem, READYSTATE readystate)
{
script_elem->readystate = readystate;
if(readystate != READYSTATE_INTERACTIVE)
fire_event(script_elem->element.node.doc, EVENTID_READYSTATECHANGE, FALSE, script_elem->element.node.nsnode, NULL, NULL);
if(readystate != READYSTATE_INTERACTIVE) {
if(!script_elem->element.node.doc->window->parser_callback_cnt) {
fire_readystatechange_task_t *task;
HRESULT hres;
if(script_elem->pending_readystatechange_event)
return;
task = heap_alloc(sizeof(*task));
if(!task)
return;
IHTMLScriptElement_AddRef(&script_elem->IHTMLScriptElement_iface);
task->elem = script_elem;
hres = push_task(&task->header, fire_readystatechange_proc, fire_readystatechange_task_destr,
script_elem->element.node.doc->window->task_magic);
if(SUCCEEDED(hres))
script_elem->pending_readystatechange_event = TRUE;
}else {
script_elem->pending_readystatechange_event = FALSE;
fire_event(script_elem->element.node.doc, EVENTID_READYSTATECHANGE, FALSE,
script_elem->element.node.nsnode, NULL, NULL);
}
}
}
static void parse_elem_text(ScriptHost *script_host, HTMLScriptElement *script_elem, LPCWSTR text)