mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
CSSRule -> CssRule
This commit is contained in:
parent
bfd4a0e5ff
commit
72c83c9394
5 changed files with 45 additions and 45 deletions
|
@ -22,7 +22,7 @@ use std::ascii::AsciiExt;
|
|||
use std::sync::Arc;
|
||||
use style::attr::AttrValue;
|
||||
use style::str::HTML_SPACE_CHARACTERS;
|
||||
use style::stylesheets::{Stylesheet, CSSRule, Origin};
|
||||
use style::stylesheets::{Stylesheet, CssRule, Origin};
|
||||
use style::viewport::ViewportRule;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -81,7 +81,7 @@ impl HTMLMetaElement {
|
|||
if !content.is_empty() {
|
||||
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
|
||||
*self.stylesheet.borrow_mut() = Some(Arc::new(Stylesheet {
|
||||
rules: vec![CSSRule::Viewport(Arc::new(RwLock::new(translated_rule)))],
|
||||
rules: vec![CssRule::Viewport(Arc::new(RwLock::new(translated_rule)))],
|
||||
origin: Origin::Author,
|
||||
media: Default::default(),
|
||||
// Viewport constraints are always recomputed on resize; they don't need to
|
||||
|
|
|
@ -32,7 +32,7 @@ use std::hash::Hash;
|
|||
use std::slice;
|
||||
use std::sync::Arc;
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use stylesheets::{CSSRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets};
|
||||
use stylesheets::{CssRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets};
|
||||
use viewport::{self, MaybeNew, ViewportRule};
|
||||
|
||||
pub type FnvHashMap<K, V> = HashMap<K, V, BuildHasherDefault<::fnv::FnvHasher>>;
|
||||
|
@ -187,7 +187,7 @@ impl Stylist {
|
|||
animations, precomputed_pseudo_element_decls);
|
||||
stylesheet.effective_rules(&self.device, |rule| {
|
||||
match *rule {
|
||||
CSSRule::Style(ref style_rule) => {
|
||||
CssRule::Style(ref style_rule) => {
|
||||
let guard = style_rule.read();
|
||||
for selector in &guard.selectors {
|
||||
let map = if let Some(ref pseudo) = selector.pseudo_element {
|
||||
|
@ -219,7 +219,7 @@ impl Stylist {
|
|||
}
|
||||
}
|
||||
}
|
||||
CSSRule::Keyframes(ref keyframes_rule) => {
|
||||
CssRule::Keyframes(ref keyframes_rule) => {
|
||||
let keyframes_rule = keyframes_rule.read();
|
||||
debug!("Found valid keyframes rule: {:?}", *keyframes_rule);
|
||||
if let Some(animation) = KeyframesAnimation::from_keyframes(&keyframes_rule.keyframes) {
|
||||
|
@ -372,7 +372,7 @@ impl Stylist {
|
|||
device = Device::new(MediaType::Screen, constraints.size);
|
||||
}
|
||||
|
||||
fn mq_eval_changed(rules: &[CSSRule], before: &Device, after: &Device) -> bool {
|
||||
fn mq_eval_changed(rules: &[CssRule], before: &Device, after: &Device) -> bool {
|
||||
for rule in rules {
|
||||
if rule.with_nested_rules_and_mq(|rules, mq| {
|
||||
if let Some(mq) = mq {
|
||||
|
|
|
@ -44,7 +44,7 @@ pub enum Origin {
|
|||
pub struct Stylesheet {
|
||||
/// List of rules in the order they were found (important for
|
||||
/// cascading order)
|
||||
pub rules: Vec<CSSRule>,
|
||||
pub rules: Vec<CssRule>,
|
||||
/// List of media associated with the Stylesheet.
|
||||
pub media: MediaList,
|
||||
pub origin: Origin,
|
||||
|
@ -60,7 +60,7 @@ pub struct UserAgentStylesheets {
|
|||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum CSSRule {
|
||||
pub enum CssRule {
|
||||
// No Charset here, CSSCharsetRule has been removed from CSSOM
|
||||
// https://drafts.csswg.org/cssom/#changes-from-5-december-2013
|
||||
|
||||
|
@ -72,21 +72,21 @@ pub enum CSSRule {
|
|||
Keyframes(Arc<RwLock<KeyframesRule>>),
|
||||
}
|
||||
|
||||
impl CSSRule {
|
||||
impl CssRule {
|
||||
/// Call `f` with the slice of rules directly contained inside this rule.
|
||||
///
|
||||
/// Note that only some types of rules can contain rules. An empty slice is used for others.
|
||||
pub fn with_nested_rules_and_mq<F, R>(&self, mut f: F) -> R
|
||||
where F: FnMut(&[CSSRule], Option<&MediaList>) -> R {
|
||||
where F: FnMut(&[CssRule], Option<&MediaList>) -> R {
|
||||
match *self {
|
||||
CSSRule::Namespace(_) |
|
||||
CSSRule::Style(_) |
|
||||
CSSRule::FontFace(_) |
|
||||
CSSRule::Viewport(_) |
|
||||
CSSRule::Keyframes(_) => {
|
||||
CssRule::Namespace(_) |
|
||||
CssRule::Style(_) |
|
||||
CssRule::FontFace(_) |
|
||||
CssRule::Viewport(_) |
|
||||
CssRule::Keyframes(_) => {
|
||||
f(&[], None)
|
||||
}
|
||||
CSSRule::Media(ref lock) => {
|
||||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read();
|
||||
let mq = media_rule.media_queries.read();
|
||||
f(&media_rule.rules, Some(&mq))
|
||||
|
@ -112,7 +112,7 @@ pub struct KeyframesRule {
|
|||
#[derive(Debug)]
|
||||
pub struct MediaRule {
|
||||
pub media_queries: Arc<RwLock<MediaList>>,
|
||||
pub rules: Vec<CSSRule>,
|
||||
pub rules: Vec<CssRule>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -207,12 +207,12 @@ impl Stylesheet {
|
|||
/// nested rules will be skipped. Use `rules` if all rules need to be
|
||||
/// examined.
|
||||
#[inline]
|
||||
pub fn effective_rules<F>(&self, device: &Device, mut f: F) where F: FnMut(&CSSRule) {
|
||||
pub fn effective_rules<F>(&self, device: &Device, mut f: F) where F: FnMut(&CssRule) {
|
||||
effective_rules(&self.rules, device, &mut f);
|
||||
}
|
||||
}
|
||||
|
||||
fn effective_rules<F>(rules: &[CSSRule], device: &Device, f: &mut F) where F: FnMut(&CSSRule) {
|
||||
fn effective_rules<F>(rules: &[CssRule], device: &Device, f: &mut F) where F: FnMut(&CssRule) {
|
||||
for rule in rules {
|
||||
f(rule);
|
||||
rule.with_nested_rules_and_mq(|rules, mq| {
|
||||
|
@ -232,7 +232,7 @@ macro_rules! rule_filter {
|
|||
$(
|
||||
pub fn $method<F>(&self, device: &Device, mut f: F) where F: FnMut(&$rule_type) {
|
||||
self.effective_rules(device, |rule| {
|
||||
if let CSSRule::$variant(ref lock) = *rule {
|
||||
if let CssRule::$variant(ref lock) = *rule {
|
||||
let rule = lock.read();
|
||||
f(&rule)
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ rule_filter! {
|
|||
effective_keyframes_rules(Keyframes => KeyframesRule),
|
||||
}
|
||||
|
||||
fn parse_nested_rules(context: &ParserContext, input: &mut Parser) -> Vec<CSSRule> {
|
||||
fn parse_nested_rules(context: &ParserContext, input: &mut Parser) -> Vec<CssRule> {
|
||||
let mut iter = RuleListParser::new_for_nested_rule(input,
|
||||
NestedRuleParser { context: context });
|
||||
let mut rules = Vec::new();
|
||||
|
@ -297,10 +297,10 @@ enum AtRulePrelude {
|
|||
|
||||
impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
||||
type Prelude = AtRulePrelude;
|
||||
type AtRule = CSSRule;
|
||||
type AtRule = CssRule;
|
||||
|
||||
fn parse_prelude(&mut self, name: &str, input: &mut Parser)
|
||||
-> Result<AtRuleType<AtRulePrelude, CSSRule>, ()> {
|
||||
-> Result<AtRuleType<AtRulePrelude, CssRule>, ()> {
|
||||
match_ignore_ascii_case! { name,
|
||||
"import" => {
|
||||
if self.state.get() <= State::Imports {
|
||||
|
@ -328,7 +328,7 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
|||
None
|
||||
};
|
||||
|
||||
return Ok(AtRuleType::WithoutBlock(CSSRule::Namespace(Arc::new(RwLock::new(
|
||||
return Ok(AtRuleType::WithoutBlock(CssRule::Namespace(Arc::new(RwLock::new(
|
||||
NamespaceRule {
|
||||
prefix: opt_prefix,
|
||||
url: url,
|
||||
|
@ -349,7 +349,7 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn parse_block(&mut self, prelude: AtRulePrelude, input: &mut Parser) -> Result<CSSRule, ()> {
|
||||
fn parse_block(&mut self, prelude: AtRulePrelude, input: &mut Parser) -> Result<CssRule, ()> {
|
||||
AtRuleParser::parse_block(&mut NestedRuleParser { context: &self.context }, prelude, input)
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
|
|||
|
||||
impl<'a> QualifiedRuleParser for TopLevelRuleParser<'a> {
|
||||
type Prelude = Vec<Selector<TheSelectorImpl>>;
|
||||
type QualifiedRule = CSSRule;
|
||||
type QualifiedRule = CssRule;
|
||||
|
||||
#[inline]
|
||||
fn parse_prelude(&mut self, input: &mut Parser) -> Result<Vec<Selector<TheSelectorImpl>>, ()> {
|
||||
|
@ -367,7 +367,7 @@ impl<'a> QualifiedRuleParser for TopLevelRuleParser<'a> {
|
|||
|
||||
#[inline]
|
||||
fn parse_block(&mut self, prelude: Vec<Selector<TheSelectorImpl>>, input: &mut Parser)
|
||||
-> Result<CSSRule, ()> {
|
||||
-> Result<CssRule, ()> {
|
||||
QualifiedRuleParser::parse_block(&mut NestedRuleParser { context: &self.context },
|
||||
prelude, input)
|
||||
}
|
||||
|
@ -381,10 +381,10 @@ struct NestedRuleParser<'a, 'b: 'a> {
|
|||
|
||||
impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
|
||||
type Prelude = AtRulePrelude;
|
||||
type AtRule = CSSRule;
|
||||
type AtRule = CssRule;
|
||||
|
||||
fn parse_prelude(&mut self, name: &str, input: &mut Parser)
|
||||
-> Result<AtRuleType<AtRulePrelude, CSSRule>, ()> {
|
||||
-> Result<AtRuleType<AtRulePrelude, CssRule>, ()> {
|
||||
match_ignore_ascii_case! { name,
|
||||
"media" => {
|
||||
let media_queries = parse_media_query_list(input);
|
||||
|
@ -414,24 +414,24 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_block(&mut self, prelude: AtRulePrelude, input: &mut Parser) -> Result<CSSRule, ()> {
|
||||
fn parse_block(&mut self, prelude: AtRulePrelude, input: &mut Parser) -> Result<CssRule, ()> {
|
||||
match prelude {
|
||||
AtRulePrelude::FontFace => {
|
||||
Ok(CSSRule::FontFace(Arc::new(RwLock::new(
|
||||
Ok(CssRule::FontFace(Arc::new(RwLock::new(
|
||||
try!(parse_font_face_block(self.context, input))))))
|
||||
}
|
||||
AtRulePrelude::Media(media_queries) => {
|
||||
Ok(CSSRule::Media(Arc::new(RwLock::new(MediaRule {
|
||||
Ok(CssRule::Media(Arc::new(RwLock::new(MediaRule {
|
||||
media_queries: media_queries,
|
||||
rules: parse_nested_rules(self.context, input),
|
||||
}))))
|
||||
}
|
||||
AtRulePrelude::Viewport => {
|
||||
Ok(CSSRule::Viewport(Arc::new(RwLock::new(
|
||||
Ok(CssRule::Viewport(Arc::new(RwLock::new(
|
||||
try!(ViewportRule::parse(input, self.context))))))
|
||||
}
|
||||
AtRulePrelude::Keyframes(name) => {
|
||||
Ok(CSSRule::Keyframes(Arc::new(RwLock::new(KeyframesRule {
|
||||
Ok(CssRule::Keyframes(Arc::new(RwLock::new(KeyframesRule {
|
||||
name: name,
|
||||
keyframes: parse_keyframe_list(&self.context, input),
|
||||
}))))
|
||||
|
@ -442,15 +442,15 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
|
|||
|
||||
impl<'a, 'b> QualifiedRuleParser for NestedRuleParser<'a, 'b> {
|
||||
type Prelude = Vec<Selector<TheSelectorImpl>>;
|
||||
type QualifiedRule = CSSRule;
|
||||
type QualifiedRule = CssRule;
|
||||
|
||||
fn parse_prelude(&mut self, input: &mut Parser) -> Result<Vec<Selector<TheSelectorImpl>>, ()> {
|
||||
parse_selector_list(&self.context.selector_context, input)
|
||||
}
|
||||
|
||||
fn parse_block(&mut self, prelude: Vec<Selector<TheSelectorImpl>>, input: &mut Parser)
|
||||
-> Result<CSSRule, ()> {
|
||||
Ok(CSSRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
-> Result<CssRule, ()> {
|
||||
Ok(CssRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
selectors: prelude,
|
||||
block: Arc::new(RwLock::new(parse_property_declaration_list(self.context, input)))
|
||||
}))))
|
||||
|
|
|
@ -10,7 +10,7 @@ use style::Atom;
|
|||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::media_queries::*;
|
||||
use style::parser::ParserContextExtraData;
|
||||
use style::stylesheets::{Stylesheet, Origin, CSSRule};
|
||||
use style::stylesheets::{Stylesheet, Origin, CssRule};
|
||||
use style::values::specified;
|
||||
use url::Url;
|
||||
|
||||
|
@ -36,7 +36,7 @@ fn test_media_rule<F>(css: &str, callback: F) where F: Fn(&MediaList, &str) {
|
|||
assert!(rule_count > 0);
|
||||
}
|
||||
|
||||
fn media_queries<F>(rules: &[CSSRule], f: &mut F) where F: FnMut(&MediaList) {
|
||||
fn media_queries<F>(rules: &[CssRule], f: &mut F) where F: FnMut(&MediaList) {
|
||||
for rule in rules {
|
||||
rule.with_nested_rules_and_mq(|rules, mq| {
|
||||
if let Some(mq) = mq {
|
||||
|
|
|
@ -17,7 +17,7 @@ use style::parser::ParserContextExtraData;
|
|||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue, longhands};
|
||||
use style::properties::Importance;
|
||||
use style::properties::longhands::animation_play_state;
|
||||
use style::stylesheets::{Stylesheet, NamespaceRule, CSSRule, StyleRule, KeyframesRule, Origin};
|
||||
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, StyleRule, KeyframesRule, Origin};
|
||||
use style::values::specified::{LengthOrPercentageOrAuto, Percentage};
|
||||
use url::Url;
|
||||
|
||||
|
@ -57,11 +57,11 @@ fn test_parse_stylesheet() {
|
|||
media: Default::default(),
|
||||
dirty_on_viewport_size_change: false,
|
||||
rules: vec![
|
||||
CSSRule::Namespace(Arc::new(RwLock::new(NamespaceRule {
|
||||
CssRule::Namespace(Arc::new(RwLock::new(NamespaceRule {
|
||||
prefix: None,
|
||||
url: NsAtom::from("http://www.w3.org/1999/xhtml")
|
||||
}))),
|
||||
CSSRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
CssRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
selectors: vec![
|
||||
Selector {
|
||||
complex_selector: Arc::new(ComplexSelector {
|
||||
|
@ -100,7 +100,7 @@ fn test_parse_stylesheet() {
|
|||
important_count: 2,
|
||||
})),
|
||||
}))),
|
||||
CSSRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
CssRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
selectors: vec![
|
||||
Selector {
|
||||
complex_selector: Arc::new(ComplexSelector {
|
||||
|
@ -146,7 +146,7 @@ fn test_parse_stylesheet() {
|
|||
important_count: 0,
|
||||
})),
|
||||
}))),
|
||||
CSSRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
CssRule::Style(Arc::new(RwLock::new(StyleRule {
|
||||
selectors: vec![
|
||||
Selector {
|
||||
complex_selector: Arc::new(ComplexSelector {
|
||||
|
@ -222,7 +222,7 @@ fn test_parse_stylesheet() {
|
|||
important_count: 0,
|
||||
})),
|
||||
}))),
|
||||
CSSRule::Keyframes(Arc::new(RwLock::new(KeyframesRule {
|
||||
CssRule::Keyframes(Arc::new(RwLock::new(KeyframesRule {
|
||||
name: "foo".into(),
|
||||
keyframes: vec![
|
||||
Arc::new(RwLock::new(Keyframe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue