[go: nahoru, domu]

Skip to content

Commit

Permalink
Bug 1846251 - Make CSSStyleRule inherit from CSSGroupingRule. r=peter…
Browse files Browse the repository at this point in the history
…v,devtools-reviewers

As per w3c/csswg-drafts#8940.

I didn't do this in bug 1837638 because that's what the spec said at the
time, that's what other browsers did, and specially because if we did
this we had no way of runtime-disable nesting during development or if
things went south.

This means that we can't keep the nesting pref in 118, but that seems
fine (it's already enabled everywhere in 117).

Differential Revision: https://phabricator.services.mozilla.com/D184930
  • Loading branch information
emilio committed Aug 1, 2023
1 parent 086c513 commit 1175df3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
3 changes: 2 additions & 1 deletion style/gecko/selector_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
type Impl = SelectorImpl;
type Error = StyleParseErrorKind<'i>;

#[inline]
fn parse_parent_selector(&self) -> bool {
static_prefs::pref!("layout.css.nesting.enabled")
true
}

#[inline]
Expand Down
16 changes: 1 addition & 15 deletions style/stylesheets/rule_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,6 @@ impl NestedParseResult {
}

impl<'a, 'i> NestedRuleParser<'a, 'i> {
/// When nesting is disabled, we prevent parsing at rules and qualified rules inside style
/// rules.
fn allow_at_and_qualified_rules(&self) -> bool {
if !self.in_style_rule() {
return true;
}
static_prefs::pref!("layout.css.nesting.enabled")
}

#[inline]
fn in_style_rule(&self) -> bool {
self.context.rule_types.contains(CssRuleType::Style)
Expand Down Expand Up @@ -622,9 +613,6 @@ impl<'a, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'i> {
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>,
) -> Result<Self::Prelude, ParseError<'i>> {
if self.in_style_rule() && !static_prefs::pref!("layout.css.nesting.enabled") {
return Err(input.new_error(BasicParseErrorKind::AtRuleInvalid(name)));
}
Ok(match_ignore_ascii_case! { &*name,
"media" => {
let media_queries = MediaList::parse(&self.context, input);
Expand Down Expand Up @@ -934,9 +922,7 @@ impl<'a, 'i> DeclarationParser<'i> for NestedRuleParser<'a, 'i> {
}

impl<'a, 'i> RuleBodyItemParser<'i, (), StyleParseErrorKind<'i>> for NestedRuleParser<'a, 'i> {
fn parse_qualified(&self) -> bool {
self.allow_at_and_qualified_rules()
}
fn parse_qualified(&self) -> bool { true }

/// If nesting is disabled, we can't get there for a non-style-rule. If it's enabled, we parse
/// raw declarations there.
Expand Down

0 comments on commit 1175df3

Please sign in to comment.