mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Trigger reflow on document.elementsFromPoint
This commit is contained in:
parent
d0856fd4cd
commit
7426d902a3
10 changed files with 86 additions and 33 deletions
|
@ -73,7 +73,7 @@ mod linked_list;
|
||||||
mod list_item;
|
mod list_item;
|
||||||
mod model;
|
mod model;
|
||||||
mod multicol;
|
mod multicol;
|
||||||
mod opaque_node;
|
pub mod opaque_node;
|
||||||
pub mod parallel;
|
pub mod parallel;
|
||||||
mod persistent_list;
|
mod persistent_list;
|
||||||
pub mod query;
|
pub mod query;
|
||||||
|
|
|
@ -94,6 +94,9 @@ pub struct LayoutThreadData {
|
||||||
|
|
||||||
/// A list of images requests that need to be initiated.
|
/// A list of images requests that need to be initiated.
|
||||||
pub pending_images: Vec<PendingImage>,
|
pub pending_images: Vec<PendingImage>,
|
||||||
|
|
||||||
|
/// A queued response for the list of nodes at a given point.
|
||||||
|
pub nodes_from_point_response: Vec<UntrustedNodeAddress>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutThreadData>>);
|
pub struct LayoutRPCImpl(pub Arc<Mutex<LayoutThreadData>>);
|
||||||
|
@ -144,33 +147,10 @@ impl LayoutRPC for LayoutRPCImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nodes_from_point(&self,
|
fn nodes_from_point(&self) -> Vec<UntrustedNodeAddress> {
|
||||||
page_point: Point2D<f32>,
|
|
||||||
client_point: Point2D<f32>) -> Vec<UntrustedNodeAddress> {
|
|
||||||
let page_point = Point2D::new(Au::from_f32_px(page_point.x),
|
|
||||||
Au::from_f32_px(page_point.y));
|
|
||||||
let client_point = Point2D::new(Au::from_f32_px(client_point.x),
|
|
||||||
Au::from_f32_px(client_point.y));
|
|
||||||
|
|
||||||
let nodes_from_point_list = {
|
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let &LayoutRPCImpl(ref rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
let result = match rw_data.display_list {
|
rw_data.nodes_from_point_response.clone()
|
||||||
None => panic!("Tried to hit test without a DisplayList"),
|
|
||||||
Some(ref display_list) => {
|
|
||||||
display_list.hit_test(&page_point,
|
|
||||||
&client_point,
|
|
||||||
&rw_data.stacking_context_scroll_offsets)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
result
|
|
||||||
};
|
|
||||||
|
|
||||||
nodes_from_point_list.iter()
|
|
||||||
.rev()
|
|
||||||
.map(|metadata| metadata.node.to_untrusted_node_address())
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_geometry(&self) -> NodeGeometryResponse {
|
fn node_geometry(&self) -> NodeGeometryResponse {
|
||||||
|
|
|
@ -63,6 +63,7 @@ use layout::flow::{self, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwne
|
||||||
use layout::flow_ref::FlowRef;
|
use layout::flow_ref::FlowRef;
|
||||||
use layout::incremental::{LayoutDamageComputation, REFLOW_ENTIRE_DOCUMENT};
|
use layout::incremental::{LayoutDamageComputation, REFLOW_ENTIRE_DOCUMENT};
|
||||||
use layout::layout_debug;
|
use layout::layout_debug;
|
||||||
|
use layout::opaque_node::OpaqueNodeMethods;
|
||||||
use layout::parallel;
|
use layout::parallel;
|
||||||
use layout::query::{LayoutRPCImpl, LayoutThreadData, process_content_box_request, process_content_boxes_request};
|
use layout::query::{LayoutRPCImpl, LayoutThreadData, process_content_box_request, process_content_boxes_request};
|
||||||
use layout::query::{process_margin_style_query, process_node_overflow_request, process_resolved_style_request};
|
use layout::query::{process_margin_style_query, process_node_overflow_request, process_resolved_style_request};
|
||||||
|
@ -459,6 +460,7 @@ impl LayoutThread {
|
||||||
stacking_context_scroll_offsets: HashMap::new(),
|
stacking_context_scroll_offsets: HashMap::new(),
|
||||||
text_index_response: TextIndexResponse(None),
|
text_index_response: TextIndexResponse(None),
|
||||||
pending_images: vec![],
|
pending_images: vec![],
|
||||||
|
nodes_from_point_response: vec![],
|
||||||
})),
|
})),
|
||||||
error_reporter: CSSErrorReporter {
|
error_reporter: CSSErrorReporter {
|
||||||
pipelineid: id,
|
pipelineid: id,
|
||||||
|
@ -977,6 +979,9 @@ impl LayoutThread {
|
||||||
ReflowQueryType::HitTestQuery(..) => {
|
ReflowQueryType::HitTestQuery(..) => {
|
||||||
rw_data.hit_test_response = (None, false);
|
rw_data.hit_test_response = (None, false);
|
||||||
},
|
},
|
||||||
|
ReflowQueryType::NodesFromPoint(..) => {
|
||||||
|
rw_data.nodes_from_point_response = Vec::new();
|
||||||
|
},
|
||||||
ReflowQueryType::NodeGeometryQuery(_) => {
|
ReflowQueryType::NodeGeometryQuery(_) => {
|
||||||
rw_data.client_rect_response = Rect::zero();
|
rw_data.client_rect_response = Rect::zero();
|
||||||
},
|
},
|
||||||
|
@ -1279,6 +1284,29 @@ impl LayoutThread {
|
||||||
let node = unsafe { ServoLayoutNode::new(&node) };
|
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||||
rw_data.margin_style_response = process_margin_style_query(node);
|
rw_data.margin_style_response = process_margin_style_query(node);
|
||||||
},
|
},
|
||||||
|
ReflowQueryType::NodesFromPoint(page_point, client_point) => {
|
||||||
|
let page_point = Point2D::new(Au::from_f32_px(page_point.x),
|
||||||
|
Au::from_f32_px(page_point.y));
|
||||||
|
let client_point = Point2D::new(Au::from_f32_px(client_point.x),
|
||||||
|
Au::from_f32_px(client_point.y));
|
||||||
|
let nodes_from_point_list = {
|
||||||
|
let result = match rw_data.display_list {
|
||||||
|
None => panic!("Tried to hit test without a DisplayList"),
|
||||||
|
Some(ref display_list) => {
|
||||||
|
display_list.hit_test(&page_point,
|
||||||
|
&client_point,
|
||||||
|
&rw_data.stacking_context_scroll_offsets)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
result
|
||||||
|
};
|
||||||
|
|
||||||
|
rw_data.nodes_from_point_response = nodes_from_point_list.iter()
|
||||||
|
.rev()
|
||||||
|
.map(|metadata| metadata.node.to_untrusted_node_address())
|
||||||
|
.collect()
|
||||||
|
},
|
||||||
ReflowQueryType::NoQuery => {}
|
ReflowQueryType::NoQuery => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1585,7 +1613,8 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
|
||||||
/// or false if it only needs stacking-relative positions.
|
/// or false if it only needs stacking-relative positions.
|
||||||
fn reflow_query_type_needs_display_list(query_type: &ReflowQueryType) -> bool {
|
fn reflow_query_type_needs_display_list(query_type: &ReflowQueryType) -> bool {
|
||||||
match *query_type {
|
match *query_type {
|
||||||
ReflowQueryType::HitTestQuery(..) | ReflowQueryType::TextIndexQuery(..) => true,
|
ReflowQueryType::HitTestQuery(..) | ReflowQueryType::TextIndexQuery(..) |
|
||||||
|
ReflowQueryType::NodesFromPoint(..) => true,
|
||||||
ReflowQueryType::ContentBoxQuery(_) | ReflowQueryType::ContentBoxesQuery(_) |
|
ReflowQueryType::ContentBoxQuery(_) | ReflowQueryType::ContentBoxesQuery(_) |
|
||||||
ReflowQueryType::NodeGeometryQuery(_) | ReflowQueryType::NodeScrollGeometryQuery(_) |
|
ReflowQueryType::NodeGeometryQuery(_) | ReflowQueryType::NodeScrollGeometryQuery(_) |
|
||||||
ReflowQueryType::NodeOverflowQuery(_) | ReflowQueryType::NodeScrollRootIdQuery(_) |
|
ReflowQueryType::NodeOverflowQuery(_) | ReflowQueryType::NodeScrollRootIdQuery(_) |
|
||||||
|
|
|
@ -1877,7 +1877,13 @@ impl Document {
|
||||||
Point2D::new(client_point.x + self.window.PageXOffset() as f32,
|
Point2D::new(client_point.x + self.window.PageXOffset() as f32,
|
||||||
client_point.y + self.window.PageYOffset() as f32);
|
client_point.y + self.window.PageYOffset() as f32);
|
||||||
|
|
||||||
self.window.layout().nodes_from_point(page_point, *client_point)
|
if !self.window.reflow(ReflowGoal::ForScriptQuery,
|
||||||
|
ReflowQueryType::NodesFromPoint(page_point, *client_point),
|
||||||
|
ReflowReason::Query) {
|
||||||
|
return vec!();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.window.layout().nodes_from_point()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1811,6 +1811,7 @@ fn debug_reflow_events(id: PipelineId, goal: &ReflowGoal, query_type: &ReflowQue
|
||||||
ReflowQueryType::ContentBoxQuery(_n) => "\tContentBoxQuery",
|
ReflowQueryType::ContentBoxQuery(_n) => "\tContentBoxQuery",
|
||||||
ReflowQueryType::ContentBoxesQuery(_n) => "\tContentBoxesQuery",
|
ReflowQueryType::ContentBoxesQuery(_n) => "\tContentBoxesQuery",
|
||||||
ReflowQueryType::HitTestQuery(..) => "\tHitTestQuery",
|
ReflowQueryType::HitTestQuery(..) => "\tHitTestQuery",
|
||||||
|
ReflowQueryType::NodesFromPoint(..) => "\tNodesFromPoint",
|
||||||
ReflowQueryType::NodeGeometryQuery(_n) => "\tNodeGeometryQuery",
|
ReflowQueryType::NodeGeometryQuery(_n) => "\tNodeGeometryQuery",
|
||||||
ReflowQueryType::NodeOverflowQuery(_n) => "\tNodeOverFlowQuery",
|
ReflowQueryType::NodeOverflowQuery(_n) => "\tNodeOverFlowQuery",
|
||||||
ReflowQueryType::NodeScrollGeometryQuery(_n) => "\tNodeScrollGeometryQuery",
|
ReflowQueryType::NodeScrollGeometryQuery(_n) => "\tNodeScrollGeometryQuery",
|
||||||
|
|
|
@ -101,6 +101,7 @@ pub enum ReflowQueryType {
|
||||||
OffsetParentQuery(TrustedNodeAddress),
|
OffsetParentQuery(TrustedNodeAddress),
|
||||||
MarginStyleQuery(TrustedNodeAddress),
|
MarginStyleQuery(TrustedNodeAddress),
|
||||||
TextIndexQuery(TrustedNodeAddress, i32, i32),
|
TextIndexQuery(TrustedNodeAddress, i32, i32),
|
||||||
|
NodesFromPoint(Point2D<f32>, Point2D<f32>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information needed for a reflow.
|
/// Information needed for a reflow.
|
||||||
|
|
|
@ -40,7 +40,8 @@ pub trait LayoutRPC {
|
||||||
fn margin_style(&self) -> MarginStyleResponse;
|
fn margin_style(&self) -> MarginStyleResponse;
|
||||||
/// Requests the list of not-yet-loaded images that were encountered in the last reflow.
|
/// Requests the list of not-yet-loaded images that were encountered in the last reflow.
|
||||||
fn pending_images(&self) -> Vec<PendingImage>;
|
fn pending_images(&self) -> Vec<PendingImage>;
|
||||||
fn nodes_from_point(&self, page_point: Point2D<f32>, client_point: Point2D<f32>) -> Vec<UntrustedNodeAddress>;
|
/// Requests the list of nodes from the given point.
|
||||||
|
fn nodes_from_point(&self) -> Vec<UntrustedNodeAddress>;
|
||||||
|
|
||||||
fn text_index(&self) -> TextIndexResponse;
|
fn text_index(&self) -> TextIndexResponse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6341,6 +6341,18 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"mozilla/document_elementsFromPoint.html": [
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/document_elementsFromPoint.html",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/document_elementsFromPoint_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"mozilla/iframe/resize_after_load.html": [
|
"mozilla/iframe/resize_after_load.html": [
|
||||||
[
|
[
|
||||||
"/_mozilla/mozilla/iframe/resize_after_load.html",
|
"/_mozilla/mozilla/iframe/resize_after_load.html",
|
||||||
|
@ -9388,6 +9400,11 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"mozilla/document_elementsFromPoint_ref.html": [
|
||||||
|
[
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"mozilla/form_submit_about_frame.html": [
|
"mozilla/form_submit_about_frame.html": [
|
||||||
[
|
[
|
||||||
{}
|
{}
|
||||||
|
@ -25137,6 +25154,14 @@
|
||||||
"12eef74e9ba1a62b0302df79633cab5c48f4977f",
|
"12eef74e9ba1a62b0302df79633cab5c48f4977f",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
|
"mozilla/document_elementsFromPoint.html": [
|
||||||
|
"2349e1d102552a46bb8e3dd36c0b3396e0d6530b",
|
||||||
|
"reftest"
|
||||||
|
],
|
||||||
|
"mozilla/document_elementsFromPoint_ref.html": [
|
||||||
|
"4d1a1d0acc16bcb123781cbed47184ff308f3097",
|
||||||
|
"support"
|
||||||
|
],
|
||||||
"mozilla/document_getElementById.html": [
|
"mozilla/document_getElementById.html": [
|
||||||
"ae5270afde878c8fbe9b4a89c5c3f8ff609220dc",
|
"ae5270afde878c8fbe9b4a89c5c3f8ff609220dc",
|
||||||
"testharness"
|
"testharness"
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title></title>
|
||||||
|
<link rel="match" href="document_elementsFromPoint_ref.html">
|
||||||
|
<script>
|
||||||
|
var elements = document.elementsFromPoint(10, 10);
|
||||||
|
</script>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title></title>
|
Loading…
Add table
Add a link
Reference in a new issue