mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Clean up a bit traversal culling
Differential Revision: https://phabricator.services.mozilla.com/D151544
This commit is contained in:
parent
461850d5e6
commit
047812cb98
1 changed files with 4 additions and 26 deletions
|
@ -268,26 +268,6 @@ pub trait DomTraversal<E: TElement>: Sync {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if we want to cull this subtree from the travesal.
|
|
||||||
fn should_cull_subtree(
|
|
||||||
&self,
|
|
||||||
context: &mut StyleContext<E>,
|
|
||||||
parent: E,
|
|
||||||
parent_data: &ElementData,
|
|
||||||
) -> bool {
|
|
||||||
debug_assert!(
|
|
||||||
parent.has_current_styles_for_traversal(parent_data, context.shared.traversal_flags)
|
|
||||||
);
|
|
||||||
|
|
||||||
// If the parent computed display:none, we don't style the subtree.
|
|
||||||
if parent_data.styles.is_display_none() {
|
|
||||||
debug!("Parent {:?} is display:none, culling traversal", parent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the shared style context common to all worker threads.
|
/// Return the shared style context common to all worker threads.
|
||||||
fn shared_context(&self) -> &SharedStyleContext;
|
fn shared_context(&self) -> &SharedStyleContext;
|
||||||
}
|
}
|
||||||
|
@ -408,7 +388,7 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn recalc_style_at<E, D, F>(
|
pub fn recalc_style_at<E, D, F>(
|
||||||
traversal: &D,
|
_traversal: &D,
|
||||||
traversal_data: &PerLevelTraversalData,
|
traversal_data: &PerLevelTraversalData,
|
||||||
context: &mut StyleContext<E>,
|
context: &mut StyleContext<E>,
|
||||||
element: E,
|
element: E,
|
||||||
|
@ -520,16 +500,14 @@ pub fn recalc_style_at<E, D, F>(
|
||||||
// * We can't skip the cascade.
|
// * We can't skip the cascade.
|
||||||
// * This is a servo non-incremental traversal.
|
// * This is a servo non-incremental traversal.
|
||||||
//
|
//
|
||||||
// Additionally, there are a few scenarios where we avoid traversing the
|
// We only do this if we're not a display: none root, since in that case
|
||||||
// subtree even if descendant styles are out of date. These cases are
|
// it's useless to style children.
|
||||||
// enumerated in should_cull_subtree().
|
|
||||||
let mut traverse_children = has_dirty_descendants_for_this_restyle ||
|
let mut traverse_children = has_dirty_descendants_for_this_restyle ||
|
||||||
!propagated_hint.is_empty() ||
|
!propagated_hint.is_empty() ||
|
||||||
!child_cascade_requirement.can_skip_cascade() ||
|
!child_cascade_requirement.can_skip_cascade() ||
|
||||||
is_servo_nonincremental_layout();
|
is_servo_nonincremental_layout();
|
||||||
|
|
||||||
traverse_children =
|
traverse_children = traverse_children && !data.styles.is_display_none();
|
||||||
traverse_children && !traversal.should_cull_subtree(context, element, &data);
|
|
||||||
|
|
||||||
// Examine our children, and enqueue the appropriate ones for traversal.
|
// Examine our children, and enqueue the appropriate ones for traversal.
|
||||||
if traverse_children {
|
if traverse_children {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue