aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/query.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-09-15 12:57:54 +0200
committerGitHub <noreply@github.com>2023-09-15 10:57:54 +0000
commitabca586e0aa6111d9acd77d4976d52da7671214f (patch)
tree66d53361ec9c06246a5caf1ac5eec9ee35f8027c /components/layout_2020/query.rs
parent0b86d6579823d0786b37cee86eaaf3ce6bd8aa7d (diff)
downloadservo-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/query.rs')
-rw-r--r--components/layout_2020/query.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/components/layout_2020/query.rs b/components/layout_2020/query.rs
index e71b5df20ee..3ea4003cd0a 100644
--- a/components/layout_2020/query.rs
+++ b/components/layout_2020/query.rs
@@ -56,7 +56,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,
@@ -115,9 +115,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,
}
}
@@ -201,14 +201,19 @@ 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,
+ requested_node: Option<OpaqueNode>,
fragment_tree: Option<Arc<FragmentTree>>,
) -> Rect<i32> {
- if let Some(fragment_tree) = fragment_tree {
- fragment_tree.get_scroll_area_for_node(requested_node)
- } else {
- Rect::zero()
- }
+ let rect = match (fragment_tree, requested_node) {
+ (Some(tree), Some(node)) => tree.get_scrolling_area_for_node(node),
+ (Some(tree), None) => tree.get_scrolling_area_for_viewport(),
+ _ => return Rect::zero(),
+ };
+
+ Rect::new(
+ Point2D::new(rect.origin.x.px() as i32, rect.origin.y.px() as i32),
+ Size2D::new(rect.size.width.px() as i32, rect.size.height.px() as i32),
+ )
}
/// Return the resolved value of property for a given (pseudo)element.