Jacek Caban : mshtml: Notify parser about script evaluation.

Alexandre Julliard julliard at winehq.org
Tue Mar 15 11:33:59 CDT 2011


Module: wine
Branch: master
Commit: dc96c688d397eb4ef1392ee6a98f3eb6b176dc56
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=dc96c688d397eb4ef1392ee6a98f3eb6b176dc56

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Mar 15 13:45:46 2011 +0100

mshtml: Notify parser about script evaluation.

---

 dlls/mshtml/mutation.c          |   22 ++++++++++++++++-
 dlls/mshtml/nsiface.idl         |   49 ++++++++++++++++++++++++++++++++++++++-
 dlls/mshtml/tests/exectest.html |    4 +-
 3 files changed, 70 insertions(+), 5 deletions(-)

diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c
index 94217e9..2117e49 100644
--- a/dlls/mshtml/mutation.c
+++ b/dlls/mshtml/mutation.c
@@ -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);
     }
 
diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl
index 1df22b3..b6367b4 100644
--- a/dlls/mshtml/nsiface.idl
+++ b/dlls/mshtml/nsiface.idl
@@ -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,
@@ -2960,6 +2962,51 @@ interface nsIMutationObserver : nsISupports
 
 [
     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),
     local
 ]
diff --git a/dlls/mshtml/tests/exectest.html b/dlls/mshtml/tests/exectest.html
index 65d3701..1d84917 100644
--- a/dlls/mshtml/tests/exectest.html
+++ b/dlls/mshtml/tests/exectest.html
@@ -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();




More information about the wine-cvs mailing list