Auto merge of #11914 - notriddle:text_fragment_color_merge, r=jdm

Text fragment color merge

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.
____________________

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not fix an existing Github issue
- [X] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11914)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-28 22:43:07 -05:00 committed by GitHub
commit 5b20673d43
6 changed files with 49 additions and 8 deletions

View file

@ -949,7 +949,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// Modify the style as necessary. (See the comment in
// `properties::modify_style_for_replaced_content()`.)
let mut style = (*node.style(self.style_context())).clone();
let mut style = node.style(self.style_context()).clone();
properties::modify_style_for_replaced_content(&mut style);
// If this is generated content, then we need to initialize the accumulator with the

View file

@ -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
}