From e5c9306b222e597f907697ab28a7936bfc61e487 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 4 May 2012 11:08:55 -0700 Subject: Disable prerenders while scrolling Bug: 6445656 Change-Id: I3d9e2cece4b3ec86deb00e98ae98f281525dab48 --- Source/WebKit/android/jni/WebViewCore.cpp | 7 +++++++ Source/WebKit/android/jni/WebViewCore.h | 1 + 2 files changed, 8 insertions(+) (limited to 'Source/WebKit/android') diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 1a1fc16..dddae43 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -171,6 +171,10 @@ FILE* gRenderTreeFile = 0; #include "RenderLayerCompositor.h" #endif +// How many ms to wait for the scroll to "settle" before we will consider doing +// prerenders +#define PRERENDER_AFTER_SCROLL_DELAY 750 + //////////////////////////////////////////////////////////////////////////////////////////////// namespace android { @@ -737,6 +741,8 @@ void WebViewCore::paintContents(WebCore::GraphicsContext* gc, WebCore::IntRect& SkCanvas* WebViewCore::createPrerenderCanvas(PrerenderedInval* prerendered) { + if (currentTimeMS() - m_scrollSetTime < PRERENDER_AFTER_SCROLL_DELAY) + return 0; if (prerendered->area.isEmpty()) return 0; FloatRect scaleTemp(m_scrollOffsetX, m_scrollOffsetY, m_screenWidth, m_screenHeight); @@ -1049,6 +1055,7 @@ void WebViewCore::setScrollOffset(bool sendScrollEvent, int dx, int dy) if (m_scrollOffsetX != dx || m_scrollOffsetY != dy) { m_scrollOffsetX = dx; m_scrollOffsetY = dy; + m_scrollSetTime = currentTimeMS(); // The visible rect is located within our coordinate space so it // contains the actual scroll position. Setting the location makes hit // testing work correctly. diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 8dc1d07..043953b 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -760,6 +760,7 @@ namespace android { int m_maxYScroll; int m_scrollOffsetX; // webview.java's current scroll in X int m_scrollOffsetY; // webview.java's current scroll in Y + double m_scrollSetTime; // when the scroll was last set WebCore::IntPoint m_mousePos; int m_screenWidth; // width of the visible rect in document coordinates int m_screenHeight;// height of the visible rect in document coordinates -- cgit v1.1