style: Require an nth-index cache for invalidation.

This commit is contained in:
Emilio Cobos Álvarez 2017-11-29 21:21:14 +01:00
parent dbe3136a05
commit 02ad6d3d90
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 15 additions and 15 deletions

View file

@ -239,7 +239,7 @@ impl ElementData {
element: E, element: E,
shared_context: &SharedStyleContext, shared_context: &SharedStyleContext,
stack_limit_checker: Option<&StackLimitChecker>, stack_limit_checker: Option<&StackLimitChecker>,
nth_index_cache: Option<&mut NthIndexCache>, nth_index_cache: &mut NthIndexCache,
) -> InvalidationResult { ) -> InvalidationResult {
// In animation-only restyle we shouldn't touch snapshot at all. // In animation-only restyle we shouldn't touch snapshot at all.
if shared_context.traversal_flags.for_animation_only() { if shared_context.traversal_flags.for_animation_only() {

View file

@ -71,12 +71,12 @@ impl<'a, 'b: 'a, E: TElement> StateAndAttrInvalidationProcessor<'a, 'b, E> {
cut_off_inheritance: bool, cut_off_inheritance: bool,
element: E, element: E,
data: &'a mut ElementData, data: &'a mut ElementData,
nth_index_cache: Option<&'a mut NthIndexCache>, nth_index_cache: &'a mut NthIndexCache,
) -> Self { ) -> Self {
let matching_context = MatchingContext::new_for_visited( let matching_context = MatchingContext::new_for_visited(
MatchingMode::Normal, MatchingMode::Normal,
None, None,
nth_index_cache, Some(nth_index_cache),
VisitedHandlingMode::AllLinksVisitedAndUnvisited, VisitedHandlingMode::AllLinksVisitedAndUnvisited,
shared_context.quirks_mode(), shared_context.quirks_mode(),
); );

View file

@ -10,6 +10,7 @@ use dom::{NodeInfo, OpaqueNode, TElement, TNode};
use invalidation::element::restyle_hints::RestyleHint; use invalidation::element::restyle_hints::RestyleHint;
use matching::{ChildCascadeRequirement, MatchMethods}; use matching::{ChildCascadeRequirement, MatchMethods};
use selector_parser::PseudoElement; use selector_parser::PseudoElement;
use selectors::NthIndexCache;
use sharing::StyleSharingTarget; use sharing::StyleSharingTarget;
use smallvec::SmallVec; use smallvec::SmallVec;
use style_resolver::{PseudoElementResolution, StyleResolverForElement}; use style_resolver::{PseudoElementResolution, StyleResolverForElement};
@ -153,11 +154,12 @@ pub trait DomTraversal<E: TElement> : Sync {
if !traversal_flags.for_animation_only() { if !traversal_flags.for_animation_only() {
// Invalidate our style, and that of our siblings and // Invalidate our style, and that of our siblings and
// descendants as needed. // descendants as needed.
// let invalidation_result = data.invalidate_style_if_needed(
// FIXME(emilio): an nth-index cache could be worth here, even root,
// if temporary? shared_context,
let invalidation_result = None,
data.invalidate_style_if_needed(root, shared_context, None, None); &mut NthIndexCache::default(),
);
if invalidation_result.has_invalidated_siblings() { if invalidation_result.has_invalidated_siblings() {
let actual_root = root.traversal_parent() let actual_root = root.traversal_parent()
@ -802,7 +804,7 @@ where
child, child,
&context.shared, &context.shared,
Some(&context.thread_local.stack_limit_checker), Some(&context.thread_local.stack_limit_checker),
Some(&mut context.thread_local.nth_index_cache) &mut context.thread_local.nth_index_cache,
); );
} }

View file

@ -6,7 +6,7 @@ use cssparser::{Parser, ParserInput};
use cssparser::ToCss as ParserToCss; use cssparser::ToCss as ParserToCss;
use env_logger::LogBuilder; use env_logger::LogBuilder;
use malloc_size_of::MallocSizeOfOps; use malloc_size_of::MallocSizeOfOps;
use selectors::Element; use selectors::{Element, NthIndexCache};
use selectors::matching::{MatchingContext, MatchingMode, matches_selector}; use selectors::matching::{MatchingContext, MatchingMode, matches_selector};
use servo_arc::{Arc, ArcBorrow, RawOffsetArc}; use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
use std::cell::RefCell; use std::cell::RefCell;
@ -4478,15 +4478,13 @@ pub extern "C" fn Servo_ProcessInvalidations(
let mut data = data.as_mut().map(|d| &mut **d); let mut data = data.as_mut().map(|d| &mut **d);
if let Some(ref mut data) = data { if let Some(ref mut data) = data {
// FIXME(emilio): an nth-index cache could be worth here, even // FIXME(emilio): Ideally we could share the nth-index-cache across all
// if temporary? // the elements?
//
// Also, ideally we could share them across all the elements?
let result = data.invalidate_style_if_needed( let result = data.invalidate_style_if_needed(
element, element,
&shared_style_context, &shared_style_context,
None, None,
None, &mut NthIndexCache::default(),
); );
if result.has_invalidated_siblings() { if result.has_invalidated_siblings() {