OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 15 matching lines...) Expand all Loading... |
26 #ifndef PlatformMouseEvent_h | 26 #ifndef PlatformMouseEvent_h |
27 #define PlatformMouseEvent_h | 27 #define PlatformMouseEvent_h |
28 | 28 |
29 #include "platform/PlatformEvent.h" | 29 #include "platform/PlatformEvent.h" |
30 #include "platform/geometry/IntPoint.h" | 30 #include "platform/geometry/IntPoint.h" |
31 #include "public/platform/WebPointerProperties.h" | 31 #include "public/platform/WebPointerProperties.h" |
32 #include "wtf/text/WTFString.h" | 32 #include "wtf/text/WTFString.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
| 36 // These button numbers match the ones used in the DOM API, 0 through 2, except
for NoButton which is specified in PointerEvent |
| 37 // spec but not in MouseEvent spec. |
| 38 enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton }; |
| 39 |
36 class PlatformMouseEvent : public PlatformEvent { | 40 class PlatformMouseEvent : public PlatformEvent { |
37 public: | 41 public: |
38 enum SyntheticEventType { | 42 enum SyntheticEventType { |
39 // Real mouse input events or synthetic events that behave just like rea
l events | 43 // Real mouse input events or synthetic events that behave just like rea
l events |
40 RealOrIndistinguishable, | 44 RealOrIndistinguishable, |
41 // Synthetic mouse events derived from touch input | 45 // Synthetic mouse events derived from touch input |
42 FromTouch, | 46 FromTouch, |
43 // Synthetic mouse events generated without a position, for example thos
e generated | 47 // Synthetic mouse events generated without a position, for example thos
e generated |
44 // from keyboard input. | 48 // from keyboard input. |
45 Positionless, | 49 Positionless, |
46 }; | 50 }; |
47 | 51 |
48 PlatformMouseEvent() | 52 PlatformMouseEvent() |
49 : PlatformEvent(PlatformEvent::MouseMoved) | 53 : PlatformEvent(PlatformEvent::MouseMoved) |
| 54 , m_button(NoButton) |
50 , m_clickCount(0) | 55 , m_clickCount(0) |
51 , m_synthesized(RealOrIndistinguishable) | 56 , m_synthesized(RealOrIndistinguishable) |
52 { | 57 { |
53 } | 58 } |
54 | 59 |
55 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition,
WebPointerProperties::Button button, EventType type, int clickCount, Modifiers
modifiers, double timestamp) | 60 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition,
MouseButton button, EventType type, int clickCount, Modifiers modifiers, double
timestamp) |
56 : PlatformEvent(type, modifiers, timestamp) | 61 : PlatformEvent(type, modifiers, timestamp) |
57 , m_position(position) | 62 , m_position(position) |
58 , m_globalPosition(globalPosition) | 63 , m_globalPosition(globalPosition) |
| 64 , m_button(button) |
59 , m_clickCount(clickCount) | 65 , m_clickCount(clickCount) |
60 , m_synthesized(RealOrIndistinguishable) | 66 , m_synthesized(RealOrIndistinguishable) |
61 { | 67 { |
62 m_pointerProperties.button = button; | |
63 } | 68 } |
64 | 69 |
65 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition,
WebPointerProperties::Button button, EventType type, int clickCount, Modifiers
modifiers, SyntheticEventType synthesized, double timestamp, WebPointerPropertie
s::PointerType pointerType = WebPointerProperties::PointerType::Unknown) | 70 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition,
MouseButton button, EventType type, int clickCount, Modifiers modifiers, Synthe
ticEventType synthesized, double timestamp, WebPointerProperties::PointerType po
interType = WebPointerProperties::PointerType::Unknown) |
66 : PlatformEvent(type, modifiers, timestamp) | 71 : PlatformEvent(type, modifiers, timestamp) |
67 , m_position(position) | 72 , m_position(position) |
68 , m_globalPosition(globalPosition) | 73 , m_globalPosition(globalPosition) |
| 74 , m_button(button) |
69 , m_clickCount(clickCount) | 75 , m_clickCount(clickCount) |
70 , m_synthesized(synthesized) | 76 , m_synthesized(synthesized) |
71 { | 77 { |
72 m_pointerProperties.pointerType = pointerType; | 78 m_pointerProperties.pointerType = pointerType; |
73 m_pointerProperties.button = button; | |
74 } | 79 } |
75 | 80 |
76 const WebPointerProperties& pointerProperties() const { return m_pointerProp
erties; } | 81 const WebPointerProperties& pointerProperties() const { return m_pointerProp
erties; } |
77 const IntPoint& position() const { return m_position; } | 82 const IntPoint& position() const { return m_position; } |
78 const IntPoint& globalPosition() const { return m_globalPosition; } | 83 const IntPoint& globalPosition() const { return m_globalPosition; } |
79 const IntPoint& movementDelta() const { return m_movementDelta; } | 84 const IntPoint& movementDelta() const { return m_movementDelta; } |
80 | 85 |
| 86 MouseButton button() const { return m_button; } |
81 int clickCount() const { return m_clickCount; } | 87 int clickCount() const { return m_clickCount; } |
82 bool fromTouch() const { return m_synthesized == FromTouch; } | 88 bool fromTouch() const { return m_synthesized == FromTouch; } |
83 SyntheticEventType getSyntheticEventType() const { return m_synthesized; } | 89 SyntheticEventType getSyntheticEventType() const { return m_synthesized; } |
84 | 90 |
85 const String& region() const { return m_region; } | 91 const String& region() const { return m_region; } |
86 void setRegion(const String& region) { m_region = region; } | 92 void setRegion(const String& region) { m_region = region; } |
87 | 93 |
88 protected: | 94 protected: |
89 WebPointerProperties m_pointerProperties; | 95 WebPointerProperties m_pointerProperties; |
90 | 96 |
91 // In local root frame coordinates. (Except possibly if the Widget under | 97 // In local root frame coordinates. (Except possibly if the Widget under |
92 // the mouse is a popup, see FIXME in PlatformMouseEventBuilder). | 98 // the mouse is a popup, see FIXME in PlatformMouseEventBuilder). |
93 IntPoint m_position; | 99 IntPoint m_position; |
94 | 100 |
95 // In screen coordinates. | 101 // In screen coordinates. |
96 IntPoint m_globalPosition; | 102 IntPoint m_globalPosition; |
97 | 103 |
98 IntPoint m_movementDelta; | 104 IntPoint m_movementDelta; |
| 105 MouseButton m_button; |
99 int m_clickCount; | 106 int m_clickCount; |
100 SyntheticEventType m_synthesized; | 107 SyntheticEventType m_synthesized; |
101 | 108 |
102 // For canvas hit region. | 109 // For canvas hit region. |
103 // TODO(zino): This might make more sense to put in HitTestResults or | 110 // TODO(zino): This might make more sense to put in HitTestResults or |
104 // some other part of MouseEventWithHitTestResults, but for now it's | 111 // some other part of MouseEventWithHitTestResults, but for now it's |
105 // most convenient to stash it here. Please see: http://crbug.com/592947. | 112 // most convenient to stash it here. Please see: http://crbug.com/592947. |
106 String m_region; | 113 String m_region; |
107 }; | 114 }; |
108 | 115 |
109 } // namespace blink | 116 } // namespace blink |
110 | 117 |
111 #endif // PlatformMouseEvent_h | 118 #endif // PlatformMouseEvent_h |
OLD | NEW |