Fixed <rdar://problem/3813271> dashboard-region-circle and dashboard-region-rectangl...
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Sep 2004 00:17:57 +0000 (00:17 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Sep 2004 00:17:57 +0000 (00:17 +0000)
Fixed <rdar://problem/3813289> dashboard regions need to correctly account for overflow/scrolling

        Reviewed by Chris.

        * khtml/css/css_valueimpl.cpp:
        (CSSPrimitiveValueImpl::cssText):
        * khtml/css/css_valueimpl.h:
        * khtml/css/cssparser.cpp:
        (CSSParser::parseValue):
        (skipCommaInDashboardRegion):
        (CSSParser::parseDashboardRegions):
        * khtml/khtmlview.cpp:
        (KHTMLView::layout):
        (KHTMLView::updateDashboardRegions):
        * khtml/khtmlview.h:
        * khtml/rendering/render_layer.cpp:
        (RenderLayer::scrollToOffset):
        * khtml/rendering/render_object.cpp:
        (RenderObject::addDashboardRegions):
        * khtml/rendering/render_object.h:
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::dashboardRegionsChanged):
        * kwq/WebDashboardRegion.h:
        * kwq/WebDashboardRegion.m:
        (-[WebDashboardRegion initWithRect:clip:type:]):
        (-[WebDashboardRegion dashboardRegionClip]):
        (-[WebDashboardRegion description]):

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

12 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/khtml/css/css_valueimpl.cpp
WebCore/khtml/css/css_valueimpl.h
WebCore/khtml/css/cssparser.cpp
WebCore/khtml/khtmlview.cpp
WebCore/khtml/khtmlview.h
WebCore/khtml/rendering/render_layer.cpp
WebCore/khtml/rendering/render_object.cpp
WebCore/khtml/rendering/render_object.h
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/WebDashboardRegion.h
WebCore/kwq/WebDashboardRegion.m

index 36847fce5d58fb1e51a7d87717f4fa6dd3749d46..fb4d2b854429c500534f0be76123dee9393cdc4b 100644 (file)
@@ -1,3 +1,34 @@
+2004-09-23  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3813271> dashboard-region-circle and dashboard-region-rectangle should be collapsed into dashboard-region
+       Fixed <rdar://problem/3813289> dashboard regions need to correctly account for overflow/scrolling
+
+        Reviewed by Chris.
+
+        * khtml/css/css_valueimpl.cpp:
+        (CSSPrimitiveValueImpl::cssText):
+        * khtml/css/css_valueimpl.h:
+        * khtml/css/cssparser.cpp:
+        (CSSParser::parseValue):
+        (skipCommaInDashboardRegion):
+        (CSSParser::parseDashboardRegions):
+        * khtml/khtmlview.cpp:
+        (KHTMLView::layout):
+        (KHTMLView::updateDashboardRegions):
+        * khtml/khtmlview.h:
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::scrollToOffset):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::addDashboardRegions):
+        * khtml/rendering/render_object.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::dashboardRegionsChanged):
+        * kwq/WebDashboardRegion.h:
+        * kwq/WebDashboardRegion.m:
+        (-[WebDashboardRegion initWithRect:clip:type:]):
+        (-[WebDashboardRegion dashboardRegionClip]):
+        (-[WebDashboardRegion description]):
+
 2004-09-23  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Richard
