diff options
author | Grace Kloba <klobag@google.com> | 2009-07-28 13:12:34 -0700 |
---|---|---|
committer | Grace Kloba <klobag@google.com> | 2009-07-28 13:16:52 -0700 |
commit | a50885e6d06f2cfdee3bf43b1fb367bca126c5dc (patch) | |
tree | e312893b45cde389c39823364c0e033c3787eead /WebKit/android/jni | |
parent | e4cc103c22e426fd5cc249143a6c90ebc3389906 (diff) | |
download | external_webkit-a50885e6d06f2cfdee3bf43b1fb367bca126c5dc.zip external_webkit-a50885e6d06f2cfdee3bf43b1fb367bca126c5dc.tar.gz external_webkit-a50885e6d06f2cfdee3bf43b1fb367bca126c5dc.tar.bz2 |
Support double tap in the Browser.
Add api to get the left edge of the block from the current (x,y). The code
was copied from Cary's change.
Todo:
1.need some tuning as we can see from nytimes.com that some times the left
edge is not correct.
2.currently nav cache is not up to date while loading. This means the left
edge may not be correct during loading.
3.if (x,y) is over an edit text box, or image, it should return the left
edge of it. Currently it is not working as expected.
Added the code to store the extra scale factor, so that back/forward history
works correctly.
Diffstat (limited to 'WebKit/android/jni')
-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 |
3 files changed, 39 insertions, 2 deletions
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; |