From 61e86687816f581053a96dc2686208fe3616ae40 Mon Sep 17 00:00:00 2001 From: "Shimeng (Simon) Wang" Date: Fri, 5 Mar 2010 15:17:45 -0800 Subject: 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. --- WebCore/history/android/AndroidWebHistoryBridge.h | 4 ++-- 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 { 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& v, WebCore::HistoryItem* item) { @@ -416,9 +416,12 @@ static void write_item(WTF::Vector& 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& 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; -- cgit v1.1