diff options
author | Jon Leighton <j@jonathanleighton.com> | 2018-01-27 21:30:24 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2018-01-28 10:59:45 +0100 |
commit | fe583fc5d0aa667b40ecddfb1cbff3c5f65649d7 (patch) | |
tree | 580d3aa22053fd2ddd99d0151f6515ad318e3c39 /components/script_layout_interface/rpc.rs | |
parent | c9ba16f9fbdf7f43cb19feedfaaa68c85bbcbe3b (diff) | |
download | servo-fe583fc5d0aa667b40ecddfb1cbff3c5f65649d7.tar.gz servo-fe583fc5d0aa667b40ecddfb1cbff3c5f65649d7.zip |
Add layout RPC query for getting an element's style
This enables us to implement Element::has_css_layout_box() in a more
direct way, and also enables us to remove some of the existing more
specific queries.
Fixes #19811.
Diffstat (limited to 'components/script_layout_interface/rpc.rs')
-rw-r--r-- | components/script_layout_interface/rpc.rs | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/components/script_layout_interface/rpc.rs b/components/script_layout_interface/rpc.rs index 5702c8cce9d..3988711eeaa 100644 --- a/components/script_layout_interface/rpc.rs +++ b/components/script_layout_interface/rpc.rs @@ -5,7 +5,9 @@ use app_units::Au; use euclid::{Point2D, Rect}; use script_traits::UntrustedNodeAddress; -use style::properties::longhands::{margin_top, margin_right, margin_bottom, margin_left, overflow_x}; +use servo_arc::Arc; +use style::properties::ComputedValues; +use style::properties::longhands::overflow_x; use webrender_api::ClipId; /// Synchronous messages that script can send to layout. @@ -23,8 +25,6 @@ pub trait LayoutRPC { 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 scroll root id of this node. Used by APIs such as `scrollTop` @@ -32,8 +32,9 @@ pub trait LayoutRPC { /// 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; + /// Requests the styles for an element. Contains a `None` value if the element is in a `display: + /// none` subtree. + fn style(&self) -> StyleResponse; fn text_index(&self) -> TextIndexResponse; /// Requests the list of nodes from the given point. fn nodes_from_point_response(&self) -> Vec<UntrustedNodeAddress>; @@ -70,23 +71,7 @@ impl OffsetParentResponse { } #[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 StyleResponse(pub Option<Arc<ComputedValues>>); #[derive(Clone)] pub struct TextIndexResponse(pub Option<usize>); |