Jacek Caban : mshtml: Add IHTMLCSSStyleDeclaration:: setProperty implementation.
Alexandre Julliard
julliard at winehq.org
Tue Mar 19 17:09:21 CDT 2019
Module: wine
Branch: master
Commit: 119b1a69224c507f27d8c21f5bb1173013f1a272
URL: https://source.winehq.org/git/wine.git/?a=commit;h=119b1a69224c507f27d8c21f5bb1173013f1a272
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Mar 19 18:12:38 2019 +0100
mshtml: Add IHTMLCSSStyleDeclaration::setProperty implementation.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/htmlstyle.c | 50 ++++++++++++++++++++++++++++++++++++-------
dlls/mshtml/tests/elements.js | 24 +++++++++++++++++++++
2 files changed, 66 insertions(+), 8 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index ea435d1..76fbe11 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -933,7 +933,7 @@ static HRESULT set_nsstyle_property(nsIDOMCSSStyleDeclaration *nsstyle, styleid_
return S_OK;
}
-static HRESULT var_to_styleval(HTMLStyle *style, const VARIANT *v, styleid_t sid, WCHAR *buf, const WCHAR **ret)
+static HRESULT var_to_styleval(HTMLStyle *style, const VARIANT *v, const style_tbl_entry_t *entry, WCHAR *buf, const WCHAR **ret)
{
switch(V_VT(v)) {
case VT_NULL:
@@ -949,7 +949,7 @@ static HRESULT var_to_styleval(HTMLStyle *style, const VARIANT *v, styleid_t sid
return S_OK;
case VT_I4: {
- unsigned flags = dispex_compat_mode(&style->dispex) < COMPAT_MODE_IE9 ? style_tbl[sid].flags : 0;
+ unsigned flags = entry && dispex_compat_mode(&style->dispex) < COMPAT_MODE_IE9 ? entry->flags : 0;
static const WCHAR formatW[] = {'%','d',0};
static const WCHAR hex_formatW[] = {'#','%','0','6','x',0};
@@ -1008,7 +1008,7 @@ static HRESULT set_style_property_var(HTMLStyle *style, styleid_t sid, VARIANT *
WCHAR buf[14];
HRESULT hres;
- hres = var_to_styleval(style, value, sid, buf, &val);
+ hres = var_to_styleval(style, value, &style_tbl[sid], buf, &val);
if(FAILED(hres))
return hres;
@@ -1615,7 +1615,7 @@ static HRESULT WINAPI HTMLStyle_put_backgroundPositionX(IHTMLStyle *iface, VARIA
TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
- hres = var_to_styleval(This, &v, STYLEID_BACKGROUND_POSITION_X, buf, &val);
+ hres = var_to_styleval(This, &v, &style_tbl[STYLEID_BACKGROUND_POSITION_X], buf, &val);
if(FAILED(hres))
return hres;
@@ -1708,7 +1708,7 @@ static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIA
TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
- hres = var_to_styleval(This, &v, STYLEID_BACKGROUND_POSITION, buf, &val);
+ hres = var_to_styleval(This, &v, &style_tbl[STYLEID_BACKGROUND_POSITION], buf, &val);
if(FAILED(hres))
return hres;
@@ -5194,11 +5194,45 @@ static HRESULT WINAPI HTMLCSSStyleDeclaration_removeProperty(IHTMLCSSStyleDeclar
return return_nsstr(nsres, &ret_str, pbstrPropertyValue);
}
-static HRESULT WINAPI HTMLCSSStyleDeclaration_setProperty(IHTMLCSSStyleDeclaration *iface, BSTR bstrPropertyName, VARIANT *pvarPropertyValue, VARIANT *pvarPropertyPriority)
+static HRESULT WINAPI HTMLCSSStyleDeclaration_setProperty(IHTMLCSSStyleDeclaration *iface, BSTR name, VARIANT *value, VARIANT *priority)
{
HTMLStyle *This = impl_from_IHTMLCSSStyleDeclaration(iface);
- FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrPropertyName), pvarPropertyValue, pvarPropertyPriority);
- return E_NOTIMPL;
+ nsAString priority_str, name_str, value_str;
+ const style_tbl_entry_t *style_entry;
+ const WCHAR *val;
+ WCHAR buf[14];
+ nsresult nsres;
+ HRESULT hres;
+
+ TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(name), debugstr_variant(value), debugstr_variant(priority));
+
+ style_entry = lookup_style_tbl(name);
+ hres = var_to_styleval(This, value, style_entry, buf, &val);
+ if(FAILED(hres))
+ return hres;
+
+ if(priority) {
+ if(V_VT(priority) != VT_BSTR) {
+ WARN("invalid priority type %s\n", debugstr_variant(priority));
+ return S_OK;
+ }
+ nsAString_InitDepend(&priority_str, V_BSTR(priority));
+ }else {
+ nsAString_InitDepend(&priority_str, NULL);
+ }
+
+ nsAString_InitDepend(&name_str, style_entry ? style_entry->name : name);
+ nsAString_InitDepend(&value_str, val);
+ nsres = nsIDOMCSSStyleDeclaration_SetProperty(This->nsstyle, &name_str, &value_str, &priority_str);
+ nsAString_Finish(&name_str);
+ nsAString_Finish(&value_str);
+ nsAString_Finish(&priority_str);
+ if(NS_FAILED(nsres)) {
+ FIXME("SetProperty failed: %08x\n", nsres);
+ return E_FAIL;
+ }
+
+ return S_OK;
}
static HRESULT WINAPI HTMLCSSStyleDeclaration_item(IHTMLCSSStyleDeclaration *iface, LONG index, BSTR *pbstrPropertyName)
diff --git a/dlls/mshtml/tests/elements.js b/dlls/mshtml/tests/elements.js
index 50f19e5..2652c6b 100644
--- a/dlls/mshtml/tests/elements.js
+++ b/dlls/mshtml/tests/elements.js
@@ -239,6 +239,30 @@ function test_style_properties() {
ok(style.zIndex === 1, "zIndex = " + style.zIndex);
ok(style["z-index"] === 1, "z-index = " + style["z-index"]);
+ style.setProperty("border-width", "5px");
+ ok(style.borderWidth === "5px", "style.borderWidth = " + style.borderWidth);
+
+ try {
+ style.setProperty("border-width", 6);
+ ok(style.borderWidth === "5px", "style.borderWidth = " + style.borderWidth);
+ }catch(e) {
+ win_skip("skipping setProperty tests on too old IE version");
+ next_test();
+ return;
+ }
+
+ style.setProperty("border-width", "7px", "test");
+ ok(style.borderWidth === "5px", "style.borderWidth = " + style.borderWidth);
+
+ style.setProperty("border-width", "6px", "");
+ ok(style.borderWidth === "6px", "style.borderWidth = " + style.borderWidth);
+
+ style.setProperty("border-width", "7px", "important");
+ ok(style.borderWidth === "7px", "style.borderWidth = " + style.borderWidth);
+
+ style.setProperty("border-width", "8px", undefined);
+ ok(style.borderWidth === "7px", "style.borderWidth = " + style.borderWidth);
+
next_test();
}
More information about the wine-cvs
mailing list