mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Make InvalidationProcessor methods be &mut self.
This would allow querySelector / querySelectorAll to mutate the list of matched nodes as it sees fit.
This commit is contained in:
parent
9034e6a732
commit
e447f819a2
3 changed files with 38 additions and 41 deletions
|
@ -259,14 +259,14 @@ impl ElementData {
|
||||||
return InvalidationResult::empty();
|
return InvalidationResult::empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
let processor = StateAndAttrInvalidationProcessor;
|
let mut processor = StateAndAttrInvalidationProcessor;
|
||||||
let invalidator = TreeStyleInvalidator::new(
|
let invalidator = TreeStyleInvalidator::new(
|
||||||
element,
|
element,
|
||||||
Some(self),
|
Some(self),
|
||||||
shared_context,
|
shared_context,
|
||||||
stack_limit_checker,
|
stack_limit_checker,
|
||||||
nth_index_cache,
|
nth_index_cache,
|
||||||
&processor,
|
&mut processor,
|
||||||
);
|
);
|
||||||
|
|
||||||
let result = invalidator.invalidate();
|
let result = invalidator.invalidate();
|
||||||
|
|
|
@ -63,7 +63,7 @@ where
|
||||||
fn invalidates_on_eager_pseudo_element(&self) -> bool { true }
|
fn invalidates_on_eager_pseudo_element(&self) -> bool { true }
|
||||||
|
|
||||||
fn collect_invalidations(
|
fn collect_invalidations(
|
||||||
&self,
|
&mut self,
|
||||||
element: E,
|
element: E,
|
||||||
mut data: Option<&mut ElementData>,
|
mut data: Option<&mut ElementData>,
|
||||||
nth_index_cache: Option<&mut NthIndexCache>,
|
nth_index_cache: Option<&mut NthIndexCache>,
|
||||||
|
@ -182,7 +182,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_process_descendants(
|
fn should_process_descendants(
|
||||||
&self,
|
&mut self,
|
||||||
_element: E,
|
_element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
@ -196,7 +196,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn recursion_limit_exceeded(
|
fn recursion_limit_exceeded(
|
||||||
&self,
|
&mut self,
|
||||||
_element: E,
|
_element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
) {
|
) {
|
||||||
|
@ -206,7 +206,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invalidated_descendants(
|
fn invalidated_descendants(
|
||||||
&self,
|
&mut self,
|
||||||
element: E,
|
element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
child: E,
|
child: E,
|
||||||
|
@ -236,7 +236,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invalidated_self(
|
fn invalidated_self(
|
||||||
&self,
|
&mut self,
|
||||||
_element: E,
|
_element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ where
|
||||||
///
|
///
|
||||||
/// Returns whether the element itself was invalidated.
|
/// Returns whether the element itself was invalidated.
|
||||||
fn collect_invalidations(
|
fn collect_invalidations(
|
||||||
&self,
|
&mut self,
|
||||||
element: E,
|
element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
nth_index_cache: Option<&mut NthIndexCache>,
|
nth_index_cache: Option<&mut NthIndexCache>,
|
||||||
|
@ -46,7 +46,7 @@ where
|
||||||
/// Returns whether the invalidation process should process the descendants
|
/// Returns whether the invalidation process should process the descendants
|
||||||
/// of the given element.
|
/// of the given element.
|
||||||
fn should_process_descendants(
|
fn should_process_descendants(
|
||||||
&self,
|
&mut self,
|
||||||
element: E,
|
element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
|
@ -54,21 +54,21 @@ where
|
||||||
/// Executes an arbitrary action when the recursion limit is exceded (if
|
/// Executes an arbitrary action when the recursion limit is exceded (if
|
||||||
/// any).
|
/// any).
|
||||||
fn recursion_limit_exceeded(
|
fn recursion_limit_exceeded(
|
||||||
&self,
|
&mut self,
|
||||||
element: E,
|
element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Executes an action when `Self` is invalidated.
|
/// Executes an action when `Self` is invalidated.
|
||||||
fn invalidated_self(
|
fn invalidated_self(
|
||||||
&self,
|
&mut self,
|
||||||
element: E,
|
element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Executes an action when any descendant of `Self` is invalidated.
|
/// Executes an action when any descendant of `Self` is invalidated.
|
||||||
fn invalidated_descendants(
|
fn invalidated_descendants(
|
||||||
&self,
|
&mut self,
|
||||||
element: E,
|
element: E,
|
||||||
data: Option<&mut ElementData>,
|
data: Option<&mut ElementData>,
|
||||||
child: E,
|
child: E,
|
||||||
|
@ -96,10 +96,7 @@ where
|
||||||
shared_context: &'a SharedStyleContext<'b>,
|
shared_context: &'a SharedStyleContext<'b>,
|
||||||
stack_limit_checker: Option<&'a StackLimitChecker>,
|
stack_limit_checker: Option<&'a StackLimitChecker>,
|
||||||
nth_index_cache: Option<&'a mut NthIndexCache>,
|
nth_index_cache: Option<&'a mut NthIndexCache>,
|
||||||
|
processor: &'a mut P,
|
||||||
// TODO(emilio): Make a mutable reference, we're going to need that for
|
|
||||||
// QS/QSA.
|
|
||||||
processor: &'a P,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A vector of invalidations, optimized for small invalidation sets.
|
/// A vector of invalidations, optimized for small invalidation sets.
|
||||||
|
@ -240,7 +237,7 @@ where
|
||||||
shared_context: &'a SharedStyleContext<'b>,
|
shared_context: &'a SharedStyleContext<'b>,
|
||||||
stack_limit_checker: Option<&'a StackLimitChecker>,
|
stack_limit_checker: Option<&'a StackLimitChecker>,
|
||||||
nth_index_cache: Option<&'a mut NthIndexCache>,
|
nth_index_cache: Option<&'a mut NthIndexCache>,
|
||||||
processor: &'a P,
|
processor: &'a mut P,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
element,
|
element,
|
||||||
|
@ -359,36 +356,36 @@ where
|
||||||
invalidations: &InvalidationVector,
|
invalidations: &InvalidationVector,
|
||||||
sibling_invalidations: &mut InvalidationVector,
|
sibling_invalidations: &mut InvalidationVector,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut child_data = child.mutate_data();
|
|
||||||
|
|
||||||
let mut child_invalidator = TreeStyleInvalidator::new(
|
|
||||||
child,
|
|
||||||
child_data.as_mut().map(|d| &mut **d),
|
|
||||||
self.shared_context,
|
|
||||||
self.stack_limit_checker,
|
|
||||||
self.nth_index_cache.as_mut().map(|c| &mut **c),
|
|
||||||
self.processor,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut invalidations_for_descendants = InvalidationVector::new();
|
let mut invalidations_for_descendants = InvalidationVector::new();
|
||||||
|
|
||||||
let mut invalidated_child = false;
|
let mut invalidated_child = false;
|
||||||
|
let invalidated_descendants = {
|
||||||
|
let mut child_data = child.mutate_data();
|
||||||
|
|
||||||
invalidated_child |=
|
let mut child_invalidator = TreeStyleInvalidator::new(
|
||||||
child_invalidator.process_sibling_invalidations(
|
child,
|
||||||
&mut invalidations_for_descendants,
|
child_data.as_mut().map(|d| &mut **d),
|
||||||
sibling_invalidations,
|
self.shared_context,
|
||||||
|
self.stack_limit_checker,
|
||||||
|
self.nth_index_cache.as_mut().map(|c| &mut **c),
|
||||||
|
self.processor,
|
||||||
);
|
);
|
||||||
|
|
||||||
invalidated_child |=
|
invalidated_child |=
|
||||||
child_invalidator.process_descendant_invalidations(
|
child_invalidator.process_sibling_invalidations(
|
||||||
invalidations,
|
&mut invalidations_for_descendants,
|
||||||
&mut invalidations_for_descendants,
|
sibling_invalidations,
|
||||||
sibling_invalidations,
|
);
|
||||||
);
|
|
||||||
|
|
||||||
let invalidated_descendants = child_invalidator.invalidate_descendants(
|
invalidated_child |=
|
||||||
&invalidations_for_descendants
|
child_invalidator.process_descendant_invalidations(
|
||||||
);
|
invalidations,
|
||||||
|
&mut invalidations_for_descendants,
|
||||||
|
sibling_invalidations,
|
||||||
|
);
|
||||||
|
|
||||||
|
child_invalidator.invalidate_descendants(&invalidations_for_descendants)
|
||||||
|
};
|
||||||
|
|
||||||
// The child may not be a flattened tree child of the current element,
|
// The child may not be a flattened tree child of the current element,
|
||||||
// but may be arbitrarily deep.
|
// but may be arbitrarily deep.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue