Jacek Caban : mshtml: Added IHTMLTxtRange::parentElement implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Sep 10 10:18:05 CDT 2007


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun Sep  9 20:17:54 2007 +0200

mshtml: Added IHTMLTxtRange::parentElement implementation.

---

 dlls/mshtml/txtrange.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/txtrange.c b/dlls/mshtml/txtrange.c
index 37a836d..f684df7 100644
--- a/dlls/mshtml/txtrange.c
+++ b/dlls/mshtml/txtrange.c
@@ -77,6 +77,16 @@ static int string_to_nscmptype(LPCWSTR str)
     return -1;
 }
 
+static PRUint16 get_node_type(nsIDOMNode *node)
+{
+    PRUint16 type = 0xfff;
+
+    if(node)
+        nsIDOMNode_GetNodeType(node, &type);
+
+    return type;
+}
+
 #define HTMLTXTRANGE_THIS(iface) DEFINE_THIS(HTMLTxtRange, HTMLTxtRange, iface)
 
 static HRESULT WINAPI HTMLTxtRange_QueryInterface(IHTMLTxtRange *iface, REFIID riid, void **ppv)
@@ -280,8 +290,31 @@ static HRESULT WINAPI HTMLTxtRange_get_text(IHTMLTxtRange *iface, BSTR *p)
 static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElement **parent)
 {
     HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, parent);
-    return E_NOTIMPL;
+    nsIDOMNode *nsnode, *tmp;
+    HTMLDOMNode *node;
+    HRESULT hres;
+
+    TRACE("(%p)->(%p)\n", This, parent);
+
+    nsIDOMRange_GetCommonAncestorContainer(This->nsrange, &nsnode);
+    while(nsnode && get_node_type(nsnode) != ELEMENT_NODE) {
+        nsIDOMNode_GetParentNode(nsnode, &tmp);
+        nsIDOMNode_Release(nsnode);
+        nsnode = tmp;
+    }
+
+    if(!nsnode) {
+        *parent = NULL;
+        return S_OK;
+    }
+
+    node = get_node(This->doc, nsnode);
+    nsIDOMNode_Release(nsnode);
+
+    hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)parent);
+
+    IHTMLDOMNode_Release(HTMLDOMNODE(node));
+    return hres;
 }
 
 static HRESULT WINAPI HTMLTxtRange_duplicate(IHTMLTxtRange *iface, IHTMLTxtRange **Duplicate)




More information about the wine-cvs mailing list