mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Skip system font variant for ToCss in font subproperties.
System font keywords are not a valid value for those properties. The newly-added #[css(skip)] would be reused by deriving algorithm of SpecifiedValueInfo to skip them as well. Bug: 1434130 Reviewed-by: emilio MozReview-Commit-ID: EmnhkaA9RR5
This commit is contained in:
parent
6e3fa68f46
commit
3b9c40dd14
4 changed files with 23 additions and 0 deletions
|
@ -411,6 +411,7 @@
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, SpecifiedValueInfo, ToCss)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, SpecifiedValueInfo, ToCss)]
|
||||||
pub enum SpecifiedValue {
|
pub enum SpecifiedValue {
|
||||||
Keyword(computed_value::T),
|
Keyword(computed_value::T),
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,11 @@ ${helpers.predefined_type("-x-text-zoom",
|
||||||
//! detects that a value has a system font, it will resolve it, and
|
//! detects that a value has a system font, it will resolve it, and
|
||||||
//! cache it on the ComputedValues. After this, it can be just fetched
|
//! cache it on the ComputedValues. After this, it can be just fetched
|
||||||
//! whenever a font longhand on the same element needs the system font.
|
//! whenever a font longhand on the same element needs the system font.
|
||||||
|
//!
|
||||||
|
//! When a longhand property is holding a SystemFont, it's serialized
|
||||||
|
//! to an empty string as if its value comes from a shorthand with
|
||||||
|
//! variable reference. We may want to improve this behavior at some
|
||||||
|
//! point. See also https://github.com/w3c/csswg-drafts/issues/1586.
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{Parser, ToCss};
|
use cssparser::{Parser, ToCss};
|
||||||
|
|
|
@ -86,6 +86,7 @@ pub enum FontWeight {
|
||||||
/// Lighter variant
|
/// Lighter variant
|
||||||
Lighter,
|
Lighter,
|
||||||
/// System font variant.
|
/// System font variant.
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +339,7 @@ impl SpecifiedFontStyle {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum FontStyle {
|
pub enum FontStyle {
|
||||||
Specified(SpecifiedFontStyle),
|
Specified(SpecifiedFontStyle),
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,6 +386,7 @@ impl Parse for FontStyle {
|
||||||
pub enum FontStretch {
|
pub enum FontStretch {
|
||||||
Stretch(Percentage),
|
Stretch(Percentage),
|
||||||
Keyword(FontStretchKeyword),
|
Keyword(FontStretchKeyword),
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,6 +528,7 @@ pub enum FontSize {
|
||||||
/// font-size: larger
|
/// font-size: larger
|
||||||
Larger,
|
Larger,
|
||||||
/// Derived from a specified system font.
|
/// Derived from a specified system font.
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,6 +545,7 @@ pub enum FontFamily {
|
||||||
#[css(comma)]
|
#[css(comma)]
|
||||||
Values(#[css(iterable)] FontFamilyList),
|
Values(#[css(iterable)] FontFamilyList),
|
||||||
/// System font
|
/// System font
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,6 +637,7 @@ pub enum FontSizeAdjust {
|
||||||
/// Number variant
|
/// Number variant
|
||||||
Number(Number),
|
Number(Number),
|
||||||
/// system font
|
/// system font
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1136,6 +1142,7 @@ pub enum FontVariantAlternates {
|
||||||
/// Use alternative glyph from value
|
/// Use alternative glyph from value
|
||||||
Value(VariantAlternatesList),
|
Value(VariantAlternatesList),
|
||||||
/// Use system font glyph
|
/// Use system font glyph
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1389,6 +1396,7 @@ pub enum FontVariantEastAsian {
|
||||||
/// Value variant with `variant-east-asian`
|
/// Value variant with `variant-east-asian`
|
||||||
Value(VariantEastAsian),
|
Value(VariantEastAsian),
|
||||||
/// System font variant
|
/// System font variant
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1617,6 +1625,7 @@ pub enum FontVariantLigatures {
|
||||||
/// Value variant with `variant-ligatures`
|
/// Value variant with `variant-ligatures`
|
||||||
Value(VariantLigatures),
|
Value(VariantLigatures),
|
||||||
/// System font variant
|
/// System font variant
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1847,6 +1856,7 @@ pub enum FontVariantNumeric {
|
||||||
/// Value variant with `variant-numeric`
|
/// Value variant with `variant-numeric`
|
||||||
Value(VariantNumeric),
|
Value(VariantNumeric),
|
||||||
/// System font
|
/// System font
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1954,6 +1964,7 @@ pub enum FontFeatureSettings {
|
||||||
/// Value of `FontSettings`
|
/// Value of `FontSettings`
|
||||||
Value(SpecifiedFontFeatureSettings),
|
Value(SpecifiedFontFeatureSettings),
|
||||||
/// System font
|
/// System font
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2104,6 +2115,7 @@ pub enum FontLanguageOverride {
|
||||||
/// the language system implied by the language of the element
|
/// the language system implied by the language of the element
|
||||||
Override(Box<str>),
|
Override(Box<str>),
|
||||||
/// Use system font
|
/// Use system font
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2186,6 +2198,7 @@ pub enum FontVariationSettings {
|
||||||
/// Value of `FontSettings`
|
/// Value of `FontSettings`
|
||||||
Value(SpecifiedFontVariationSettings),
|
Value(SpecifiedFontVariationSettings),
|
||||||
/// System font
|
/// System font
|
||||||
|
#[css(skip)]
|
||||||
System(SystemFont),
|
System(SystemFont),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,9 @@ fn derive_variant_arm(
|
||||||
let variant_attrs = cg::parse_variant_attrs_from_ast::<CssVariantAttrs>(&ast);
|
let variant_attrs = cg::parse_variant_attrs_from_ast::<CssVariantAttrs>(&ast);
|
||||||
let separator = if variant_attrs.comma { ", " } else { " " };
|
let separator = if variant_attrs.comma { ", " } else { " " };
|
||||||
|
|
||||||
|
if variant_attrs.skip {
|
||||||
|
return quote!(Ok(()));
|
||||||
|
}
|
||||||
if variant_attrs.dimension {
|
if variant_attrs.dimension {
|
||||||
assert_eq!(bindings.len(), 1);
|
assert_eq!(bindings.len(), 1);
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -223,6 +226,7 @@ pub struct CssVariantAttrs {
|
||||||
pub dimension: bool,
|
pub dimension: bool,
|
||||||
pub keyword: Option<String>,
|
pub keyword: Option<String>,
|
||||||
pub aliases: Option<String>,
|
pub aliases: Option<String>,
|
||||||
|
pub skip: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[darling(attributes(css), default)]
|
#[darling(attributes(css), default)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue