Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit a1ac909

Browse files
committed
servo: Merge #19426 - style: Require an nth-index cache for invalidation (from emilio:cache-invalidation); r=xidorn
Source-Repo: https://github.com/servo/servo Source-Revision: 95aac490a5150fd1a354f25c61b01ee0406a1e84 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : ca65470776263fe2a7f0bb65ad54a64034c956d5
1 parent 6c6269e commit a1ac909

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

servo/components/style/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl ElementData {
239239
element: E,
240240
shared_context: &SharedStyleContext,
241241
stack_limit_checker: Option<&StackLimitChecker>,
242-
nth_index_cache: Option<&mut NthIndexCache>,
242+
nth_index_cache: &mut NthIndexCache,
243243
) -> InvalidationResult {
244244
// In animation-only restyle we shouldn't touch snapshot at all.
245245
if shared_context.traversal_flags.for_animation_only() {

servo/components/style/invalidation/element/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ impl<'a, 'b: 'a, E: TElement> StateAndAttrInvalidationProcessor<'a, 'b, E> {
7171
cut_off_inheritance: bool,
7272
element: E,
7373
data: &'a mut ElementData,
74-
nth_index_cache: Option<&'a mut NthIndexCache>,
74+
nth_index_cache: &'a mut NthIndexCache,
7575
) -> Self {
7676
let matching_context = MatchingContext::new_for_visited(
7777
MatchingMode::Normal,
7878
None,
79-
nth_index_cache,
79+
Some(nth_index_cache),
8080
VisitedHandlingMode::AllLinksVisitedAndUnvisited,
8181
shared_context.quirks_mode(),
8282
);

servo/components/style/traversal.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use dom::{NodeInfo, OpaqueNode, TElement, TNode};
1010
use invalidation::element::restyle_hints::RestyleHint;
1111
use matching::{ChildCascadeRequirement, MatchMethods};
1212
use selector_parser::PseudoElement;
13+
use selectors::NthIndexCache;
1314
use sharing::StyleSharingTarget;
1415
use smallvec::SmallVec;
1516
use style_resolver::{PseudoElementResolution, StyleResolverForElement};
@@ -153,11 +154,12 @@ pub trait DomTraversal<E: TElement> : Sync {
153154
if !traversal_flags.for_animation_only() {
154155
// Invalidate our style, and that of our siblings and
155156
// descendants as needed.
156-
//
157-
// FIXME(emilio): an nth-index cache could be worth here, even
158-
// if temporary?
159-
let invalidation_result =
160-
data.invalidate_style_if_needed(root, shared_context, None, None);
157+
let invalidation_result = data.invalidate_style_if_needed(
158+
root,
159+
shared_context,
160+
None,
161+
&mut NthIndexCache::default(),
162+
);
161163

162164
if invalidation_result.has_invalidated_siblings() {
163165
let actual_root = root.traversal_parent()
@@ -802,7 +804,7 @@ where
802804
child,
803805
&context.shared,
804806
Some(&context.thread_local.stack_limit_checker),
805-
Some(&mut context.thread_local.nth_index_cache)
807+
&mut context.thread_local.nth_index_cache,
806808
);
807809
}
808810

servo/ports/geckolib/glue.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cssparser::{Parser, ParserInput};
66
use cssparser::ToCss as ParserToCss;
77
use env_logger::LogBuilder;
88
use malloc_size_of::MallocSizeOfOps;
9-
use selectors::Element;
9+
use selectors::{Element, NthIndexCache};
1010
use selectors::matching::{MatchingContext, MatchingMode, matches_selector};
1111
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
1212
use std::cell::RefCell;
@@ -4478,15 +4478,13 @@ pub extern "C" fn Servo_ProcessInvalidations(
44784478
let mut data = data.as_mut().map(|d| &mut **d);
44794479

44804480
if let Some(ref mut data) = data {
4481-
// FIXME(emilio): an nth-index cache could be worth here, even
4482-
// if temporary?
4483-
//
4484-
// Also, ideally we could share them across all the elements?
4481+
// FIXME(emilio): Ideally we could share the nth-index-cache across all
4482+
// the elements?
44854483
let result = data.invalidate_style_if_needed(
44864484
element,
44874485
&shared_style_context,
44884486
None,
4489-
None,
4487+
&mut NthIndexCache::default(),
44904488
);
44914489

44924490
if result.has_invalidated_siblings() {

0 commit comments

Comments
 (0)