コード例 #1
0
JSValue* jsCSSStyleDeclarationPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSCSSStyleDeclaration::s_info))
        return throwError(exec, TypeError);
    JSCSSStyleDeclaration* castedThisObj = static_cast<JSCSSStyleDeclaration*>(thisValue);
    CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThisObj->impl());
    unsigned index = args[0]->toInt32(exec);


    KJS::JSValue* result = jsStringOrNull(exec, imp->item(index));
    return result;
}
コード例 #2
0
JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info))
        return throwError(exec, TypeError);
    JSCSSStyleDeclaration* castedThisObj = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
    CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThisObj->impl());
    unsigned index = args.at(0).toInt32(exec);


    JSC::JSValue result = jsStringOrNull(exec, imp->item(index));
    return result;
}
コード例 #3
0
EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionItem(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
        return throwVMTypeError(exec);
    JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
    CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
    unsigned index(exec->argument(0).toUInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = jsString(exec, imp->item(index));
    return JSValue::encode(result);
}
コード例 #4
0
QVariantMap DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(const QWebElement& element)
{
    QVariantMap res;

    WebCore::Element* webElement = element.m_element;
    if (!webElement)
        return res;

    RefPtr<WebCore::CSSComputedStyleDeclaration> computedStyleDeclaration = CSSComputedStyleDeclaration::create(webElement, true);
    CSSStyleDeclaration* style = static_cast<WebCore::CSSStyleDeclaration*>(computedStyleDeclaration.get());
    for (unsigned i = 0; i < style->length(); i++) {
        QString name = style->item(i);
        QString value = style->getPropertyValue(name);
        res[convertToPropertyName(name)] = QVariant(value);
    }
    return res;
}
コード例 #5
0
JSValue* JSCSSStyleDeclarationPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSCSSStyleDeclaration::info))
      return throwError(exec, TypeError);

    CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(static_cast<JSCSSStyleDeclaration*>(thisObj)->impl());

    switch (id) {
    case JSCSSStyleDeclaration::GetPropertyValueFuncNum: {
        String propertyName = args[0]->toString(exec);


        KJS::JSValue* result = jsStringOrNull(imp->getPropertyValue(propertyName));
        return result;
    }
    case JSCSSStyleDeclaration::GetPropertyCSSValueFuncNum: {
        String propertyName = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getPropertyCSSValue(propertyName)));
        return result;
    }
    case JSCSSStyleDeclaration::RemovePropertyFuncNum: {
        ExceptionCode ec = 0;
        String propertyName = args[0]->toString(exec);


        KJS::JSValue* result = jsStringOrNull(imp->removeProperty(propertyName, ec));
        setDOMException(exec, ec);
        return result;
    }
    case JSCSSStyleDeclaration::GetPropertyPriorityFuncNum: {
        String propertyName = args[0]->toString(exec);


        KJS::JSValue* result = jsStringOrNull(imp->getPropertyPriority(propertyName));
        return result;
    }
    case JSCSSStyleDeclaration::SetPropertyFuncNum: {
        ExceptionCode ec = 0;
        String propertyName = args[0]->toString(exec);
        String value = valueToStringWithNullCheck(exec, args[1]);
        String priority = args[2]->toString(exec);

        imp->setProperty(propertyName, value, priority, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }
    case JSCSSStyleDeclaration::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 JSCSSStyleDeclaration::GetPropertyShorthandFuncNum: {
        String propertyName = args[0]->toString(exec);


        KJS::JSValue* result = jsStringOrNull(imp->getPropertyShorthand(propertyName));
        return result;
    }
    case JSCSSStyleDeclaration::IsPropertyImplicitFuncNum: {
        String propertyName = args[0]->toString(exec);


        KJS::JSValue* result = jsBoolean(imp->isPropertyImplicit(propertyName));
        return result;
    }
    }
    return 0;
}