示例#1
0
JSValue JSStorage::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& 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);
 
    return jsStringOrNull(exec, thisObj->impl()->getItem(identifierToString(propertyName)));
}
示例#2
0
JSValue JSC_HOST_CALL jsStoragePrototypeFunctionClear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSStorage::s_info))
        return throwError(exec, TypeError);
    JSStorage* castedThisObj = static_cast<JSStorage*>(asObject(thisValue));
    Storage* imp = static_cast<Storage*>(castedThisObj->impl());

    imp->clear();
    return jsUndefined();
}
示例#3
0
JSValue JSC_HOST_CALL jsStoragePrototypeFunctionRemoveItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSStorage::s_info))
        return throwError(exec, TypeError);
    JSStorage* castedThisObj = static_cast<JSStorage*>(asObject(thisValue));
    Storage* imp = static_cast<Storage*>(castedThisObj->impl());
    const UString& key = args.at(0).toString(exec);

    imp->removeItem(key);
    return jsUndefined();
}
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;
}
示例#5
0
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);
}
示例#6
0
void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
    JSStorage* thisObject = jsCast<JSStorage*>(object);
    ExceptionCode ec = 0;
    unsigned length = thisObject->wrapped().length(ec);
    setDOMException(exec, ec);
    if (exec->hadException())
        return;
    for (unsigned i = 0; i < length; ++i) {
        propertyNames.add(Identifier::fromString(exec, thisObject->wrapped().key(i, ec)));
        setDOMException(exec, ec);
        if (exec->hadException())
            return;
    }
        
    Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& 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;

    thisObject->m_impl->removeItem(identifierToString(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);
    if (getStaticValueSlot<JSStorage, Base>(exec, *s_info.staticPropHashTable, thisObject, propertyName, slot))
        return false;
        
    JSValue prototype = thisObject->prototype();
    if (prototype.isObject() && asObject(prototype)->getPropertySlot(exec, propertyName, slot))
        return false;

    ExceptionCode ec = 0;
    thisObject->m_impl->removeItem(propertyNameToString(propertyName), ec);
    setDOMException(exec, ec);
    return true;
}
示例#9
0
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;
}
JSValue JSStorage::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
{
    JSStorage* thisObj = static_cast<JSStorage*>(asObject(slotBase));
    return jsStringOrNull(exec, thisObj->impl()->getItem(identifierToString(propertyName)));
}
示例#11
0
JSValue* JSStorage::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
    JSStorage* thisObj = static_cast<JSStorage*>(slot.slotBase());
    return jsStringOrNull(exec, thisObj->impl()->getItem(propertyName));
}