mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #18704 - mrobinson:wr-hit-testing, r=jdm,glennw,mbrubeck
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. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because they should not change behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18704) <!-- Reviewable:end -->
This commit is contained in:
commit
ca08271345
20 changed files with 381 additions and 555 deletions
|
@ -10,16 +10,15 @@ use context::LayoutContext;
|
|||
use euclid::{Point2D, Vector2D, Rect, Size2D};
|
||||
use flow::{self, Flow};
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
|
||||
use gfx::display_list::{DisplayItemMetadata, DisplayList, OpaqueNode, ScrollOffsetMap};
|
||||
use gfx::display_list::{DisplayList, OpaqueNode, ScrollOffsetMap};
|
||||
use inline::LAST_FRAGMENT_OF_ELEMENT;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use opaque_node::OpaqueNodeMethods;
|
||||
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse};
|
||||
use script_layout_interface::rpc::{HitTestResponse, LayoutRPC};
|
||||
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC};
|
||||
use script_layout_interface::rpc::{MarginStyleResponse, NodeGeometryResponse};
|
||||
use script_layout_interface::rpc::{NodeOverflowResponse, OffsetParentResponse};
|
||||
use script_layout_interface::rpc::{NodeScrollRootIdResponse, ResolvedStyleResponse, TextIndexResponse};
|
||||
use script_layout_interface::rpc::{NodeOverflowResponse, NodeScrollRootIdResponse};
|
||||
use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse, TextIndexResponse};
|
||||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||
use script_traits::LayoutMsg as ConstellationMsg;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
|
@ -35,7 +34,6 @@ use style::properties::{style_structs, PropertyId, PropertyDeclarationId, Longha
|
|||
use style::properties::longhands::{display, position};
|
||||
use style::selector_parser::PseudoElement;
|
||||
use style_traits::ToCss;
|
||||
use style_traits::cursor::Cursor;
|
||||
use webrender_api::ClipId;
|
||||
use wrapper::LayoutNodeLayoutData;
|
||||
|
||||
|
@ -58,9 +56,6 @@ pub struct LayoutThreadData {
|
|||
/// A queued response for the client {top, left, width, height} of a node in pixels.
|
||||
pub client_rect_response: Rect<i32>,
|
||||
|
||||
/// A queued response for the node at a given point
|
||||
pub hit_test_response: (Option<DisplayItemMetadata>, bool),
|
||||
|
||||
/// A queued response for the scroll root id for a given node.
|
||||
pub scroll_root_id_response: Option<ClipId>,
|
||||
|
||||
|
@ -119,24 +114,6 @@ impl LayoutRPC for LayoutRPCImpl {
|
|||
ContentBoxesResponse(rw_data.content_boxes_response.clone())
|
||||
}
|
||||
|
||||
/// Requests the node containing the point of interest.
|
||||
fn hit_test(&self) -> HitTestResponse {
|
||||
let &LayoutRPCImpl(ref rw_data) = self;
|
||||
let rw_data = rw_data.lock().unwrap();
|
||||
let &(ref result, update_cursor) = &rw_data.hit_test_response;
|
||||
if update_cursor {
|
||||
// Compute the new cursor.
|
||||
let cursor = match *result {
|
||||
None => Cursor::Default,
|
||||
Some(dim) => dim.pointing.unwrap(),
|
||||
};
|
||||
rw_data.constellation_chan.send(ConstellationMsg::SetCursor(cursor)).unwrap();
|
||||
}
|
||||
HitTestResponse {
|
||||
node_address: result.map(|dim| dim.node.to_untrusted_node_address()),
|
||||
}
|
||||
}
|
||||
|
||||
fn nodes_from_point_response(&self) -> Vec<UntrustedNodeAddress> {
|
||||
let &LayoutRPCImpl(ref rw_data) = self;
|
||||
let rw_data = rw_data.lock().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue