bool JSNodeListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { JSNodeList* jsNodeList = jsCast<JSNodeList*>(handle.get().asCell()); if (!jsNodeList->hasCustomProperties()) return false; if (!jsNodeList->impl()->isDynamicNodeList()) return false; return visitor.containsOpaqueRoot(root(static_cast<DynamicNodeList*>(jsNodeList->impl())->node())); }
bool JSNodeList::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot) { JSNodeList* thisObject = jsCast<JSNodeList*>(object); ASSERT_GC_OBJECT_INHERITS(thisObject, info()); if (index < thisObject->impl().length()) { unsigned attributes = DontDelete | ReadOnly; slot.setCustomIndex(thisObject, attributes, index, thisObject->indexGetter); return true; } PropertyName propertyName = Identifier::from(exec, index); if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) { slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter); return true; } return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot); }
void JSNodeListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { JSNodeList* jsNodeList = jsCast<JSNodeList*>(handle.get().asCell()); DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, &jsNodeList->impl(), jsNodeList); jsNodeList->releaseImpl(); }
void JSNodeList::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { JSNodeList* thisObject = jsCast<JSNodeList*>(object); ASSERT_GC_OBJECT_INHERITS(thisObject, info()); for (unsigned i = 0, count = thisObject->impl().length(); i < count; ++i) propertyNames.add(Identifier::from(exec, i)); Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); }
EncodedJSValue jsNodeListLength(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName) { JSNodeList* castedThis = jsDynamicCast<JSNodeList*>(JSValue::decode(thisValue)); UNUSED_PARAM(slotBase); if (!castedThis) return throwVMTypeError(exec); UNUSED_PARAM(exec); NodeList& impl = castedThis->impl(); JSValue result = jsNumber(impl.length()); return JSValue::encode(result); }
bool JSNodeList::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) { JSNodeList* thisObject = jsCast<JSNodeList*>(object); ASSERT_GC_OBJECT_INHERITS(thisObject, info()); const HashEntry* entry = getStaticValueSlotEntryWithoutCaching<JSNodeList>(exec, propertyName); if (entry) { slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter()); return true; } unsigned index = propertyName.asIndex(); if (index != PropertyName::NotAnIndex && index < thisObject->impl().length()) { unsigned attributes = DontDelete | ReadOnly; slot.setCustomIndex(thisObject, attributes, index, indexGetter); return true; } if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) { slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter); return true; } return getStaticValueSlot<JSNodeList, Base>(exec, JSNodeListTable, thisObject, propertyName, slot); }
JSValue* jsNodeListPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSNodeList::s_info)) return throwError(exec, TypeError); JSNodeList* castedThisObj = static_cast<JSNodeList*>(thisValue); NodeList* imp = static_cast<NodeList*>(castedThisObj->impl()); int index = args[0]->toInt32(exec); if (index < 0) { setDOMException(exec, INDEX_SIZE_ERR); return jsUndefined(); } KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->item(index))); return result; }
EncodedJSValue JSC_HOST_CALL jsNodeListPrototypeFunctionItem(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); JSNodeList* castedThis = jsDynamicCast<JSNodeList*>(thisValue); if (!castedThis) return throwVMTypeError(exec); ASSERT_GC_OBJECT_INHERITS(castedThis, JSNodeList::info()); NodeList& impl = castedThis->impl(); if (exec->argumentCount() < 1) return throwVMError(exec, createNotEnoughArgumentsError(exec)); unsigned index(toUInt32(exec, exec->argument(0), NormalConversion)); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.item(index))); return JSValue::encode(result); }
bool JSNodeListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { JSNodeList* jsNodeList = jsCast<JSNodeList*>(handle.slot()->asCell()); if (!jsNodeList->hasCustomProperties()) return false; if (jsNodeList->impl().isLiveNodeList()) return visitor.containsOpaqueRoot(root(static_cast<LiveNodeList&>(jsNodeList->impl()).ownerNode())); if (jsNodeList->impl().isChildNodeList()) return visitor.containsOpaqueRoot(root(static_cast<ChildNodeList&>(jsNodeList->impl()).ownerNode())); if (jsNodeList->impl().isEmptyNodeList()) return visitor.containsOpaqueRoot(root(static_cast<EmptyNodeList&>(jsNodeList->impl()).ownerNode())); return false; }
JSValue JSNodeList::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { JSNodeList* thisObj = static_cast<JSNodeList*>(asObject(slotBase)); return toJS(exec, thisObj->impl()->itemWithName(identifierToAtomicString(propertyName))); }
KJS::JSValue* JSNodeList::nameGetter(KJS::ExecState* exec, KJS::JSObject* originalObject, const KJS::Identifier& propertyName, const KJS::PropertySlot& slot) { JSNodeList* thisObj = static_cast<JSNodeList*>(slot.slotBase()); return toJS(exec, thisObj->impl()->itemWithName(propertyName)); }
JSValue JSNodeList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSNodeList* thisObj = static_cast<JSNodeList*>(asObject(slot.slotBase())); return toJS(exec, thisObj->impl()->itemWithName(propertyName)); }
JSValue JSNodeList::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName) { JSNodeList* thisObj = jsCast<JSNodeList*>(asObject(slotBase)); return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(propertyNameToAtomicString(propertyName))); }
EncodedJSValue JSNodeList::indexGetter(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue, unsigned index) { JSNodeList* thisObj = jsCast<JSNodeList*>(JSValue::decode(slotBase)); ASSERT_GC_OBJECT_INHERITS(thisObj, info()); return JSValue::encode(toJS(exec, thisObj->globalObject(), thisObj->impl().item(index))); }
JSValue* JSNodeList::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSNodeList* thisObj = static_cast<JSNodeList*>(slot.slotBase()); return toJS(exec, static_cast<NodeList*>(thisObj->impl())->item(slot.index())); }