| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 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 INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef PlatformEvent_h | |
| 27 #define PlatformEvent_h | |
| 28 | |
| 29 #include "wtf/Allocator.h" | |
| 30 #include "wtf/Noncopyable.h" | |
| 31 #include "wtf/Time.h" | |
| 32 | |
| 33 namespace blink { | |
| 34 | |
| 35 class PlatformEvent { | |
| 36 public: | |
| 37 enum EventType { | |
| 38 NoType = 0, | |
| 39 }; | |
| 40 | |
| 41 // These values are direct mappings of the values in WebInputEvent so the | |
| 42 // values can be cast between the enumerations. static_asserts checking this | |
| 43 // are in web/WebInputEventConversion.cpp. | |
| 44 enum Modifiers { | |
| 45 NoModifiers = 0, | |
| 46 ShiftKey = 1 << 0, | |
| 47 CtrlKey = 1 << 1, | |
| 48 AltKey = 1 << 2, | |
| 49 MetaKey = 1 << 3, | |
| 50 | |
| 51 IsKeyPad = 1 << 4, | |
| 52 IsAutoRepeat = 1 << 5, | |
| 53 | |
| 54 LeftButtonDown = 1 << 6, | |
| 55 MiddleButtonDown = 1 << 7, | |
| 56 RightButtonDown = 1 << 8, | |
| 57 | |
| 58 CapsLockOn = 1 << 9, | |
| 59 NumLockOn = 1 << 10, | |
| 60 | |
| 61 IsLeft = 1 << 11, | |
| 62 IsRight = 1 << 12, | |
| 63 IsTouchAccessibility = 1 << 13, | |
| 64 IsComposing = 1 << 14, | |
| 65 | |
| 66 AltGrKey = 1 << 15, | |
| 67 FnKey = 1 << 16, | |
| 68 SymbolKey = 1 << 17, | |
| 69 | |
| 70 ScrollLockOn = 1 << 18, | |
| 71 | |
| 72 // The set of non-stateful modifiers that specifically change the | |
| 73 // interpretation of the key being pressed. For example; IsLeft, | |
| 74 // IsRight, IsComposing don't change the meaning of the key | |
| 75 // being pressed. NumLockOn, ScrollLockOn, CapsLockOn are stateful | |
| 76 // and don't indicate explicit depressed state. | |
| 77 KeyModifiers = | |
| 78 SymbolKey | FnKey | AltGrKey | MetaKey | AltKey | CtrlKey | ShiftKey, | |
| 79 }; | |
| 80 | |
| 81 | |
| 82 EventType type() const { return static_cast<EventType>(m_type); } | |
| 83 | |
| 84 bool shiftKey() const { return m_modifiers & ShiftKey; } | |
| 85 bool ctrlKey() const { return m_modifiers & CtrlKey; } | |
| 86 bool altKey() const { return m_modifiers & AltKey; } | |
| 87 bool metaKey() const { return m_modifiers & MetaKey; } | |
| 88 | |
| 89 Modifiers getModifiers() const { return static_cast<Modifiers>(m_modifiers); } | |
| 90 | |
| 91 TimeTicks timestamp() const { return m_timestamp; } | |
| 92 | |
| 93 protected: | |
| 94 PlatformEvent() : m_type(NoType), m_modifiers() {} | |
| 95 | |
| 96 explicit PlatformEvent(EventType type) : m_type(type), m_modifiers(0) {} | |
| 97 | |
| 98 PlatformEvent(EventType type, Modifiers modifiers, TimeTicks timestamp) | |
| 99 : m_type(type), m_modifiers(modifiers), m_timestamp(timestamp) {} | |
| 100 | |
| 101 // Explicit protected destructor so that people don't accidentally | |
| 102 // delete a PlatformEvent. | |
| 103 ~PlatformEvent() {} | |
| 104 | |
| 105 unsigned m_type; | |
| 106 unsigned m_modifiers; | |
| 107 TimeTicks m_timestamp; | |
| 108 }; | |
| 109 | |
| 110 } // namespace blink | |
| 111 | |
| 112 #endif // PlatformEvent_h | |
| OLD | NEW |