diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2013-11-09 21:39:39 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2013-11-18 11:24:11 -0800 |
commit | 155befe10dc56cfb2dfbf0cca7b652293dba9753 (patch) | |
tree | 43c3e51689cd42a3fb623eda84740f49dd667f5e /src/components/main/layout/float.rs | |
parent | 37f9427b6c53b90234e82d219217a97c10811243 (diff) | |
download | servo-155befe10dc56cfb2dfbf0cca7b652293dba9753.tar.gz servo-155befe10dc56cfb2dfbf0cca7b652293dba9753.zip |
Rewrite flow construction to be incrementalizable and parallelizable.
This replaces flow construction with a strict bottom-up tree traversal,
allowing for parallelism. Each step of the traversal creates a flow or
a `ConstructionItem`, similar to how Gecko works. {ib} splits are
handled by not creating `InlineFlow`s until the containing block is
reached.
This should be able to be incrementalized by storing the `Flow` from
layout to layout, and performing fixups during flow construction
and/or wiping containing blocks in a previous pass.
Diffstat (limited to 'src/components/main/layout/float.rs')
-rw-r--r-- | src/components/main/layout/float.rs | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/components/main/layout/float.rs b/src/components/main/layout/float.rs index 3559ca4e842..be7ac50524b 100644 --- a/src/components/main/layout/float.rs +++ b/src/components/main/layout/float.rs @@ -53,6 +53,18 @@ impl FloatFlow { } } + pub fn from_box(base: FlowData, float_type: FloatType, box: @RenderBox) -> FloatFlow { + FloatFlow { + base: base, + containing_width: Au(0), + box: Some(box), + index: None, + float_type: float_type, + rel_pos: Point2D(Au(0), Au(0)), + floated_children: 0, + } + } + pub fn teardown(&mut self) { for box in self.box.iter() { box.teardown(); @@ -252,7 +264,7 @@ impl FlowContext for FloatFlow { } fn assign_height(&mut self, ctx: &mut LayoutContext) { - debug!("assign_height_float: assigning height for float {}", self.base.id); + // Now that we've determined our height, propagate that out. let has_inorder_children = self.base.num_floats > 0; if has_inorder_children { let mut float_ctx = FloatContext::new(self.floated_children); @@ -262,7 +274,7 @@ impl FlowContext for FloatFlow { float_ctx = flow::mut_base(*kid).floats_out.clone(); } } - + debug!("assign_height_float: assigning height for float {}", self.base.id); let mut cur_y = Au(0); let mut top_offset = Au(0); @@ -281,26 +293,25 @@ impl FlowContext for FloatFlow { let mut height = cur_y - top_offset; let mut noncontent_height; - for box in self.box.iter() { - let base = box.base(); - let mut position_ref = base.position.mutate(); - let position = &mut position_ref.ptr; + let box = self.box.as_ref().unwrap(); + let base = box.base(); + let mut position_ref = base.position.mutate(); + let position = &mut position_ref.ptr; - // The associated box is the border box of this flow. - position.origin.y = base.margin.top; + // The associated box is the border box of this flow. + position.origin.y = base.margin.top; - noncontent_height = base.padding.top + base.padding.bottom + base.border.top + - base.border.bottom; - - //TODO(eatkinson): compute heights properly using the 'height' property. - let height_prop = MaybeAuto::from_style(base.style().Box.height, - Au::new(0)).specified_or_zero(); + noncontent_height = base.padding.top + base.padding.bottom + base.border.top + + base.border.bottom; + + //TODO(eatkinson): compute heights properly using the 'height' property. + let height_prop = MaybeAuto::from_style(base.style().Box.height, + Au::new(0)).specified_or_zero(); - height = geometry::max(height, height_prop) + noncontent_height; - debug!("assign_height_float -- height: {}", height); + height = geometry::max(height, height_prop) + noncontent_height; + debug!("assign_height_float -- height: {}", height); - position.size.height = height; - } + position.size.height = height; } @@ -314,6 +325,7 @@ impl FlowContext for FloatFlow { // Margins between a floated box and any other box do not collapse. *collapsing = Au::new(0); } + fn debug_str(&self) -> ~str { ~"FloatFlow" } |