More dashboard region work.
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Sep 2004 01:13:10 +0000 (01:13 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Sep 2004 01:13:10 +0000 (01:13 +0000)
Added support for computed style and cssText for new region property.
Added restriction on length types allowed in region functions.
Added initial and inheritance support for -apple-dashboard-region.

        Reviewed by Hyatt.

        * khtml/css/css_computedstyle.cpp:
        (DOM::CSSComputedStyleDeclarationImpl::getPropertyCSSValue):
        * khtml/css/css_valueimpl.cpp:
        (CSSPrimitiveValueImpl::cssText):
        * khtml/css/cssparser.cpp:
        (CSSParser::parseDashboardRegions):
        * khtml/css/cssstyleselector.cpp:
        (khtml::CSSStyleSelector::applyProperty):
        * khtml/rendering/render_object.cpp:
        (RenderObject::addDashboardRegions):
        * khtml/rendering/render_style.cpp:
        (RenderStyle::diff):
        * khtml/rendering/render_style.h:
        (khtml::StyleDashboardRegion::operator==):
        (khtml::RenderStyle::dashboardRegions):
        (khtml::RenderStyle::setDashboardRegions):
        (khtml::RenderStyle::initialDashboardRegions):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7626 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/css/css_computedstyle.cpp
WebCore/khtml/css/css_valueimpl.cpp
WebCore/khtml/css/cssparser.cpp
WebCore/khtml/css/cssstyleselector.cpp
WebCore/khtml/rendering/render_object.cpp
WebCore/khtml/rendering/render_style.cpp
WebCore/khtml/rendering/render_style.h

index 3474dbc41d7213e0659d2e5d943daa12ff15c74d..ba3a4d5f36d1cf4cc9aff7e54a57419a6a9eaebc 100644 (file)
@@ -1,3 +1,31 @@
+2004-09-21  Richard Williamson   <rjw@apple.com>
+
+       More dashboard region work.
+
+       Added support for computed style and cssText for new region property.
+       Added restriction on length types allowed in region functions.
+       Added initial and inheritance support for -apple-dashboard-region.
+
+        Reviewed by Hyatt.
+
+        * khtml/css/css_computedstyle.cpp:
+        (DOM::CSSComputedStyleDeclarationImpl::getPropertyCSSValue):
+        * khtml/css/css_valueimpl.cpp:
+        (CSSPrimitiveValueImpl::cssText):
+        * khtml/css/cssparser.cpp:
+        (CSSParser::parseDashboardRegions):
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::applyProperty):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::addDashboardRegions):
+        * khtml/rendering/render_style.cpp:
+        (RenderStyle::diff):
+        * khtml/rendering/render_style.h:
+        (khtml::StyleDashboardRegion::operator==):
+        (khtml::RenderStyle::dashboardRegions):
+        (khtml::RenderStyle::setDashboardRegions):
+        (khtml::RenderStyle::initialDashboardRegions):
+
 2004-09-21  Darin Adler  <darin@apple.com>
 
         Reviewed by Ken.
index 958faf304c9b6175592deecde2955176740e5b51..36b8468a51d78ab3613c5e08e468750b83f52fc6 100644 (file)
@@ -42,8 +42,10 @@ using khtml::ETextAlign;
 using khtml::Font;
 using khtml::FontDef;
 using khtml::Length;
+using khtml::LengthBox;
 using khtml::RenderStyle;
 using khtml::ShadowData;
+using khtml::StyleDashboardRegion;
 
 namespace DOM {
 
@@ -776,7 +778,33 @@ CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyI
     case CSS_PROP__KHTML_FLOW_MODE:
         // FIXME: unimplemented
         break;
+#if APPLE_CHANGES
+        case CSS_PROP__APPLE_DASHBOARD_REGION: {
+            QValueList<StyleDashboardRegion> regions = style->dashboardRegions();
+            uint i, count = regions.count();
+            DashboardRegionImpl *firstRegion = new DashboardRegionImpl(), *region;
+            region = firstRegion;
+            for (i = 0; i < count; i++) {
+                StyleDashboardRegion styleRegion = regions[i];
+                region->m_label = styleRegion.label;
+                LengthBox offset = styleRegion.offset;
+                region->setTop (new CSSPrimitiveValueImpl(offset.top.value, CSSPrimitiveValue::CSS_PX));
+                region->setRight (new CSSPrimitiveValueImpl(offset.right.value, CSSPrimitiveValue::CSS_PX));
+                region->setBottom (new CSSPrimitiveValueImpl(offset.bottom.value, CSSPrimitiveValue::CSS_PX));
+                region->setLeft (new CSSPrimitiveValueImpl(offset.left.value, CSSPrimitiveValue::CSS_PX));
+                region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle); 
+                region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
+                if (i != count-1) {
+                    DashboardRegionImpl *newRegion = new DashboardRegionImpl();
+                    region->setNext (newRegion);
+                    region = newRegion;
+                }
+            }
+            return new CSSPrimitiveValueImpl(firstRegion);
+        }
+#endif
     }
