Bug 1472567 - Honor logical border colors in visited links r=emilio
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Thu, 05 Jul 2018 12:56:34 +0200
changeset 425551 fc9fd41ca2d3a50e5248327f255a49517ae400e3
parent 425550 4c31558d3481dbd0d0f842fafc73120eb04cbd91
child 425552 120a610ee8bafbaf44a3487da1f4409b5fde0205
push id34258
push usertoros@mozilla.com
push dateTue, 10 Jul 2018 09:43:53 +0000
treeherdermozilla-central@0c55071115c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1472567
milestone63.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 1472567 - Honor logical border colors in visited links r=emilio MozReview-Commit-ID: IF8yvkFmPc4
layout/reftests/css-visited/logical-box-border-color-visited-link-001.html
layout/reftests/css-visited/logical-box-border-color-visited-link-002.html
layout/reftests/css-visited/logical-box-border-color-visited-link-ref.html
layout/style/test/moz.build
layout/style/test/test_visited_reftests.html
servo/components/style/properties/properties.mako.rs
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-visited/logical-box-border-color-visited-link-001.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Logical Properties: Flow-Relative Border Colors in Visited Links</title>
+<style>
+a {
+  display: inline-block;
+  vertical-align: top;
+  border: 25px solid red;
+}
+#link1, #link2:visited {
+  border-block-start-color: green;
+  border-block-end-color: green;
+  border-inline-start-color: green;
+  border-inline-end-color: green;
+}
+#link3 {
+  border-block-start: 25px solid green;
+  border-block-end: 25px solid green;
+  border-inline-start: 25px solid green;
+  border-inline-end: 25px solid green;
+}
+#link4:visited {
+  /* :visited should honor the border color but ignore other values in the shorthand */
+  border-block-start: 0 none green;
+  border-block-end: 0 none green;
+  border-inline-start: 0 none green;
+  border-inline-end: 0 none green;
+}
+</style>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<a id="link1" href="visited-page.html"></a><a id="link2" href="visited-page.html"></a><br>
+<a id="link3" href="visited-page.html"></a><a id="link4" href="visited-page.html"></a>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-visited/logical-box-border-color-visited-link-002.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Logical Properties: Flow-Relative Border Colors in Visited Links</title>
+<style>
+a {
+  display: inline-block;
+  vertical-align: top;
+  border: 25px solid red;
+}
+#link1, #link2:visited {
+  border-block-color: green;
+  border-inline-color: green;
+}
+#link3 {
+  border-block: 25px solid green;
+  border-inline: 25px solid green;
+}
+#link4:visited {
+  /* :visited should honor the border color but ignore other values in the shorthand */
+  border-block: 0 none green;
+  border-inline: 0 none green;
+}
+</style>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<a id="link1" href="visited-page.html"></a><a id="link2" href="visited-page.html"></a><br>
+<a id="link3" href="visited-page.html"></a><a id="link4" href="visited-page.html"></a>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-visited/logical-box-border-color-visited-link-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<style>
+div {
+  background: green;
+  height: 100px;
+  width: 100px;
+}
+</style>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div></div>
--- a/layout/style/test/moz.build
+++ b/layout/style/test/moz.build
@@ -74,16 +74,19 @@ TEST_HARNESS_FILES.testing.mochitest.tes
     '/layout/reftests/css-visited/content-on-link-before-1.html',
     '/layout/reftests/css-visited/content-on-visited-before-1.html',
     '/layout/reftests/css-visited/first-line-1-ref.html',
     '/layout/reftests/css-visited/first-line-1.html',
     '/layout/reftests/css-visited/inherit-keyword-1-ref.html',
     '/layout/reftests/css-visited/inherit-keyword-1.xhtml',
     '/layout/reftests/css-visited/link-root-1-ref.xhtml',
     '/layout/reftests/css-visited/link-root-1.xhtml',
