diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2011-02-10 13:38:41 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2011-02-10 13:38:41 -0800 |
commit | 3c0909cb7a28a49e5b95c1355657460c07c4a714 (patch) | |
tree | efce942906b13932a446ef5104a97726f67d4183 /WebKit/android/jni/WebViewCore.cpp | |
parent | e2233abc7c8574970b34ef0e83ff994e3b41456d (diff) | |
download | external_webkit-3c0909cb7a28a49e5b95c1355657460c07c4a714.zip external_webkit-3c0909cb7a28a49e5b95c1355657460c07c4a714.tar.gz external_webkit-3c0909cb7a28a49e5b95c1355657460c07c4a714.tar.bz2 |
Only update history position if scrolling is done by user.
issue: 3433562
Change-Id: I520f50cc6657f0a244860e01d38e3f71607fe665
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 38a8020..02bdbe5 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -1155,23 +1155,25 @@ void WebViewCore::setScrollOffset(int moveGeneration, bool sendScrollEvent, int // testing work correctly. m_mainFrame->view()->platformWidget()->setLocation(m_scrollOffsetX, m_scrollOffsetY); - if (sendScrollEvent) + if (sendScrollEvent) { m_mainFrame->eventHandler()->sendScrollEvent(); - // Update history item to reflect the new scroll position. - // This also helps save the history information when the browser goes to - // background, so scroll position will be restored if browser gets - // killed while in background. - WebCore::HistoryController* history = m_mainFrame->loader()->history(); - // 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; - if (history->currentItem()) { - 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()); + // Only update history position if it's user scrolled. + // Update history item to reflect the new scroll position. + // This also helps save the history information when the browser goes to + // background, so scroll position will be restored if browser gets + // killed while in background. + WebCore::HistoryController* history = m_mainFrame->loader()->history(); + // 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; + if (history->currentItem()) { + 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()); + } } } |