mshtml: Correctly handle comment nodes in IHTMLElement::[get|put]_title implementation.

This commit is contained in:
Jacek Caban 2010-02-08 21:50:08 +01:00 committed by Alexandre Julliard
parent 29389b8742
commit 0849a81169
2 changed files with 36 additions and 0 deletions

View File

@ -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)) {

View File

@ -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);
}