aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-09-19 14:43:29 +0200
committerGitHub <noreply@github.com>2024-09-19 12:43:29 +0000
commitef229b93863b7b1f1f718c4f1fbb755d0136e40d (patch)
tree12bc9f2f3abfea47999f21f467d8c06010e5ddd5 /components
parenteecf5bdea16581f201d674a9079a888858ec84bc (diff)
downloadservo-ef229b93863b7b1f1f718c4f1fbb755d0136e40d.tar.gz
servo-ef229b93863b7b1f1f718c4f1fbb755d0136e40d.zip
layout: Ensure that `<caption>`'s support `position: relative` (#33426)
This change adds support for `position: relative` to table `<caption>`. In addition to adjusting their position according to inset values, table captions must also establish containing blocks for descendants that are absolutely positioned. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components')
-rw-r--r--components/layout_2020/table/layout.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs
index 054d291c593..5b622cbb7b9 100644
--- a/components/layout_2020/table/layout.rs
+++ b/components/layout_2020/table/layout.rs
@@ -13,6 +13,7 @@ use style::computed_values::border_collapse::T as BorderCollapse;
use style::computed_values::box_sizing::T as BoxSizing;
use style::computed_values::caption_side::T as CaptionSide;
use style::computed_values::empty_cells::T as EmptyCells;
+use style::computed_values::position::T as Position;
use style::computed_values::table_layout::T as TableLayoutMode;
use style::computed_values::visibility::T as Visibility;
use style::logical_geometry::WritingMode;
@@ -1642,7 +1643,7 @@ impl<'a> TableLayout<'a> {
style: containing_block.style,
};
- let box_fragment = context.layout_in_flow_block_level(
+ let mut box_fragment = context.layout_in_flow_block_level(
layout_context,
positioning_context
.as_mut()
@@ -1651,7 +1652,8 @@ impl<'a> TableLayout<'a> {
None, /* sequential_layout_state */
);
- if let Some(positioning_context) = positioning_context.take() {
+ if let Some(mut positioning_context) = positioning_context.take() {
+ positioning_context.layout_collected_children(layout_context, &mut box_fragment);
parent_positioning_context.append(positioning_context);
}
@@ -1735,11 +1737,19 @@ impl<'a> TableLayout<'a> {
let caption_pbm = caption_fragment
.padding_border_margin()
.to_logical(table_writing_mode);
+
+ let caption_relative_offset = match caption_fragment.style.clone_position() {
+ Position::Relative => {
+ relative_adjustement(&caption_fragment.style, containing_block_for_children)
+ },
+ _ => LogicalVec2::zero(),
+ };
+
caption_fragment.content_rect = LogicalRect {
start_corner: LogicalVec2 {
inline: offset_from_wrapper.inline_start + caption_pbm.inline_start,
block: current_block_offset + caption_pbm.block_start,
- },
+ } + caption_relative_offset,
size: caption_fragment
.content_rect
.size