| 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. |
| 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 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" | |
| 31 #include "public/platform/WebInputEvent.h" | 30 #include "public/platform/WebInputEvent.h" |
| 32 | 31 |
| 33 namespace blink { | 32 namespace blink { |
| 34 | 33 |
| 35 class CORE_EXPORT UIEventWithKeyState : public UIEvent { | 34 class CORE_EXPORT UIEventWithKeyState : public UIEvent { |
| 36 public: | 35 public: |
| 37 bool ctrlKey() const { return m_modifiers & PlatformEvent::CtrlKey; } | 36 bool ctrlKey() const { return m_modifiers & WebInputEvent::ControlKey; } |
| 38 bool shiftKey() const { return m_modifiers & PlatformEvent::ShiftKey; } | 37 bool shiftKey() const { return m_modifiers & WebInputEvent::ShiftKey; } |
| 39 bool altKey() const { return m_modifiers & PlatformEvent::AltKey; } | 38 bool altKey() const { return m_modifiers & WebInputEvent::AltKey; } |
| 40 bool metaKey() const { return m_modifiers & PlatformEvent::MetaKey; } | 39 bool metaKey() const { return m_modifiers & WebInputEvent::MetaKey; } |
| 41 | 40 |
| 42 // We ignore the new tab modifiers (ctrl or meta, depending on OS) set by | 41 // We ignore the new tab modifiers (ctrl or meta, depending on OS) set by |
| 43 // JavaScript when processing events. However, scripts running in isolated | 42 // JavaScript when processing events. However, scripts running in isolated |
| 44 // worlds (aka content scripts) are not subject to this restriction. Since it | 43 // worlds (aka content scripts) are not subject to this restriction. Since it |
| 45 // is possible that an event created by a content script is caught and | 44 // is possible that an event created by a content script is caught and |
| 46 // recreated by the web page's script, we resort to a global flag. | 45 // recreated by the web page's script, we resort to a global flag. |
| 47 static bool newTabModifierSetFromIsolatedWorld() { | 46 static bool newTabModifierSetFromIsolatedWorld() { |
| 48 return s_newTabModifierSetFromIsolatedWorld; | 47 return s_newTabModifierSetFromIsolatedWorld; |
| 49 } | 48 } |
| 50 static void clearNewTabModifierSetFromIsolatedWorld() { | 49 static void clearNewTabModifierSetFromIsolatedWorld() { |
| 51 s_newTabModifierSetFromIsolatedWorld = false; | 50 s_newTabModifierSetFromIsolatedWorld = false; |
| 52 } | 51 } |
| 53 static void didCreateEventInIsolatedWorld(bool ctrlKey, | 52 static void didCreateEventInIsolatedWorld(bool ctrlKey, |
| 54 bool shiftKey, | 53 bool shiftKey, |
| 55 bool altKey, | 54 bool altKey, |
| 56 bool metaKey); | 55 bool metaKey); |
| 57 | 56 |
| 58 static void setFromPlatformModifiers(EventModifierInit&, | |
| 59 const PlatformEvent::Modifiers); | |
| 60 static void setFromWebInputEventModifiers(EventModifierInit&, | 57 static void setFromWebInputEventModifiers(EventModifierInit&, |
| 61 WebInputEvent::Modifiers); | 58 WebInputEvent::Modifiers); |
| 62 | 59 |
| 63 bool getModifierState(const String& keyIdentifier) const; | 60 bool getModifierState(const String& keyIdentifier) const; |
| 64 | 61 |
| 65 PlatformEvent::Modifiers modifiers() const { | 62 WebInputEvent::Modifiers modifiers() const { |
| 66 return static_cast<PlatformEvent::Modifiers>(m_modifiers); | 63 return static_cast<WebInputEvent::Modifiers>(m_modifiers); |
| 67 } | 64 } |
| 68 | 65 |
| 69 protected: | 66 protected: |
| 70 UIEventWithKeyState() : m_modifiers(0) {} | 67 UIEventWithKeyState() : m_modifiers(0) {} |
| 71 | 68 |
| 72 UIEventWithKeyState(const AtomicString& type, | 69 UIEventWithKeyState(const AtomicString& type, |
| 73 bool canBubble, | 70 bool canBubble, |
| 74 bool cancelable, | 71 bool cancelable, |
| 75 AbstractView*, | 72 AbstractView*, |
| 76 int detail, | 73 int detail, |
| 77 PlatformEvent::Modifiers, | 74 WebInputEvent::Modifiers, |
| 78 TimeTicks platformTimeStamp, | 75 TimeTicks platformTimeStamp, |
| 79 InputDeviceCapabilities* sourceCapabilities = nullptr); | 76 InputDeviceCapabilities* sourceCapabilities = nullptr); |
| 80 UIEventWithKeyState(const AtomicString& type, | 77 UIEventWithKeyState(const AtomicString& type, |
| 81 const EventModifierInit& initializer); | 78 const EventModifierInit& initializer); |
| 82 void initModifiers(bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); | 79 void initModifiers(bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); |
| 83 | 80 |
| 84 unsigned m_modifiers; | 81 unsigned m_modifiers; |
| 85 | 82 |
| 86 private: | 83 private: |
| 87 static bool s_newTabModifierSetFromIsolatedWorld; | 84 static bool s_newTabModifierSetFromIsolatedWorld; |
| 88 }; | 85 }; |
| 89 | 86 |
| 90 UIEventWithKeyState* findEventWithKeyState(Event*); | 87 UIEventWithKeyState* findEventWithKeyState(Event*); |
| 91 | 88 |
| 92 } // namespace blink | 89 } // namespace blink |
| 93 | 90 |
| 94 #endif // UIEventWithKeyState_h | 91 #endif // UIEventWithKeyState_h |
| OLD | NEW |