diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 26a29a49f39..9bf491a4546 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -16,7 +16,8 @@ ${helpers.single_keyword("text-overflow", "clip ellipsis")} ${helpers.single_keyword("unicode-bidi", "normal embed isolate bidi-override isolate-override plaintext")} -<%helpers:longhand name="text-decoration" custom_cascade="${product == 'servo'}"> +<%helpers:longhand name="${'text-decoration' if product == 'servo' else 'text-decoration-line'}" + custom_cascade="${product == 'servo'}"> use cssparser::ToCss; use std::fmt; use values::computed::ComputedValueAsSpecified; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index ec6fe6562e0..9a1b2546efa 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -130,6 +130,7 @@ pub mod shorthands { <%include file="/shorthand/margin.mako.rs" /> <%include file="/shorthand/outline.mako.rs" /> <%include file="/shorthand/padding.mako.rs" /> + <%include file="/shorthand/text.mako.rs" /> } @@ -815,14 +816,15 @@ pub mod style_structs { self.outline_width != ::app_units::Au(0) } % elif style_struct.trait_name == "Text": + <% text_decoration_field = 'text_decoration' if product == 'servo' else 'text_decoration_line' %> fn has_underline(&self) -> bool { - self.text_decoration.underline + self.${text_decoration_field}.underline } fn has_overline(&self) -> bool { - self.text_decoration.overline + self.${text_decoration_field}.overline } fn has_line_through(&self) -> bool { - self.text_decoration.line_through + self.${text_decoration_field}.line_through } % endif } @@ -1463,7 +1465,7 @@ pub fn cascade( PropertyDeclaration::Color(_) | PropertyDeclaration::Position(_) | PropertyDeclaration::Float(_) | - PropertyDeclaration::TextDecoration(_) + PropertyDeclaration::TextDecoration${'' if product == 'servo' else 'Line'}(_) ); if % if category_to_cascade_now == "early": diff --git a/components/style/properties/shorthand/text.mako.rs b/components/style/properties/shorthand/text.mako.rs new file mode 100644 index 00000000000..becdb111231 --- /dev/null +++ b/components/style/properties/shorthand/text.mako.rs @@ -0,0 +1,46 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +<%namespace name="helpers" file="/helpers.mako.rs" /> + +<%helpers:shorthand name="text-decoration" + sub_properties="text-decoration-color + text-decoration-line + text-decoration-style" + products="gecko"> + use cssparser::Color as CSSParserColor; + use properties::longhands::{text_decoration_color, text_decoration_line, text_decoration_style}; + use values::specified::CSSColor; + + let (mut color, mut line, mut style, mut any) = (None, None, None, false); + loop { + macro_rules! parse_component { + ($value:ident, $module:ident) => ( + if $value.is_none() { + if let Ok(value) = input.try(|input| $module::parse(context, input)) { + $value = Some(value); + any = true; + continue; + } + } + ) + } + + parse_component!(color, text_decoration_color); + parse_component!(line, text_decoration_line); + parse_component!(style, text_decoration_style); + break; + } + + if !any { + return Err(()); + } + + Ok(Longhands { + text_decoration_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor, + authored: None })), + text_decoration_line: line.or(Some(text_decoration_line::computed_value::none)), + text_decoration_style: style.or(Some(text_decoration_style::computed_value::T::solid)), + }) + diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 387f5e02edb..bff52878d70 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -727,20 +727,36 @@ fn static_assert() { <%self:impl_trait style_struct_name="Text" - skip_longhands="text-decoration-color" + skip_longhands="text-decoration-color text-decoration-line" skip_additionals="*"> <% impl_color("text_decoration_color", "mTextDecorationColor", color_flags_ffi_name="mTextDecorationStyle") %> + fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) { + let mut bits: u8 = 0; + if v.underline { + bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8; + } + if v.overline { + bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8; + } + if v.line_through { + bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8; + } + self.gecko.mTextDecorationLine = bits; + } + + <%call expr="impl_simple_copy('text_decoration_line', 'mTextDecorationLine')"> + fn has_underline(&self) -> bool { - (self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0 + (self.gecko.mTextDecorationLine & (structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0 } fn has_overline(&self) -> bool { - (self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8)) != 0 + (self.gecko.mTextDecorationLine & (structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8)) != 0 } fn has_line_through(&self) -> bool { - (self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8)) != 0 + (self.gecko.mTextDecorationLine & (structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8)) != 0 }