Title: [136700] trunk/Source/WebKit/blackberry
- Revision
- 136700
- Author
- [email protected]
- Date
- 2012-12-05 09:25:15 -0800 (Wed, 05 Dec 2012)
Log Message
[BlackBerry] meta viewport pages are rendered at a bad initial scale
https://bugs.webkit.org/show_bug.cgi?id=104122
Patch by Jacky Jiang <[email protected]>.
Reviewed by Rob Buis.
Internally reviewed by Arvid Nilsson.
PR: 240378
Many websites are rendered at a very bad initial scale because they
both specify meta viewport tag and have large width elements. In such
a case we will think the meta viewport tag is broken if the width of
any element is larger than the calculated layout viewport width.
The fix to this is straightforward that we will zoom the page to fit
the screen to have better user experience instead of respecting the
meta viewport. This can fix the issue on the websites such as
www.travelpod.com, www.forbes.com, interfacelift.com, www.sky.com,
raphaeljs.com and so on.
If non-empty m_userViewportArguments is applied, then we will force to
respect the viewport arguments. In this way we will restrict the fix to
browser only.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
(BlackBerry::WebKit::WebPagePrivate::setLoadState):
(BlackBerry::WebKit::WebPagePrivate::respectViewport):
(WebKit):
(BlackBerry::WebKit::WebPagePrivate::initialScale):
(BlackBerry::WebKit::WebPagePrivate::maximumScale):
(BlackBerry::WebKit::WebPagePrivate::dispatchViewportPropertiesDidChange):
* Api/WebPage_p.h:
(BlackBerry::WebKit::WebPagePrivate::isUserScalable):
(WebPagePrivate):
(BlackBerry::WebKit::WebPagePrivate::minimumScale):
Modified Paths
Diff
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (136699 => 136700)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-12-05 17:22:23 UTC (rev 136699)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-12-05 17:25:15 UTC (rev 136700)
@@ -405,6 +405,7 @@
, m_initialScale(-1.0)
, m_minimumScale(-1.0)
, m_maximumScale(-1.0)
+ , m_forceRespectViewportArguments(false)
, m_blockZoomFinalScale(1.0)
, m_anchorInNodeRectRatio(-1, -1)
, m_currentBlockZoomNode(0)
@@ -1087,6 +1088,7 @@
m_userPerformedManualZoom = false;
m_userPerformedManualScroll = false;
m_shouldUseFixedDesktopMode = false;
+ m_forceRespectViewportArguments = false;
if (m_resetVirtualViewportOnCommitted) // For DRT.
m_virtualViewportSize = IntSize();
if (m_webSettings->viewportWidth() > 0)
@@ -1108,6 +1110,8 @@
// to any fallback values. If there is a meta viewport in the
// content it will overwrite the fallback arguments soon.
dispatchViewportPropertiesDidChange(m_userViewportArguments);
+ if (m_userViewportArguments != defaultViewportArguments)
+ m_forceRespectViewportArguments = true;
} else {
Platform::IntSize virtualViewport = recomputeVirtualViewportFromViewportArguments();
m_webPage->setVirtualViewportSize(virtualViewport);
@@ -1697,9 +1701,15 @@
return std::min(zoomToFitScale, maximumImageDocumentZoomToFitScale);
}
+bool WebPagePrivate::respectViewport() const
+{
+ return m_forceRespectViewportArguments || contentsSize().width() <= m_virtualViewportSize.width();
+}
+
double WebPagePrivate::initialScale() const
{
- if (m_initialScale > 0.0)
+
+ if (m_initialScale > 0.0 && respectViewport())
return m_initialScale;
if (m_webSettings->isZoomToFitOnLoad())
@@ -1755,7 +1765,7 @@
double WebPagePrivate::maximumScale() const
{
- if (m_maximumScale >= zoomToFitScale() && m_maximumScale >= m_minimumScale)
+ if (m_maximumScale >= zoomToFitScale() && m_maximumScale >= m_minimumScale && respectViewport())
return m_maximumScale;
return hasVirtualViewport() ? std::max<double>(zoomToFitScale(), 4.0) : 4.0;
@@ -3461,9 +3471,10 @@
// If the caller is trying to reset to default arguments, use the user supplied ones instead.
static const ViewportArguments defaultViewportArguments;
- if (arguments == defaultViewportArguments)
+ if (arguments == defaultViewportArguments) {
m_viewportArguments = m_userViewportArguments;
- else
+ m_forceRespectViewportArguments = m_userViewportArguments != defaultViewportArguments;
+ } else
m_viewportArguments = arguments;
// 0 width or height in viewport arguments makes no sense, and results in a very large initial scale.
Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (136699 => 136700)
--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2012-12-05 17:22:23 UTC (rev 136699)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2012-12-05 17:25:15 UTC (rev 136700)
@@ -167,7 +167,12 @@
// Modifies the zoomToFit algorithm logic to construct a scale such that the viewportSize above is equal to this size.
bool hasVirtualViewport() const;
- bool isUserScalable() const { return m_userScalable; }
+ bool isUserScalable() const
+ {
+ if (!respectViewport())
+ return true;
+ return m_userScalable;
+ }
void setUserScalable(bool userScalable) { m_userScalable = userScalable; }
// Sets default layout size without doing layout or marking as needing layout.
@@ -234,11 +239,12 @@
// Various scale factors.
double currentScale() const { return m_transformationMatrix->m11(); }
double zoomToFitScale() const;
+ bool respectViewport() const;
double initialScale() const;
void setInitialScale(double scale) { m_initialScale = scale; }
double minimumScale() const
{
- return (m_minimumScale > zoomToFitScale() && m_minimumScale <= maximumScale()) ? m_minimumScale : zoomToFitScale();
+ return (m_minimumScale > zoomToFitScale() && m_minimumScale <= maximumScale() && respectViewport()) ? m_minimumScale : zoomToFitScale();
}
void setMinimumScale(double scale) { m_minimumScale = scale; }
@@ -533,6 +539,7 @@
double m_initialScale;
double m_minimumScale;
double m_maximumScale;
+ bool m_forceRespectViewportArguments;
// Block zoom animation data.
WebCore::FloatPoint m_finalBlockPoint;
Modified: trunk/Source/WebKit/blackberry/ChangeLog (136699 => 136700)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-12-05 17:22:23 UTC (rev 136699)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-12-05 17:25:15 UTC (rev 136700)
@@ -1,3 +1,38 @@
+2012-12-05 Jacky Jiang <[email protected]>
+
+ [BlackBerry] meta viewport pages are rendered at a bad initial scale
+ https://bugs.webkit.org/show_bug.cgi?id=104122
+
+ Reviewed by Rob Buis.
+ Internally reviewed by Arvid Nilsson.
+
+ PR: 240378
+ Many websites are rendered at a very bad initial scale because they
+ both specify meta viewport tag and have large width elements. In such
+ a case we will think the meta viewport tag is broken if the width of
+ any element is larger than the calculated layout viewport width.
+ The fix to this is straightforward that we will zoom the page to fit
+ the screen to have better user experience instead of respecting the
+ meta viewport. This can fix the issue on the websites such as
+ www.travelpod.com, www.forbes.com, interfacelift.com, www.sky.com,
+ raphaeljs.com and so on.
+ If non-empty m_userViewportArguments is applied, then we will force to
+ respect the viewport arguments. In this way we will restrict the fix to
+ browser only.
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
+ (BlackBerry::WebKit::WebPagePrivate::setLoadState):
+ (BlackBerry::WebKit::WebPagePrivate::respectViewport):
+ (WebKit):
+ (BlackBerry::WebKit::WebPagePrivate::initialScale):
+ (BlackBerry::WebKit::WebPagePrivate::maximumScale):
+ (BlackBerry::WebKit::WebPagePrivate::dispatchViewportPropertiesDidChange):
+ * Api/WebPage_p.h:
+ (BlackBerry::WebKit::WebPagePrivate::isUserScalable):
+ (WebPagePrivate):
+ (BlackBerry::WebKit::WebPagePrivate::minimumScale):
+
2012-12-05 Otto Derek Cheung <[email protected]>
[BlackBerry] GeolocationClientBB only holding the latest geolocation permission request
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes