Jacek Caban : mshtml: Added IHTMLDOMTextNode::splitText implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Dec 22 16:20:51 CST 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun Dec 21 16:32:48 2014 +0100

mshtml: Added IHTMLDOMTextNode::splitText implementation.

---

 dlls/mshtml/htmltextnode.c    | 27 +++++++++++++++++++++++++--
 dlls/mshtml/tests/jstest.html | 16 ++++++++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/htmltextnode.c b/dlls/mshtml/htmltextnode.c
index fd4795b..411123d 100644
--- a/dlls/mshtml/htmltextnode.c
+++ b/dlls/mshtml/htmltextnode.c
@@ -152,8 +152,31 @@ static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *
 static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
 {
     HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
-    FIXME("(%p)->(%d %p)\n", This, offset, pRetNode);
-    return E_NOTIMPL;
+    HTMLDOMNode *node;
+    nsIDOMText *text;
+    nsresult nsres;
+    HRESULT hres;
+
+    TRACE("(%p)->(%d %p)\n", This, offset, pRetNode);
+
+    nsres = nsIDOMText_SplitText(This->nstext, offset, &text);
+    if(NS_FAILED(nsres)) {
+        ERR("SplitText failed: %x08x\n", nsres);
+        return E_FAIL;
+    }
+
+    if(!text) {
+        *pRetNode = NULL;
+        return S_OK;
+    }
+
+    hres = get_node(This->node.doc, (nsIDOMNode*)text, TRUE, &node);
+    nsIDOMText_Release(text);
+    if(FAILED(hres))
+        return hres;
+
+    *pRetNode = &node->IHTMLDOMNode_iface;
+    return S_OK;
 }
 
 static const IHTMLDOMTextNodeVtbl HTMLDOMTextNodeVtbl = {
diff --git a/dlls/mshtml/tests/jstest.html b/dlls/mshtml/tests/jstest.html
index 2b3634e..528c2e1 100644
--- a/dlls/mshtml/tests/jstest.html
+++ b/dlls/mshtml/tests/jstest.html
@@ -339,6 +339,21 @@ function test_language_attribute() {
     ok(elem.language === "1", "elem.language = " + elem.language);
 }
 
+function test_text_node() {
+    document.body.innerHTML = 'testing text';
+    var text = document.body.childNodes[0], text2;
+    ok(text.data == "testing text", "text.data = " + text.data);
+
+    text2 = text.splitText(7);
+    ok(text.data == "testing", "text.data = " + text.data);
+    ok(text2.data == " text", "text2.data = " + text2.data);
+    ok(text.nextSibling === text2, "text.nextSibling !== text2");
+
+    text2 = text.splitText(0);
+    ok(text.data == "", "text.data = " + text.data);
+    ok(text2.data == "testing", "text2.data = " + text2.data);
+}
+
 var globalVar = false;
 
 function runTests() {
@@ -363,6 +378,7 @@ function runTests() {
     test_customtag();
     test_whitespace_nodes();
     test_language_attribute();
+    test_text_node();
 
     var r = window.execScript("globalVar = true;");
     ok(r === undefined, "execScript returned " + r);




More information about the wine-cvs mailing list