Jacek Caban : mshtml: Get owner document from Gecko node in get_node.
Alexandre Julliard
julliard at winehq.org
Mon Feb 19 13:52:02 CST 2018
Module: wine
Branch: master
Commit: 23b1d3a79df224f14f39278731477ff3ee86f194
URL: https://source.winehq.org/git/wine.git/?a=commit;h=23b1d3a79df224f14f39278731477ff3ee86f194
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Feb 19 14:48:44 2018 +0100
mshtml: Get owner document from Gecko node in get_node.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/htmldoc.c | 19 +++++++++++++++++++
dlls/mshtml/htmlnode.c | 18 +++++++++++++++++-
dlls/mshtml/mshtml_private.h | 1 +
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 174ef20..a4e281b 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -5205,6 +5205,25 @@ static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *do
return S_OK;
}
+HRESULT get_document_node(nsIDOMDocument *dom_document, HTMLDocumentNode **ret)
+{
+ HTMLDOMNode *node;
+ HRESULT hres;
+
+ hres = get_node(NULL, (nsIDOMNode*)dom_document, FALSE, &node);
+ if(FAILED(hres))
+ return hres;
+
+ if(!node) {
+ ERR("document not initialized\n");
+ return E_FAIL;
+ }
+
+ assert(node->vtbl == &HTMLDocumentNodeImplVtbl);
+ *ret = impl_from_HTMLDOMNode(node);
+ return S_OK;
+}
+
static inline HTMLDocumentObj *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, HTMLDocumentObj, IUnknown_outer);
diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c
index 0aad491..44983bc 100644
--- a/dlls/mshtml/htmlnode.c
+++ b/dlls/mshtml/htmlnode.c
@@ -1616,8 +1616,11 @@ void init_node_cc(void)
HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDOMNode **ret)
{
+ nsIDOMDocument *dom_document;
+ HTMLDocumentNode *document;
nsISupports *unk = NULL;
nsresult nsres;
+ HRESULT hres;
nsres = nsIDOMNode_GetMshtmlNode(nsnode, &unk);
assert(nsres == NS_OK);
@@ -1633,5 +1636,18 @@ HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDO
return S_OK;
}
- return create_node(This, nsnode, ret);
+ nsres = nsIDOMNode_GetOwnerDocument(nsnode, &dom_document);
+ if(NS_FAILED(nsres) || !dom_document) {
+ ERR("GetOwnerDocument failed: %08x\n", nsres);
+ return E_FAIL;
+ }
+
+ hres = get_document_node(dom_document, &document);
+ nsIDOMDocument_Release(dom_document);
+ if(!document)
+ return E_FAIL;
+
+ hres = create_node(document, nsnode, ret);
+ htmldoc_release(&document->basedoc);
+ return hres;
}
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index de200cf..cd5b9c3 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -1074,6 +1074,7 @@ void HTMLFrameBase_destructor(HTMLFrameBase*) DECLSPEC_HIDDEN;
HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**) DECLSPEC_HIDDEN;
HRESULT get_elem(HTMLDocumentNode*,nsIDOMElement*,HTMLElement**) DECLSPEC_HIDDEN;
+HRESULT get_document_node(nsIDOMDocument*,HTMLDocumentNode**) DECLSPEC_HIDDEN;
HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement*) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list