Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 // found in the LICENSE file. |
| 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. | |
| 6 * | |
| 7 * This library is free software; you can redistribute it and/or | |
| 8 * modify it under the terms of the GNU Library General Public | |
| 9 * License as published by the Free Software Foundation; either | |
| 10 * version 2 of the License, or (at your option) any later version. | |
| 11 * | |
| 12 * This library is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 * Library General Public License for more details. | |
| 16 * | |
| 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 | |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 20 * Boston, MA 02110-1301, USA. | |
| 21 * | |
| 22 */ | |
| 23 | 4 |
| 24 #ifndef SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ | 5 #ifndef SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ |
| 25 #define SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ | 6 #define SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ |
| 26 | 7 |
| 27 #include "sky/engine/core/events/EventDispatchMediator.h" | 8 #include "sky/engine/core/events/Event.h" |
| 28 #include "sky/engine/core/events/UIEventWithKeyState.h" | 9 #include "sky/engine/public/platform/WebInputEvent.h" |
| 29 | 10 |
| 30 namespace blink { | 11 namespace blink { |
| 31 | 12 |
| 32 class EventDispatcher; | 13 struct KeyboardEventInit : public EventInit { |
| 33 class Node; | 14 unsigned virtualKeyCode = 0; |
| 34 class PlatformKeyboardEvent; | 15 String location; |
| 35 | 16 unsigned charCode = 0; |
| 36 struct KeyboardEventInit : public UIEventInit { | 17 bool ctrlKey = false; |
| 37 KeyboardEventInit(); | 18 bool shiftKey = false; |
| 38 | 19 bool altKey = false; |
| 39 String keyIdentifier; | 20 bool metaKey = false; |
| 40 unsigned location; | 21 bool repeat = false; |
| 41 bool ctrlKey; | |
| 42 bool altKey; | |
| 43 bool shiftKey; | |
| 44 bool metaKey; | |
| 45 bool repeat; | |
| 46 }; | 22 }; |
| 47 | 23 |
| 48 class KeyboardEvent final : public UIEventWithKeyState { | 24 class KeyboardEvent : public Event { |
| 49 DEFINE_WRAPPERTYPEINFO(); | 25 DEFINE_WRAPPERTYPEINFO(); |
| 50 public: | 26 public: |
| 51 enum KeyLocationCode { | |
| 52 DOM_KEY_LOCATION_STANDARD = 0x00, | |
| 53 DOM_KEY_LOCATION_LEFT = 0x01, | |
| 54 DOM_KEY_LOCATION_RIGHT = 0x02, | |
| 55 DOM_KEY_LOCATION_NUMPAD = 0x03 | |
| 56 }; | |
| 57 | |
| 58 static PassRefPtr<KeyboardEvent> create() | 27 static PassRefPtr<KeyboardEvent> create() |
| 59 { | 28 { |
| 60 return adoptRef(new KeyboardEvent); | 29 return adoptRef(new KeyboardEvent); |
| 61 } | 30 } |
| 62 | 31 static PassRefPtr<KeyboardEvent> create(const WebKeyboardEvent& event) |
| 63 static PassRefPtr<KeyboardEvent> create(const PlatformKeyboardEvent& platfor mEvent, AbstractView* view) | |
| 64 { | 32 { |
| 65 return adoptRef(new KeyboardEvent(platformEvent, view)); | 33 return adoptRef(new KeyboardEvent(event)); |
| 66 } | 34 } |
| 67 | |
| 68 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, const Keyb oardEventInit& initializer) | 35 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, const Keyb oardEventInit& initializer) |
| 69 { | 36 { |
| 70 return adoptRef(new KeyboardEvent(type, initializer)); | 37 return adoptRef(new KeyboardEvent(type, initializer)); |
| 71 } | 38 } |
| 72 | 39 |
| 73 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, bool canBu bble, bool cancelable, AbstractView* view, | 40 ~KeyboardEvent() override; |
| 74 const String& keyIdentifier, unsigned location, | 41 const AtomicString& interfaceName() const override; |
| 75 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) | |
| 76 { | |
| 77 return adoptRef(new KeyboardEvent(type, canBubble, cancelable, view, key Identifier, location, | |
| 78 ctrlKey, altKey, shiftKey, metaKey)); | |
| 79 } | |
| 80 | 42 |
| 81 virtual ~KeyboardEvent(); | 43 bool isKeyboardEvent() const override; |
| 82 | 44 |
| 83 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancel able, AbstractView*, | 45 unsigned virtualKeyCode() const { return m_virtualKeyCode; } |
|
ojan
2015/01/26 06:18:51
FWIW, virtual keycode means something to windows d
abarth-chromium
2015/01/26 06:28:16
You need to use codes for some keys because not al
abarth-chromium
2015/01/26 06:38:51
I renamed this to "key"
| |
| 84 const String& keyIdentifier, unsigned location, | 46 const String& location() const { return m_location; } |
| 85 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); | 47 unsigned charCode() const { return m_charCode; } |
| 86 | 48 bool ctrlKey() const { return m_ctrlKey; } |
| 87 const String& keyIdentifier() const { return m_keyIdentifier; } | 49 bool shiftKey() const { return m_shiftKey; } |
| 88 unsigned location() const { return m_location; } | 50 bool altKey() const { return m_altKey; } |
| 89 | 51 bool metaKey() const { return m_metaKey; } |
| 90 bool getModifierState(const String& keyIdentifier) const; | 52 bool repeat() const { return m_repeat; } |
| 91 | |
| 92 const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); } | |
| 93 | |
| 94 virtual int keyCode() const override; // key code for keydown and keyup, cha racter for keypress | |
| 95 virtual int charCode() const override; // character code for keypress, 0 for keydown and keyup | |
| 96 bool repeat() const { return m_isAutoRepeat; } | |
| 97 | |
| 98 virtual const AtomicString& interfaceName() const override; | |
| 99 virtual bool isKeyboardEvent() const override; | |
| 100 virtual int which() const override; | |
| 101 | 53 |
| 102 private: | 54 private: |
| 103 KeyboardEvent(); | 55 KeyboardEvent(); |
| 104 KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*); | 56 explicit KeyboardEvent(const WebKeyboardEvent& event); |
| 105 KeyboardEvent(const AtomicString&, const KeyboardEventInit&); | 57 KeyboardEvent(const AtomicString&, const KeyboardEventInit&); |
| 106 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, Abs tractView*, | |
| 107 const String& keyIdentifier, unsigned location, | |
| 108 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); | |
| 109 | 58 |
| 110 OwnPtr<PlatformKeyboardEvent> m_keyEvent; | 59 unsigned m_virtualKeyCode; |
| 111 String m_keyIdentifier; | 60 String m_location; |
| 112 unsigned m_location; | 61 unsigned m_charCode; |
| 113 bool m_isAutoRepeat : 1; | 62 bool m_ctrlKey; |
| 114 }; | 63 bool m_shiftKey; |
| 115 | 64 bool m_altKey; |
| 116 class KeyboardEventDispatchMediator : public EventDispatchMediator { | 65 bool m_metaKey; |
| 117 public: | 66 bool m_repeat; |
| 118 static PassRefPtr<KeyboardEventDispatchMediator> create(PassRefPtr<KeyboardE vent>); | |
| 119 private: | |
| 120 explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>); | |
| 121 virtual bool dispatchEvent(EventDispatcher*) const override; | |
| 122 }; | 67 }; |
| 123 | 68 |
| 124 DEFINE_EVENT_TYPE_CASTS(KeyboardEvent); | 69 DEFINE_EVENT_TYPE_CASTS(KeyboardEvent); |
| 125 | 70 |
| 126 } // namespace blink | 71 } // namespace blink |
| 127 | 72 |
| 128 #endif // SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ | 73 #endif // SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ |
| OLD | NEW |