mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Only accept the CSS2 font-variant values (normal/small-caps) in the font shorthand; CSS Fonts 3/4 font-variant additions are not allowed
Differential Revision: https://phabricator.services.mozilla.com/D149440
This commit is contained in:
parent
6a5f012d3b
commit
becb855b3a
1 changed files with 14 additions and 2 deletions
|
@ -31,6 +31,7 @@
|
||||||
derive_value_info="False"
|
derive_value_info="False"
|
||||||
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font"
|
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font"
|
||||||
>
|
>
|
||||||
|
use crate::computed_values::font_variant_caps::T::SmallCaps;
|
||||||
use crate::parser::Parse;
|
use crate::parser::Parse;
|
||||||
use crate::properties::longhands::{font_family, font_style, font_weight, font_stretch};
|
use crate::properties::longhands::{font_family, font_style, font_weight, font_stretch};
|
||||||
use crate::properties::longhands::font_variant_caps;
|
use crate::properties::longhands::font_variant_caps;
|
||||||
|
@ -100,8 +101,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if variant_caps.is_none() {
|
if variant_caps.is_none() {
|
||||||
if let Ok(value) = input.try_parse(|input| font_variant_caps::parse(context, input)) {
|
// The only variant-caps value allowed is small-caps (from CSS2); the added values
|
||||||
variant_caps = Some(value);
|
// defined by CSS Fonts 3 and later are not accepted.
|
||||||
|
// https://www.w3.org/TR/css-fonts-4/#font-prop
|
||||||
|
if input.try_parse(|input| input.expect_ident_matching("small-caps")).is_ok() {
|
||||||
|
variant_caps = Some(font_variant_caps::SpecifiedValue::Keyword(SmallCaps));
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,6 +209,14 @@
|
||||||
FontStretch::System(..) => return Ok(()),
|
FontStretch::System(..) => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The only variant-caps value allowed in the shorthand is small-caps (from CSS2);
|
||||||
|
// the added values defined by CSS Fonts 3 and later are not supported.
|
||||||
|
// https://www.w3.org/TR/css-fonts-4/#font-prop
|
||||||
|
if self.font_variant_caps != &font_variant_caps::get_initial_specified_value() &&
|
||||||
|
*self.font_variant_caps != font_variant_caps::SpecifiedValue::Keyword(SmallCaps) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
% for name in "style variant_caps weight".split():
|
% for name in "style variant_caps weight".split():
|
||||||
if self.font_${name} != &font_${name}::get_initial_specified_value() {
|
if self.font_${name} != &font_${name}::get_initial_specified_value() {
|
||||||
self.font_${name}.to_css(dest)?;
|
self.font_${name}.to_css(dest)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue