Commit b79ef676 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added new helper for GetAttribute based getters and use it in…

mshtml: Added new helper for GetAttribute based getters and use it in IHTMLMetaElement implementation.
parent 39e24713
......@@ -175,6 +175,23 @@ nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsASt
return NS_OK;
}
HRESULT elem_string_attr_getter(HTMLElement *elem, const WCHAR *name, BSTR *p)
{
const PRUnichar *val;
nsAString val_str;
nsresult nsres;
nsres = get_elem_attr_value(elem->nselem, name, &val_str, &val);
if(NS_FAILED(nsres))
return E_FAIL;
TRACE("%s: returning %s\n", debugstr_w(name), debugstr_w(val));
*p = SysAllocString(val);
nsAString_Finish(&val_str);
return *p ? S_OK : E_OUTOFMEMORY;
}
typedef struct
{
DispatchEx dispex;
......
......@@ -104,19 +104,11 @@ static HRESULT WINAPI HTMLMetaElement_put_httpEquiv(IHTMLMetaElement *iface, BST
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);
return elem_string_attr_getter(&This->element, httpEquivW, p);
}
static HRESULT WINAPI HTMLMetaElement_put_content(IHTMLMetaElement *iface, BSTR v)
......@@ -129,19 +121,11 @@ static HRESULT WINAPI HTMLMetaElement_put_content(IHTMLMetaElement *iface, BSTR
static HRESULT WINAPI HTMLMetaElement_get_content(IHTMLMetaElement *iface, BSTR *p)
{
HTMLMetaElement *This = impl_from_IHTMLMetaElement(iface);
nsAString content_str, val_str;
nsresult nsres;
static const PRUnichar contentW[] = {'c','o','n','t','e','n','t',0};
TRACE("(%p)->(%p)\n", This, p);
nsAString_InitDepend(&content_str, contentW);
nsAString_Init(&val_str, NULL);
nsres = nsIDOMHTMLElement_GetAttribute(This->element.nselem, &content_str, &val_str);
nsAString_Finish(&content_str);
return return_nsstr(nsres, &val_str, p);
return elem_string_attr_getter(&This->element, contentW, p);
}
static HRESULT WINAPI HTMLMetaElement_put_name(IHTMLMetaElement *iface, BSTR v)
......@@ -154,19 +138,11 @@ static HRESULT WINAPI HTMLMetaElement_put_name(IHTMLMetaElement *iface, BSTR v)
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);
return elem_string_attr_getter(&This->element, nameW, p);
}
static HRESULT WINAPI HTMLMetaElement_put_url(IHTMLMetaElement *iface, BSTR v)
......
......@@ -960,6 +960,7 @@ IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,nsIDOM
IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,nsIDOMHTMLCollection*) DECLSPEC_HIDDEN;
nsresult get_elem_attr_value(nsIDOMHTMLElement*,const WCHAR*,nsAString*,const PRUnichar**) DECLSPEC_HIDDEN;
HRESULT elem_string_attr_getter(HTMLElement*,const WCHAR*,BSTR*) DECLSPEC_HIDDEN;
/* commands */
typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment