mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Turn CSSStyleRule
into a CSSGroupingRule
subclass (#36254)
Note that `StyleRule` may not have the `CssRules` readily available, they may need to be created. So the previous approach of providing `CSSGroupingRule` with the `CssRules` is no good: it would require writing them in advance, just in case they end up being used. Therefore, this removes the `CSSGroupingRule::rules` field. Instead, they are lazily obtained in `CSSGroupingRule::rulelist()` by downcasting and calling the appropriate method for the subclass. Testing: covered by WPT Fixes: #36245 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
dba8a0c22c
commit
0cdc1dcf72
8 changed files with 83 additions and 76 deletions
|
@ -190,20 +190,32 @@ impl CSSRuleList {
|
|||
self.dom_rules.borrow().get(idx as usize).map(|rule| {
|
||||
rule.or_init(|| {
|
||||
let parent_stylesheet = &self.parent_stylesheet;
|
||||
let guard = parent_stylesheet.shared_lock().read();
|
||||
let lock = parent_stylesheet.shared_lock();
|
||||
match self.rules {
|
||||
RulesSource::Rules(ref rules) => CSSRule::new_specific(
|
||||
self.global().as_window(),
|
||||
parent_stylesheet,
|
||||
rules.read_with(&guard).0[idx as usize].clone(),
|
||||
can_gc,
|
||||
),
|
||||
RulesSource::Keyframes(ref rules) => DomRoot::upcast(CSSKeyframeRule::new(
|
||||
self.global().as_window(),
|
||||
parent_stylesheet,
|
||||
rules.read_with(&guard).keyframes[idx as usize].clone(),
|
||||
can_gc,
|
||||
)),
|
||||
RulesSource::Rules(ref rules) => {
|
||||
let rule = {
|
||||
let guard = lock.read();
|
||||
rules.read_with(&guard).0[idx as usize].clone()
|
||||
};
|
||||
CSSRule::new_specific(
|
||||
self.global().as_window(),
|
||||
parent_stylesheet,
|
||||
rule,
|
||||
can_gc,
|
||||
)
|
||||
},
|
||||
RulesSource::Keyframes(ref rules) => {
|
||||
let rule = {
|
||||
let guard = lock.read();
|
||||
rules.read_with(&guard).keyframes[idx as usize].clone()
|
||||
};
|
||||
DomRoot::upcast(CSSKeyframeRule::new(
|
||||
self.global().as_window(),
|
||||
parent_stylesheet,
|
||||
rule,
|
||||
can_gc,
|
||||
))
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue