From fefdaf76ded7675c0c67fd33f5abfbb5f74ac30f Mon Sep 17 00:00:00 2001 From: Zhen Zhang Date: Sun, 3 Apr 2016 15:41:37 +0800 Subject: Implement ScrollTop and ScrollLeft getters: Add new compositor message to get scroll_offset; Add new layout query for computed value of overflow-x/y; Implement layer_id method for ThreadSafeLayoutNode; Add new layout query for layer_id; Implement script interface for getting scrollTop and scrollLeft, as well as relavant helper functions. --- components/script/layout_interface.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'components/script/layout_interface.rs') diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index 07d8ac47edc..945fdbcbc7c 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use std::sync::mpsc::{Receiver, Sender, channel}; use string_cache::Atom; use style::context::ReflowGoal; -use style::properties::longhands::{margin_top, margin_right, margin_bottom, margin_left}; +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; @@ -104,8 +104,12 @@ 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 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 @@ -136,6 +140,8 @@ impl MarginStyleResponse { } } +pub struct NodeOverflowResponse(pub Option>); + pub struct ContentBoxResponse(pub Rect); pub struct ContentBoxesResponse(pub Vec>); pub struct HitTestResponse { @@ -144,6 +150,11 @@ pub struct HitTestResponse { pub struct NodeGeometryResponse { pub client_rect: Rect, } + +pub struct NodeLayerIdResponse { + pub layer_id: LayerId, +} + pub struct ResolvedStyleResponse(pub Option); #[derive(Clone)] @@ -167,8 +178,10 @@ pub enum ReflowQueryType { NoQuery, ContentBoxQuery(TrustedNodeAddress), ContentBoxesQuery(TrustedNodeAddress), + NodeOverflowQuery(TrustedNodeAddress), HitTestQuery(Point2D, bool), NodeGeometryQuery(TrustedNodeAddress), + NodeLayerIdQuery(TrustedNodeAddress), NodeScrollGeometryQuery(TrustedNodeAddress), ResolvedStyleQuery(TrustedNodeAddress, Option, Atom), OffsetParentQuery(TrustedNodeAddress), -- cgit v1.2.3