Add more clipping retrieval functionality for widgets.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Oct 2006 09:01:58 +0000 (09:01 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Oct 2006 09:01:58 +0000 (09:01 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17002 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
WebCore/ChangeLog
WebCore/page/Frame.h
WebCore/page/FrameView.cpp
WebCore/page/FrameView.h
WebCore/platform/ScrollBar.h
WebCore/platform/ScrollView.h
WebCore/platform/Widget.h
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLayer.h
WebCore/rendering/RenderListBox.cpp
WebCore/rendering/RenderListBox.h
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h

index d765623afa6cb2ef83277a6a99196678a7a29a8a..509bd897603be33b67069b6052f23c4bb6b71b8b 100644 (file)
@@ -1,3 +1,52 @@
+2006-10-12  Dave Hyatt  <hyatt@apple.com>
+
+        Patch to add more clipping retrieval functionality for widgets.
+       
+        Reviewed by mjs
+
+        * page/Frame.h:
+        Remove windowResizerRect.  This is in the wrong place.
+        
+        * page/FrameView.cpp:
+        (WebCore::FrameView::windowClipRect):
+        (WebCore::FrameView::windowClipRectForLayer):
+        Break out windowClipRect into helper functions that can be called separately (to make
+        it easier for scrollbars in overflow sections and list boxes to get to an enclosing
+        layer and get the right clip.
+        
+        * page/FrameView.h:
+        Add the new windowClipRect helper methods.
+        
+        * platform/ScrollBar.h:
+        Add a new interface to ScrollbarClient so that scrollbars can hand back proper
+        clip rects for themselves depending on how they are used.
+        
+        * platform/ScrollView.h:
+        Stub out methods for talking to a double buffer backing store on Win32.
+        
+        * platform/Widget.h:
+        Add the ability to query for invalidation suppression.
+        
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::windowClipRect):
+        (WebCore::RenderLayer::paintOverflowControls):
+        (WebCore::RenderLayer::calculateRects):
+        (WebCore::RenderLayer::childrenClipRect):
+        (WebCore::RenderLayer::selfClipRect):
+        * rendering/RenderLayer.h:
+        Enhance layers so that they can return either their foreground or background
+        document clip rects.  Make sure a layer scrollbar can return a proper clip.
+        
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::windowClipRect):
+        * rendering/RenderListBox.h:
+        Make sure a list box scrollbar can return a proper clip.
+        
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::enclosingLayer):
+        * rendering/RenderObject.h:
+        Make enclosingLayer const.
+        
 2006-10-11  Darin Adler  <darin@apple.com>
 
         Reviewed by John.
index 8929ad9e54b35def59ee068c3114e34a6244b054..258a620afa0f300b4d4b20fbd243494dd2b95b0d 100644 (file)
@@ -751,12 +751,10 @@ private:
   
   void replaceContentsWithScriptResult(const KURL& url);
 
-    void disconnectOwnerElement();
+  void disconnectOwnerElement();
 
-    void setNeedsReapplyStyles();
+  void setNeedsReapplyStyles();
 
-  virtual IntRect windowResizerRect() const { return IntRect(); }
-  
   void stopAutoscrollTimer();
   RenderObject* autoscrollRenderer() const;
 
index 392aaa999dcc6c3cf07e3db5a7023e4de99a0759..7162086669744dd61376748eff39e68678e731b5 100644 (file)
@@ -1485,8 +1485,17 @@ void FrameView::dispatchScheduledEvents()
 
 IntRect FrameView::windowClipRect() const
 {
-    // Get our parent's clip rect.
-    IntRect clipRect(enclosingIntRect(visibleContentRect()));
+    return windowClipRect(true);
+}
+
+IntRect FrameView::windowClipRect(bool clipToContents) const
+{
+    // Set our clip rect to be our contents.
+    IntRect clipRect;
+    if (clipToContents)
+        clipRect = enclosingIntRect(visibleContentRect());
+    else
+        clipRect = IntRect(contentsX(), contentsY(), width(), height());
     clipRect.setLocation(contentsToWindow(clipRect.location()));
     if (!m_frame || !m_frame->document() || !m_frame->document()->ownerElement())
         return clipRect;
@@ -1494,15 +1503,26 @@ IntRect FrameView::windowClipRect() const
     // Take our owner element and get the clip rect from the enclosing layer.
     Element* elt = m_frame->document()->ownerElement();
     RenderLayer* layer = elt->renderer()->enclosingLayer();
+    FrameView* parentView = elt->document()->view();
+    clipRect.intersect(parentView->windowClipRectForLayer(layer, true));
+    return clipRect;
+}
 
