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 | |
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')
-rw-r--r-- | components/script_layout_interface/message.rs | 11 | ||||
-rw-r--r-- | components/script_layout_interface/rpc.rs | 29 |
2 files changed, 12 insertions, 28 deletions
diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 7a1cb7e5316..6f2ab91420d 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -113,13 +113,12 @@ pub enum ReflowGoal { TickAnimations, ContentBoxQuery(TrustedNodeAddress), ContentBoxesQuery(TrustedNodeAddress), - NodeOverflowQuery(TrustedNodeAddress), NodeScrollRootIdQuery(TrustedNodeAddress), NodeGeometryQuery(TrustedNodeAddress), NodeScrollGeometryQuery(TrustedNodeAddress), ResolvedStyleQuery(TrustedNodeAddress, Option<PseudoElement>, PropertyId), OffsetParentQuery(TrustedNodeAddress), - MarginStyleQuery(TrustedNodeAddress), + StyleQuery(TrustedNodeAddress), TextIndexQuery(TrustedNodeAddress, Point2D<f32>), NodesFromPointQuery(Point2D<f32>, NodesFromPointQueryType), } @@ -133,9 +132,9 @@ impl ReflowGoal { ReflowGoal::TickAnimations | ReflowGoal::Full => true, ReflowGoal::ContentBoxQuery(_) | ReflowGoal::ContentBoxesQuery(_) | ReflowGoal::NodeGeometryQuery(_) | ReflowGoal::NodeScrollGeometryQuery(_) | - ReflowGoal::NodeOverflowQuery(_) | ReflowGoal::NodeScrollRootIdQuery(_) | + ReflowGoal::NodeScrollRootIdQuery(_) | ReflowGoal::ResolvedStyleQuery(..) | ReflowGoal::OffsetParentQuery(_) | - ReflowGoal::MarginStyleQuery(_) => false, + ReflowGoal::StyleQuery(_) => false, } } @@ -143,10 +142,10 @@ impl ReflowGoal { /// false if a layout_thread display list is sufficient. pub fn needs_display(&self) -> bool { match *self { - ReflowGoal::MarginStyleQuery(_) | ReflowGoal::TextIndexQuery(..) | + ReflowGoal::StyleQuery(_) | ReflowGoal::TextIndexQuery(..) | ReflowGoal::ContentBoxQuery(_) | ReflowGoal::ContentBoxesQuery(_) | ReflowGoal::NodeGeometryQuery(_) | ReflowGoal::NodeScrollGeometryQuery(_) | - ReflowGoal::NodeOverflowQuery(_) | ReflowGoal::NodeScrollRootIdQuery(_) | + ReflowGoal::NodeScrollRootIdQuery(_) | ReflowGoal::ResolvedStyleQuery(..) | ReflowGoal::OffsetParentQuery(_) => false, ReflowGoal::NodesFromPointQuery(..) | ReflowGoal::Full | 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>); |