diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2010-03-05 15:17:45 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2010-03-05 17:17:54 -0800 |
commit | 61e86687816f581053a96dc2686208fe3616ae40 (patch) | |
tree | 4d3f74b474aed4fd7ce10ec1514aaba0836f7d43 | |
parent | 0d72f882dbb757a8398e371417dd96714d0dc7f7 (diff) | |
download | external_webkit-61e86687816f581053a96dc2686208fe3616ae40.zip external_webkit-61e86687816f581053a96dc2686208fe3616ae40.tar.gz external_webkit-61e86687816f581053a96dc2686208fe3616ae40.tar.bz2 |
Serialize/unserialize screen width scale, which is used when restoring sites.
Also change the scales' default value to 0, so in WebViewCore.java, in case
the scales are not set inside webkit, the default logic can be used.
This helps in case a mobile site is loaded but no scales is saved, and when
restored, the mobile site will have wrong restored scales because default
values are not 0.
-rw-r--r-- | WebCore/history/android/AndroidWebHistoryBridge.h | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.cpp | 16 |
2 files changed, 14 insertions, 6 deletions
diff --git a/WebCore/history/android/AndroidWebHistoryBridge.h b/WebCore/history/android/AndroidWebHistoryBridge.h index b401933..893d137 100644 --- a/WebCore/history/android/AndroidWebHistoryBridge.h +++ b/WebCore/history/android/AndroidWebHistoryBridge.h @@ -35,8 +35,8 @@ class HistoryItem; class AndroidWebHistoryBridge : public RefCounted<AndroidWebHistoryBridge> { public: AndroidWebHistoryBridge(HistoryItem* item) - : m_scale(100) - , m_screenWidthScale(100) + : m_scale(0) + , m_screenWidthScale(0) , m_active(false) , m_historyItem(item) { } virtual ~AndroidWebHistoryBridge() { } diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index 46c40a5..d518ba8 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -189,9 +189,9 @@ static void WebHistoryInflate(JNIEnv* env, jobject obj, jint frame, jbyteArray d bridge->updateHistoryItem(newItem.get()); } -// 6 empty strings + no document state + children count = 8 unsigned values -// 1 char for isTargetItem and 1 char is for scale. -#define HISTORY_MIN_SIZE ((int)(sizeof(unsigned) * 9 + sizeof(char))) +// 6 empty strings + no document state + children count + 2 scales = 10 unsigned values +// 1 char for isTargetItem. +#define HISTORY_MIN_SIZE ((int)(sizeof(unsigned) * 10 + sizeof(char))) jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::HistoryItem* item) { @@ -416,9 +416,12 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item) AndroidWebHistoryBridge* bridge = item->bridge(); LOG_ASSERT(bridge, "We should have a bridge here!"); // Screen scale - int scale = bridge->scale(); + const int scale = bridge->scale(); LOGV("Writing scale %d", scale); v.append((char*)&scale, sizeof(int)); + const int screenWidthScale = bridge->screenWidthScale(); + LOGV("Writing screen width scale %d", screenWidthScale); + v.append((char*)&screenWidthScale, sizeof(int)); // Document state const WTF::Vector<WebCore::String>& docState = item->documentState(); @@ -599,6 +602,11 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, LOGV("Screen scale %d", l); bridge->setScale(l); data += sizeofUnsigned; + memcpy(&l, data, sizeofUnsigned); + LOGV("Screen width scale %d", l); + bridge->setScreenWidthScale(l); + data += sizeofUnsigned; + if (end - data < sizeofUnsigned) return false; |