mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +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
|
@ -4,8 +4,8 @@
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
use servo_arc::Arc;
|
||||
use style::shared_lock::ToCssWithGuard;
|
||||
use style::stylesheets::{CssRuleType, LayerBlockRule};
|
||||
use style::shared_lock::{Locked, ToCssWithGuard};
|
||||
use style::stylesheets::{CssRuleType, CssRules, LayerBlockRule};
|
||||
use style_traits::ToCss;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::CSSLayerBlockRuleBinding::CSSLayerBlockRuleMethods;
|
||||
|
@ -32,10 +32,7 @@ impl CSSLayerBlockRule {
|
|||
layerblockrule: Arc<LayerBlockRule>,
|
||||
) -> CSSLayerBlockRule {
|
||||
CSSLayerBlockRule {
|
||||
cssgroupingrule: CSSGroupingRule::new_inherited(
|
||||
parent_stylesheet,
|
||||
layerblockrule.rules.clone(),
|
||||
),
|
||||
cssgroupingrule: CSSGroupingRule::new_inherited(parent_stylesheet),
|
||||
layerblockrule,
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +53,10 @@ impl CSSLayerBlockRule {
|
|||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn clone_rules(&self) -> Arc<Locked<CssRules>> {
|
||||
self.layerblockrule.rules.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl SpecificCSSRule for CSSLayerBlockRule {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue