|
1 /* |
|
2 This file is part of the WebKit open source project. |
|
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Library General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Library General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Library General Public License |
|
16 along with this library; see the file COPYING.LIB. If not, write to |
|
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
18 Boston, MA 02110-1301, USA. |
|
19 */ |
|
20 |
|
21 #include "config.h" |
|
22 |
|
23 #include "JSKeyboardEvent.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "ExceptionCode.h" |
|
28 #include "JSDOMWindow.h" |
|
29 #include "KeyboardEvent.h" |
|
30 #include "PlatformString.h" |
|
31 |
|
32 using namespace KJS; |
|
33 |
|
34 namespace WebCore { |
|
35 |
|
36 /* Hash table */ |
|
37 |
|
38 static const HashEntry JSKeyboardEventTableEntries[] = |
|
39 { |
|
40 { "shiftKey", JSKeyboardEvent::ShiftKeyAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
41 { 0, 0, 0, 0, 0 }, |
|
42 { "altGraphKey", JSKeyboardEvent::AltGraphKeyAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
43 { "keyIdentifier", JSKeyboardEvent::KeyIdentifierAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
44 { "altKey", JSKeyboardEvent::AltKeyAttrNum, DontDelete|ReadOnly, 0, &JSKeyboardEventTableEntries[8] }, |
|
45 { 0, 0, 0, 0, 0 }, |
|
46 { "keyLocation", JSKeyboardEvent::KeyLocationAttrNum, DontDelete|ReadOnly, 0, &JSKeyboardEventTableEntries[7] }, |
|
47 { "ctrlKey", JSKeyboardEvent::CtrlKeyAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
48 { "metaKey", JSKeyboardEvent::MetaKeyAttrNum, DontDelete|ReadOnly, 0, 0 } |
|
49 }; |
|
50 |
|
51 static const HashTable JSKeyboardEventTable = |
|
52 { |
|
53 2, 9, JSKeyboardEventTableEntries, 7 |
|
54 }; |
|
55 |
|
56 /* Hash table for prototype */ |
|
57 |
|
58 static const HashEntry JSKeyboardEventPrototypeTableEntries[] = |
|
59 { |
|
60 { "initKeyboardEvent", JSKeyboardEvent::InitKeyboardEventFuncNum, DontDelete|Function, 11, 0 } |
|
61 }; |
|
62 |
|
63 static const HashTable JSKeyboardEventPrototypeTable = |
|
64 { |
|
65 2, 1, JSKeyboardEventPrototypeTableEntries, 1 |
|
66 }; |
|
67 |
|
68 const ClassInfo JSKeyboardEventPrototype::info = { "KeyboardEventPrototype", 0, &JSKeyboardEventPrototypeTable, 0 }; |
|
69 |
|
70 JSObject* JSKeyboardEventPrototype::self(ExecState* exec) |
|
71 { |
|
72 return KJS::cacheGlobalObject<JSKeyboardEventPrototype>(exec, "[[JSKeyboardEvent.prototype]]"); |
|
73 } |
|
74 |
|
75 bool JSKeyboardEventPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
76 { |
|
77 return getStaticFunctionSlot<JSKeyboardEventPrototypeFunction, JSObject>(exec, &JSKeyboardEventPrototypeTable, this, propertyName, slot); |
|
78 } |
|
79 |
|
80 const ClassInfo JSKeyboardEvent::info = { "KeyboardEvent", &JSUIEvent::info, &JSKeyboardEventTable, 0 }; |
|
81 |
|
82 JSKeyboardEvent::JSKeyboardEvent(ExecState* exec, KeyboardEvent* impl) |
|
83 : JSUIEvent(exec, impl) |
|
84 { |
|
85 setPrototype(JSKeyboardEventPrototype::self(exec)); |
|
86 } |
|
87 |
|
88 bool JSKeyboardEvent::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
89 { |
|
90 return getStaticValueSlot<JSKeyboardEvent, JSUIEvent>(exec, &JSKeyboardEventTable, this, propertyName, slot); |
|
91 } |
|
92 |
|
93 JSValue* JSKeyboardEvent::getValueProperty(ExecState* exec, int token) const |
|
94 { |
|
95 switch (token) { |
|
96 case KeyIdentifierAttrNum: { |
|
97 KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl()); |
|
98 |
|
99 return jsString(imp->keyIdentifier()); |
|
100 } |
|
101 case KeyLocationAttrNum: { |
|
102 KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl()); |
|
103 |
|
104 return jsNumber(imp->keyLocation()); |
|
105 } |
|
106 case CtrlKeyAttrNum: { |
|
107 KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl()); |
|
108 |
|
109 return jsBoolean(imp->ctrlKey()); |
|
110 } |
|
111 case ShiftKeyAttrNum: { |
|
112 KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl()); |
|
113 |
|
114 return jsBoolean(imp->shiftKey()); |
|
115 } |
|
116 case AltKeyAttrNum: { |
|
117 KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl()); |
|
118 |
|
119 return jsBoolean(imp->altKey()); |
|
120 } |
|
121 case MetaKeyAttrNum: { |
|
122 KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl()); |
|
123 |
|
124 return jsBoolean(imp->metaKey()); |
|
125 } |
|
126 case AltGraphKeyAttrNum: { |
|
127 KeyboardEvent* imp = static_cast<KeyboardEvent*>(impl()); |
|
128 |
|
129 return jsBoolean(imp->altGraphKey()); |
|
130 } |
|
131 } |
|
132 return 0; |
|
133 } |
|
134 |
|
135 JSValue* JSKeyboardEventPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
136 { |
|
137 if (!thisObj->inherits(&JSKeyboardEvent::info)) |
|
138 return throwError(exec, TypeError); |
|
139 |
|
140 KeyboardEvent* imp = static_cast<KeyboardEvent*>(static_cast<JSKeyboardEvent*>(thisObj)->impl()); |
|
141 |
|
142 switch (id) { |
|
143 case JSKeyboardEvent::InitKeyboardEventFuncNum: { |
|
144 AtomicString type = args[0]->toString(exec); |
|
145 bool canBubble = args[1]->toBoolean(exec); |
|
146 bool cancelable = args[2]->toBoolean(exec); |
|
147 DOMWindow* view = toDOMWindow(args[3]); |
|
148 String keyIdentifier = args[4]->toString(exec); |
|
149 bool keyLocationOk; |
|
150 unsigned keyLocation = args[5]->toInt32(exec, keyLocationOk); |
|
151 if (!keyLocationOk) { |
|
152 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
153 return jsUndefined(); |
|
154 } |
|
155 bool ctrlKey = args[6]->toBoolean(exec); |
|
156 bool altKey = args[7]->toBoolean(exec); |
|
157 bool shiftKey = args[8]->toBoolean(exec); |
|
158 bool metaKey = args[9]->toBoolean(exec); |
|
159 bool altGraphKey = args[10]->toBoolean(exec); |
|
160 |
|
161 imp->initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
|
162 return jsUndefined(); |
|
163 } |
|
164 } |
|
165 return 0; |
|
166 } |
|
167 |
|
168 } |