diff options
Diffstat (limited to 'src/components/main/layout/table_cell.rs')
-rw-r--r-- | src/components/main/layout/table_cell.rs | 90 |
1 files changed, 28 insertions, 62 deletions
diff --git a/src/components/main/layout/table_cell.rs b/src/components/main/layout/table_cell.rs index 624f0d8deb4..68fff03caa4 100644 --- a/src/components/main/layout/table_cell.rs +++ b/src/components/main/layout/table_cell.rs @@ -5,16 +5,15 @@ //! CSS table formatting contexts. use layout::box_::Box; -use layout::block::{BlockFlow, WidthAndMarginsComputer}; +use layout::block::{BlockFlow, MarginsMayNotCollapse, WidthAndMarginsComputer}; use layout::context::LayoutContext; -use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData}; +use layout::display_list_builder::{DisplayListBuilder, DisplayListBuildingInfo}; use layout::flow::{TableCellFlowClass, FlowClass, Flow}; +use layout::model::{MaybeAuto}; use layout::table::InternalTable; use layout::wrapper::ThreadSafeLayoutNode; -use std::cell::RefCell; -use geom::{Point2D, Rect, Size2D}; -use gfx::display_list::{DisplayListCollection}; +use gfx::display_list::StackingContext; use servo_util::geometry::Au; /// A table formatting context. @@ -42,62 +41,23 @@ impl TableCellFlow { /// Assign height for table-cell flow. /// + /// TODO(pcwalton): This doesn't handle floats right. + /// /// inline(always) because this is only ever called by in-order or non-in-order top-level /// methods #[inline(always)] - fn assign_height_table_cell_base(&mut self, ctx: &mut LayoutContext, inorder: bool) { - let (_, mut top_offset, bottom_offset, left_offset) = self.block_flow - .initialize_offsets(true); - - self.block_flow.handle_children_floats_if_necessary(ctx, inorder, - left_offset, top_offset); - let mut cur_y = top_offset; - // Since table cell does not have `margin`, the first child's top margin and - // the last child's bottom margin do not collapse. - self.block_flow.compute_margin_collapse(&mut cur_y, - &mut top_offset, - &mut Au(0), - &mut Au(0), - false, - false); - - // CSS 2.1 § 17.5.3. Table cell box height is the minimum height required by the content. - let height = cur_y - top_offset; - - // TODO(june0cho): vertical-align of table-cell should be calculated. - let mut noncontent_height = Au::new(0); - for box_ in self.block_flow.box_.iter() { - let mut position = box_.border_box.get(); - - // noncontent_height = border_top/bottom + padding_top/bottom of box - noncontent_height = box_.noncontent_height(); - - position.origin.y = Au(0); - position.size.height = height + noncontent_height; - - box_.border_box.set(position); - } - - self.block_flow.base.position.size.height = height + noncontent_height; - - self.block_flow.set_floats_out_if_inorder(inorder, height, cur_y, top_offset, - bottom_offset, left_offset); - self.block_flow.assign_height_absolute_flows(ctx); + fn assign_height_table_cell_base(&mut self, + layout_context: &mut LayoutContext, + inorder: bool) { + self.block_flow.assign_height_block_base(layout_context, inorder, MarginsMayNotCollapse) } - pub fn build_display_list_table_cell<E:ExtraDisplayListData>( - &mut self, - builder: &DisplayListBuilder, - container_block_size: &Size2D<Au>, - absolute_cb_abs_position: Point2D<Au>, - dirty: &Rect<Au>, - index: uint, - lists: &RefCell<DisplayListCollection<E>>) - -> uint { - debug!("build_display_list_table_cell: same process as block flow"); - self.block_flow.build_display_list_block(builder, container_block_size, - absolute_cb_abs_position, - dirty, index, lists) + pub fn build_display_list_table_cell(&mut self, + stacking_context: &mut StackingContext, + builder: &mut DisplayListBuilder, + info: &DisplayListBuildingInfo) { + debug!("build_display_list_table: same process as block flow"); + self.block_flow.build_display_list_block(stacking_context, builder, info) } } @@ -117,6 +77,18 @@ impl Flow for TableCellFlow { /// Minimum/preferred widths set by this function are used in automatic table layout calculation. fn bubble_widths(&mut self, ctx: &mut LayoutContext) { self.block_flow.bubble_widths(ctx); + for box_ in self.block_flow.box_.iter() { + let specified_width = MaybeAuto::from_style(box_.style().Box.get().width, + Au::new(0)).specified_or_zero(); + if self.block_flow.base.intrinsic_widths.minimum_width < specified_width { + self.block_flow.base.intrinsic_widths.minimum_width = specified_width; + } + if self.block_flow.base.intrinsic_widths.preferred_width < + self.block_flow.base.intrinsic_widths.minimum_width { + self.block_flow.base.intrinsic_widths.preferred_width = + self.block_flow.base.intrinsic_widths.minimum_width; + } + } } /// Recursively (top-down) determines the actual width of child contexts and boxes. When called @@ -156,12 +128,6 @@ impl Flow for TableCellFlow { self.assign_height_table_cell_base(ctx, false); } - /// TableCellBox and their parents(TableRowBox) do not have margins. - /// Therefore, margins to be collapsed do not exist. - fn collapse_margins(&mut self, _: bool, _: &mut bool, _: &mut Au, - _: &mut Au, _: &mut Au, _: &mut Au) { - } - fn debug_str(&self) -> ~str { let txt = ~"TableCellFlow: "; txt.append(match self.block_flow.box_ { |