Skip to content

Commit

Permalink
Rename font_face::FontFaceRule to FontFaceData.
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Mar 30, 2017
1 parent e36b925 commit 2c0347a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
5 changes: 2 additions & 3 deletions components/script/dom/bindings/trace.rs
Expand Up @@ -94,14 +94,13 @@ use std::time::{SystemTime, Instant};
use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
use style::context::QuirksMode;
use style::element_state::*;
use style::font_face::FontFaceRule;
use style::keyframes::Keyframe;
use style::media_queries::MediaList;
use style::properties::PropertyDeclarationBlock;
use style::selector_parser::{PseudoElement, Snapshot};
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocked};
use style::stylesheets::{CssRules, KeyframesRule, MediaRule, NamespaceRule, StyleRule, ImportRule};
use style::stylesheets::SupportsRule;
use style::stylesheets::{CssRules, FontFaceRule, KeyframesRule, MediaRule};
use style::stylesheets::{NamespaceRule, StyleRule, ImportRule, SupportsRule};
use style::values::specified::Length;
use style::viewport::ViewportRule;
use time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/cssfontfacerule.rs
Expand Up @@ -11,8 +11,8 @@ use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;
use dom_struct::dom_struct;
use std::sync::Arc;
use style::font_face::FontFaceRule;
use style::shared_lock::{Locked, ToCssWithGuard};
use style::stylesheets::FontFaceRule;

#[dom_struct]
pub struct CSSFontFaceRule {
Expand Down
18 changes: 9 additions & 9 deletions components/style/font_face.rs
Expand Up @@ -75,8 +75,8 @@ impl ToCss for UrlSource {
///
/// Note that the prelude parsing code lives in the `stylesheets` module.
pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser)
-> Result<FontFaceRule, ()> {
let mut rule = FontFaceRule::initial();
-> Result<FontFaceData, ()> {
let mut rule = FontFaceData::initial();
{
let parser = FontFaceRuleParser {
context: context,
Expand Down Expand Up @@ -104,7 +104,7 @@ pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser)
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub struct EffectiveSources(Vec<Source>);

impl FontFaceRule {
impl FontFaceData {
/// Returns the list of effective sources for that font-face, that is the
/// sources which don't list any format hint, or the ones which list at
/// least "truetype" or "opentype".
Expand Down Expand Up @@ -134,7 +134,7 @@ impl iter::Iterator for EffectiveSources {

struct FontFaceRuleParser<'a, 'b: 'a> {
context: &'a ParserContext<'b>,
rule: &'a mut FontFaceRule,
rule: &'a mut FontFaceData,
missing: MissingDescriptors,
}

Expand Down Expand Up @@ -181,11 +181,11 @@ macro_rules! font_face_descriptors {
$( #[$o_doc: meta] $o_name: tt $o_ident: ident: $o_ty: ty = $o_initial: expr, )*
]
) => {
/// A `@font-face` rule.
/// Data inside a `@font-face` rule.
///
/// https://drafts.csswg.org/css-fonts/#font-face-rule
#[derive(Debug, PartialEq, Eq)]
pub struct FontFaceRule {
pub struct FontFaceData {
$(
#[$m_doc]
pub $m_ident: $m_ty,
Expand Down Expand Up @@ -218,9 +218,9 @@ macro_rules! font_face_descriptors {
}
}

impl FontFaceRule {
impl FontFaceData {
fn initial() -> Self {
FontFaceRule {
FontFaceData {
$(
$m_ident: $m_initial,
)*
Expand All @@ -231,7 +231,7 @@ macro_rules! font_face_descriptors {
}
}

impl ToCssWithGuard for FontFaceRule {
impl ToCssWithGuard for FontFaceData {
// Serialization of FontFaceRule is not specced.
fn to_css<W>(&self, _guard: &SharedRwLockReadGuard, dest: &mut W) -> fmt::Result
where W: fmt::Write {
Expand Down
7 changes: 5 additions & 2 deletions components/style/stylesheets.rs
Expand Up @@ -11,7 +11,7 @@ use cssparser::{AtRuleParser, Parser, QualifiedRuleParser};
use cssparser::{AtRuleType, RuleListParser, SourcePosition, Token, parse_one_rule};
use cssparser::ToCss as ParserToCss;
use error_reporting::ParseErrorReporter;
use font_face::{FontFaceRule, parse_font_face_block};
use font_face::{FontFaceData, parse_font_face_block};
use keyframes::{Keyframe, parse_keyframe_list};
use media_queries::{Device, MediaList, parse_media_query_list};
use parking_lot::RwLock;
Expand Down Expand Up @@ -551,6 +551,9 @@ impl ToCssWithGuard for StyleRule {
}
}

/// A @font-face rule
pub type FontFaceRule = FontFaceData;

impl Stylesheet {
/// Updates an empty stylesheet from a given string of text.
pub fn update_from_str(existing: &Stylesheet,
Expand Down Expand Up @@ -1004,7 +1007,7 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
match prelude {
AtRulePrelude::FontFace => {
Ok(CssRule::FontFace(Arc::new(self.shared_lock.wrap(
try!(parse_font_face_block(self.context, input))))))
parse_font_face_block(self.context, input)?.into()))))
}
AtRulePrelude::Media(media_queries) => {
Ok(CssRule::Media(Arc::new(self.shared_lock.wrap(MediaRule {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/gfx/font_cache_thread.rs
Expand Up @@ -5,7 +5,7 @@
use gfx::font_cache_thread::FontCacheThread;
use ipc_channel::ipc;
use style::computed_values::font_family::FamilyName;
use style::font_face::{FontFaceRule, Source};
use style::font_face::{FontFaceData, Source};

#[test]
fn test_local_web_font() {
Expand All @@ -14,7 +14,7 @@ fn test_local_web_font() {
let font_cache_thread = FontCacheThread::new(inp_chan, None);
let family_name = FamilyName(From::from("test family"));
let variant_name = FamilyName(From::from("test font face"));
let font_face_rule = FontFaceRule {
let font_face_rule = FontFaceData {
family: family_name.clone(),
sources: vec![Source::Local(variant_name)],
};
Expand Down

0 comments on commit 2c0347a

Please sign in to comment.