From 0849a81169f1feb915a9265b01be843b0f93e456 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 8 Feb 2010 21:50:08 +0100 Subject: [PATCH] mshtml: Correctly handle comment nodes in IHTMLElement::[get|put]_title implementation. --- dlls/mshtml/htmlelem.c | 33 +++++++++++++++++++++++++++++++++ dlls/mshtml/tests/dom.c | 3 +++ 2 files changed, 36 insertions(+) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 73c623a38ae..e77c1dc4c42 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -593,6 +593,8 @@ static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch ** return S_OK; } +static const WCHAR titleW[] = {'t','i','t','l','e',0}; + static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v) { HTMLElement *This = HTMLELEM_THIS(iface); @@ -601,6 +603,20 @@ static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v) TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + if(!This->nselem) { + VARIANT *var; + HRESULT hres; + + hres = dispex_get_dprop_ref(&This->node.dispex, titleW, TRUE, &var); + if(FAILED(hres)) + return hres; + + VariantClear(var); + V_VT(var) = VT_BSTR; + V_BSTR(var) = v ? SysAllocString(v) : NULL; + return S_OK; + } + nsAString_InitDepend(&title_str, v); nsres = nsIDOMHTMLElement_SetTitle(This->nselem, &title_str); nsAString_Finish(&title_str); @@ -618,6 +634,23 @@ static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p) TRACE("(%p)->(%p)\n", This, p); + if(!This->nselem) { + VARIANT *var; + HRESULT hres; + + hres = dispex_get_dprop_ref(&This->node.dispex, titleW, FALSE, &var); + if(hres == DISP_E_UNKNOWNNAME) { + *p = NULL; + }else if(V_VT(var) != VT_BSTR) { + FIXME("title = %s\n", debugstr_variant(var)); + return E_FAIL; + }else { + *p = V_BSTR(var) ? SysAllocString(V_BSTR(var)) : NULL; + } + + return S_OK; + } + nsAString_Init(&title_str, NULL); nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str); if(NS_SUCCEEDED(nsres)) { diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index aa09d9e97b7..c0128a6d4d7 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -5908,6 +5908,9 @@ static void test_create_elems(IHTMLDocument2 *doc) ok(type == 8, "type=%d, expected 8\n", type); test_node_get_value_str((IUnknown*)comment, "testing"); + test_elem_title((IUnknown*)comment, NULL); + test_elem_set_title((IUnknown*)comment, "comment title"); + test_elem_title((IUnknown*)comment, "comment title"); IHTMLDOMNode_Release(comment); } -- 2.11.4.GIT