mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
stylo: Implement font-language-override descriptor for @font-face rule
This commit is contained in:
parent
c39de45d81
commit
3421694f12
3 changed files with 27 additions and 2 deletions
|
@ -17,6 +17,8 @@ use error_reporting::ContextualParseError;
|
|||
#[cfg(feature = "gecko")] use gecko_bindings::structs::CSSFontFaceDescriptors;
|
||||
#[cfg(feature = "gecko")] use cssparser::UnicodeRange;
|
||||
use parser::{ParserContext, log_css_error, Parse};
|
||||
#[cfg(feature = "gecko")]
|
||||
use properties::longhands::font_language_override;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use std::fmt;
|
||||
|
@ -407,7 +409,10 @@ font_face_descriptors! {
|
|||
font_feature_settings::T::Normal
|
||||
},
|
||||
|
||||
// FIXME: add font-language-override.
|
||||
/// The language override of this font face.
|
||||
"font-language-override" language_override / mFontLanguageOverride: font_language_override::SpecifiedValue = {
|
||||
font_language_override::SpecifiedValue::Normal
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use gecko_bindings::structs::{self, nsCSSFontFaceRule, nsCSSValue};
|
|||
use gecko_bindings::structs::{nsCSSCounterDesc, nsCSSCounterStyleRule};
|
||||
use gecko_bindings::sugar::ns_css_value::ToNsCssValue;
|
||||
use gecko_bindings::sugar::refptr::{RefPtr, UniqueRefPtr};
|
||||
use properties::longhands::font_language_override;
|
||||
use shared_lock::{ToCssWithGuard, SharedRwLockReadGuard};
|
||||
use std::{fmt, str};
|
||||
use values::generics::FontSettings;
|
||||
|
@ -67,6 +68,17 @@ impl ToNsCssValue for font_feature_settings::T {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToNsCssValue for font_language_override::SpecifiedValue {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
match self {
|
||||
font_language_override::SpecifiedValue::Normal => nscssvalue.set_normal(),
|
||||
font_language_override::SpecifiedValue::Override(ref lang) => nscssvalue.set_string(&*lang),
|
||||
// This path is unreachable because the descriptor is only specified by the user.
|
||||
font_language_override::SpecifiedValue::System(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! map_enum {
|
||||
(
|
||||
$(
|
||||
|
|
|
@ -2012,7 +2012,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
|
|||
// OpenType "language system" tag, so we should be able to compute
|
||||
// it and store it as a 32-bit integer
|
||||
// (see http://www.microsoft.com/typography/otspec/languagetags.htm).
|
||||
#[derive(PartialEq, Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct T(pub u32);
|
||||
}
|
||||
|
@ -2082,6 +2082,14 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
|
|||
}
|
||||
}
|
||||
|
||||
/// Used in @font-face.
|
||||
impl Parse for SpecifiedValue {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
parse(context, input)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl From<u32> for computed_value::T {
|
||||
fn from(bits: u32) -> computed_value::T {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue