diff --git a/src/servo/layout/base.rs b/src/servo/layout/base.rs index 4714fc0895c..aa0441939b7 100644 --- a/src/servo/layout/base.rs +++ b/src/servo/layout/base.rs @@ -1,12 +1,15 @@ +#[doc="Fundamental layout structures and algorithms."] + import dom::base::{nk_div, nk_img, node_data, node_kind, node}; import dom::rcu; import dom::rcu::reader_methods; import gfx::geom; import gfx::geom::{size, rect, point, au, zero_size_au}; +import /*layout::*/block::block_layout_methods; import /*layout::*/inline::inline_layout_methods; import /*layout::*/style::style::{computed_style, di_block, di_inline}; import /*layout::*/style::style::style_methods; -import util::{tree}; +import util::tree; enum box_kind { bk_block, @@ -58,7 +61,7 @@ impl of tree::wr_tree_ops<@box> for btree { } } -impl block_layout_methods for @box { +impl layout_methods for @box { #[doc="The main reflow routine."] fn reflow(available_width: au) { alt self.kind { @@ -68,33 +71,6 @@ impl block_layout_methods for @box { } } - #[doc="The main reflow routine for block layout."] - fn reflow_block(available_width: au) { - assert self.kind == bk_block; - - // Root here is the root of the reflow, not necessarily the doc as - // a whole. - // - // This routine: - // - generates root.bounds.size - // - generates root.bounds.origin for each child - // - and recursively computes the bounds for each child - - let mut current_height = 0; - for tree::each_child(btree, self) {|c| - let mut blk_available_width = available_width; - // FIXME subtract borders, margins, etc - c.bounds.origin = {mut x: au(0), mut y: au(current_height)}; - c.reflow(blk_available_width); - current_height += *c.bounds.size.height; - } - - self.bounds.size = {mut width: available_width, // FIXME - mut height: au(current_height)}; - - #debug["reflow_block size=%?", self.bounds]; - } - #[doc="The trivial reflow routine for instrinsically-sized frames."] fn reflow_intrinsic(size: geom::size) { self.bounds.size = size; diff --git a/src/servo/layout/block.rs b/src/servo/layout/block.rs new file mode 100644 index 00000000000..8d66a47a464 --- /dev/null +++ b/src/servo/layout/block.rs @@ -0,0 +1,36 @@ +#[doc="Block layout."] + +import gfx::geom::au; +import /*layout::*/base::*; // FIXME: Can't get around import *; resolve bug. +import util::tree; + +#[doc="The public block layout methods."] +impl block_layout_methods for @box { + #[doc="The main reflow routine for block layout."] + fn reflow_block(available_width: au) { + assert self.kind == bk_block; + + // Root here is the root of the reflow, not necessarily the doc as + // a whole. + // + // This routine: + // - generates root.bounds.size + // - generates root.bounds.origin for each child + // - and recursively computes the bounds for each child + + let mut current_height = 0; + for tree::each_child(btree, self) {|c| + let mut blk_available_width = available_width; + // FIXME subtract borders, margins, etc + c.bounds.origin = {mut x: au(0), mut y: au(current_height)}; + c.reflow(blk_available_width); + current_height += *c.bounds.size.height; + } + + self.bounds.size = {mut width: available_width, // FIXME + mut height: au(current_height)}; + + #debug["reflow_block size=%?", self.bounds]; + } +} + diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs index 1fd886644a2..37cd11c0b24 100644 --- a/src/servo/layout/inline.rs +++ b/src/servo/layout/inline.rs @@ -1,4 +1,4 @@ -// Inline layout. +#[doc="Inline layout."] import dom::rcu; import dom::rcu::reader_methods; diff --git a/src/servo/servo.rc b/src/servo/servo.rc index 32e86d18c2e..b5d001ed6c1 100755 --- a/src/servo/servo.rc +++ b/src/servo/servo.rc @@ -35,6 +35,7 @@ mod layout { } mod base; + mod block; mod box_builder; mod display_list; mod inline;