[BlackBerry] WebPage doesn't zoom to fit viewport after being rotated from...

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

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154029 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2c2dbf97
......@@ -219,6 +219,10 @@ const double minimumExpandingRatio = 0.15;
const double minimumZoomToFitScale = 0.25;
const double maximumImageDocumentZoomToFitScale = 2;
// Fuzz a zoom factor epsilon 0.0001 which is always too small to be visible and
// should be large enough for most of the floating-point rounding errors.
const double zoomFactorEpsilon = 0.0001;
// Helper function to parse a URL and fill in missing parts.
static KURL parseUrl(const String& url)
{
......@@ -1714,7 +1718,6 @@ bool WebPagePrivate::respectViewport() const
double WebPagePrivate::initialScale() const
{
if (m_initialScale > 0.0 && respectViewport())
return m_initialScale;
......@@ -4673,17 +4676,17 @@ bool WebPage::blockZoom(const Platform::IntPoint& documentTargetPoint)
bool WebPage::isMaxZoomed() const
{
return (d->currentScale() == d->maximumScale()) || !d->isUserScalable();
return fabs(d->currentScale() - d->maximumScale()) <= zoomFactorEpsilon || !d->isUserScalable();
}
bool WebPage::isMinZoomed() const
{
return (d->currentScale() == d->minimumScale()) || !d->isUserScalable();
return fabs(d->currentScale() - d->minimumScale()) <= zoomFactorEpsilon || !d->isUserScalable();
}
bool WebPage::isAtInitialZoom() const
{
return (d->currentScale() == d->initialScale()) || !d->isUserScalable();
return fabs(d->currentScale() - d->initialScale()) <= zoomFactorEpsilon || !d->isUserScalable();
}
class DeferredTaskSetFocused: public DeferredTask<&WebPagePrivate::m_wouldSetFocused> {
......
2013-08-13 Jacky Jiang <zhajiang@blackberry.com>
[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
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):
2013-08-09 Jacky Jiang <zhajiang@blackberry.com>
[BlackBerry] Viewport allows scrolling when it shouldn't after rotation to landscape
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment