diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2011-01-31 13:06:30 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-01-31 13:06:30 -0800 |
commit | 25207148f6b10a10f544078777187966591eabb1 (patch) | |
tree | 4e9f6ff5bfbeb217c15b08655cb6dc8fddc11cbd /WebKit/android/jni/WebViewCore.cpp | |
parent | d9ef42b9a31da9a65a4192f992357b311560714c (diff) | |
parent | 24b5090e4e442093f3a1eb367b8b738234bd6571 (diff) | |
download | external_webkit-25207148f6b10a10f544078777187966591eabb1.zip external_webkit-25207148f6b10a10f544078777187966591eabb1.tar.gz external_webkit-25207148f6b10a10f544078777187966591eabb1.tar.bz2 |
Merge "Reduce history item saving frequency when scrolling." into honeycomb
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 149176a..3328acd 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -1175,7 +1175,15 @@ void WebViewCore::setScrollOffset(int moveGeneration, int userScrolled, int dx, // background, so scroll position will be restored if browser gets // killed while in background. WebCore::HistoryController* history = m_mainFrame->loader()->history(); - history->saveScrollPositionAndViewStateToItem(history->currentItem()); + // Because the history item saving could be heavy for large sites and + // scrolling can generate lots of small scroll offset, the following code + // reduces the saving frequency. + static const int MIN_SCROLL_DIFF = 32; + WebCore::IntPoint currentPoint = history->currentItem()->scrollPoint(); + if (std::abs(currentPoint.x() - dx) >= MIN_SCROLL_DIFF || + std::abs(currentPoint.y() - dy) >= MIN_SCROLL_DIFF) { + history->saveScrollPositionAndViewStateToItem(history->currentItem()); + } // update the currently visible screen sendPluginVisibleScreen(); |