Module: wine Branch: master Commit: 57f7159a21dac402b73dade0c7905efc5da3bf1e URL: https://gitlab.winehq.org/wine/wine/-/commit/57f7159a21dac402b73dade0c7905ef...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Tue Sep 19 17:26:14 2023 +0300
mshtml: Use the dispex's query_interface for Document nodes and fragments.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/mshtml/htmldoc.c | 152 ++++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 78 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 96faa3c6efc..30a337c3761 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -5696,12 +5696,82 @@ static inline HTMLDocumentNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface) return CONTAINING_RECORD(iface, HTMLDocumentNode, node); }
-static void *HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid) +void detach_document_node(HTMLDocumentNode *doc) +{ + unsigned i; + + while(!list_empty(&doc->plugin_hosts)) + detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry)); + + if(doc->dom_implementation) + detach_dom_implementation(doc->dom_implementation); + + unlink_ref(&doc->dom_implementation); + unlink_ref(&doc->namespaces); + detach_events(doc); + detach_selection(doc); + detach_ranges(doc); + + for(i=0; i < doc->elem_vars_cnt; i++) + free(doc->elem_vars[i]); + free(doc->elem_vars); + doc->elem_vars_cnt = doc->elem_vars_size = 0; + doc->elem_vars = NULL; + + unlink_ref(&doc->catmgr); + if(doc->browser) { + list_remove(&doc->browser_entry); + doc->browser = NULL; + } +} + +static void HTMLDocumentNode_destructor(HTMLDOMNode *iface) { HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface);
- if(IsEqualGUID(&IID_IUnknown, riid)) - return &This->IHTMLDocument2_iface; + TRACE("(%p)\n", This); + + free(This->event_vector); + ConnectionPointContainer_Destroy(&This->cp_container); +} + +static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface); + FIXME("%p\n", This); + return E_NOTIMPL; +} + +static const NodeImplVtbl HTMLDocumentNodeImplVtbl = { + .clsid = &CLSID_HTMLDocument, + .destructor = HTMLDocumentNode_destructor, + .cpc_entries = HTMLDocumentNode_cpc, + .clone = HTMLDocumentNode_clone, +}; + +static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) +{ + HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface); + HTMLDocumentNode *new_node; + HRESULT hres; + + hres = create_document_fragment(nsnode, This->node.doc, &new_node); + if(FAILED(hres)) + return hres; + + *ret = &new_node->node; + return S_OK; +} + +static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex); +} + +static void *HTMLDocumentNode_query_interface(DispatchEx *dispex, REFIID riid) +{ + HTMLDocumentNode *This = impl_from_DispatchEx(dispex); + if(IsEqualGUID(&IID_IDispatch, riid) || IsEqualGUID(&IID_IDispatchEx, riid)) return &This->IDispatchEx_iface; if(IsEqualGUID(&IID_IHTMLDocument, riid) || IsEqualGUID(&IID_IHTMLDocument2, riid)) @@ -5796,79 +5866,6 @@ static void *HTMLDocumentNode_QI(HTMLDOMNode *iface, REFIID riid) return HTMLDOMNode_QI(&This->node, riid); }
-void detach_document_node(HTMLDocumentNode *doc) -{ - unsigned i; - - while(!list_empty(&doc->plugin_hosts)) - detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry)); - - if(doc->dom_implementation) - detach_dom_implementation(doc->dom_implementation); - - unlink_ref(&doc->dom_implementation); - unlink_ref(&doc->namespaces); - detach_events(doc); - detach_selection(doc); - detach_ranges(doc); - - for(i=0; i < doc->elem_vars_cnt; i++) - free(doc->elem_vars[i]); - free(doc->elem_vars); - doc->elem_vars_cnt = doc->elem_vars_size = 0; - doc->elem_vars = NULL; - - unlink_ref(&doc->catmgr); - if(doc->browser) { - list_remove(&doc->browser_entry); - doc->browser = NULL; - } -} - -static void HTMLDocumentNode_destructor(HTMLDOMNode *iface) -{ - HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface); - - TRACE("(%p)\n", This); - - free(This->event_vector); - ConnectionPointContainer_Destroy(&This->cp_container); -} - -static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) -{ - HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface); - FIXME("%p\n", This); - return E_NOTIMPL; -} - -static const NodeImplVtbl HTMLDocumentNodeImplVtbl = { - .clsid = &CLSID_HTMLDocument, - .qi = HTMLDocumentNode_QI, - .destructor = HTMLDocumentNode_destructor, - .cpc_entries = HTMLDocumentNode_cpc, - .clone = HTMLDocumentNode_clone, -}; - -static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret) -{ - HTMLDocumentNode *This = impl_from_HTMLDOMNode(iface); - HTMLDocumentNode *new_node; - HRESULT hres; - - hres = create_document_fragment(nsnode, This->node.doc, &new_node); - if(FAILED(hres)) - return hres; - - *ret = &new_node->node; - return S_OK; -} - -static inline HTMLDocumentNode *impl_from_DispatchEx(DispatchEx *iface) -{ - return CONTAINING_RECORD(iface, HTMLDocumentNode, node.event_target.dispex); -} - static void HTMLDocumentNode_unlink(DispatchEx *dispex) { HTMLDocumentNode *This = impl_from_DispatchEx(dispex); @@ -6060,7 +6057,7 @@ static HRESULT HTMLDocumentNode_location_hook(DispatchEx *dispex, WORD flags, DI
static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = { { - .query_interface = HTMLDOMNode_query_interface, + .query_interface = HTMLDocumentNode_query_interface, .destructor = HTMLDOMNode_destructor, .traverse = HTMLDOMNode_traverse, .unlink = HTMLDocumentNode_unlink, @@ -6078,7 +6075,6 @@ static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = { .clsid = &CLSID_HTMLDocument, - .qi = HTMLDocumentNode_QI, .destructor = HTMLDocumentNode_destructor, .cpc_entries = HTMLDocumentNode_cpc, .clone = HTMLDocumentFragment_clone,