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

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

Issue 663523002: Adding support for DOM3 KeyboardEvents Code in KeyboardEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
OLDNEW
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, 2007, 2008 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
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 18 matching lines...) Expand all
29 29
30 namespace blink { 30 namespace blink {
31 31
32 class EventDispatcher; 32 class EventDispatcher;
33 class PlatformKeyboardEvent; 33 class PlatformKeyboardEvent;
34 34
35 struct KeyboardEventInit : public UIEventInit { 35 struct KeyboardEventInit : public UIEventInit {
36 KeyboardEventInit(); 36 KeyboardEventInit();
37 37
38 String keyIdentifier; 38 String keyIdentifier;
39 String code;
39 unsigned location; 40 unsigned location;
40 bool ctrlKey; 41 bool ctrlKey;
41 bool altKey; 42 bool altKey;
42 bool shiftKey; 43 bool shiftKey;
43 bool metaKey; 44 bool metaKey;
44 bool repeat; 45 bool repeat;
45 }; 46 };
46 47
47 class KeyboardEvent final : public UIEventWithKeyState { 48 class KeyboardEvent final : public UIEventWithKeyState {
48 DEFINE_WRAPPERTYPEINFO(); 49 DEFINE_WRAPPERTYPEINFO();
(...skipping 14 matching lines...) Expand all
63 { 64 {
64 return adoptRefWillBeNoop(new KeyboardEvent(platformEvent, view)); 65 return adoptRefWillBeNoop(new KeyboardEvent(platformEvent, view));
65 } 66 }
66 67
67 static PassRefPtrWillBeRawPtr<KeyboardEvent> create(const AtomicString& type , const KeyboardEventInit& initializer) 68 static PassRefPtrWillBeRawPtr<KeyboardEvent> create(const AtomicString& type , const KeyboardEventInit& initializer)
68 { 69 {
69 return adoptRefWillBeNoop(new KeyboardEvent(type, initializer)); 70 return adoptRefWillBeNoop(new KeyboardEvent(type, initializer));
70 } 71 }
71 72
72 static PassRefPtrWillBeRawPtr<KeyboardEvent> create(const AtomicString& type , bool canBubble, bool cancelable, AbstractView* view, 73 static PassRefPtrWillBeRawPtr<KeyboardEvent> create(const AtomicString& type , bool canBubble, bool cancelable, AbstractView* view,
73 const String& keyIdentifier, unsigned location, 74 const String& keyIdentifier, const String& code, unsigned location,
74 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) 75 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
75 { 76 {
76 return adoptRefWillBeNoop(new KeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, location, 77 return adoptRefWillBeNoop(new KeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, code, location,
77 ctrlKey, altKey, shiftKey, metaKey)); 78 ctrlKey, altKey, shiftKey, metaKey));
78 } 79 }
79 80
80 virtual ~KeyboardEvent(); 81 virtual ~KeyboardEvent();
81 82
82 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancel able, AbstractView*, 83 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancel able, AbstractView*,
83 const String& keyIdentifier, unsigned location, 84 const String& keyIdentifier, const String& code, unsigned location,
84 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); 85 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
85 86
86 const String& keyIdentifier() const { return m_keyIdentifier; } 87 const String& keyIdentifier() const { return m_keyIdentifier; }
88 const String& code() { return m_code; };
89
87 unsigned location() const { return m_location; } 90 unsigned location() const { return m_location; }
88 91
89 bool getModifierState(const String& keyIdentifier) const; 92 bool getModifierState(const String& keyIdentifier) const;
90 93
91 const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); } 94 const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); }
92 95
93 virtual int keyCode() const override; // key code for keydown and keyup, cha racter for keypress 96 virtual int keyCode() const override; // key code for keydown and keyup, cha racter for keypress
94 virtual int charCode() const override; // character code for keypress, 0 for keydown and keyup 97 virtual int charCode() const override; // character code for keypress, 0 for keydown and keyup
95 bool repeat() const { return m_isAutoRepeat; } 98 bool repeat() const { return m_isAutoRepeat; }
96 99
97 virtual const AtomicString& interfaceName() const override; 100 virtual const AtomicString& interfaceName() const override;
98 virtual bool isKeyboardEvent() const override; 101 virtual bool isKeyboardEvent() const override;
99 virtual int which() const override; 102 virtual int which() const override;
100 103
101 virtual void trace(Visitor*) override; 104 virtual void trace(Visitor*) override;
102 105
103 private: 106 private:
104 KeyboardEvent(); 107 KeyboardEvent();
105 KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*); 108 KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*);
106 KeyboardEvent(const AtomicString&, const KeyboardEventInit&); 109 KeyboardEvent(const AtomicString&, const KeyboardEventInit&);
107 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, Abs tractView*, 110 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, Abs tractView*,
108 const String& keyIdentifier, unsigned location, 111 const String& keyIdentifier, const String& code, unsigned location,
109 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); 112 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
110 113
111 OwnPtr<PlatformKeyboardEvent> m_keyEvent; 114 OwnPtr<PlatformKeyboardEvent> m_keyEvent;
112 String m_keyIdentifier; 115 String m_keyIdentifier;
116 String m_code;
garykac 2014/12/02 16:29:32 While we need to expose the |code| string as part
Habib Virji 2014/12/02 16:39:05 The only reason for not passing int value was it w
113 unsigned m_location; 117 unsigned m_location;
114 bool m_isAutoRepeat : 1; 118 bool m_isAutoRepeat : 1;
115 }; 119 };
116 120
117 class KeyboardEventDispatchMediator : public EventDispatchMediator { 121 class KeyboardEventDispatchMediator : public EventDispatchMediator {
118 public: 122 public:
119 static PassRefPtrWillBeRawPtr<KeyboardEventDispatchMediator> create(PassRefP trWillBeRawPtr<KeyboardEvent>); 123 static PassRefPtrWillBeRawPtr<KeyboardEventDispatchMediator> create(PassRefP trWillBeRawPtr<KeyboardEvent>);
120 private: 124 private:
121 explicit KeyboardEventDispatchMediator(PassRefPtrWillBeRawPtr<KeyboardEvent> ); 125 explicit KeyboardEventDispatchMediator(PassRefPtrWillBeRawPtr<KeyboardEvent> );
122 virtual bool dispatchEvent(EventDispatcher*) const override; 126 virtual bool dispatchEvent(EventDispatcher*) const override;
123 }; 127 };
124 128
125 DEFINE_EVENT_TYPE_CASTS(KeyboardEvent); 129 DEFINE_EVENT_TYPE_CASTS(KeyboardEvent);
126 130
127 } // namespace blink 131 } // namespace blink
128 132
129 #endif // KeyboardEvent_h 133 #endif // KeyboardEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698