Example #1
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionReadAsText(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSFileReader::info());
    FileReader& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    Blob* blob(toBlob(exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 1) {
        impl.readAsText(blob, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    const String& encoding(exec->argument(1).isEmpty() ? String() : exec->argument(1).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.readAsText(blob, encoding, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}
Example #2
0
void setJSFileReaderOnloadend(ExecState* exec, JSObject* thisObject, JSValue value)
{
    UNUSED_PARAM(exec);
    JSFileReader* castedThis = static_cast<JSFileReader*>(thisObject);
    FileReader* imp = static_cast<FileReader*>(castedThis->impl());
    imp->setOnloadend(createJSAttributeEventListener(exec, value, thisObject));
}
Example #3
0
void JSFileReaderOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
    JSFileReader* jsFileReader = jsCast<JSFileReader*>(handle.get().asCell());
    DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
    uncacheWrapper(world, &jsFileReader->impl(), jsFileReader);
    jsFileReader->releaseImpl();
}
Example #4
0
JSValue jsFileReaderError(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    FileReader* imp = static_cast<FileReader*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->error()));
    return result;
}
Example #5
0
JSValue jsFileReaderReadyState(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    FileReader* imp = static_cast<FileReader*>(castedThis->impl());
    JSValue result = jsNumber(imp->readyState());
    return result;
}
Example #6
0
EncodedJSValue jsFileReaderResult(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    return JSValue::encode(castedThis->result(exec));
}
Example #7
0
void JSFileReader::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
    JSFileReader* thisObject = jsCast<JSFileReader*>(cell);
    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
    Base::visitChildren(thisObject, visitor);
    thisObject->impl().visitJSEventListeners(visitor);
}
Example #8
0
EncodedJSValue jsFileReaderConstructor(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue, PropertyName)
{
    JSFileReader* domObject = jsDynamicCast<JSFileReader*>(JSValue::decode(thisValue));
    if (!domObject)
        return throwVMTypeError(exec);
    if (!domObject)
        return throwVMTypeError(exec);
    return JSValue::encode(JSFileReader::getConstructor(exec->vm(), domObject->globalObject()));
}
Example #9
0
bool JSFileReaderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
    JSFileReader* jsFileReader = static_cast<JSFileReader*>(handle.get().asCell());
    if (jsFileReader->impl()->hasPendingActivity())
        return true;
    if (!isObservable(jsFileReader))
        return false;
    UNUSED_PARAM(visitor);
    return false;
}
Example #10
0
bool JSFileReaderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
    JSFileReader* jsFileReader = jsCast<JSFileReader*>(handle.get().asCell());
    if (jsFileReader->impl().hasPendingActivity())
        return true;
    if (jsFileReader->impl().isFiringEventListeners())
        return true;
    UNUSED_PARAM(visitor);
    return false;
}
Example #11
0
EncodedJSValue jsFileReaderReadyState(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    FileReader& impl = castedThis->impl();
    JSValue result = jsNumber(impl.readyState());
    return JSValue::encode(result);
}
Example #12
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionAbort(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSFileReader::s_info))
        return throwVMTypeError(exec);
    JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(thisValue));
    FileReader* imp = static_cast<FileReader*>(castedThis->impl());

    imp->abort();
    return JSValue::encode(jsUndefined());
}
Example #13
0
EncodedJSValue jsFileReaderError(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    FileReader& impl = castedThis->impl();
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.error()));
    return JSValue::encode(result);
}
Example #14
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionAbort(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSFileReader::info());
    FileReader& impl = castedThis->impl();
    impl.abort();
    return JSValue::encode(jsUndefined());
}
Example #15
0
JSValue jsFileReaderOnloadend(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    FileReader* imp = static_cast<FileReader*>(castedThis->impl());
    if (EventListener* listener = imp->onloadend()) {
        if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
            if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
                return jsFunction;
        }
    }
    return jsNull();
}
Example #16
0
void setJSFileReaderOnloadend(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
    JSValue value = JSValue::decode(encodedValue);
    UNUSED_PARAM(exec);
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(JSValue::decode(thisValue));
    if (!castedThis) {
        throwVMTypeError(exec);
        return;
    }
    UNUSED_PARAM(exec);
    FileReader& impl = castedThis->impl();
    impl.setOnloadend(createJSAttributeEventListener(exec, value, castedThis));
}
Example #17
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionReadAsDataURL(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSFileReader::s_info))
        return throwVMTypeError(exec);
    JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(thisValue));
    FileReader* imp = static_cast<FileReader*>(castedThis->impl());
    Blob* blob(toBlob(exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->readAsDataURL(blob);
    return JSValue::encode(jsUndefined());
}
Example #18
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionRemoveEventListener(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSFileReader::info());
    FileReader& impl = castedThis->impl();
    JSValue listener = exec->argument(1);
    if (!listener.isObject())
        return JSValue::encode(jsUndefined());
    impl.removeEventListener(exec->argument(0).toString(exec)->value(exec), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
    return JSValue::encode(jsUndefined());
}
Example #19
0
EncodedJSValue jsFileReaderOnloadend(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    FileReader& impl = castedThis->impl();
    if (EventListener* listener = impl.onloadend()) {
        if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
            if (JSObject* jsFunction = jsListener->jsFunction(impl.scriptExecutionContext()))
                return JSValue::encode(jsFunction);
        }
    }
    return JSValue::encode(jsNull());
}
Example #20
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionReadAsDataURL(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSFileReader::info());
    FileReader& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    Blob* blob(toBlob(exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.readAsDataURL(blob, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}
Example #21
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionDispatchEvent(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSFileReader* castedThis = jsDynamicCast<JSFileReader*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSFileReader::info());
    FileReader& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    Event* evt(toEvent(exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsBoolean(impl.dispatchEvent(evt, ec));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
Example #22
0
EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionReadAsText(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSFileReader::s_info))
        return throwVMTypeError(exec);
    JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(thisValue));
    FileReader* imp = static_cast<FileReader*>(castedThis->impl());
    Blob* blob(toBlob(exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    int argsCount = exec->argumentCount();
    if (argsCount <= 1) {
        imp->readAsText(blob);
        return JSValue::encode(jsUndefined());
    }

    const String& encoding(ustringToString(exec->argument(1).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->readAsText(blob, encoding);
    return JSValue::encode(jsUndefined());
}
Example #23
0
JSValue jsFileReaderConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSFileReader* domObject = static_cast<JSFileReader*>(asObject(slotBase));
    return JSFileReader::getConstructor(exec, domObject->globalObject());
}
Example #24
0
JSValue jsFileReaderResult(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
    return castedThis->result(exec);
}