summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();
}