Ejemplo n.º 1
0
void CSSStyleSheetImpl::recomputeNamespaceInfo()
{
    assert(!m_namespaces);

    m_namespaces = new QList<CSSNamespaceRuleImpl *>;
    m_defaultNamespace = NamespaceName::fromId(anyNamespace);

    // Compute list of all the @namespace nodes, as well as the default one.
    for (int i = 0; i < m_lstChildren->count(); ++i) {
        StyleBaseImpl *b = m_lstChildren->at(i);
        if (b->isRule() && static_cast<CSSRuleImpl *>(b)->type() == DOM::CSSRule::NAMESPACE_RULE) {
            CSSNamespaceRuleImpl *nr = static_cast<CSSNamespaceRuleImpl *>(b);
            DOM::DOMString prefix = nr->prefix();
            DOM::DOMString uri    = nr->namespaceURI();

            if (uri.isNull()) {
                continue;
            }

            if (nr->isDefault()) {
                m_defaultNamespace = NamespaceName::fromString(uri);
            }

            m_namespaces->append(nr);
        }
    }
}
Ejemplo n.º 2
0
KJSO KJS::getString(DOM::DOMString s)
{
  if (s.isNull())
    return Null();
  else
    return String(s);
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
0
UString::UString(const DOM::DOMString &d)
{
  if (d.isNull()) {
    attach(&Rep::null);
    return;
  }

  unsigned int len = d.length();
  UChar *dat = new UChar[len];
  memcpy(dat, d.unicode(), len * sizeof(UChar));
  rep = UString::Rep::create(dat, len);
}
Ejemplo n.º 5
0
UString::UString(const DOM::DOMString &d)
{
    if(d.isNull())
    {
        // we do a conversion here as null DOMStrings shouldn't cross
        // the boundary to kjs. They should either be empty strings
        // or explicitly converted to KJS::Null via getString().
        attach(&Rep::empty);
        return;
    }

    unsigned int len = d.length();
    UChar *dat = new UChar[len];
    memcpy(dat, d.unicode(), len * sizeof(UChar));
    rep = UString::Rep::create(dat, len);
}