| 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, 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 19 matching lines...) Expand all Loading... |
| 30 namespace WebCore { | 30 namespace WebCore { |
| 31 | 31 |
| 32 class EventDispatcher; | 32 class EventDispatcher; |
| 33 class Node; | 33 class Node; |
| 34 class PlatformKeyboardEvent; | 34 class PlatformKeyboardEvent; |
| 35 | 35 |
| 36 struct KeyboardEventInit : public UIEventInit { | 36 struct KeyboardEventInit : public UIEventInit { |
| 37 KeyboardEventInit(); | 37 KeyboardEventInit(); |
| 38 | 38 |
| 39 String keyIdentifier; | 39 String keyIdentifier; |
| 40 unsigned keyLocation; | 40 unsigned location; |
| 41 bool ctrlKey; | 41 bool ctrlKey; |
| 42 bool altKey; | 42 bool altKey; |
| 43 bool shiftKey; | 43 bool shiftKey; |
| 44 bool metaKey; | 44 bool metaKey; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class KeyboardEvent : public UIEventWithKeyState { | 47 class KeyboardEvent : public UIEventWithKeyState { |
| 48 public: | 48 public: |
| 49 enum KeyLocationCode { | 49 enum KeyLocationCode { |
| 50 DOMKeyLocationStandard = 0x00, | 50 DOMKeyLocationStandard = 0x00, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 62 { | 62 { |
| 63 return adoptRef(new KeyboardEvent(platformEvent, view)); | 63 return adoptRef(new KeyboardEvent(platformEvent, view)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, const Keyb
oardEventInit& initializer) | 66 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, const Keyb
oardEventInit& initializer) |
| 67 { | 67 { |
| 68 return adoptRef(new KeyboardEvent(type, initializer)); | 68 return adoptRef(new KeyboardEvent(type, initializer)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, bool canBu
bble, bool cancelable, AbstractView* view, | 71 static PassRefPtr<KeyboardEvent> create(const AtomicString& type, bool canBu
bble, bool cancelable, AbstractView* view, |
| 72 const String& keyIdentifier, unsigned keyLocation, | 72 const String& keyIdentifier, unsigned location, |
| 73 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey
) | 73 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey
) |
| 74 { | 74 { |
| 75 return adoptRef(new KeyboardEvent(type, canBubble, cancelable, view, key
Identifier, keyLocation, | 75 return adoptRef(new KeyboardEvent(type, canBubble, cancelable, view, key
Identifier, location, |
| 76 ctrlKey, altKey, shiftKey, metaKey, altGraphKey)); | 76 ctrlKey, altKey, shiftKey, metaKey, altGraphKey)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual ~KeyboardEvent(); | 79 virtual ~KeyboardEvent(); |
| 80 | 80 |
| 81 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancel
able, AbstractView*, | 81 void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancel
able, AbstractView*, |
| 82 const String& keyIdentifier, unsigned keyLocation, | 82 const String& keyIdentifier, unsigned location, |
| 83 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey
= false); | 83 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey
= false); |
| 84 | 84 |
| 85 const String& keyIdentifier() const { return m_keyIdentifier; } | 85 const String& keyIdentifier() const { return m_keyIdentifier; } |
| 86 unsigned keyLocation() const { return m_keyLocation; } | 86 unsigned location() const { return m_location; } |
| 87 | 87 |
| 88 bool getModifierState(const String& keyIdentifier) const; | 88 bool getModifierState(const String& keyIdentifier) const; |
| 89 | 89 |
| 90 bool altGraphKey() const { return m_altGraphKey; } | 90 bool altGraphKey() const { return m_altGraphKey; } |
| 91 | 91 |
| 92 const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); } | 92 const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent.get(); } |
| 93 | 93 |
| 94 int keyCode() const; // key code for keydown and keyup, character for keypre
ss | 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 | 95 int charCode() const; // character code for keypress, 0 for keydown and keyu
p |
| 96 | 96 |
| 97 virtual const AtomicString& interfaceName() const; | 97 virtual const AtomicString& interfaceName() const; |
| 98 virtual bool isKeyboardEvent() const; | 98 virtual bool isKeyboardEvent() const; |
| 99 virtual int which() const; | 99 virtual int which() const; |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 KeyboardEvent(); | 102 KeyboardEvent(); |
| 103 KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*); | 103 KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*); |
| 104 KeyboardEvent(const AtomicString&, const KeyboardEventInit&); | 104 KeyboardEvent(const AtomicString&, const KeyboardEventInit&); |
| 105 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, Abs
tractView*, | 105 KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, Abs
tractView*, |
| 106 const String& keyIdentifier, unsigned keyLocation, | 106 const String& keyIdentifier, unsigned location, |
| 107 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey
); | 107 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey
); |
| 108 | 108 |
| 109 OwnPtr<PlatformKeyboardEvent> m_keyEvent; | 109 OwnPtr<PlatformKeyboardEvent> m_keyEvent; |
| 110 String m_keyIdentifier; | 110 String m_keyIdentifier; |
| 111 unsigned m_keyLocation; | 111 unsigned m_location; |
| 112 bool m_altGraphKey : 1; | 112 bool m_altGraphKey : 1; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 KeyboardEvent* findKeyboardEvent(Event*); | 115 KeyboardEvent* findKeyboardEvent(Event*); |
| 116 | 116 |
| 117 class KeyboardEventDispatchMediator : public EventDispatchMediator { | 117 class KeyboardEventDispatchMediator : public EventDispatchMediator { |
| 118 public: | 118 public: |
| 119 static PassRefPtr<KeyboardEventDispatchMediator> create(PassRefPtr<KeyboardE
vent>); | 119 static PassRefPtr<KeyboardEventDispatchMediator> create(PassRefPtr<KeyboardE
vent>); |
| 120 private: | 120 private: |
| 121 explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>); | 121 explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>); |
| 122 virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE; | 122 virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 inline KeyboardEvent* toKeyboardEvent(Event* event) | 125 inline KeyboardEvent* toKeyboardEvent(Event* event) |
| 126 { | 126 { |
| 127 ASSERT_WITH_SECURITY_IMPLICATION(!event || event->isKeyboardEvent()); | 127 ASSERT_WITH_SECURITY_IMPLICATION(!event || event->isKeyboardEvent()); |
| 128 return static_cast<KeyboardEvent*>(event); | 128 return static_cast<KeyboardEvent*>(event); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace WebCore | 131 } // namespace WebCore |
| 132 | 132 |
| 133 #endif // KeyboardEvent_h | 133 #endif // KeyboardEvent_h |
| OLD | NEW |