|
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 "JSHTMLElement.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "HTMLCollection.h" |
|
28 #include "HTMLElement.h" |
|
29 #include "JSHTMLCollection.h" |
|
30 #include "PlatformString.h" |
|
31 |
|
32 using namespace KJS; |
|
33 |
|
34 namespace WebCore { |
|
35 |
|
36 /* Hash table */ |
|
37 |
|
38 static const HashEntry JSHTMLElementTableEntries[] = |
|
39 { |
|
40 { 0, 0, 0, 0, 0 }, |
|
41 { "innerText", JSHTMLElement::InnerTextAttrNum, DontDelete, 0, 0 }, |
|
42 { "constructor", JSHTMLElement::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }, |
|
43 { "outerHTML", JSHTMLElement::OuterHTMLAttrNum, DontDelete, 0, &JSHTMLElementTableEntries[15] }, |
|
44 { "id", JSHTMLElement::IdAttrNum, DontDelete, 0, 0 }, |
|
45 { "isContentEditable", JSHTMLElement::IsContentEditableAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
46 { 0, 0, 0, 0, 0 }, |
|
47 { "dir", JSHTMLElement::DirAttrNum, DontDelete, 0, 0 }, |
|
48 { "title", JSHTMLElement::TitleAttrNum, DontDelete, 0, &JSHTMLElementTableEntries[14] }, |
|
49 { 0, 0, 0, 0, 0 }, |
|
50 { "className", JSHTMLElement::ClassNameAttrNum, DontDelete, 0, &JSHTMLElementTableEntries[13] }, |
|
51 { "contentEditable", JSHTMLElement::ContentEditableAttrNum, DontDelete, 0, 0 }, |
|
52 { "lang", JSHTMLElement::LangAttrNum, DontDelete, 0, 0 }, |
|
53 { "innerHTML", JSHTMLElement::InnerHTMLAttrNum, DontDelete, 0, 0 }, |
|
54 { "outerText", JSHTMLElement::OuterTextAttrNum, DontDelete, 0, 0 }, |
|
55 { "children", JSHTMLElement::ChildrenAttrNum, DontDelete|ReadOnly, 0, 0 } |
|
56 }; |
|
57 |
|
58 static const HashTable JSHTMLElementTable = |
|
59 { |
|
60 2, 16, JSHTMLElementTableEntries, 13 |
|
61 }; |
|
62 |
|
63 /* Hash table for constructor */ |
|
64 |
|
65 static const HashEntry JSHTMLElementConstructorTableEntries[] = |
|
66 { |
|
67 { 0, 0, 0, 0, 0 } |
|
68 }; |
|
69 |
|
70 static const HashTable JSHTMLElementConstructorTable = |
|
71 { |
|
72 2, 1, JSHTMLElementConstructorTableEntries, 1 |
|
73 }; |
|
74 |
|
75 class JSHTMLElementConstructor : public DOMObject { |
|
76 public: |
|
77 JSHTMLElementConstructor(ExecState* exec) |
|
78 { |
|
79 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
80 putDirect(exec->propertyNames().prototype, JSHTMLElementPrototype::self(exec), None); |
|
81 } |
|
82 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
83 JSValue* getValueProperty(ExecState*, int token) const; |
|
84 virtual const ClassInfo* classInfo() const { return &info; } |
|
85 static const ClassInfo info; |
|
86 |
|
87 virtual bool implementsHasInstance() const { return true; } |
|
88 }; |
|
89 |
|
90 const ClassInfo JSHTMLElementConstructor::info = { "HTMLElementConstructor", 0, &JSHTMLElementConstructorTable, 0 }; |
|
91 |
|
92 bool JSHTMLElementConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
93 { |
|
94 return getStaticValueSlot<JSHTMLElementConstructor, DOMObject>(exec, &JSHTMLElementConstructorTable, this, propertyName, slot); |
|
95 } |
|
96 |
|
97 JSValue* JSHTMLElementConstructor::getValueProperty(ExecState*, int token) const |
|
98 { |
|
99 // The token is the numeric value of its associated constant |
|
100 return jsNumber(token); |
|
101 } |
|
102 |
|
103 /* Hash table for prototype */ |
|
104 |
|
105 static const HashEntry JSHTMLElementPrototypeTableEntries[] = |
|
106 { |
|
107 { 0, 0, 0, 0, 0 } |
|
108 }; |
|
109 |
|
110 static const HashTable JSHTMLElementPrototypeTable = |
|
111 { |
|
112 2, 1, JSHTMLElementPrototypeTableEntries, 1 |
|
113 }; |
|
114 |
|
115 const ClassInfo JSHTMLElementPrototype::info = { "HTMLElementPrototype", 0, &JSHTMLElementPrototypeTable, 0 }; |
|
116 |
|
117 JSObject* JSHTMLElementPrototype::self(ExecState* exec) |
|
118 { |
|
119 return KJS::cacheGlobalObject<JSHTMLElementPrototype>(exec, "[[JSHTMLElement.prototype]]"); |
|
120 } |
|
121 |
|
122 const ClassInfo JSHTMLElement::info = { "HTMLElement", &JSElement::info, &JSHTMLElementTable, 0 }; |
|
123 |
|
124 JSHTMLElement::JSHTMLElement(ExecState* exec, HTMLElement* impl) |
|
125 : JSElement(exec, impl) |
|
126 { |
|
127 setPrototype(JSHTMLElementPrototype::self(exec)); |
|
128 } |
|
129 |
|
130 bool JSHTMLElement::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
131 { |
|
132 return getStaticValueSlot<JSHTMLElement, JSElement>(exec, &JSHTMLElementTable, this, propertyName, slot); |
|
133 } |
|
134 |
|
135 JSValue* JSHTMLElement::getValueProperty(ExecState* exec, int token) const |
|
136 { |
|
137 switch (token) { |
|
138 case IdAttrNum: { |
|
139 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
140 |
|
141 return jsString(imp->id()); |
|
142 } |
|
143 case TitleAttrNum: { |
|
144 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
145 |
|
146 return jsString(imp->title()); |
|
147 } |
|
148 case LangAttrNum: { |
|
149 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
150 |
|
151 return jsString(imp->lang()); |
|
152 } |
|
153 case DirAttrNum: { |
|
154 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
155 |
|
156 return jsString(imp->dir()); |
|
157 } |
|
158 case ClassNameAttrNum: { |
|
159 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
160 |
|
161 return jsString(imp->className()); |
|
162 } |
|
163 case InnerHTMLAttrNum: { |
|
164 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
165 |
|
166 return jsString(imp->innerHTML()); |
|
167 } |
|
168 case InnerTextAttrNum: { |
|
169 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
170 |
|
171 return jsString(imp->innerText()); |
|
172 } |
|
173 case OuterHTMLAttrNum: { |
|
174 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
175 |
|
176 return jsString(imp->outerHTML()); |
|
177 } |
|
178 case OuterTextAttrNum: { |
|
179 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
180 |
|
181 return jsString(imp->outerText()); |
|
182 } |
|
183 case ChildrenAttrNum: { |
|
184 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
185 |
|
186 return toJS(exec, WTF::getPtr(imp->children())); |
|
187 } |
|
188 case ContentEditableAttrNum: { |
|
189 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
190 |
|
191 return jsString(imp->contentEditable()); |
|
192 } |
|
193 case IsContentEditableAttrNum: { |
|
194 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
195 |
|
196 return jsBoolean(imp->isContentEditable()); |
|
197 } |
|
198 case ConstructorAttrNum: |
|
199 return getConstructor(exec); |
|
200 } |
|
201 return 0; |
|
202 } |
|
203 |
|
204 void JSHTMLElement::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) |
|
205 { |
|
206 lookupPut<JSHTMLElement, JSElement>(exec, propertyName, value, attr, &JSHTMLElementTable, this); |
|
207 } |
|
208 |
|
209 void JSHTMLElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/) |
|
210 { |
|
211 switch (token) { |
|
212 case IdAttrNum: { |
|
213 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
214 |
|
215 imp->setId(valueToStringWithNullCheck(exec, value)); |
|
216 break; |
|
217 } |
|
218 case TitleAttrNum: { |
|
219 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
220 |
|
221 imp->setTitle(valueToStringWithNullCheck(exec, value)); |
|
222 break; |
|
223 } |
|
224 case LangAttrNum: { |
|
225 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
226 |
|
227 imp->setLang(valueToStringWithNullCheck(exec, value)); |
|
228 break; |
|
229 } |
|
230 case DirAttrNum: { |
|
231 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
232 |
|
233 imp->setDir(valueToStringWithNullCheck(exec, value)); |
|
234 break; |
|
235 } |
|
236 case ClassNameAttrNum: { |
|
237 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
238 |
|
239 imp->setClassName(valueToStringWithNullCheck(exec, value)); |
|
240 break; |
|
241 } |
|
242 case InnerHTMLAttrNum: { |
|
243 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
244 |
|
245 ExceptionCode ec = 0; |
|
246 imp->setInnerHTML(valueToStringWithNullCheck(exec, value), ec); |
|
247 setDOMException(exec, ec); |
|
248 break; |
|
249 } |
|
250 case InnerTextAttrNum: { |
|
251 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
252 |
|
253 ExceptionCode ec = 0; |
|
254 imp->setInnerText(valueToStringWithNullCheck(exec, value), ec); |
|
255 setDOMException(exec, ec); |
|
256 break; |
|
257 } |
|
258 case OuterHTMLAttrNum: { |
|
259 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
260 |
|
261 ExceptionCode ec = 0; |
|
262 imp->setOuterHTML(valueToStringWithNullCheck(exec, value), ec); |
|
263 setDOMException(exec, ec); |
|
264 break; |
|
265 } |
|
266 case OuterTextAttrNum: { |
|
267 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
268 |
|
269 ExceptionCode ec = 0; |
|
270 imp->setOuterText(valueToStringWithNullCheck(exec, value), ec); |
|
271 setDOMException(exec, ec); |
|
272 break; |
|
273 } |
|
274 case ContentEditableAttrNum: { |
|
275 HTMLElement* imp = static_cast<HTMLElement*>(impl()); |
|
276 |
|
277 imp->setContentEditable(valueToStringWithNullCheck(exec, value)); |
|
278 break; |
|
279 } |
|
280 } |
|
281 } |
|
282 |
|
283 JSValue* JSHTMLElement::getConstructor(ExecState* exec) |
|
284 { |
|
285 return KJS::cacheGlobalObject<JSHTMLElementConstructor>(exec, "[[HTMLElement.constructor]]"); |
|
286 } |
|
287 HTMLElement* toHTMLElement(KJS::JSValue* val) |
|
288 { |
|
289 return val->isObject(&JSHTMLElement::info) ? static_cast<JSHTMLElement*>(val)->impl() : 0; |
|
290 } |
|
291 |
|
292 HTMLElement* JSHTMLElement::impl() const |
|
293 { |
|
294 return static_cast<HTMLElement*>(JSElement::impl()); |
|
295 } |
|
296 |
|
297 } |