Jacek Caban : mshtml: Added IHTMLElement::put_outerText implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 31 11:42:56 CDT 2016


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Mar 31 14:50:33 2016 +0200

mshtml: Added IHTMLElement::put_outerText implementation.

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

---

 dlls/mshtml/htmlbody.c       | 14 ++++++++++++-
 dlls/mshtml/htmlelem.c       | 47 ++++++++++++++++++++++++++++++++++++++++++--
 dlls/mshtml/mshtml_private.h |  1 +
 3 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c
index 39b1faf..a04e7c3 100644
--- a/dlls/mshtml/htmlbody.c
+++ b/dlls/mshtml/htmlbody.c
@@ -25,6 +25,7 @@
 #include "winbase.h"
 #include "winuser.h"
 #include "ole2.h"
+#include "mshtmdid.h"
 
 #include "wine/debug.h"
 
@@ -838,6 +839,16 @@ static BOOL HTMLBodyElement_is_text_edit(HTMLDOMNode *iface)
     return TRUE;
 }
 
+static BOOL HTMLBodyElement_is_settable(HTMLDOMNode *iface, DISPID dispid)
+{
+    switch(dispid) {
+    case DISPID_IHTMLELEMENT_OUTERTEXT:
+        return FALSE;
+    default:
+        return TRUE;
+    }
+}
+
 static const cpc_entry_t HTMLBodyElement_cpc[] = {
     {&DIID_HTMLTextContainerEvents},
     {&IID_IPropertyNotifySink},
@@ -863,7 +874,8 @@ static const NodeImplVtbl HTMLBodyElementImplVtbl = {
     NULL,
     HTMLBodyElement_traverse,
     HTMLBodyElement_unlink,
-    HTMLBodyElement_is_text_edit
+    HTMLBodyElement_is_text_edit,
+    HTMLBodyElement_is_settable
 };
 
 static const tid_t HTMLBodyElement_iface_tids[] = {
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 6d00063..ce1ed8a 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -1552,8 +1552,51 @@ static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
 static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v)
 {
     HTMLElement *This = impl_from_IHTMLElement(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    nsIDOMText *text_node;
+    nsIDOMRange *range;
+    nsAString nsstr;
+    nsresult nsres;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    if(This->node.vtbl->is_settable && !This->node.vtbl->is_settable(&This->node, DISPID_IHTMLELEMENT_OUTERTEXT)) {
+        WARN("Called on element that does not support setting the property.\n");
+        return 0x800a0258; /* undocumented error code */
+    }
+
+    if(!This->node.doc->nsdoc) {
+        FIXME("NULL nsdoc\n");
+        return E_FAIL;
+    }
+
+    nsAString_InitDepend(&nsstr, v);
+    nsres = nsIDOMHTMLDocument_CreateTextNode(This->node.doc->nsdoc, &nsstr, &text_node);
+    nsAString_Finish(&nsstr);
+    if(NS_FAILED(nsres)) {
+        ERR("CreateTextNode failed\n");
+        return E_FAIL;
+    }
+
+    nsres = nsIDOMHTMLDocument_CreateRange(This->node.doc->nsdoc, &range);
+    if(NS_SUCCEEDED(nsres)) {
+        nsres = nsIDOMRange_SelectNode(range, This->node.nsnode);
+        if(NS_SUCCEEDED(nsres))
+            nsres = nsIDOMRange_DeleteContents(range);
+        if(NS_SUCCEEDED(nsres))
+            nsres = nsIDOMRange_InsertNode(range, (nsIDOMNode*)text_node);
+        if(NS_SUCCEEDED(nsres))
+            nsres = nsIDOMRange_SelectNodeContents(range, This->node.nsnode);
+        if(NS_SUCCEEDED(nsres))
+            nsres = nsIDOMRange_DeleteContents(range);
+        nsIDOMRange_Release(range);
+    }
+    nsIDOMText_Release(text_node);
+    if(NS_FAILED(nsres)) {
+        ERR("failed to set text: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLElement_get_outerText(IHTMLElement *iface, BSTR *p)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 37c33d5..fe69487 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -677,6 +677,7 @@ typedef struct {
     void (*traverse)(HTMLDOMNode*,nsCycleCollectionTraversalCallback*);
     void (*unlink)(HTMLDOMNode*);
     BOOL (*is_text_edit)(HTMLDOMNode*);
+    BOOL (*is_settable)(HTMLDOMNode*,DISPID);
 } NodeImplVtbl;
 
 struct HTMLDOMNode {




More information about the wine-cvs mailing list