mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #19293 - CYBAI:font-feature-settings-out-of-mako, r=emilio
style: Move font-feature-settings outside of mako This is a sub-PR of #19015 r? emilio --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19290 - [x] These changes do not require tests <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19293) <!-- Reviewable:end -->
This commit is contained in:
commit
9edb453447
5 changed files with 91 additions and 75 deletions
|
@ -1551,6 +1551,71 @@ impl Parse for FontVariantNumeric {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
/// Define initial settings that apply when the font defined
|
||||
/// by an @font-face rule is rendered.
|
||||
pub enum FontFeatureSettings {
|
||||
/// Value of `FontSettings`
|
||||
Value(computed::FontFeatureSettings),
|
||||
/// System font
|
||||
System(SystemFont)
|
||||
}
|
||||
|
||||
impl FontFeatureSettings {
|
||||
#[inline]
|
||||
/// Get default value of `font-feature-settings` as normal
|
||||
pub fn normal() -> FontFeatureSettings {
|
||||
FontFeatureSettings::Value(FontSettings::Normal)
|
||||
}
|
||||
|
||||
/// Get `font-feature-settings` with system font
|
||||
pub fn system_font(f: SystemFont) -> Self {
|
||||
FontFeatureSettings::System(f)
|
||||
}
|
||||
|
||||
/// Get system font
|
||||
pub fn get_system(&self) -> Option<SystemFont> {
|
||||
if let FontFeatureSettings::System(s) = *self {
|
||||
Some(s)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for FontFeatureSettings {
|
||||
type ComputedValue = computed::FontFeatureSettings;
|
||||
|
||||
fn to_computed_value(&self, _context: &Context) -> computed::FontFeatureSettings {
|
||||
match *self {
|
||||
FontFeatureSettings::Value(ref v) => v.clone(),
|
||||
FontFeatureSettings::System(_) => {
|
||||
#[cfg(feature = "gecko")] {
|
||||
_context.cached_system_font.as_ref().unwrap().font_feature_settings.clone()
|
||||
}
|
||||
#[cfg(feature = "servo")] {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn from_computed_value(other: &computed::FontFeatureSettings) -> Self {
|
||||
FontFeatureSettings::Value(other.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for FontFeatureSettings {
|
||||
/// normal | <feature-tag-value>#
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<FontFeatureSettings, ParseError<'i>> {
|
||||
computed::FontFeatureSettings::parse(context, input).map(FontFeatureSettings::Value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
/// Whether user agents are allowed to synthesize bold or oblique font faces
|
||||
/// when a font family lacks bold or italic faces
|
||||
|
|
|
@ -32,7 +32,8 @@ pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
|||
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
|
||||
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
|
||||
pub use self::font::{FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
|
||||
pub use self::font::{FontVariantLigatures, FontVariantNumeric, MozScriptLevel, MozScriptMinSize, XTextZoom};
|
||||
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
|
||||
pub use self::font::{MozScriptLevel, MozScriptMinSize, XTextZoom};
|
||||
pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign};
|
||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue