diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-13 04:40:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 04:40:18 -0500 |
commit | e83e102736907a5905134aa129dd43debf5c216c (patch) | |
tree | bfa194cc4ed0125dc495e52123d727dd9cf1a940 | |
parent | 9be1fead3ccf419e5d32a935ba6a5271c2e5170a (diff) | |
parent | 5b4f0686c7738548c5f5d99a42dfc46c294e864b (diff) | |
download | servo-e83e102736907a5905134aa129dd43debf5c216c.tar.gz servo-e83e102736907a5905134aa129dd43debf5c216c.zip |
Auto merge of #16827 - upsuper:subprop-font-feature-settings, r=Manishearth
Make font-feature-settings a subprop of font
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16827)
<!-- Reviewable:end -->
-rw-r--r-- | components/style/properties/data.py | 3 | ||||
-rw-r--r-- | components/style/properties/longhand/font.mako.rs | 31 | ||||
-rw-r--r-- | components/style/properties/shorthand/font.mako.rs | 5 | ||||
-rw-r--r-- | tests/unit/style/parsing/font.rs | 23 | ||||
-rw-r--r-- | tests/unit/style/properties/serialization.rs | 3 |
5 files changed, 41 insertions, 24 deletions
diff --git a/components/style/properties/data.py b/components/style/properties/data.py index eb1706e691e..8bb1fc86988 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -18,7 +18,8 @@ SYSTEM_FONT_LONGHANDS = """font_family font_size font_style font_variant_position font_weight font_size_adjust font_variant_alternates font_variant_ligatures font_variant_east_asian - font_variant_numeric font_language_override""".split() + font_variant_numeric font_language_override + font_feature_settings""".split() def maybe_moz_logical_alias(product, side, prop): diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 11e4aeb1ef0..6691603499f 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -22,7 +22,7 @@ impl ToCss for SpecifiedValue { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { - SpecifiedValue::Value(v) => v.to_css(dest), + SpecifiedValue::Value(ref v) => v.to_css(dest), SpecifiedValue::System(_) => Ok(()) } } @@ -47,17 +47,17 @@ fn to_computed_value(&self, _context: &Context) -> computed_value::T { match *self { - SpecifiedValue::Value(v) => v, + SpecifiedValue::Value(ref v) => v.clone(), SpecifiedValue::System(_) => { <%self:nongecko_unreachable> - _context.cached_system_font.as_ref().unwrap().${name} + _context.cached_system_font.as_ref().unwrap().${name}.clone() </%self:nongecko_unreachable> } } } fn from_computed_value(other: &computed_value::T) -> Self { - SpecifiedValue::Value(*other) + SpecifiedValue::Value(other.clone()) } } </%def> @@ -1777,17 +1777,24 @@ ${helpers.single_keyword_system("font-variant-position", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-position", animation_value_type="none")} -<%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="none" extra_prefixes="moz" +<%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="none" + extra_prefixes="moz" boxed="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings"> + use properties::longhands::system_font::SystemFont; use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; use values::computed::ComputedValueAsSpecified; - pub use self::computed_value::T as SpecifiedValue; - impl ComputedValueAsSpecified for SpecifiedValue {} + #[derive(Debug, Clone, PartialEq)] + pub enum SpecifiedValue { + Value(computed_value::T), + System(SystemFont) + } no_viewport_percentage!(SpecifiedValue); + <%self:simple_system_boilerplate name="font_feature_settings"></%self:simple_system_boilerplate> + pub mod computed_value { use cssparser::Parser; use parser::{Parse, ParserContext}; @@ -1891,13 +1898,18 @@ ${helpers.single_keyword_system("font-variant-position", computed_value::T::Normal } + #[inline] + pub fn get_initial_specified_value() -> SpecifiedValue { + SpecifiedValue::Value(computed_value::T::Normal) + } + /// normal | <feature-tag-value># pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { if input.try(|input| input.expect_ident_matching("normal")).is_ok() { - Ok(computed_value::T::Normal) + Ok(SpecifiedValue::Value(computed_value::T::Normal)) } else { input.parse_comma_separated(|i| computed_value::FeatureTagValue::parse(context, i)) - .map(computed_value::T::Tag) + .map(computed_value::T::Tag).map(SpecifiedValue::Value) } } </%helpers:longhand> @@ -2390,6 +2402,7 @@ ${helpers.single_keyword("-moz-math-variant", % endfor font_language_override: longhands::font_language_override::computed_value ::T(system.languageOverride), + font_feature_settings: longhands::font_feature_settings::get_initial_value(), system_font: *self, }; unsafe { bindings::Gecko_nsFont_Destroy(&mut system); } diff --git a/components/style/properties/shorthand/font.mako.rs b/components/style/properties/shorthand/font.mako.rs index f82aea164cc..409e0717013 100644 --- a/components/style/properties/shorthand/font.mako.rs +++ b/components/style/properties/shorthand/font.mako.rs @@ -15,7 +15,8 @@ ${'font-variant-ligatures' if product == 'gecko' or data.testing else ''} ${'font-variant-numeric' if product == 'gecko' or data.testing else ''} ${'font-variant-position' if product == 'gecko' or data.testing else ''} - ${'font-language-override' if product == 'gecko' or data.testing else ''}" + ${'font-language-override' if product == 'gecko' or data.testing else ''} + ${'font-feature-settings' if product == 'gecko' or data.testing else ''}" spec="https://drafts.csswg.org/css-fonts-3/#propdef-font"> use properties::longhands::{font_family, font_style, font_weight, font_stretch}; use properties::longhands::{font_size, line_height, font_variant_caps}; @@ -25,7 +26,7 @@ gecko_sub_properties = "kerning language_override size_adjust \ variant_alternates variant_east_asian \ variant_ligatures variant_numeric \ - variant_position".split() + variant_position feature_settings".split() %> % if product == "gecko" or data.testing: % for prop in gecko_sub_properties: diff --git a/tests/unit/style/parsing/font.rs b/tests/unit/style/parsing/font.rs index 4513f79ce98..607f0ecb967 100644 --- a/tests/unit/style/parsing/font.rs +++ b/tests/unit/style/parsing/font.rs @@ -4,6 +4,7 @@ use parsing::parse; use style::properties::longhands::{font_feature_settings, font_weight}; +use style::properties::longhands::font_feature_settings::SpecifiedValue; use style::properties::longhands::font_feature_settings::computed_value; use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue; use style_traits::ToCss; @@ -14,7 +15,7 @@ fn font_feature_settings_should_parse_properly() { use std::io::Cursor; let normal = parse_longhand!(font_feature_settings, "normal"); - let normal_computed = computed_value::T::Normal; + let normal_computed = SpecifiedValue::Value(computed_value::T::Normal); assert_eq!(normal, normal_computed); let mut a_d_bytes = Cursor::new(b"abcd"); @@ -24,34 +25,34 @@ fn font_feature_settings_should_parse_properly() { let efgh = e_h_bytes.read_u32::<BigEndian>().unwrap(); let on = parse_longhand!(font_feature_settings, "\"abcd\" on"); - let on_computed = computed_value::T::Tag(vec![ + let on_computed = SpecifiedValue::Value(computed_value::T::Tag(vec![ FeatureTagValue { tag: abcd, value: 1 } - ]); + ])); assert_eq!(on, on_computed); let off = parse_longhand!(font_feature_settings, "\"abcd\" off"); - let off_computed = computed_value::T::Tag(vec![ + let off_computed = SpecifiedValue::Value(computed_value::T::Tag(vec![ FeatureTagValue { tag: abcd, value: 0 } - ]); + ])); assert_eq!(off, off_computed); let no_value = parse_longhand!(font_feature_settings, "\"abcd\""); - let no_value_computed = computed_value::T::Tag(vec![ + let no_value_computed = SpecifiedValue::Value(computed_value::T::Tag(vec![ FeatureTagValue { tag: abcd, value: 1 } - ]); + ])); assert_eq!(no_value, no_value_computed); let pos_integer = parse_longhand!(font_feature_settings, "\"abcd\" 100"); - let pos_integer_computed = computed_value::T::Tag(vec![ + let pos_integer_computed = SpecifiedValue::Value(computed_value::T::Tag(vec![ FeatureTagValue { tag: abcd, value: 100 } - ]); + ])); assert_eq!(pos_integer, pos_integer_computed); let multiple = parse_longhand!(font_feature_settings, "\"abcd\" off, \"efgh\""); - let multiple_computed = computed_value::T::Tag(vec![ + let multiple_computed = SpecifiedValue::Value(computed_value::T::Tag(vec![ FeatureTagValue { tag: abcd, value: 0 }, FeatureTagValue { tag: efgh, value: 1 } - ]); + ])); assert_eq!(multiple, multiple_computed); } diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index f164b656ce1..426597e56b4 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -653,7 +653,8 @@ mod shorthand_serialization { font-kerning: auto; \ font-variant-caps: normal; \ font-variant-position: normal; \ - font-language-override: normal;"; + font-language-override: normal; \ + font-feature-settings: normal;"; let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap(); |