diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-08-14 14:22:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-14 12:22:06 +0000 |
commit | d941d2fd67e7c2cd9859ae743c76b0238679bfe4 (patch) | |
tree | 8df14b9d617a4354ac1c82452ad9eaa0f5f89f44 /components/layout_2020/fragment_tree/fragment_tree.rs | |
parent | 65f90ff1fd82758aa7644ada7bb75d34291c363f (diff) | |
download | servo-d941d2fd67e7c2cd9859ae743c76b0238679bfe4.tar.gz servo-d941d2fd67e7c2cd9859ae743c76b0238679bfe4.zip |
layout: Convert the FragmentTree to physical geometry (#33030)
This converts all geometry in the FragmentTree into physical geometry,
doing conversions ahead of time instead of when traversing the fragment
tree. This is necessary to properly implement BiDi in Servo as we need
to know what side borders are on in mixed RTL and LTR contexts.
In addition, fragments are laid out in a particular context and only
that context knows its writing mode. There were issues where were using
one writing mode to lay out and another to convert to phyisical
coordinates. This isn't an issue now since we only use the default
writing mode, but starts to be an issue with BiDi text.
Closes #25564.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/layout_2020/fragment_tree/fragment_tree.rs')
-rw-r--r-- | components/layout_2020/fragment_tree/fragment_tree.rs | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs index 107bd3e36da..5394f08cc33 100644 --- a/components/layout_2020/fragment_tree/fragment_tree.rs +++ b/components/layout_2020/fragment_tree/fragment_tree.rs @@ -110,15 +110,9 @@ impl FragmentTree { } let fragment_relative_rect = match fragment { - 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::Box(fragment) | Fragment::Float(fragment) => fragment.border_rect(), + Fragment::Positioning(fragment) => fragment.rect, + Fragment::Text(fragment) => fragment.rect, Fragment::AbsoluteOrFixedPositioned(_) | Fragment::Image(_) | Fragment::IFrame(_) => return None, @@ -134,7 +128,7 @@ impl FragmentTree { pub fn get_border_dimensions_for_node(&self, requested_node: OpaqueNode) -> Rect<i32> { let tag_to_find = Tag::new(requested_node); - self.find(|fragment, _, containing_block| { + self.find(|fragment, _, _containing_block| { if fragment.tag() != Some(tag_to_find) { return None; } @@ -151,18 +145,13 @@ impl FragmentTree { } let border = fragment.style.get_border(); - let padding_rect = fragment - .padding_rect() - .to_physical(fragment.style.writing_mode, containing_block); + 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), ) }, - Fragment::Positioning(fragment) => fragment - .rect - .to_physical(fragment.writing_mode, containing_block) - .cast_unit(), + Fragment::Positioning(fragment) => fragment.rect.cast_unit(), _ => return None, }; |