示例#1
0
Value MimeTypes::get(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
    kdDebug(6070) << "MimeTypes::get " << propertyName.qstring() << endl;
#endif
    if(!pluginsEnabled())
    {
        if(propertyName == lengthPropertyName)
            return Number(0);
    }
    else
    {
        if(propertyName == lengthPropertyName)
            return Number(mimes->count());

        // mimeTypes[#]
        bool ok;
        unsigned int i = propertyName.toULong(&ok);
        if(ok && i < mimes->count())
            return Value(new MimeType(exec, mimes->at(i)));

        // mimeTypes[name]
        Value val = mimeTypeByName(exec, propertyName.qstring());
        if(!val.isA(UndefinedType))
            return val;
    }

    return lookupGet< MimeTypesFunc, MimeTypes, ObjectImp >(exec, propertyName, &MimeTypesTable, this);
}
示例#2
0
Value Plugin::get(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
    kdDebug(6070) << "Plugin::get " << propertyName.qstring() << endl;
#endif
    if(propertyName == lengthPropertyName)
        return Number(m_info->mimes.count());

    // plugin[#]
    bool ok;
    unsigned int i = propertyName.toULong(&ok);
    // kdDebug(6070) << "Plugin::get plugin[" << i << "]" << endl;
    if(ok && i < m_info->mimes.count())
    {
        // kdDebug(6070) << "returning mimetype " << m_info->mimes.at(i)->type << endl;
        return Value(new MimeType(exec, m_info->mimes.at(i)));
    }

    // plugin["name"]
    Value val = mimeByName(exec, propertyName.qstring());
    if(!val.isA(UndefinedType))
        return val;

    return lookupGet< PluginFunc, Plugin, ObjectImp >(exec, propertyName, &PluginTable, this);
}
示例#3
0
KDE_NO_EXPORT
Value EmbedLiveConnect::get(ExecState *, const Identifier &prop) const
{
    if(m_liveconnect)
    {
        KParts::LiveConnectExtension::Type rettype;
        QString retval;
        unsigned long retobjid;
        if(m_liveconnect->get(objid, prop.qstring(), rettype, retobjid, retval))
            return getLiveConnectValue(m_liveconnect, prop.qstring(), rettype, retval, retobjid);
    }
    return Undefined();
}
示例#4
0
Value MimeType::get(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
    kdDebug(6070) << "MimeType::get " << propertyName.qstring() << endl;
#endif
    return lookupGetValue< MimeType, ObjectImp >(exec, propertyName, &MimeTypeTable, this);
}
示例#5
0
void DOMCSSStyleDeclaration::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr )
{
#ifdef KJS_VERBOSE
  kdDebug(6070) << "DOMCSSStyleDeclaration::tryPut " << propertyName.qstring() << endl;
#endif
  if (propertyName == "cssText") {
    styleDecl.setCssText(value.toString(exec).string());
  }
  else {
    bool pxSuffix;
    QString prop = cssPropertyName(propertyName, pxSuffix);
    QString propvalue = value.toString(exec).qstring();

    if (pxSuffix)
      propvalue += "px";
#ifdef KJS_VERBOSE
    kdDebug(6070) << "DOMCSSStyleDeclaration: prop=" << prop << " propvalue=" << propvalue << endl;
#endif
    // Look whether the property is known.d In that case add it as a CSS property.
    if (DOM::getPropertyID(prop.latin1(), prop.length())) {
      if (propvalue.isEmpty())
        styleDecl.removeProperty(prop);
      else {
        int important = propvalue.find("!important", 0, false);
        if (important == -1)
            styleDecl.setProperty(prop, DOM::DOMString(propvalue), "");
        else
            styleDecl.setProperty(prop, DOM::DOMString(propvalue.left(important - 1)), "important");
      }
    }
    else
      // otherwise add it as a JS property
      DOMObject::tryPut( exec, propertyName, value, attr );
  }
}
示例#6
0
bool KeyboardEventConstructor::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
#ifdef KJS_VERBOSE
  kDebug(6070) << "DOMKeyboardEvent::getOwnPropertySlot " << propertyName.qstring();
#endif
  return getStaticValueSlot<KeyboardEventConstructor, DOMObject>(exec,&KeyboardEventConstructorTable,this,propertyName,slot);
}
示例#7
0
bool DOMKeyboardEvent::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
#ifdef KJS_VERBOSE
  kDebug(6070) << "DOMKeyboardEvent::getOwnPropertySlot " << propertyName.qstring();
#endif
  return getStaticValueSlot<DOMKeyboardEvent, DOMKeyEventBase>(exec,&DOMKeyboardEventTable,this,propertyName,slot);
}
示例#8
0
bool DOMEvent::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
#ifdef KJS_VERBOSE
  kDebug() << "KJS::DOMEvent::getOwnPropertySlot " << propertyName.qstring();
#endif

  return getStaticValueSlot<DOMEvent, DOMObject>(exec,&DOMEventTable,this,propertyName,slot);
}
示例#9
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);
}
示例#10
0
Value DOMStyleSheetList::tryGet(ExecState *exec, const Identifier &p) const
{
#ifdef KJS_VERBOSE
    kdDebug(6070) << "DOMStyleSheetList::tryGet " << p.qstring() << endl;
#endif
    if(p == lengthPropertyName)
        return Number(styleSheetList.length());
    else if(p == "item")
        return lookupOrCreateFunction< DOMStyleSheetListFunc >(exec, p, this, DOMStyleSheetList::Item, 1, DontDelete | Function);

    // Retrieve stylesheet by index
    bool ok;
    long unsigned int u = p.toULong(&ok);
    if(ok)
        return getDOMStyleSheet(exec, DOM::StyleSheetList(styleSheetList).item(u));

// IE also supports retrieving a stylesheet by name, using the name/id of the <style> tag
// (this is consistent with all the other collections)
#if 0
  // Bad implementation because DOM::StyleSheet doesn't inherit DOM::Node
  // so we can't use DOMNamedNodesCollection.....
  // We could duplicate it for stylesheets though - worth it ?
  // Other problem of this implementation: it doesn't look for the ID attribute!
  DOM::NameNodeListImpl namedList( m_doc.documentElement().handle(), p.string() );
  int len = namedList.length();
  if ( len ) {
    QValueList<DOM::Node> styleSheets;
    for ( int i = 0 ; i < len ; ++i ) {
      DOM::HTMLStyleElement elem = DOM::Node(namedList.item(i));
      if (!elem.isNull())
        styleSheets.append(elem.sheet());
    }
    if ( styleSheets.count() == 1 ) // single result
      return getDOMStyleSheet(exec, styleSheets[0]);
    else if ( styleSheets.count() > 1 ) {
      return new DOMNamedItemsCollection(exec,styleSheets);
    }
  }
#endif
    // ### Bad implementation because returns a single element (are IDs always unique?)
    // and doesn't look for name attribute (see implementation above).
    // But unicity of stylesheet ids is good practice anyway ;)
    DOM::DOMString pstr = p.string();
    DOM::HTMLStyleElement styleElem = m_doc.getElementById(pstr);
    if(!styleElem.isNull())
        return getDOMStyleSheet(exec, styleElem.sheet());

    return DOMObject::tryGet(exec, p);
}
示例#11
0
/*
@begin DOMCSSRuleTable 4
  type			DOMCSSRule::Type	DontDelete|ReadOnly
  cssText		DOMCSSRule::CssText	DontDelete|ReadOnly
  parentStyleSheet	DOMCSSRule::ParentStyleSheet	DontDelete|ReadOnly
  parentRule		DOMCSSRule::ParentRule	DontDelete|ReadOnly
@end
@begin DOMCSSStyleRuleTable 2
  selectorText		DOMCSSRule::Style_SelectorText	DontDelete
  style			DOMCSSRule::Style_Style		DontDelete|ReadOnly
@end
@begin DOMCSSMediaRuleTable 4
  media			DOMCSSRule::Media_Media		DontDelete|ReadOnly
  cssRules		DOMCSSRule::Media_CssRules	DontDelete|ReadOnly
  insertRule		DOMCSSRule::Media_InsertRule	DontDelete|Function 2
  deleteRule		DOMCSSRule::Media_DeleteRule	DontDelete|Function 1
@end
@begin DOMCSSFontFaceRuleTable 1
  style			DOMCSSRule::FontFace_Style	DontDelete|ReadOnly
@end
@begin DOMCSSPageRuleTable 2
  selectorText		DOMCSSRule::Page_SelectorText	DontDelete
  style			DOMCSSRule::Page_Style		DontDelete|ReadOnly
@end
@begin DOMCSSImportRuleTable 3
  href			DOMCSSRule::Import_Href		DontDelete|ReadOnly
  media			DOMCSSRule::Import_Media	DontDelete|ReadOnly
  styleSheet		DOMCSSRule::Import_StyleSheet	DontDelete|ReadOnly
@end
@begin DOMCSSCharsetRuleTable 1
  encoding		DOMCSSRule::Charset_Encoding	DontDelete
@end
*/
Value DOMCSSRule::tryGet(ExecState *exec, const Identifier &propertyName) const
{
#ifdef KJS_VERBOSE
  kdDebug(6070) << "DOMCSSRule::tryGet " << propertyName.qstring() << endl;
#endif
  const HashTable* table = classInfo()->propHashTable; // get the right hashtable
  const HashEntry* entry = Lookup::findEntry(table, propertyName);
  if (entry) {
    if (entry->attr & Function)
      return lookupOrCreateFunction<DOMCSSRuleFunc>(exec, propertyName, this, entry->value, entry->params, entry->attr);
    return getValueProperty(exec, entry->value);
  }

  // Base CSSRule stuff or parent class forward, as usual
  return DOMObjectLookupGet<DOMCSSRuleFunc, DOMCSSRule, DOMObject>(exec, propertyName, &DOMCSSRuleTable, this);
}
示例#12
0
KDE_NO_EXPORT
void EmbedLiveConnect::put(ExecState *exec, const Identifier &prop, const Value &value, int)
{
    if(m_liveconnect)
        m_liveconnect->put(objid, prop.qstring(), value.toString(exec).qstring());
}