From 46396d7f3b11f88667d69616073419a990c1e9d3 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 28 Jun 2016 15:35:19 -0700 Subject: [PATCH] Do not merge text fragments of differing colors The display list item for a line of text has a single color assigned for it, so text fragments with different colors cannot be merged. There is no issue number for this, as far as I know. I found this while trying an internal program that uses red asterisks for required text fields. --- components/layout/fragment.rs | 13 ++++++---- .../html4/content-inherit-002.htm.ini | 3 --- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ .../wpt/mozilla/tests/css/content_color.html | 8 +++++++ .../mozilla/tests/css/content_color_ref.html | 7 ++++++ 5 files changed, 48 insertions(+), 7 deletions(-) delete mode 100644 tests/wpt/metadata-css/css21_dev/html4/content-inherit-002.htm.ini create mode 100644 tests/wpt/mozilla/tests/css/content_color.html create mode 100644 tests/wpt/mozilla/tests/css/content_color_ref.html diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 28d88e48da3..92edd5f2d4c 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -38,9 +38,9 @@ use std::collections::LinkedList; use std::fmt; use std::sync::{Arc, Mutex}; use style::computed_values::content::ContentItem; -use style::computed_values::{border_collapse, clear, display, mix_blend_mode, overflow_wrap}; -use style::computed_values::{overflow_x, position, text_decoration, transform_style}; -use style::computed_values::{vertical_align, white_space, word_break, z_index}; +use style::computed_values::{border_collapse, clear, color, display, mix_blend_mode}; +use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration}; +use style::computed_values::{transform_style, vertical_align, white_space, word_break, z_index}; use style::dom::TRestyleDamage; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::properties::{ComputedValues, ServoComputedValues}; @@ -1304,6 +1304,10 @@ impl Fragment { self.style().get_inheritedtext().white_space } + pub fn color(&self) -> color::T { + self.style().get_color().color + } + /// Returns the text decoration of this fragment, according to the style of the nearest ancestor /// element. /// @@ -2042,7 +2046,8 @@ impl Fragment { // FIXME: Should probably use a whitelist of styles that can safely differ (#3165) if self.style().get_font() != other.style().get_font() || self.text_decoration() != other.text_decoration() || - self.white_space() != other.white_space() { + self.white_space() != other.white_space() || + self.color() != other.color() { return false } diff --git a/tests/wpt/metadata-css/css21_dev/html4/content-inherit-002.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/content-inherit-002.htm.ini deleted file mode 100644 index 2bbd2da84e1..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/content-inherit-002.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[content-inherit-002.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index fff9517a8b1..c274c632fd7 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -1272,6 +1272,18 @@ "url": "/_mozilla/css/clip_a.html" } ], + "css/content_color.html": [ + { + "path": "css/content_color.html", + "references": [ + [ + "/_mozilla/css/content_color_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/content_color.html" + } + ], "css/counters_nested_a.html": [ { "path": "css/counters_nested_a.html", @@ -8360,6 +8372,18 @@ "url": "/_mozilla/css/clip_a.html" } ], + "css/content_color.html": [ + { + "path": "css/content_color.html", + "references": [ + [ + "/_mozilla/css/content_color_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/content_color.html" + } + ], "css/counters_nested_a.html": [ { "path": "css/counters_nested_a.html", diff --git a/tests/wpt/mozilla/tests/css/content_color.html b/tests/wpt/mozilla/tests/css/content_color.html new file mode 100644 index 00000000000..eb12f372949 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/content_color.html @@ -0,0 +1,8 @@ + + +Pseudo-elements can have color + + +A diff --git a/tests/wpt/mozilla/tests/css/content_color_ref.html b/tests/wpt/mozilla/tests/css/content_color_ref.html new file mode 100644 index 00000000000..4a34431c367 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/content_color_ref.html @@ -0,0 +1,7 @@ + +This test should have a red B and a black A + +AB