mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
style: Update font-size-adjust keywords to match CSSWG resolution in csswg-drafts/#6288
Differential Revision: https://phabricator.services.mozilla.com/D118198
This commit is contained in:
parent
25edb3c21b
commit
695ff236c8
2 changed files with 20 additions and 15 deletions
|
@ -207,6 +207,7 @@ pub enum FontStyle<Angle> {
|
|||
///
|
||||
/// https://www.w3.org/TR/css-fonts-4/#font-size-adjust-prop
|
||||
/// https://github.com/w3c/csswg-drafts/issues/6160
|
||||
/// https://github.com/w3c/csswg-drafts/issues/6288
|
||||
#[allow(missing_docs)]
|
||||
#[repr(u8)]
|
||||
#[derive(
|
||||
|
@ -228,14 +229,16 @@ pub enum FontStyle<Angle> {
|
|||
pub enum GenericFontSizeAdjust<Number> {
|
||||
#[animation(error)]
|
||||
None,
|
||||
// 'ex' is the implied basis, so the keyword can be omitted
|
||||
Ex(Number),
|
||||
// 'ex-height' is the implied basis, so the keyword can be omitted
|
||||
ExHeight(Number),
|
||||
#[value_info(starts_with_keyword)]
|
||||
Cap(Number),
|
||||
CapHeight(Number),
|
||||
#[value_info(starts_with_keyword)]
|
||||
Ch(Number),
|
||||
ChWidth(Number),
|
||||
#[value_info(starts_with_keyword)]
|
||||
Ic(Number),
|
||||
IcWidth(Number),
|
||||
#[value_info(starts_with_keyword)]
|
||||
IcHeight(Number),
|
||||
}
|
||||
|
||||
impl<Number: ToCss> ToCss for GenericFontSizeAdjust<Number> {
|
||||
|
@ -245,10 +248,11 @@ impl<Number: ToCss> ToCss for GenericFontSizeAdjust<Number> {
|
|||
{
|
||||
let (prefix, value) = match self {
|
||||
Self::None => return dest.write_str("none"),
|
||||
Self::Ex(v) => ("", v),
|
||||
Self::Cap(v) => ("cap ", v),
|
||||
Self::Ch(v) => ("ch ", v),
|
||||
Self::Ic(v) => ("ic ", v),
|
||||
Self::ExHeight(v) => ("", v),
|
||||
Self::CapHeight(v) => ("cap-height ", v),
|
||||
Self::ChWidth(v) => ("ch-width ", v),
|
||||
Self::IcWidth(v) => ("ic-width ", v),
|
||||
Self::IcHeight(v) => ("ic-height ", v),
|
||||
};
|
||||
|
||||
dest.write_str(prefix)?;
|
||||
|
|
|
@ -794,10 +794,11 @@ impl Parse for FontSizeAdjust {
|
|||
let basis = match_ignore_ascii_case! { &ident,
|
||||
"none" => return Ok(FontSizeAdjust::none()),
|
||||
// Check for size adjustment basis keywords if enabled.
|
||||
"ex" if basis_enabled => GenericFontSizeAdjust::Ex,
|
||||
"cap" if basis_enabled => GenericFontSizeAdjust::Cap,
|
||||
"ch" if basis_enabled => GenericFontSizeAdjust::Ch,
|
||||
"ic" if basis_enabled => GenericFontSizeAdjust::Ic,
|
||||
"ex-height" if basis_enabled => GenericFontSizeAdjust::ExHeight,
|
||||
"cap-height" if basis_enabled => GenericFontSizeAdjust::CapHeight,
|
||||
"ch-width" if basis_enabled => GenericFontSizeAdjust::ChWidth,
|
||||
"ic-width" if basis_enabled => GenericFontSizeAdjust::IcWidth,
|
||||
"ic-height" if basis_enabled => GenericFontSizeAdjust::IcHeight,
|
||||
// Unknown (or disabled) keyword.
|
||||
_ => return Err(location.new_custom_error(
|
||||
::selectors::parser::SelectorParseErrorKind::UnexpectedIdent(ident)
|
||||
|
@ -806,9 +807,9 @@ impl Parse for FontSizeAdjust {
|
|||
let value = NonNegativeNumber::parse(context, input)?;
|
||||
return Ok(FontSizeAdjust::Value(basis(value)));
|
||||
}
|
||||
// Without a basis keyword, the number refers to the 'ex' metric.
|
||||
// Without a basis keyword, the number refers to the 'ex-height' metric.
|
||||
let value = NonNegativeNumber::parse(context, input)?;
|
||||
Ok(FontSizeAdjust::Value(GenericFontSizeAdjust::Ex(value)))
|
||||
Ok(FontSizeAdjust::Value(GenericFontSizeAdjust::ExHeight(value)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue