Title: [153896] trunk/Source/WebKit/blackberry
Revision
153896
Author
commit-qu...@webkit.org
Date
2013-08-09 09:07:29 -0700 (Fri, 09 Aug 2013)

Log Message

[BlackBerry] Viewport allows scrolling when it shouldn't after rotation to landscape
https://bugs.webkit.org/show_bug.cgi?id=119595

Patch by Jacky Jiang <zhaji...@blackberry.com> on 2013-08-09
Reviewed by Rob Buis.
Internally reviewed by Konrad Piascik, Max Feil, Arvid Nilsson and John Griggs.

JIRA 466384
Initial scales of portrait mode and landscape mode can be different due
to different viewport size and contents size. In this case, we restored
to the intial scale of portrait mode instead of the initial scale of current
landscape mode which zoomed in the WebPage a little bit and made the WebPage
scallable as the scale is larger than the initial scale of the current
landscape mode WebPage.
To fix that, we should restore to the current initial scale instead if
the WebPage was at initial scale before fullscreen.
Meanwhile, move the FIXME comments to the right place.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
(BlackBerry::WebKit::WebPagePrivate::setViewportSize):
(BlackBerry::WebKit::WebPagePrivate::enterFullScreenForElement):
* Api/WebPage_p.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (153895 => 153896)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-08-09 15:28:24 UTC (rev 153895)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-08-09 16:07:29 UTC (rev 153896)
@@ -387,6 +387,7 @@
     , m_touchEventMode(ProcessedTouchEvents)
 #endif
 #if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO)
+    , m_atInitialScaleBeforeFullScreen(false)
     , m_scaleBeforeFullScreen(-1.0)
 #endif
     , m_currentCursor(Platform::CursorNone)
@@ -3745,10 +3746,16 @@
 #if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO)
     // When leaving fullscreen mode, restore the scale and scroll position if needed.
     // We also need to make sure the scale and scroll position won't cause over scale or over scroll.
-    if (m_scaleBeforeFullScreen > 0 && !m_fullscreenNode) {
-        // Restore the scale when leaving fullscreen. We can't use TransformationMatrix::scale(double) here,
-        // as it will multiply the scale rather than set the scale.
-        // FIXME: We can refactor this into setCurrentScale(double) if it is useful in the future.
+    if ((m_atInitialScaleBeforeFullScreen || m_scaleBeforeFullScreen > 0) && !m_fullscreenNode) {
+        // Initial scales of portrait mode and landscape mode can be different due to different
+        // viewport size and contents size, restore the scale of current mode from the scale
+        // before fullscreen of the other mode can be wrong if the WebPage was at initial scale.
+        // So restore m_scaleBeforeFullScreen to the initialScale() of the current mode WebPage instead.
+        if (m_atInitialScaleBeforeFullScreen) {
+            m_scaleBeforeFullScreen = initialScale();
+            m_atInitialScaleBeforeFullScreen = false;
+        }
+
         if (m_orientationBeforeFullScreen % 180 != orientation() % 180) { // Orientation changed
             if (m_actualVisibleWidth > contentsSize().width() * m_scaleBeforeFullScreen) {
                 // Cached scale need to be adjusted after rotation.
@@ -3769,6 +3776,9 @@
             }
         }
 
+        // Restore the scale when leaving fullscreen. We can't use TransformationMatrix::scale(double) here,
+        // as it will multiply the scale rather than set the scale.
+        // FIXME: We can refactor this into setCurrentScale(double) if it is useful in the future.
         m_transformationMatrix->setM11(m_scaleBeforeFullScreen);
         m_transformationMatrix->setM22(m_scaleBeforeFullScreen);
         m_scaleBeforeFullScreen = -1.0;
@@ -5697,7 +5707,10 @@
             // The current scale can be clamped to a greater minimum scale when we relayout contents during
             // the change of the viewport size. Cache the current scale so that we can restore it when
             // leaving fullscreen. Otherwise, it is possible that we will use the wrong scale.
-            m_scaleBeforeFullScreen = currentScale();
+            // We'll restore to initialScale() instead when exiting fullscreen if the WebPage is
+            // at intial scale before fullscreen.
+            if (!(m_atInitialScaleBeforeFullScreen = m_webPage->isAtInitialZoom()))
+                m_scaleBeforeFullScreen = currentScale();
 
             // When an element goes fullscreen, the viewport size changes and the scroll
             // position might change. So we keep track of it here, in order to restore it

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (153895 => 153896)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-08-09 15:28:24 UTC (rev 153895)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-08-09 16:07:29 UTC (rev 153896)
@@ -536,6 +536,7 @@
 
 #if ENABLE(FULLSCREEN_API)
 #if ENABLE(VIDEO)
+    bool m_atInitialScaleBeforeFullScreen;
     double m_scaleBeforeFullScreen;
     WebCore::IntPoint m_scrollPositionBeforeFullScreen;
     int m_orientationBeforeFullScreen;

Modified: trunk/Source/WebKit/blackberry/ChangeLog (153895 => 153896)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-08-09 15:28:24 UTC (rev 153895)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-08-09 16:07:29 UTC (rev 153896)
@@ -1,3 +1,28 @@
+2013-08-09  Jacky Jiang  <zhaji...@blackberry.com>
+
+        [BlackBerry] Viewport allows scrolling when it shouldn't after rotation to landscape
+        https://bugs.webkit.org/show_bug.cgi?id=119595
+
+        Reviewed by Rob Buis.
+        Internally reviewed by Konrad Piascik, Max Feil, Arvid Nilsson and John Griggs.
+
+        JIRA 466384
+        Initial scales of portrait mode and landscape mode can be different due
+        to different viewport size and contents size. In this case, we restored
+        to the intial scale of portrait mode instead of the initial scale of current
+        landscape mode which zoomed in the WebPage a little bit and made the WebPage
+        scallable as the scale is larger than the initial scale of the current
+        landscape mode WebPage.
+        To fix that, we should restore to the current initial scale instead if
+        the WebPage was at initial scale before fullscreen.
+        Meanwhile, move the FIXME comments to the right place.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
+        (BlackBerry::WebKit::WebPagePrivate::setViewportSize):
+        (BlackBerry::WebKit::WebPagePrivate::enterFullScreenForElement):
+        * Api/WebPage_p.h:
+
 2013-08-08  Andreas Kling  <akl...@apple.com>
 
         Element: Modernize attribute storage accessor functions.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to