Jacek Caban : mshtml: Bind events to document node instead of body element.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Sep 10 14:47:22 CDT 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Sep 10 17:30:24 2014 +0200

mshtml: Bind events to document node instead of body element.

---

 dlls/mshtml/htmlevent.c       | 12 ++----------
 dlls/mshtml/tests/events.html | 21 ++++++++++++++++++---
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c
index 33f763e..75b41d3 100644
--- a/dlls/mshtml/htmlevent.c
+++ b/dlls/mshtml/htmlevent.c
@@ -1328,16 +1328,8 @@ static HRESULT ensure_nsevent_handler(HTMLDocumentNode *doc, event_target_t *eve
         return S_OK;
 
     if(event_info[eid].flags & EVENT_BIND_TO_BODY) {
-        nsIDOMHTMLElement *nsbody;
-        nsresult nsres;
-
-        nsres = nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
-        if(NS_SUCCEEDED(nsres) && nsbody) {
-            nsnode = (nsIDOMNode*)nsbody;
-        }else {
-            ERR("GetBody failed: %08x\n", nsres);
-            return E_UNEXPECTED;
-        }
+        nsnode = doc->node.nsnode;
+        nsIDOMNode_AddRef(nsnode);
     }
 
     doc->event_vector[eid] = TRUE;
diff --git a/dlls/mshtml/tests/events.html b/dlls/mshtml/tests/events.html
index bf8a21f..d4e2644 100644
--- a/dlls/mshtml/tests/events.html
+++ b/dlls/mshtml/tests/events.html
@@ -114,14 +114,16 @@ function test_handler_this() {
     ok(calls == "div2,div2*,div1,div1*,body,body*", "calls = " + calls);
 }
 
-function runTests(t) {
+window.onload = function() {
     try {
         ok(cnt == 1, "cnt=" + cnt + " exception during loading?");
-        ok(t === window, "t !== window");
+        ok(this === window, "this !== window");
 
         ok(typeof(window.onload) === "function", "typeof(window.onload) = " + typeof(window.onload));
         ok(document.body.onload === window.onload, "document.body.onload !== window.onload");
 
+        ok(img_onload_called, "img.onload not called before window.onload");
+
         test_scriptfor();
         ondataavailable_test();
         test_handler_this();
@@ -132,8 +134,18 @@ function runTests(t) {
     external.reportSuccess();
 }
 </script>
+<script>
+var img = document.createElement("img");
+img.src = "http://test.winehq.org/tests/winehq_snapshot/index_files/winehq_logo_glass.png";
+
+var img_onload_called = false;
+img.onload = function() {
+    external.trace("img.onload");
+    img_onload_called = true;
+}
+</script>
 </head>
-<body onload="runTests(this)">
+<body>
 <div id="divid"></div>
 <div id="divid2"></div>
 <script event="onclick" for="divid2">
@@ -152,5 +164,8 @@ function runTests(t) {
     cnt++;
 })();
 </script>
+<script>
+document.body.appendChild(img);
+</script>
 </body>
 </html>




More information about the wine-cvs mailing list