diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2011-01-07 15:46:52 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2011-01-11 10:53:17 -0800 |
commit | c4683829d0d4932156a97ce14ea15deed71bf21d (patch) | |
tree | 46ae05af82a74578639530ed4b38517b0f17ce81 | |
parent | cea2bc79994f4e4f617a2e1a372dfc44a3f5365a (diff) | |
download | external_webkit-c4683829d0d4932156a97ce14ea15deed71bf21d.zip external_webkit-c4683829d0d4932156a97ce14ea15deed71bf21d.tar.gz external_webkit-c4683829d0d4932156a97ce14ea15deed71bf21d.tar.bz2 |
Use float to preserve scales' accuracy.
This change helps page navigation, since the restored scale
is accurate.
This change has a corresponding change in frameworks/base.
https://android-git.corp.google.com/g/#change,88121
issue: 3225233
Change-Id: I7e5601e8412e8b81e7f32c9ffb9e6c114db95169
-rw-r--r-- | WebCore/history/android/AndroidWebHistoryBridge.h | 12 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.cpp | 29 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 |
5 files changed, 26 insertions, 25 deletions
diff --git a/WebCore/history/android/AndroidWebHistoryBridge.h b/WebCore/history/android/AndroidWebHistoryBridge.h index b320c4a..a827b4a 100644 --- a/WebCore/history/android/AndroidWebHistoryBridge.h +++ b/WebCore/history/android/AndroidWebHistoryBridge.h @@ -42,17 +42,17 @@ public: virtual ~AndroidWebHistoryBridge() { } virtual void updateHistoryItem(HistoryItem* item) = 0; - void setScale(int s) { m_scale = s; } - void setTextWrapScale(int s) { m_textWrapScale = s; } - int scale() const { return m_scale; } - int textWrapScale() const { return m_textWrapScale; } + void setScale(float s) { m_scale = s; } + void setTextWrapScale(float s) { m_textWrapScale = s; } + float scale() const { return m_scale; } + float textWrapScale() const { return m_textWrapScale; } void detachHistoryItem() { m_historyItem = 0; } HistoryItem* historyItem() const { return m_historyItem; } void setActive() { m_active = true; } protected: - int m_scale; - int m_textWrapScale; + float m_scale; + float m_textWrapScale; bool m_active; HistoryItem* m_historyItem; }; diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index c56348c..d165afa 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -814,8 +814,8 @@ void FrameLoaderClientAndroid::saveViewStateToItem(HistoryItem* item) { // store the current scale (only) for the top frame if (!m_frame->tree()->parent()) { WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view()); - bridge->setScale((int)(webViewCore->scale() * 100)); - bridge->setTextWrapScale((int)(webViewCore->textWrapScale() * 100)); + bridge->setScale(webViewCore->scale()); + bridge->setTextWrapScale(webViewCore->textWrapScale()); } WebCore::notifyHistoryItemChanged(item); diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index d3893ff..e5b0346 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -415,12 +415,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 - const int scale = bridge->scale(); - LOGV("Writing scale %d", scale); - v.append((char*)&scale, sizeof(int)); - const int textWrapScale = bridge->textWrapScale(); - LOGV("Writing text wrap scale %d", textWrapScale); - v.append((char*)&textWrapScale, sizeof(int)); + const float scale = bridge->scale(); + LOGV("Writing scale %f", scale); + v.append((char*)&scale, sizeof(float)); + const float textWrapScale = bridge->textWrapScale(); + LOGV("Writing text wrap scale %f", textWrapScale); + v.append((char*)&textWrapScale, sizeof(float)); // Document state const WTF::Vector<WTF::String>& docState = item->documentState(); @@ -596,15 +596,16 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, AndroidWebHistoryBridge* bridge = newItem->bridge(); LOG_ASSERT(bridge, "There should be a bridge object during inflate"); + float fValue; // Read the screen scale - memcpy(&l, data, sizeofUnsigned); - LOGV("Screen scale %d", l); - bridge->setScale(l); - data += sizeofUnsigned; - memcpy(&l, data, sizeofUnsigned); - LOGV("Text wrap scale %d", l); - bridge->setTextWrapScale(l); - data += sizeofUnsigned; + memcpy(&fValue, data, sizeof(float)); + LOGV("Screen scale %f", fValue); + bridge->setScale(fValue); + data += sizeof(float); + memcpy(&fValue, data, sizeofUnsigned); + LOGV("Text wrap scale %f", fValue); + bridge->setTextWrapScale(fValue); + data += sizeof(float); if (end - data < sizeofUnsigned) return false; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index f7f1058..110ce94 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -361,7 +361,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V"); m_javaGlue->m_updateTextSelection = GetJMethod(env, clazz, "updateTextSelection", "(IIII)V"); m_javaGlue->m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); - m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(II)V"); + m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(FF)V"); m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V"); m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(Z)V"); m_javaGlue->m_requestKeyboardWithSelection = GetJMethod(env, clazz, "requestKeyboardWithSelection", "(IIII)V"); @@ -1053,7 +1053,7 @@ void WebViewCore::updateViewport() checkException(env); } -void WebViewCore::restoreScale(int scale, int textWrapScale) +void WebViewCore::restoreScale(float scale, float textWrapScale) { DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index fa474ce..ae5a65f 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -207,7 +207,7 @@ namespace android { * Notify the view to restore the screen width, which in turn restores * the scale. Also restore the scale for the text wrap. */ - void restoreScale(int scale, int textWrapScale); + void restoreScale(float scale, float textWrapScale); /** * Tell the java side to update the focused textfield |