Title: [154029] trunk/Source/WebKit/blackberry
Revision
154029
Author
[email protected]
Date
2013-08-13 15:51:40 -0700 (Tue, 13 Aug 2013)

Log 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 <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (154028 => 154029)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-08-13 22:50:35 UTC (rev 154028)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-08-13 22:51:40 UTC (rev 154029)
@@ -219,6 +219,10 @@
 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 @@
 
 double WebPagePrivate::initialScale() const
 {
-
     if (m_initialScale > 0.0 && respectViewport())
         return m_initialScale;
 
@@ -4673,17 +4676,17 @@
 
 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> {

Modified: trunk/Source/WebKit/blackberry/ChangeLog (154028 => 154029)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-08-13 22:50:35 UTC (rev 154028)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-08-13 22:51:40 UTC (rev 154029)
@@ -1,3 +1,30 @@
+2013-08-13  Jacky Jiang  <[email protected]>
+
+        [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  <[email protected]>
 
         [BlackBerry] Viewport allows scrolling when it shouldn't after rotation to landscape
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to