diff options
author | Oriol Brufau <obrufau@igalia.com> | 2025-01-20 09:18:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-20 17:18:20 +0000 |
commit | 9b388da9cb9f6a898050464360ae4c8ce90f6693 (patch) | |
tree | 00023a4b0142f3f6ee97480a3c6b7b6c6476401c /components/layout_2020/fragment_tree/fragment_tree.rs | |
parent | b5d1d0369859504963d6f1ad90a25672dcc09400 (diff) | |
download | servo-9b388da9cb9f6a898050464360ae4c8ce90f6693.tar.gz servo-9b388da9cb9f6a898050464360ae4c8ce90f6693.zip |
layout: Fix clientWidth & friends for tables (#35096)
`clientWidth` shouldn't include the borders of a box. The problem was
that we pretend that table wrapper boxes have the border specified on
the table element, even though this border actually applies to the
table grid box instead of the table wrapper box.
Therefore, `clientWidth` was wrong when it subtracted the borders.
This patch fixes it.
Signed-off-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.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs index 545eef2df0f..7bc01f994f0 100644 --- a/components/layout_2020/fragment_tree/fragment_tree.rs +++ b/components/layout_2020/fragment_tree/fragment_tree.rs @@ -14,7 +14,7 @@ use webrender_traits::display_list::ScrollSensitivity; use super::{ContainingBlockManager, Fragment, Tag}; use crate::display_list::StackingContext; use crate::flow::CanvasBackground; -use crate::geom::PhysicalRect; +use crate::geom::{PhysicalPoint, PhysicalRect}; pub struct FragmentTree { /// Fragments at the top-level of the tree. @@ -142,13 +142,17 @@ impl FragmentTree { if fragment.is_inline_box() { return Some(Rect::zero()); } - - let border = fragment.style.get_border(); - let padding_rect = fragment.padding_rect(); - Rect::new( - Point2D::new(border.border_left_width, border.border_top_width), - Size2D::new(padding_rect.size.width, padding_rect.size.height), - ) + if fragment.is_table_wrapper() { + // For tables the border actually belongs to the table grid box, + // so we need to include it in the dimension of the table wrapper box. + let mut rect = fragment.border_rect(); + rect.origin = PhysicalPoint::zero(); + rect + } else { + let mut rect = fragment.padding_rect(); + rect.origin = PhysicalPoint::new(fragment.border.left, fragment.border.top); + rect + } }, Fragment::Positioning(fragment) => fragment.borrow().rect.cast_unit(), _ => return None, |