mshtml: Use return_nsstr_variant in HTMLTable_get_width.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
93dfc9b60e
commit
0dfc101e17
|
@ -1234,7 +1234,7 @@ static HRESULT WINAPI HTMLDOMNode3_get_namespaceURI(IHTMLDOMNode3 *iface, VARIAN
|
|||
|
||||
nsAString_InitDepend(&nsstr, NULL);
|
||||
nsres = nsIDOMNode_GetNamespaceURI(This->nsnode, &nsstr);
|
||||
return return_nsstr_variant(nsres, &nsstr, p);
|
||||
return return_nsstr_variant(nsres, &nsstr, 0, p);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLDOMNode3_put_textContent(IHTMLDOMNode3 *iface, VARIANT v)
|
||||
|
@ -1266,7 +1266,7 @@ static HRESULT WINAPI HTMLDOMNode3_get_textContent(IHTMLDOMNode3 *iface, VARIANT
|
|||
|
||||
nsAString_Init(&nsstr, NULL);
|
||||
nsres = nsIDOMNode_GetTextContent(This->nsnode, &nsstr);
|
||||
return return_nsstr_variant(nsres, &nsstr, p);
|
||||
return return_nsstr_variant(nsres, &nsstr, 0, p);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLDOMNode3_isEqualNode(IHTMLDOMNode3 *iface, IHTMLDOMNode3 *otherNode, VARIANT_BOOL *isEqual)
|
||||
|
|
|
@ -1014,26 +1014,6 @@ static HRESULT var2str(const VARIANT *p, nsAString *nsstr)
|
|||
return ret ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
static HRESULT nsstr_to_truncated_bstr(const nsAString *nsstr, BSTR *ret_ptr)
|
||||
{
|
||||
const PRUnichar *str, *ptr, *end = NULL;
|
||||
BSTR ret;
|
||||
|
||||
nsAString_GetData(nsstr, &str);
|
||||
|
||||
for(ptr = str; is_digit(*ptr); ptr++);
|
||||
if(*ptr == '.') {
|
||||
for(end = ptr++; is_digit(*ptr); ptr++);
|
||||
if(*ptr)
|
||||
end = NULL;
|
||||
}
|
||||
|
||||
ret = end ? SysAllocStringLen(str, end-str) : SysAllocString(str);
|
||||
|
||||
*ret_ptr = ret;
|
||||
return ret ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLTable_QueryInterface(IHTMLTable *iface,
|
||||
REFIID riid, void **ppv)
|
||||
{
|
||||
|
@ -1244,7 +1224,7 @@ static HRESULT WINAPI HTMLTable_get_cellPadding(IHTMLTable *iface, VARIANT *p)
|
|||
|
||||
nsAString_Init(&val, NULL);
|
||||
nsres = nsIDOMHTMLTableElement_GetCellPadding(This->nstable, &val);
|
||||
return return_nsstr_variant(nsres, &val, p);
|
||||
return return_nsstr_variant(nsres, &val, 0, p);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLTable_put_background(IHTMLTable *iface, BSTR v)
|
||||
|
@ -1440,25 +1420,13 @@ static HRESULT WINAPI HTMLTable_get_width(IHTMLTable *iface, VARIANT *p)
|
|||
{
|
||||
HTMLTable *This = impl_from_IHTMLTable(iface);
|
||||
nsAString val;
|
||||
BSTR bstr;
|
||||
nsresult nsres;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, p);
|
||||
|
||||
nsAString_Init(&val, NULL);
|
||||
nsres = nsIDOMHTMLTableElement_GetWidth(This->nstable, &val);
|
||||
if (NS_FAILED(nsres)){
|
||||
ERR("Get Width failed!\n");
|
||||
nsAString_Finish(&val);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
hres = nsstr_to_truncated_bstr(&val, &bstr);
|
||||
nsAString_Finish(&val);
|
||||
|
||||
V_VT(p) = VT_BSTR;
|
||||
V_BSTR(p) = bstr;
|
||||
return hres;
|
||||
return return_nsstr_variant(nsres, &val, NSSTR_IMPLICIT_PX, p);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLTable_put_height(IHTMLTable *iface, VARIANT v)
|
||||
|
|
|
@ -981,9 +981,11 @@ void nsAString_SetData(nsAString*,const PRUnichar*) DECLSPEC_HIDDEN;
|
|||
UINT32 nsAString_GetData(const nsAString*,const PRUnichar**) DECLSPEC_HIDDEN;
|
||||
void nsAString_Finish(nsAString*) DECLSPEC_HIDDEN;
|
||||
|
||||
#define NSSTR_IMPLICIT_PX 0x01
|
||||
|
||||
HRESULT map_nsresult(nsresult) DECLSPEC_HIDDEN;
|
||||
HRESULT return_nsstr(nsresult,nsAString*,BSTR*) DECLSPEC_HIDDEN;
|
||||
HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, VARIANT *p) DECLSPEC_HIDDEN;
|
||||
HRESULT return_nsstr_variant(nsresult,nsAString*,unsigned,VARIANT*) DECLSPEC_HIDDEN;
|
||||
HRESULT variant_to_nsstr(VARIANT*,BOOL,nsAString*) DECLSPEC_HIDDEN;
|
||||
HRESULT return_nsform(nsresult,nsIDOMHTMLFormElement*,IHTMLFormElement**) DECLSPEC_HIDDEN;
|
||||
|
||||
|
|
|
@ -962,10 +962,8 @@ HRESULT return_nsstr(nsresult nsres, nsAString *nsstr, BSTR *p)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, VARIANT *p)
|
||||
HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, unsigned flags, VARIANT *p)
|
||||
{
|
||||
const PRUnichar *str;
|
||||
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("failed: %08x\n", nsres);
|
||||
nsAString_Finish(nsstr);
|
||||
|
@ -976,10 +974,24 @@ HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, VARIANT *p)
|
|||
TRACE("ret null\n");
|
||||
V_VT(p) = VT_NULL;
|
||||
}else {
|
||||
const WCHAR *str;
|
||||
size_t len;
|
||||
nsAString_GetData(nsstr, &str);
|
||||
TRACE("ret %s\n", debugstr_w(str));
|
||||
len = wcslen(str);
|
||||
if(flags & NSSTR_IMPLICIT_PX) {
|
||||
const WCHAR *iter;
|
||||
if(len > 2 && !wcscmp(str + len - 2, L"px"))
|
||||
len -= 2;
|
||||
for(iter = str; iter < str + len && is_digit(*iter); iter++);
|
||||
if(*iter == '.') {
|
||||
const WCHAR *dot = iter++;
|
||||
while(iter < str + len && is_digit(*iter)) iter++;
|
||||
if(iter == str + len && dot) len = dot - str;
|
||||
}
|
||||
}
|
||||
TRACE("ret %s\n", debugstr_wn(str, len));
|
||||
if(*str) {
|
||||
V_BSTR(p) = SysAllocString(str);
|
||||
V_BSTR(p) = SysAllocStringLen(str, len);
|
||||
if(!V_BSTR(p)) {
|
||||
nsAString_Finish(nsstr);
|
||||
return E_OUTOFMEMORY;
|
||||
|
|
|
@ -7910,6 +7910,16 @@ static void test_table_elem(IHTMLElement *elem)
|
|||
ok(hres == S_OK, "put_bgColor failed: %08x\n", hres);
|
||||
VariantClear(&vDefaultbg);
|
||||
|
||||
V_VT(&v) = VT_BSTR;
|
||||
V_BSTR(&v) = SysAllocString(L"12px");
|
||||
hres = IHTMLTable_put_width(table, v);
|
||||
ok(hres == S_OK, "put_width = %08x\n", hres);
|
||||
VariantClear(&v);
|
||||
hres = IHTMLTable_get_width(table, &v);
|
||||
ok(hres == S_OK, "get_width = %08x\n", hres);
|
||||
ok(!lstrcmpW(V_BSTR(&v), L"12"), "Expected 12, got %s\n", wine_dbgstr_w(V_BSTR(&v)));
|
||||
VariantClear(&v);
|
||||
|
||||
V_VT(&v) = VT_BSTR;
|
||||
V_BSTR(&v) = SysAllocString(L"11");
|
||||
hres = IHTMLTable_put_width(table, v);
|
||||
|
|
Loading…
Reference in New Issue