Module: wine Branch: master Commit: 0849a81169f1feb915a9265b01be843b0f93e456 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0849a81169f1feb915a9265b01...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Feb 8 21:50:08 2010 +0100
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(+), 0 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 73c623a..e77c1dc 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 aa09d9e..c0128a6 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); }