index 0188973f74142b9bc8e2389e8d95a99db8b9ac02..4670df4e03b032d41ebb932864e66bbf19c008a1 100644 (file)
@@ -820,15 +820,16 @@ DOM::DOMString CSSPrimitiveValueImpl::cssText() const
         case CSSPrimitiveValue::CSS_DASHBOARD_REGION: {
             DashboardRegionImpl *region = getDashboardRegionValue();
             while (region) {
+                text = "dashboard-region(";
+                text += region->m_label;
                 if (region->m_isCircle){
-                    text = "dashboard-region-circle(";
+                    text = " circle ";
                 }
                 else if (region->m_isRectangle){
-                    text = "dashboard-region-rectangle(";
+                    text = " rectangle ";
                 }
                 else
                     break;
-                text += region->m_label;
                 text += " ";
                 text += region->top()->cssText() + " ";
                 text += region->right()->cssText() + " ";
index be1cfed395f035b74b93f05d047e676cea8159ec..e4869b5a0e9bf824f7b62fa68197261b90294d9b 100644 (file)
@@ -316,6 +316,7 @@ public:
 public:
     DashboardRegionImpl *m_next;
     QString m_label;
+    QString m_geometryType;
     unsigned int m_isCircle:1;
     unsigned int m_isRectangle:1;
 };
index 1aafe91959568f43fe9e7f858dc8ca7584bf21e0..e53e06f428b8d4f3a754610ad18ab40fb22943c5 100644 (file)
@@ -522,7 +522,7 @@ bool CSSParser::parseValue( int propId, bool important )
        break;
 
 #if APPLE_CHANGES
-    case CSS_PROP__APPLE_DASHBOARD_REGION:                 // <dashboard-region-circle> | <dashboard-region-rectangle
+    case CSS_PROP__APPLE_DASHBOARD_REGION:                 // <dashboard-region> | <dashboard-region
        if ( value->unit == Value::Function )
            return parseDashboardRegions( propId, important );
        break;
@@ -1502,9 +1502,11 @@ bool CSSParser::parseContent( int propId, bool important )
     return false;
 }
 
