diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index b54b7494544..9c0d6449164 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -2230,13 +2230,10 @@ impl FragmentDisplayListBuilding for Fragment { // Create display items for text decorations. - let mut text_decorations = self.style() - .get_inheritedtext() - ._servo_text_decorations_in_effect; - // Note that the text decoration colors are always the same as the text color. - text_decorations.underline = text_decorations.underline.map(|_| text_color); - text_decorations.overline = text_decorations.overline.map(|_| text_color); - text_decorations.line_through = text_decorations.line_through.map(|_| text_color); + let text_decorations = + self.style() + .get_inheritedtext() + ._servo_text_decorations_in_effect; let stacking_relative_content_box = LogicalRect::from_physical(self.style.writing_mode, @@ -2244,25 +2241,29 @@ impl FragmentDisplayListBuilding for Fragment { container_size); // Underline - if let Some(ref underline_color) = text_decorations.underline { + if text_decorations.underline { let mut stacking_relative_box = stacking_relative_content_box; stacking_relative_box.start.b = stacking_relative_content_box.start.b + metrics.ascent - metrics.underline_offset; stacking_relative_box.size.block = metrics.underline_size; - self.build_display_list_for_text_decoration(state, - underline_color, - &stacking_relative_box, - clip); + self.build_display_list_for_text_decoration( + state, + &text_color, + &stacking_relative_box, + clip, + ); } // Overline - if let Some(ref overline_color) = text_decorations.overline { + if text_decorations.overline { let mut stacking_relative_box = stacking_relative_content_box; stacking_relative_box.size.block = metrics.underline_size; - self.build_display_list_for_text_decoration(state, - overline_color, - &stacking_relative_box, - clip); + self.build_display_list_for_text_decoration( + state, + &text_color, + &stacking_relative_box, + clip, + ); } // Text @@ -2281,15 +2282,17 @@ impl FragmentDisplayListBuilding for Fragment { // Line-Through - if let Some(ref line_through_color) = text_decorations.line_through { + if text_decorations.line_through { let mut stacking_relative_box = stacking_relative_content_box; stacking_relative_box.start.b = stacking_relative_box.start.b + metrics.ascent - metrics.strikeout_offset; stacking_relative_box.size.block = metrics.strikeout_size; - self.build_display_list_for_text_decoration(state, - line_through_color, - &stacking_relative_box, - clip); + self.build_display_list_for_text_decoration( + state, + &text_color, + &stacking_relative_box, + clip, + ); } // Pair all the PushTextShadows diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 9fbab4b6753..55a8d792733 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -282,17 +282,16 @@ ${helpers.predefined_type("word-spacing", need_clone="True" products="servo" animation_value_type="none" spec="Nonstandard (Internal property used by Servo)"> - use cssparser::RGBA; use std::fmt; use style_traits::ToCss; - #[derive(Clone, Copy, Debug, PartialEq)] + #[derive(Clone, Copy, Debug, Default, PartialEq)] #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { - pub underline: Option, - pub overline: Option, - pub line_through: Option, + pub underline: bool, + pub overline: bool, + pub line_through: bool, } trivial_to_computed_value!(SpecifiedValue); @@ -310,19 +309,7 @@ ${helpers.predefined_type("word-spacing", #[inline] pub fn get_initial_value() -> computed_value::T { - SpecifiedValue { - underline: None, - overline: None, - line_through: None, - } - } - - fn maybe(flag: bool, context: &Context) -> Option { - if flag { - Some(context.style().get_color().clone_color()) - } else { - None - } + SpecifiedValue::default() } fn derive(context: &Context) -> computed_value::T { @@ -330,20 +317,13 @@ ${helpers.predefined_type("word-spacing", // declarations in effect and add in the text decorations that this block specifies. let mut result = match context.style().get_box().clone_display() { super::display::computed_value::T::inline_block | - super::display::computed_value::T::inline_table => SpecifiedValue { - underline: None, - overline: None, - line_through: None, - }, + super::display::computed_value::T::inline_table => get_initial_value(), _ => context.builder.get_parent_inheritedtext().clone__servo_text_decorations_in_effect() }; - result.underline = maybe(context.style().get_text().has_underline() - || result.underline.is_some(), context); - result.overline = maybe(context.style().get_text().has_overline() - || result.overline.is_some(), context); - result.line_through = maybe(context.style().get_text().has_line_through() - || result.line_through.is_some(), context); + result.underline |= context.style().get_text().has_underline(); + result.overline |= context.style().get_text().has_overline(); + result.line_through |= context.style().get_text().has_line_through(); result }