diff options
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 11 | ||||
| -rw-r--r-- | WebKit/android/jni/WebHistory.h | 7 | ||||
| -rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 26 | ||||
| -rw-r--r-- | WebKit/android/jni/WebViewCore.h | 8 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 19 |
5 files changed, 66 insertions, 5 deletions
diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index b81e5f3..92d3294 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -692,8 +692,9 @@ void FrameLoaderClientAndroid::saveViewStateToItem(HistoryItem* item) { ASSERT(bridge); // store the current scale (only) for the top frame if (!m_frame->tree()->parent()) { - float scale = WebViewCore::getWebViewCore(m_frame->view())->scale(); - bridge->setScale((int)(scale * 100)); + WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view()); + bridge->setScale((int)(webViewCore->scale() * 100)); + bridge->setScreenWidthScale((int)(webViewCore->screenWidthScale() * 100)); } WebCore::notifyHistoryItemChanged(item); @@ -706,7 +707,11 @@ void FrameLoaderClientAndroid::restoreViewState() { HistoryItem* item = m_frame->loader()->currentHistoryItem(); // restore the scale (only) for the top frame if (!m_frame->tree()->parent()) { - webViewCore->restoreScale(item->bridge()->scale()); + int scale = item->bridge()->scale(); + webViewCore->restoreScale(scale); + int screenWidthScale = item->bridge()->screenWidthScale(); + if (screenWidthScale != scale) + webViewCore->restoreScreenWidthScale(screenWidthScale); } #endif } diff --git a/WebKit/android/jni/WebHistory.h b/WebKit/android/jni/WebHistory.h index 40dc8f8..fe70443 100644 --- a/WebKit/android/jni/WebHistory.h +++ b/WebKit/android/jni/WebHistory.h @@ -46,27 +46,34 @@ public: static void UpdateHistoryIndex(const AutoJObject&, int); }; +// there are two scale factors saved with each history item. mScale reflects the +// viewport scale factor, default to 100 means 100%. mScreenWidthScale records +// the scale factor for the screen width used to wrap the text paragraph. class WebHistoryItem : public WTF::RefCounted<WebHistoryItem> { public: WebHistoryItem(WebHistoryItem* parent) : mParent(parent) , mObject(NULL) , mScale(100) + , mScreenWidthScale(100) , mActive(false) , mHistoryItem(NULL) {} WebHistoryItem(JNIEnv*, jobject, WebCore::HistoryItem*); ~WebHistoryItem(); void updateHistoryItem(WebCore::HistoryItem* item); void setScale(int s) { mScale = s; } + void setScreenWidthScale(int s) { mScreenWidthScale = s; } void setActive() { mActive = true; } void setParent(WebHistoryItem* parent) { mParent = parent; } WebHistoryItem* parent() { return mParent.get(); } int scale() { return mScale; } + int screenWidthScale() { return mScreenWidthScale; } WebCore::HistoryItem* historyItem() { return mHistoryItem; } private: RefPtr<WebHistoryItem> mParent; jobject mObject; int mScale; + int mScreenWidthScale; bool mActive; WebCore::HistoryItem* mHistoryItem; }; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 51293b8..45e1434 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -173,6 +173,7 @@ struct WebViewCore::JavaGlue { jmethodID m_updateTextfield; jmethodID m_clearTextEntry; jmethodID m_restoreScale; + jmethodID m_restoreScreenWidthScale; jmethodID m_needTouchEvents; jmethodID m_requestKeyboard; jmethodID m_exceededDatabaseQuota; @@ -218,6 +219,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_textGeneration = 0; m_screenWidth = 320; m_scale = 1; + m_screenWidthScale = 1; LOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!"); @@ -241,6 +243,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_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(I)V"); + m_javaGlue->m_restoreScreenWidthScale = GetJMethod(env, clazz, "restoreScreenWidthScale", "(I)V"); m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V"); m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(Z)V"); m_javaGlue->m_exceededDatabaseQuota = GetJMethod(env, clazz, "exceededDatabaseQuota", "(Ljava/lang/String;Ljava/lang/String;J)V"); @@ -810,7 +813,11 @@ void WebViewCore::didFirstLayout() JNIEnv* env = JSC::Bindings::getJNIEnv(); env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_didFirstLayout, - loadType == WebCore::FrameLoadTypeStandard); + loadType == WebCore::FrameLoadTypeStandard + // When redirect with locked history, we would like to reset the + // scale factor. This is important for www.yahoo.com as it is + // redirected to www.yahoo.com/?rs=1 on load. + || loadType == WebCore::FrameLoadTypeRedirectWithLockedBackForwardList); checkException(env); DBG_NAV_LOG("call updateFrameCache"); @@ -829,6 +836,16 @@ void WebViewCore::restoreScale(int scale) checkException(env); } +void WebViewCore::restoreScreenWidthScale(int scale) +{ + DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); + LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); + + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_restoreScreenWidthScale, scale); + checkException(env); +} + void WebViewCore::needTouchEvents(bool need) { DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); @@ -928,8 +945,13 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height, ow, oh, osw, m_scale, width, height, screenWidth, scale); m_screenWidth = screenWidth; m_screenHeight = screenHeight; - if (scale >= 0) // negative means ignore + if (scale >= 0) { // negative means ignore m_scale = scale; + if (screenWidth != realScreenWidth) + m_screenWidthScale = realScreenWidth * scale / screenWidth; + else + m_screenWidthScale = m_scale; + } m_maxXScroll = screenWidth >> 2; m_maxYScroll = (screenWidth * height / width) >> 2; if (ow != width || oh != height || osw != screenWidth) { diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index be08830..dba644c 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -157,6 +157,12 @@ namespace android { void restoreScale(int); /** + * Notify the view to restore the scale used to calculate the screen + * width for wrapping the text + */ + void restoreScreenWidthScale(int); + + /** * Tell the java side to update the focused textfield * @param pointer Pointer to the node for the input field. * @param changeToPassword If true, we are changing the textfield to @@ -346,6 +352,7 @@ namespace android { bool recordContent(SkRegion* , SkIPoint* ); int screenWidth() const { return m_screenWidth; } float scale() const { return m_scale; } + float screenWidthScale() const { return m_screenWidthScale; } WebCore::Frame* mainFrame() const { return m_mainFrame; } // utility to split slow parts of the picture set @@ -424,6 +431,7 @@ namespace android { int m_screenWidth; // width of the visible rect in document coordinates int m_screenHeight;// height of the visible rect in document coordinates float m_scale; + float m_screenWidthScale; unsigned m_domtree_version; bool m_check_domtree_version; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index ec57a3b..37e4608 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -963,6 +963,14 @@ bool motionUp(int x, int y, int slop) return pageScrolled; } +int getBlockLeftEdge(int x, int y) +{ + CachedRoot* root = getFrameCache(AllowNewer); + if (root) + return root->getBlockLeftEdge(x, y); + return -1; +} + void overrideUrlLoading(const WebCore::String& url) { JNIEnv* env = JSC::Bindings::getJNIEnv(); @@ -1846,6 +1854,15 @@ static void nativeUpdateCachedTextfield(JNIEnv *env, jobject obj, jstring update checkException(env); } +static jint nativeGetBlockLeftEdge(JNIEnv *env, jobject obj, jint x, jint y) +{ + WebView* view = GET_NATIVE_VIEW(env, obj); + LOG_ASSERT(view, "view not set in %s", __FUNCTION__); + if (!view) + return -1; + return view->getBlockLeftEdge(x, y); +} + static void nativeDestroy(JNIEnv *env, jobject obj) { WebView* view = GET_NATIVE_VIEW(env, obj); @@ -2026,6 +2043,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeTextGeneration }, { "nativeUpdateCachedTextfield", "(Ljava/lang/String;I)V", (void*) nativeUpdateCachedTextfield }, + { "nativeGetBlockLeftEdge", "(II)I", + (void*) nativeGetBlockLeftEdge }, { "nativeUpdatePluginReceivesEvents", "()V", (void*) nativeUpdatePluginReceivesEvents } }; |
