script: Implement CSSStyleSheet constructor (#36521)

https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssstylesheet

Testing: covered by WPT
This is part of #36162

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-04-15 07:05:13 -07:00 committed by GitHub
parent 372fd04b23
commit 10f6f50c61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 127 additions and 38 deletions

View file

@ -125,6 +125,11 @@ impl CSSRuleList {
let loader = owner
.as_ref()
.map(|element| StylesheetLoader::for_element(element));
let allow_import_rules = if self.parent_stylesheet.is_constructed() {
AllowImportRules::No
} else {
AllowImportRules::Yes
};
let new_rule = css_rules
.insert_rule(
&parent_stylesheet.shared_lock,
@ -134,7 +139,7 @@ impl CSSRuleList {
containing_rule_types,
parse_relative_rule_type,
loader.as_ref().map(|l| l as &dyn StyleStylesheetLoader),
AllowImportRules::Yes,
allow_import_rules,
)
.map_err(Convert::convert)?;