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/query.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/query.rs')
-rw-r--r-- | components/layout/query.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/components/layout/query.rs b/components/layout/query.rs index a4eba68b947..61dd1c2ba33 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -76,7 +76,7 @@ pub struct LayoutThreadData { pub scroll_id_response: Option<ExternalScrollId>, /// A queued response for the scroll {top, left, width, height} of a node in pixels. - pub scroll_area_response: Rect<i32>, + pub scrolling_area_response: Rect<i32>, /// A queued response for the resolved style property of an element. pub resolved_style_response: String, @@ -158,9 +158,9 @@ impl LayoutRPC for LayoutRPCImpl { } } - fn node_scroll_area(&self) -> NodeGeometryResponse { + fn scrolling_area(&self) -> NodeGeometryResponse { NodeGeometryResponse { - client_rect: self.0.lock().unwrap().scroll_area_response, + client_rect: self.0.lock().unwrap().scrolling_area_response, } } @@ -730,10 +730,21 @@ pub fn process_node_scroll_id_request<'dom>( } /// https://drafts.csswg.org/cssom-view/#scrolling-area -pub fn process_node_scroll_area_request( - requested_node: OpaqueNode, +pub fn process_scrolling_area_request( + requested_node: Option<OpaqueNode>, layout_root: &mut dyn Flow, ) -> Rect<i32> { + let requested_node = match requested_node { + Some(node) => node, + None => { + let rect = layout_root.base().overflow.scroll; + return Rect::new( + Point2D::new(rect.origin.x.to_nearest_px(), rect.origin.y.to_nearest_px()), + Size2D::new(rect.width().ceil_to_px(), rect.height().ceil_to_px()), + ); + }, + }; + let mut iterator = UnioningFragmentScrollAreaIterator::new(requested_node); sequential::iterate_through_flow_tree_fragment_border_boxes(layout_root, &mut iterator); match iterator.overflow_direction { |