| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef PlatformMouseEvent_h | |
| 27 #define PlatformMouseEvent_h | |
| 28 | |
| 29 #include "platform/PlatformEvent.h" | |
| 30 #include "platform/geometry/FloatPoint.h" | |
| 31 #include "platform/geometry/IntPoint.h" | |
| 32 #include "public/platform/WebGestureEvent.h" | |
| 33 #include "public/platform/WebPointerProperties.h" | |
| 34 #include "wtf/text/WTFString.h" | |
| 35 | |
| 36 namespace blink { | |
| 37 | |
| 38 class PlatformMouseEvent : public PlatformEvent { | |
| 39 public: | |
| 40 enum SyntheticEventType { | |
| 41 // Real mouse input events or synthetic events that behave just like real | |
| 42 // events | |
| 43 RealOrIndistinguishable, | |
| 44 // Synthetic mouse events derived from touch input | |
| 45 FromTouch, | |
| 46 // Synthetic mouse events generated without a position, for example those | |
| 47 // generated from keyboard input. | |
| 48 Positionless, | |
| 49 }; | |
| 50 | |
| 51 PlatformMouseEvent() : PlatformMouseEvent(PlatformEvent::MouseMoved) {} | |
| 52 | |
| 53 explicit PlatformMouseEvent(EventType type) | |
| 54 : PlatformEvent(type), | |
| 55 m_clickCount(0), | |
| 56 m_synthesized(RealOrIndistinguishable) {} | |
| 57 | |
| 58 PlatformMouseEvent(const IntPoint& position, | |
| 59 const IntPoint& globalPosition, | |
| 60 WebPointerProperties::Button button, | |
| 61 EventType type, | |
| 62 int clickCount, | |
| 63 Modifiers modifiers, | |
| 64 TimeTicks timestamp) | |
| 65 : PlatformEvent(type, modifiers, timestamp), | |
| 66 m_position(position), | |
| 67 m_globalPosition(globalPosition), | |
| 68 m_clickCount(clickCount), | |
| 69 m_synthesized(RealOrIndistinguishable) { | |
| 70 m_pointerProperties.button = button; | |
| 71 } | |
| 72 | |
| 73 PlatformMouseEvent(const IntPoint& position, | |
| 74 const IntPoint& globalPosition, | |
| 75 WebPointerProperties::Button button, | |
| 76 EventType type, | |
| 77 int clickCount, | |
| 78 Modifiers modifiers, | |
| 79 SyntheticEventType synthesized, | |
| 80 TimeTicks timestamp, | |
| 81 WebPointerProperties::PointerType pointerType = | |
| 82 WebPointerProperties::PointerType::Unknown) | |
| 83 : PlatformEvent(type, modifiers, timestamp), | |
| 84 m_position(position), | |
| 85 m_globalPosition(globalPosition), | |
| 86 m_clickCount(clickCount), | |
| 87 m_synthesized(synthesized) { | |
| 88 m_pointerProperties.pointerType = pointerType; | |
| 89 m_pointerProperties.button = button; | |
| 90 } | |
| 91 | |
| 92 #if INSIDE_BLINK | |
| 93 PlatformMouseEvent(const WebGestureEvent& gestureEvent, | |
| 94 WebPointerProperties::Button button, | |
| 95 EventType type, | |
| 96 int clickCount, | |
| 97 Modifiers modifiers, | |
| 98 SyntheticEventType synthesized, | |
| 99 TimeTicks timestamp, | |
| 100 WebPointerProperties::PointerType pointerType = | |
| 101 WebPointerProperties::PointerType::Unknown) | |
| 102 : PlatformMouseEvent(flooredIntPoint(gestureEvent.positionInRootFrame()), | |
| 103 IntPoint(gestureEvent.globalX, gestureEvent.globalY), | |
| 104 button, | |
| 105 type, | |
| 106 clickCount, | |
| 107 modifiers, | |
| 108 synthesized, | |
| 109 timestamp, | |
| 110 pointerType) {} | |
| 111 #endif | |
| 112 | |
| 113 const WebPointerProperties& pointerProperties() const { | |
| 114 return m_pointerProperties; | |
| 115 } | |
| 116 const IntPoint& position() const { return m_position; } | |
| 117 const IntPoint& globalPosition() const { return m_globalPosition; } | |
| 118 const IntPoint& movementDelta() const { return m_movementDelta; } | |
| 119 | |
| 120 int clickCount() const { return m_clickCount; } | |
| 121 bool fromTouch() const { return m_synthesized == FromTouch; } | |
| 122 SyntheticEventType getSyntheticEventType() const { return m_synthesized; } | |
| 123 | |
| 124 const String& region() const { return m_region; } | |
| 125 void setRegion(const String& region) { m_region = region; } | |
| 126 | |
| 127 protected: | |
| 128 WebPointerProperties m_pointerProperties; | |
| 129 | |
| 130 // In local root frame coordinates. (Except possibly if the Widget under | |
| 131 // the mouse is a popup, see FIXME in PlatformMouseEventBuilder). | |
| 132 IntPoint m_position; | |
| 133 | |
| 134 // In screen coordinates. | |
| 135 IntPoint m_globalPosition; | |
| 136 | |
| 137 IntPoint m_movementDelta; | |
| 138 int m_clickCount; | |
| 139 SyntheticEventType m_synthesized; | |
| 140 | |
| 141 // For canvas hit region. | |
| 142 // TODO(zino): This might make more sense to put in HitTestResults or | |
| 143 // some other part of MouseEventWithHitTestResults, but for now it's | |
| 144 // most convenient to stash it here. Please see: http://crbug.com/592947. | |
| 145 String m_region; | |
| 146 }; | |
| 147 | |
| 148 } // namespace blink | |
| 149 | |
| 150 #endif // PlatformMouseEvent_h | |
| OLD | NEW |