+IntRect FrameView::windowClipRectForLayer(const RenderLayer* layer, bool clipToLayerContents) const
+{
     // Apply the clip from the layer.
-    FrameView* parentView = elt->document()->view();
-    IntRect layerClipRect = layer->documentClipRect();
-    layerClipRect.setLocation(parentView->contentsToWindow(layerClipRect.location()));
-    clipRect.intersect(layerClipRect);
+    IntRect clipRect;
+    if (clipToLayerContents)
+        clipRect = layer->childrenClipRect();
+    else
+        clipRect = layer->selfClipRect();
+
+    clipRect.setLocation(contentsToWindow(clipRect.location()));
+    // Now apply the clip from our view.
+    clipRect.intersect(windowClipRect());
 
-    // Now apply the clip from our ancestor.
-    clipRect.intersect(parentView->windowClipRect());
+    // Return the result.
     return clipRect;
 }
 
index d000121319ee88d7cad665325bae28809c25bc9c..b4566e30ec282e6f837b815817563d6d08fc553d 100644 (file)
@@ -61,6 +61,7 @@ class MouseEventWithHitTestResults;
 class Node;
 class RenderBox;
 class RenderView;
+class RenderLayer;
 class RenderLineEdit;
 class RenderObject;
 class RenderPart;
@@ -190,6 +191,8 @@ public:
 #endif
 
     virtual IntRect windowClipRect() const;
+    IntRect windowClipRect(bool clipToContents) const;
+    IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const;
 
     virtual void scrollPointRecursively(int x, int y);
     virtual void setContentsPos(int x, int y);
index 9abf8e3f7b18273ea25b168a700e9a514e8f57ef..db33de4b16bf4bac6115c66c96aa83d56d2cba69 100644 (file)
@@ -61,6 +61,9 @@ class ScrollbarClient {
 public:
     virtual ~ScrollbarClient() {}
     virtual void valueChanged(Scrollbar*) = 0;
+
+    // Used to obtain a window clip rect.
+    virtual IntRect windowClipRect() const = 0;
 };
 
 class Scrollbar : public Shared<Scrollbar> {
index edc87438f43f7e54fac621bf184a4caa6c44e8d6..16347f6e11a4d6e20c12cd3e62008c13ec1c225e 100644 (file)
 class QScrollArea;
 #endif
 
+#if PLATFORM(WIN)
+typedef struct HRGN__* HRGN;
+#endif
+
 namespace WebCore {
     class FloatRect;
     class PlatformWheelEvent;
@@ -114,6 +118,10 @@ namespace WebCore {
         IntRect windowResizerRect();
         bool resizerOverlapsContent() const;
 
+        void addToDirtyRegion(const IntRect&);
+        void scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect);
+        void updateBackingStore();
+
     private:
         void updateScrollbars(const IntSize& desiredOffset);
         IntSize maximumScroll() const;
index 7ffbe77d4246c049b5a2ceab1c5b1dde0a789a22..ec8de8768bf120a0d307470bfd384539c46ba23f 100644 (file)
@@ -165,6 +165,7 @@ namespace WebCore {
         virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const;
         virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const;
 
+        bool suppressInvalidation() const;
         void setSuppressInvalidation(bool);
 
         // These methods will be called on a widget while it is capturing the mouse.
index 749d5dc8c4fb70d84a3be8c6e4acdef5483428ac..1d93e633d61497a0028b37b188423c7d4a3b9922 100644 (file)
@@ -966,6 +966,11 @@ void RenderLayer::valueChanged(Scrollbar*)
         scrollToOffset(newX, newY, false);
 }
 
+IntRect RenderLayer::windowClipRect() const
+{
+    return renderer()->view()->frameView()->windowClipRectForLayer(this, false);
+}
+
 PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientation)
 {
     if (Scrollbar::hasPlatformScrollbars()) {
@@ -1259,7 +1264,7 @@ void RenderLayer::paintOverflowControls(GraphicsContext* p, int tx, int ty, cons
     // We fill our scroll corner with white if we have a resizer control and at least one scrollbar
     // or if we have two scrollbars.
     if ((m_hBar && m_vBar) || m_object->style()->resize() != RESIZE_NONE)  {
-        IntRect absBounds(tx, ty, m_object->width(), m_object->height());
+        IntRect absBounds(m_object->xPos() + tx, m_object->yPos() + ty, m_object->width(), m_object->height());
         IntRect scrollCorner = scrollCornerRect(m_object, absBounds);
         if (!scrollCorner.intersects(damageRect))
             return;
@@ -1655,7 +1660,7 @@ void RenderLayer::calculateClipRects(const RenderLayer* rootLayer)
 }
 
 void RenderLayer::calculateRects(const RenderLayer* rootLayer, const IntRect& paintDirtyRect, IntRect& layerBounds,
-                                 IntRect& backgroundRect, IntRect& foregroundRect, IntRect& outlineRect)
+                                 IntRect& backgroundRect, IntRect& foregroundRect, IntRect& outlineRect) const
 {
     if (parent()) {
         parent()->calculateClipRects(rootLayer);
@@ -1692,12 +1697,20 @@ void RenderLayer::calculateRects(const RenderLayer* rootLayer, const IntRect& pa
     }
 }
 
-IntRect RenderLayer::documentClipRect()
+IntRect RenderLayer::childrenClipRect() const
 {
     RenderLayer* rootLayer = renderer()->document()->renderer()->layer();
-    IntRect layerBounds, damageRect, clipRectToApply, outlineRect;
-    calculateRects(rootLayer, rootLayer->absoluteBoundingBox(), layerBounds, damageRect, clipRectToApply, outlineRect);
-    return clipRectToApply;
+    IntRect layerBounds, backgroundRect, foregroundRect, outlineRect;
+    calculateRects(rootLayer, rootLayer->absoluteBoundingBox(), layerBounds, backgroundRect, foregroundRect, outlineRect);
+    return foregroundRect;
+}
+
+IntRect RenderLayer::selfClipRect() const
+{
+    RenderLayer* rootLayer = renderer()->document()->renderer()->layer();
+    IntRect layerBounds, backgroundRect, foregroundRect, outlineRect;
+    calculateRects(rootLayer, rootLayer->absoluteBoundingBox(), layerBounds, backgroundRect, foregroundRect, outlineRect);
+    return backgroundRect;
 }
 
 bool RenderLayer::intersectsDamageRect(const IntRect& layerBounds, const IntRect& damageRect) const
index 5d7f83047a15105940624ff0b4a57ef5c1408257..bbddcff563ca75122bdd8f9bc3e5d7a1b9f9add1 100644 (file)
@@ -297,10 +297,11 @@ public:
     // |rootLayer}.  It also computes our background and foreground clip rects
     // for painting/event handling.
     void calculateRects(const RenderLayer* rootLayer, const IntRect& paintDirtyRect, IntRect& layerBounds,
-                        IntRect& backgroundRect, IntRect& foregroundRect, IntRect& outlineRect);
+                        IntRect& backgroundRect, IntRect& foregroundRect, IntRect& outlineRect) const;
     void calculateClipRects(const RenderLayer* rootLayer);
     ClipRects* clipRects() const { return m_clipRects; }
-    IntRect documentClipRect(); // Returns the foreground clip rect of the layer in the document's coordinate space.
+    IntRect childrenClipRect() const; // Returns the foreground clip rect of the layer in the document's coordinate space.
+    IntRect selfClipRect() const; // Returns the background clip rect of the layer in the document's coordinate space.
 
     bool intersectsDamageRect(const IntRect& layerBounds, const IntRect& damageRect) const;
 
@@ -341,6 +342,7 @@ private:
     bool shouldBeOverflowOnly() const;
 
     virtual void valueChanged(Scrollbar*);
+    virtual IntRect windowClipRect() const;
 
     void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
     
index 446f5b5d84424830a18441fc2884748440625e3c..6c18532e32a605ef697193bf6bf956fa47af173f 100644 (file)
@@ -36,6 +36,7 @@
 #include "RenderBR.h"
 #include "RenderText.h"
 #include "RenderTheme.h"
+#include "RenderView.h"
 #include "TextStyle.h"
 #include <math.h>
 
@@ -425,4 +426,9 @@ void RenderListBox::valueChanged(Scrollbar*)
     }
 }
 
+IntRect RenderListBox::windowClipRect() const
+{
+    return view()->frameView()->windowClipRectForLayer(enclosingLayer(), true);
+}
+
 }
