commit e07fe5183b75
Author: J. Ryan Stinnett <jryans@gmail.com>
Date: Wed Oct 11 18:50:23 2017 -0500
Bug 1406254 - servo: Clear visited rules for text inheritance. r=emilio, a=ritu
Source-Repo: https://github.com/servo/servo
Source-Revision: dbf0991f8cab54516c5b0211e1818a16cfbf9e19
MozReview-Commit-ID: LP8VmxRopA4
---
servo/components/style/properties/gecko.mako.rs | 2 +-
servo/components/style/properties/properties.mako.rs | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git servo/components/style/properties/gecko.mako.rs servo/components/style/properties/gecko.mako.rs
index d7e5496971e3..090a31ff9d4b 100644
--- servo/components/style/properties/gecko.mako.rs
+++ servo/components/style/properties/gecko.mako.rs
@@ -323,7 +323,7 @@ impl ComputedValuesInner {
}
/// Clone the visited style. Used for inheriting parent styles in
- /// StyleBuilder::for_inheritance.
+ /// StyleBuilder::for_derived_style.
pub fn clone_visited_style(&self) -> Option<Arc<ComputedValues>> {
self.visited_style.as_ref().map(|x| x.clone_arc())
}
diff --git servo/components/style/properties/properties.mako.rs servo/components/style/properties/properties.mako.rs
index 269bf0dbbbb5..80238450a9c5 100644
--- servo/components/style/properties/properties.mako.rs
+++ servo/components/style/properties/properties.mako.rs
@@ -2170,7 +2170,7 @@ impl ComputedValuesInner {
}
/// Clone the visited style. Used for inheriting parent styles in
- /// StyleBuilder::for_inheritance.
+ /// StyleBuilder::for_derived_style.
pub fn clone_visited_style(&self) -> Option<Arc<ComputedValues>> {
self.visited_style.clone()
}
@@ -2830,6 +2830,18 @@ impl<'a> StyleBuilder<'a> {
parent: &'a ComputedValues,
pseudo: Option<<&'a PseudoElement>,
) -> Self {
+ // Rebuild the visited style from the parent, ensuring that it will also
+ // not have rules. This matches the unvisited style that will be
+ // produced by this builder. This assumes that the caller doesn't need
+ // to adjust or process visited style, so we can just build visited
+ // style here for simplicity.
+ let visited_style = parent.get_visited_style().map(|style| {
+ Self::for_inheritance(
+ device,
+ style,
+ pseudo,
+ ).build()
+ });
// FIXME(emilio): This Some(parent) here is inconsistent with what we
// usually do if `parent` is the default computed values, but that's
// fine, and we want to eventually get rid of it.
@@ -2844,7 +2856,7 @@ impl<'a> StyleBuilder<'a> {
parent.writing_mode,
parent.font_computation_data,
parent.flags,
- parent.clone_visited_style()
+ visited_style,
)
}
commit d8586d78bd43
Author: J. Ryan Stinnett <jryans@gmail.com>
Date: Wed Oct 11 15:33:14 2017 -0500
Bug 1406254 - Visited reftest for ::first-line inheritance. r=emilio, a=ritu
MozReview-Commit-ID: 4ZOlVvBuSfT
---
.../css-visited/color-on-visited-text-1-ref.html | 16 ++++++++++++++++
.../css-visited/color-on-visited-text-1.html | 20 ++++++++++++++++++++
layout/style/test/moz.build | 2 ++
layout/style/test/test_visited_reftests.html | 1 +
4 files changed, 39 insertions(+)
diff --git layout/reftests/css-visited/color-on-visited-text-1-ref.html layout/reftests/css-visited/color-on-visited-text-1-ref.html
new file mode 100644
index 000000000000..b144767ce76e
--- /dev/null
+++ layout/reftests/css-visited/color-on-visited-text-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+ .unvisited {
+ color: blue;
+ }
+ .visited {
+ color: purple;
+ }
+ .first-line {
+ color: green;
+ }
+</style>
+<div class="first-line">Visited</div>
+<div class="first-line">Visited with span</div>
+<div class="unvisited">Visited with inner unvisited</div>
+<div class="visited">Visited with inner visited</div>
diff --git layout/reftests/css-visited/color-on-visited-text-1.html layout/reftests/css-visited/color-on-visited-text-1.html
new file mode 100644
index 000000000000..d9dab8f3b8a7
--- /dev/null
+++ layout/reftests/css-visited/color-on-visited-text-1.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+ a {
+ display: block;
+ text-decoration: none;
+ }
+ :link {
+ color: blue;
+ }
+ :visited {
+ color: purple;
+ }
+ .outer::first-line {
+ color: green;
+ }
+</style>
+<a class="outer" href>Visited</a>
+<a class="outer" href><span>Visited with span</span></a>
+<a class="outer" href><a href="unvisited-page.html">Visited with inner unvisited</a></a>
+<a class="outer" href><a href>Visited with inner visited</a></a>
diff --git layout/style/test/moz.build layout/style/test/moz.build
index fa646ca16dd3..74fe23260aa7 100644
--- layout/style/test/moz.build
+++ layout/style/test/moz.build
@@ -60,6 +60,8 @@ TEST_HARNESS_FILES.testing.mochitest.tests.layout.style.test['css-visited'] += [
'/layout/reftests/css-visited/color-on-visited-1-ref.html',
'/layout/reftests/css-visited/color-on-visited-1.html',
'/layout/reftests/css-visited/color-on-visited-before-1.html',
+ '/layout/reftests/css-visited/color-on-visited-text-1-ref.html',
+ '/layout/reftests/css-visited/color-on-visited-text-1.html',
'/layout/reftests/css-visited/column-rule-1-notref.html',
'/layout/reftests/css-visited/column-rule-1-ref.html',
'/layout/reftests/css-visited/column-rule-1.html',
diff --git layout/style/test/test_visited_reftests.html layout/style/test/test_visited_reftests.html
index aea857f031d2..850d35bae867 100644
--- layout/style/test/test_visited_reftests.html
+++ layout/style/test/test_visited_reftests.html
@@ -38,6 +38,7 @@ var gTests = [
"== color-on-link-before-1.html color-on-link-1-ref.html",
"== color-on-visited-1.html color-on-visited-1-ref.html",
"== color-on-visited-before-1.html color-on-visited-1-ref.html",
+ "== color-on-visited-text-1.html color-on-visited-text-1-ref.html",
"!= content-color-on-link-before-1-ref.html content-color-on-visited-before-1-ref.html",
"== content-color-on-link-before-1.html content-color-on-link-before-1-ref.html",
"== content-color-on-visited-before-1.html content-color-on-visited-before-1-ref.html",