Jacek Caban : mshtml: Propagate nsIDOMCSSStyleDeclaration errors.
Alexandre Julliard
julliard at winehq.org
Tue Mar 26 16:43:15 CDT 2019
Module: wine
Branch: master
Commit: 9944c4bd688b40c3c856d37517c2587996157cd9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9944c4bd688b40c3c856d37517c2587996157cd9
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Mar 26 17:27:32 2019 +0100
mshtml: Propagate nsIDOMCSSStyleDeclaration errors.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/htmlstyle.c | 31 +++++++++++--------------------
dlls/mshtml/mshtml_private.h | 2 ++
dlls/mshtml/nsembed.c | 4 +++-
dlls/mshtml/tests/dom.c | 36 +++++++++++++++++++++++++++++++++---
4 files changed, 49 insertions(+), 24 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index 584ac59..7f99c89 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -921,16 +921,13 @@ static HRESULT set_nsstyle_property(nsIDOMCSSStyleDeclaration *nsstyle, styleid_
nsAString_InitDepend(&str_name, style_tbl[sid].name);
nsAString_InitDepend(&str_value, value);
nsAString_InitDepend(&str_empty, emptyW);
-
nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty);
- if(NS_FAILED(nsres))
- ERR("SetProperty failed: %08x\n", nsres);
-
nsAString_Finish(&str_name);
nsAString_Finish(&str_value);
nsAString_Finish(&str_empty);
-
- return S_OK;
+ if(NS_FAILED(nsres))
+ WARN("SetProperty failed: %08x\n", nsres);
+ return map_nsresult(nsres);
}
static HRESULT var_to_styleval(CSSStyle *style, const VARIANT *v, const style_tbl_entry_t *entry, WCHAR *buf, const WCHAR **ret)
@@ -1023,12 +1020,9 @@ static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, stylei
nsAString_InitDepend(&str_name, style_tbl[sid].name);
nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value);
nsAString_Finish(&str_name);
- if(NS_FAILED(nsres)) {
- ERR("SetProperty failed: %08x\n", nsres);
- return E_FAIL;
- }
-
- return S_OK;
+ if(NS_FAILED(nsres))
+ WARN("GetPropertyValue failed: %08x\n", nsres);
+ return map_nsresult(nsres);
}
static HRESULT nsstyle_to_bstr(const WCHAR *val, DWORD flags, BSTR *p)
@@ -3179,11 +3173,11 @@ static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttri
nsAString_GetData(&ret_str, &ret);
*pfSuccess = variant_bool(*ret);
}else {
- ERR("RemoveProperty failed: %08x\n", nsres);
+ WARN("RemoveProperty failed: %08x\n", nsres);
}
nsAString_Finish(&name_str);
nsAString_Finish(&ret_str);
- return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
+ return map_nsresult(nsres);
}
static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String)
@@ -5063,12 +5057,9 @@ static HRESULT WINAPI HTMLCSSStyleDeclaration_setProperty(IHTMLCSSStyleDeclarati
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;
+ if(NS_FAILED(nsres))
+ WARN("SetProperty failed: %08x\n", nsres);
+ return map_nsresult(nsres);
}
static HRESULT WINAPI HTMLCSSStyleDeclaration_item(IHTMLCSSStyleDeclaration *iface, LONG index, BSTR *pbstrPropertyName)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 14cc561..a2b05e7 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -56,6 +56,7 @@
#define NS_ERROR_NOT_AVAILABLE ((nsresult)0x80040111L)
#define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
#define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
+#define NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ((nsresult)0x80530007)
#define NS_ERROR_MODULE_NETWORK 6
@@ -958,6 +959,7 @@ void nsAString_InitDepend(nsAString*,const PRUnichar*) DECLSPEC_HIDDEN;
UINT32 nsAString_GetData(const nsAString*,const PRUnichar**) DECLSPEC_HIDDEN;
void nsAString_Finish(nsAString*) DECLSPEC_HIDDEN;
+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_nsform(nsresult,nsIDOMHTMLFormElement*,IHTMLFormElement**) DECLSPEC_HIDDEN;
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index cebed37..6aa2812 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -848,7 +848,7 @@ void nsAString_Finish(nsAString *str)
NS_StringContainerFinish(str);
}
-static HRESULT map_nsresult(nsresult nsres)
+HRESULT map_nsresult(nsresult nsres)
{
switch(nsres) {
case NS_OK:
@@ -865,6 +865,8 @@ static HRESULT map_nsresult(nsresult nsres)
return E_INVALIDARG;
case NS_ERROR_UNEXPECTED:
return E_UNEXPECTED;
+ case NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR:
+ return 0x80700007; /* according to tests */
}
return E_FAIL;
}
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 8c7548a..bf23163 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -6750,6 +6750,27 @@ static void test_xmlhttprequest(IHTMLWindow5 *window)
VariantClear(&var);
}
+static void test_read_only_style(IHTMLCSSStyleDeclaration *style)
+{
+ BSTR none = a2bstr("none"), display = a2bstr("display"), str;
+ VARIANT v;
+ HRESULT hres;
+
+ hres = IHTMLCSSStyleDeclaration_put_display(style, none);
+ ok(hres == 0x80700007, "put_display failed: %08x\n", hres);
+
+ hres = IHTMLCSSStyleDeclaration_removeProperty(style, display, &str);
+ ok(hres == 0x80700007, "removeProperty failed: %08x\n", hres);
+
+ V_VT(&v) = VT_BSTR;
+ V_BSTR(&v) = none;
+ hres = IHTMLCSSStyleDeclaration_setProperty(style, display, &v, NULL);
+ ok(hres == 0x80700007, "setProperty returned: %08x\n", hres);
+
+ SysFreeString(none);
+ SysFreeString(display);
+}
+
static void test_window(IHTMLDocument2 *doc)
{
IHTMLWindow2 *window, *window2, *self, *parent;
@@ -7099,10 +7120,19 @@ static void test_defaults(IHTMLDocument2 *doc)
test_ifaces((IUnknown*)cstyle, cstyle_iids);
hres = IHTMLCurrentStyle_QueryInterface(cstyle, &IID_IHTMLCurrentStyle4, (void**)&unk);
- if(SUCCEEDED(hres))
+ if(SUCCEEDED(hres)) {
+ IHTMLCSSStyleDeclaration *css_style;
+
+ hres = IHTMLCurrentStyle_QueryInterface(cstyle, &IID_IHTMLCSSStyleDeclaration, (void**)&css_style);
+ if(SUCCEEDED(hres)) {
+ test_read_only_style(css_style);
+ IHTMLCSSStyleDeclaration_Release(css_style);
+ }else {
+ win_skip("IHTMLCSSStyleDeclaration not supported\n");
+ }
+
IUnknown_Release(unk);
- else
- {
+ }else {
/*IE6 doesn't have interface */
win_skip("IID_IHTMLCurrentStyle4 not supported\n");
}
More information about the wine-cvs
mailing list