Bug 1625036 - Tweak background: transparent handling so that color: transparent doesn't override UA sheet backgrounds. r=morgan
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 30 Mar 2020 15:09:33 +0000
changeset 521088 360f09e5abbdce59310f36a60a0168cf0c6a6588
parent 521087 4ba3f4a39170e1625509b553ff60b2bd1bdaf2de
child 521089 f2f8ac87d5178d1703c6ac3b967e7238668528a0
push id111468
push userealvarez@mozilla.com
push dateMon, 30 Mar 2020 15:23:06 +0000
treeherderautoland@360f09e5abbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmorgan
bugs1625036
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1625036 - Tweak background: transparent handling so that color: transparent doesn't override UA sheet backgrounds. r=morgan Differential Revision: https://phabricator.services.mozilla.com/D68408
layout/reftests/high-contrast/background-transparent-form-control-ref.html
layout/reftests/high-contrast/background-transparent-form-control.html
layout/reftests/high-contrast/reftest.list
servo/components/style/properties/cascade.rs
new file mode 100644
--- /dev/null
+++ b/layout/reftests/high-contrast/background-transparent-form-control-ref.html
@@ -0,0 +1,2 @@
+<!doctype html>
+<button>ABC</button>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/high-contrast/background-transparent-form-control.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<style>
+  button {
+    background-color: transparent;
+  }
+</style>
+<button>ABC</button>
--- a/layout/reftests/high-contrast/reftest.list
+++ b/layout/reftests/high-contrast/reftest.list
@@ -35,8 +35,10 @@ pref(browser.display.document_color_use,
 != color-transparent-002.html about:blank
 
 == links.html links-ref.html
 
 pref(browser.display.document_color_use,2) == non-themed-button-001.html non-themed-button-001-ref.html
 pref(browser.display.document_color_use,2) == non-themed-button-002.html non-themed-button-002-ref.html
 
 != cascade-001.html about:blank
+
+pref(browser.display.document_color_use,2) == background-transparent-form-control.html background-transparent-form-control-ref.html
--- a/servo/components/style/properties/cascade.rs
+++ b/servo/components/style/properties/cascade.rs
@@ -367,23 +367,22 @@ fn tweak_when_ignoring_colors(
         return;
     }
 
     // A few special-cases ahead.
     match **declaration {
         // We honor color and background-color: transparent, and
         // "revert-or-initial" otherwise.
         PropertyDeclaration::BackgroundColor(ref color) => {
-            if color.is_transparent() {
-                return;
+            if !color.is_transparent() {
+                let color = builder.device.default_background_color();
+                declarations_to_apply_unless_overriden.push(
+                    PropertyDeclaration::BackgroundColor(color.into())
+                )
             }
-            let color = builder.device.default_background_color();
-            declarations_to_apply_unless_overriden.push(
-                PropertyDeclaration::BackgroundColor(color.into())
-            )
         }
         PropertyDeclaration::Color(ref color) => {
             // otherwise.
             if color.0.is_transparent() {
                 return;
             }
             let color = builder.device.default_color();
             declarations_to_apply_unless_overriden.push(