[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/khtml/ecma
From:       Maks Orlovich <maksim () kde ! org>
Date:       2009-12-30 2:37:23
Message-ID: 1262140643.419576.30703.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1067634 by orlovich:

Enumerate dynamic properties in CSSStyleDeclaration
(Note: this includes the SVG properties as well...)

BUG:220627



 M  +28 -4     kjs_css.cpp  
 M  +5 -4      kjs_css.h  


--- trunk/KDE/kdelibs/khtml/ecma/kjs_css.cpp #1067633:1067634
@@ -34,6 +34,7 @@
 #include "css/css_renderstyledeclarationimpl.h"
 #include "css/css_stylesheetimpl.h"
 #include "css/css_valueimpl.h"
+#include "css/cssproperties.h"
 
 #include "misc/htmltags.h"
 
@@ -72,7 +73,7 @@
 
 static QString cssPropertyName( const Identifier &p, bool* hadPixelPrefix )
 {
-    // The point here is to provide compatibility with IE 
+    // The point here is to provide compatibility with IE
     // syntax for accessing properties, which camel-cases them
     // and can add prefixes to produce things like pixelFoo
     QString prop = p.qstring();
@@ -199,12 +200,12 @@
       CSSValueImpl *v = m_impl->getPropertyCSSValue(p);
       if (v && v->cssValueType() == DOM::CSSValue::CSS_PRIMITIVE_VALUE)
          //### FIXME: should this not set exception when type is wrong, or convert?
-        return getImmediateValueSlot(this, 
+        return getImmediateValueSlot(this,
                   jsNumber(static_cast<CSSPrimitiveValueImpl*>(v)->floatValue(DOM::CSSPrimitiveValue::CSS_PX)), \
slot);  }
 
     DOM::DOMString str = m_impl->getPropertyValue(p);
-    
+
     // We want to return at least an empty string here --- see #152791
     return getImmediateValueSlot(this, jsString(str), slot);
   }
@@ -212,7 +213,30 @@
   return DOMObject::getOwnPropertySlot(exec, propertyName, slot);
 }
 
+void DOMCSSStyleDeclaration::getOwnPropertyNames(ExecState* exec, PropertyNameArray& \
arr) +{
+    DOMObject::getOwnPropertyNames(exec, arr);
 
+    // Add in all properties we support.
+    for (int p = 1; p < CSS_PROP_TOTAL; ++p) {
+        QString dashName = getPropertyName(p).string();
+        QString camelName;
+
+        bool capitalize = false;
+        for (int c = 0; c < dashName.length(); ++c) {
+            if (dashName[c] == QLatin1Char('-')) {
+                capitalize = true;
+            } else {
+                camelName += capitalize ? dashName[c].toUpper() : dashName[c];
+                capitalize = false;
+            }
+        } // char
+
+        arr.add(KJS::Identifier(camelName));
+    } // prop
+}
+
+
 void DOMCSSStyleDeclaration::put(ExecState *exec, const Identifier &propertyName, \
JSValue *value, int attr )  {
 #ifdef KJS_VERBOSE
@@ -595,7 +619,7 @@
 */
 KJS_DEFINE_PROTOTYPE(DOMCSSStyleSheetProto)
 KJS_IMPLEMENT_PROTOFUNC(DOMCSSStyleSheetProtoFunc)
-KJS_IMPLEMENT_PROTOTYPE("DOMCSSStyleSheet",DOMCSSStyleSheetProto,DOMCSSStyleSheetProtoFunc, \
DOMStyleSheetProto)  \
+KJS_IMPLEMENT_PROTOTYPE("DOMCSSStyleSheet",DOMCSSStyleSheetProto,DOMCSSStyleSheetProtoFunc, \
DOMStyleSheetProto)  
 DOMCSSStyleSheet::DOMCSSStyleSheet(ExecState *exec, DOM::CSSStyleSheetImpl* ss): \
DOMStyleSheet(exec, ss)  {
--- trunk/KDE/kdelibs/khtml/ecma/kjs_css.h #1067633:1067634
@@ -39,6 +39,7 @@
     DOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclarationImpl* s);
     virtual ~DOMCSSStyleDeclaration();
     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
+    virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
     virtual void put(ExecState *exec, const Identifier &propertyName, JSValue \
*value, int attr = None);  JSValue *getValueProperty(ExecState *exec, int token);
 
@@ -47,7 +48,7 @@
     enum { CssText, Length, ParentRule,
            GetPropertyValue, GetPropertyCSSValue, RemoveProperty, \
GetPropertyPriority,  SetProperty, Item };
-           
+
     DOM::CSSStyleDeclarationImpl *impl() const { return m_impl.get(); }
 
     JSValue *indexGetter(ExecState* exec, unsigned index);
@@ -74,7 +75,7 @@
   protected:
     SharedPtr<DOM::StyleSheetImpl> m_impl;
   };
-  DEFINE_PSEUDO_CONSTRUCTOR(DOMStyleSheetPseudoCtor)  
+  DEFINE_PSEUDO_CONSTRUCTOR(DOMStyleSheetPseudoCtor)
 
   JSValue* getDOMStyleSheet(ExecState *exec, DOM::StyleSheetImpl* ss);
 
@@ -92,13 +93,13 @@
     virtual const ClassInfo* classInfo() const { return &info; }
     virtual bool toBoolean(ExecState* ) const { return true; }
     static const ClassInfo info;
-    
+
     DOM::StyleSheetListImpl* impl() const { return m_impl.get(); }
     enum { Item, Length };
     JSValue *indexGetter(ExecState* exec, unsigned index);
   private:
     static JSValue *nameGetter(ExecState *, JSObject*, const Identifier&, const \
                PropertySlot&);
-  
+
     SharedPtr<DOM::StyleSheetListImpl> m_impl;
     SharedPtr<DOM::DocumentImpl>       m_doc;
   };


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic