Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13875 - Implement parsing/serialization for font-size-adjust. #14125

Merged
merged 1 commit into from
Nov 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions components/style/properties/longhand/font.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,55 @@ ${helpers.single_keyword("font-variant",
}
</%helpers:longhand>

// https://www.w3.org/TR/css-fonts-3/#font-size-adjust-prop
// FIXME: This prop should be animatable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to work on the gecko glue this is easy to fix.

<%helpers:longhand products="none" name="font-size-adjust" animatable="False">
use values::NoViewportPercentage;
use values::computed::ComputedValueAsSpecified;
use values::specified::Number;

impl ComputedValueAsSpecified for SpecifiedValue {}
impl NoViewportPercentage for SpecifiedValue {}

#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
None,
Number(Number),
}

pub mod computed_value {
use style_traits::ToCss;
use std::fmt;

pub use super::SpecifiedValue as T;

impl ToCss for T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
T::None => dest.write_str("none"),
T::Number(number) => number.to_css(dest),
}
}
}
}

#[inline] pub fn get_initial_value() -> computed_value::T {
computed_value::T::None
}

/// none | <number>
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
use values::specified::Number;

if input.try(|input| input.expect_ident_matching("none")).is_ok() {
return Ok(SpecifiedValue::None);
}

Ok(SpecifiedValue::Number(try!(Number::parse_non_negative(input))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should file a spec bug for making this explicit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
</%helpers:longhand>

<%helpers:longhand products="gecko" name="font-synthesis" animatable="False">
use std::fmt;
use style_traits::ToCss;
Expand Down