+#define DASHBOARD_REGION_NUM_PARAMETERS  6
+
 static Value *skipCommaInDashboardRegion (ValueList *args)
 {
-    if ( args->numValues == 9 ) {
+    if ( args->numValues == (DASHBOARD_REGION_NUM_PARAMETERS*2-1) ) {
         Value *current = args->current();
         if (current->unit == Value::Operator && current->iValue == ',' )
             return args->next();
@@ -1536,28 +1538,22 @@ bool CSSParser::parseDashboardRegions( int propId, bool important )
         }
             
         // Commas count as values, so allow:
-        // dashbaord-region-rectangle( label, t, r, b, l ) or dashbaord-region-rectangle( label t r b l )
-        // dashbaord-region-circle( label, t, r, b, l ) or dashbaord-region-circle( label t r b l )
+        // dashbaord-region( label, type, t, r, b, l ) or dashbaord-region( label type t r b l )
+        // dashbaord-region( label, type, t, r, b, l ) or dashbaord-region( label type t r b l )
         ValueList *args = value->function->args;
         int numArgs = value->function->args->numValues;
-        if (numArgs != 5 && numArgs != 9) {
+        if (numArgs != DASHBOARD_REGION_NUM_PARAMETERS && numArgs != (DASHBOARD_REGION_NUM_PARAMETERS*2-1)) {
             valid = false;
             break;
         }
         
         QString fname = qString( value->function->name ).lower();
-        if (fname == "dashboard-region-rectangle(" ) {
-            region->m_isRectangle = true;
-        }    
-        else if (fname == "dashboard-region-circle(" ) {
-            region->m_isCircle = true;
-        }
-        else {
+        if (fname != "dashboard-region(" ) {
             valid = false;
             break;
         }
             
-        // First arg should be a label.
+        // First arg is a label.
         Value *arg = args->current();
         if (arg->unit != CSSPrimitiveValue::CSS_IDENT) {
             valid = false;
@@ -1566,6 +1562,26 @@ bool CSSParser::parseDashboardRegions( int propId, bool important )
             
         region->m_label = qString(arg->string);
 
+        // Second arg is a type.
+        arg = args->next();
+        arg = skipCommaInDashboardRegion (args);
+        if (arg->unit != CSSPrimitiveValue::CSS_IDENT) {
+            valid = false;
+            break;
+        }
+
+        QString geometryType = qString(arg->string).lower();
+        if (geometryType == "circle")
+            region->m_isCircle = true;
+        else if (geometryType == "rectangle")
+            region->m_isRectangle = true;
+        else {
+            valid = false;
+            break;
+        }
+            
+        region->m_geometryType = qString(arg->string);
+
         // Next four arguments must be offset numbers
         int i;
         for (i = 0; i < 4; i++) {
index e9bc29b685bc83d057ff1d123780f3eed180d2ab..0699ee3bd31575184e1044cd1a5b93b6a3e01a4b 100644 (file)
@@ -701,14 +701,7 @@ void KHTMLView::layout()
 #endif
 
 #if APPLE_CHANGES
-    if (document->hasDashboardRegions()) {
-        QValueList<DashboardRegionValue> newRegions = document->renderer()->computeDashboardRegions();
-        QValueList<DashboardRegionValue> currentRegions = document->dashboardRegions();
-        if (!(newRegions == currentRegions)) {
-            document->setDashboardRegions(newRegions);
-            KWQ(m_part)->dashboardRegionsChanged(newRegions);
-        }
-    }
+    updateDashboardRegions();
 #endif
 
     if (root->needsLayout()) {
@@ -725,6 +718,21 @@ void KHTMLView::layout()
 #endif
 }
 
+#if APPLE_CHANGES
+void KHTMLView::updateDashboardRegions()
+{
+    DOM::DocumentImpl* document = m_part->xmlDocImpl();
+    if (document->hasDashboardRegions()) {
+        QValueList<DashboardRegionValue> newRegions = document->renderer()->computeDashboardRegions();
+        QValueList<DashboardRegionValue> currentRegions = document->dashboardRegions();
+        if (!(newRegions == currentRegions)) {
+            document->setDashboardRegions(newRegions);
+            KWQ(m_part)->dashboardRegionsChanged(newRegions);
+        }
+    }
+}
+#endif
+
 //
 // Event Handling
 //
index 48cb3dabd541e4265a5b1c126394182ab24ebcfe..36ee60c1f255ff5a13b676c506013ab77e8a1934 100644 (file)
@@ -222,6 +222,8 @@ public:
     QPoint viewportToGlobal(const QPoint &) const;
     void adjustViewSize();
     void initScrollBars();
+    
+    void updateDashboardRegions();
 #endif
 
     void ref() { ++_refCount; }
index 687129039fea3e459ef810d1e5fda5e8c23e60e0..ec48fc1dc120cd6fbcc4dc9051c15a72da700760 100644 (file)
@@ -462,6 +462,10 @@ RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repaint)
 #if APPLE_CHANGES
     // Move our widgets.
     m_object->updateWidgetPositions();
+    
+    // Update dashboard regions, scrolling may change the clip of a
+    // particular region.
+    renderer()->canvas()->view()->updateDashboardRegions();
 #endif
 
     // Fire the scroll DOM event.
index 370700278cac49ccb1d53c30d433649c55e3acfb..96037c4cbd38e917837a404148f095dd664d6e53 100644 (file)
@@ -2165,9 +2165,6 @@ void RenderObject::addDashboardRegions (QValueList<DashboardRegionValue>& region
         uint i, count = styleRegions.count();
         for (i = 0; i < count; i++){
             StyleDashboardRegion styleRegion = styleRegions[i];
-
-            int x, y;
-            absolutePosition (x, y);
             
             int w = width();
             int h = height();
@@ -2175,11 +2172,23 @@ void RenderObject::addDashboardRegions (QValueList<DashboardRegionValue>& region
             DashboardRegionValue region;
             region.label = styleRegion.label;
             region.bounds = QRect (
-                x + styleRegion.offset.left.value,
-                y + styleRegion.offset.top.value,
+                styleRegion.offset.left.value,
+                styleRegion.offset.top.value,
                 w - styleRegion.offset.left.value - styleRegion.offset.right.value,
                 h - styleRegion.offset.top.value - styleRegion.offset.bottom.value);
             region.type = styleRegion.type;
+
+            region.clip = region.bounds;
+            computeAbsoluteRepaintRect(region.clip);
+            if (region.clip.height() < 0) {
+                region.clip.setHeight(0);
+                region.clip.setWidth(0);
+            }
+
+            int x, y;
+            absolutePosition (x, y);
+            region.bounds.setX (x + styleRegion.offset.left.value);
+            region.bounds.setY (y + styleRegion.offset.left.value);
             
             regions.append (region);
         }
index a5549892f9afd719a2e150ed3a5fd75064a8ff3b..dc5d4da701194d56c1c20824a1c20c5fd289cd93 100644 (file)
@@ -107,6 +107,7 @@ struct DashboardRegionValue
 {
     QString label;
     QRect bounds;
+    QRect clip;
     int type;
 
     bool operator==(const DashboardRegionValue& o) const
index b9eafec651a62ccee39eb73e9bcd306e52e0b4e1..bfab205e8f993bee7aedbd3b92f02b338ed76b7f 100644 (file)
@@ -3941,6 +3941,11 @@ void KWQKHTMLPart::dashboardRegionsChanged(const QValueList<DashboardRegionValue
     NSMutableDictionary *webRegions = [[NSMutableDictionary alloc] initWithCapacity:count];
     for (i = 0; i < count; i++) {
         DashboardRegionValue region = regions[i];
+        NSRect clip;
+        clip.origin.x = region.clip.x();
+        clip.origin.y = region.clip.y();
+        clip.size.width = region.clip.width();
+        clip.size.height = region.clip.height();
         NSRect rect;
         rect.origin.x = region.bounds.x();
         rect.origin.y = region.bounds.y();
@@ -3958,7 +3963,7 @@ void KWQKHTMLPart::dashboardRegionsChanged(const QValueList<DashboardRegionValue
             [webRegions setObject:regionValues forKey:label];
         }
         
-        WebDashboardRegion *webRegion = [[[WebDashboardRegion alloc] initWithRect:rect type:type] autorelease];
+        WebDashboardRegion *webRegion = [[[WebDashboardRegion alloc] initWithRect:rect clip:clip type:type] autorelease];
         [regionValues addObject:webRegion];
     }
     
index bcec247a69c8c790128bd69431b9a48632f16ad6..ab9326fd55497f9a192f32479f1bc83859f5aea7 100644 (file)
@@ -33,9 +33,11 @@ typedef enum {
 @interface WebDashboardRegion : NSObject <NSCopying>
 {
     NSRect rect;
+    NSRect clip;
     WebDashboardRegionType type;
 }
-- initWithRect:(NSRect)rect type:(WebDashboardRegionType)type;
+- initWithRect:(NSRect)rect clip:(NSRect)clip type:(WebDashboardRegionType)type;
+- (NSRect)dashboardRegionClip;
 - (NSRect)dashboardRegionRect;
 - (WebDashboardRegionType)dashboardRegionType;
 @end
index cd421ca8a9ba1b64851450a214abd4d5e911f385..eb4555a0279c3f3cafa6b8bda6d728994f03bbd5 100644 (file)
 #import "WebDashboardRegion.h"
 
 @implementation WebDashboardRegion
-- initWithRect:(NSRect)r type:(WebDashboardRegionType)t
+- initWithRect:(NSRect)r clip:(NSRect)c type:(WebDashboardRegionType)t
 {
     self = [super init];
     rect = r;
+    clip = c;
     type = t;
     return self;
 }
     return [self retain];
 }
 
+- (NSRect)dashboardRegionClip
+{
+    return clip;
+}
+
 - (NSRect)dashboardRegionRect
 {
     return rect;
 }
+
 - (WebDashboardRegionType)dashboardRegionType
 {
     return type;
 }
+
 - (NSString *)description
 {
-    return [NSString stringWithFormat:@"rect:%@ type:%s",
+    return [NSString stringWithFormat:@"rect:%@ clip:%@ type:%s",
         NSStringFromRect(rect),
+        NSStringFromRect(clip),
         type == WebDashboardRegionTypeNone ? "None" :
             (type == WebDashboardRegionTypeCircle ? "Circle" :
                 (type == WebDashboardRegionTypeRectangle ? "Rectangle" :