diff options
author | Clark Gaebel <cgaebel@mozilla.com> | 2014-08-26 17:02:18 -0700 |
---|---|---|
committer | Clark Gaebel <cgaebel@mozilla.com> | 2014-09-04 14:10:07 -0700 |
commit | dafd0b652d8b5452e485a8430c8e120029fcdbbd (patch) | |
tree | fd7e92578a799b5392210b1cd4cbfad64e320155 /src/components/script/layout_interface.rs | |
parent | ff97135ab974ae3059c1bfe00779b128aad5be34 (diff) | |
download | servo-dafd0b652d8b5452e485a8430c8e120029fcdbbd.tar.gz servo-dafd0b652d8b5452e485a8430c8e120029fcdbbd.zip |
Added a fast no-message RPC interface to the layout task.
Diffstat (limited to 'src/components/script/layout_interface.rs')
-rw-r--r-- | src/components/script/layout_interface.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/components/script/layout_interface.rs b/src/components/script/layout_interface.rs index f36c3e83167..1e5e23f9c9a 100644 --- a/src/components/script/layout_interface.rs +++ b/src/components/script/layout_interface.rs @@ -25,8 +25,6 @@ use url::Url; use serialize::{Encodable, Encoder}; /// Asynchronous messages that script can send to layout. -/// -/// FIXME(pcwalton): I think this should probably be merged with `LayoutQuery` below. pub enum Msg { /// Adds the given stylesheet to the document. AddStylesheetMsg(Stylesheet), @@ -34,10 +32,8 @@ pub enum Msg { /// Requests a reflow. ReflowMsg(Box<Reflow>), - /// Performs a synchronous layout request. - /// - /// FIXME(pcwalton): As noted below, this isn't very type safe. - QueryMsg(LayoutQuery), + /// Get an RPC interface. + GetRPCMsg(Sender<Box<LayoutRPC + Send>>), /// Destroys layout data associated with a DOM node. /// @@ -55,14 +51,21 @@ pub enum Msg { } /// Synchronous messages that script can send to layout. -pub enum LayoutQuery { +/// +/// 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 LayoutTaskData, +/// 2) small, +// 3) and really needs to be fast. +pub trait LayoutRPC { /// Requests the dimensions of the content box, as in the `getBoundingClientRect()` call. - ContentBoxQuery(TrustedNodeAddress, Sender<ContentBoxResponse>), + fn content_box(&self, node: TrustedNodeAddress) -> ContentBoxResponse; /// Requests the dimensions of all the content boxes, as in the `getClientRects()` call. - ContentBoxesQuery(TrustedNodeAddress, Sender<ContentBoxesResponse>), + fn content_boxes(&self, node: TrustedNodeAddress) -> ContentBoxesResponse; /// Requests the node containing the point of interest - HitTestQuery(TrustedNodeAddress, Point2D<f32>, Sender<Result<HitTestResponse, ()>>), - MouseOverQuery(TrustedNodeAddress, Point2D<f32>, Sender<Result<MouseOverResponse, ()>>), + fn hit_test(&self, node: TrustedNodeAddress, point: Point2D<f32>) -> Result<HitTestResponse, ()>; + fn mouse_over(&self, node: TrustedNodeAddress, point: Point2D<f32>) -> Result<MouseOverResponse, ()>; } /// The address of a node known to be valid. These must only be sent from content -> layout, |