mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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
|
@ -18,6 +18,9 @@ use crate::dom::csssupportsrule::CSSSupportsRule;
|
|||
#[dom_struct]
|
||||
pub(crate) struct CSSConditionRule {
|
||||
cssgroupingrule: CSSGroupingRule,
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
#[no_trace]
|
||||
rules: Arc<Locked<StyleCssRules>>,
|
||||
}
|
||||
|
||||
impl CSSConditionRule {
|
||||
|
@ -26,7 +29,8 @@ impl CSSConditionRule {
|
|||
rules: Arc<Locked<StyleCssRules>>,
|
||||
) -> CSSConditionRule {
|
||||
CSSConditionRule {
|
||||
cssgroupingrule: CSSGroupingRule::new_inherited(parent_stylesheet, rules),
|
||||
cssgroupingrule: CSSGroupingRule::new_inherited(parent_stylesheet),
|
||||
rules,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +41,10 @@ impl CSSConditionRule {
|
|||
pub(crate) fn shared_lock(&self) -> &SharedRwLock {
|
||||
self.cssgroupingrule.shared_lock()
|
||||
}
|
||||
|
||||
pub(crate) fn clone_rules(&self) -> Arc<Locked<StyleCssRules>> {
|
||||
self.rules.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl CSSConditionRuleMethods<crate::DomTypeHolder> for CSSConditionRule {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue