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

List:       kde-commits
Subject:    branches/KDE/4.1/kdelibs/khtml/css
From:       Germain Garand <germain () ebooksfrance ! org>
Date:       2008-09-15 4:22:12
Message-ID: 1221452532.957367.18762.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 861083 by ggarand:

automatically merged revision 859314:
compute proper getPropertyValue for the 'border' shorthand

adapted patch by Rob Buis.

 M  +43 -3     css_valueimpl.cpp  
 M  +1 -0      css_valueimpl.h  


--- branches/KDE/4.1/kdelibs/khtml/css/css_valueimpl.cpp #861082:861083
@@ -189,9 +189,30 @@
     }
     case CSS_PROP_BORDER:
     {
-        const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE,
-                                    CSS_PROP_BORDER_COLOR };
-        return getShortHandValue( properties, 3 );
+            const int properties[3][4] = {{ CSS_PROP_BORDER_TOP_WIDTH,
+                                            CSS_PROP_BORDER_RIGHT_WIDTH,
+                                            CSS_PROP_BORDER_BOTTOM_WIDTH,
+                                            CSS_PROP_BORDER_LEFT_WIDTH },
+                                          { CSS_PROP_BORDER_TOP_STYLE,
+                                            CSS_PROP_BORDER_RIGHT_STYLE,
+                                            CSS_PROP_BORDER_BOTTOM_STYLE,
+                                            CSS_PROP_BORDER_LEFT_STYLE },
+                                          { CSS_PROP_BORDER_TOP_COLOR,
+                                            CSS_PROP_BORDER_RIGHT_COLOR,
+                                            CSS_PROP_BORDER_LEFT_COLOR,
+                                            CSS_PROP_BORDER_BOTTOM_COLOR }};
+            DOMString res;
+            const int nrprops = sizeof(properties) / sizeof(properties[0]);
+            for (int i = 0; i < nrprops; ++i) {
+                DOMString value = getCommonValue(properties[i], 4);
+                if (!value.isNull()) {
+                    if (!res.isNull())
+                        res += " ";
+                    res += value;
+                }
+            }
+            return res;
+
     }
     case CSS_PROP_BORDER_TOP:
     {
@@ -263,6 +284,25 @@
     //kDebug() << "property not found:" << propertyID;
     return DOMString();
 }
+ 
+// only returns a non-null value if all properties have the same, non-null value
+DOMString CSSStyleDeclarationImpl::getCommonValue(const int* properties, int number) const
+{
+    DOMString res;
+    for (int i = 0; i < number; ++i) {
+            CSSValueImpl* value = getPropertyCSSValue(properties[i]);
+            if (!value)
+                return DOMString();
+            DOMString text = value->cssText();
+            if (text.isNull())
+                return DOMString();
+            if (res.isNull())
+                res = text;
+            else if (res != text)
+                return DOMString();
+    }
+    return res;
+}
 
 DOMString CSSStyleDeclarationImpl::get4Values( const int* properties ) const
 {
--- branches/KDE/4.1/kdelibs/khtml/css/css_valueimpl.h #861082:861083
@@ -96,6 +96,7 @@
 
 protected:
     DOMString getShortHandValue( const int* properties, int number ) const;
+    DOMString getCommonValue(const int* properties, int number) const;
     DOMString getLayeredShortHandValue(const int* properties, unsigned number) const;
     DOMString get4Values( const int* properties ) const;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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