summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/input/event_handling_util.h
blob: 1883ce83c192fd20215d696cd6d0161816fee83f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_INPUT_EVENT_HANDLING_UTIL_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_INPUT_EVENT_HANDLING_UTIL_H_

#include "third_party/blink/public/platform/web_input_event_result.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/page/event_with_hit_test_results.h"
#include "third_party/blink/renderer/platform/geometry/layout_point.h"

namespace blink {

class ContainerNode;
class EventTarget;
class LocalFrame;
class ScrollableArea;
class PaintLayer;
enum class DispatchEventResult;

namespace event_handling_util {

HitTestResult HitTestResultInFrame(
    LocalFrame*,
    const HitTestLocation&,
    HitTestRequest::HitTestRequestType hit_type = HitTestRequest::kReadOnly |
                                                  HitTestRequest::kActive);

WebInputEventResult MergeEventResult(WebInputEventResult result_a,
                                     WebInputEventResult result_b);
WebInputEventResult ToWebInputEventResult(DispatchEventResult);

PaintLayer* LayerForNode(Node*);
ScrollableArea* AssociatedScrollableArea(const PaintLayer*);

bool IsInDocument(EventTarget*);

ContainerNode* ParentForClickEvent(const Node&);

LayoutPoint ContentPointFromRootFrame(LocalFrame*,
                                      const FloatPoint& point_in_root_frame);

MouseEventWithHitTestResults PerformMouseEventHitTest(LocalFrame*,
                                                      const HitTestRequest&,
                                                      const WebMouseEvent&);

LocalFrame* GetTargetSubframe(const MouseEventWithHitTestResults&,
                              Node* capturing_node = nullptr,
                              bool* is_remote_frame = nullptr);

LocalFrame* SubframeForTargetNode(Node*, bool* is_remote_frame = nullptr);

class PointerEventTarget {
  DISALLOW_NEW();

 public:
  void Trace(blink::Visitor* visitor) {
    visitor->Trace(target_element);
    visitor->Trace(target_frame);
  }

  Member<Element> target_element;
  Member<LocalFrame> target_frame;
  String region;
};

}  // namespace event_handling_util

}  // namespace blink

WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(
    blink::event_handling_util::PointerEventTarget)

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_INPUT_EVENT_HANDLING_UTIL_H_