#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/input/pointer_event_manager.h"
#include "base/auto_reset.h"
#include "base/metrics/field_trial_params.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom-blink.h"
#include "third_party/blink/public/mojom/input/input_handler.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/events/event_path.h"
#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/core/frame/event_handler_registry.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/input/event_handling_util.h"
#include "third_party/blink/renderer/core/input/mouse_event_manager.h"
#include "third_party/blink/renderer/core/input/touch_action_util.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/loader/anchor_element_interaction_tracker.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/pointer_lock_controller.h"
#include "third_party/blink/renderer/core/page/touch_adjustment.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/scroll/scrollbar.h"
#include "third_party/blink/renderer/core/timing/event_timing.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "ui/display/screen_info.h"
namespace blink {
namespace {
const char kSkipTouchEventFilterTrial[] = …;
const char kSkipTouchEventFilterTrialProcessParamName[] = …;
const char kSkipTouchEventFilterTrialTypeParamName[] = …;
const size_t kStylusWritableAdjustmentSizeDip = …;
size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) { … }
bool HasPointerEventListener(const EventHandlerRegistry& registry) { … }
const AtomicString& MouseEventNameForPointerEventInputType(
const WebInputEvent::Type& event_type) { … }
}
PointerEventManager::PointerEventManager(LocalFrame& frame,
MouseEventManager& mouse_event_manager)
: … { … }
void PointerEventManager::Clear() { … }
void PointerEventManager::Trace(Visitor* visitor) const { … }
PointerEventManager::PointerEventBoundaryEventDispatcher::
PointerEventBoundaryEventDispatcher(
PointerEventManager* pointer_event_manager,
PointerEvent* pointer_event)
: … { … }
void PointerEventManager::PointerEventBoundaryEventDispatcher::Dispatch(
EventTarget* target,
EventTarget* related_target,
const AtomicString& type,
bool check_for_listener) { … }
WebInputEventResult PointerEventManager::DispatchPointerEvent(
EventTarget* target,
PointerEvent* pointer_event,
bool check_for_listener) { … }
Element* PointerEventManager::GetEffectiveTargetForPointerEvent(
Element* target,
PointerId pointer_id) { … }
void PointerEventManager::SendMouseAndPointerBoundaryEvents(
Element* entered_element,
const WebMouseEvent& mouse_event) { … }
void PointerEventManager::SendBoundaryEvents(
EventTarget* exited_target,
bool original_exited_target_removed,
EventTarget* entered_target,
PointerEvent* pointer_event) { … }
void PointerEventManager::SetElementUnderPointer(PointerEvent* pointer_event,
Element* target) { … }
void PointerEventManager::NodeWillBeRemoved(Node& node_to_be_removed) { … }
void PointerEventManager::HandlePointerInterruption(
const WebPointerEvent& web_pointer_event) { … }
bool PointerEventManager::ShouldAdjustPointerEvent(
const WebPointerEvent& pointer_event) const { … }
bool PointerEventManager::ShouldAdjustStylusPointerEvent(
const WebPointerEvent& pointer_event) const { … }
void PointerEventManager::AdjustPointerEvent(WebPointerEvent& pointer_event) { … }
void PointerEventManager::AdjustPointerEvent(WebPointerEvent& pointer_event,
Node*& adjusted_node) { … }
bool PointerEventManager::ShouldFilterEvent(PointerEvent* pointer_event) { … }
event_handling_util::PointerEventTarget
PointerEventManager::ComputePointerEventTarget(
const WebPointerEvent& web_pointer_event) { … }
WebInputEventResult PointerEventManager::DispatchTouchPointerEvent(
const WebPointerEvent& web_pointer_event,
const Vector<WebPointerEvent>& coalesced_events,
const Vector<WebPointerEvent>& predicted_events,
const event_handling_util::PointerEventTarget& pointer_event_target) { … }
WebInputEventResult PointerEventManager::SendTouchPointerEvent(
Element* target,
PointerEvent* pointer_event,
bool hovering) { … }
WebInputEventResult PointerEventManager::FlushEvents() { … }
WebInputEventResult PointerEventManager::HandlePointerEvent(
const WebPointerEvent& event,
const Vector<WebPointerEvent>& coalesced_events,
const Vector<WebPointerEvent>& predicted_events) { … }
bool PointerEventManager::HandleScrollbarTouchDrag(const WebPointerEvent& event,
Scrollbar* scrollbar) { … }
bool PointerEventManager::HandleResizerDrag(
const WebPointerEvent& event,
const event_handling_util::PointerEventTarget& pointer_event_target) { … }
WebInputEventResult PointerEventManager::CreateAndDispatchPointerEvent(
Element* target,
const AtomicString& mouse_event_name,
const WebMouseEvent& mouse_event,
const Vector<WebMouseEvent>& coalesced_events,
const Vector<WebMouseEvent>& predicted_events) { … }
WebInputEventResult PointerEventManager::DirectDispatchMousePointerEvent(
Element* target,
const WebMouseEvent& event,
const AtomicString& mouse_event_type,
const Vector<WebMouseEvent>& coalesced_events,
const Vector<WebMouseEvent>& predicted_events) { … }
void PointerEventManager::SendEffectivePanActionAtPointer(
const WebPointerEvent& event,
const Node* node_at_pointer) { … }
namespace {
Element* NonDeletedElementTarget(Element* target,
PointerEvent* dispatched_pointer_event) { … }
}
WebInputEventResult PointerEventManager::SendMousePointerEvent(
Element* target,
const WebInputEvent::Type event_type,
const WebMouseEvent& mouse_event,
const Vector<WebMouseEvent>& coalesced_events,
const Vector<WebMouseEvent>& predicted_events,
bool skip_click_dispatch) { … }
bool PointerEventManager::GetPointerCaptureState(
PointerId pointer_id,
Element** pointer_capture_target,
Element** pending_pointer_capture_target) { … }
Element* PointerEventManager::ProcessCaptureAndPositionOfPointerEvent(
PointerEvent* pointer_event,
Element* hit_test_target,
const WebMouseEvent* mouse_event) { … }
void PointerEventManager::ProcessPendingPointerCapture(
PointerEvent* pointer_event) { … }
void PointerEventManager::RemoveTargetFromPointerCapturingMapping(
PointerCapturingMap& map,
const Element* target) { … }
void PointerEventManager::RemovePointer(PointerEvent* pointer_event) { … }
void PointerEventManager::ElementRemoved(Element* target) { … }
bool PointerEventManager::SetPointerCapture(PointerId pointer_id,
Element* target,
bool explicit_capture) { … }
bool PointerEventManager::ReleasePointerCapture(PointerId pointer_id,
Element* target) { … }
void PointerEventManager::ReleaseMousePointerCapture() { … }
bool PointerEventManager::HasPointerCapture(PointerId pointer_id,
const Element* target) const { … }
void PointerEventManager::ReleasePointerCapture(PointerId pointer_id) { … }
Element* PointerEventManager::GetMouseCaptureTarget() { … }
bool PointerEventManager::IsActive(const PointerId pointer_id) const { … }
bool PointerEventManager::IsPointerIdActiveOnFrame(PointerId pointer_id,
LocalFrame* frame) const { … }
bool PointerEventManager::IsAnyTouchActive() const { … }
bool PointerEventManager::PrimaryPointerdownCanceled(
uint32_t unique_touch_event_id) { … }
void PointerEventManager::SetLastPointerPositionForFrameBoundary(
const WebPointerEvent& web_pointer_event,
Element* new_target) { … }
void PointerEventManager::RemoveLastMousePosition() { … }
PointerId PointerEventManager::GetPointerIdForTouchGesture(
const uint32_t unique_touch_event_id) { … }
Element* PointerEventManager::CurrentTouchDownElement() { … }
}