Title: [139955] trunk/Source/WebKit/blackberry
Revision
139955
Author
[email protected]
Date
2013-01-16 19:52:52 -0800 (Wed, 16 Jan 2013)

Log Message

[BlackBerry] Need to adjust the scale and scroll position after leaving fullscreen mode if there's
device rotation in fullscreen mode
https://bugs.webkit.org/show_bug.cgi?id=107085

Reviewed by George STaikos.
Also internally reviewed by Jacky Jiang.

We saved the scale and scroll position before entering full screen mode, so that we can restore
them after leaving fullscreen mode, because entering fullscreen mode automatically changes the
       scale to make the video to fit to the viewport. But if there's device rotation during the fullscreen,
       the scale and scroll position saved before may or may not apply anymore, we need to adjust the
       scale and/or scroll position if needed to make sure no over-scale or over-scroll in the new orientation.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (139954 => 139955)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-01-17 03:42:09 UTC (rev 139954)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-01-17 03:52:52 UTC (rev 139955)
@@ -3819,14 +3819,32 @@
     }
 
 #if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO)
-    // When leaving fullscreen mode, restore the scale and scroll position
-    // if needed.
-    // FIXME: The cached values might get imprecise if user have rotated the
-    // device while in fullscreen.
+    // 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_fullscreenVideoNode) {
         // 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_orientationBeforeFullScreen % 180 != orientation() % 180) { // Orientation changed
+            if (m_actualVisibleWidth > contentsSize().width() * m_scaleBeforeFullScreen) {
+                // Cached scale need to be adjusted after rotation.
+                m_scaleBeforeFullScreen = double(m_actualVisibleWidth) / contentsSize().width();
+            }
+            if (m_scaleBeforeFullScreen * contentsSize().height() < m_actualVisibleHeight) {
+                // Use zoom to fit height scale in order to cover the screen height.
+                m_scaleBeforeFullScreen = double(m_actualVisibleHeight) / contentsSize().height();
+            }
+
+            if (m_actualVisibleWidth > m_scaleBeforeFullScreen * (contentsSize().width() - m_scrollPositionBeforeFullScreen.x())) {
+                // Cached scroll position over scrolls horizontally after rotation.
+                m_scrollPositionBeforeFullScreen.setX(contentsSize().width() - m_actualVisibleWidth / m_scaleBeforeFullScreen);
+            }
+            if (m_actualVisibleHeight > m_scaleBeforeFullScreen * (contentsSize().height() - m_scrollPositionBeforeFullScreen.y())) {
+                // Cached scroll position over scrolls vertically after rotation.
+                m_scrollPositionBeforeFullScreen.setY(contentsSize().height() - m_actualVisibleHeight / m_scaleBeforeFullScreen);
+            }
+        }
+
         m_transformationMatrix->setM11(m_scaleBeforeFullScreen);
         m_transformationMatrix->setM22(m_scaleBeforeFullScreen);
         m_scaleBeforeFullScreen = -1.0;
@@ -5808,6 +5826,11 @@
             // position might change. So we keep track of it here, in order to restore it
             // once element leaves fullscreen.
             m_scrollPositionBeforeFullScreen = m_mainFrame->view()->scrollPosition();
+
+            // We need to remember the orientation before entering fullscreen, so that we can adjust
+            // the scale and scroll position when exiting fullscreen if needed, because the scale and
+            // scroll position  may not apply (overscale and/or overscroll) in the other orientation.
+            m_orientationBeforeFullScreen = orientation();
         }
 
         // No fullscreen video widget has been made available by the Browser

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (139954 => 139955)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-01-17 03:42:09 UTC (rev 139954)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-01-17 03:52:52 UTC (rev 139955)
@@ -528,6 +528,7 @@
 #if ENABLE(VIDEO)
     double m_scaleBeforeFullScreen;
     WebCore::IntPoint m_scrollPositionBeforeFullScreen;
+    int m_orientationBeforeFullScreen;
 #endif
 #endif
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (139954 => 139955)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-01-17 03:42:09 UTC (rev 139954)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-01-17 03:52:52 UTC (rev 139955)
@@ -1,3 +1,24 @@
+2013-01-16  Charles Wei  <[email protected]>
+
+        [BlackBerry] Need to adjust the scale and scroll position after leaving fullscreen mode if there's
+        device rotation in fullscreen mode
+        https://bugs.webkit.org/show_bug.cgi?id=107085
+
+        Reviewed by George STaikos.
+        Also internally reviewed by Jacky Jiang.
+
+        We saved the scale and scroll position before entering full screen mode, so that we can restore
+        them after leaving fullscreen mode, because entering fullscreen mode automatically changes the 
+       scale to make the video to fit to the viewport. But if there's device rotation during the fullscreen,
+       the scale and scroll position saved before may or may not apply anymore, we need to adjust the
+       scale and/or scroll position if needed to make sure no over-scale or over-scroll in the new orientation.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::setViewportSize):
+        (BlackBerry::WebKit::WebPagePrivate::enterFullScreenForElement):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+
 2013-01-16  Joe Mason  <[email protected]>
 
         [BlackBerry] Remove bogus assert in GeolocationClientBlackBerry
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to