Beispiel #1
0
JSValue* jsCSSStyleSheetPrototypeFunctionRemoveRule(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSCSSStyleSheet::s_info))
        return throwError(exec, TypeError);
    JSCSSStyleSheet* castedThisObj = static_cast<JSCSSStyleSheet*>(thisValue);
    CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    unsigned index = args[0]->toInt32(exec);

    imp->removeRule(index, ec);
    setDOMException(exec, ec);
    return jsUndefined();
}
static v8::Handle<v8::Value> removeRuleCallback(const v8::Arguments& args)
{
    CSSStyleSheet* imp = V8CSSStyleSheet::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH(unsigned, index, toUInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
    imp->removeRule(index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
JSValue JSC_HOST_CALL jsCSSStyleSheetPrototypeFunctionRemoveRule(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.inherits(&JSCSSStyleSheet::s_info))
        return throwError(exec, TypeError);
    JSCSSStyleSheet* castedThisObj = static_cast<JSCSSStyleSheet*>(asObject(thisValue));
    CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    unsigned index = args.at(0).toInt32(exec);

    imp->removeRule(index, ec);
    setDOMException(exec, ec);
    return jsUndefined();
}
Beispiel #4
0
static v8::Handle<v8::Value> removeRuleCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.CSSStyleSheet.removeRule");
    CSSStyleSheet* imp = V8CSSStyleSheet::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    EXCEPTION_BLOCK(unsigned, index, toUInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
    imp->removeRule(index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8::Handle<v8::Value>();
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
Beispiel #5
0
JSValue* JSCSSStyleSheetPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSCSSStyleSheet::info))
      return throwError(exec, TypeError);

    CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(static_cast<JSCSSStyleSheet*>(thisObj)->impl());

    switch (id) {
    case JSCSSStyleSheet::InsertRuleFuncNum: {
        ExceptionCode ec = 0;
        String rule = args[0]->toString(exec);
        bool indexOk;
        unsigned index = args[1]->toInt32(exec, indexOk);
        if (!indexOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }


        KJS::JSValue* result = jsNumber(imp->insertRule(rule, index, ec));
        setDOMException(exec, ec);
        return result;
    }
    case JSCSSStyleSheet::DeleteRuleFuncNum: {
        ExceptionCode ec = 0;
        bool indexOk;
        unsigned index = args[0]->toInt32(exec, indexOk);
        if (!indexOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }

        imp->deleteRule(index, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSCSSStyleSheet::AddRuleFuncNum: {
        ExceptionCode ec = 0;
        String selector = args[0]->toString(exec);
        String style = args[1]->toString(exec);

        int argsCount = args.size();
        if (argsCount < 3) {

            KJS::JSValue* result = jsNumber(imp->addRule(selector, style, ec));
            setDOMException(exec, ec);
            return result;
        }

        bool indexOk;
        unsigned index = args[2]->toInt32(exec, indexOk);
        if (!indexOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }


        KJS::JSValue* result = jsNumber(imp->addRule(selector, style, index, ec));
        setDOMException(exec, ec);
        return result;
    }
    case JSCSSStyleSheet::RemoveRuleFuncNum: {
        ExceptionCode ec = 0;

        int argsCount = args.size();
        if (argsCount < 1) {
            imp->removeRule(ec);
            setDOMException(exec, ec);
            return jsUndefined();
        }

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

        imp->removeRule(index, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    }
    return 0;
}