mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Arc all Vec<CSSRule>s, put in CSSRules type
This commit is contained in:
parent
ef74d8da3b
commit
2220fcdc0b
3 changed files with 18 additions and 10 deletions
|
@ -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)))].into(),
|
||||
origin: Origin::Author,
|
||||
media: Default::default(),
|
||||
// Viewport constraints are always recomputed on resize; they don't need to
|
||||
|
|
|
@ -380,7 +380,7 @@ impl Stylist {
|
|||
return true
|
||||
}
|
||||
}
|
||||
mq_eval_changed(rules, before, after)
|
||||
mq_eval_changed(&rules, before, after)
|
||||
}) {
|
||||
return true
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ impl Stylist {
|
|||
false
|
||||
}
|
||||
self.is_device_dirty |= stylesheets.iter().any(|stylesheet| {
|
||||
mq_eval_changed(&stylesheet.rules, &self.device, &device)
|
||||
mq_eval_changed(&stylesheet.rules.0, &self.device, &device)
|
||||
});
|
||||
|
||||
self.device = device;
|
||||
|
|
|
@ -39,12 +39,20 @@ pub enum Origin {
|
|||
User,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CssRules(pub Arc<Vec<CssRule>>);
|
||||
|
||||
impl From<Vec<CssRule>> for CssRules {
|
||||
fn from(other: Vec<CssRule>) -> Self {
|
||||
CssRules(Arc::new(other))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Stylesheet {
|
||||
/// List of rules in the order they were found (important for
|
||||
/// cascading order)
|
||||
pub rules: Vec<CssRule>,
|
||||
pub rules: CssRules,
|
||||
/// List of media associated with the Stylesheet.
|
||||
pub media: MediaList,
|
||||
pub origin: Origin,
|
||||
|
@ -89,7 +97,7 @@ impl CssRule {
|
|||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read();
|
||||
let mq = media_rule.media_queries.read();
|
||||
f(&media_rule.rules, Some(&mq))
|
||||
f(&media_rule.rules.0, Some(&mq))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +120,7 @@ pub struct KeyframesRule {
|
|||
#[derive(Debug)]
|
||||
pub struct MediaRule {
|
||||
pub media_queries: Arc<RwLock<MediaList>>,
|
||||
pub rules: Vec<CssRule>,
|
||||
pub rules: CssRules,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -180,7 +188,7 @@ impl Stylesheet {
|
|||
|
||||
Stylesheet {
|
||||
origin: origin,
|
||||
rules: rules,
|
||||
rules: rules.into(),
|
||||
media: Default::default(),
|
||||
dirty_on_viewport_size_change:
|
||||
input.seen_viewport_percentages(),
|
||||
|
@ -208,7 +216,7 @@ impl Stylesheet {
|
|||
/// examined.
|
||||
#[inline]
|
||||
pub fn effective_rules<F>(&self, device: &Device, mut f: F) where F: FnMut(&CssRule) {
|
||||
effective_rules(&self.rules, device, &mut f);
|
||||
effective_rules(&self.rules.0, device, &mut f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,7 +259,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) -> CssRules {
|
||||
let mut iter = RuleListParser::new_for_nested_rule(input,
|
||||
NestedRuleParser { context: context });
|
||||
let mut rules = Vec::new();
|
||||
|
@ -265,7 +273,7 @@ fn parse_nested_rules(context: &ParserContext, input: &mut Parser) -> Vec<CssRul
|
|||
}
|
||||
}
|
||||
}
|
||||
rules
|
||||
rules.into()
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue