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://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/6160
|
||||||
|
/// https://github.com/w3c/csswg-drafts/issues/6288
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(
|
#[derive(
|
||||||
|
@ -228,14 +229,16 @@ pub enum FontStyle<Angle> {
|
||||||
pub enum GenericFontSizeAdjust<Number> {
|
pub enum GenericFontSizeAdjust<Number> {
|
||||||
#[animation(error)]
|
#[animation(error)]
|
||||||
None,
|
None,
|
||||||
// 'ex' is the implied basis, so the keyword can be omitted
|
// 'ex-height' is the implied basis, so the keyword can be omitted
|
||||||
Ex(Number),
|
ExHeight(Number),
|
||||||
#[value_info(starts_with_keyword)]
|
#[value_info(starts_with_keyword)]
|
||||||
Cap(Number),
|
CapHeight(Number),
|
||||||
#[value_info(starts_with_keyword)]
|
#[value_info(starts_with_keyword)]
|
||||||
Ch(Number),
|
ChWidth(Number),
|
||||||
#[value_info(starts_with_keyword)]
|
#[value_info(starts_with_keyword)]
|
||||||
Ic(Number),
|
IcWidth(Number),
|
||||||
|
#[value_info(starts_with_keyword)]
|
||||||
|
IcHeight(Number),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Number: ToCss> ToCss for GenericFontSizeAdjust<Number> {
|
impl<Number: ToCss> ToCss for GenericFontSizeAdjust<Number> {
|
||||||
|
@ -245,10 +248,11 @@ impl<Number: ToCss> ToCss for GenericFontSizeAdjust<Number> {
|
||||||
{
|
{
|
||||||
let (prefix, value) = match self {
|
let (prefix, value) = match self {
|
||||||
Self::None => return dest.write_str("none"),
|
Self::None => return dest.write_str("none"),
|
||||||
Self::Ex(v) => ("", v),
|
Self::ExHeight(v) => ("", v),
|
||||||
Self::Cap(v) => ("cap ", v),
|
Self::CapHeight(v) => ("cap-height ", v),
|
||||||
Self::Ch(v) => ("ch ", v),
|
Self::ChWidth(v) => ("ch-width ", v),
|
||||||
Self::Ic(v) => ("ic ", v),
|
Self::IcWidth(v) => ("ic-width ", v),
|
||||||
|
Self::IcHeight(v) => ("ic-height ", v),
|
||||||
};
|
};
|
||||||
|
|
||||||
dest.write_str(prefix)?;
|
dest.write_str(prefix)?;
|
||||||
|
|
|
@ -794,10 +794,11 @@ impl Parse for FontSizeAdjust {
|
||||||
let basis = match_ignore_ascii_case! { &ident,
|
let basis = match_ignore_ascii_case! { &ident,
|
||||||
"none" => return Ok(FontSizeAdjust::none()),
|
"none" => return Ok(FontSizeAdjust::none()),
|
||||||
// Check for size adjustment basis keywords if enabled.
|
// Check for size adjustment basis keywords if enabled.
|
||||||
"ex" if basis_enabled => GenericFontSizeAdjust::Ex,
|
"ex-height" if basis_enabled => GenericFontSizeAdjust::ExHeight,
|
||||||
"cap" if basis_enabled => GenericFontSizeAdjust::Cap,
|
"cap-height" if basis_enabled => GenericFontSizeAdjust::CapHeight,
|
||||||
"ch" if basis_enabled => GenericFontSizeAdjust::Ch,
|
"ch-width" if basis_enabled => GenericFontSizeAdjust::ChWidth,
|
||||||
"ic" if basis_enabled => GenericFontSizeAdjust::Ic,
|
"ic-width" if basis_enabled => GenericFontSizeAdjust::IcWidth,
|
||||||
|
"ic-height" if basis_enabled => GenericFontSizeAdjust::IcHeight,
|
||||||
// Unknown (or disabled) keyword.
|
// Unknown (or disabled) keyword.
|
||||||
_ => return Err(location.new_custom_error(
|
_ => return Err(location.new_custom_error(
|
||||||
::selectors::parser::SelectorParseErrorKind::UnexpectedIdent(ident)
|
::selectors::parser::SelectorParseErrorKind::UnexpectedIdent(ident)
|
||||||
|
@ -806,9 +807,9 @@ impl Parse for FontSizeAdjust {
|
||||||
let value = NonNegativeNumber::parse(context, input)?;
|
let value = NonNegativeNumber::parse(context, input)?;
|
||||||
return Ok(FontSizeAdjust::Value(basis(value)));
|
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)?;
|
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