mirror of
https://github.com/servo/servo.git
synced 2025-07-30 10:40:27 +01:00
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.
This commit is contained in:
parent
f73c6143d5
commit
fefdaf76de
12 changed files with 243 additions and 9 deletions
|
@ -45,10 +45,11 @@ use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
|||
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
||||
use profile_traits::time::{self, TimerMetadata, profile};
|
||||
use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request};
|
||||
use query::{process_node_geometry_request, process_node_scroll_area_request, process_offset_parent_query};
|
||||
use query::{process_resolved_style_request, process_margin_style_query};
|
||||
use query::{process_node_geometry_request, process_node_layer_id_request, process_node_scroll_area_request};
|
||||
use query::{process_node_overflow_request, process_resolved_style_request, process_margin_style_query};
|
||||
use query::{process_offset_parent_query};
|
||||
use script::dom::node::OpaqueStyleAndLayoutData;
|
||||
use script::layout_interface::{LayoutRPC, OffsetParentResponse, MarginStyleResponse};
|
||||
use script::layout_interface::{LayoutRPC, OffsetParentResponse, NodeOverflowResponse, MarginStyleResponse};
|
||||
use script::layout_interface::{Msg, NewLayoutThreadInfo, Reflow, ReflowQueryType};
|
||||
use script::layout_interface::{ScriptLayoutChan, ScriptReflow};
|
||||
use script::reporter::CSSErrorReporter;
|
||||
|
@ -117,9 +118,14 @@ pub struct LayoutThreadData {
|
|||
/// A queued response for the client {top, left, width, height} of a node in pixels.
|
||||
pub client_rect_response: Rect<i32>,
|
||||
|
||||
pub layer_id_response: Option<LayerId>,
|
||||
|
||||
/// A queued response for the node at a given point
|
||||
pub hit_test_response: (Option<DisplayItemMetadata>, bool),
|
||||
|
||||
/// A pair of overflow property in x and y
|
||||
pub overflow_response: NodeOverflowResponse,
|
||||
|
||||
/// A queued response for the scroll {top, left, width, height} of a node in pixels.
|
||||
pub scroll_area_response: Rect<i32>,
|
||||
|
||||
|
@ -463,8 +469,10 @@ impl LayoutThread {
|
|||
content_box_response: Rect::zero(),
|
||||
content_boxes_response: Vec::new(),
|
||||
client_rect_response: Rect::zero(),
|
||||
layer_id_response: None,
|
||||
hit_test_response: (None, false),
|
||||
scroll_area_response: Rect::zero(),
|
||||
overflow_response: NodeOverflowResponse(None),
|
||||
resolved_style_response: None,
|
||||
offset_parent_response: OffsetParentResponse::empty(),
|
||||
margin_style_response: MarginStyleResponse::empty(),
|
||||
|
@ -1015,9 +1023,15 @@ impl LayoutThread {
|
|||
ReflowQueryType::NodeGeometryQuery(_) => {
|
||||
rw_data.client_rect_response = Rect::zero();
|
||||
},
|
||||
ReflowQueryType::NodeLayerIdQuery(_) => {
|
||||
rw_data.layer_id_response = None;
|
||||
},
|
||||
ReflowQueryType::NodeScrollGeometryQuery(_) => {
|
||||
rw_data.scroll_area_response = Rect::zero();
|
||||
},
|
||||
ReflowQueryType::NodeOverflowQuery(_) => {
|
||||
rw_data.overflow_response = NodeOverflowResponse(None);
|
||||
},
|
||||
ReflowQueryType::ResolvedStyleQuery(_, _, _) => {
|
||||
rw_data.resolved_style_response = None;
|
||||
},
|
||||
|
@ -1177,6 +1191,14 @@ impl LayoutThread {
|
|||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
rw_data.scroll_area_response = process_node_scroll_area_request(node, &mut root_flow);
|
||||
},
|
||||
ReflowQueryType::NodeOverflowQuery(node) => {
|
||||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
rw_data.overflow_response = process_node_overflow_request(node);
|
||||
},
|
||||
ReflowQueryType::NodeLayerIdQuery(node) => {
|
||||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
rw_data.layer_id_response = Some(process_node_layer_id_request(node));
|
||||
},
|
||||
ReflowQueryType::ResolvedStyleQuery(node, ref pseudo, ref property) => {
|
||||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
rw_data.resolved_style_response =
|
||||
|
|
|
@ -13,11 +13,12 @@ use flow;
|
|||
use flow_ref::FlowRef;
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
|
||||
use gfx::display_list::OpaqueNode;
|
||||
use gfx_traits::{LayerId};
|
||||
use layout_thread::LayoutThreadData;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use opaque_node::OpaqueNodeMethods;
|
||||
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse, NodeGeometryResponse};
|
||||
use script::layout_interface::{HitTestResponse, LayoutRPC, OffsetParentResponse};
|
||||
use script::layout_interface::{ContentBoxResponse, NodeOverflowResponse, ContentBoxesResponse, NodeGeometryResponse};
|
||||
use script::layout_interface::{HitTestResponse, LayoutRPC, OffsetParentResponse, NodeLayerIdResponse};
|
||||
use script::layout_interface::{ResolvedStyleResponse, ScriptLayoutChan, MarginStyleResponse};
|
||||
use script_traits::LayoutMsg as ConstellationMsg;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
|
@ -112,12 +113,23 @@ impl LayoutRPC for LayoutRPCImpl {
|
|||
}
|
||||
}
|
||||
|
||||
fn node_overflow(&self) -> NodeOverflowResponse {
|
||||
NodeOverflowResponse(self.0.lock().unwrap().overflow_response.0)
|
||||
}
|
||||
|
||||
fn node_scroll_area(&self) -> NodeGeometryResponse {
|
||||
NodeGeometryResponse {
|
||||
client_rect: self.0.lock().unwrap().scroll_area_response
|
||||
}
|
||||
}
|
||||
|
||||
fn node_layer_id(&self) -> NodeLayerIdResponse {
|
||||
NodeLayerIdResponse {
|
||||
layer_id: self.0.lock().unwrap().layer_id_response
|
||||
.expect("layer_id is not correctly fetched, see PR #9968")
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves the resolved value for a CSS style property.
|
||||
fn resolved_style(&self) -> ResolvedStyleResponse {
|
||||
let &LayoutRPCImpl(ref rw_data) = self;
|
||||
|
@ -425,6 +437,7 @@ impl FragmentBorderBoxIterator for UnioningFragmentScrollAreaIterator {
|
|||
let bottom_padding = (border_box.size.height - bottom_border - top_border).to_px();
|
||||
let top_padding = top_border.to_px();
|
||||
let left_padding = left_border.to_px();
|
||||
|
||||
match self.level {
|
||||
Some(start_level) if level <= start_level => { self.is_child = false; }
|
||||
Some(_) => {
|
||||
|
@ -517,6 +530,11 @@ pub fn process_node_geometry_request<N: LayoutNode>(requested_node: N, layout_ro
|
|||
iterator.client_rect
|
||||
}
|
||||
|
||||
pub fn process_node_layer_id_request<N: LayoutNode>(requested_node: N) -> LayerId {
|
||||
let layout_node = requested_node.to_threadsafe();
|
||||
layout_node.layer_id()
|
||||
}
|
||||
|
||||
pub fn process_node_scroll_area_request< N: LayoutNode>(requested_node: N, layout_root: &mut FlowRef)
|
||||
-> Rect<i32> {
|
||||
let mut iterator = UnioningFragmentScrollAreaIterator::new(requested_node.opaque());
|
||||
|
@ -691,6 +709,14 @@ pub fn process_offset_parent_query<N: LayoutNode>(requested_node: N, layout_root
|
|||
}
|
||||
}
|
||||
|
||||
pub fn process_node_overflow_request<N: LayoutNode>(requested_node: N) -> NodeOverflowResponse {
|
||||
let layout_node = requested_node.to_threadsafe();
|
||||
let style = &*layout_node.style();
|
||||
let style_box = style.get_box();
|
||||
|
||||
NodeOverflowResponse(Some((Point2D::new(style_box.overflow_x, style_box.overflow_y.0))))
|
||||
}
|
||||
|
||||
pub fn process_margin_style_query<N: LayoutNode>(requested_node: N)
|
||||
-> MarginStyleResponse {
|
||||
let layout_node = requested_node.to_threadsafe();
|
||||
|
|
|
@ -34,6 +34,7 @@ use core::nonzero::NonZero;
|
|||
use data::{LayoutDataFlags, PrivateLayoutData};
|
||||
use gfx::display_list::OpaqueNode;
|
||||
use gfx::text::glyph::CharIndex;
|
||||
use gfx_traits::{LayerId, LayerType};
|
||||
use incremental::RestyleDamage;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use opaque_node::OpaqueNodeMethods;
|
||||
|
@ -851,6 +852,21 @@ pub trait ThreadSafeLayoutNode : Clone + Copy + Sized + PartialEq {
|
|||
fn iframe_pipeline_id(&self) -> PipelineId;
|
||||
|
||||
fn get_colspan(&self) -> u32;
|
||||
|
||||
fn layer_id(&self) -> LayerId {
|
||||
let layer_type = match self.get_pseudo_element_type() {
|
||||
PseudoElementType::Normal => LayerType::FragmentBody,
|
||||
PseudoElementType::Before(_) => LayerType::BeforePseudoContent,
|
||||
PseudoElementType::After(_) => LayerType::AfterPseudoContent,
|
||||
PseudoElementType::DetailsSummary(_) => LayerType::FragmentBody,
|
||||
PseudoElementType::DetailsContent(_) => LayerType::FragmentBody,
|
||||
};
|
||||
LayerId::new_of_type(layer_type, self.opaque().id() as usize)
|
||||
}
|
||||
|
||||
fn layer_id_for_overflow_scroll(&self) -> LayerId {
|
||||
LayerId::new_of_type(LayerType::OverflowScroll, self.opaque().id() as usize)
|
||||
}
|
||||
}
|
||||
|
||||
// This trait is only public so that it can be implemented by the gecko wrapper.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue