Jacek Caban : mshtml: Initialize DispatchEx in HTMLDOMNode_Init.

Alexandre Julliard julliard at winehq.org
Fri Sep 22 15:49:05 CDT 2017


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Sep 21 23:25:17 2017 +0200

mshtml: Initialize DispatchEx in HTMLDOMNode_Init.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmlcomment.c    |  2 +-
 dlls/mshtml/htmldoc.c        |  6 ++----
 dlls/mshtml/htmlelem.c       |  4 +---
 dlls/mshtml/htmlnode.c       | 19 +++++++++++++++++--
 dlls/mshtml/htmltextnode.c   |  5 +----
 dlls/mshtml/mshtml_private.h |  2 +-
 6 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/dlls/mshtml/htmlcomment.c b/dlls/mshtml/htmlcomment.c
index ed6a740..85eceef 100644
--- a/dlls/mshtml/htmlcomment.c
+++ b/dlls/mshtml/htmlcomment.c
@@ -217,7 +217,7 @@ HRESULT HTMLCommentElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTM
     ret->IHTMLCommentElement_iface.lpVtbl = &HTMLCommentElementVtbl;
 
     HTMLElement_Init(&ret->element, doc, NULL, &HTMLCommentElement_dispex);
-    HTMLDOMNode_Init(doc, &ret->element.node, nsnode);
+    HTMLDOMNode_Init(doc, &ret->element.node, nsnode, &HTMLCommentElement_dispex);
 
     *elem = &ret->element;
     return S_OK;
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 0a2d243..f4ff2f7 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -5025,8 +5025,6 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindo
     doc->basedoc.window = window->base.outer_window;
     doc->window = window;
 
-    init_dispex(&doc->node.event_target.dispex, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
-            &HTMLDocumentNode_dispex);
     init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
             &doc->node.event_target.dispex.IDispatchEx_iface);
     HTMLDocumentNode_SecMgr_Init(doc);
@@ -5049,7 +5047,7 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
     if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
         doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
 
-    HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
+    HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
 
     nsIDOMHTMLDocument_AddRef(nsdoc);
     doc->nsdoc = nsdoc;
@@ -5074,7 +5072,7 @@ static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *do
 
     IHTMLWindow2_AddRef(&doc_frag->window->base.IHTMLWindow2_iface);
 
-    HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
+    HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode, &HTMLDocumentNode_dispex);
     doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
     doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
 
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index a87bdf0..ea65042 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -5396,11 +5396,9 @@ void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElemen
 
     if(dispex_data && !dispex_data->vtbl)
         dispex_data->vtbl = &HTMLElement_dispex_vtbl;
-    init_dispex_with_compat_mode(&This->node.event_target.dispex, (IUnknown*)&This->IHTMLElement_iface,
-            dispex_data ? dispex_data : &HTMLElement_dispex, doc->document_mode);
 
     if(nselem) {
-        HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
+        HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem, dispex_data ? dispex_data : &HTMLElement_dispex);
 
         /* No AddRef, share reference with HTMLDOMNode */
         assert((nsIDOMNode*)nselem == This->node.nsnode);
diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c
index 80bf31d..e90f4e3 100644
--- a/dlls/mshtml/htmlnode.c
+++ b/dlls/mshtml/htmlnode.c
@@ -1441,7 +1441,7 @@ static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
     HTMLDOMNode_clone
 };
 
-void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsnode)
+void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsnode, dispex_static_data_t *dispex_data)
 {
     nsresult nsres;
 
@@ -1450,6 +1450,8 @@ void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsno
     node->IHTMLDOMNode3_iface.lpVtbl = &HTMLDOMNode3Vtbl;
 
     ccref_init(&node->ccref, 1);
+    init_dispex_with_compat_mode(&node->event_target.dispex, (IUnknown*)&node->IHTMLDOMNode_iface,
+                                 dispex_data, doc->document_mode);
     init_event_target(&node->event_target);
 
     if(&doc->node != node)
@@ -1463,6 +1465,17 @@ void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsno
     assert(nsres == NS_OK);
 }
 
+static const tid_t HTMLDOMNode_iface_tids[] = {
+    IHTMLDOMNode_tid,
+    0
+};
+static dispex_static_data_t HTMLDOMNode_dispex = {
+    NULL,
+    IHTMLDOMNode_tid,
+    HTMLDOMNode_iface_tids,
+    HTMLDOMNode_init_dispex_info
+};
+
 static HRESULT create_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret)
 {
     UINT16 node_type;
@@ -1500,12 +1513,14 @@ static HRESULT create_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNod
     default: {
         HTMLDOMNode *node;
 
+        FIXME("unimplemented node type %u\n", node_type);
+
         node = heap_alloc_zero(sizeof(HTMLDOMNode));
         if(!node)
             return E_OUTOFMEMORY;
 
         node->vtbl = &HTMLDOMNodeImplVtbl;
-        HTMLDOMNode_Init(doc, node, nsnode);
+        HTMLDOMNode_Init(doc, node, nsnode, &HTMLDOMNode_dispex);
         *ret = node;
     }
     }
diff --git a/dlls/mshtml/htmltextnode.c b/dlls/mshtml/htmltextnode.c
index a5587c1..f9d7eec 100644
--- a/dlls/mshtml/htmltextnode.c
+++ b/dlls/mshtml/htmltextnode.c
@@ -378,10 +378,7 @@ HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDO
     ret->IHTMLDOMTextNode_iface.lpVtbl = &HTMLDOMTextNodeVtbl;
     ret->IHTMLDOMTextNode2_iface.lpVtbl = &HTMLDOMTextNode2Vtbl;
 
-    init_dispex_with_compat_mode(&ret->node.event_target.dispex, (IUnknown*)&ret->IHTMLDOMTextNode_iface,
-                                 &HTMLDOMTextNode_dispex, doc->document_mode);
-
-    HTMLDOMNode_Init(doc, &ret->node, nsnode);
+    HTMLDOMNode_Init(doc, &ret->node, nsnode, &HTMLDOMTextNode_dispex);
 
     nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&ret->nstext);
     assert(nsres == NS_OK && (nsIDOMNode*)ret->nstext == ret->node.nsnode);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index ecd72b8..45bf98c 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -1035,7 +1035,7 @@ HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElem
 HRESULT HTMLTitleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
 HRESULT HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
 
-void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*) DECLSPEC_HIDDEN;
+void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*,dispex_static_data_t*) DECLSPEC_HIDDEN;
 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*) DECLSPEC_HIDDEN;
 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*) DECLSPEC_HIDDEN;
 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list