mshtml: Notify parser about script evaluation.
authorJacek Caban <jacek@codeweavers.com>
Tue, 15 Mar 2011 12:45:46 +0000 (13:45 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 15 Mar 2011 16:14:08 +0000 (17:14 +0100)
dlls/mshtml/mutation.c
dlls/mshtml/nsiface.idl
dlls/mshtml/tests/exectest.html

index 94217e916d9b439828eb42bfba1ca88add6e24bb..2117e494d482b943c1c96728cd0c2509b5ed8965 100644 (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);
     }
 
index 1df22b39c98ca29490d9576bd6fbef954022fa6f..b6367b44d4408ecc9ca11f3d59078005253d8db3 100644 (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),
index 65d3701f9afd43963f56c1e12b84feddc03b7ff7..1d84917cab0c7941a0e06ea19dfd3621d207ccc7 100644 (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();