[BlackBerry] Fully restore both zoom and scroll when leaving an input field.
authormifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2012 18:23:59 +0000 (18:23 +0000)
committermifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2012 18:23:59 +0000 (18:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102094

Reviewed by Rob Buis.

PR 234187.

Cache both the zoom and scroll position prior to adjusting
for input focus so that state can be reset fully.

Reviewed Internally by Gen Mak.

* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible):
* WebKitSupport/InputHandler.h:
(InputHandler):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134437 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.h

index 8f63bfb..d008419 100644 (file)
@@ -1,3 +1,22 @@
+2012-11-13  Mike Fenton  <mifenton@rim.com>
+
+        [BlackBerry] Fully restore both zoom and scroll when leaving an input field.
+        https://bugs.webkit.org/show_bug.cgi?id=102094
+
+        Reviewed by Rob Buis.
+
+        PR 234187.
+
+        Cache both the zoom and scroll position prior to adjusting
+        for input focus so that state can be reset fully.
+
+        Reviewed Internally by Gen Mak.
+
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible):
+        * WebKitSupport/InputHandler.h:
+        (InputHandler):
+
 2012-11-12  Nima Ghanavatian  <nghanavatian@rim.com>
 
         [BlackBerry] Ensure we only receive one KeyUp per key event
index 2bb46bb..6fff99c 100644 (file)
@@ -1099,9 +1099,15 @@ void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
     }
     case VisibleSelection::NoSelection:
         if (m_focusZoomScale) {
-            m_webPage->zoomAboutPoint(m_focusZoomScale, m_focusZoomLocation);
+            m_webPage->zoomAboutPoint(m_focusZoomScale, selectionFocusRect.location());
+            InputLog(LogLevelInfo, "InputHandler::ensureFocusTextElementVisible resetting zoom to %f", m_focusZoomScale);
             m_focusZoomScale = 0.0;
-            m_focusZoomLocation = WebCore::IntPoint();
+        }
+
+        if (m_focusScrollLocation != WebCore::IntPoint(-1, -1)) {
+            mainFrameView->setScrollPosition(m_focusScrollLocation);
+            InputLog(LogLevelInfo, "InputHandler::ensureFocusTextElementVisible resetting scroll to %d, %d", m_focusScrollLocation.x(), m_focusScrollLocation.y());
+            m_focusScrollLocation = WebCore::IntPoint(-1, -1);
         }
         return;
     }
@@ -1110,6 +1116,8 @@ void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
 
     m_webPage->suspendBackingStore();
 
+    WebCore::IntPoint sourceScrollPosition = mainFrameView->scrollPosition();
+
     // If the text is too small, zoom in to make it a minimum size.
     // The minimum size being defined as 3 mm is a good value based on my observations.
     static const int s_minimumTextHeightInPixels = Graphics::Screen::primaryScreen()->heightInMMToPixels(3);
@@ -1117,14 +1125,11 @@ void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
     if (m_webPage->isUserScalable() && fontHeight && fontHeight * m_webPage->currentScale() < s_minimumTextHeightInPixels && !isRunningDrt()) {
         if (!m_focusZoomScale) {
             m_focusZoomScale = m_webPage->currentScale();
-            m_focusZoomLocation = selectionFocusRect.location();
+            m_focusScrollLocation = sourceScrollPosition;
         }
         double zoomScaleRequired = static_cast<double>(s_minimumTextHeightInPixels) / fontHeight;
-        m_webPage->zoomAboutPoint(zoomScaleRequired, m_focusZoomLocation);
-        InputLog(LogLevelInfo, "InputHandler::ensureFocusTextElementVisible zooming in to %f at point %d, %d", zoomScaleRequired, m_focusZoomLocation.x(), m_focusZoomLocation.y());
-    } else {
-        m_focusZoomScale = 0.0;
-        m_focusZoomLocation = WebCore::IntPoint();
+        m_webPage->zoomAboutPoint(zoomScaleRequired, selectionFocusRect.location());
+        InputLog(LogLevelInfo, "InputHandler::ensureFocusTextElementVisible zooming in to %f at point %d, %d", zoomScaleRequired, selectionFocusRect.location().x(), selectionFocusRect.location().y());
     }
 
     if (elementFrame != mainFrame) { // Element is in a subframe.
@@ -1192,9 +1197,13 @@ void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
             scrollLocation.clampNegativeToZero();
             WebCore::IntPoint maximumScrollPosition = WebCore::IntPoint(mainFrameView->contentsWidth() - actualScreenRect.width(), mainFrameView->contentsHeight() - actualScreenRect.height());
             scrollLocation = scrollLocation.shrunkTo(maximumScrollPosition);
-            mainFrameView->setScrollPosition(scrollLocation);
-            mainFrameView->setConstrainsScrollingToContentEdge(true);
-            InputLog(LogLevelInfo, "InputHandler::ensureFocusTextElementVisible scrolling to point %d, %d", scrollLocation.x(), scrollLocation.y());
+            if (scrollLocation != mainFrameView->scrollPosition()) {
+                if (m_focusScrollLocation == WebCore::IntPoint(-1, -1))
+                    m_focusScrollLocation = sourceScrollPosition;
+                mainFrameView->setScrollPosition(scrollLocation);
+                mainFrameView->setConstrainsScrollingToContentEdge(true);
+                InputLog(LogLevelInfo, "InputHandler::ensureFocusTextElementVisible scrolling to point %d, %d", scrollLocation.x(), scrollLocation.y());
+            }
         }
     }
     m_webPage->resumeBackingStore();
index fe4293d..764286f 100644 (file)
@@ -224,7 +224,7 @@ private:
     int32_t m_processingTransactionId;
 
     double m_focusZoomScale;
-    WebCore::FloatPoint m_focusZoomLocation;
+    WebCore::IntPoint m_focusScrollLocation;
 
     bool m_receivedBackspaceKeyDown;
     unsigned short m_expectedKeyUpChar;