зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #17979 - style: Revert font-family serialization commit #17972 (from heycam:font-family-revert); r=heycam
This reverts commit 4f525f6fa04195cdb93fc4394fbc0c78f2626bd7. I accidentally included some unrelated changes in #17972, so backing out here. Source-Repo: https://github.com/servo/servo Source-Revision: 40315a6bf701dc8ade850f7521acf023966d1a09 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 96056d1c77c1afd7638026bab0a3a43346bdb131
This commit is contained in:
Родитель
ee6b05b899
Коммит
557434233a
|
@ -2181,7 +2181,7 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) {
|
||||
use properties::longhands::font_family::computed_value::{FontFamily, FamilyNameSyntax};
|
||||
use properties::longhands::font_family::computed_value::FontFamily;
|
||||
|
||||
let list = &mut self.gecko.mFont.fontlist;
|
||||
unsafe { Gecko_FontFamilyList_Clear(list); }
|
||||
|
@ -2191,8 +2191,7 @@ fn static_assert() {
|
|||
for family in &v.0 {
|
||||
match *family {
|
||||
FontFamily::FamilyName(ref f) => {
|
||||
let quoted = matches!(f.syntax, FamilyNameSyntax::Quoted);
|
||||
unsafe { Gecko_FontFamilyList_AppendNamed(list, f.name.as_ptr(), quoted); }
|
||||
unsafe { Gecko_FontFamilyList_AppendNamed(list, f.name.as_ptr(), f.quoted); }
|
||||
}
|
||||
FontFamily::Generic(ref name) => {
|
||||
let (family_type, generic) = FontFamily::generic(name);
|
||||
|
@ -2223,7 +2222,7 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
pub fn clone_font_family(&self) -> longhands::font_family::computed_value::T {
|
||||
use properties::longhands::font_family::computed_value::{FontFamily, FamilyName, FamilyNameSyntax};
|
||||
use properties::longhands::font_family::computed_value::{FontFamily, FamilyName};
|
||||
use gecko_bindings::structs::FontFamilyType;
|
||||
use gecko_string_cache::Atom;
|
||||
|
||||
|
@ -2236,16 +2235,13 @@ fn static_assert() {
|
|||
FontFamilyType::eFamily_cursive => FontFamily::Generic(atom!("cursive")),
|
||||
FontFamilyType::eFamily_fantasy => FontFamily::Generic(atom!("fantasy")),
|
||||
FontFamilyType::eFamily_moz_fixed => FontFamily::Generic(Atom::from("-moz-fixed")),
|
||||
FontFamilyType::eFamily_named => {
|
||||
let name = Atom::from(&*gecko_font_family_name.mName);
|
||||
FontFamily::FamilyName(FamilyName {
|
||||
name: name.clone(),
|
||||
syntax: FamilyNameSyntax::Identifiers(vec![name]),
|
||||
})
|
||||
},
|
||||
FontFamilyType::eFamily_named => FontFamily::FamilyName(FamilyName {
|
||||
name: (&*gecko_font_family_name.mName).into(),
|
||||
quoted: false
|
||||
}),
|
||||
FontFamilyType::eFamily_named_quoted => FontFamily::FamilyName(FamilyName {
|
||||
name: (&*gecko_font_family_name.mName).into(),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
quoted: true
|
||||
}),
|
||||
x => panic!("Found unexpected font FontFamilyType: {:?}", x),
|
||||
}
|
||||
|
|
|
@ -96,14 +96,7 @@ macro_rules! impl_gecko_keyword_conversions {
|
|||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||
pub struct FamilyName {
|
||||
pub name: Atom,
|
||||
pub syntax: FamilyNameSyntax,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||
pub enum FamilyNameSyntax {
|
||||
Quoted,
|
||||
Identifiers(Vec<Atom>),
|
||||
pub quoted: bool,
|
||||
}
|
||||
|
||||
impl FontFamily {
|
||||
|
@ -146,7 +139,7 @@ macro_rules! impl_gecko_keyword_conversions {
|
|||
// quoted by default.
|
||||
FontFamily::FamilyName(FamilyName {
|
||||
name: input,
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
quoted: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -155,14 +148,10 @@ macro_rules! impl_gecko_keyword_conversions {
|
|||
if let Ok(value) = input.try(|i| i.expect_string_cloned()) {
|
||||
return Ok(FontFamily::FamilyName(FamilyName {
|
||||
name: Atom::from(&*value),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
quoted: true,
|
||||
}))
|
||||
}
|
||||
|
||||
let mut identifiers = vec![];
|
||||
|
||||
let first_ident = input.expect_ident()?.clone();
|
||||
identifiers.push(Atom::from(&*first_ident));
|
||||
|
||||
// FIXME(bholley): The fast thing to do here would be to look up the
|
||||
// string (as lowercase) in the static atoms table. We don't have an
|
||||
|
@ -199,16 +188,14 @@ macro_rules! impl_gecko_keyword_conversions {
|
|||
let ident = input.expect_ident()?;
|
||||
value.push_str(" ");
|
||||
value.push_str(&ident);
|
||||
identifiers.push(Atom::from(&*ident.clone()));
|
||||
}
|
||||
while let Ok(ident) = input.try(|i| i.expect_ident_cloned()) {
|
||||
value.push_str(" ");
|
||||
value.push_str(&ident);
|
||||
identifiers.push(Atom::from(&*ident));
|
||||
}
|
||||
Ok(FontFamily::FamilyName(FamilyName {
|
||||
name: Atom::from(value),
|
||||
syntax: FamilyNameSyntax::Identifiers(identifiers),
|
||||
quoted: false,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -242,23 +229,12 @@ macro_rules! impl_gecko_keyword_conversions {
|
|||
|
||||
impl ToCss for FamilyName {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match self.syntax {
|
||||
FamilyNameSyntax::Quoted => {
|
||||
dest.write_char('"')?;
|
||||
write!(CssStringWriter::new(dest), "{}", self.name)?;
|
||||
dest.write_char('"')
|
||||
}
|
||||
FamilyNameSyntax::Identifiers(ref identifiers) => {
|
||||
let mut first = true;
|
||||
for identifier in identifiers {
|
||||
if !first {
|
||||
dest.write_char(' ')?;
|
||||
}
|
||||
serialize_identifier(&*identifier.to_string(), dest)?;
|
||||
first = false;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
if self.quoted {
|
||||
dest.write_char('"')?;
|
||||
write!(CssStringWriter::new(dest), "{}", self.name)?;
|
||||
dest.write_char('"')
|
||||
} else {
|
||||
serialize_identifier(&*self.name.to_string(), dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2532,7 +2508,7 @@ ${helpers.single_keyword("-moz-math-variant",
|
|||
use properties::longhands::font_family::computed_value::*;
|
||||
FontFamily::FamilyName(FamilyName {
|
||||
name: (&*font.mName).into(),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
quoted: true
|
||||
})
|
||||
}).collect::<Vec<_>>();
|
||||
let weight = longhands::font_weight::computed_value::T::from_gecko_weight(system.weight);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use cssparser::SourceLocation;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use ipc_channel::ipc;
|
||||
use style::computed_values::font_family::{FamilyName, FamilyNameSyntax};
|
||||
use style::computed_values::font_family::FamilyName;
|
||||
use style::font_face::{FontFaceRuleData, Source};
|
||||
|
||||
#[test]
|
||||
|
@ -15,11 +15,11 @@ fn test_local_web_font() {
|
|||
let font_cache_thread = FontCacheThread::new(inp_chan, None);
|
||||
let family_name = FamilyName {
|
||||
name: From::from("test family"),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
quoted: true,
|
||||
};
|
||||
let variant_name = FamilyName {
|
||||
name: From::from("test font face"),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
quoted: true,
|
||||
};
|
||||
let font_face_rule = FontFaceRuleData {
|
||||
family: Some(family_name.clone()),
|
||||
|
|
|
@ -14,7 +14,7 @@ use servo_url::ServoUrl;
|
|||
use std::borrow::ToOwned;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use style::computed_values::font_family::{FamilyName, FamilyNameSyntax};
|
||||
use style::computed_values::font_family::FamilyName;
|
||||
use style::context::QuirksMode;
|
||||
use style::error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use style::media_queries::MediaList;
|
||||
|
@ -254,7 +254,7 @@ fn test_parse_stylesheet() {
|
|||
CssRule::FontFeatureValues(Arc::new(stylesheet.shared_lock.wrap(FontFeatureValuesRule {
|
||||
family_names: vec![FamilyName {
|
||||
name: Atom::from("test"),
|
||||
syntax: FamilyNameSyntax::Identifiers(vec![Atom::from("test")]),
|
||||
quoted: false,
|
||||
}],
|
||||
swash: vec![
|
||||
FFVDeclaration {
|
||||
|
|
Загрузка…
Ссылка в новой задаче