Example #1
0
JSValue* jsCSSStyleSheetPrototypeFunctionAddRule(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;
    const UString& selector = args[0]->toString(exec);
    const UString& style = args[1]->toString(exec);

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

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

    unsigned index = args[2]->toInt32(exec);


    KJS::JSValue* result = jsNumber(exec, imp->addRule(selector, style, index, ec));
    setDOMException(exec, ec);
    return result;
}
Example #2
0
JSValue JSC_HOST_CALL jsCSSStyleSheetPrototypeFunctionAddRule(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;
    const UString& selector = args.at(0).toString(exec);
    const UString& style = args.at(1).toString(exec);

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

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

    unsigned index = args.at(2).toInt32(exec);


    JSC::JSValue result = jsNumber(exec, imp->addRule(selector, style, index, ec));
    setDOMException(exec, ec);
    return result;
}
static v8::Handle<v8::Value> addRuleCallback(const v8::Arguments& args)
{
    CSSStyleSheet* imp = V8CSSStyleSheet::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, selector, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, style, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
    if (args.Length() <= 2) {
        int result = imp->addRule(selector, style, ec);
        if (UNLIKELY(ec))
            goto fail;
        return v8Integer(result, args.GetIsolate());
    }
    V8TRYCATCH(unsigned, index, toUInt32(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)));
    int result = imp->addRule(selector, style, index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Integer(result, args.GetIsolate());
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
Example #4
0
static v8::Handle<v8::Value> addRuleCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.CSSStyleSheet.addRule");
    CSSStyleSheet* imp = V8CSSStyleSheet::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, selector, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, style, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
    if (args.Length() <= 2) {
        int result = imp->addRule(selector, style, ec);
        if (UNLIKELY(ec))
            goto fail;
        return v8::Integer::New(result);
    }
    EXCEPTION_BLOCK(unsigned, index, toUInt32(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)));
    int result = imp->addRule(selector, style, index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8::Integer::New(result);
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
Example #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;
}