[BlackBerry] Wrong scale after leaving fullscreen <video>
authorzhajiang@rim.com <zhajiang@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2012 20:38:54 +0000 (20:38 +0000)
committerzhajiang@rim.com <zhajiang@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2012 20:38:54 +0000 (20:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89546

Reviewed by Antonio Gomes.
Patch by Jacky Jiang <zhajiang@rim.com>

PR: 164948
When we were entering fullscreen, the current scale A was clamped to a
greater minimum scale B as we relayouted the contents during the change
of the viewport size. When leaving fullscreen, we still used that scale
B as the current scale which was incorrect.
To fix this, we can save the current scale when entering fullscreen and
restore it when leaving fullscreen.

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

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

Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/Api/WebPage_p.h
Source/WebKit/blackberry/ChangeLog

index 8cc1427..ab502a8 100644 (file)
@@ -371,8 +371,9 @@ WebPagePrivate::WebPagePrivate(WebPage* webPage, WebPageClient* client, const In
     , m_touchEventModePriorGoingFullScreen(ProcessedTouchEvents)
 #endif
 #endif
-#if ENABLE(FULLSCREEN_API)
-    , m_xScrollOffsetPriorGoingFullScreen(-1)
+#if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO)
+    , m_scaleBeforeFullScreen(-1.0)
+    , m_xScrollOffsetBeforeFullScreen(-1)
 #endif
     , m_currentCursor(Platform::CursorNone)
     , m_dumpRenderTree(0) // Lazy initialization.
@@ -6209,13 +6210,18 @@ void WebPagePrivate::enterFullScreenForElement(Element* element)
         // we temporarily scroll the WebPage to x:0 so that the wrapper gets properly
         // positioned. The original scroll position is restored once element leaves fullscreen.
         WebCore::IntPoint scrollPosition = m_mainFrame->view()->scrollPosition();
-        m_xScrollOffsetPriorGoingFullScreen = scrollPosition.x();
+        m_xScrollOffsetBeforeFullScreen = scrollPosition.x();
         m_mainFrame->view()->setScrollPosition(WebCore::IntPoint(0, scrollPosition.y()));
 
 #if ENABLE(EVENT_MODE_METATAGS)
         m_touchEventModePriorGoingFullScreen = m_touchEventMode;
         didReceiveTouchEventMode(PureTouchEventsWithMouseConversion);
 #endif
+        // 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();
+
         // No fullscreen video widget has been made available by the Browser
         // chrome, or this is not a video element. The webkitRequestFullScreen
         // Javascript call is often made on a div element.
@@ -6237,16 +6243,27 @@ void WebPagePrivate::exitFullScreenForElement(Element* element)
         exitFullscreenForNode(element);
     } else {
         // When leaving fullscreen mode, we need to restore the 'x' scroll position
-        // prior going full screen.
+        // before fullscreen.
+        // FIXME: We may need to respect 'y' position as well, because the web page always scrolls to
+        // the top when leaving fullscreen mode.
         WebCore::IntPoint scrollPosition = m_mainFrame->view()->scrollPosition();
         m_mainFrame->view()->setScrollPosition(
-            WebCore::IntPoint(m_xScrollOffsetPriorGoingFullScreen, scrollPosition.y()));
-        m_xScrollOffsetPriorGoingFullScreen = -1;
+            WebCore::IntPoint(m_xScrollOffsetBeforeFullScreen, scrollPosition.y()));
+        m_xScrollOffsetBeforeFullScreen = -1;
 
 #if ENABLE(EVENT_MODE_METATAGS)
         didReceiveTouchEventMode(m_touchEventModePriorGoingFullScreen);
         m_touchEventModePriorGoingFullScreen = ProcessedTouchEvents;
 #endif
+        if (m_scaleBeforeFullScreen > 0) {
+            // 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;
+        }
+
         // This is where we would restore the browser's chrome
         // if hidden above.
         client()->fullscreenStop();
index 9b2ee70..d8ca5d5 100644 (file)
@@ -498,7 +498,10 @@ public:
 #if ENABLE(EVENT_MODE_METATAGS)
     WebCore::TouchEventMode m_touchEventModePriorGoingFullScreen;
 #endif
-    int m_xScrollOffsetPriorGoingFullScreen;
+#if ENABLE(VIDEO)
+    double m_scaleBeforeFullScreen;
+    int m_xScrollOffsetBeforeFullScreen;
+#endif
 #endif
 
     Platform::BlackBerryCursor m_currentCursor;
index 2d174f6..9d9db92 100644 (file)
@@ -1,5 +1,27 @@
 2012-06-27  Jacky Jiang  <zhajiang@rim.com>
 
+        [BlackBerry] Wrong scale after leaving fullscreen <video>
+        https://bugs.webkit.org/show_bug.cgi?id=89546
+
+        Reviewed by Antonio Gomes.
+
+        PR: 164948
+        When we were entering fullscreen, the current scale A was clamped to a
+        greater minimum scale B as we relayouted the contents during the change
+        of the viewport size. When leaving fullscreen, we still used that scale
+        B as the current scale which was incorrect.
+        To fix this, we can save the current scale when entering fullscreen and
+        restore it when leaving fullscreen.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
+        (BlackBerry::WebKit::WebPagePrivate::enterFullScreenForElement):
+        (BlackBerry::WebKit::WebPagePrivate::exitFullScreenForElement):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+
+2012-06-27  Jacky Jiang  <zhajiang@rim.com>
+
         [BlackBerry] Scale was incorrect when reloading a simple web page after initial load
         https://bugs.webkit.org/show_bug.cgi?id=88889