Switch to using WebRender hit testing

This trades quite a bit of complicated code in Servo for few more
messages and a significant performance improvement. In particular,
WebRender can search the entire display list at once instead of
ping-ponging down the pipeline tree. This allows us to send mouse
events to the correct pipeline immediately.
This commit is contained in:
Martin Robinson 2017-09-30 15:50:47 +02:00
parent 00e2a1c62a
commit b5d51dd263
20 changed files with 381 additions and 555 deletions

View file

@ -1149,28 +1149,15 @@ impl Window {
x: f32,
y: f32,
scroll_root_id: ClipId,
behavior: ScrollBehavior,
element: Option<&Element>) {
//TODO Step 1
let point = Point2D::new(x, y);
let smooth = match behavior {
ScrollBehavior::Auto => {
element.map_or(false, |_element| {
// TODO check computed scroll-behaviour CSS property
true
})
}
ScrollBehavior::Instant => false,
ScrollBehavior::Smooth => true
};
_behavior: ScrollBehavior,
_element: Option<&Element>) {
// TODO Step 1
// TODO(mrobinson, #18709): Add smooth scrolling support to WebRender so that we can
// properly process ScrollBehavior here.
self.layout_chan.send(Msg::UpdateScrollStateFromScript(ScrollState {
scroll_root_id: scroll_root_id,
scroll_offset: Vector2D::new(-x, -y),
})).unwrap();
let message = ScriptMsg::ScrollFragmentPoint(scroll_root_id, point, smooth);
self.send_to_constellation(message);
}
pub fn update_viewport_for_scroll(&self, x: f32, y: f32) {
@ -1406,18 +1393,6 @@ impl Window {
self.layout_rpc.node_geometry().client_rect
}
pub fn hit_test_query(&self,
client_point: Point2D<f32>,
update_cursor: bool)
-> Option<UntrustedNodeAddress> {
if !self.reflow(ReflowGoal::HitTestQuery(client_point, update_cursor),
ReflowReason::Query) {
return None
}
self.layout_rpc.hit_test().node_address
}
pub fn scroll_area_query(&self, node: TrustedNodeAddress) -> Rect<i32> {
if !self.reflow(ReflowGoal::NodeScrollGeometryQuery(node), ReflowReason::Query) {
return Rect::zero();
@ -1910,8 +1885,7 @@ fn debug_reflow_events(id: PipelineId, reflow_goal: &ReflowGoal, reason: &Reflow
ReflowGoal::Full => "\tFull",
ReflowGoal::ContentBoxQuery(_n) => "\tContentBoxQuery",
ReflowGoal::ContentBoxesQuery(_n) => "\tContentBoxesQuery",
ReflowGoal::HitTestQuery(..) => "\tHitTestQuery",
ReflowGoal::NodesFromPoint(..) => "\tNodesFromPoint",
ReflowGoal::NodesFromPointQuery(..) => "\tNodesFromPointQuery",
ReflowGoal::NodeGeometryQuery(_n) => "\tNodeGeometryQuery",
ReflowGoal::NodeOverflowQuery(_n) => "\tNodeOverFlowQuery",
ReflowGoal::NodeScrollGeometryQuery(_n) => "\tNodeScrollGeometryQuery",