diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-09-15 12:57:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-15 10:57:54 +0000 |
commit | abca586e0aa6111d9acd77d4976d52da7671214f (patch) | |
tree | 66d53361ec9c06246a5caf1ac5eec9ee35f8027c /components/layout_2020/fragment_tree/fragment_tree.rs | |
parent | 0b86d6579823d0786b37cee86eaaf3ce6bd8aa7d (diff) | |
download | servo-abca586e0aa6111d9acd77d4976d52da7671214f.tar.gz servo-abca586e0aa6111d9acd77d4976d52da7671214f.zip |
Refactor scrolls on the window object (#29680)
Refactor the scrolling and scrollable area calculation on the window
object, to make it better match the specification. This has some mild
changes to behavior, but in general things work the same as they did
before. This is mainly preparation for properly handling viewport
propagation of the `overflow` property but seems to fix a few issues as
well.
There is one new failure in Layout 2020 regarding `position: sticky`,
but this isn't a big deal because there is no support for `position:
sticky` in Layout 2020 yet.
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
Diffstat (limited to 'components/layout_2020/fragment_tree/fragment_tree.rs')
-rw-r--r-- | components/layout_2020/fragment_tree/fragment_tree.rs | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs index 023344a1b6c..f797f5644c6 100644 --- a/components/layout_2020/fragment_tree/fragment_tree.rs +++ b/components/layout_2020/fragment_tree/fragment_tree.rs @@ -172,36 +172,26 @@ impl FragmentTree { .unwrap_or_else(Rect::zero) } - pub fn get_scroll_area_for_node(&self, requested_node: OpaqueNode) -> Rect<i32> { - let mut scroll_area: PhysicalRect<Length> = PhysicalRect::zero(); + pub fn get_scrolling_area_for_viewport(&self) -> PhysicalRect<Length> { + let mut scroll_area = self.initial_containing_block; + for fragment in self.root_fragments.iter() { + scroll_area = fragment + .borrow() + .scrolling_area(&self.initial_containing_block) + .union(&scroll_area); + } + scroll_area + } + + pub fn get_scrolling_area_for_node(&self, requested_node: OpaqueNode) -> PhysicalRect<Length> { let tag_to_find = Tag::new(requested_node); - self.find(|fragment, _, containing_block| { - if fragment.tag() != Some(tag_to_find) { - return None::<()>; + let scroll_area = self.find(|fragment, _, containing_block| { + if fragment.tag() == Some(tag_to_find) { + Some(fragment.scrolling_area(&containing_block)) + } else { + None } - - scroll_area = match fragment { - Fragment::Box(fragment) | Fragment::Float(fragment) => fragment - .scrollable_overflow(&containing_block) - .translate(containing_block.origin.to_vector()), - Fragment::Text(_) | - Fragment::AbsoluteOrFixedPositioned(_) | - Fragment::Image(_) | - Fragment::IFrame(_) | - Fragment::Anonymous(_) => return None, - }; - None::<()> }); - - Rect::new( - Point2D::new( - scroll_area.origin.x.px() as i32, - scroll_area.origin.y.px() as i32, - ), - Size2D::new( - scroll_area.size.width.px() as i32, - scroll_area.size.height.px() as i32, - ), - ) + scroll_area.unwrap_or_else(PhysicalRect::<Length>::zero) } } |