Jacek Caban : mshtml: Added IHTMLDOMNode3:: compareDocumentPosition implementation.

Alexandre Julliard julliard at winehq.org
Thu Nov 23 15:04:45 CST 2017


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Nov 23 17:37:03 2017 +0100

mshtml: Added IHTMLDOMNode3::compareDocumentPosition implementation.

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

---

 dlls/mshtml/htmlnode.c        | 21 +++++++++++++++++++--
 dlls/mshtml/tests/elements.js | 27 ++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c
index 70b8758..0aad491 100644
--- a/dlls/mshtml/htmlnode.c
+++ b/dlls/mshtml/htmlnode.c
@@ -1341,8 +1341,25 @@ static HRESULT WINAPI HTMLDOMNode3_isSameNode(IHTMLDOMNode3 *iface, IHTMLDOMNode
 static HRESULT WINAPI HTMLDOMNode3_compareDocumentPosition(IHTMLDOMNode3 *iface, IHTMLDOMNode *otherNode, USHORT *flags)
 {
     HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
-    FIXME("(%p)->()\n", This);
-    return E_NOTIMPL;
+    HTMLDOMNode *other;
+    UINT16 position;
+    nsresult nsres;
+
+    TRACE("(%p)->()\n", This);
+
+    other = get_node_obj(otherNode);
+    if(!other)
+        return E_INVALIDARG;
+
+    nsres = nsIDOMNode_CompareDocumentPosition(This->nsnode, other->nsnode, &position);
+    IHTMLDOMNode_Release(&other->IHTMLDOMNode_iface);
+    if(NS_FAILED(nsres)) {
+        ERR("failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    *flags = position;
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLDOMNode3_isSupported(IHTMLDOMNode3 *iface, BSTR feature, VARIANT version, VARIANT_BOOL *pfisSupported)
diff --git a/dlls/mshtml/tests/elements.js b/dlls/mshtml/tests/elements.js
index 3912e9a..6e193ee 100644
--- a/dlls/mshtml/tests/elements.js
+++ b/dlls/mshtml/tests/elements.js
@@ -148,11 +148,36 @@ function test_query_selector() {
     next_test();
 }
 
+function test_compare_position() {
+    document.body.innerHTML = '<div><div></div><div></div></div>';
+
+    var parent = document.body.firstChild;
+    var child1 = parent.firstChild;
+    var child2 = child1.nextSibling;
+    var elem = document.createElement("div");
+
+    function compare_position(node1, node2, expected_result, ignore_mask) {
+        var cmp = node1.compareDocumentPosition(node2);
+        ok((cmp & ~ignore_mask) == expected_result,
+           "compareDocumentPosition returned " + cmp + " expected " + expected_result);
+    }
+
+    compare_position(child1, child2, 4);
+    compare_position(child2, child1, 2);
+    compare_position(parent, child1, 0x14);
+    compare_position(parent, child2, 0x14);
+    compare_position(parent, elem, 0x21, 6);
+    compare_position(elem, parent, 0x21, 6);
+
+    next_test();
+}
+
 var tests = [
     test_input_selection,
     test_textContent,
     test_ElementTraversal,
     test_getElementsByClassName,
     test_head,
-    test_query_selector
+    test_query_selector,
+    test_compare_position
 ];




More information about the wine-cvs mailing list