|
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 "JSCSSValue.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "CSSValue.h" |
|
28 #include "PlatformString.h" |
|
29 |
|
30 using namespace KJS; |
|
31 |
|
32 namespace WebCore { |
|
33 |
|
34 /* Hash table */ |
|
35 |
|
36 static const HashEntry JSCSSValueTableEntries[] = |
|
37 { |
|
38 { "cssText", JSCSSValue::CssTextAttrNum, DontDelete, 0, &JSCSSValueTableEntries[3] }, |
|
39 { 0, 0, 0, 0, 0 }, |
|
40 { 0, 0, 0, 0, 0 }, |
|
41 { "cssValueType", JSCSSValue::CssValueTypeAttrNum, DontDelete|ReadOnly, 0, &JSCSSValueTableEntries[4] }, |
|
42 { "constructor", JSCSSValue::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 } |
|
43 }; |
|
44 |
|
45 static const HashTable JSCSSValueTable = |
|
46 { |
|
47 2, 5, JSCSSValueTableEntries, 3 |
|
48 }; |
|
49 |
|
50 /* Hash table for constructor */ |
|
51 |
|
52 static const HashEntry JSCSSValueConstructorTableEntries[] = |
|
53 { |
|
54 { 0, 0, 0, 0, 0 }, |
|
55 { "CSS_INHERIT", CSSValue::CSS_INHERIT, DontDelete|ReadOnly, 0, 0 }, |
|
56 { "CSS_CUSTOM", CSSValue::CSS_CUSTOM, DontDelete|ReadOnly, 0, 0 }, |
|
57 { "CSS_PRIMITIVE_VALUE", CSSValue::CSS_PRIMITIVE_VALUE, DontDelete|ReadOnly, 0, &JSCSSValueConstructorTableEntries[4] }, |
|
58 { "CSS_VALUE_LIST", CSSValue::CSS_VALUE_LIST, DontDelete|ReadOnly, 0, 0 } |
|
59 }; |
|
60 |
|
61 static const HashTable JSCSSValueConstructorTable = |
|
62 { |
|
63 2, 5, JSCSSValueConstructorTableEntries, 4 |
|
64 }; |
|
65 |
|
66 class JSCSSValueConstructor : public DOMObject { |
|
67 public: |
|
68 JSCSSValueConstructor(ExecState* exec) |
|
69 { |
|
70 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
71 putDirect(exec->propertyNames().prototype, JSCSSValuePrototype::self(exec), None); |
|
72 } |
|
73 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
74 JSValue* getValueProperty(ExecState*, int token) const; |
|
75 virtual const ClassInfo* classInfo() const { return &info; } |
|
76 static const ClassInfo info; |
|
77 |
|
78 virtual bool implementsHasInstance() const { return true; } |
|
79 }; |
|
80 |
|
81 const ClassInfo JSCSSValueConstructor::info = { "CSSValueConstructor", 0, &JSCSSValueConstructorTable, 0 }; |
|
82 |
|
83 bool JSCSSValueConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
84 { |
|
85 return getStaticValueSlot<JSCSSValueConstructor, DOMObject>(exec, &JSCSSValueConstructorTable, this, propertyName, slot); |
|
86 } |
|
87 |
|
88 JSValue* JSCSSValueConstructor::getValueProperty(ExecState*, int token) const |
|
89 { |
|
90 // The token is the numeric value of its associated constant |
|
91 return jsNumber(token); |
|
92 } |
|
93 |
|
94 /* Hash table for prototype */ |
|
95 |
|
96 static const HashEntry JSCSSValuePrototypeTableEntries[] = |
|
97 { |
|
98 { 0, 0, 0, 0, 0 }, |
|
99 { "CSS_INHERIT", CSSValue::CSS_INHERIT, DontDelete|ReadOnly, 0, 0 }, |
|
100 { "CSS_CUSTOM", CSSValue::CSS_CUSTOM, DontDelete|ReadOnly, 0, 0 }, |
|
101 { "CSS_PRIMITIVE_VALUE", CSSValue::CSS_PRIMITIVE_VALUE, DontDelete|ReadOnly, 0, &JSCSSValuePrototypeTableEntries[4] }, |
|
102 { "CSS_VALUE_LIST", CSSValue::CSS_VALUE_LIST, DontDelete|ReadOnly, 0, 0 } |
|
103 }; |
|
104 |
|
105 static const HashTable JSCSSValuePrototypeTable = |
|
106 { |
|
107 2, 5, JSCSSValuePrototypeTableEntries, 4 |
|
108 }; |
|
109 |
|
110 const ClassInfo JSCSSValuePrototype::info = { "CSSValuePrototype", 0, &JSCSSValuePrototypeTable, 0 }; |
|
111 |
|
112 JSObject* JSCSSValuePrototype::self(ExecState* exec) |
|
113 { |
|
114 return KJS::cacheGlobalObject<JSCSSValuePrototype>(exec, "[[JSCSSValue.prototype]]"); |
|
115 } |
|
116 |
|
117 bool JSCSSValuePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
118 { |
|
119 return getStaticValueSlot<JSCSSValuePrototype, JSObject>(exec, &JSCSSValuePrototypeTable, this, propertyName, slot); |
|
120 } |
|
121 |
|
122 JSValue* JSCSSValuePrototype::getValueProperty(ExecState*, int token) const |
|
123 { |
|
124 // The token is the numeric value of its associated constant |
|
125 return jsNumber(token); |
|
126 } |
|
127 |
|
128 const ClassInfo JSCSSValue::info = { "CSSValue", 0, &JSCSSValueTable, 0 }; |
|
129 |
|
130 JSCSSValue::JSCSSValue(ExecState* exec, CSSValue* impl) |
|
131 : m_impl(impl) |
|
132 { |
|
133 setPrototype(JSCSSValuePrototype::self(exec)); |
|
134 } |
|
135 |
|
136 JSCSSValue::~JSCSSValue() |
|
137 { |
|
138 ScriptInterpreter::forgetDOMObject(m_impl.get()); |
|
139 } |
|
140 |
|
141 bool JSCSSValue::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
142 { |
|
143 return getStaticValueSlot<JSCSSValue, KJS::DOMObject>(exec, &JSCSSValueTable, this, propertyName, slot); |
|
144 } |
|
145 |
|
146 JSValue* JSCSSValue::getValueProperty(ExecState* exec, int token) const |
|
147 { |
|
148 switch (token) { |
|
149 case CssTextAttrNum: { |
|
150 CSSValue* imp = static_cast<CSSValue*>(impl()); |
|
151 |
|
152 return jsStringOrNull(imp->cssText()); |
|
153 } |
|
154 case CssValueTypeAttrNum: { |
|
155 CSSValue* imp = static_cast<CSSValue*>(impl()); |
|
156 |
|
157 return jsNumber(imp->cssValueType()); |
|
158 } |
|
159 case ConstructorAttrNum: |
|
160 return getConstructor(exec); |
|
161 } |
|
162 return 0; |
|
163 } |
|
164 |
|
165 void JSCSSValue::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) |
|
166 { |
|
167 lookupPut<JSCSSValue, KJS::DOMObject>(exec, propertyName, value, attr, &JSCSSValueTable, this); |
|
168 } |
|
169 |
|
170 void JSCSSValue::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/) |
|
171 { |
|
172 switch (token) { |
|
173 case CssTextAttrNum: { |
|
174 CSSValue* imp = static_cast<CSSValue*>(impl()); |
|
175 |
|
176 ExceptionCode ec = 0; |
|
177 imp->setCssText(valueToStringWithNullCheck(exec, value), ec); |
|
178 setDOMException(exec, ec); |
|
179 break; |
|
180 } |
|
181 } |
|
182 } |
|
183 |
|
184 JSValue* JSCSSValue::getConstructor(ExecState* exec) |
|
185 { |
|
186 return KJS::cacheGlobalObject<JSCSSValueConstructor>(exec, "[[CSSValue.constructor]]"); |
|
187 } |
|
188 CSSValue* toCSSValue(KJS::JSValue* val) |
|
189 { |
|
190 return val->isObject(&JSCSSValue::info) ? static_cast<JSCSSValue*>(val)->impl() : 0; |
|
191 } |
|
192 |
|
193 } |