Skip to content

Commit

Permalink
style: added text-decoration-thickness to the text-decoration shortha…
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Marlow authored and emilio committed Aug 15, 2019
1 parent 29f6db4 commit ad1d028
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 0 additions & 1 deletion components/style/properties/data.py
Expand Up @@ -653,7 +653,6 @@ def _remove_common_first_line_and_first_letter_properties(props, engine):
props.remove("text-emphasis-style")
props.remove("text-emphasis-color")
props.remove("text-decoration-skip-ink")
props.remove("text-decoration-thickness")
props.remove("text-underline-offset")

props.remove("overflow-wrap")
Expand Down
1 change: 1 addition & 0 deletions components/style/properties/longhands/text.mako.rs
Expand Up @@ -74,6 +74,7 @@ ${helpers.predefined_type(
"LengthOrAuto",
"computed::LengthOrAuto::auto()",
engines="gecko",
initial_specified_value="specified::LengthOrAuto::auto()",
animation_value_type="ComputedValue",
gecko_pref="layout.css.text-decoration-thickness.enabled",
spec="https://drafts.csswg.org/css-text-decor-4/#text-decoration-width-property"
Expand Down
21 changes: 18 additions & 3 deletions components/style/properties/shorthands/text.mako.rs
Expand Up @@ -8,12 +8,13 @@
engines="gecko servo-2013"
flags="SHORTHAND_IN_GETCS"
sub_properties="text-decoration-line
${' text-decoration-style text-decoration-color' if engine == 'gecko' else ''}"
${' text-decoration-style text-decoration-color text-decoration-thickness' if engine == 'gecko' else ''}"
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration">

% if engine == "gecko":
use crate::values::specified;
use crate::properties::longhands::{text_decoration_style, text_decoration_color};
use crate::properties::longhands::{text_decoration_style, text_decoration_color, text_decoration_thickness};
use crate::properties::{PropertyId, LonghandId};
% endif
use crate::properties::longhands::text_decoration_line;

Expand All @@ -22,11 +23,14 @@
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
% if engine == "gecko":
let (mut line, mut style, mut color, mut any) = (None, None, None, false);
let (mut line, mut style, mut color, mut thickness, mut any) = (None, None, None, None, false);
% else:
let (mut line, mut any) = (None, false);
% endif

let text_decoration_thickness_enabled =
PropertyId::Longhand(LonghandId::TextDecorationThickness).enabled_for_all_content();

loop {
macro_rules! parse_component {
($value:ident, $module:ident) => (
Expand All @@ -45,6 +49,9 @@
% if engine == "gecko":
parse_component!(style, text_decoration_style);
parse_component!(color, text_decoration_color);
if text_decoration_thickness_enabled {
parse_component!(thickness, text_decoration_thickness);
}
% endif

break;
Expand All @@ -60,6 +67,7 @@
% if engine == "gecko":
text_decoration_style: unwrap_or_initial!(text_decoration_style, style),
text_decoration_color: unwrap_or_initial!(text_decoration_color, color),
text_decoration_thickness: unwrap_or_initial!(text_decoration_thickness, thickness),
% endif
})
}
Expand All @@ -78,6 +86,13 @@
dest.write_str(" ")?;
self.text_decoration_color.to_css(dest)?;
}

if let Some(text_decoration_thickness) = self.text_decoration_thickness {
if !text_decoration_thickness.is_auto() {
dest.write_str(" ")?;
self.text_decoration_thickness.to_css(dest)?;
}
}
% endif

Ok(())
Expand Down

0 comments on commit ad1d028

Please sign in to comment.