aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/data.rs5
-rw-r--r--components/style/invalidation/element/collector.rs22
-rw-r--r--components/style/invalidation/element/invalidator.rs24
3 files changed, 31 insertions, 20 deletions
diff --git a/components/style/data.rs b/components/style/data.rs
index 7e50a67dbb3..defb0a49759 100644
--- a/components/style/data.rs
+++ b/components/style/data.rs
@@ -259,11 +259,12 @@ impl ElementData {
return InvalidationResult::empty();
}
- let mut processor = StateAndAttrInvalidationProcessor;
+ let mut processor =
+ StateAndAttrInvalidationProcessor::new(shared_context);
let invalidator = TreeStyleInvalidator::new(
element,
Some(self),
- shared_context,
+ shared_context.quirks_mode(),
stack_limit_checker,
nth_index_cache,
&mut processor,
diff --git a/components/style/invalidation/element/collector.rs b/components/style/invalidation/element/collector.rs
index b1971bfab19..2bdc5f4a0cc 100644
--- a/components/style/invalidation/element/collector.rs
+++ b/components/style/invalidation/element/collector.rs
@@ -51,9 +51,18 @@ where
/// An invalidation processor for style changes due to state and attribute
/// changes.
-pub struct StateAndAttrInvalidationProcessor;
+pub struct StateAndAttrInvalidationProcessor<'a, 'b: 'a> {
+ shared_context: &'a SharedStyleContext<'b>,
+}
+
+impl<'a, 'b: 'a> StateAndAttrInvalidationProcessor<'a, 'b> {
+ /// Creates a new StateAndAttrInvalidationProcessor.
+ pub fn new(shared_context: &'a SharedStyleContext<'b>) -> Self {
+ Self { shared_context }
+ }
+}
-impl<E> InvalidationProcessor<E> for StateAndAttrInvalidationProcessor
+impl<'a, 'b: 'a, E> InvalidationProcessor<E> for StateAndAttrInvalidationProcessor<'a, 'b>
where
E: TElement,
{
@@ -67,15 +76,16 @@ where
element: E,
mut data: Option<&mut ElementData>,
nth_index_cache: Option<&mut NthIndexCache>,
- shared_context: &SharedStyleContext,
+ quirks_mode: QuirksMode,
descendant_invalidations: &mut InvalidationVector,
sibling_invalidations: &mut InvalidationVector,
) -> bool {
debug_assert!(element.has_snapshot(), "Why bothering?");
debug_assert!(data.is_some(), "How exactly?");
+ debug_assert_eq!(quirks_mode, self.shared_context.quirks_mode(), "How exactly?");
let wrapper =
- ElementWrapper::new(element, &*shared_context.snapshot_map);
+ ElementWrapper::new(element, &*self.shared_context.snapshot_map);
let state_changes = wrapper.state_changes();
let snapshot = wrapper.snapshot().expect("has_snapshot lied");
@@ -140,7 +150,7 @@ where
state_changes,
element,
snapshot: &snapshot,
- quirks_mode: shared_context.quirks_mode(),
+ quirks_mode: self.shared_context.quirks_mode(),
removed_id: id_removed.as_ref(),
added_id: id_added.as_ref(),
classes_removed: &classes_removed,
@@ -150,7 +160,7 @@ where
invalidates_self: false,
};
- shared_context.stylist.each_invalidation_map(|invalidation_map| {
+ self.shared_context.stylist.each_invalidation_map(|invalidation_map| {
collector.collect_dependencies_in_invalidation_map(invalidation_map);
});
diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs
index 97edd7a4203..7ad87363066 100644
--- a/components/style/invalidation/element/invalidator.rs
+++ b/components/style/invalidation/element/invalidator.rs
@@ -5,12 +5,12 @@
//! The struct that takes care of encapsulating all the logic on where and how
//! element styles need to be invalidated.
-use context::{SharedStyleContext, StackLimitChecker};
+use context::StackLimitChecker;
use data::ElementData;
use dom::{TElement, TNode};
use selector_parser::SelectorImpl;
use selectors::NthIndexCache;
-use selectors::matching::{MatchingContext, MatchingMode, VisitedHandlingMode};
+use selectors::matching::{MatchingContext, MatchingMode, QuirksMode, VisitedHandlingMode};
use selectors::matching::CompoundSelectorMatchingResult;
use selectors::matching::matches_compound_selector;
use selectors::parser::{Combinator, Component, Selector};
@@ -38,7 +38,7 @@ where
element: E,
data: Option<&mut ElementData>,
nth_index_cache: Option<&mut NthIndexCache>,
- shared_context: &SharedStyleContext,
+ quirks_mode: QuirksMode,
descendant_invalidations: &mut InvalidationVector,
sibling_invalidations: &mut InvalidationVector,
) -> bool;
@@ -77,7 +77,7 @@ where
/// The struct that takes care of encapsulating all the logic on where and how
/// element styles need to be invalidated.
-pub struct TreeStyleInvalidator<'a, 'b: 'a, E, P: 'a>
+pub struct TreeStyleInvalidator<'a, E, P: 'a>
where
E: TElement,
P: InvalidationProcessor<E>
@@ -93,7 +93,7 @@ where
// Seems like we could at least avoid running invalidation for the
// descendants if an element has no data, though.
data: Option<&'a mut ElementData>,
- shared_context: &'a SharedStyleContext<'b>,
+ quirks_mode: QuirksMode,
stack_limit_checker: Option<&'a StackLimitChecker>,
nth_index_cache: Option<&'a mut NthIndexCache>,
processor: &'a mut P,
@@ -224,7 +224,7 @@ impl InvalidationResult {
}
}
-impl<'a, 'b: 'a, E, P: 'a> TreeStyleInvalidator<'a, 'b, E, P>
+impl<'a, E, P: 'a> TreeStyleInvalidator<'a, E, P>
where
E: TElement,
P: InvalidationProcessor<E>,
@@ -233,7 +233,7 @@ where
pub fn new(
element: E,
data: Option<&'a mut ElementData>,
- shared_context: &'a SharedStyleContext<'b>,
+ quirks_mode: QuirksMode,
stack_limit_checker: Option<&'a StackLimitChecker>,
nth_index_cache: Option<&'a mut NthIndexCache>,
processor: &'a mut P,
@@ -241,7 +241,7 @@ where
Self {
element,
data,
- shared_context,
+ quirks_mode,
stack_limit_checker,
nth_index_cache,
processor,
@@ -259,7 +259,7 @@ where
self.element,
self.data.as_mut().map(|d| &mut **d),
self.nth_index_cache.as_mut().map(|c| &mut **c),
- self.shared_context,
+ self.quirks_mode,
&mut descendant_invalidations,
&mut sibling_invalidations,
);
@@ -296,7 +296,7 @@ where
let mut sibling_invalidator = TreeStyleInvalidator::new(
sibling,
sibling_data.as_mut().map(|d| &mut **d),
- self.shared_context,
+ self.quirks_mode,
self.stack_limit_checker,
self.nth_index_cache.as_mut().map(|c| &mut **c),
self.processor,
@@ -364,7 +364,7 @@ where
let mut child_invalidator = TreeStyleInvalidator::new(
child,
child_data.as_mut().map(|d| &mut **d),
- self.shared_context,
+ self.quirks_mode,
self.stack_limit_checker,
self.nth_index_cache.as_mut().map(|c| &mut **c),
self.processor,
@@ -609,7 +609,7 @@ where
None,
self.nth_index_cache.as_mut().map(|c| &mut **c),
VisitedHandlingMode::AllLinksVisitedAndUnvisited,
- self.shared_context.quirks_mode(),
+ self.quirks_mode,
);
matches_compound_selector(