Make ScrollView's updateContents method cross-platform.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/platform/HostWindow.h b/WebCore/platform/HostWindow.h
index f08a340..d42b9d3 100644
--- a/WebCore/platform/HostWindow.h
+++ b/WebCore/platform/HostWindow.h
@@ -30,10 +30,17 @@
namespace WebCore {
+class IntRect;
+
class HostWindow : Noncopyable {
public:
HostWindow() {}
virtual ~HostWindow() {}
+
+ // The repaint method asks the host window to repaint a rect in the window's coordinate space. The
+ // contentChanged boolean indicates whether or not the Web page content actually changed (or if a repaint
+ // of unchanged content is being requested).
+ virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false) = 0;
};
} // namespace WebCore
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp
index 441db0f..f2e8312 100644
--- a/WebCore/platform/ScrollView.cpp
+++ b/WebCore/platform/ScrollView.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "ScrollView.h"
+#include "HostWindow.h"
#include "PlatformMouseEvent.h"
#include "PlatformWheelEvent.h"
#include "Scrollbar.h"
@@ -340,6 +341,21 @@
(*current)->frameRectsChanged();
}
+void ScrollView::repaintContentRectangle(const IntRect& rect, bool now)
+{
+ if (rect.isEmpty())
+ return;
+
+ ASSERT(!parent());
+
+ if (platformWidget()) {
+ platformRepaintContentRectangle(rect, now);
+ return;
+ }
+
+ hostWindow()->repaint(contentsToWindow(rect), true, now);
+}
+
#if !PLATFORM(MAC)
void ScrollView::platformSetCanBlitOnScroll()
{
@@ -381,6 +397,10 @@
{
return true;
}
+
+void ScrollView::platformRepaintContentRectangle(const IntRect&, bool now)
+{
+}
#endif
}
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index 088a001..1adafb0 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -54,6 +54,7 @@
// Port authors should wait until this refactoring is complete before attempting to implement this interface.
namespace WebCore {
+class HostWindow;
class PlatformWheelEvent;
class Scrollbar;
@@ -62,6 +63,10 @@
ScrollView();
~ScrollView();
+ // The window thats hosts the ScrollView. The ScrollView will communicate scrolls and repaints to the
+ // host window in the window's coordinate space.
+ virtual HostWindow* hostWindow() const = 0;
+
// Methods for child manipulation and inspection.
const HashSet<Widget*>* children() const { return &m_children; }
void addChild(Widget*);
@@ -180,7 +185,7 @@
#endif
protected:
- void updateContents(const IntRect&, bool now = false);
+ virtual void repaintContentRectangle(const IntRect&, bool now = false);
void updateWindowRect(const IntRect&, bool now = false);
public:
void update();
@@ -212,7 +217,8 @@
void platformSetScrollPosition(const IntPoint&);
bool platformScroll(ScrollDirection, ScrollGranularity);
void platformSetScrollbarsSuppressed(bool repaintOnUnsuppress);
-
+ void platformRepaintContentRectangle(const IntRect&, bool now);
+
#if PLATFORM(MAC) && defined __OBJC__
public:
NSView* documentView() const;
diff --git a/WebCore/platform/gtk/ScrollViewGtk.cpp b/WebCore/platform/gtk/ScrollViewGtk.cpp
index ee6d3f4..2ff822a 100644
--- a/WebCore/platform/gtk/ScrollViewGtk.cpp
+++ b/WebCore/platform/gtk/ScrollViewGtk.cpp
@@ -285,28 +285,6 @@
updateScrollbars(m_scrollOffset);
}
-void ScrollView::updateContents(const IntRect& updateRect, bool now)
-{
- if (updateRect.isEmpty())
- return;
-
- IntPoint windowPoint = contentsToWindow(updateRect.location());
- IntRect containingWindowRect = updateRect;
- containingWindowRect.setLocation(windowPoint);
-
- GdkRectangle rect = containingWindowRect;
- GdkWindow* window = GTK_WIDGET(containingWindow())->window;
-
- if (window)
- gdk_window_invalidate_rect(window, &rect, true);
-
- // Cache the dirty spot.
- addToDirtyRegion(containingWindowRect);
-
- if (now && window)
- gdk_window_process_updates(window, true);
-}
-
void ScrollView::update()
{
ASSERT(containingWindow());
diff --git a/WebCore/platform/mac/ScrollViewMac.mm b/WebCore/platform/mac/ScrollViewMac.mm
index de4f487..4019acd 100644
--- a/WebCore/platform/mac/ScrollViewMac.mm
+++ b/WebCore/platform/mac/ScrollViewMac.mm
@@ -156,13 +156,17 @@
return true;
}
-void ScrollView::updateContents(const IntRect& rect, bool now)
+void ScrollView::platformRepaintContentRectangle(const IntRect& rect, bool now)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
NSView *view = documentView();
NSRect visibleRect = visibleContentRect();
+ // FIXME: I don't think this intersection is necessary any more now that
+ // selection doesn't call this method directly (but has to go through FrameView's
+ // repaintContentRectangle, which does the intersection test also). Leaving it in
+ // for now until I'm sure.
// Checking for rect visibility is an important optimization for the case of
// Select All of a large document. AppKit does not do this check, and so ends
// up building a large complicated NSRegion if we don't perform the check.
diff --git a/WebCore/platform/qt/ScrollViewQt.cpp b/WebCore/platform/qt/ScrollViewQt.cpp
index c9db167..836974e 100644
--- a/WebCore/platform/qt/ScrollViewQt.cpp
+++ b/WebCore/platform/qt/ScrollViewQt.cpp
@@ -180,22 +180,6 @@
delete m_data;
}
-void ScrollView::updateContents(const IntRect& rect, bool now)
-{
- if (rect.isEmpty())
- return;
-
- IntPoint windowPoint = contentsToWindow(rect.location());
- IntRect containingWindowRect = rect;
- containingWindowRect.setLocation(windowPoint);
-
- // Cache the dirty spot.
- addToDirtyRegion(containingWindowRect);
-
- if (now)
- updateBackingStore();
-}
-
void ScrollView::update()
{
QWidget* native = platformWidget();
diff --git a/WebCore/platform/win/ScrollViewWin.cpp b/WebCore/platform/win/ScrollViewWin.cpp
index 33af8a1..a2396e1 100644
--- a/WebCore/platform/win/ScrollViewWin.cpp
+++ b/WebCore/platform/win/ScrollViewWin.cpp
@@ -201,18 +201,6 @@
{
}
-void ScrollView::updateContents(const IntRect& rect, bool now)
-{
- if (rect.isEmpty())
- return;
-
- IntPoint windowPoint = contentsToWindow(rect.location());
- IntRect containingWindowRect = rect;
- containingWindowRect.setLocation(windowPoint);
-
- updateWindowRect(containingWindowRect, now);
-}
-
void ScrollView::updateWindowRect(const IntRect& rect, bool now)
{
RECT containingWindowRectWin = rect;
diff --git a/WebCore/platform/wx/ScrollViewWx.cpp b/WebCore/platform/wx/ScrollViewWx.cpp
index d789a11..fc5e798 100644
--- a/WebCore/platform/wx/ScrollViewWx.cpp
+++ b/WebCore/platform/wx/ScrollViewWx.cpp
@@ -137,7 +137,7 @@
delete m_data;
}
-void ScrollView::updateContents(const IntRect& updateRect, bool now)
+void ScrollView::platformRepaintContentRectangle(const IntRect& updateRect, bool now)
{
// we need to convert coordinates to scrolled position
wxRect contentsRect = updateRect;