aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/fragment_tree/fragment_tree.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-02-20 14:22:02 +0100
committerGitHub <noreply@github.com>2024-02-20 13:22:02 +0000
commit02ae1f448ef3cae3cd0a58dbd145a741b8561f5b (patch)
tree62ba458722ba45720958aff9763e34bf2a732f7b /components/layout_2020/fragment_tree/fragment_tree.rs
parent74c07db56c281787009c8f1c1bd311f4fd3f6d19 (diff)
downloadservo-02ae1f448ef3cae3cd0a58dbd145a741b8561f5b.tar.gz
servo-02ae1f448ef3cae3cd0a58dbd145a741b8561f5b.zip
layout: Add support for table rows, columns, rowgroups and colgroups (#31341)
This adds support for table rows, columns, rowgroups and colgroups. There are few additions here: 1. The createion of fragments, which allows script queries and hit testing to work properly. These fragments are empty as all cells are still direct descendants of the table fragment. 2. Properly handling size information from tracks and track groups as well as frustrating rules about reordering rowgroups. 3. Painting a background seemlessly across track groups and groups. This is a thing that isn't done in legacy layout (nor WebKit)! Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020/fragment_tree/fragment_tree.rs')
-rw-r--r--components/layout_2020/fragment_tree/fragment_tree.rs66
1 files changed, 36 insertions, 30 deletions
diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs
index 5e50a54768c..4bce1e9b125 100644
--- a/components/layout_2020/fragment_tree/fragment_tree.rs
+++ b/components/layout_2020/fragment_tree/fragment_tree.rs
@@ -106,13 +106,15 @@ impl FragmentTree {
Fragment::Box(fragment) | Fragment::Float(fragment) => fragment
.border_rect()
.to_physical(fragment.style.writing_mode, containing_block),
+ Fragment::Positioning(fragment) => fragment
+ .rect
+ .to_physical(fragment.writing_mode, containing_block),
Fragment::Text(fragment) => fragment
.rect
.to_physical(fragment.parent_style.writing_mode, containing_block),
Fragment::AbsoluteOrFixedPositioned(_) |
Fragment::Image(_) |
- Fragment::IFrame(_) |
- Fragment::Anonymous(_) => return None,
+ Fragment::IFrame(_) => return None,
};
found_any_nodes = true;
@@ -145,37 +147,41 @@ impl FragmentTree {
return None;
}
- let (style, padding_rect) = match fragment {
- Fragment::Box(fragment) => (&fragment.style, fragment.padding_rect()),
+ let rect = match fragment {
+ Fragment::Box(fragment) => {
+ // https://drafts.csswg.org/cssom-view/#dom-element-clienttop
+ // " If the element has no associated CSS layout box or if the
+ // CSS layout box is inline, return zero." For this check we
+ // also explicitly ignore the list item portion of the display
+ // style.
+ if fragment.style.get_box().display.is_inline_flow() {
+ return Some(Rect::zero());
+ }
+
+ let border = fragment.style.get_border();
+ let padding_rect = fragment
+ .padding_rect()
+ .to_physical(fragment.style.writing_mode, containing_block);
+ Rect::new(
+ Point2D::new(
+ border.border_left_width.into(),
+ border.border_top_width.into(),
+ ),
+ Size2D::new(padding_rect.size.width, padding_rect.size.height),
+ )
+ },
+ Fragment::Positioning(fragment) => fragment
+ .rect
+ .to_physical(fragment.writing_mode, containing_block)
+ .cast_unit(),
_ => return None,
};
- // https://drafts.csswg.org/cssom-view/#dom-element-clienttop
- // " If the element has no associated CSS layout box or if the
- // CSS layout box is inline, return zero." For this check we
- // also explicitly ignore the list item portion of the display
- // style.
- let display = &style.get_box().display;
- if display.inside() == style::values::specified::box_::DisplayInside::Flow &&
- display.outside() == style::values::specified::box_::DisplayOutside::Inline
- {
- return Some(Rect::zero());
- }
-
- let border = style.get_border();
- let padding_rect = padding_rect.to_physical(style.writing_mode, containing_block);
- Some(
- Rect::new(
- Point2D::new(
- border.border_left_width.to_f32_px(),
- border.border_top_width.to_f32_px(),
- ),
- Size2D::new(padding_rect.size.width.px(), padding_rect.size.height.px()),
- )
- .round()
- .to_i32()
- .to_untyped(),
- )
+ let rect = Rect::new(
+ Point2D::new(rect.origin.x.px(), rect.origin.y.px()),
+ Size2D::new(rect.size.width.px(), rect.size.height.px()),
+ );
+ Some(rect.round().to_i32().to_untyped())
})
.unwrap_or_else(Rect::zero)
}