diff options
Diffstat (limited to 'components/layout/table')
-rw-r--r-- | components/layout/table/construct.rs | 27 | ||||
-rw-r--r-- | components/layout/table/layout.rs | 47 |
2 files changed, 21 insertions, 53 deletions
diff --git a/components/layout/table/construct.rs b/components/layout/table/construct.rs index f20360d3b56..56e11320be4 100644 --- a/components/layout/table/construct.rs +++ b/components/layout/table/construct.rs @@ -1019,15 +1019,16 @@ where DisplayLayoutInternal::TableCell => { // This value will already have filtered out rowspan=0 // in quirks mode, so we don't have to worry about that. - // - // The HTML specification limits the parsed value of `rowspan` to - // 65534 and `colspan` to 1000, so we also enforce the same limits - // when dealing with arbitrary DOM elements (perhaps created via - // script). let (rowspan, colspan) = if info.pseudo_element_type.is_none() { let node = info.node.to_threadsafe(); - let rowspan = node.get_rowspan().unwrap_or(1).min(65534) as usize; - let colspan = node.get_colspan().unwrap_or(1).min(1000) as usize; + let rowspan = node.get_rowspan().unwrap_or(1) as usize; + let colspan = node.get_colspan().unwrap_or(1) as usize; + + // The HTML specification clamps value of `rowspan` to [0, 65534] and + // `colspan` to [1, 1000]. + assert!((1..=1000).contains(&colspan)); + assert!((0..=65534).contains(&rowspan)); + (rowspan, colspan) } else { (1, 1) @@ -1140,21 +1141,19 @@ fn add_column<'dom, Node: NodeExt<'dom>>( is_anonymous: bool, ) -> ArcRefCell<TableTrack> { let span = if column_info.pseudo_element_type.is_none() { - column_info - .node - .to_threadsafe() - .get_span() - .unwrap_or(1) - .min(1000) as usize + column_info.node.to_threadsafe().get_span().unwrap_or(1) } else { 1 }; + // The HTML specification clamps value of `span` for `<col>` to [1, 1000]. + assert!((1..=1000).contains(&span)); + let column = ArcRefCell::new(TableTrack { base: LayoutBoxBase::new(column_info.into(), column_info.style.clone()), group_index, is_anonymous, }); - collection.extend(repeat(column.clone()).take(span)); + collection.extend(repeat(column.clone()).take(span as usize)); column } diff --git a/components/layout/table/layout.rs b/components/layout/table/layout.rs index 0cbe3e9ca76..2efe339837e 100644 --- a/components/layout/table/layout.rs +++ b/components/layout/table/layout.rs @@ -1068,7 +1068,6 @@ impl<'a> TableLayout<'a> { &mut self, layout_context: &LayoutContext, containing_block_for_table: &ContainingBlock, - parent_positioning_context: &mut PositioningContext, ) { self.cells_laid_out = self .table @@ -1076,30 +1075,6 @@ impl<'a> TableLayout<'a> { .par_iter() .enumerate() .map(|(row_index, row_slots)| { - // When building the PositioningContext for this cell, we want it to have the same - // configuration for whatever PositioningContext the contents are ultimately added to. - let collect_for_nearest_positioned_ancestor = parent_positioning_context - .collects_for_nearest_positioned_ancestor() || - self.table.rows.get(row_index).is_some_and(|row| { - let row = row.borrow(); - let row_group_collects_for_nearest_positioned_ancestor = - row.group_index.is_some_and(|group_index| { - self.table.row_groups[group_index] - .borrow() - .base - .style - .establishes_containing_block_for_absolute_descendants( - FragmentFlags::empty(), - ) - }); - row_group_collects_for_nearest_positioned_ancestor || - row.base - .style - .establishes_containing_block_for_absolute_descendants( - FragmentFlags::empty(), - ) - }); - row_slots .par_iter() .enumerate() @@ -1141,10 +1116,7 @@ impl<'a> TableLayout<'a> { style: &cell.base.style, }; - let mut positioning_context = PositioningContext::new_for_subtree( - collect_for_nearest_positioned_ancestor, - ); - + let mut positioning_context = PositioningContext::default(); let layout = cell.contents.layout( layout_context, &mut positioning_context, @@ -1503,7 +1475,6 @@ impl<'a> TableLayout<'a> { layout_context: &LayoutContext, parent_positioning_context: &mut PositioningContext, ) -> BoxFragment { - let mut positioning_context = caption.context.new_positioning_context(); let containing_block = &ContainingBlock { size: ContainingBlockSize { inline: self.table_width + self.pbm.padding_border_sums.inline, @@ -1517,6 +1488,8 @@ impl<'a> TableLayout<'a> { // stretch block size. https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing let ignore_block_margins_for_stretch = LogicalSides1D::new(false, false); + let mut positioning_context = + PositioningContext::new_for_layout_box_base(&caption.context.base); let mut box_fragment = caption.context.layout_in_flow_block_level( layout_context, positioning_context @@ -1769,11 +1742,7 @@ impl<'a> TableLayout<'a> { ) -> BoxFragment { self.distributed_column_widths = Self::distribute_width_to_columns(self.assignable_width, &self.columns); - self.layout_cells_in_row( - layout_context, - containing_block_for_children, - positioning_context, - ); + self.layout_cells_in_row(layout_context, containing_block_for_children); let table_writing_mode = containing_block_for_children.style.writing_mode; let first_layout_row_heights = self.do_first_row_layout(table_writing_mode); self.compute_table_height_and_final_row_heights( @@ -2325,7 +2294,7 @@ impl<'a> RowFragmentLayout<'a> { Self { row: table_row, rect, - positioning_context: table_row.base.new_positioning_context(), + positioning_context: PositioningContext::new_for_layout_box_base(&table_row.base), containing_block, fragments: Vec::new(), } @@ -2379,11 +2348,11 @@ impl<'a> RowFragmentLayout<'a> { if let Some(mut row_positioning_context) = self.positioning_context.take() { row_positioning_context.layout_collected_children(layout_context, &mut row_fragment); - let positioning_context = row_group_fragment_layout + let parent_positioning_context = row_group_fragment_layout .as_mut() .and_then(|layout| layout.positioning_context.as_mut()) .unwrap_or(table_positioning_context); - positioning_context.append(row_positioning_context); + parent_positioning_context.append(row_positioning_context); } let fragment = Fragment::Box(ArcRefCell::new(row_fragment)); @@ -2410,7 +2379,7 @@ impl RowGroupFragmentLayout { let row_group = row_group.borrow(); ( dimensions.get_row_group_rect(&row_group), - row_group.base.new_positioning_context(), + PositioningContext::new_for_layout_box_base(&row_group.base), ) }; Self { |