style: Simplify NAC setup

Make all UA widgets also NAC.

Keep the UA widget flag but break at anonymous subtree boundaries, so
that only nodes inside the UA widget directly (and not NAC from those)
get the flag.

This is important because two callers depend on this difference:

  * The style system, since we still want to match content rules from
    stylesheets in the UA widget. We also match user rules, which is a
    bit sketchy, but that was the previous behavior, will file a
    follow-up for that.

  * The reflector code, since we want the scope for UA widgets to not
    include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
    got it wrong.

After this patch, ChromeOnlyAccess is equivalent to
IsInNativeAnonymousSubtree, so we should probably unify the naming.
That's left for a follow-up patch because I don't have a strong
preference.

Differential Revision: https://phabricator.services.mozilla.com/D174310
This commit is contained in:
Emilio Cobos Álvarez 2023-04-05 09:19:15 +00:00 committed by Martin Robinson
parent 0917ee3f9b
commit 5dd35ac6cd
6 changed files with 87 additions and 113 deletions

View file

@ -73,7 +73,7 @@ where
rule_inclusion: RuleInclusion,
rules: &'a mut ApplicableDeclarationList,
context: &'a mut MatchingContext<'b, E::Impl>,
matches_user_and_author_rules: bool,
matches_user_and_content_rules: bool,
matches_document_author_rules: bool,
in_sort_scope: bool,
}
@ -102,7 +102,7 @@ where
MatchingMode::Normal => element.rule_hash_target(),
};
let matches_user_and_author_rules = rule_hash_target.matches_user_and_author_rules();
let matches_user_and_content_rules = rule_hash_target.matches_user_and_content_rules();
// Gecko definitely has pseudo-elements with style attributes, like
// ::-moz-color-swatch.
@ -123,8 +123,8 @@ where
rule_inclusion,
context,
rules,
matches_user_and_author_rules,
matches_document_author_rules: matches_user_and_author_rules,
matches_user_and_content_rules,
matches_document_author_rules: matches_user_and_content_rules,
in_sort_scope: false,
}
}
@ -179,7 +179,7 @@ where
}
fn collect_user_rules(&mut self) {
if !self.matches_user_and_author_rules {
if !self.matches_user_and_content_rules {
return;
}
@ -257,7 +257,7 @@ where
while let Some(slot) = current {
debug_assert!(
self.matches_user_and_author_rules,
self.matches_user_and_content_rules,
"We should not slot NAC anywhere"
);
slots.push(slot);
@ -292,7 +292,7 @@ where
}
fn collect_rules_from_containing_shadow_tree(&mut self) {
if !self.matches_user_and_author_rules {
if !self.matches_user_and_content_rules {
return;
}
@ -341,11 +341,6 @@ where
None => return,
};
debug_assert!(
self.matches_user_and_author_rules,
"NAC should not be a shadow host"
);
let style_data = match shadow.style_data() {
Some(d) => d,
None => return,