Index: sky/engine/core/events/KeyboardEvent.h |
diff --git a/sky/engine/core/events/KeyboardEvent.h b/sky/engine/core/events/KeyboardEvent.h |
index c5e5c3c69b94e31c7ec96a47f81d79b012e1c942..736e63219390011a3b5b370944d5d63fb9173c87 100644 |
--- a/sky/engine/core/events/KeyboardEvent.h |
+++ b/sky/engine/core/events/KeyboardEvent.h |
@@ -1,124 +1,69 @@ |
-/* |
- * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
- * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
- * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
- * |
- * This library is free software; you can redistribute it and/or |
- * modify it under the terms of the GNU Library General Public |
- * License as published by the Free Software Foundation; either |
- * version 2 of the License, or (at your option) any later version. |
- * |
- * This library is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
- * Library General Public License for more details. |
- * |
- * You should have received a copy of the GNU Library General Public License |
- * along with this library; see the file COPYING.LIB. If not, write to |
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
- * Boston, MA 02110-1301, USA. |
- * |
- */ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
#ifndef SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ |
#define SKY_ENGINE_CORE_EVENTS_KEYBOARDEVENT_H_ |
-#include "sky/engine/core/events/EventDispatchMediator.h" |
-#include "sky/engine/core/events/UIEventWithKeyState.h" |
+#include "sky/engine/core/events/Event.h" |
+#include "sky/engine/public/platform/WebInputEvent.h" |
namespace blink { |
-class EventDispatcher; |
-class Node; |
-class PlatformKeyboardEvent; |
- |
-struct KeyboardEventInit : public UIEventInit { |
- KeyboardEventInit(); |
- |
- String keyIdentifier; |
- unsigned location; |
- bool ctrlKey; |
- bool altKey; |
- bool shiftKey; |
- bool metaKey; |
- bool repeat; |
+struct KeyboardEventInit : public EventInit { |
+ unsigned virtualKeyCode = 0; |
+ String location; |
+ unsigned charCode = 0; |
+ bool ctrlKey = false; |
+ bool shiftKey = false; |
+ bool altKey = false; |
+ bool metaKey = false; |
+ bool repeat = false; |
}; |
-class KeyboardEvent final : public UIEventWithKeyState { |
+class KeyboardEvent : public Event { |
DEFINE_WRAPPERTYPEINFO(); |
public: |
- enum KeyLocationCode { |
- DOM_KEY_LOCATION_STANDARD = 0x00, |
- DOM_KEY_LOCATION_LEFT = 0x01, |
- DOM_KEY_LOCATION_RIGHT = 0x02, |
- DOM_KEY_LOCATION_NUMPAD = 0x03 |
- }; |
- |
static PassRefPtr<KeyboardEvent> create() |
{ |
return adoptRef(new KeyboardEvent); |
} |
- |
- static PassRefPtr<KeyboardEvent> create(const PlatformKeyboardEvent& platformEvent, AbstractView* view) |
+ static PassRefPtr<KeyboardEvent> create(const WebKeyboardEvent& event) |
{ |
- return adoptRef(new KeyboardEvent(platformEvent, view)); |
+ return adoptRef(new KeyboardEvent(event)); |
} |
- |
static PassRefPtr<KeyboardEvent> create(const AtomicString& type, const KeyboardEventInit& initializer) |
{ |
return adoptRef(new KeyboardEvent(type, initializer)); |
} |
- static PassRefPtr<KeyboardEvent> create(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view, |
- const String& keyIdentifier, unsigned location, |
- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) |
- { |
- return adoptRef(new KeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, location, |
- ctrlKey, altKey, shiftKey, metaKey)); |
- } |
- |
- virtual ~KeyboardEvent(); |
+ ~KeyboardEvent() override; |
+ const AtomicString& interfaceName() const override; |
- void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*, |
- const String& keyIdentifier, unsigned location, |
- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); |
+ bool isKeyboardEvent() const override; |
- const String& keyIdentifier() const { return m_keyIdentifier; } |
- unsigned location() const { return m_location; } |
- |
- bool getModifierState(const String& keyIdentifier) const; |
- |
- const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); } |
- |
- virtual int keyCode() const override; // key code for keydown and keyup, character for keypress |
- virtual int charCode() const override; // character code for keypress, 0 for keydown and keyup |
- bool repeat() const { return m_isAutoRepeat; } |
- |
- virtual const AtomicString& interfaceName() const override; |
- virtual bool isKeyboardEvent() const override; |
- virtual int which() const override; |
+ 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"
|
+ const String& location() const { return m_location; } |
+ unsigned charCode() const { return m_charCode; } |
+ bool ctrlKey() const { return m_ctrlKey; } |
+ bool shiftKey() const { return m_shiftKey; } |
+ bool altKey() const { return m_altKey; } |
+ bool metaKey() const { return m_metaKey; } |
+ bool repeat() const { return m_repeat; } |
private: |
KeyboardEvent(); |
- KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*); |
+ explicit KeyboardEvent(const WebKeyboardEvent& event); |
KeyboardEvent(const AtomicString&, const KeyboardEventInit&); |
- KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*, |
- const String& keyIdentifier, unsigned location, |
- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); |
- OwnPtr<PlatformKeyboardEvent> m_keyEvent; |
- String m_keyIdentifier; |
- unsigned m_location; |
- bool m_isAutoRepeat : 1; |
-}; |
- |
-class KeyboardEventDispatchMediator : public EventDispatchMediator { |
-public: |
- static PassRefPtr<KeyboardEventDispatchMediator> create(PassRefPtr<KeyboardEvent>); |
-private: |
- explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>); |
- virtual bool dispatchEvent(EventDispatcher*) const override; |
+ unsigned m_virtualKeyCode; |
+ String m_location; |
+ unsigned m_charCode; |
+ bool m_ctrlKey; |
+ bool m_shiftKey; |
+ bool m_altKey; |
+ bool m_metaKey; |
+ bool m_repeat; |
}; |
DEFINE_EVENT_TYPE_CASTS(KeyboardEvent); |