Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: Source/core/events/KeyboardEvent.h

Issue 26558004: Revert 158219 "Move dom/*Event* to events to match the DOM vs. E..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1651/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/events/HashChangeEvent.idl ('k') | Source/core/events/KeyboardEvent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
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
24 #ifndef KeyboardEvent_h
25 #define KeyboardEvent_h
26
27 #include "core/events/EventDispatchMediator.h"
28 #include "core/events/UIEventWithKeyState.h"
29
30 namespace WebCore {
31
32 class EventDispatcher;
33 class Node;
34 class PlatformKeyboardEvent;
35
36 struct KeyboardEventInit : public UIEventInit {
37 KeyboardEventInit();
38
39 String keyIdentifier;
40 unsigned location;
41 bool ctrlKey;
42 bool altKey;
43 bool shiftKey;
44 bool metaKey;
45 };
46
47 class KeyboardEvent : public UIEventWithKeyState {
48 public:
49 enum KeyLocationCode {
50 DOM_KEY_LOCATION_STANDARD = 0x00,
51 DOM_KEY_LOCATION_LEFT = 0x01,
52 DOM_KEY_LOCATION_RIGHT = 0x02,
53 DOM_KEY_LOCATION_NUMPAD = 0x03
54 };
55
56 static PassRefPtr<KeyboardEvent> create()
57 {
58 return adoptRef(new KeyboardEvent);
59 }
60
61 static PassRefPtr<KeyboardEvent> create(const PlatformKeyboardEvent& platfor mEvent, AbstractView* view)
62 {
63 return adoptRef(new KeyboardEvent(platformEvent, view));
64 }
65
66 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, const Keyb oardEventInit& initializer)
67 {
68 return adoptRef(new KeyboardEvent(type, initializer));
69 }
70
71 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, bool canBu bble, bool cancelable, AbstractView* view,
72 const String& keyIdentifier, unsigned location,
73 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey )
74 {
75 return adoptRef(new KeyboardEvent(type, canBubble, cancelable, view, key Identifier, location,
76 ctrlKey, altKey, shiftKey, metaKey, altGraphKey));
77 }
78
79 virtual ~KeyboardEvent();
80
81 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancel able, AbstractView*,
82 const String& keyIdentifier, unsigned location,
83 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey = false);
84
85 const String& keyIdentifier() const { return m_keyIdentifier; }
86 unsigned location() const { return m_location; }
87
88 bool getModifierState(const String& keyIdentifier) const;
89
90 bool altGraphKey() const { return m_altGraphKey; }
91
92 const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); }
93
94 int keyCode() const; // key code for keydown and keyup, character for keypre ss
95 int charCode() const; // character code for keypress, 0 for keydown and keyu p
96
97 virtual const AtomicString& interfaceName() const;
98 virtual bool isKeyboardEvent() const;
99 virtual int which() const;
100
101 private:
102 KeyboardEvent();
103 KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*);
104 KeyboardEvent(const AtomicString&, const KeyboardEventInit&);
105 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, Abs tractView*,
106 const String& keyIdentifier, unsigned location,
107 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey );
108
109 OwnPtr<PlatformKeyboardEvent> m_keyEvent;
110 String m_keyIdentifier;
111 unsigned m_location;
112 bool m_altGraphKey : 1;
113 };
114
115 KeyboardEvent* findKeyboardEvent(Event*);
116
117 class KeyboardEventDispatchMediator : public EventDispatchMediator {
118 public:
119 static PassRefPtr<KeyboardEventDispatchMediator> create(PassRefPtr<KeyboardE vent>);
120 private:
121 explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>);
122 virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE;
123 };
124
125 inline KeyboardEvent* toKeyboardEvent(Event* event)
126 {
127 ASSERT_WITH_SECURITY_IMPLICATION(!event || event->isKeyboardEvent());
128 return static_cast<KeyboardEvent*>(event);
129 }
130
131 } // namespace WebCore
132
133 #endif // KeyboardEvent_h
OLDNEW
« no previous file with comments | « Source/core/events/HashChangeEvent.idl ('k') | Source/core/events/KeyboardEvent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698