BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr) { switch(V_VT(v)) { case VT_BSTR: nsAString_Init(nsstr, V_BSTR(v)); return TRUE; case VT_I4: { PRUnichar buf[10]; static const WCHAR formatW[] = {'#','%','x',0}; wsprintfW(buf, formatW, V_I4(v)); nsAString_Init(nsstr, buf); return TRUE; } default: FIXME("invalid color %s\n", debugstr_variant(v)); } return FALSE; }
static HRESULT navigate_anchor(HTMLAnchorElement *This) { nsAString href_str, target_str; nsresult nsres; HRESULT hres; nsAString_Init(&target_str, NULL); nsres = nsIDOMHTMLAnchorElement_GetTarget(This->nsanchor, &target_str); if(NS_SUCCEEDED(nsres)) { const PRUnichar *target; nsAString_GetData(&target_str, &target); if(*target) { FIXME("Navigating to target %s is not implemented\n", debugstr_w(target)); nsAString_Finish(&target_str); return S_OK; } } nsAString_Finish(&target_str); nsAString_Init(&href_str, NULL); nsres = nsIDOMHTMLAnchorElement_GetHref(This->nsanchor, &href_str); if(NS_SUCCEEDED(nsres)) { const PRUnichar *href; nsAString_GetData(&href_str, &href); if(*href) { HTMLWindow *window = This->element.node.doc->basedoc.window; hres = navigate_url(window, href, window->url); }else { TRACE("empty href\n"); hres = S_OK; } } nsAString_Finish(&href_str); return hres; }
static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p) { HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface); nsAString nsstr; const PRUnichar *strdata; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); if(This->nsframe) { nsAString_Init(&nsstr, NULL); nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr); }else if(This->nsiframe) { nsAString_Init(&nsstr, NULL); nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr); }else { ERR("No attached ns frame object\n"); return E_UNEXPECTED; } if(NS_FAILED(nsres)) { ERR("GetScrolling failed: 0x%08x\n", nsres); nsAString_Finish(&nsstr); return E_FAIL; } nsAString_GetData(&nsstr, &strdata); if(*strdata) *p = SysAllocString(strdata); else *p = SysAllocString(autoW); nsAString_Finish(&nsstr); return *p ? S_OK : E_OUTOFMEMORY; }
void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem) { const PRUnichar *attr_value; nsAString attr_name_str, attr_value_str; IDispatch *disp; HTMLDOMNode *node; int i; nsresult nsres; HRESULT hres; nsAString_Init(&attr_value_str, NULL); nsAString_Init(&attr_name_str, NULL); for(i=0; i < EVENTID_LAST; i++) { nsAString_SetData(&attr_name_str, event_info[i].attr_name); nsres = nsIDOMElement_GetAttribute(nselem, &attr_name_str, &attr_value_str); if(NS_SUCCEEDED(nsres)) { nsAString_GetData(&attr_value_str, &attr_value); if(!*attr_value) continue; TRACE("%p.%s = %s\n", nselem, debugstr_w(event_info[i].attr_name), debugstr_w(attr_value)); disp = script_parse_event(doc->basedoc.window, attr_value); if(disp) { hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node); if(SUCCEEDED(hres)) set_event_handler_disp(get_node_event_target(node), node->nsnode, node->doc, i, disp); IDispatch_Release(disp); } } } nsAString_Finish(&attr_value_str); nsAString_Finish(&attr_name_str); }
static HRESULT WINAPI HTMLXMLHttpRequest_get_responseText(IHTMLXMLHttpRequest *iface, BSTR *p) { HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface); nsAString nsstr; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); if(!p) return E_POINTER; nsAString_Init(&nsstr, NULL); nsres = nsIXMLHttpRequest_GetResponseText(This->nsxhr, &nsstr); return return_nsstr(nsres, &nsstr, p); }
HRESULT HTMLCurrentStyle_Create(HTMLElement *elem, IHTMLCurrentStyle **p) { nsIDOMCSSStyleDeclaration *nsstyle; nsIDOMWindow *nsview; nsAString nsempty_str; HTMLCurrentStyle *ret; nsresult nsres; if(!elem->node.doc->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsres = nsIDOMHTMLDocument_GetDefaultView(elem->node.doc->nsdoc, &nsview); if(NS_FAILED(nsres)) { ERR("GetDefaultView failed: %08x\n", nsres); return E_FAIL; } nsAString_Init(&nsempty_str, NULL); nsres = nsIDOMWindow_GetComputedStyle(nsview, (nsIDOMElement*)elem->nselem, &nsempty_str, &nsstyle); nsAString_Finish(&nsempty_str); if(NS_FAILED(nsres)) { ERR("GetComputedStyle failed: %08x\n", nsres); return E_FAIL; } ret = heap_alloc_zero(sizeof(HTMLCurrentStyle)); if(!ret) { nsIDOMCSSStyleDeclaration_Release(nsstyle); return E_OUTOFMEMORY; } ret->IHTMLCurrentStyle_iface.lpVtbl = &HTMLCurrentStyleVtbl; ret->IHTMLCurrentStyle2_iface.lpVtbl = &HTMLCurrentStyle2Vtbl; ret->IHTMLCurrentStyle3_iface.lpVtbl = &HTMLCurrentStyle3Vtbl; ret->IHTMLCurrentStyle4_iface.lpVtbl = &HTMLCurrentStyle4Vtbl; ret->ref = 1; ret->nsstyle = nsstyle; init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLCurrentStyle_iface, &HTMLCurrentStyle_dispex); IHTMLElement_AddRef(&elem->IHTMLElement_iface); ret->elem = elem; *p = &ret->IHTMLCurrentStyle_iface; return S_OK; }
static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR v) { HTMLOptionElement *This = HTMLOPTION_THIS(iface); nsIDOMText *text_node; nsAString text_str; nsIDOMNode *tmp; nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); if(!This->element.node.doc->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } while(1) { nsIDOMNode *child; nsres = nsIDOMHTMLOptionElement_GetFirstChild(This->nsoption, &child); if(NS_FAILED(nsres) || !child) break; nsres = nsIDOMHTMLOptionElement_RemoveChild(This->nsoption, child, &tmp); nsIDOMNode_Release(child); if(NS_SUCCEEDED(nsres)) { nsIDOMNode_Release(tmp); } else { ERR("RemoveChild failed: %08x\n", nsres); break; } } nsAString_Init(&text_str, v); nsres = nsIDOMHTMLDocument_CreateTextNode(This->element.node.doc->nsdoc, &text_str, &text_node); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { ERR("CreateTextNode failed: %08x\n", nsres); return E_FAIL; } nsres = nsIDOMHTMLOptionElement_AppendChild(This->nsoption, (nsIDOMNode*)text_node, &tmp); if(NS_SUCCEEDED(nsres)) nsIDOMNode_Release(tmp); else ERR("AppendChild failed: %08x\n", nsres); return S_OK; }
static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR v) { HTMLInputElement *This = HTMLINPUT_THIS(iface); nsAString val_str; nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); nsAString_Init(&val_str, v); nsres = nsIDOMHTMLInputElement_SetValue(This->nsinput, &val_str); nsAString_Finish(&val_str); if(NS_FAILED(nsres)) ERR("SetValue failed: %08x\n", nsres); return S_OK; }
static HRESULT variant_to_nsastr(VARIANT var, nsAString *ret) { switch(V_VT(&var)) { case VT_NULL: case VT_ERROR: case VT_EMPTY: nsAString_Init(ret, NULL); return S_OK; case VT_BSTR: nsAString_InitDepend(ret, V_BSTR(&var)); return S_OK; default: FIXME("Unsupported VARIANT: %s\n", debugstr_variant(&var)); return E_INVALIDARG; } }
static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v) { HTMLImgElement *This = HTMLIMG_THIS(iface); nsAString src_str; nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); nsAString_Init(&src_str, v); nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str); nsAString_Finish(&src_str); if(NS_FAILED(nsres)) ERR("SetSrc failed: %08x\n", nsres); return NS_OK; }
static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v) { HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface); nsAString nstype_str; nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); nsAString_Init(&nstype_str, v); nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str); if (NS_FAILED(nsres)) ERR("SetType failed: %08x\n", nsres); nsAString_Finish (&nstype_str); return S_OK; }
static void remove_child_attr(nsIDOMElement *elem, LPCWSTR tag, nsAString *attr_str) { cpp_bool has_children; UINT32 child_cnt, i; nsIDOMNode *child_node; nsIDOMNodeList *node_list; UINT16 node_type; nsIDOMElement_HasChildNodes(elem, &has_children); if(!has_children) return; nsIDOMElement_GetChildNodes(elem, &node_list); nsIDOMNodeList_GetLength(node_list, &child_cnt); for(i=0; i<child_cnt; i++) { nsIDOMNodeList_Item(node_list, i, &child_node); nsIDOMNode_GetNodeType(child_node, &node_type); if(node_type == ELEMENT_NODE) { nsIDOMElement *child_elem; nsAString tag_str; const PRUnichar *ctag; nsIDOMNode_QueryInterface(child_node, &IID_nsIDOMElement, (void**)&child_elem); nsAString_Init(&tag_str, NULL); nsIDOMElement_GetTagName(child_elem, &tag_str); nsAString_GetData(&tag_str, &ctag); if(!strcmpiW(ctag, tag)) /* FIXME: remove node if there are no more attributes */ nsIDOMElement_RemoveAttribute(child_elem, attr_str); nsAString_Finish(&tag_str); remove_child_attr(child_elem, tag, attr_str); nsIDOMElement_Release(child_elem); } nsIDOMNode_Release(child_node); } nsIDOMNodeList_Release(node_list); }
static HRESULT WINAPI HTMLMetaElement_get_name(IHTMLMetaElement *iface, BSTR *p) { HTMLMetaElement *This = impl_from_IHTMLMetaElement(iface); nsAString name_str, val_str; nsresult nsres; static const PRUnichar nameW[] = {'n','a','m','e',0}; TRACE("(%p)->(%p)\n", This, p); nsAString_InitDepend(&name_str, nameW); nsAString_Init(&val_str, NULL); nsres = nsIDOMHTMLElement_GetAttribute(This->element.nselem, &name_str, &val_str); nsAString_Finish(&name_str); return return_nsstr(nsres, &val_str, p); }
static HRESULT WINAPI HTMLMetaElement_get_httpEquiv(IHTMLMetaElement *iface, BSTR *p) { HTMLMetaElement *This = impl_from_IHTMLMetaElement(iface); nsAString httpequiv_str, val_str; nsresult nsres; static const PRUnichar httpEquivW[] = {'h','t','t','p','-','e','q','u','i','v',0}; TRACE("(%p)->(%p)\n", This, p); nsAString_InitDepend(&httpequiv_str, httpEquivW); nsAString_Init(&val_str, NULL); nsres = nsIDOMHTMLElement_GetAttribute(This->element.nselem, &httpequiv_str, &val_str); nsAString_Finish(&httpequiv_str); return return_nsstr(nsres, &val_str, p); }
static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p) { HTMLElement *This = impl_from_IHTMLElement2(iface); nsAString dir_str; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); if(!This->nselem) { *p = NULL; return S_OK; } nsAString_Init(&dir_str, NULL); nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str); return return_nsstr(nsres, &dir_str, p); }
static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p) { HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface); nsAString alink_str; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&alink_str, NULL); nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str); if(NS_FAILED(nsres)) ERR("GetALink failed: %08x\n", nsres); nscolor_to_variant(&alink_str, p); nsAString_Finish(&alink_str); return S_OK; }
static DWORD query_align_status(HTMLDocument *This, const WCHAR *align) { DWORD ret = OLECMDF_SUPPORTED | OLECMDF_ENABLED; nsAString justify_str; cpp_bool b; nsresult nsres; if(This->doc_obj->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE) return OLECMDF_SUPPORTED; nsAString_Init(&justify_str, align); nsres = nsIDOMHTMLDocument_QueryCommandState(This->doc_node->nsdoc, &justify_str, &b); nsAString_Finish(&justify_str); if(NS_SUCCEEDED(nsres) && b) ret |= OLECMDF_LATCHED; return ret; }
static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p) { HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface); nsAString nsstr; nsresult nsres; HRESULT hres = S_OK; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&nsstr, NULL); if(This->nsframe) nsres = nsIDOMHTMLFrameElement_GetMarginHeight(This->nsframe, &nsstr); else nsres = nsIDOMHTMLIFrameElement_GetMarginHeight(This->nsiframe, &nsstr); if(NS_SUCCEEDED(nsres)) { const PRUnichar *str, *end; nsAString_GetData(&nsstr, &str); if(*str) { BSTR ret; end = strstrW(str, pxW); if(!end) end = str+strlenW(str); ret = SysAllocStringLen(str, end-str); if(ret) { V_VT(p) = VT_BSTR; V_BSTR(p) = ret; }else { hres = E_OUTOFMEMORY; } }else { V_VT(p) = VT_BSTR; V_BSTR(p) = NULL; } }else { ERR("SetMarginHeight failed: %08x\n", nsres); hres = E_FAIL; } nsAString_Finish(&nsstr); return hres; }
static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *event) { nsEventListener *This = impl_from_nsIDOMEventListener(iface); HTMLDocumentNode *doc = This->This->doc; const PRUnichar *type; nsIDOMEventTarget *event_target; nsIDOMNode *nsnode; nsAString type_str; eventid_t eid; nsresult nsres; TRACE("%p\n", This->This); if(!doc) { WARN("NULL doc\n"); return NS_OK; } nsAString_Init(&type_str, NULL); nsIDOMEvent_GetType(event, &type_str); nsAString_GetData(&type_str, &type); eid = str_to_eid(type); nsAString_Finish(&type_str); nsres = nsIDOMEvent_GetTarget(event, &event_target); if(NS_FAILED(nsres) || !event_target) { ERR("GetEventTarget failed: %08x\n", nsres); return NS_OK; } nsres = nsIDOMEventTarget_QueryInterface(event_target, &IID_nsIDOMNode, (void**)&nsnode); nsIDOMEventTarget_Release(event_target); if(NS_FAILED(nsres)) { ERR("Could not get nsIDOMNode: %08x\n", nsres); return NS_OK; } fire_event(doc, eid, TRUE, nsnode, event, NULL); nsIDOMNode_Release(nsnode); return NS_OK; }
static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface, VARIANT tagName, IDispatch **pdisp) { HTMLElementCollection *This = impl_from_IHTMLElementCollection(iface); DWORD i; nsAString tag_str; const PRUnichar *tag; elem_vector_t buf = {NULL, 0, 8}; if(V_VT(&tagName) != VT_BSTR) { WARN("Invalid arg\n"); return DISP_E_MEMBERNOTFOUND; } TRACE("(%p)->(%s %p)\n", This, debugstr_w(V_BSTR(&tagName)), pdisp); buf.buf = heap_alloc(buf.size*sizeof(HTMLElement*)); nsAString_Init(&tag_str, NULL); for(i=0; i<This->len; i++) { if(!This->elems[i]->nselem) continue; nsIDOMHTMLElement_GetTagName(This->elems[i]->nselem, &tag_str); nsAString_GetData(&tag_str, &tag); if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, tag, -1, V_BSTR(&tagName), -1) == CSTR_EQUAL) { node_addref(&This->elems[i]->node); elem_vector_add(&buf, This->elems[i]); } } nsAString_Finish(&tag_str); elem_vector_normalize(&buf); TRACE("fount %d tags\n", buf.len); *pdisp = (IDispatch*)HTMLElementCollection_Create(buf.buf, buf.len); return S_OK; }
static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p) { HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface); nsAString nsstr; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); if(!This->nsframe && !This->nsiframe) { ERR("No attached ns frame object\n"); return E_UNEXPECTED; } nsAString_Init(&nsstr, NULL); if(This->nsframe) nsres = nsIDOMHTMLFrameElement_GetFrameBorder(This->nsframe, &nsstr); else nsres = nsIDOMHTMLIFrameElement_GetFrameBorder(This->nsiframe, &nsstr); return return_nsstr(nsres, &nsstr, p); }
static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p) { HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface); const PRUnichar *nstype; nsAString nstype_str; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&nstype_str, NULL); nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str); if(NS_FAILED(nsres)) ERR("GetType failed: %08x\n", nsres); nsAString_GetData(&nstype_str, &nstype); *p = *nstype ? SysAllocString(nstype) : NULL; nsAString_Finish(&nstype_str); return S_OK; }
static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BSTR *p) { HTMLOptionElement *This = HTMLOPTION_THIS(iface); nsAString value_str; const PRUnichar *value; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&value_str, NULL); nsres = nsIDOMHTMLOptionElement_GetValue(This->nsoption, &value_str); if(NS_SUCCEEDED(nsres)) { nsAString_GetData(&value_str, &value); *p = SysAllocString(value); } else { ERR("GetValue failed: %08x\n", nsres); *p = NULL; } nsAString_Finish(&value_str); return S_OK; }
static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p) { HTMLImgElement *This = HTMLIMG_THIS(iface); nsAString alt_str; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&alt_str, NULL); nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str); if(NS_SUCCEEDED(nsres)) { const PRUnichar *alt; nsAString_GetData(&alt_str, &alt); *p = *alt ? SysAllocString(alt) : NULL; } else { ERR("GetAlt failed: %08x\n", nsres); } nsAString_Finish(&alt_str); return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL; }
static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p) { HTMLDocument *This = impl_from_IHTMLDocument5(iface); nsAString mode_str; const PRUnichar *mode; TRACE("(%p)->(%p)\n", This, p); if(!This->doc_node->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsAString_Init(&mode_str, NULL); nsIDOMHTMLDocument_GetCompatMode(This->doc_node->nsdoc, &mode_str); nsAString_GetData(&mode_str, &mode); *p = SysAllocString(mode); nsAString_Finish(&mode_str); return S_OK; }
static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BSTR v, IHTMLElementCollection **pelColl) { HTMLElement *This = HTMLELEM2_THIS(iface); nsIDOMNodeList *nslist; nsAString tag_str; nsresult nsres; TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl); nsAString_Init(&tag_str, v); nsres = nsIDOMHTMLElement_GetElementsByTagName(This->nselem, &tag_str, &nslist); nsAString_Finish(&tag_str); if(NS_FAILED(nsres)) { ERR("GetElementByTagName failed: %08x\n", nsres); return E_FAIL; } *pelColl = create_collection_from_nodelist(This->node.doc, (IUnknown*)HTMLELEM(This), nslist); nsIDOMNodeList_Release(nslist); return S_OK; }
static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR *p) { HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface); nsAString text_str; const PRUnichar *text; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&text_str, NULL); nsres = nsIDOMHTMLOptionElement_GetText(This->nsoption, &text_str); if(NS_SUCCEEDED(nsres)) { nsAString_GetData(&text_str, &text); *p = SysAllocString(text); }else { ERR("GetText failed: %08x\n", nsres); *p = NULL; } nsAString_Finish(&text_str); return S_OK; }
static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p) { HTMLImgElement *This = impl_from_IHTMLImgElement(iface); nsAString strName; nsresult nsres; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&strName, NULL); nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &strName); if(NS_SUCCEEDED(nsres)) { const PRUnichar *str; nsAString_GetData(&strName, &str); *p = *str ? SysAllocString(str) : NULL; }else { ERR("GetName failed: %08x\n", nsres); } nsAString_Finish(&strName); return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL; }
static HRESULT get_doc_string(HTMLDocumentNode *This, char **str) { nsIDOMNode *nsnode; LPCWSTR strw; nsAString nsstr; nsresult nsres; HRESULT hres; if(!This->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode); if(NS_FAILED(nsres)) { ERR("Could not get nsIDOMNode failed: %08x\n", nsres); return E_FAIL; } nsAString_Init(&nsstr, NULL); hres = nsnode_to_nsstring(nsnode, &nsstr); nsIDOMNode_Release(nsnode); if(FAILED(hres)) { nsAString_Finish(&nsstr); return hres; } nsAString_GetData(&nsstr, &strw); TRACE("%s\n", debugstr_w(strw)); *str = heap_strdupWtoA(strw); nsAString_Finish(&nsstr); if(!*str) return E_OUTOFMEMORY; return S_OK; }
static HRESULT WINAPI HTMLDOMNode_get_nodeValue(IHTMLDOMNode *iface, VARIANT *p) { HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface); const PRUnichar *val; nsAString val_str; TRACE("(%p)->(%p)\n", This, p); nsAString_Init(&val_str, NULL); nsIDOMNode_GetNodeValue(This->nsnode, &val_str); nsAString_GetData(&val_str, &val); if(*val) { V_VT(p) = VT_BSTR; V_BSTR(p) = SysAllocString(val); }else { V_VT(p) = VT_NULL; } nsAString_Finish(&val_str); return S_OK; }