index 06668d6d4879f2ce057f9a82aa9e35c1217b048e..cff41d753b760451159879bf8ff25ea3441d5142 100644 (file)
@@ -53,8 +53,11 @@ public:
     virtual void calcHeight();
     void setOptionsChanged(bool c) { m_optionsChanged = c; }
     void valueChanged(unsigned listIndex);
-    virtual void valueChanged(Scrollbar*);
     
+    // ScrollbarClient interface.
+    virtual void valueChanged(Scrollbar*);
+    virtual IntRect windowClipRect() const;
+
     HTMLOptionElement* optionAtPoint(int x, int y);
     
     bool scrollToRevealElementAtListIndex(int index);
index c55e5a80f5becd96500056ca3e7bbcdf12a5cc90..7ee6746cf4fe08535828dc2968eda42429ff23ba 100644 (file)
@@ -545,9 +545,9 @@ RenderLayer* RenderObject::findNextLayer(RenderLayer* parentLayer, RenderObject*
     return 0;
 }
     
-RenderLayer* RenderObject::enclosingLayer()
+RenderLayer* RenderObject::enclosingLayer() const
 {
-    RenderObject* curr = this;
+    const RenderObject* curr = this;
     while (curr) {
         RenderLayer *layer = curr->layer();
         if (layer)
index c6814c2bc963702a509581b19c21b81c52561f06..64f09fc295c5a17afabd12e19256183318ee02df 100644 (file)
@@ -153,7 +153,7 @@ public:
     RenderObject *lastLeafChild() const;
     
     virtual RenderLayer* layer() const { return 0; }
-    RenderLayer* enclosingLayer();
+    RenderLayer* enclosingLayer() const;
     void addLayers(RenderLayer* parentLayer, RenderObject* newObject);
     void removeLayers(RenderLayer* parentLayer);
     void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);