mshtml: Notify parser about script evaluation.

This commit is contained in:
Jacek Caban 2011-03-15 13:45:46 +01:00 committed by Alexandre Julliard
parent 699e41cdd8
commit dc96c688d3
3 changed files with 70 additions and 5 deletions

View File

@ -310,9 +310,10 @@ static nsresult run_end_load(HTMLDocumentNode *This, nsISupports *arg1, nsISuppo
return NS_OK;
}
static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_iface, nsISupports *arg)
static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_iface, nsISupports *parser_iface)
{
nsIDOMHTMLScriptElement *nsscript;
nsIParser *nsparser = NULL;
nsresult nsres;
TRACE("(%p)->(%p)\n", doc, script_iface);
@ -323,7 +324,24 @@ static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_ifa
return nsres;
}
if(parser_iface) {
nsres = nsISupports_QueryInterface(parser_iface, &IID_nsIParser, (void**)&nsparser);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIParser iface: %08x\n", nsres);
nsparser = NULL;
}
}
if(nsparser)
nsIParser_BeginEvaluatingParserInsertedScript(nsparser);
doc_insert_script(doc->basedoc.window, nsscript);
if(nsparser) {
nsIParser_EndEvaluatingParserInsertedScript(nsparser);
nsIParser_Release(nsparser);
}
nsIDOMHTMLScriptElement_Release(nsscript);
return NS_OK;
}
@ -649,7 +667,7 @@ static nsresult NSAPI nsDocumentObserver_DoneAddingChildren(nsIDocumentObserver
if(NS_SUCCEEDED(nsres)) {
TRACE("script node\n");
add_script_runner(This, run_insert_script, (nsISupports*)nsscript, NULL);
add_script_runner(This, run_insert_script, (nsISupports*)nsscript, (nsISupports*)aParser);
nsIDOMHTMLScriptElement_Release(nsscript);
}

View File

@ -150,7 +150,9 @@ typedef nsISupports nsIControllers;
typedef nsISupports nsIDOMValidityState;
typedef nsISupports nsIPluginInstanceOwner;
typedef nsISupports nsIPluginStreamListener;
typedef nsISupports nsIParser;
typedef nsISupports nsIContentSink;
typedef nsISupports nsIParserFilter;
typedef nsISupports nsIDTD;
[
object,
@ -2958,6 +2960,51 @@ interface nsIMutationObserver : nsISupports
void ParentChainChanged(nsIContent *aContent);
}
[
object,
uuid(cbc0cbd8-bbb7-46d6-a551-378a6953a714),
local
]
interface nsIParser : nsISupports
{
typedef int nsDTDMode;
typedef int eParserCommands;
void SetContentSink(nsIContentSink *aSink);
nsIContentSink *GetContentSink();
void GetCommand(nsACString *aCommand);
void SetCommand2(const char *aCommand);
void SetCommand(eParserCommands aParserCommand);
void SetDocumentCharset(const nsACString *aCharset, PRInt32 aSource);
void GetDocumentCharset(nsACString *oCharset, PRInt32 *oSource);
void SetParserFilter(nsIParserFilter *aFilter);
nsresult GetChannel(nsIChannel **aChannel);
nsresult GetDTD(nsIDTD **aDTD);
nsresult GetStreamListener(nsIStreamListener **aListener);
nsresult ContinueInterruptedParsing();
void BlockParser();
void UnblockParser();
PRBool IsParserEnabled();
PRBool IsComplete();
nsresult Parse(nsIURI *aURL, nsIRequestObserver *aListener, void *aKey, nsDTDMode aMode);
nsresult Parse2(const nsAString *aSourceBuffer, void *aKey, const nsACString *aMimeType, PRBool aLastCall, nsDTDMode aMode);
void *GetRootContextKey();
nsresult Terminate();
nsresult ParseFragment(const nsAString *aSourceBuffer, void *aKey, void /*nsTArray<nsString>*/ *aTagStack,
PRBool aXMLMode, const nsACString *aContentType, nsDTDMode aMode);
nsresult ParseFragment2(const nsAString *aSourceBuffer, nsIContent *aTargetNode, nsIAtom *aContextLocalName,
PRInt32 aContextNamespace, PRBool aQuirks);
nsresult BuildModel();
nsresult CancelParsingEvents();
void Reset();
PRBool CanInterrupt();
PRBool IsInsertionPointDefined();
void BeginEvaluatingParserInsertedScript();
void EndEvaluatingParserInsertedScript();
void MarkAsNotScriptCreated();
PRBool IsScriptCreated();
}
[
object,
uuid(3d005225-210f-4b07-b1d9-96020574c437),

View File

@ -15,12 +15,12 @@ ok(len === 3, "init length = " + len);
document.write("<script>"
+ "var len = document.getElementsByTagName('div').length;"
+ "external.todo_wine_ok(len === 3, 'unexpected length ' + len);"
+ "ok(len === 3, 'unexpected length ' + len);"
+ "executed = true;"
+ "<" + "/script>");
len = document.getElementsByTagName('script').length;
external.todo_wine_ok(len === 2, "script col length = " + len);
ok(len === 2, "script col length = " + len);
ok(executed, "writen script not executed");
external.reportSuccess();