Skip to content

Commit

Permalink
Auto merge of #16827 - upsuper:subprop-font-feature-settings, r=Manis…
Browse files Browse the repository at this point in the history
…hearth

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 -->
  • Loading branch information
bors-servo committed May 12, 2017
2 parents 875b07b + 0e09b81 commit f2e80f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
3 changes: 2 additions & 1 deletion components/style/properties/data.py
Expand Up @@ -18,7 +18,8 @@
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):
Expand Down
28 changes: 20 additions & 8 deletions components/style/properties/longhand/font.mako.rs
Expand Up @@ -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(())
}
}
Expand All @@ -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>
Expand Down Expand Up @@ -1762,15 +1762,21 @@ ${helpers.single_keyword_system("font-variant-position",

<%helpers:longhand name="font-feature-settings" products="gecko" animation_value_type="none" extra_prefixes="moz"
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};
Expand Down Expand Up @@ -1874,13 +1880,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>
Expand Down Expand Up @@ -2373,6 +2384,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); }
Expand Down
5 changes: 3 additions & 2 deletions components/style/properties/shorthand/font.mako.rs
Expand Up @@ -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};
Expand All @@ -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:
Expand Down

0 comments on commit f2e80f5

Please sign in to comment.