mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Use Servo data to back @font-face rule in Gecko.
This commit is contained in:
parent
0332674909
commit
ac7467221a
10 changed files with 461 additions and 528 deletions
|
@ -13,7 +13,6 @@ use computed_values::{font_stretch, font_style, font_weight};
|
|||
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
|
||||
use cssparser::{SourceLocation, CowRcStr};
|
||||
use error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::CSSFontFaceDescriptors;
|
||||
#[cfg(feature = "gecko")] use cssparser::UnicodeRange;
|
||||
use parser::{ParserContext, ParserErrorContext, Parse};
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -271,7 +270,8 @@ macro_rules! font_face_descriptors_common {
|
|||
}
|
||||
|
||||
impl FontFaceRuleData {
|
||||
fn empty(location: SourceLocation) -> Self {
|
||||
/// Create an empty font-face rule
|
||||
pub fn empty(location: SourceLocation) -> Self {
|
||||
FontFaceRuleData {
|
||||
$(
|
||||
$ident: None,
|
||||
|
@ -280,24 +280,8 @@ macro_rules! font_face_descriptors_common {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert to Gecko types
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn set_descriptors(self, descriptors: &mut CSSFontFaceDescriptors) {
|
||||
$(
|
||||
if let Some(value) = self.$ident {
|
||||
descriptors.$gecko_ident.set_from(value)
|
||||
}
|
||||
)*
|
||||
// Leave unset descriptors to eCSSUnit_Null,
|
||||
// FontFaceSet::FindOrCreateUserFontEntryFromFontFace does the defaulting
|
||||
// to initial values.
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCssWithGuard for FontFaceRuleData {
|
||||
// Serialization of FontFaceRule is not specced.
|
||||
fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
||||
dest.write_str("@font-face {\n")?;
|
||||
/// Serialization of declarations in the FontFaceRule
|
||||
pub fn decl_to_css(&self, dest: &mut CssStringWriter) -> fmt::Result {
|
||||
$(
|
||||
if let Some(ref value) = self.$ident {
|
||||
dest.write_str(concat!(" ", $name, ": "))?;
|
||||
|
@ -305,7 +289,7 @@ macro_rules! font_face_descriptors_common {
|
|||
dest.write_str(";\n")?;
|
||||
}
|
||||
)*
|
||||
dest.write_str("}")
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,6 +318,15 @@ macro_rules! font_face_descriptors_common {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToCssWithGuard for FontFaceRuleData {
|
||||
// Serialization of FontFaceRule is not specced.
|
||||
fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
||||
dest.write_str("@font-face {\n")?;
|
||||
self.decl_to_css(dest)?;
|
||||
dest.write_str("}")
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! font_face_descriptors {
|
||||
(
|
||||
mandatory descriptors = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue