mshtml: Factor out variant_to_nsstr from var_to_styleval.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f0497aac0b
commit
1593364466
|
@ -933,43 +933,14 @@ static HRESULT set_nsstyle_property(nsIDOMCSSStyleDeclaration *nsstyle, styleid_
|
||||||
|
|
||||||
static HRESULT var_to_styleval(CSSStyle *style, VARIANT *v, const style_tbl_entry_t *entry, nsAString *nsstr)
|
static HRESULT var_to_styleval(CSSStyle *style, VARIANT *v, const style_tbl_entry_t *entry, nsAString *nsstr)
|
||||||
{
|
{
|
||||||
|
HRESULT hres;
|
||||||
unsigned flags = entry && dispex_compat_mode(&style->dispex) < COMPAT_MODE_IE9
|
unsigned flags = entry && dispex_compat_mode(&style->dispex) < COMPAT_MODE_IE9
|
||||||
? entry->flags : 0;
|
? entry->flags : 0;
|
||||||
|
|
||||||
switch(V_VT(v)) {
|
hres = variant_to_nsstr(v, !!(flags & ATTR_HEX_INT), nsstr);
|
||||||
case VT_NULL:
|
if(SUCCEEDED(hres) && (flags & ATTR_FIX_PX))
|
||||||
nsAString_InitDepend(nsstr, NULL);
|
|
||||||
return S_OK;
|
|
||||||
|
|
||||||
case VT_BSTR:
|
|
||||||
nsAString_InitDepend(nsstr, V_BSTR(v));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VT_BSTR|VT_BYREF:
|
|
||||||
nsAString_InitDepend(nsstr, *V_BSTRREF(v));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VT_I4: {
|
|
||||||
static const WCHAR formatW[] = {'%','d',0};
|
|
||||||
static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
|
|
||||||
WCHAR buf[14];
|
|
||||||
|
|
||||||
if(flags & ATTR_HEX_INT)
|
|
||||||
wsprintfW(buf, hex_formatW, V_I4(v));
|
|
||||||
else
|
|
||||||
wsprintfW(buf, formatW, V_I4(v));
|
|
||||||
|
|
||||||
nsAString_Init(nsstr, buf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
FIXME("not implemented for %s\n", debugstr_variant(v));
|
|
||||||
return E_NOTIMPL;
|
|
||||||
|
|
||||||
}
|
|
||||||
if(flags & ATTR_FIX_PX)
|
|
||||||
fix_px_value(nsstr);
|
fix_px_value(nsstr);
|
||||||
return S_OK;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HRESULT set_style_property(CSSStyle *style, styleid_t sid, const WCHAR *value)
|
static inline HRESULT set_style_property(CSSStyle *style, styleid_t sid, const WCHAR *value)
|
||||||
|
|
|
@ -975,6 +975,7 @@ void nsAString_Finish(nsAString*) DECLSPEC_HIDDEN;
|
||||||
HRESULT map_nsresult(nsresult) DECLSPEC_HIDDEN;
|
HRESULT map_nsresult(nsresult) DECLSPEC_HIDDEN;
|
||||||
HRESULT return_nsstr(nsresult,nsAString*,BSTR*) 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 nsres, nsAString *nsstr, VARIANT *p) DECLSPEC_HIDDEN;
|
||||||
|
HRESULT variant_to_nsstr(VARIANT*,BOOL,nsAString*) DECLSPEC_HIDDEN;
|
||||||
HRESULT return_nsform(nsresult,nsIDOMHTMLFormElement*,IHTMLFormElement**) DECLSPEC_HIDDEN;
|
HRESULT return_nsform(nsresult,nsIDOMHTMLFormElement*,IHTMLFormElement**) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
nsICommandParams *create_nscommand_params(void) DECLSPEC_HIDDEN;
|
nsICommandParams *create_nscommand_params(void) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -932,6 +932,44 @@ HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, VARIANT *p)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts VARIANT to string and stores the result in nsAString. To avoid useless
|
||||||
|
* allocations, the function uses an existing string if available, so caller must
|
||||||
|
* ensure that passed VARIANT is unchanged as long as its string representation is used
|
||||||
|
*/
|
||||||
|
HRESULT variant_to_nsstr(VARIANT *v, BOOL hex_int, nsAString *nsstr)
|
||||||
|
{
|
||||||
|
WCHAR buf[32];
|
||||||
|
|
||||||
|
static const WCHAR d_formatW[] = {'%','d',0};
|
||||||
|
static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
|
||||||
|
|
||||||
|
switch(V_VT(v)) {
|
||||||
|
case VT_NULL:
|
||||||
|
nsAString_InitDepend(nsstr, NULL);
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
case VT_BSTR:
|
||||||
|
nsAString_InitDepend(nsstr, V_BSTR(v));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VT_BSTR|VT_BYREF:
|
||||||
|
nsAString_InitDepend(nsstr, *V_BSTRREF(v));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VT_I4:
|
||||||
|
wsprintfW(buf, hex_int ? hex_formatW : d_formatW, V_I4(v));
|
||||||
|
nsAString_Init(nsstr, buf);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
FIXME("not implemented for %s\n", debugstr_variant(v));
|
||||||
|
return E_NOTIMPL;
|
||||||
|
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsICommandParams *create_nscommand_params(void)
|
nsICommandParams *create_nscommand_params(void)
|
||||||
{
|
{
|
||||||
nsICommandParams *ret = NULL;
|
nsICommandParams *ret = NULL;
|
||||||
|
|
Loading…
Reference in New Issue