OSDN Git Service

Only re-center the page if it is zoom change or
authorGrace Kloba <klobag@google.com>
Fri, 4 Dec 2009 08:32:52 +0000 (00:32 -0800)
committerGrace Kloba <klobag@google.com>
Fri, 4 Dec 2009 08:32:52 +0000 (00:32 -0800)
orientation change. Do not re-center the page if
it is caused by show/hide soft keyboard.

Fix http://b/issue?id=2303918

WebKit/android/jni/WebViewCore.cpp

index f138662..4e3d8bf 100644 (file)
@@ -1100,11 +1100,18 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
             WebCore::IntPoint screenCenter = WebCore::IntPoint(
                 m_scrollOffsetX + (realScreenWidth >> 1),
                 m_scrollOffsetY + (screenHeight >> 1));
-            WebCore::HitTestResult hitTestResult = m_mainFrame->eventHandler()->
-                hitTestResultAtPoint(screenCenter, false);
-            WebCore::Node* node = hitTestResult.innerNode();
+            WebCore::Node* node = 0;
             WebCore::IntRect bounds;
             WebCore::IntPoint offset;
+            // If the screen width changed, it is probably zoom change or
+            // orientation change. Try to keep the node in the center of the
+            // screen staying at the same place.
+            if (osw != screenWidth) {
+                WebCore::HitTestResult hitTestResult =
+                        m_mainFrame->eventHandler()-> hitTestResultAtPoint(
+                                screenCenter, false);
+                node = hitTestResult.innerNode();
+            }
             if (node) {
                 bounds = node->getRect();
                 DBG_NAV_LOGD("ob:(x=%d,y=%d,w=%d,h=%d)",