+
     ERROR("unimplemented propertyID: %d", propertyID);
     return 0;
 }
index d78802aeb07ffedae53829fbf63895b950c8b2a3..0188973f74142b9bc8e2389e8d95a99db8b9ac02 100644 (file)
@@ -816,6 +816,29 @@ DOM::DOMString CSSPrimitiveValueImpl::cssText() const
             text += ")";
             break;
         }
+#if APPLE_CHANGES        
+        case CSSPrimitiveValue::CSS_DASHBOARD_REGION: {
+            DashboardRegionImpl *region = getDashboardRegionValue();
+            while (region) {
+                if (region->m_isCircle){
+                    text = "dashboard-region-circle(";
+                }
+                else if (region->m_isRectangle){
+                    text = "dashboard-region-rectangle(";
+                }
+                else
+                    break;
+                text += region->m_label;
+                text += " ";
+                text += region->top()->cssText() + " ";
+                text += region->right()->cssText() + " ";
+                text += region->bottom()->cssText() + " ";
+                text += region->left()->cssText();
+                text += ")";
+            }
+            break;
+        }
+#endif
     }
     return text;
 }
index e963b8cc5227a64a80a0b43c1b9695f98b6a00e1..1aafe91959568f43fe9e7f858dc8ca7584bf21e0 100644 (file)
@@ -1572,6 +1572,10 @@ bool CSSParser::parseDashboardRegions( int propId, bool important )
             arg = args->next();
             arg = skipCommaInDashboardRegion (args);
 
+            valid = arg->id == CSS_VAL_AUTO || validUnit( arg, FLength, strict );
+            if ( !valid )
+                break;
+                
             CSSPrimitiveValueImpl *amount = arg->id == CSS_VAL_AUTO ?
                 new CSSPrimitiveValueImpl(CSS_VAL_AUTO) :
                 new CSSPrimitiveValueImpl(arg->fValue, (CSSPrimitiveValue::UnitTypes) arg->unit );
index 8e4f83409e23d65be6073fbbeea2a614a2b6b96d..65c2e98b18de0a2013047d0c95866accfc7753a5 100644 (file)
@@ -3711,8 +3711,11 @@ void CSSStyleSelector::applyProperty( int id, DOM::CSSValueImpl *value )
         break;
     }
     case CSS_PROP__APPLE_DASHBOARD_REGION: {
+        HANDLE_INHERIT_AND_INITIAL(dashboardRegions, DashboardRegions)
+
         if (!primitiveValue)
             return;
+
         DashboardRegionImpl *region = primitiveValue->getDashboardRegionValue();
         if (!region)
             return;
index 7b232a0db826a42ba1a1008586fd8de50d5cb2ec..2a6257d401e67d6a43c739e1cc223ca1a6689c1a 100644 (file)
@@ -2169,8 +2169,8 @@ void RenderObject::addDashboardRegions (QValueList<DashboardRegionValue>& region
             int x, y;
             absolutePosition (x, y);
             
-            int w = width() + marginLeft() + marginRight();
-            int h = height() + marginTop() + marginBottom();
+            int w = width();
+            int h = height();
             
             DashboardRegionValue region;
             region.label = styleRegion.label;
index 0b18e93091dfc329e0dc1d2be546722f38ae0285..ae52a1d51ea0ba08feb5bb81dcdf6b5fa6f95d22 100644 (file)
@@ -669,6 +669,12 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
        )
         return Visible;
 
+#if APPLE_CHANGES
+// If regions change trigger a relayout to re-calc regions.
+    if (!(m_dashboardRegions == other->m_dashboardRegions))
+        return Layout;
+#endif
+
     return Equal;
 }
 
index e546611834e32a88bed5c60f0f3c03d7433b8da6..5f818de2c7c945b7d4315f1e7912c488f905cdec 100644 (file)
@@ -354,6 +354,11 @@ struct StyleDashboardRegion
         Circle,
         Rectangle
     };
+
+    bool operator==(const StyleDashboardRegion& o) const
+    {
+        return type == o.type && offset == o.offset && label == o.label;
+    }
 };
 #endif
 
@@ -1165,7 +1170,8 @@ public:
     void setMaxHeight(Length v) { SET_VAR(box,max_height,v) }
 
 #if APPLE_CHANGES
-    QValueList<StyleDashboardRegion> dashboardRegions() { return m_dashboardRegions; }
+    QValueList<StyleDashboardRegion> dashboardRegions() const { return m_dashboardRegions; }
+    void setDashboardRegions(QValueList<StyleDashboardRegion> regions) { m_dashboardRegions = regions; }
     void setDashboardRegion (int type, QString label, Length t, Length r, Length b, Length l, bool append) {
         StyleDashboardRegion region;
         region.label = label;
@@ -1449,6 +1455,10 @@ public:
     // Keep these at the end.
     static int initialLineClamp() { return -1; }
     static bool initialTextSizeAdjust() { return true; }
+    static QValueList<StyleDashboardRegion> initialDashboardRegions() { 
+        QValueList<StyleDashboardRegion> emptyList;
+        return emptyList;
+    }
 #endif
 };