コード例 #1
0
Value DOMCSSStyleDeclaration::tryGet(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
    kdDebug(6070) << "DOMCSSStyleDeclaration::tryGet " << propertyName.qstring() << endl;
#endif
    const HashEntry *entry = Lookup::findEntry(&DOMCSSStyleDeclarationTable, propertyName);
    if(entry)
        switch(entry->value)
        {
            case CssText:
                return String(styleDecl.cssText());
            case Length:
                return Number(styleDecl.length());
            case ParentRule:
                return getDOMCSSRule(exec, styleDecl.parentRule());
            default:
                break;
        }

    // Look in the prototype (for functions) before assuming it's a name
    Object proto = Object::dynamicCast(prototype());
    if(proto.isValid() && proto.hasProperty(exec, propertyName))
        return proto.get(exec, propertyName);

    bool ok;
    long unsigned int u = propertyName.toULong(&ok);
    if(ok)
        return String(DOM::CSSStyleDeclaration(styleDecl).item(u));

    // pixelTop returns "CSS Top" as number value in unit pixels
    // posTop returns "CSS top" as number value in unit pixels _if_ its a
    // positioned element. if it is not a positioned element, return 0
    // from MSIE documentation ### IMPLEMENT THAT (Dirk)
    bool asNumber;
    QString p = cssPropertyName(propertyName, asNumber);

#ifdef KJS_VERBOSE
    kdDebug(6070) << "DOMCSSStyleDeclaration: converting to css property name: " << p << (asNumber ? "px" : "") << endl;
#endif

    if(asNumber)
    {
        DOM::CSSValue v = styleDecl.getPropertyCSSValue(p);
        if(!v.isNull() && v.cssValueType() == DOM::CSSValue::CSS_PRIMITIVE_VALUE)
            return Number(static_cast< DOM::CSSPrimitiveValue >(v).getFloatValue(DOM::CSSPrimitiveValue::CSS_PX));
    }

    DOM::DOMString str = const_cast< DOM::CSSStyleDeclaration & >(styleDecl).getPropertyValue(p);
    if(!str.isNull())
        return String(str);

    // see if we know this css property, return empty then
    if(DOM::getPropertyID(p.latin1(), p.length()))
        return String(DOM::DOMString(""));

    return DOMObject::tryGet(exec, propertyName);
}
コード例 #2
0
Value DOMCSSStyleSheet::tryGet(ExecState *exec, const Identifier &p) const
{
    DOM::CSSStyleSheet cssStyleSheet = static_cast< DOM::CSSStyleSheet >(styleSheet);
    if(p == "ownerRule")
        return getDOMCSSRule(exec, cssStyleSheet.ownerRule());
    else if(p == "cssRules" || p == "rules" /* MSIE extension */)
        return getDOMCSSRuleList(exec, cssStyleSheet.cssRules());
    return DOMStyleSheet::tryGet(exec, p);
}
コード例 #3
0
Value DOMCSSRuleListFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
  KJS_CHECK_THIS( KJS::DOMCSSRuleList, thisObj );
  DOM::CSSRuleList cssRuleList = static_cast<DOMCSSRuleList *>(thisObj.imp())->toCSSRuleList();
  switch (id) {
    case DOMCSSRuleList::Item:
      return getDOMCSSRule(exec,cssRuleList.item(args[0].toInteger(exec)));
    default:
      return Undefined();
  }
}
コード例 #4
0
Value DOMCSSRule::getValueProperty(ExecState *exec, int token) const
{
    switch(token)
    {
        case Type:
            return Number(cssRule.type());
        case CssText:
            return String(cssRule.cssText());
        case ParentStyleSheet:
            return getDOMStyleSheet(exec, cssRule.parentStyleSheet());
        case ParentRule:
            return getDOMCSSRule(exec, cssRule.parentRule());

        // for DOM::CSSRule::STYLE_RULE:
        case Style_SelectorText:
            return String(static_cast< DOM::CSSStyleRule >(cssRule).selectorText());
        case Style_Style:
            return getDOMCSSStyleDeclaration(exec, static_cast< DOM::CSSStyleRule >(cssRule).style());

        // for DOM::CSSRule::MEDIA_RULE:
        case Media_Media:
            return getDOMMediaList(exec, static_cast< DOM::CSSMediaRule >(cssRule).media());
        case Media_CssRules:
            return getDOMCSSRuleList(exec, static_cast< DOM::CSSMediaRule >(cssRule).cssRules());

        // for DOM::CSSRule::FONT_FACE_RULE:
        case FontFace_Style:
            return getDOMCSSStyleDeclaration(exec, static_cast< DOM::CSSFontFaceRule >(cssRule).style());

        // for DOM::CSSRule::PAGE_RULE:
        case Page_SelectorText:
            return String(static_cast< DOM::CSSPageRule >(cssRule).selectorText());
        case Page_Style:
            return getDOMCSSStyleDeclaration(exec, static_cast< DOM::CSSPageRule >(cssRule).style());

        // for DOM::CSSRule::IMPORT_RULE:
        case Import_Href:
            return String(static_cast< DOM::CSSImportRule >(cssRule).href());
        case Import_Media:
            return getDOMMediaList(exec, static_cast< DOM::CSSImportRule >(cssRule).media());
        case Import_StyleSheet:
            return getDOMStyleSheet(exec, static_cast< DOM::CSSImportRule >(cssRule).styleSheet());

        // for DOM::CSSRule::CHARSET_RULE:
        case Charset_Encoding:
            return String(static_cast< DOM::CSSCharsetRule >(cssRule).encoding());

        default:
            kdDebug(6070) << "WARNING: DOMCSSRule::getValueProperty unhandled token " << token << endl;
    }
    return Undefined();
}
コード例 #5
0
Value DOMCSSRuleList::tryGet(ExecState *exec, const Identifier &p) const
{
    Value result;
    if(p == lengthPropertyName)
        return Number(cssRuleList.length());
    else if(p == "item")
        return lookupOrCreateFunction< DOMCSSRuleListFunc >(exec, p, this, DOMCSSRuleList::Item, 1, DontDelete | Function);

    bool ok;
    long unsigned int u = p.toULong(&ok);
    if(ok)
        return getDOMCSSRule(exec, DOM::CSSRuleList(cssRuleList).item(u));

    return DOMObject::tryGet(exec, p);
}