Title: [153562] trunk/Source/WebKit/blackberry
- Revision
- 153562
- Author
- [email protected]
- Date
- 2013-07-31 19:20:22 -0700 (Wed, 31 Jul 2013)
Log Message
[BlackBerry] Page scrolls when width equals device width and initial scale is greater than 0.92
https://bugs.webkit.org/show_bug.cgi?id=119365
Patch by Jacky Jiang <[email protected]> on 2013-07-31
Reviewed by Rob Buis.
Internally reviewed by Gen Mak and Konrad Piascik.
JIRA 445423
layoutSize (deviceScreenSize/devicePixelRatio) is FloatSize as devicePixelRatio
is float. We have to round that to IntSize as ScrollView needs IntSize
fixedLayoutSize. Based on conversion result, zoomToFitWidthScale will
hardly equal to zoomToFitHeightScale in this case. And unfortunately
zoomToFitHeightScale is a little bit greater than zoomToFitWidthScale
in this case so that we have to pick up zoomToFitHeightScale which makes
the page scollable horizontally.
The way to fix that is to define an accurate contentsSize area which
potentially has float layoutSize rounding error and can cause upexpected
scroll based on the ideal contentsSize area first, and then don't scroll
only if the scale is zoomToFitScale as "contentsSize > visibleViewportSize"
still works well if the scale is larger than zoomToFitScale.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::hasFloatLayoutSizeRoundingError):
* Api/WebPage_p.h:
* WebKitSupport/WebKitThreadViewportAccessor.cpp:
(BlackBerry::WebKit::WebKitThreadViewportAccessor::cannotScrollIfHasFloatLayoutSizeRoundingError):
* WebKitSupport/WebKitThreadViewportAccessor.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (153561 => 153562)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2013-08-01 02:17:16 UTC (rev 153561)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2013-08-01 02:20:22 UTC (rev 153562)
@@ -1695,6 +1695,17 @@
return std::min(zoomToFitScale, maximumImageDocumentZoomToFitScale);
}
+bool WebPagePrivate::hasFloatLayoutSizeRoundingError() const
+{
+ int contentsWidth = contentsSize().width();
+ int contentsHeight = contentsSize().height();
+ float devicePixelRatio = m_webSettings->devicePixelRatio();
+ float idealContentsWidth = static_cast<float>(transformedActualVisibleSize().width()) / devicePixelRatio;
+ float idealContentsHeight = static_cast<float>(transformedActualVisibleSize().height()) / devicePixelRatio;
+ return devicePixelRatio > 1 && contentsWidth < idealContentsWidth && (contentsWidth + 1) > idealContentsWidth
+ && contentsHeight < idealContentsHeight && (contentsHeight + 1) > idealContentsHeight;
+}
+
bool WebPagePrivate::respectViewport() const
{
return m_forceRespectViewportArguments || contentsSize().width() <= m_virtualViewportSize.width() + 1;
Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (153561 => 153562)
--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2013-08-01 02:17:16 UTC (rev 153561)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2013-08-01 02:20:22 UTC (rev 153562)
@@ -247,6 +247,12 @@
// Various scale factors.
double currentScale() const { return m_transformationMatrix->m11(); }
double zoomToFitScale() const;
+
+ // When layoutSize is rounded from FloatSize to IntSize, it happens that contents
+ // can not be zoomed to fit the visible viewport both horizontally and vertically
+ // due to rounding error only and causes unexpected scroll.
+ bool hasFloatLayoutSizeRoundingError() const;
+
bool respectViewport() const;
double initialScale() const;
void setInitialScale(double scale) { m_initialScale = scale; }
Modified: trunk/Source/WebKit/blackberry/ChangeLog (153561 => 153562)
--- trunk/Source/WebKit/blackberry/ChangeLog 2013-08-01 02:17:16 UTC (rev 153561)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2013-08-01 02:20:22 UTC (rev 153562)
@@ -1,3 +1,32 @@
+2013-07-31 Jacky Jiang <[email protected]>
+
+ [BlackBerry] Page scrolls when width equals device width and initial scale is greater than 0.92
+ https://bugs.webkit.org/show_bug.cgi?id=119365
+
+ Reviewed by Rob Buis.
+ Internally reviewed by Gen Mak and Konrad Piascik.
+
+ JIRA 445423
+ layoutSize (deviceScreenSize/devicePixelRatio) is FloatSize as devicePixelRatio
+ is float. We have to round that to IntSize as ScrollView needs IntSize
+ fixedLayoutSize. Based on conversion result, zoomToFitWidthScale will
+ hardly equal to zoomToFitHeightScale in this case. And unfortunately
+ zoomToFitHeightScale is a little bit greater than zoomToFitWidthScale
+ in this case so that we have to pick up zoomToFitHeightScale which makes
+ the page scollable horizontally.
+ The way to fix that is to define an accurate contentsSize area which
+ potentially has float layoutSize rounding error and can cause upexpected
+ scroll based on the ideal contentsSize area first, and then don't scroll
+ only if the scale is zoomToFitScale as "contentsSize > visibleViewportSize"
+ still works well if the scale is larger than zoomToFitScale.
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPagePrivate::hasFloatLayoutSizeRoundingError):
+ * Api/WebPage_p.h:
+ * WebKitSupport/WebKitThreadViewportAccessor.cpp:
+ (BlackBerry::WebKit::WebKitThreadViewportAccessor::cannotScrollIfHasFloatLayoutSizeRoundingError):
+ * WebKitSupport/WebKitThreadViewportAccessor.h:
+
2013-07-27 Jacky Jiang <[email protected]>
Replace all uses of GraphicsLayer::create function with the one that takes a GraphicsLayerFactory
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/WebKitThreadViewportAccessor.cpp (153561 => 153562)
--- trunk/Source/WebKit/blackberry/WebKitSupport/WebKitThreadViewportAccessor.cpp 2013-08-01 02:17:16 UTC (rev 153561)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/WebKitThreadViewportAccessor.cpp 2013-08-01 02:20:22 UTC (rev 153562)
@@ -88,5 +88,15 @@
return m_webPagePrivate->currentScale();
}
+bool WebKitThreadViewportAccessor::cannotScrollIfHasFloatLayoutSizeRoundingError() const
+{
+ ASSERT(Platform::webKitThreadMessageClient()->isCurrentThread());
+
+ // floatLayoutSizeRoundingError can cause inaccurate pixelContentsSize and result in
+ // unexpected scroll only when the current scale is zoomToFitScale. We have to exclude this case.
+ return m_webPagePrivate->hasFloatLayoutSizeRoundingError()
+ && fabsf(m_webPagePrivate->currentScale() - m_webPagePrivate->zoomToFitScale()) < FLT_EPSILON;
+}
+
} // namespace WebKit
} // namespace BlackBerry
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/WebKitThreadViewportAccessor.h (153561 => 153562)
--- trunk/Source/WebKit/blackberry/WebKitSupport/WebKitThreadViewportAccessor.h 2013-08-01 02:17:16 UTC (rev 153561)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/WebKitThreadViewportAccessor.h 2013-08-01 02:20:22 UTC (rev 153562)
@@ -36,6 +36,8 @@
virtual double scale() const;
+ virtual bool cannotScrollIfHasFloatLayoutSizeRoundingError() const;
+
private:
Platform::ViewportAccessor* m_originalAccessor;
WebPagePrivate* m_webPagePrivate;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes