Title: [121362] trunk/Source/WebKit/blackberry
Revision
121362
Author
[email protected]
Date
2012-06-27 13:38:54 -0700 (Wed, 27 Jun 2012)

Log Message

[BlackBerry] Wrong scale after leaving fullscreen <video>
https://bugs.webkit.org/show_bug.cgi?id=89546

Reviewed by Antonio Gomes.
Patch by Jacky Jiang <[email protected]>

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (121361 => 121362)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-06-27 20:31:27 UTC (rev 121361)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-06-27 20:38:54 UTC (rev 121362)
@@ -371,8 +371,9 @@
     , 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 @@
         // 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 @@
         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();

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (121361 => 121362)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-06-27 20:31:27 UTC (rev 121361)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-06-27 20:38:54 UTC (rev 121362)
@@ -498,8 +498,11 @@
 #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;
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (121361 => 121362)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-06-27 20:31:27 UTC (rev 121361)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-06-27 20:38:54 UTC (rev 121362)
@@ -1,5 +1,27 @@
 2012-06-27  Jacky Jiang  <[email protected]>
 
+        [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  <[email protected]>
+
         [BlackBerry] Scale was incorrect when reloading a simple web page after initial load
         https://bugs.webkit.org/show_bug.cgi?id=88889
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to