aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/traversal.rs
diff options
context:
space:
mode:
authorClark Gaebel <cgaebel@mozilla.com>2014-10-13 00:07:03 -0400
committerClark Gaebel <cgaebel@mozilla.com>2014-10-14 16:28:29 -0700
commit7368d42225b94f3ac821058800350d7c541f1a3f (patch)
treee06ddd10a36d9946ea0aeb1396f9358e7a881beb /components/layout/traversal.rs
parent56989b8dec4aa95a3b484d45f15b23f9b3daaf13 (diff)
downloadservo-7368d42225b94f3ac821058800350d7c541f1a3f.tar.gz
servo-7368d42225b94f3ac821058800350d7c541f1a3f.zip
Removes duplicate CSS selector matching logic.
Now that DOM/Flow traversals have been refactored out, the `recalc_style_for_subtree` function in `css/matching.rs` can be removed, in lieu of just running the standard `recalc_style_for_node` and `construct_flows` traversals sequentially. Now we no longer have the maintenance headache of duplicating selector matching logic in two places! \o/ r? @pcwalton
Diffstat (limited to 'components/layout/traversal.rs')
-rw-r--r--components/layout/traversal.rs42
1 files changed, 17 insertions, 25 deletions
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index b9686e84276..c05e67b4dc0 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -261,14 +261,13 @@ struct FlowTreeVerification;
#[cfg(debug)]
impl PreorderFlow for FlowTreeVerification {
#[inline]
- fn process(&mut self, flow: &mut Flow) -> bool {
+ fn process(&mut self, flow: &mut Flow) {
let base = flow::base(flow);
if !base.flags.is_leaf() && !base.flags.is_nonleaf() {
println("flow tree verification failed: flow wasn't a leaf or a nonleaf!");
flow.dump();
fail!("flow tree verification failed")
}
- true
}
}
@@ -280,18 +279,9 @@ pub struct BubbleISizes<'a> {
impl<'a> PostorderFlowTraversal for BubbleISizes<'a> {
#[inline]
- fn process(&mut self, flow: &mut Flow) -> bool {
+ fn process(&self, flow: &mut Flow) {
flow.bubble_inline_sizes();
- true
}
-
- // FIXME: We can't prune until we start reusing flows
- /*
- #[inline]
- fn should_prune(&mut self, flow: &mut Flow) -> bool {
- flow::mut_base(flow).restyle_damage.lacks(BubbleISizes)
- }
- */
}
/// The assign-inline-sizes traversal. In Gecko this corresponds to `Reflow`.
@@ -301,9 +291,8 @@ pub struct AssignISizes<'a> {
impl<'a> PreorderFlowTraversal for AssignISizes<'a> {
#[inline]
- fn process(&mut self, flow: &mut Flow) -> bool {
+ fn process(&self, flow: &mut Flow) {
flow.assign_inline_sizes(self.layout_context);
- true
}
}
@@ -317,36 +306,39 @@ pub struct AssignBSizesAndStoreOverflow<'a> {
impl<'a> PostorderFlowTraversal for AssignBSizesAndStoreOverflow<'a> {
#[inline]
- fn process(&mut self, flow: &mut Flow) -> bool {
+ fn process(&self, flow: &mut Flow) {
flow.assign_block_size(self.layout_context);
// Skip store-overflow for absolutely positioned flows. That will be
// done in a separate traversal.
if !flow.is_store_overflow_delayed() {
flow.store_overflow(self.layout_context);
}
- true
}
#[inline]
- fn should_process(&mut self, flow: &mut Flow) -> bool {
+ fn should_process(&self, flow: &mut Flow) -> bool {
!flow::base(flow).flags.impacted_by_floats()
}
}
-/// The display list construction traversal.
-pub struct BuildDisplayList<'a> {
+pub struct ComputeAbsolutePositions<'a> {
pub layout_context: &'a LayoutContext<'a>,
}
-impl<'a> BuildDisplayList<'a> {
+impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> {
#[inline]
- pub fn process(&mut self, flow: &mut Flow) {
- flow.compute_absolute_position();
+ fn process(&self, flow: &mut Flow) {
+ flow.compute_absolute_position()
+ }
+}
- for kid in flow::mut_base(flow).child_iter() {
- self.process(kid)
- }
+pub struct BuildDisplayList<'a> {
+ pub layout_context: &'a LayoutContext<'a>,
+}
+impl<'a> PostorderFlowTraversal for BuildDisplayList<'a> {
+ #[inline]
+ fn process(&self, flow: &mut Flow) {
flow.build_display_list(self.layout_context)
}
}