From 14a0e875cede6f972f955e96198e9ddadfc2120e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 22 Aug 2013 17:13:56 +0200 Subject: [PATCH] mshtml: Added IHTMLLabelElement::htmlFor property implementation. --- dlls/mshtml/htmlinput.c | 45 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index 4d304b2b23f..e6fb1841a3b 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -43,6 +43,8 @@ typedef struct { nsIDOMHTMLInputElement *nsinput; } HTMLInputElement; +static const WCHAR forW[] = {'f','o','r',0}; + static inline HTMLInputElement *impl_from_IHTMLInputElement(IHTMLInputElement *iface) { return CONTAINING_RECORD(iface, HTMLInputElement, IHTMLInputElement_iface); @@ -1311,15 +1313,50 @@ static HRESULT WINAPI HTMLLabelElement_Invoke(IHTMLLabelElement *iface, DISPID d static HRESULT WINAPI HTMLLabelElement_put_htmlFor(IHTMLLabelElement *iface, BSTR v) { HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString for_str, val_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + nsAString_InitDepend(&for_str, forW); + nsAString_InitDepend(&val_str, v); + nsres = nsIDOMHTMLElement_SetAttribute(This->element.nselem, &for_str, &val_str); + nsAString_Finish(&for_str); + nsAString_Finish(&val_str); + if(NS_FAILED(nsres)) { + ERR("SetAttribute failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLLabelElement_get_htmlFor(IHTMLLabelElement *iface, BSTR *p) { HTMLLabelElement *This = impl_from_IHTMLLabelElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString for_str, val_str; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_InitDepend(&for_str, forW); + nsAString_Init(&val_str, NULL); + nsres = nsIDOMHTMLElement_GetAttribute(This->element.nselem, &for_str, &val_str); + nsAString_Finish(&for_str); + if(NS_SUCCEEDED(nsres)) { + const PRUnichar *val; + + nsAString_GetData(&val_str, &val); + *p = SysAllocString(val); + hres = *p ? S_OK : E_OUTOFMEMORY; + }else { + ERR("GetAttribute failed: %08x\n", nsres); + hres = E_FAIL; + } + + nsAString_Finish(&val_str); + return hres; } static HRESULT WINAPI HTMLLabelElement_put_accessKey(IHTMLLabelElement *iface, BSTR v)