Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: third_party/WebKit/Source/core/events/MouseRelatedEvent.h

Issue 2580083002: Remove MouseRelatedEvent (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24 #ifndef MouseRelatedEvent_h
25 #define MouseRelatedEvent_h
26
27 #include "core/CoreExport.h"
28 #include "core/events/MouseEventInit.h"
29 #include "core/events/UIEventWithKeyState.h"
30 #include "platform/geometry/LayoutPoint.h"
31
32 namespace blink {
33
34 // Internal only: Helper class for what's common between mouse and wheel events.
35 class CORE_EXPORT MouseRelatedEvent : public UIEventWithKeyState {
36 public:
37 enum class PositionType {
38 Position,
39 // Positionless mouse events are used, for example, for 'click' events from
40 // keyboard input. It's kind of surprising for a mouse event not to have a
41 // position.
42 Positionless
43 };
44
45 // Note that these values are adjusted to counter the effects of zoom, so that
46 // values exposed via DOM APIs are invariant under zooming.
47 // TODO(mustaq): Remove the PointerEvent specific code when mouse has
48 // fractional coordinates. See crbug.com/655786.
49 double screenX() const {
50 return isPointerEvent() ? m_screenLocation.x()
51 : static_cast<int>(m_screenLocation.x());
52 }
53 double screenY() const {
54 return isPointerEvent() ? m_screenLocation.y()
55 : static_cast<int>(m_screenLocation.y());
56 }
57
58 double clientX() const {
59 return isPointerEvent() ? m_clientLocation.x()
60 : static_cast<int>(m_clientLocation.x());
61 }
62 double clientY() const {
63 return isPointerEvent() ? m_clientLocation.y()
64 : static_cast<int>(m_clientLocation.y());
65 }
66
67 int movementX() const { return m_movementDelta.x(); }
68 int movementY() const { return m_movementDelta.y(); }
69
70 int layerX();
71 int layerY();
72
73 int offsetX();
74 int offsetY();
75
76 double pageX() const {
77 return isPointerEvent() ? m_pageLocation.x()
78 : static_cast<int>(m_pageLocation.x());
79 }
80 double pageY() const {
81 return isPointerEvent() ? m_pageLocation.y()
82 : static_cast<int>(m_pageLocation.y());
83 }
84
85 double x() const { return clientX(); }
86 double y() const { return clientY(); }
87
88 bool hasPosition() const { return m_positionType == PositionType::Position; }
89
90 // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative
91 // coords, usable with LayoutObject::absoluteToLocal) relative to view(), i.e.
92 // the local frame.
93 const DoublePoint& absoluteLocation() const { return m_absoluteLocation; }
94
95 DECLARE_VIRTUAL_TRACE();
96
97 protected:
98 MouseRelatedEvent();
99 // TODO(lanwei): Will make this argument non-optional and all the callers need
100 // to provide sourceCapabilities even when it is null, see
101 // https://crbug.com/476530.
102 MouseRelatedEvent(const AtomicString& type,
103 bool canBubble,
104 bool cancelable,
105 AbstractView*,
106 int detail,
107 const IntPoint& screenLocation,
108 const IntPoint& rootFrameLocation,
109 const IntPoint& movementDelta,
110 PlatformEvent::Modifiers,
111 TimeTicks platformTimeStamp,
112 PositionType,
113 InputDeviceCapabilities* sourceCapabilities = nullptr);
114
115 MouseRelatedEvent(const AtomicString& type,
116 const MouseEventInit& initializer);
117
118 void initCoordinates(const double clientX, const double clientY);
119 void receivedTarget() final;
120
121 void computePageLocation();
122 void computeRelativePosition();
123
124 // Expose these so MouseEvent::initMouseEvent can set them.
125 DoublePoint m_screenLocation;
126 DoublePoint m_clientLocation;
127 DoublePoint m_movementDelta;
128
129 private:
130 DoublePoint m_pageLocation;
131 DoublePoint m_layerLocation;
132 DoublePoint m_offsetLocation;
133 DoublePoint m_absoluteLocation;
134 PositionType m_positionType;
135 bool m_hasCachedRelativePosition;
136 };
137
138 } // namespace blink
139
140 #endif // MouseRelatedEvent_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/MouseEvent.cpp ('k') | third_party/WebKit/Source/core/events/MouseRelatedEvent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698