aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/script_layout/rpc.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-03-29 17:25:47 +0100
committerGitHub <noreply@github.com>2024-03-29 16:25:47 +0000
commitb7d089930ea075a580a20bede881c677a0ba0fb0 (patch)
treec85d7bf011d80d5f3c47a2a5b5df2948134ec1b8 /components/shared/script_layout/rpc.rs
parent07391e346b0ff3e89485ddc7e8f3c448ef1de4f4 (diff)
downloadservo-b7d089930ea075a580a20bede881c677a0ba0fb0.tar.gz
servo-b7d089930ea075a580a20bede881c677a0ba0fb0.zip
layout: Remove LayoutRPC and query layout via the `Layout` trait (#31937)
Instead of the tricky `LayoutRPC` interface, query layout using the `Layout` trait. This means that now queries will requires calling layout and then running the query. During layout an enum is used to indicate what kind of layout is necessary. This change also removes the mutex-locked `rw_data` from both layout threads. It's no longer necessary since layout runs synchronously. The one downside here is that for resolved style queries, we now have to create two StyleContexts. One for layout and one for the query itself. The creation of this context should not be very expensive though. `LayoutRPC` used to be necessary because layout used to run asynchronously from script, but that no longer happens. With this change, it becomes possible to safely pass nodes to layout from script -- a cleanup that can happen in a followup change.
Diffstat (limited to 'components/shared/script_layout/rpc.rs')
-rw-r--r--components/shared/script_layout/rpc.rs75
1 files changed, 0 insertions, 75 deletions
diff --git a/components/shared/script_layout/rpc.rs b/components/shared/script_layout/rpc.rs
deleted file mode 100644
index 3778d8f975a..00000000000
--- a/components/shared/script_layout/rpc.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-
-use app_units::Au;
-use euclid::default::Rect;
-use euclid::Size2D;
-use script_traits::UntrustedNodeAddress;
-use servo_arc::Arc;
-use style::properties::style_structs::Font;
-use style_traits::CSSPixel;
-use webrender_api::ExternalScrollId;
-
-/// Synchronous messages that script can send to layout.
-///
-/// In general, you should use messages to talk to Layout. Use the RPC interface
-/// if and only if the work is
-///
-/// 1) read-only with respect to LayoutThreadData,
-/// 2) small,
-/// 3) and really needs to be fast.
-pub trait LayoutRPC {
- /// Requests the dimensions of the content box, as in the `getBoundingClientRect()` call.
- fn content_box(&self) -> ContentBoxResponse;
- /// Requests the dimensions of all the content boxes, as in the `getClientRects()` call.
- fn content_boxes(&self) -> ContentBoxesResponse;
- /// Requests the geometry of this node. Used by APIs such as `clientTop`.
- fn node_geometry(&self) -> NodeGeometryResponse;
- /// Requests the scroll geometry of this node. Used by APIs such as `scrollTop`.
- fn scrolling_area(&self) -> NodeGeometryResponse;
- /// Requests the scroll id of this node. Used by APIs such as `scrollTop`
- fn node_scroll_id(&self) -> NodeScrollIdResponse;
- /// Query layout for the resolved value of a given CSS property
- fn resolved_style(&self) -> ResolvedStyleResponse;
- /// Query layout to get the resolved font style for canvas.
- fn resolved_font_style(&self) -> Option<Arc<Font>>;
- fn offset_parent(&self) -> OffsetParentResponse;
- fn text_index(&self) -> TextIndexResponse;
- /// Requests the list of nodes from the given point.
- fn nodes_from_point_response(&self) -> Vec<UntrustedNodeAddress>;
- /// Query layout to get the inner text for a given element.
- fn element_inner_text(&self) -> String;
- /// Get the dimensions of an iframe's inner window.
- fn inner_window_dimensions(&self) -> Option<Size2D<f32, CSSPixel>>;
-}
-
-pub struct ContentBoxResponse(pub Option<Rect<Au>>);
-
-pub struct ContentBoxesResponse(pub Vec<Rect<Au>>);
-
-pub struct NodeGeometryResponse {
- pub client_rect: Rect<i32>,
-}
-
-pub struct NodeScrollIdResponse(pub ExternalScrollId);
-
-pub struct ResolvedStyleResponse(pub String);
-
-#[derive(Clone)]
-pub struct OffsetParentResponse {
- pub node_address: Option<UntrustedNodeAddress>,
- pub rect: Rect<Au>,
-}
-
-impl OffsetParentResponse {
- pub fn empty() -> OffsetParentResponse {
- OffsetParentResponse {
- node_address: None,
- rect: Rect::zero(),
- }
- }
-}
-
-#[derive(Clone)]
-pub struct TextIndexResponse(pub Option<usize>);