68
static const HashTable JSHTMLCollectionConstructorTable =
65
static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionConstructorTable =
69
66
#if ENABLE(PERFECT_HASH_SIZE)
70
67
{ 0, JSHTMLCollectionConstructorTableValues, 0 };
72
69
{ 1, 0, JSHTMLCollectionConstructorTableValues, 0 };
75
class JSHTMLCollectionConstructor : public DOMObject {
72
class JSHTMLCollectionConstructor : public DOMConstructorObject {
77
JSHTMLCollectionConstructor(ExecState* exec)
78
: DOMObject(JSHTMLCollectionConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype()))
74
JSHTMLCollectionConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
75
: DOMConstructorObject(JSHTMLCollectionConstructor::createStructure(globalObject->objectPrototype()), globalObject)
80
putDirect(exec->propertyNames().prototype, JSHTMLCollectionPrototype::self(exec, exec->lexicalGlobalObject()), None);
77
putDirect(exec->propertyNames().prototype, JSHTMLCollectionPrototype::self(exec, globalObject), None);
82
79
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
80
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
83
81
virtual const ClassInfo* classInfo() const { return &s_info; }
84
82
static const ClassInfo s_info;
86
static PassRefPtr<Structure> createStructure(JSValuePtr proto)
84
static PassRefPtr<Structure> createStructure(JSValue proto)
88
86
return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
125
128
return getStaticFunctionSlot<JSObject>(exec, &JSHTMLCollectionPrototypeTable, this, propertyName, slot);
131
bool JSHTMLCollectionPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
133
return getStaticFunctionDescriptor<JSObject>(exec, &JSHTMLCollectionPrototypeTable, this, propertyName, descriptor);
128
136
const ClassInfo JSHTMLCollection::s_info = { "HTMLCollection", 0, &JSHTMLCollectionTable, 0 };
130
JSHTMLCollection::JSHTMLCollection(PassRefPtr<Structure> structure, PassRefPtr<HTMLCollection> impl)
131
: DOMObject(structure)
138
JSHTMLCollection::JSHTMLCollection(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<HTMLCollection> impl)
139
: DOMObjectWithGlobalPointer(structure, globalObject)
136
144
JSHTMLCollection::~JSHTMLCollection()
138
forgetDOMObject(*Heap::heap(this)->globalData(), m_impl.get());
146
forgetDOMObject(*Heap::heap(this)->globalData(), impl());
142
149
JSObject* JSHTMLCollection::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
168
175
return getStaticValueSlot<JSHTMLCollection, Base>(exec, &JSHTMLCollectionTable, this, propertyName, slot);
178
bool JSHTMLCollection::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
180
JSValue proto = prototype();
181
if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
184
const HashEntry* entry = JSHTMLCollectionTable.entry(exec, propertyName);
187
slot.setCustom(this, entry->propertyGetter());
188
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
192
unsigned index = propertyName.toUInt32(&ok, false);
193
if (ok && index < static_cast<HTMLCollection*>(impl())->length()) {
195
slot.setCustomIndex(this, index, indexGetter);
196
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
199
if (canGetItemsForName(exec, static_cast<HTMLCollection*>(impl()), propertyName)) {
201
slot.setCustom(this, nameGetter);
202
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
205
return getStaticValueDescriptor<JSHTMLCollection, Base>(exec, &JSHTMLCollectionTable, this, propertyName, descriptor);
171
208
bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
173
210
if (propertyName < static_cast<HTMLCollection*>(impl())->length()) {
177
214
return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
180
JSValuePtr jsHTMLCollectionLength(ExecState* exec, const Identifier&, const PropertySlot& slot)
217
JSValue jsHTMLCollectionLength(ExecState* exec, const Identifier&, const PropertySlot& slot)
182
HTMLCollection* imp = static_cast<HTMLCollection*>(static_cast<JSHTMLCollection*>(asObject(slot.slotBase()))->impl());
219
JSHTMLCollection* castedThis = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
221
HTMLCollection* imp = static_cast<HTMLCollection*>(castedThis->impl());
183
222
return jsNumber(exec, imp->length());
186
JSValuePtr jsHTMLCollectionConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot)
225
JSValue jsHTMLCollectionConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot)
188
return static_cast<JSHTMLCollection*>(asObject(slot.slotBase()))->getConstructor(exec);
227
JSHTMLCollection* domObject = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
228
return JSHTMLCollection::getConstructor(exec, domObject->globalObject());
190
void JSHTMLCollection::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
230
void JSHTMLCollection::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
192
232
for (unsigned i = 0; i < static_cast<HTMLCollection*>(impl())->length(); ++i)
193
233
propertyNames.add(Identifier::from(exec, i));
194
Base::getPropertyNames(exec, propertyNames);
197
JSValuePtr JSHTMLCollection::getConstructor(ExecState* exec)
199
return getDOMConstructor<JSHTMLCollectionConstructor>(exec);
202
JSValuePtr jsHTMLCollectionPrototypeFunctionItem(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
204
if (!thisValue->isObject(&JSHTMLCollection::s_info))
234
Base::getOwnPropertyNames(exec, propertyNames);
237
JSValue JSHTMLCollection::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
239
return getDOMConstructor<JSHTMLCollectionConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
242
JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
245
if (!thisValue.inherits(&JSHTMLCollection::s_info))
205
246
return throwError(exec, TypeError);
206
247
JSHTMLCollection* castedThisObj = static_cast<JSHTMLCollection*>(asObject(thisValue));
207
248
return castedThisObj->item(exec, args);
210
JSValuePtr jsHTMLCollectionPrototypeFunctionNamedItem(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
251
JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionNamedItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
212
if (!thisValue->isObject(&JSHTMLCollection::s_info))
254
if (!thisValue.inherits(&JSHTMLCollection::s_info))
213
255
return throwError(exec, TypeError);
214
256
JSHTMLCollection* castedThisObj = static_cast<JSHTMLCollection*>(asObject(thisValue));
215
257
return castedThisObj->namedItem(exec, args);
218
JSValuePtr jsHTMLCollectionPrototypeFunctionTags(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
260
JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionTags(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
220
if (!thisValue->isObject(&JSHTMLCollection::s_info))
263
if (!thisValue.inherits(&JSHTMLCollection::s_info))
221
264
return throwError(exec, TypeError);
222
265
JSHTMLCollection* castedThisObj = static_cast<JSHTMLCollection*>(asObject(thisValue));
223
266
HTMLCollection* imp = static_cast<HTMLCollection*>(castedThisObj->impl());
224
const UString& name = args.at(exec, 0)->toString(exec);
227
JSC::JSValuePtr result = toJS(exec, WTF::getPtr(imp->tags(name)));
267
const UString& name = args.at(0).toString(exec);
270
JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->tags(name)));
232
JSValuePtr JSHTMLCollection::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
275
JSValue JSHTMLCollection::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
234
277
JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
235
return toJS(exec, static_cast<HTMLCollection*>(thisObj->impl())->item(slot.index()));
278
return toJS(exec, thisObj->globalObject(), static_cast<HTMLCollection*>(thisObj->impl())->item(slot.index()));
237
HTMLCollection* toHTMLCollection(JSC::JSValuePtr value)
280
HTMLCollection* toHTMLCollection(JSC::JSValue value)
239
return value->isObject(&JSHTMLCollection::s_info) ? static_cast<JSHTMLCollection*>(asObject(value))->impl() : 0;
282
return value.inherits(&JSHTMLCollection::s_info) ? static_cast<JSHTMLCollection*>(asObject(value))->impl() : 0;