+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.
void replaceContentsWithScriptResult(const KURL& url);
- void disconnectOwnerElement();
+ void disconnectOwnerElement();
- void setNeedsReapplyStyles();
+ void setNeedsReapplyStyles();
- virtual IntRect windowResizerRect() const { return IntRect(); }
-
void stopAutoscrollTimer();
RenderObject* autoscrollRenderer() const;
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;
// 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;
}
class Node;
class RenderBox;
class RenderView;
+class RenderLayer;
class RenderLineEdit;
class RenderObject;
class RenderPart;
#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);
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> {
class QScrollArea;
#endif
+#if PLATFORM(WIN)
+typedef struct HRGN__* HRGN;
+#endif
+
namespace WebCore {
class FloatRect;
class PlatformWheelEvent;
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;
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.
scrollToOffset(newX, newY, false);
}
+IntRect RenderLayer::windowClipRect() const
+{
+ return renderer()->view()->frameView()->windowClipRectForLayer(this, false);
+}
+
PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientation)
{
if (Scrollbar::hasPlatformScrollbars()) {
// 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;
}
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);
}
}
-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
// |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;
bool shouldBeOverflowOnly() const;
virtual void valueChanged(Scrollbar*);
+ virtual IntRect windowClipRect() const;
void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
#include "RenderBR.h"
#include "RenderText.h"
#include "RenderTheme.h"
+#include "RenderView.h"
#include "TextStyle.h"
#include <math.h>
}
}
+IntRect RenderListBox::windowClipRect() const
+{
+ return view()->frameView()->windowClipRectForLayer(enclosingLayer(), true);
+}
+
}
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);
return 0;
}
-RenderLayer* RenderObject::enclosingLayer()
+RenderLayer* RenderObject::enclosingLayer() const
{
- RenderObject* curr = this;
+ const RenderObject* curr = this;
while (curr) {
RenderLayer *layer = curr->layer();
if (layer)
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);