diff options
author | Ms2ger <Ms2ger@gmail.com> | 2016-06-16 02:07:57 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-06-20 19:08:07 +0200 |
commit | 86bfd2cc9f14b95c3b6376c6b723ddf77af3fc35 (patch) | |
tree | 13078c74486575fb7e86e0bb577f1673cefc5f5c /components/script | |
parent | 68d603a6d0a059965d2fa604d153b531cb16d404 (diff) | |
download | servo-86bfd2cc9f14b95c3b6376c6b723ddf77af3fc35.tar.gz servo-86bfd2cc9f14b95c3b6376c6b723ddf77af3fc35.zip |
Move LayoutRPC to script_layout_interface.
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/bindings/trace.rs | 2 | ||||
-rw-r--r-- | components/script/dom/window.rs | 5 | ||||
-rw-r--r-- | components/script/layout_interface.rs | 88 |
3 files changed, 7 insertions, 88 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 070a3e1b954..4abfc8fd58d 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -55,7 +55,6 @@ use js::glue::{CallObjectTracer, CallUnbarrieredObjectTracer, CallValueTracer}; use js::jsapi::{GCTraceKindToAscii, Heap, TraceKind, JSObject, JSTracer}; use js::jsval::JSVal; use js::rust::Runtime; -use layout_interface::LayoutRPC; use libc; use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy}; use net_traits::filemanager_thread::SelectedFileId; @@ -68,6 +67,7 @@ use offscreen_gl_context::GLLimits; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan as TimeProfilerChan; use script_layout_interface::OpaqueStyleAndLayoutData; +use script_layout_interface::rpc::LayoutRPC; use script_runtime::ScriptChan; use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase, UntrustedNodeAddress}; use serde::{Deserialize, Serialize}; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index f2f3195c875..6dc43f8b925 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -42,8 +42,7 @@ use js::jsapi::{Evaluate2, HandleObject, HandleValue, JSAutoCompartment, JSConte use js::jsapi::{JS_GetRuntime, JS_GC, MutableHandleValue, SetWindowProxy}; use js::rust::CompileOptionsWrapper; use js::rust::Runtime; -use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow}; -use layout_interface::{LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse}; +use layout_interface::{Msg, Reflow, ReflowQueryType, ScriptReflow}; use libc; use msg::constellation_msg::{FrameType, LoadData, PanicMsg, PipelineId, SubpageId}; use msg::constellation_msg::{WindowSizeData, WindowSizeType}; @@ -60,6 +59,8 @@ use profile_traits::time::{ProfilerChan, TimerMetadataReflowType, profile}; use reporter::CSSErrorReporter; use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64}; use script_layout_interface::TrustedNodeAddress; +use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC}; +use script_layout_interface::rpc::{MarginStyleResponse, ResolvedStyleResponse}; use script_runtime::{ScriptChan, ScriptPort}; use script_thread::SendableMainThreadScriptChan; use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper}; diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index cb645ef6439..3c5516e4b8d 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -14,14 +14,14 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::{PanicMsg, PipelineId, WindowSizeData}; use net_traits::image_cache_thread::ImageCacheThread; use profile_traits::mem::ReportsChan; +use script_layout_interface::rpc::LayoutRPC; use script_layout_interface::{OpaqueStyleAndLayoutData, TrustedNodeAddress}; -use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; -use script_traits::{StackingContextScrollState, UntrustedNodeAddress}; +use script_traits::{ConstellationControlMsg, LayoutControlMsg}; +use script_traits::{LayoutMsg as ConstellationMsg, StackingContextScrollState}; use std::sync::Arc; use std::sync::mpsc::{Receiver, Sender}; use string_cache::Atom; use style::context::ReflowGoal; -use style::properties::longhands::{margin_top, margin_right, margin_bottom, margin_left, overflow_x}; use style::selector_impl::PseudoElement; use style::servo::Stylesheet; use url::Url; @@ -101,88 +101,6 @@ pub enum Msg { SetStackingContextScrollStates(Vec<StackingContextScrollState>), } -/// 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 overflow-x and overflow-y of this node. Used by `scrollTop` etc. - fn node_overflow(&self) -> NodeOverflowResponse; - /// Requests the scroll geometry of this node. Used by APIs such as `scrollTop`. - fn node_scroll_area(&self) -> NodeGeometryResponse; - /// Requests the layer id of this node. Used by APIs such as `scrollTop` - fn node_layer_id(&self) -> NodeLayerIdResponse; - /// Requests the node containing the point of interest - fn hit_test(&self) -> HitTestResponse; - /// Query layout for the resolved value of a given CSS property - fn resolved_style(&self) -> ResolvedStyleResponse; - fn offset_parent(&self) -> OffsetParentResponse; - /// Query layout for the resolve values of the margin properties for an element. - fn margin_style(&self) -> MarginStyleResponse; - - fn nodes_from_point(&self, point: Point2D<f32>) -> Vec<UntrustedNodeAddress>; -} - -#[derive(Clone)] -pub struct MarginStyleResponse { - pub top: margin_top::computed_value::T, - pub right: margin_right::computed_value::T, - pub bottom: margin_bottom::computed_value::T, - pub left: margin_left::computed_value::T, -} - -impl MarginStyleResponse { - pub fn empty() -> MarginStyleResponse { - MarginStyleResponse { - top: margin_top::computed_value::T::Auto, - right: margin_right::computed_value::T::Auto, - bottom: margin_bottom::computed_value::T::Auto, - left: margin_left::computed_value::T::Auto, - } - } -} - -pub struct NodeOverflowResponse(pub Option<Point2D<overflow_x::computed_value::T>>); - -pub struct ContentBoxResponse(pub Rect<Au>); -pub struct ContentBoxesResponse(pub Vec<Rect<Au>>); -pub struct HitTestResponse { - pub node_address: Option<UntrustedNodeAddress>, -} -pub struct NodeGeometryResponse { - pub client_rect: Rect<i32>, -} - -pub struct NodeLayerIdResponse { - pub layer_id: LayerId, -} - -pub struct ResolvedStyleResponse(pub Option<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(), - } - } -} /// Any query to perform with this reflow. #[derive(PartialEq)] |