WebCore:

2008-10-02  David Hyatt  <hyatt@apple.com>

        https://bugs.webkit.org/show_bug.cgi?id=21328
        
        Make widget invalidation more cross-platform.
        
        (1) Make invalidateRect a pure virtual function on Widget.  All leaf widgets must now implement this function.
        
        (2) Scrollbars now send invalidations through the ScrollbarClient.  windowClipRect on ScrollbarClient has been removed and replaced with this invalidation call.
        This allows all scrollbar invalidations to go through the render tree so that transforms and reflections will be respected.
        
        (3) Plugins now have the native window invalidation code for windowed plugins.  Windowless plugins do a repaintRectangle on the plugin's renderer.
        
        (4) FrameViews now do a repaintRectangle on their owner element's renderer.

        Reviewed by Sam Weinig

        * WebCore.base.exp:
        * page/FrameView.cpp:
        (WebCore::FrameView::invalidateRect):
        (WebCore::FrameView::invalidateScrollbarRect):
        * page/FrameView.h:
        * platform/PopupMenu.h:
        * platform/ScrollView.cpp:
        (WebCore::ScrollView::scrollContents):
        * platform/ScrollView.h:
        * platform/Scrollbar.cpp:
        (WebCore::Scrollbar::setEnabled):
        (WebCore::Scrollbar::invalidateRect):
        * platform/Scrollbar.h:
        * platform/ScrollbarClient.h:
        * platform/Widget.h:
        * platform/gtk/WidgetGtk.cpp:
        * platform/mac/WidgetMac.mm:
        * platform/win/PopupMenuWin.cpp:
        (WebCore::PopupMenu::invalidateScrollbarRect):
        * platform/win/WidgetWin.cpp:
        * plugins/PluginView.cpp:
        (WebCore::PluginView::invalidateTimerFired):
        (WebCore::PluginView::invalidateWindowlessPluginRect):
        * plugins/PluginView.h:
        * plugins/gtk/PluginViewGtk.cpp:
        (WebCore::PluginView::invalidateRect):
        * plugins/qt/PluginViewQt.cpp:
        (WebCore::PluginView::invalidateRect):
        * plugins/win/PluginViewWin.cpp:
        (WebCore::PluginView::invalidateRect):
        (WebCore::PluginView::invalidateRegion):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::invalidateScrollbarRect):
        * rendering/RenderLayer.h:
        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::paintObject):
        (WebCore::RenderListBox::paintScrollbar):
        (WebCore::RenderListBox::invalidateScrollbarRect):
        * rendering/RenderListBox.h:

WebKit/mac:

2008-10-02  David Hyatt  <hyatt@apple.com>

        https://bugs.webkit.org/show_bug.cgi?id=21328
        
        Make widget invalidation more cross-platform.
        
        (1) Make invalidateRect a pure virtual function on Widget.  All leaf widgets must now implement this function.
        
        (2) Scrollbars now send invalidations through the ScrollbarClient.  windowClipRect on ScrollbarClient has been removed and replaced with this invalidation call.
        This allows all scrollbar invalidations to go through the render tree so that transforms and reflections will be respected.
        
        (3) Plugins now have the native window invalidation code for windowed plugins.  Windowless plugins do a repaintRectangle on the plugin's renderer.
        
        (4) FrameViews now do a repaintRectangle on their owner element's renderer.

        Reviewed by Sam Weinig

        * WebCoreSupport/WebFrameLoaderClient.mm:
        (PluginWidget::PluginWidget):
        (PluginWidget::invalidateRect):
        (NetscapePluginWidget::NetscapePluginWidget):
        (WebFrameLoaderClient::createPlugin):

WebKit/win:

2008-10-02  David Hyatt  <hyatt@apple.com>

        https://bugs.webkit.org/show_bug.cgi?id=21328
        
        Make widget invalidation more cross-platform.
        
        (1) Make invalidateRect a pure virtual function on Widget.  All leaf widgets must now implement this function.
        
        (2) Scrollbars now send invalidations through the ScrollbarClient.  windowClipRect on ScrollbarClient has been removed and replaced with this invalidation call.
        This allows all scrollbar invalidations to go through the render tree so that transforms and reflections will be respected.
        
        (3) Plugins now have the native window invalidation code for windowed plugins.  Windowless plugins do a repaintRectangle on the plugin's renderer.
        
        (4) FrameViews now do a repaintRectangle on their owner element's renderer.

        Reviewed by Sam Weinig

        * WebCoreSupport/EmbeddedWidget.cpp:
        (EmbeddedWidget::invalidateRect):
        * WebCoreSupport/EmbeddedWidget.h:
        * WebScrollBar.cpp:
        (WebScrollBar::invalidateScrollbarRect):
        * WebScrollBar.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37223 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/platform/PopupMenu.h b/WebCore/platform/PopupMenu.h
