mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Hook the recursive invalidation traversal up to the stack checker machinery.
MozReview-Commit-ID: 3tX3gHFTBT
This commit is contained in:
parent
2136dd2bb7
commit
8c3cc9ba1f
4 changed files with 33 additions and 13 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! Per-node data used in style calculation.
|
||||
|
||||
use context::SharedStyleContext;
|
||||
use context::{SharedStyleContext, StackLimitChecker};
|
||||
use dom::TElement;
|
||||
use invalidation::element::restyle_hints::RestyleHint;
|
||||
use properties::ComputedValues;
|
||||
|
@ -327,8 +327,9 @@ impl ElementData {
|
|||
pub fn invalidate_style_if_needed<'a, E: TElement>(
|
||||
&mut self,
|
||||
element: E,
|
||||
shared_context: &SharedStyleContext)
|
||||
{
|
||||
shared_context: &SharedStyleContext,
|
||||
stack_limit_checker: Option<&StackLimitChecker>,
|
||||
) {
|
||||
// In animation-only restyle we shouldn't touch snapshot at all.
|
||||
if shared_context.traversal_flags.for_animation_only() {
|
||||
return;
|
||||
|
@ -349,6 +350,7 @@ impl ElementData {
|
|||
element,
|
||||
Some(self),
|
||||
shared_context,
|
||||
stack_limit_checker,
|
||||
);
|
||||
invalidator.invalidate();
|
||||
unsafe { element.set_handled_snapshot() }
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//! element styles need to be invalidated.
|
||||
|
||||
use Atom;
|
||||
use context::SharedStyleContext;
|
||||
use context::{SharedStyleContext, StackLimitChecker};
|
||||
use data::ElementData;
|
||||
use dom::{TElement, TNode};
|
||||
use element_state::{ElementState, IN_VISITED_OR_UNVISITED_STATE};
|
||||
|
@ -40,6 +40,7 @@ pub struct TreeStyleInvalidator<'a, 'b: 'a, E>
|
|||
// descendants if an element has no data, though.
|
||||
data: Option<&'a mut ElementData>,
|
||||
shared_context: &'a SharedStyleContext<'b>,
|
||||
stack_limit_checker: Option<&'a StackLimitChecker>,
|
||||
}
|
||||
|
||||
type InvalidationVector = SmallVec<[Invalidation; 10]>;
|
||||
|
@ -130,11 +131,13 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>
|
|||
element: E,
|
||||
data: Option<&'a mut ElementData>,
|
||||
shared_context: &'a SharedStyleContext<'b>,
|
||||
stack_limit_checker: Option<&'a StackLimitChecker>,
|
||||
) -> Self {
|
||||
Self {
|
||||
element: element,
|
||||
data: data,
|
||||
shared_context: shared_context,
|
||||
element,
|
||||
data,
|
||||
shared_context,
|
||||
stack_limit_checker,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +279,8 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>
|
|||
let mut sibling_invalidator = TreeStyleInvalidator::new(
|
||||
sibling,
|
||||
sibling_data,
|
||||
self.shared_context
|
||||
self.shared_context,
|
||||
self.stack_limit_checker,
|
||||
);
|
||||
|
||||
let mut invalidations_for_descendants = InvalidationVector::new();
|
||||
|
@ -338,7 +342,8 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>
|
|||
let mut child_invalidator = TreeStyleInvalidator::new(
|
||||
child,
|
||||
child_data,
|
||||
self.shared_context
|
||||
self.shared_context,
|
||||
self.stack_limit_checker,
|
||||
);
|
||||
|
||||
let mut invalidations_for_descendants = InvalidationVector::new();
|
||||
|
@ -448,12 +453,21 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>
|
|||
match self.data {
|
||||
None => return false,
|
||||
Some(ref data) => {
|
||||
// FIXME(emilio): Only needs to check RESTYLE_DESCENDANTS,
|
||||
// really.
|
||||
if data.restyle.hint.contains_subtree() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(checker) = self.stack_limit_checker {
|
||||
if checker.limit_exceeded() {
|
||||
self.data.as_mut().unwrap().restyle.hint.insert(RESTYLE_DESCENDANTS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
let mut any_descendant = false;
|
||||
|
||||
if let Some(anon_content) = self.element.xbl_binding_anonymous_content() {
|
||||
|
|
|
@ -139,7 +139,7 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
fn pre_traverse(
|
||||
root: E,
|
||||
shared_context: &SharedStyleContext,
|
||||
traversal_flags: TraversalFlags
|
||||
traversal_flags: TraversalFlags,
|
||||
) -> PreTraverseToken {
|
||||
// If this is an unstyled-only traversal, the caller has already verified
|
||||
// that there's something to traverse, and we don't need to do any
|
||||
|
@ -155,7 +155,7 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
if let Some(ref mut data) = data {
|
||||
// Invalidate our style, and the one of our siblings and descendants
|
||||
// as needed.
|
||||
data.invalidate_style_if_needed(root, shared_context);
|
||||
data.invalidate_style_if_needed(root, shared_context, None);
|
||||
|
||||
// Make sure we don't have any stale RECONSTRUCTED_ANCESTOR bits from
|
||||
// the last traversal (at a potentially-higher root). From the
|
||||
|
@ -828,7 +828,11 @@ where
|
|||
// as needed.
|
||||
//
|
||||
// NB: This will be a no-op if there's no snapshot.
|
||||
child_data.invalidate_style_if_needed(child, &context.shared);
|
||||
child_data.invalidate_style_if_needed(
|
||||
child,
|
||||
&context.shared,
|
||||
Some(&context.thread_local.stack_limit_checker)
|
||||
);
|
||||
}
|
||||
|
||||
if D::element_needs_traversal(child, flags, child_data.map(|d| &*d), Some(data)) {
|
||||
|
|
|
@ -3701,6 +3701,6 @@ pub extern "C" fn Servo_ProcessInvalidations(set: RawServoStyleSetBorrowed,
|
|||
let mut data = data.as_mut().map(|d| &mut **d);
|
||||
|
||||
if let Some(ref mut data) = data {
|
||||
data.invalidate_style_if_needed(element, &shared_style_context);
|
||||
data.invalidate_style_if_needed(element, &shared_style_context, None);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue