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, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
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. |
(...skipping 10 matching lines...) Expand all Loading... |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef UIEventWithKeyState_h | 24 #ifndef UIEventWithKeyState_h |
25 #define UIEventWithKeyState_h | 25 #define UIEventWithKeyState_h |
26 | 26 |
27 #include "core/CoreExport.h" | 27 #include "core/CoreExport.h" |
28 #include "core/events/EventModifierInit.h" | 28 #include "core/events/EventModifierInit.h" |
29 #include "core/events/UIEvent.h" | 29 #include "core/events/UIEvent.h" |
30 #include "platform/PlatformEvent.h" | 30 #include "platform/PlatformEvent.h" |
| 31 #include "public/platform/WebInputEvent.h" |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 | 34 |
34 class CORE_EXPORT UIEventWithKeyState : public UIEvent { | 35 class CORE_EXPORT UIEventWithKeyState : public UIEvent { |
35 public: | 36 public: |
36 bool ctrlKey() const { return m_modifiers & PlatformEvent::CtrlKey; } | 37 bool ctrlKey() const { return m_modifiers & PlatformEvent::CtrlKey; } |
37 bool shiftKey() const { return m_modifiers & PlatformEvent::ShiftKey; } | 38 bool shiftKey() const { return m_modifiers & PlatformEvent::ShiftKey; } |
38 bool altKey() const { return m_modifiers & PlatformEvent::AltKey; } | 39 bool altKey() const { return m_modifiers & PlatformEvent::AltKey; } |
39 bool metaKey() const { return m_modifiers & PlatformEvent::MetaKey; } | 40 bool metaKey() const { return m_modifiers & PlatformEvent::MetaKey; } |
40 | 41 |
41 // We ignore the new tab modifiers (ctrl or meta, depending on OS) set by | 42 // We ignore the new tab modifiers (ctrl or meta, depending on OS) set by |
42 // JavaScript when processing events. However, scripts running in isolated | 43 // JavaScript when processing events. However, scripts running in isolated |
43 // worlds (aka content scripts) are not subject to this restriction. Since it | 44 // worlds (aka content scripts) are not subject to this restriction. Since it |
44 // is possible that an event created by a content script is caught and | 45 // is possible that an event created by a content script is caught and |
45 // recreated by the web page's script, we resort to a global flag. | 46 // recreated by the web page's script, we resort to a global flag. |
46 static bool newTabModifierSetFromIsolatedWorld() { | 47 static bool newTabModifierSetFromIsolatedWorld() { |
47 return s_newTabModifierSetFromIsolatedWorld; | 48 return s_newTabModifierSetFromIsolatedWorld; |
48 } | 49 } |
49 static void clearNewTabModifierSetFromIsolatedWorld() { | 50 static void clearNewTabModifierSetFromIsolatedWorld() { |
50 s_newTabModifierSetFromIsolatedWorld = false; | 51 s_newTabModifierSetFromIsolatedWorld = false; |
51 } | 52 } |
52 static void didCreateEventInIsolatedWorld(bool ctrlKey, | 53 static void didCreateEventInIsolatedWorld(bool ctrlKey, |
53 bool shiftKey, | 54 bool shiftKey, |
54 bool altKey, | 55 bool altKey, |
55 bool metaKey); | 56 bool metaKey); |
56 | 57 |
57 static void setFromPlatformModifiers(EventModifierInit&, | 58 static void setFromPlatformModifiers(EventModifierInit&, |
58 const PlatformEvent::Modifiers); | 59 const PlatformEvent::Modifiers); |
| 60 static void setFromWebInputEventModifiers(EventModifierInit&, |
| 61 WebInputEvent::Modifiers); |
59 | 62 |
60 bool getModifierState(const String& keyIdentifier) const; | 63 bool getModifierState(const String& keyIdentifier) const; |
61 | 64 |
62 PlatformEvent::Modifiers modifiers() const { | 65 PlatformEvent::Modifiers modifiers() const { |
63 return static_cast<PlatformEvent::Modifiers>(m_modifiers); | 66 return static_cast<PlatformEvent::Modifiers>(m_modifiers); |
64 } | 67 } |
65 | 68 |
66 protected: | 69 protected: |
67 UIEventWithKeyState() : m_modifiers(0) {} | 70 UIEventWithKeyState() : m_modifiers(0) {} |
68 | 71 |
(...skipping 13 matching lines...) Expand all Loading... |
82 | 85 |
83 private: | 86 private: |
84 static bool s_newTabModifierSetFromIsolatedWorld; | 87 static bool s_newTabModifierSetFromIsolatedWorld; |
85 }; | 88 }; |
86 | 89 |
87 UIEventWithKeyState* findEventWithKeyState(Event*); | 90 UIEventWithKeyState* findEventWithKeyState(Event*); |
88 | 91 |
89 } // namespace blink | 92 } // namespace blink |
90 | 93 |
91 #endif // UIEventWithKeyState_h | 94 #endif // UIEventWithKeyState_h |
OLD | NEW |