tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 6c0edd8a0b83d3e12b929f1cdf837162fb975f2e
parent 99bc37686413de8cf494b5ad3eec5503e125a0e1
Author: Diego Escalante <descalante@mozilla.com>
Date:   Tue, 14 Oct 2025 20:10:59 +0000

Bug 1993076 - Simplify datapath and add clarification for pushing scope dependencies in invalidation collector and processor. r=dshin,firefox-style-system-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D268594

Diffstat:
Mservo/components/style/invalidation/element/invalidator.rs | 19++++++++++---------
Mservo/components/style/invalidation/element/state_and_attributes.rs | 12+++++-------
2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/servo/components/style/invalidation/element/invalidator.rs b/servo/components/style/invalidation/element/invalidator.rs @@ -402,7 +402,6 @@ impl<'a> Invalidation<'a> { } } - /// A struct that visits a selector and determines if there is a `:scope` /// component nested withing a negation. eg. :not(:scope) struct NegationScopeVisitor { @@ -1064,7 +1063,6 @@ where fn handle_fully_matched( &mut self, invalidation: &Invalidation<'b>, - descendant_invalidations: &mut DescendantInvalidationLists<'b>, ) -> (ProcessInvalidationResult, SmallVec<[Invalidation<'b>; 1]>) { debug!(" > Invalidation matched completely"); // We matched completely. If we're an inner selector now we need @@ -1092,9 +1090,7 @@ where force_add, ); - for invalidation in invalidations { - descendant_invalidations.dom_descendants.push(invalidation); - } + next_invalidations.extend(invalidations); continue; } @@ -1210,9 +1206,7 @@ where matched: false, } }, - CompoundSelectorMatchingResult::FullyMatched => { - self.handle_fully_matched(invalidation, descendant_invalidations) - }, + CompoundSelectorMatchingResult::FullyMatched => self.handle_fully_matched(invalidation), CompoundSelectorMatchingResult::Matched { next_combinator_offset, } => ( @@ -1394,7 +1388,14 @@ pub fn note_scope_dependency_force_at_subject<'selectors>( continue; } - if dep.next.is_some() { + // Follow the normal dependencies as far as we can, leaving + // other kinds to their own invalidation mechanisms elsewhere + if dep.next.is_some() + && matches!( + dep.invalidation_kind(), + DependencyInvalidationKind::Normal(_) + ) + { invalidations.extend(note_scope_dependency_force_at_subject( dep, current_host, diff --git a/servo/components/style/invalidation/element/state_and_attributes.rs b/servo/components/style/invalidation/element/state_and_attributes.rs @@ -11,7 +11,8 @@ use crate::dom::{TElement, TNode}; use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; use crate::invalidation::element::invalidation_map::*; use crate::invalidation::element::invalidator::{ - any_next_has_scope_in_negation, note_scope_dependency_force_at_subject, DescendantInvalidationLists, InvalidationVector, SiblingTraversalMap + any_next_has_scope_in_negation, note_scope_dependency_force_at_subject, + DescendantInvalidationLists, InvalidationVector, SiblingTraversalMap, }; use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; use crate::invalidation::element::restyle_hints::RestyleHint; @@ -562,12 +563,7 @@ where return; } - if self.check_dependency(dependency, set_scope) - || matches!( - dependency.invalidation_kind(), - DependencyInvalidationKind::Scope(_) - ) - { + if self.check_dependency(dependency, set_scope) { return self.note_dependency(dependency, set_scope); } } @@ -663,6 +659,8 @@ pub(crate) fn push_invalidation<'a>( DependencyInvalidationKind::FullSelector => unreachable!(), DependencyInvalidationKind::Relative(_) => unreachable!(), DependencyInvalidationKind::Scope(_) => { + // Scope invalidation kind matters only upon reaching the subject. + // Examine the combinator to the right of the compound. let combinator = invalidation.combinator_to_right(); if combinator.is_sibling() { sibling_invalidations.push(invalidation);