mshtml: Split getAttribute into helper function and use it in IHTMLDOMAttribute::get_nodeValue implementation.

This commit is contained in:
Jacek Caban 2015-05-04 19:14:13 +02:00 committed by Alexandre Julliard
parent e2e1ac2bf6
commit 8e0d661927
3 changed files with 38 additions and 33 deletions

View File

@ -164,8 +164,6 @@ static HRESULT WINAPI HTMLDOMAttribute_put_nodeValue(IHTMLDOMAttribute *iface, V
static HRESULT WINAPI HTMLDOMAttribute_get_nodeValue(IHTMLDOMAttribute *iface, VARIANT *p)
{
HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
DISPPARAMS dp = {NULL, NULL, 0, 0};
EXCEPINFO ei;
TRACE("(%p)->(%p)\n", This, p);
@ -174,9 +172,7 @@ static HRESULT WINAPI HTMLDOMAttribute_get_nodeValue(IHTMLDOMAttribute *iface, V
return E_UNEXPECTED;
}
memset(&ei, 0, sizeof(ei));
return IDispatchEx_InvokeEx(&This->elem->node.dispex.IDispatchEx_iface, This->dispid, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dp, p, &ei, NULL);
return get_elem_attr_value_by_dispid(This->elem, This->dispid, 0, p);
}
static HRESULT WINAPI HTMLDOMAttribute_get_specified(IHTMLDOMAttribute *iface, VARIANT_BOOL *p)

View File

@ -606,10 +606,6 @@ static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMembe
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}
#define ATTRFLAG_CASESENSITIVE 0x0001
#define ATTRFLAG_ASSTRING 0x0002
#define ATTRFLAG_EXPANDURL 0x0004
static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
VARIANT AttributeValue, LONG lFlags)
{
@ -640,14 +636,42 @@ static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttr
LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dispParams, NULL, &excep, NULL);
}
HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, DWORD flags, VARIANT *ret)
{
DISPPARAMS dispParams = {NULL, NULL, 0, 0};
EXCEPINFO excep;
HRESULT hres;
hres = IDispatchEx_InvokeEx(&elem->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
if(FAILED(hres))
return hres;
if(flags & ATTRFLAG_ASSTRING) {
switch(V_VT(ret)) {
case VT_BSTR:
break;
case VT_DISPATCH:
IDispatch_Release(V_DISPATCH(ret));
V_VT(ret) = VT_BSTR;
V_BSTR(ret) = SysAllocString(NULL);
break;
default:
hres = VariantChangeType(ret, ret, 0, VT_BSTR);
if(FAILED(hres))
return hres;
}
}
return S_OK;
}
static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttributeName,
LONG lFlags, VARIANT *AttributeValue)
{
HTMLElement *This = impl_from_IHTMLElement(iface);
DISPID dispid;
HRESULT hres;
DISPPARAMS dispParams = {NULL, NULL, 0, 0};
EXCEPINFO excep;
TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
@ -666,28 +690,7 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
return hres;
}
hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
if(FAILED(hres))
return hres;
if(lFlags & ATTRFLAG_ASSTRING) {
switch(V_VT(AttributeValue)) {
case VT_BSTR:
break;
case VT_DISPATCH:
IDispatch_Release(V_DISPATCH(AttributeValue));
V_VT(AttributeValue) = VT_BSTR;
V_BSTR(AttributeValue) = SysAllocString(NULL);
break;
default:
hres = VariantChangeType(AttributeValue, AttributeValue, 0, VT_BSTR);
if(FAILED(hres))
return hres;
}
}
return S_OK;
return get_elem_attr_value_by_dispid(This, dispid, lFlags, AttributeValue);
}
static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,

View File

@ -976,6 +976,12 @@ HRESULT wrap_iface(IUnknown*,IUnknown*,IUnknown**) DECLSPEC_HIDDEN;
IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL) DECLSPEC_HIDDEN;
IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,nsIDOMNodeList*) DECLSPEC_HIDDEN;
IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,nsIDOMHTMLCollection*) DECLSPEC_HIDDEN;
#define ATTRFLAG_CASESENSITIVE 0x0001
#define ATTRFLAG_ASSTRING 0x0002
#define ATTRFLAG_EXPANDURL 0x0004
HRESULT get_elem_attr_value_by_dispid(HTMLElement*,DISPID,DWORD,VARIANT*) DECLSPEC_HIDDEN;
HRESULT get_elem_source_index(HTMLElement*,LONG*) DECLSPEC_HIDDEN;
nsresult get_elem_attr_value(nsIDOMHTMLElement*,const WCHAR*,nsAString*,const PRUnichar**) DECLSPEC_HIDDEN;