bool JSStorage::canGetItemsForName(ExecState* exec, Storage* impl, PropertyName propertyName) { ExceptionCode ec = 0; bool result = impl->contains(propertyNameToString(propertyName), ec); setDOMException(exec, ec); return result; }
bool JSStorage::putDelegate(ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult) { VM& vm = state->vm(); auto scope = DECLARE_THROW_SCOPE(vm); // Only perform the custom put if the object doesn't have a native property by this name. // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check // the native property slots manually. PropertySlot slot { this, PropertySlot::InternalMethodType::GetOwnProperty }; JSValue prototype = this->getPrototypeDirect(); if (prototype.isObject() && asObject(prototype)->getPropertySlot(state, propertyName, slot)) return false; if (propertyName.isSymbol()) return false; String stringValue = value.toWTFString(state); RETURN_IF_EXCEPTION(scope, true); auto setItemResult = wrapped().setItem(propertyNameToString(propertyName), stringValue); if (setItemResult.hasException()) { propagateException(*state, scope, setItemResult.releaseException()); return true; } putResult = true; return true; }
bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult) { // Only perform the custom put if the object doesn't have a native property by this name. // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check // the native property slots manually. PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty); static_assert(!hasStaticPropertyTable, "This function does not handle static instance properties"); JSValue prototype = this->getPrototypeDirect(); if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot)) return false; if (propertyName.isSymbol()) return false; String stringValue = value.toString(exec)->value(exec); if (exec->hadException()) { // The return value indicates whether putDelegate() should handle the put operation (which // if true, tells the caller not to execute the generic put). It does not indicate whether // putDelegate() did successfully complete the operation or not (which it didn't in this // case due to the exception). putResult = false; return true; } ExceptionCode ec = 0; wrapped().setItem(propertyNameToString(propertyName), stringValue, ec); setDOMException(exec, ec); putResult = !ec; return true; }
bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&) { // Only perform the custom put if the object doesn't have a native property by this name. // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check // the native property slots manually. PropertySlot slot(this); if (getStaticValueSlot<JSStorage, Base>(exec, *s_info.staticPropHashTable, this, propertyName, slot)) return false; JSValue prototype = this->prototype(); if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot)) return false; if (propertyName.isSymbol()) return false; String stringValue = value.toString(exec)->value(exec); if (exec->hadException()) return true; ExceptionCode ec = 0; wrapped().setItem(propertyNameToString(propertyName), stringValue, ec); setDOMException(exec, ec); return true; }
EncodedJSValue JSStyleSheetList::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName) { JSStyleSheetList* thisObj = jsCast<JSStyleSheetList*>(slotBase); HTMLStyleElement* element = thisObj->impl().getNamedItem(propertyNameToString(propertyName)); ASSERT(element); return JSValue::encode(toJS(exec, thisObj->globalObject(), element->sheet())); }
bool JSTestNamedDeleterNoIdentifier::deleteProperty(JSCell* cell, ExecState* state, PropertyName propertyName) { auto& thisObject = *jsCast<JSTestNamedDeleterNoIdentifier*>(cell); auto& impl = thisObject.wrapped(); if (isVisibleNamedProperty<OverrideBuiltins::No>(*state, thisObject, propertyName)) { return impl.deleteNamedProperty(propertyNameToString(propertyName)); } return JSObject::deleteProperty(cell, state, propertyName); }
bool JSDOMStringMap::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot) { bool nameIsValid; const AtomicString& item = impl().item(propertyNameToString(propertyName), nameIsValid); if (nameIsValid) { slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS(exec, globalObject(), item)); return true; } return false; }
bool JSDOMStringMap::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&) { String stringValue = value.toString(exec)->value(exec); if (exec->hadException()) return false; ExceptionCode ec = 0; impl().setItem(propertyNameToString(propertyName), stringValue, ec); setDOMException(exec, ec); return !ec; }
JSValue JSStorage::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName) { JSStorage* thisObj = jsCast<JSStorage*>(asObject(slotBase)); JSValue prototype = asObject(slotBase)->prototype(); if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName)) return asObject(prototype)->get(exec, propertyName); ExceptionCode ec = 0; JSValue result = jsStringOrNull(exec, thisObj->impl()->getItem(propertyNameToString(propertyName), ec)); setDOMException(exec, ec); return result; }
EncodedJSValue JSStorage::nameGetter(ExecState* exec, JSObject* slotBase, EncodedJSValue, PropertyName propertyName) { JSStorage* thisObject = jsCast<JSStorage*>(slotBase); JSValue prototype = thisObject->prototype(); PropertySlot slot(thisObject); if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot)) return JSValue::encode(slot.getValue(exec, propertyName)); ExceptionCode ec = 0; JSValue result = jsStringOrNull(exec, thisObject->impl().getItem(propertyNameToString(propertyName), ec)); setDOMException(exec, ec); return JSValue::encode(result); }
bool JSStorage::nameGetter(ExecState* exec, PropertyName propertyName, JSValue& value) { if (propertyName.isSymbol()) return false; ExceptionCode ec = 0; String item = wrapped().getItem(propertyNameToString(propertyName), ec); setDOMException(exec, ec); if (item.isNull()) return false; value = jsStringWithCache(exec, item); return true; }
bool JSTestNamedDeleterThrowingException::deleteProperty(JSCell* cell, ExecState* state, PropertyName propertyName) { auto& thisObject = *jsCast<JSTestNamedDeleterThrowingException*>(cell); auto& impl = thisObject.wrapped(); if (isVisibleNamedProperty<OverrideBuiltins::No>(*state, thisObject, propertyName)) { auto result = impl.deleteNamedProperty(propertyNameToString(propertyName)); if (result.hasException()) { auto throwScope = DECLARE_THROW_SCOPE(state->vm()); propagateException(*state, throwScope, result.releaseException()); return true; } return result.releaseReturnValue(); } return JSObject::deleteProperty(cell, state, propertyName); }
bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) { JSStorage* thisObject = jsCast<JSStorage*>(cell); // Only perform the custom delete if the object doesn't have a native property by this name. // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check // the native property slots manually. PropertySlot slot; if (getStaticValueSlot<JSStorage, Base>(exec, s_info.propHashTable(exec), thisObject, propertyName, slot)) return false; JSValue prototype = thisObject->prototype(); if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName)) return false; ExceptionCode ec = 0; thisObject->m_impl->removeItem(propertyNameToString(propertyName), ec); setDOMException(exec, ec); return true; }
bool JSStorage::nameGetter(ExecState* state, PropertyName propertyName, JSValue& value) { if (propertyName.isSymbol()) return false; auto item = wrapped().getItem(propertyNameToString(propertyName)); if (item.hasException()) { auto& vm = state->vm(); auto scope = DECLARE_THROW_SCOPE(vm); propagateException(*state, scope, item.releaseException()); return false; } auto string = item.releaseReturnValue(); if (string.isNull()) return false; value = jsStringWithCache(state, string); return true; }
bool JSStorage::deleteProperty(JSCell* cell, ExecState* state, PropertyName propertyName) { auto& thisObject = *jsCast<JSStorage*>(cell); // Only perform the custom delete if the object doesn't have a native property by this name. // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check // the native property slots manually. PropertySlot slot(&thisObject, PropertySlot::InternalMethodType::GetOwnProperty); JSValue prototype = thisObject.getPrototypeDirect(); if (prototype.isObject() && asObject(prototype)->getPropertySlot(state, propertyName, slot)) return Base::deleteProperty(&thisObject, state, propertyName); if (propertyName.isSymbol()) return Base::deleteProperty(&thisObject, state, propertyName); VM& vm = state->vm(); auto scope = DECLARE_THROW_SCOPE(vm); propagateException(*state, scope, thisObject.wrapped().removeItem(propertyNameToString(propertyName))); return true; }
bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) { JSStorage* thisObject = jsCast<JSStorage*>(cell); // Only perform the custom delete if the object doesn't have a native property by this name. // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check // the native property slots manually. PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty); static_assert(!hasStaticPropertyTable, "This function does not handle static instance properties"); JSValue prototype = thisObject->getPrototypeDirect(); if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot)) return Base::deleteProperty(thisObject, exec, propertyName); if (propertyName.isSymbol()) return Base::deleteProperty(thisObject, exec, propertyName); ExceptionCode ec = 0; thisObject->wrapped().removeItem(propertyNameToString(propertyName), ec); setDOMException(exec, ec); return true; }
bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheetList, PropertyName propertyName) { return styleSheetList->getNamedItem(propertyNameToString(propertyName)); }
bool JSRTCStatsResponse::canGetItemsForName(ExecState*, RTCStatsResponse* impl, PropertyName propertyName) { return impl->namedItem(propertyNameToString(propertyName)); }
JSValue JSRTCStatsResponse::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName) { JSRTCStatsResponse* thisObj = jsCast<JSRTCStatsResponse*>(asObject(slotBase)); return toJS(exec, thisObj->globalObject(), thisObj->impl()->namedItem(propertyNameToString(propertyName))); }
bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheetList, PropertyName propertyName) { if (propertyName.isSymbol()) return false; return styleSheetList->getNamedItem(propertyNameToString(propertyName)); }