Changeset 154029 in webkit


Ignore:
Timestamp:
Aug 13, 2013 3:51:40 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] WebPage doesn't zoom to fit viewport after being rotated from landscape to portrait mode
https://bugs.webkit.org/show_bug.cgi?id=119754

Patch by Jacky Jiang <zhajiang@blackberry.com> on 2013-08-13
Reviewed by Rob Buis.
Internally reviewed by Konrad Piascik.

JIRA 470951
In this case, zoomToFitWidthScale(currentScale) = viewportWidth / contentsWidth
which was 2.6666666666666665, initialScale = ((viewportWidth / devicePixelRatio)
/ contentsWidth) * devicePixelRatio which was 2.6666665077209473. When
rotating the device from landscape to portrait, m_webPage->isAtInitialZoom()
was false in setViewportSize() because of the floating-point rounding error
above so that we had to use the scale of the previous rotation WebPage
which was too large for the current rotation WebPage.
Ignore the floating-point rounding error in isAtInitialZoom() so that we
can use initialScale of the current rotation WebPage as the scale and also
we should do it for isMaxZoomed() and isMinZoomed() as well. Please note
that we can not use FLT_EPSILON here as it's 1E-7 on our platform.

  • Api/WebPage.cpp:

(BlackBerry::WebKit::WebPagePrivate::initialScale):
(BlackBerry::WebKit::WebPage::isMaxZoomed):
(BlackBerry::WebKit::WebPage::isMinZoomed):
(BlackBerry::WebKit::WebPage::isAtInitialZoom):

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

Legend:

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

    r153896 r154029  
    220220const double maximumImageDocumentZoomToFitScale = 2;
    221221
     222// Fuzz a zoom factor epsilon 0.0001 which is always too small to be visible and
     223// should be large enough for most of the floating-point rounding errors.
     224const double zoomFactorEpsilon = 0.0001;
     225
    222226// Helper function to parse a URL and fill in missing parts.
    223227static KURL parseUrl(const String& url)
     
    17151719double WebPagePrivate::initialScale() const
    17161720{
    1717 
    17181721    if (m_initialScale > 0.0 && respectViewport())
    17191722        return m_initialScale;
     
    46744677bool WebPage::isMaxZoomed() const
    46754678{
    4676     return (d->currentScale() == d->maximumScale()) || !d->isUserScalable();
     4679    return fabs(d->currentScale() - d->maximumScale()) <= zoomFactorEpsilon || !d->isUserScalable();
    46774680}
    46784681
    46794682bool WebPage::isMinZoomed() const
    46804683{
    4681     return (d->currentScale() == d->minimumScale()) || !d->isUserScalable();
     4684    return fabs(d->currentScale() - d->minimumScale()) <= zoomFactorEpsilon || !d->isUserScalable();
    46824685}
    46834686
    46844687bool WebPage::isAtInitialZoom() const
    46854688{
    4686     return (d->currentScale() == d->initialScale()) || !d->isUserScalable();
     4689    return fabs(d->currentScale() - d->initialScale()) <= zoomFactorEpsilon || !d->isUserScalable();
    46874690}
    46884691
  • trunk/Source/WebKit/blackberry/ChangeLog

    r153896 r154029  
     12013-08-13  Jacky Jiang  <zhajiang@blackberry.com>
     2
     3        [BlackBerry] WebPage doesn't zoom to fit viewport after being rotated from landscape to portrait mode
     4        https://bugs.webkit.org/show_bug.cgi?id=119754
     5
     6        Reviewed by Rob Buis.
     7        Internally reviewed by Konrad Piascik.
     8
     9        JIRA 470951
     10        In this case, zoomToFitWidthScale(currentScale) = viewportWidth / contentsWidth
     11        which was 2.6666666666666665, initialScale = ((viewportWidth / devicePixelRatio)
     12        / contentsWidth) * devicePixelRatio which was 2.6666665077209473. When
     13        rotating the device from landscape to portrait, m_webPage->isAtInitialZoom()
     14        was false in setViewportSize() because of the floating-point rounding error
     15        above so that we had to use the scale of the previous rotation WebPage
     16        which was too large for the current rotation WebPage.
     17        Ignore the floating-point rounding error in isAtInitialZoom() so that we
     18        can use initialScale of the current rotation WebPage as the scale and also
     19        we should do it for isMaxZoomed() and isMinZoomed() as well. Please note
     20        that we can not use FLT_EPSILON here as it's 1E-7 on our platform.
     21
     22        * Api/WebPage.cpp:
     23        (BlackBerry::WebKit::WebPagePrivate::initialScale):
     24        (BlackBerry::WebKit::WebPage::isMaxZoomed):
     25        (BlackBerry::WebKit::WebPage::isMinZoomed):
     26        (BlackBerry::WebKit::WebPage::isAtInitialZoom):
     27
    1282013-08-09  Jacky Jiang  <zhajiang@blackberry.com>
    229
Note: See TracChangeset for help on using the changeset viewer.