index 55b336fb..c6b572e 100644
--- a/WebCore/platform/PopupMenu.h
+++ b/WebCore/platform/PopupMenu.h
@@ -144,7 +144,7 @@
 #elif PLATFORM(WIN)
     // ScrollBarClient
     virtual void valueChanged(Scrollbar*);
-    virtual IntRect windowClipRect(const Scrollbar*) const;
+    virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
     virtual bool isActive() const { return true; }
 
     void calculatePositionAndSize(const IntRect&, FrameView*);
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp
index d9fa07e..dd1f176 100644
--- a/WebCore/platform/ScrollView.cpp
+++ b/WebCore/platform/ScrollView.cpp
@@ -379,7 +379,7 @@
 {
     // Since scrolling is double buffered, we will be blitting the scroll view's intersection
     // with the clip rect every time to keep it smooth.
-    IntRect clipRect = static_cast<Widget*>(this)->windowClipRect();
+    IntRect clipRect = windowClipRect();
     IntRect scrollViewRect = convertToContainingWindow(IntRect(0, 0, visibleWidth(), visibleHeight()));
     IntRect updateRect = clipRect;
     updateRect.intersect(scrollViewRect);
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index 84c042b..325eda6 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -71,6 +71,9 @@
     // host window in the window's coordinate space.
     virtual HostWindow* hostWindow() const = 0;
 
+    // Returns a clip rect in host window coordinates.  Used to clip the blit on a scroll.
+    virtual IntRect windowClipRect(bool clipToContents = true) const = 0;
+
     // Methods for child manipulation and inspection.
     const HashSet<Widget*>* children() const { return &m_children; }
     void addChild(Widget*);
diff --git a/WebCore/platform/Scrollbar.cpp b/WebCore/platform/Scrollbar.cpp
index e58124d..59a378a 100644
--- a/WebCore/platform/Scrollbar.cpp
+++ b/WebCore/platform/Scrollbar.cpp
@@ -417,23 +417,12 @@
     m_enabled = e;
     invalidate();
 }
-    
-IntRect Scrollbar::windowClipRect() const
-{
-    IntRect clipRect(0, 0, width(), height());
-
-    clipRect = convertToContainingWindow(clipRect);
-    if (m_client)
-        clipRect.intersect(m_client->windowClipRect(this));
-
-    return clipRect;
-}
 
 void Scrollbar::invalidateRect(const IntRect& rect)
 {
     if (suppressInvalidation())
         return;
-    Widget::invalidateRect(rect);
+    m_client->invalidateScrollbarRect(this, rect);
 }
 
 }
diff --git a/WebCore/platform/Scrollbar.h b/WebCore/platform/Scrollbar.h
index 5125c1f..77c0f06 100644
--- a/WebCore/platform/Scrollbar.h
+++ b/WebCore/platform/Scrollbar.h
@@ -110,7 +110,6 @@
 
     virtual void setParent(ScrollView*);
     virtual void setFrameRect(const IntRect&);
-    virtual IntRect windowClipRect() const;
 
     virtual void invalidateRect(const IntRect&);
     
diff --git a/WebCore/platform/ScrollbarClient.h b/WebCore/platform/ScrollbarClient.h
index 283d4fb..be3588b 100644
--- a/WebCore/platform/ScrollbarClient.h
+++ b/WebCore/platform/ScrollbarClient.h
@@ -37,8 +37,7 @@
     virtual ~ScrollbarClient() {}
     virtual void valueChanged(Scrollbar*) = 0;
 
-    // Used to obtain a window clip rect.
-    virtual IntRect windowClipRect(const Scrollbar*) const = 0;
+    virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
 
     virtual bool isActive() const = 0;
 };
diff --git a/WebCore/platform/Widget.h b/WebCore/platform/Widget.h
index e977de2..b8a93d1 100644
--- a/WebCore/platform/Widget.h
+++ b/WebCore/platform/Widget.h
@@ -133,7 +133,7 @@
 
     virtual void paint(GraphicsContext*, const IntRect&);
     void invalidate() { invalidateRect(boundsRect()); }
