From fbe9845890fa67ddc2974a879120af416b264c30 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 11 Aug 2009 19:17:19 +0200 Subject: [PATCH] mshtml: Added IHTMLElement::get_outerHTML implementation. --- dlls/mshtml/htmlelem.c | 22 ++++++++++++++++++++-- dlls/mshtml/mshtml_private.h | 2 +- dlls/mshtml/nsembed.c | 26 ++++++++++++++------------ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 170d5a0761a..84f63095497 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -931,8 +931,26 @@ static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v) static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p) { HTMLElement *This = HTMLELEM_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString html_str; + HRESULT hres; + + WARN("(%p)->(%p) semi-stub\n", This, p); + + nsAString_Init(&html_str, NULL); + hres = nsnode_to_nsstring(This->node.nsnode, &html_str); + if(SUCCEEDED(hres)) { + const PRUnichar *html; + + nsAString_GetData(&html_str, &html); + *p = SysAllocString(html); + if(!*p) + hres = E_OUTOFMEMORY; + } + + nsAString_Finish(&html_str); + + TRACE("ret %s\n", debugstr_w(*p)); + return S_OK; } static HRESULT WINAPI HTMLElement_put_outerText(IHTMLElement *iface, BSTR v) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 6f722713804..7d21f5ec393 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -562,7 +562,7 @@ void nsAString_Finish(nsAString*); nsIInputStream *create_nsstream(const char*,PRInt32); nsICommandParams *create_nscommand_params(void); -void nsnode_to_nsstring(nsIDOMNode*,nsAString*); +HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*); void get_editor_controller(NSContainer*); void init_nsevents(NSContainer*); void add_nsevent_listener(NSContainer*,LPCWSTR); diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index a708fde33bf..d6e320675f0 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -633,7 +633,7 @@ nsresult get_nsinterface(nsISupports *iface, REFIID riid, void **ppv) return nsres; } -static void nsnode_to_nsstring_rec(nsIContentSerializer *serializer, nsIDOMNode *nsnode, nsAString *str) +static HRESULT nsnode_to_nsstring_rec(nsIContentSerializer *serializer, nsIDOMNode *nsnode, nsAString *str) { nsIDOMNodeList *node_list = NULL; PRBool has_children = FALSE; @@ -645,7 +645,7 @@ static void nsnode_to_nsstring_rec(nsIContentSerializer *serializer, nsIDOMNode nsres = nsIDOMNode_GetNodeType(nsnode, &type); if(NS_FAILED(nsres)) { ERR("GetType failed: %08x\n", nsres); - return; + return E_FAIL; } switch(type) { @@ -711,35 +711,37 @@ static void nsnode_to_nsstring_rec(nsIContentSerializer *serializer, nsIDOMNode nsIContentSerializer_AppendElementEnd(serializer, nselem, str); nsIDOMElement_Release(nselem); } + + return S_OK; } -void nsnode_to_nsstring(nsIDOMNode *nsdoc, nsAString *str) +HRESULT nsnode_to_nsstring(nsIDOMNode *nsnode, nsAString *str) { nsIContentSerializer *serializer; - nsIDOMNode *nsnode; nsresult nsres; + HRESULT hres; nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_HTMLSERIALIZER_CONTRACTID, NULL, &IID_nsIContentSerializer, (void**)&serializer); if(NS_FAILED(nsres)) { ERR("Could not get nsIContentSerializer: %08x\n", nsres); - return; + return E_FAIL; } nsres = nsIContentSerializer_Init(serializer, 0, 100, NULL, FALSE, FALSE /* FIXME */); if(NS_FAILED(nsres)) ERR("Init failed: %08x\n", nsres); - nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMNode, (void**)&nsnode); - nsnode_to_nsstring_rec(serializer, nsnode, str); - nsIDOMNode_Release(nsnode); - - nsres = nsIContentSerializer_Flush(serializer, str); - if(NS_FAILED(nsres)) - ERR("Flush failed: %08x\n", nsres); + hres = nsnode_to_nsstring_rec(serializer, nsnode, str); + if(SUCCEEDED(hres)) { + nsres = nsIContentSerializer_Flush(serializer, str); + if(NS_FAILED(nsres)) + ERR("Flush failed: %08x\n", nsres); + } nsIContentSerializer_Release(serializer); + return hres; } void get_editor_controller(NSContainer *This)