summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorShimeng (Simon) Wang <swang@google.com>2011-01-18 09:52:21 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-18 09:52:21 -0800
commit264c2ff307988137482953b0001c14dbc62abcc5 (patch)
tree59898835d434c1d70e8b87142422bb87a1a63687 /WebKit
parenta27a95188f8f778d90d69accb1b00e6b38879dbd (diff)
parentbfc0ebd2ace64845c11b40ce5dae09347ce0020d (diff)
downloadexternal_webkit-264c2ff307988137482953b0001c14dbc62abcc5.zip
external_webkit-264c2ff307988137482953b0001c14dbc62abcc5.tar.gz
external_webkit-264c2ff307988137482953b0001c14dbc62abcc5.tar.bz2
Merge "Persist scrollPoint as part of the history item." into honeycomb
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/jni/WebHistory.cpp18
-rw-r--r--WebKit/android/jni/WebViewCore.cpp7
2 files changed, 25 insertions, 0 deletions
diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp
index 52d9f61..97ce23b 100644
--- a/WebKit/android/jni/WebHistory.cpp
+++ b/WebKit/android/jni/WebHistory.cpp
@@ -422,6 +422,12 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item)
LOGV("Writing text wrap scale %f", textWrapScale);
v.append((char*)&textWrapScale, sizeof(float));
+ // Scroll position.
+ const int scrollX = item->scrollPoint().x();
+ v.append((char*)&scrollX, sizeof(int));
+ const int scrollY = item->scrollPoint().y();
+ v.append((char*)&scrollY, sizeof(int));
+
// Document state
const WTF::Vector<WTF::String>& docState = item->documentState();
WTF::Vector<WTF::String>::const_iterator end = docState.end();
@@ -610,6 +616,18 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
if (end - data < sizeofUnsigned)
return false;
+ // Read scroll position.
+ int scrollX = 0;
+ memcpy(&scrollX, data, sizeofUnsigned);
+ data += sizeofUnsigned;
+ int scrollY = 0;
+ memcpy(&scrollY, data, sizeofUnsigned);
+ data += sizeofUnsigned;
+ newItem->setScrollPoint(IntPoint(scrollX, scrollY));
+
+ if (end - data < sizeofUnsigned)
+ return false;
+
// Read the document state
memcpy(&l, data, sizeofUnsigned);
LOGV("Document state %d", l);
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 80de32f..27ced0e 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1152,6 +1152,13 @@ void WebViewCore::setScrollOffset(int moveGeneration, int userScrolled, int dx,
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();
+ history->saveScrollPositionAndViewStateToItem(history->currentItem());
+
// update the currently visible screen
sendPluginVisibleScreen();
}