Jacek Caban : mshtml: Added document fragment cloneNode implementation.

Alexandre Julliard julliard at winehq.org
Mon Nov 15 13:28:48 CST 2010


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun Nov 14 14:43:18 2010 +0100

mshtml: Added document fragment cloneNode implementation.

---

 dlls/mshtml/htmldoc.c         |   26 +++++++++++++++++++++++---
 dlls/mshtml/tests/jstest.html |    5 +++++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 28059cc..f0b7056 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1908,14 +1908,34 @@ static HRESULT HTMLDocumentNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HT
     return E_NOTIMPL;
 }
 
-#undef HTMLDOCNODE_NODE_THIS
-
 static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
     HTMLDocumentNode_QI,
     HTMLDocumentNode_destructor,
     HTMLDocumentNode_clone
 };
 
+static HRESULT HTMLDocumentFragment_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
+{
+    HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(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;
+}
+
+#undef HTMLDOCNODE_NODE_THIS
+
+static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
+    HTMLDocumentNode_QI,
+    HTMLDocumentNode_destructor,
+    HTMLDocumentFragment_clone
+};
+
 static const tid_t HTMLDocumentNode_iface_tids[] = {
     IHTMLDOMNode_tid,
     IHTMLDOMNode2_tid,
@@ -1998,7 +2018,7 @@ HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node,
         return E_OUTOFMEMORY;
 
     HTMLDOMNode_Init(doc_node, &doc_frag->node, nsnode);
-    doc_frag->node.vtbl = &HTMLDocumentNodeImplVtbl;
+    doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
     doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
 
     htmldoc_addref(&doc_frag->basedoc);
diff --git a/dlls/mshtml/tests/jstest.html b/dlls/mshtml/tests/jstest.html
index ae224cc..39f2620 100644
--- a/dlls/mshtml/tests/jstest.html
+++ b/dlls/mshtml/tests/jstest.html
@@ -38,6 +38,11 @@ function test_createDocumentFragment() {
     ok(fragment.parentWindow === window, "fragment.parentWindow != window");
     ok(fragment.nodeType === 11, "fragment.nodeType = " + fragment.nodeType);
     ok(fragment.nodeName === "#document-fragment", "fragment.nodeName = " + fragment.nodeName);
+
+    var cloned = fragment.cloneNode(true);
+    ok(cloned.parentWindow === window, "cloned.parentWindow != window");
+    ok(cloned.nodeType === 11, "cloned.nodeType = " + cloned.nodeType);
+    ok(cloned.nodeName === "#document-fragment", "cloned.nodeName = " + cloned.nodeName);
 }
 
 var globalVar = false;




More information about the wine-cvs mailing list