mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
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.
This commit is contained in:
parent
c9ba16f9fb
commit
fe583fc5d0
10 changed files with 88 additions and 136 deletions
|
@ -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 |
|
||||
|
|
|
@ -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>);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue