mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
compositor/layout: Rely on layout for fine-grained input event hit testing (#38480)
Before, the compositor was responsible for doing the hit testing during input events within a page. This change moves that hit testing to layout. With this change, epoch mismatches are no longer a bit deal and we can simply ignore them, as the Constellation and Script will take care of ignoring hit tests against scroll nodes and browsing contexts that no longer exist. This means that hit testing retry support can be removed. Add the concept of a Script `HitTest` that transforms the coarse-grained renderer hit test into one that hit tests against the actual layout items. Testing: Currently we do not have good tests for verifying the behavior of input events, but WebDriver tests should cover this. Fixes: This is part of #37932. Fixes: #26608. Fixes: #25282. Fixes: #38090. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: kongbai1996 <1782765876@qq.com>
This commit is contained in:
parent
c0cc8484f8
commit
ad805e3110
19 changed files with 348 additions and 511 deletions
|
@ -3,7 +3,9 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::Point2D;
|
||||
use js::rust::HandleObject;
|
||||
use style_traits::CSSPixel;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::InputEventBinding::{self, InputEventMethods};
|
||||
use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEvent_Binding::UIEventMethods;
|
||||
|
@ -11,6 +13,7 @@ use crate::dom::bindings::error::Fallible;
|
|||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::node::Node;
|
||||
use crate::dom::uievent::UIEvent;
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
@ -91,3 +94,12 @@ impl InputEventMethods<crate::DomTypeHolder> for InputEvent {
|
|||
self.uievent.IsTrusted()
|
||||
}
|
||||
}
|
||||
|
||||
/// A [`HitTestResult`] that is the result of doing a hit test based on a less-fine-grained
|
||||
/// `CompositorHitTestResult` against our current layout.
|
||||
pub(crate) struct HitTestResult {
|
||||
pub node: DomRoot<Node>,
|
||||
pub point_in_node: Point2D<f32, CSSPixel>,
|
||||
pub point_in_frame: Point2D<f32, CSSPixel>,
|
||||
pub point_relative_to_initial_containing_block: Point2D<f32, CSSPixel>,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue