Changeset 139955 in webkit


Ignore:
Timestamp:
Jan 16, 2013 7:52:52 PM (11 years ago)
Author:
charles.wei@torchmobile.com.cn
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):

Location:
trunk/Source/WebKit/blackberry
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r139787 r139955  
    38203820
    38213821#if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO)
    3822     // When leaving fullscreen mode, restore the scale and scroll position
    3823     // if needed.
    3824     // FIXME: The cached values might get imprecise if user have rotated the
    3825     // device while in fullscreen.
     3822    // When leaving fullscreen mode, restore the scale and scroll position if needed.
     3823    // We also need to make sure the scale and scroll position won't cause over scale or over scroll.
    38263824    if (m_scaleBeforeFullScreen > 0 && !m_fullscreenVideoNode) {
    38273825        // Restore the scale when leaving fullscreen. We can't use TransformationMatrix::scale(double) here,
    38283826        // as it will multiply the scale rather than set the scale.
    38293827        // FIXME: We can refactor this into setCurrentScale(double) if it is useful in the future.
     3828        if (m_orientationBeforeFullScreen % 180 != orientation() % 180) { // Orientation changed
     3829            if (m_actualVisibleWidth > contentsSize().width() * m_scaleBeforeFullScreen) {
     3830                // Cached scale need to be adjusted after rotation.
     3831                m_scaleBeforeFullScreen = double(m_actualVisibleWidth) / contentsSize().width();
     3832            }
     3833            if (m_scaleBeforeFullScreen * contentsSize().height() < m_actualVisibleHeight) {
     3834                // Use zoom to fit height scale in order to cover the screen height.
     3835                m_scaleBeforeFullScreen = double(m_actualVisibleHeight) / contentsSize().height();
     3836            }
     3837
     3838            if (m_actualVisibleWidth > m_scaleBeforeFullScreen * (contentsSize().width() - m_scrollPositionBeforeFullScreen.x())) {
     3839                // Cached scroll position over scrolls horizontally after rotation.
     3840                m_scrollPositionBeforeFullScreen.setX(contentsSize().width() - m_actualVisibleWidth / m_scaleBeforeFullScreen);
     3841            }
     3842            if (m_actualVisibleHeight > m_scaleBeforeFullScreen * (contentsSize().height() - m_scrollPositionBeforeFullScreen.y())) {
     3843                // Cached scroll position over scrolls vertically after rotation.
     3844                m_scrollPositionBeforeFullScreen.setY(contentsSize().height() - m_actualVisibleHeight / m_scaleBeforeFullScreen);
     3845            }
     3846        }
     3847
    38303848        m_transformationMatrix->setM11(m_scaleBeforeFullScreen);
    38313849        m_transformationMatrix->setM22(m_scaleBeforeFullScreen);
     
    58095827            // once element leaves fullscreen.
    58105828            m_scrollPositionBeforeFullScreen = m_mainFrame->view()->scrollPosition();
     5829
     5830            // We need to remember the orientation before entering fullscreen, so that we can adjust
     5831            // the scale and scroll position when exiting fullscreen if needed, because the scale and
     5832            // scroll position  may not apply (overscale and/or overscroll) in the other orientation.
     5833            m_orientationBeforeFullScreen = orientation();
    58115834        }
    58125835
  • trunk/Source/WebKit/blackberry/Api/WebPage_p.h

    r139787 r139955  
    529529    double m_scaleBeforeFullScreen;
    530530    WebCore::IntPoint m_scrollPositionBeforeFullScreen;
     531    int m_orientationBeforeFullScreen;
    531532#endif
    532533#endif
  • trunk/Source/WebKit/blackberry/ChangeLog

    r139925 r139955  
     12013-01-16  Charles Wei  <charles.wei@torchmobile.com.cn>
     2
     3        [BlackBerry] Need to adjust the scale and scroll position after leaving fullscreen mode if there's
     4        device rotation in fullscreen mode
     5        https://bugs.webkit.org/show_bug.cgi?id=107085
     6
     7        Reviewed by George STaikos.
     8        Also internally reviewed by Jacky Jiang.
     9
     10        We saved the scale and scroll position before entering full screen mode, so that we can restore
     11        them after leaving fullscreen mode, because entering fullscreen mode automatically changes the
     12       scale to make the video to fit to the viewport. But if there's device rotation during the fullscreen,
     13       the scale and scroll position saved before may or may not apply anymore, we need to adjust the
     14       scale and/or scroll position if needed to make sure no over-scale or over-scroll in the new orientation.
     15
     16        * Api/WebPage.cpp:
     17        (BlackBerry::WebKit::WebPagePrivate::setViewportSize):
     18        (BlackBerry::WebKit::WebPagePrivate::enterFullScreenForElement):
     19        * Api/WebPage_p.h:
     20        (WebPagePrivate):
     21
    1222013-01-16  Joe Mason  <jmason@rim.com>
    223
Note: See TracChangeset for help on using the changeset viewer.