-    virtual void invalidateRect(const IntRect&);
+    virtual void invalidateRect(const IntRect&) = 0;
 
     virtual void setFocus();
 
@@ -158,11 +158,6 @@
     ScrollView* parent() const { return m_parent; }
     ScrollView* root() const;
 
-    // This method is used by plugins on all platforms to obtain a clip rect that includes clips set by WebCore,
-    // e.g., in overflow:auto sections.  The clip rects coordinates are in the containing window's coordinate space.
-    // This clip includes any clips that the widget itself sets up for its children.
-    virtual IntRect windowClipRect() const { return IntRect(); }
-
     virtual void handleEvent(Event*) { }
 
     // The containing window is used as the coordinate space for event handling.
diff --git a/WebCore/platform/gtk/WidgetGtk.cpp b/WebCore/platform/gtk/WidgetGtk.cpp
index bf42c01..7b2d6f6 100644
--- a/WebCore/platform/gtk/WidgetGtk.cpp
+++ b/WebCore/platform/gtk/WidgetGtk.cpp
@@ -151,29 +151,6 @@
     notImplemented();
 }
 
-void Widget::invalidateRect(const IntRect& rect)
-{
-    if (!parent()) {
-        gtk_widget_queue_draw_area(GTK_WIDGET(containingWindow()), rect.x(), rect.y(),
-                                   rect.width(), rect.height());
-        if (isFrameView())
-            static_cast<FrameView*>(this)->addToDirtyRegion(rect);
-        return;
-    }
-
-    // Get the root widget.
-    ScrollView* outermostView = parent();
-    while (outermostView && outermostView->parent())
-        outermostView = outermostView->parent();
-    if (!outermostView)
-        return;
-
-    IntRect windowRect = convertToContainingWindow(rect);
-    gtk_widget_queue_draw_area(GTK_WIDGET(containingWindow()), windowRect.x(), windowRect.y(),
-                               windowRect.width(), windowRect.height());
-    outermostView->addToDirtyRegion(windowRect);
-}
-
 IntRect Widget::frameRect() const
 {
     return m_frame;
diff --git a/WebCore/platform/mac/WidgetMac.mm b/WebCore/platform/mac/WidgetMac.mm
index 7a45807..dbbe95c 100644
--- a/WebCore/platform/mac/WidgetMac.mm
+++ b/WebCore/platform/mac/WidgetMac.mm
@@ -229,19 +229,6 @@
     }
 }
 
-void Widget::invalidateRect(const IntRect& r)
-{
-    if (!platformWidget() && parent()) {
-        IntPoint newPoint = parent()->convertChildToSelf(this, r.location());
-        parent()->invalidateRect(IntRect(newPoint, r.size()));
-        return;
-    }
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [platformWidget() setNeedsDisplayInRect: r];
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
 void Widget::setIsSelected(bool isSelected)
 {
     NSView *view = platformWidget();
diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp
index c465334..d1545d4 100644
--- a/WebCore/platform/win/PopupMenuWin.cpp
+++ b/WebCore/platform/win/PopupMenuWin.cpp
@@ -584,9 +584,12 @@
     ::UpdateWindow(m_popup);
 }
 
-IntRect PopupMenu::windowClipRect(const Scrollbar*) const
+void PopupMenu::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
 {
-    return m_windowRect;
+    IntRect scrollRect = rect;
+    scrollRect.move(scrollbar->x(), scrollbar->y());
+    RECT r = scrollRect;
+    ::InvalidateRect(m_popup, &r, false);
 }
 
 static ATOM registerPopup()
diff --git a/WebCore/platform/win/WidgetWin.cpp b/WebCore/platform/win/WidgetWin.cpp
index df7ecd8..c1d5459 100644
--- a/WebCore/platform/win/WidgetWin.cpp
+++ b/WebCore/platform/win/WidgetWin.cpp
@@ -83,6 +83,7 @@
 {
 }
 
+/*
 void Widget::invalidateRect(const IntRect& r)
 {
     if (!parent()) {
@@ -110,6 +111,7 @@
     ::InvalidateRect(containingWindow(), &rect, false);
     outermostView->addToDirtyRegion(windowRect);
 }
+*/
 
 void Widget::setFocus()
 {