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

@ -584,8 +584,8 @@ impl<E: TElement> StyleSharingCache<E> {
},
};
if element.is_in_native_anonymous_subtree() {
debug!("Failing to insert into the cache: NAC");
if !element.matches_user_and_content_rules() {
debug!("Failing to insert into the cache: no tree rules:");
return;
}
@ -674,8 +674,8 @@ impl<E: TElement> StyleSharingCache<E> {
return None;
}
if target.is_in_native_anonymous_subtree() {
debug!("{:?} Cannot share style: NAC", target.element);
if !target.matches_user_and_content_rules() {
debug!("{:?} Cannot share style: content rules", target.element);
return None;
}
@ -699,7 +699,7 @@ impl<E: TElement> StyleSharingCache<E> {
nth_index_cache: &mut NthIndexCache,
shared_context: &SharedStyleContext,
) -> Option<ResolvedElementStyles> {
debug_assert!(!target.is_in_native_anonymous_subtree());
debug_assert!(target.matches_user_and_content_rules());
// Check that we have the same parent, or at least that the parents
// share styles and permit sharing across their children. The latter
@ -762,8 +762,8 @@ impl<E: TElement> StyleSharingCache<E> {
return None;
}
if target.matches_user_and_author_rules() !=
candidate.element.matches_user_and_author_rules()
if target.matches_user_and_content_rules() !=
candidate.element.matches_user_and_content_rules()
{
trace!("Miss: User and Author Rules");
return None;