Title: [134437] trunk/Source/WebKit/blackberry
Revision
134437
Author
mifen...@rim.com
Date
2012-11-13 10:23:59 -0800 (Tue, 13 Nov 2012)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (134436 => 134437)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-11-13 18:19:00 UTC (rev 134436)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-11-13 18:23:59 UTC (rev 134437)
@@ -1,3 +1,22 @@
+2012-11-13  Mike Fenton  <mifen...@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  <nghanavat...@rim.com>
 
         [BlackBerry] Ensure we only receive one KeyUp per key event

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (134436 => 134437)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-11-13 18:19:00 UTC (rev 134436)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-11-13 18:23:59 UTC (rev 134437)
@@ -1099,10 +1099,16 @@
     }
     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 @@
 
     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 @@
     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 @@
             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();

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h (134436 => 134437)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h	2012-11-13 18:19:00 UTC (rev 134436)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h	2012-11-13 18:23:59 UTC (rev 134437)
@@ -224,7 +224,7 @@
     int32_t m_processingTransactionId;
 
     double m_focusZoomScale;
-    WebCore::FloatPoint m_focusZoomLocation;
+    WebCore::IntPoint m_focusScrollLocation;
 
     bool m_receivedBackspaceKeyDown;
     unsigned short m_expectedKeyUpChar;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to