Jacek Caban : mshtml: Expose IHTMLStyleSheet4 to scripts.

Alexandre Julliard julliard at winehq.org
Wed Apr 7 15:48:29 CDT 2021


Module: wine
Branch: master
Commit: 1afbe2e1ea2ca1dc8a4e3c5bb71bdbd22f20b2b7
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1afbe2e1ea2ca1dc8a4e3c5bb71bdbd22f20b2b7

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Apr  7 00:24:30 2021 +0200

mshtml: Expose IHTMLStyleSheet4 to scripts.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmlstylesheet.c      |  9 ++++++++-
 dlls/mshtml/tests/documentmode.js | 36 ++++++++++++++++++++++++++++++++++++
 dlls/mshtml/tests/dom.js          | 12 ++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c
index da9a1a0894a..243aea2e618 100644
--- a/dlls/mshtml/htmlstylesheet.c
+++ b/dlls/mshtml/htmlstylesheet.c
@@ -1102,6 +1102,12 @@ static const IHTMLStyleSheet4Vtbl HTMLStyleSheet4Vtbl = {
     HTMLStyleSheet4_deleteRule,
 };
 
+static void HTMLStyleSheet_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
+{
+    if(mode >= COMPAT_MODE_IE9)
+        dispex_info_add_interface(info, IHTMLStyleSheet4_tid, NULL);
+}
+
 static const tid_t HTMLStyleSheet_iface_tids[] = {
     IHTMLStyleSheet_tid,
     0
@@ -1109,7 +1115,8 @@ static const tid_t HTMLStyleSheet_iface_tids[] = {
 static dispex_static_data_t HTMLStyleSheet_dispex = {
     NULL,
     DispHTMLStyleSheet_tid,
-    HTMLStyleSheet_iface_tids
+    HTMLStyleSheet_iface_tids,
+    HTMLStyleSheet_init_dispex_info
 };
 
 HRESULT create_style_sheet(nsIDOMStyleSheet *nsstylesheet, compat_mode_t compat_mode, IHTMLStyleSheet **ret)
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index a8bcc611083..75a132e83a7 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -134,6 +134,42 @@ sync_test("xhr_props", function() {
     test_exposed("dispatchEvent", v >= 9);
 });
 
+sync_test("stylesheet_props", function() {
+    var v = document.documentMode;
+    var elem = document.createElement("style");
+    document.body.appendChild(elem);
+    var sheet = v >= 9 ? elem.sheet : elem.styleSheet;
+
+    function test_exposed(prop, expect) {
+        if(expect)
+            ok(prop in sheet, prop + " not found in style sheet.");
+        else
+            ok(!(prop in sheet), prop + " found in style sheet.");
+    }
+
+    test_exposed("href", true);
+    test_exposed("title", true);
+    test_exposed("type", true);
+    test_exposed("media", true);
+    test_exposed("ownerNode", v >= 9);
+    test_exposed("ownerRule", v >= 9);
+    test_exposed("cssRules", v >= 9);
+    test_exposed("insertRule", v >= 9);
+    test_exposed("deleteRule", v >= 9);
+    test_exposed("disabled", true);
+    test_exposed("parentStyleSheet", true);
+    test_exposed("owningElement", true);
+    test_exposed("readOnly", true);
+    test_exposed("imports", true);
+    test_exposed("id", true);
+    test_exposed("addImport", true);
+    test_exposed("addRule", true);
+    test_exposed("removeImport", true);
+    test_exposed("removeRule", true);
+    test_exposed("cssText", true);
+    test_exposed("rules", true);
+});
+
 sync_test("xhr open", function() {
     var e = false;
     try {
diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js
index 4db743241a0..564ca87821a 100644
--- a/dlls/mshtml/tests/dom.js
+++ b/dlls/mshtml/tests/dom.js
@@ -381,6 +381,7 @@ sync_test("style_properties", function() {
 
 sync_test("stylesheets", function() {
     document.body.innerHTML = '<style>.div { margin-right: 1px; }</style>';
+    var elem = document.body.firstChild;
 
     ok(document.styleSheets.length === 1, "document.styleSheets.length = " + document.styleSheets.length);
 
@@ -393,6 +394,17 @@ sync_test("stylesheets", function() {
         stylesheet.rules.item(1);
         ok(false, "expected exception");
     }catch(e) {}
+
+    ok(stylesheet.href === null, "stylesheet.href = " + stylesheet.href);
+
+    var id = stylesheet.insertRule(".input { margin-left: 1px; }", 0);
+    ok(id === 0, "id = " + id);
+    ok(document.styleSheets.length === 1, "document.styleSheets.length = " + document.styleSheets.length);
+
+    try {
+        stylesheet.insertRule(".input { margin-left: 1px; }", 3);
+        ok(false, "expected exception");
+    }catch(e) {}
 });
 
 sync_test("storage", function() {




More information about the wine-cvs mailing list