|
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 "JSHTMLCanvasElement.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "HTMLCanvasElement.h" |
|
28 #include "JSCanvasRenderingContext2D.h" |
|
29 |
|
30 using namespace KJS; |
|
31 |
|
32 namespace WebCore { |
|
33 |
|
34 /* Hash table */ |
|
35 |
|
36 static const HashEntry JSHTMLCanvasElementTableEntries[] = |
|
37 { |
|
38 { "constructor", JSHTMLCanvasElement::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }, |
|
39 { "width", JSHTMLCanvasElement::WidthAttrNum, DontDelete, 0, 0 }, |
|
40 { "height", JSHTMLCanvasElement::HeightAttrNum, DontDelete, 0, 0 } |
|
41 }; |
|
42 |
|
43 static const HashTable JSHTMLCanvasElementTable = |
|
44 { |
|
45 2, 3, JSHTMLCanvasElementTableEntries, 3 |
|
46 }; |
|
47 |
|
48 /* Hash table for constructor */ |
|
49 |
|
50 static const HashEntry JSHTMLCanvasElementConstructorTableEntries[] = |
|
51 { |
|
52 { 0, 0, 0, 0, 0 } |
|
53 }; |
|
54 |
|
55 static const HashTable JSHTMLCanvasElementConstructorTable = |
|
56 { |
|
57 2, 1, JSHTMLCanvasElementConstructorTableEntries, 1 |
|
58 }; |
|
59 |
|
60 class JSHTMLCanvasElementConstructor : public DOMObject { |
|
61 public: |
|
62 JSHTMLCanvasElementConstructor(ExecState* exec) |
|
63 { |
|
64 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
65 putDirect(exec->propertyNames().prototype, JSHTMLCanvasElementPrototype::self(exec), None); |
|
66 } |
|
67 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
68 JSValue* getValueProperty(ExecState*, int token) const; |
|
69 virtual const ClassInfo* classInfo() const { return &info; } |
|
70 static const ClassInfo info; |
|
71 |
|
72 virtual bool implementsHasInstance() const { return true; } |
|
73 }; |
|
74 |
|
75 const ClassInfo JSHTMLCanvasElementConstructor::info = { "HTMLCanvasElementConstructor", 0, &JSHTMLCanvasElementConstructorTable, 0 }; |
|
76 |
|
77 bool JSHTMLCanvasElementConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
78 { |
|
79 return getStaticValueSlot<JSHTMLCanvasElementConstructor, DOMObject>(exec, &JSHTMLCanvasElementConstructorTable, this, propertyName, slot); |
|
80 } |
|
81 |
|
82 JSValue* JSHTMLCanvasElementConstructor::getValueProperty(ExecState*, int token) const |
|
83 { |
|
84 // The token is the numeric value of its associated constant |
|
85 return jsNumber(token); |
|
86 } |
|
87 |
|
88 /* Hash table for prototype */ |
|
89 |
|
90 static const HashEntry JSHTMLCanvasElementPrototypeTableEntries[] = |
|
91 { |
|
92 { "getContext", JSHTMLCanvasElement::GetContextFuncNum, DontDelete|Function, 1, 0 } |
|
93 }; |
|
94 |
|
95 static const HashTable JSHTMLCanvasElementPrototypeTable = |
|
96 { |
|
97 2, 1, JSHTMLCanvasElementPrototypeTableEntries, 1 |
|
98 }; |
|
99 |
|
100 const ClassInfo JSHTMLCanvasElementPrototype::info = { "HTMLCanvasElementPrototype", 0, &JSHTMLCanvasElementPrototypeTable, 0 }; |
|
101 |
|
102 JSObject* JSHTMLCanvasElementPrototype::self(ExecState* exec) |
|
103 { |
|
104 return KJS::cacheGlobalObject<JSHTMLCanvasElementPrototype>(exec, "[[JSHTMLCanvasElement.prototype]]"); |
|
105 } |
|
106 |
|
107 bool JSHTMLCanvasElementPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
108 { |
|
109 return getStaticFunctionSlot<JSHTMLCanvasElementPrototypeFunction, JSObject>(exec, &JSHTMLCanvasElementPrototypeTable, this, propertyName, slot); |
|
110 } |
|
111 |
|
112 const ClassInfo JSHTMLCanvasElement::info = { "HTMLCanvasElement", &JSHTMLElement::info, &JSHTMLCanvasElementTable, 0 }; |
|
113 |
|
114 JSHTMLCanvasElement::JSHTMLCanvasElement(ExecState* exec, HTMLCanvasElement* impl) |
|
115 : JSHTMLElement(exec, impl) |
|
116 { |
|
117 setPrototype(JSHTMLCanvasElementPrototype::self(exec)); |
|
118 } |
|
119 |
|
120 bool JSHTMLCanvasElement::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
121 { |
|
122 return getStaticValueSlot<JSHTMLCanvasElement, JSHTMLElement>(exec, &JSHTMLCanvasElementTable, this, propertyName, slot); |
|
123 } |
|
124 |
|
125 JSValue* JSHTMLCanvasElement::getValueProperty(ExecState* exec, int token) const |
|
126 { |
|
127 switch (token) { |
|
128 case WidthAttrNum: { |
|
129 HTMLCanvasElement* imp = static_cast<HTMLCanvasElement*>(impl()); |
|
130 |
|
131 return jsNumber(imp->width()); |
|
132 } |
|
133 case HeightAttrNum: { |
|
134 HTMLCanvasElement* imp = static_cast<HTMLCanvasElement*>(impl()); |
|
135 |
|
136 return jsNumber(imp->height()); |
|
137 } |
|
138 case ConstructorAttrNum: |
|
139 return getConstructor(exec); |
|
140 } |
|
141 return 0; |
|
142 } |
|
143 |
|
144 void JSHTMLCanvasElement::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) |
|
145 { |
|
146 lookupPut<JSHTMLCanvasElement, JSHTMLElement>(exec, propertyName, value, attr, &JSHTMLCanvasElementTable, this); |
|
147 } |
|
148 |
|
149 void JSHTMLCanvasElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/) |
|
150 { |
|
151 switch (token) { |
|
152 case WidthAttrNum: { |
|
153 HTMLCanvasElement* imp = static_cast<HTMLCanvasElement*>(impl()); |
|
154 |
|
155 imp->setWidth(value->toInt32(exec)); |
|
156 break; |
|
157 } |
|
158 case HeightAttrNum: { |
|
159 HTMLCanvasElement* imp = static_cast<HTMLCanvasElement*>(impl()); |
|
160 |
|
161 imp->setHeight(value->toInt32(exec)); |
|
162 break; |
|
163 } |
|
164 } |
|
165 } |
|
166 |
|
167 JSValue* JSHTMLCanvasElement::getConstructor(ExecState* exec) |
|
168 { |
|
169 return KJS::cacheGlobalObject<JSHTMLCanvasElementConstructor>(exec, "[[HTMLCanvasElement.constructor]]"); |
|
170 } |
|
171 JSValue* JSHTMLCanvasElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
172 { |
|
173 if (!thisObj->inherits(&JSHTMLCanvasElement::info)) |
|
174 return throwError(exec, TypeError); |
|
175 |
|
176 HTMLCanvasElement* imp = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLCanvasElement*>(thisObj)->impl()); |
|
177 |
|
178 switch (id) { |
|
179 case JSHTMLCanvasElement::GetContextFuncNum: { |
|
180 String contextId = args[0]->toString(exec); |
|
181 |
|
182 |
|
183 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getContext(contextId))); |
|
184 return result; |
|
185 } |
|
186 } |
|
187 return 0; |
|
188 } |
|
189 |
|
190 } |