OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef MouseRelatedEvent_h | 24 #ifndef MouseRelatedEvent_h |
25 #define MouseRelatedEvent_h | 25 #define MouseRelatedEvent_h |
26 | 26 |
27 #include "core/events/UIEventWithKeyState.h" | 27 #include "core/events/UIEventWithKeyState.h" |
28 #include "platform/PlatformMouseEvent.h" | |
28 #include "platform/geometry/LayoutPoint.h" | 29 #include "platform/geometry/LayoutPoint.h" |
29 | 30 |
30 namespace blink { | 31 namespace blink { |
31 | 32 |
32 // Internal only: Helper class for what's common between mouse and wheel eve nts. | 33 // Internal only: Helper class for what's common between mouse and wheel eve nts. |
33 class MouseRelatedEvent : public UIEventWithKeyState { | 34 class MouseRelatedEvent : public UIEventWithKeyState { |
34 public: | 35 public: |
35 // Note that these values are adjusted to counter the effects of zoom, s o that values | 36 // Note that these values are adjusted to counter the effects of zoom, s o that values |
36 // exposed via DOM APIs are invariant under zooming. | 37 // exposed via DOM APIs are invariant under zooming. |
37 int screenX() const { return m_screenLocation.x(); } | 38 int screenX() const { return m_screenLocation.x(); } |
38 int screenY() const { return m_screenLocation.y(); } | 39 int screenY() const { return m_screenLocation.y(); } |
39 const IntPoint& screenLocation() const { return m_screenLocation; } | 40 const IntPoint& screenLocation() const { return m_screenLocation; } |
40 int clientX() const { return m_clientLocation.x(); } | 41 int clientX() const { return m_clientLocation.x(); } |
41 int clientY() const { return m_clientLocation.y(); } | 42 int clientY() const { return m_clientLocation.y(); } |
42 int movementX() const { return m_movementDelta.x(); } | 43 int movementX() const { return m_movementDelta.x(); } |
43 int movementY() const { return m_movementDelta.y(); } | 44 int movementY() const { return m_movementDelta.y(); } |
44 const LayoutPoint& clientLocation() const { return m_clientLocation; } | 45 const LayoutPoint& clientLocation() const { return m_clientLocation; } |
45 virtual int layerX() OVERRIDE FINAL; | 46 virtual int layerX() OVERRIDE FINAL; |
46 virtual int layerY() OVERRIDE FINAL; | 47 virtual int layerY() OVERRIDE FINAL; |
47 int offsetX(); | 48 int offsetX(); |
48 int offsetY(); | 49 int offsetY(); |
50 // FIXME: rename isSimulated to fromKeyboard() and replace m_isSimulated with a new value | |
51 // in PlatformMouseEvent::SyntheticEventType. isSimulated() is only true for synthetic | |
52 // mouse events that derive from keyboard input, which do not have a pos ition. | |
49 bool isSimulated() const { return m_isSimulated; } | 53 bool isSimulated() const { return m_isSimulated; } |
54 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEve nt::FromTouch; } | |
55 bool notFromInput() const { return m_syntheticEventType == PlatformMouse Event::NotFromInput; } | |
50 virtual int pageX() const OVERRIDE FINAL; | 56 virtual int pageX() const OVERRIDE FINAL; |
51 virtual int pageY() const OVERRIDE FINAL; | 57 virtual int pageY() const OVERRIDE FINAL; |
52 int x() const; | 58 int x() const; |
53 int y() const; | 59 int y() const; |
54 | 60 |
55 // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords, | 61 // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coords, |
56 // usable with RenderObject::absoluteToLocal). | 62 // usable with RenderObject::absoluteToLocal). |
57 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } | 63 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } |
58 void setAbsoluteLocation(const LayoutPoint& p) { m_absoluteLocation = p; } | 64 void setAbsoluteLocation(const LayoutPoint& p) { m_absoluteLocation = p; } |
59 | 65 |
60 virtual void trace(Visitor*) OVERRIDE; | 66 virtual void trace(Visitor*) OVERRIDE; |
61 | 67 |
62 protected: | 68 protected: |
63 MouseRelatedEvent(); | 69 MouseRelatedEvent(); |
64 MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancela ble, PassRefPtrWillBeRawPtr<AbstractView>, | 70 MouseRelatedEvent(const AtomicString& type, bool canBubble, bool cancela ble, |
65 int detail, const IntPoint& screenLocation, const IntP oint& windowLocation, | 71 PassRefPtrWillBeRawPtr<AbstractView>, int detail, const IntPoint& sc reenLocation, |
66 const IntPoint& movementDelta, | 72 const IntPoint& windowLocation, const IntPoint& movementDelta, bool ctrlKey, bool altKey, |
67 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey , bool isSimulated = false); | 73 bool shiftKey, bool metaKey, bool isSimulated = false, |
74 PlatformMouseEvent::SyntheticEventType = PlatformMouseEvent::NotSynt heticOrIndistinguishable); | |
68 | 75 |
69 void initCoordinates(); | 76 void initCoordinates(); |
70 void initCoordinates(const LayoutPoint& clientLocation); | 77 void initCoordinates(const LayoutPoint& clientLocation); |
71 virtual void receivedTarget() OVERRIDE FINAL; | 78 virtual void receivedTarget() OVERRIDE FINAL; |
72 | 79 |
73 void computePageLocation(); | 80 void computePageLocation(); |
74 void computeRelativePosition(); | 81 void computeRelativePosition(); |
75 | 82 |
76 // Expose these so MouseEvent::initMouseEvent can set them. | 83 // Expose these so MouseEvent::initMouseEvent can set them. |
77 IntPoint m_screenLocation; | 84 IntPoint m_screenLocation; |
78 LayoutPoint m_clientLocation; | 85 LayoutPoint m_clientLocation; |
79 LayoutPoint m_movementDelta; | 86 LayoutPoint m_movementDelta; |
80 | 87 |
81 private: | 88 private: |
82 LayoutPoint m_pageLocation; | 89 LayoutPoint m_pageLocation; |
83 LayoutPoint m_layerLocation; | 90 LayoutPoint m_layerLocation; |
84 LayoutPoint m_offsetLocation; | 91 LayoutPoint m_offsetLocation; |
85 LayoutPoint m_absoluteLocation; | 92 LayoutPoint m_absoluteLocation; |
86 bool m_isSimulated; | 93 bool m_isSimulated; |
87 bool m_hasCachedRelativePosition; | 94 bool m_hasCachedRelativePosition; |
95 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; | |
Rick Byers
2014/08/22 18:11:13
Adding this to MouseRelatedEvent doesn't really ma
Ignacio Solla
2014/08/26 13:40:53
Done.
| |
88 }; | 96 }; |
89 | 97 |
90 } // namespace blink | 98 } // namespace blink |
91 | 99 |
92 #endif // MouseRelatedEvent_h | 100 #endif // MouseRelatedEvent_h |
OLD | NEW |