File: pointer_event.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (152 lines) | stat: -rw-r--r-- 4,802 bytes parent folder | download | duplicates (6)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright 2015 The Chromium Authors
// 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_EVENTS_POINTER_EVENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_POINTER_EVENT_H_

#include "third_party/blink/public/common/input/pointer_id.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"

namespace blink {

class PointerEventInit;

class CORE_EXPORT PointerEvent : public MouseEvent {
  DEFINE_WRAPPERTYPEINFO();

 public:
  static PointerEvent* Create(
      const AtomicString& type,
      const PointerEventInit* initializer,
      base::TimeTicks platform_time_stamp = base::TimeTicks::Now(),
      MouseEvent::SyntheticEventType synthetic_event_type =
          kRealOrIndistinguishable,
      WebMenuSourceType menu_source_type = kMenuSourceNone,
      bool prevent_counting_as_interaction = false) {
    return MakeGarbageCollected<PointerEvent>(
        type, initializer, platform_time_stamp, synthetic_event_type,
        menu_source_type, prevent_counting_as_interaction);
  }

  PointerEvent(const AtomicString&,
               const PointerEventInit*,
               base::TimeTicks platform_time_stamp,
               MouseEvent::SyntheticEventType synthetic_event_type,
               WebMenuSourceType menu_source_type = kMenuSourceNone,
               bool prevent_counting_as_interaction = false);

  PointerId pointerId() const { return pointer_id_; }
  PointerId pointerIdForBindings() const;
  double width() const { return width_; }
  double height() const { return height_; }
  float pressure() const { return pressure_; }
  int32_t tiltX() const { return tilt_x_; }
  int32_t tiltY() const { return tilt_y_; }
  double azimuthAngle() const { return azimuth_angle_; }
  double altitudeAngle() const { return altitude_angle_; }
  float tangentialPressure() const { return tangential_pressure_; }
  int32_t twist() const { return twist_; }
  const String& pointerType() const { return pointer_type_; }
  bool isPrimary() const { return is_primary_; }

  int16_t button() const override { return RawButton(); }
  bool IsMouseEvent() const override;
  bool IsPointerEvent() const override;

  double screenX() const override {
    if (ShouldHaveIntegerCoordinates())
      return MouseEvent::screenX();
    return screen_x_;
  }
  double screenY() const override {
    if (ShouldHaveIntegerCoordinates())
      return MouseEvent::screenY();
    return screen_y_;
  }
  double clientX() const override {
    if (ShouldHaveIntegerCoordinates())
      return MouseEvent::clientX();
    return client_x_;
  }
  double clientY() const override {
    if (ShouldHaveIntegerCoordinates())
      return MouseEvent::clientY();
    return client_y_;
  }
  double pageX() const override {
    if (ShouldHaveIntegerCoordinates())
      return MouseEvent::pageX();
    return page_x_;
  }
  double pageY() const override {
    if (ShouldHaveIntegerCoordinates())
      return MouseEvent::pageY();
    return page_y_;
  }

  double offsetX() const override;
  double offsetY() const override;

  void ReceivedTarget() override;

  // Always return null for fromElement and toElement because these fields
  // (inherited from MouseEvents) are non-standard.
  Node* fromElement() const final;
  Node* toElement() const final;

  HeapVector<Member<PointerEvent>> getCoalescedEvents();
  HeapVector<Member<PointerEvent>> getPredictedEvents();
  base::TimeTicks OldestPlatformTimeStamp() const;

  DispatchEventResult DispatchEvent(EventDispatcher&) override;

  Document* GetDocument() const;

  int32_t persistentDeviceId() const { return persistent_device_id_; }

  bool GetPreventCountingAsInteraction() const {
    return prevent_counting_as_interaction_;
  }

  void Trace(Visitor*) const override;

 private:
  bool ShouldHaveIntegerCoordinates() const;

  PointerId pointer_id_;
  double width_;
  double height_;
  float pressure_;
  int32_t tilt_x_;
  int32_t tilt_y_;
  double azimuth_angle_;
  double altitude_angle_;
  float tangential_pressure_;
  int32_t twist_;
  String pointer_type_;
  bool is_primary_;

  bool coalesced_events_targets_dirty_;
  bool predicted_events_targets_dirty_;

  HeapVector<Member<PointerEvent>> coalesced_events_;

  HeapVector<Member<PointerEvent>> predicted_events_;

  int32_t persistent_device_id_;

  // See equivalent member in web_input_event.h.
  bool prevent_counting_as_interaction_ = false;
};

template <>
struct DowncastTraits<PointerEvent> {
  static bool AllowFrom(const Event& event) { return event.IsPointerEvent(); }
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_POINTER_EVENT_H_