Ejemplo n.º 1
0
JSValue* jsMediaListPrototypeFunctionAppendMedium(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSMediaList::s_info))
        return throwError(exec, TypeError);
    JSMediaList* castedThisObj = static_cast<JSMediaList*>(thisValue);
    MediaList* imp = static_cast<MediaList*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    const UString& newMedium = args.at(exec, 0)->toString(exec);

    imp->appendMedium(newMedium, ec);
    setDOMException(exec, ec);
    return jsUndefined();
}
Ejemplo n.º 2
0
static v8::Handle<v8::Value> appendMediumCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.MediaList.appendMedium");
    MediaList* imp = V8MediaList::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, newMedium, args[0]);
    imp->appendMedium(newMedium, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8::Handle<v8::Value>();
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
Ejemplo n.º 3
0
EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionAppendMedium(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSMediaList::s_info))
        return throwVMTypeError(exec);
    JSMediaList* castedThis = static_cast<JSMediaList*>(asObject(thisValue));
    MediaList* imp = static_cast<MediaList*>(castedThis->impl());
    ExceptionCode ec = 0;
    const String& newMedium(ustringToString(exec->argument(0).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->appendMedium(newMedium, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}
Ejemplo n.º 4
0
JSValue* JSMediaListPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSMediaList::info))
      return throwError(exec, TypeError);

    JSMediaList* castedThisObj = static_cast<JSMediaList*>(thisObj);
    MediaList* imp = static_cast<MediaList*>(castedThisObj->impl());

    switch (id) {
    case JSMediaList::ItemFuncNum: {
        bool indexOk;
        unsigned index = args[0]->toInt32(exec, indexOk);
        if (!indexOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }


        KJS::JSValue* result = jsStringOrNull(imp->item(index));
        return result;
    }
    case JSMediaList::DeleteMediumFuncNum: {
        ExceptionCode ec = 0;
        String oldMedium = args[0]->toString(exec);

        imp->deleteMedium(oldMedium, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSMediaList::AppendMediumFuncNum: {
        ExceptionCode ec = 0;
        String newMedium = args[0]->toString(exec);

        imp->appendMedium(newMedium, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    }
    return 0;
}