aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/traversal.rs
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2016-11-01 23:11:24 -0700
committerBobby Holley <bobbyholley@gmail.com>2016-11-24 17:07:38 -0800
commit992f7dddf4771cf298c3510fca82b497d2593750 (patch)
tree1d495d5597da007294c79fc009b17d7f07288cf4 /components/layout/traversal.rs
parente1eff691f8a1d8c9c7ab33344364f0419626b80e (diff)
downloadservo-992f7dddf4771cf298c3510fca82b497d2593750.tar.gz
servo-992f7dddf4771cf298c3510fca82b497d2593750.zip
Bug 1317016 - Basic infrastructure for RestyleHint-driven traversal.
MozReview-Commit-ID: 7wH5XcILVmX
Diffstat (limited to 'components/layout/traversal.rs')
-rw-r--r--components/layout/traversal.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index f0ba10d9f55..f932a8bffc0 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -112,15 +112,11 @@ impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc>
construct_flows_at(&self.context, self.root, node);
}
- fn should_traverse_child(parent: N::ConcreteElement, child: N) -> bool {
- // If the parent is display:none, we don't need to do anything.
- if parent.is_display_none() {
- return false;
- }
-
+ fn should_traverse_child(child: N, restyled_previous_sibling_element: bool) -> bool {
match child.as_element() {
// Elements should be traversed if they need styling or flow construction.
- Some(el) => el.styling_mode() != StylingMode::Stop ||
+ Some(el) => restyled_previous_sibling_element ||
+ el.styling_mode() != StylingMode::Stop ||
el.as_node().to_threadsafe().restyle_damage() != RestyleDamage::empty(),
// Text nodes never need styling. However, there are two cases they may need
@@ -128,7 +124,7 @@ impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc>
// (1) They child doesn't yet have layout data (preorder traversal initializes it).
// (2) The parent element has restyle damage (so the text flow also needs fixup).
None => child.get_raw_data().is_none() ||
- parent.as_node().to_threadsafe().restyle_damage() != RestyleDamage::empty(),
+ child.parent_node().unwrap().to_threadsafe().restyle_damage() != RestyleDamage::empty(),
}
}
@@ -156,6 +152,8 @@ pub trait PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode: ThreadSafeLayo
#[inline]
#[allow(unsafe_code)]
fn construct_flows_at<'a, N: LayoutNode>(context: &'a LayoutContext<'a>, root: OpaqueNode, node: N) {
+ debug!("construct_flows_at: {:?}", node);
+
// Construct flows for this node.
{
let tnode = node.to_threadsafe();
@@ -167,16 +165,18 @@ fn construct_flows_at<'a, N: LayoutNode>(context: &'a LayoutContext<'a>, root: O
let mut flow_constructor = FlowConstructor::new(context);
if nonincremental_layout || !flow_constructor.repair_if_possible(&tnode) {
flow_constructor.process(&tnode);
- debug!("Constructed flow for {:x}: {:x}",
- tnode.debug_id(),
+ debug!("Constructed flow for {:?}: {:x}",
+ tnode,
tnode.flow_debug_id());
}
}
+ }
- tnode.clear_restyle_damage();
+ if let Some(el) = node.as_element() {
+ el.mutate_data().unwrap().persist();
+ unsafe { el.unset_dirty_descendants(); }
}
- unsafe { node.clear_dirty_bits(); }
remove_from_bloom_filter(context, root, node);
}