+    '/layout/reftests/css-visited/logical-box-border-color-visited-link-001.html',
+    '/layout/reftests/css-visited/logical-box-border-color-visited-link-002.html',
+    '/layout/reftests/css-visited/logical-box-border-color-visited-link-ref.html',
     '/layout/reftests/css-visited/mathml-links-ref.html',
     '/layout/reftests/css-visited/mathml-links.html',
     '/layout/reftests/css-visited/outline-1-ref.html',
     '/layout/reftests/css-visited/outline-1.html',
     '/layout/reftests/css-visited/placeholder-1-ref.html',
     '/layout/reftests/css-visited/placeholder-1.html',
     '/layout/reftests/css-visited/selector-adj-sibling-1-ref.html',
     '/layout/reftests/css-visited/selector-adj-sibling-1.html',
--- a/layout/style/test/test_visited_reftests.html
+++ b/layout/style/test/test_visited_reftests.html
@@ -85,17 +85,20 @@ var gTests = [
   // FIXME: commented out because dynamic changes on the non-first-line
   // part of the test don't work right when the link becomes visited.
   //"== first-line-1.html first-line-1-ref.html",
   "== white-to-transparent-1.html white-to-transparent-1-ref.html",
   "== link-root-1.xhtml link-root-1-ref.xhtml",
   "== mathml-links.html mathml-links-ref.html",
   "== placeholder-1.html placeholder-1-ref.html",
   "== visited-inherit-1.html visited-inherit-1-ref.html",
-  "== transition-on-visited.html transition-on-visited-ref.html"
+  "== transition-on-visited.html transition-on-visited-ref.html",
+  "== logical-box-border-color-visited-link-001.html logical-box-border-color-visited-link-ref.html",
+  // TODO: test should equal the reference after implementing logical border shorthands.
+  "!= logical-box-border-color-visited-link-002.html logical-box-border-color-visited-link-ref.html",
 ];
 
 // We record the maximum number of times we had to look at a test before
 // it switched to the passing state (though we assume it's 10 to start
 // rather than 0 so that we have a reasonable default).  Then we make a
 // test "time out" if it takes more than gTimeoutFactor times that
 // amount of time.  This allows us to report a test failure rather than
 // making a test failure just show up as a timeout.
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -3763,24 +3763,16 @@ where
         % endif
         for (declaration, cascade_level) in iter_declarations() {
             let declaration_id = declaration.id();
             let longhand_id = match declaration_id {
                 PropertyDeclarationId::Longhand(id) => id,
                 PropertyDeclarationId::Custom(..) => continue,
             };
 
-            // Only a few properties are allowed to depend on the visited state
-            // of links.  When cascading visited styles, we can save time by
-            // only processing these properties.
-            if flags.contains(CascadeFlags::VISITED_DEPENDENT_ONLY) &&
-               !longhand_id.is_visited_dependent() {
-                continue
-            }
-
             if !apply_reset && !longhand_id.inherited() {
                 continue;
             }
 
             if
                 % if category_to_cascade_now == "early":
                     !
                 % endif
@@ -3790,16 +3782,24 @@ where
             }
 
             <% maybe_to_physical = ".to_physical(writing_mode)" if category_to_cascade_now != "early" else "" %>
             let physical_longhand_id = longhand_id ${maybe_to_physical};
             if seen.contains(physical_longhand_id) {
                 continue
             }
 
+            // Only a few properties are allowed to depend on the visited state
+            // of links.  When cascading visited styles, we can save time by
+            // only processing these properties.
+            if flags.contains(CascadeFlags::VISITED_DEPENDENT_ONLY) &&
+               !physical_longhand_id.is_visited_dependent() {
+                continue
+            }
+
             let mut declaration = match *declaration {
                 PropertyDeclaration::WithVariables(ref declaration) => {
                     if !declaration.id.inherited() {
                         context.rule_cache_conditions.borrow_mut()
                             .set_uncacheable();
                     }
                     Cow::Owned(declaration.value.substitute_variables(
                         declaration.id,