- Revision
- 121213
- Author
- [email protected]
- Date
- 2012-06-25 18:59:57 -0700 (Mon, 25 Jun 2012)
Log Message
[Chromium] Let the embedder override the max page scale factor set by the page
https://bugs.webkit.org/show_bug.cgi?id=89406
Reviewed by James Robinson.
Chrome on Android has an option to force the web site to allow page
scaling (for accessibility). This patch adds
WebView::setIgnoreViewportTagMaximumScale, which instructs the WebView
to ignore the maximum scale factor supplied by by the page in the
viewport meta tag.
This patch is a bit different from how this is implemented on the
chromium-android branch, but I'll clean up the branch once this patch
lands.
* public/WebView.h:
(WebView):
* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::setIgnoreViewportTagMaximumScale):
(WebKit):
* src/WebViewImpl.h:
(WebViewImpl):
(WebKit::WebViewImpl::ignoreViewportTagMaximumScale):
* tests/WebFrameTest.cpp:
(WebKit::TEST_F):
(WebKit):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (121212 => 121213)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-06-26 01:57:37 UTC (rev 121212)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-06-26 01:59:57 UTC (rev 121213)
@@ -1,3 +1,35 @@
+2012-06-25 Adam Barth <[email protected]>
+
+ [Chromium] Let the embedder override the max page scale factor set by the page
+ https://bugs.webkit.org/show_bug.cgi?id=89406
+
+ Reviewed by James Robinson.
+
+ Chrome on Android has an option to force the web site to allow page
+ scaling (for accessibility). This patch adds
+ WebView::setIgnoreViewportTagMaximumScale, which instructs the WebView
+ to ignore the maximum scale factor supplied by by the page in the
+ viewport meta tag.
+
+ This patch is a bit different from how this is implemented on the
+ chromium-android branch, but I'll clean up the branch once this patch
+ lands.
+
+ * public/WebView.h:
+ (WebView):
+ * src/ChromeClientImpl.cpp:
+ (WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::WebViewImpl):
+ (WebKit::WebViewImpl::setIgnoreViewportTagMaximumScale):
+ (WebKit):
+ * src/WebViewImpl.h:
+ (WebViewImpl):
+ (WebKit::WebViewImpl::ignoreViewportTagMaximumScale):
+ * tests/WebFrameTest.cpp:
+ (WebKit::TEST_F):
+ (WebKit):
+
2012-06-25 Sheriff Bot <[email protected]>
Unreviewed, rolling out r121176.
Modified: trunk/Source/WebKit/chromium/public/WebView.h (121212 => 121213)
--- trunk/Source/WebKit/chromium/public/WebView.h 2012-06-26 01:57:37 UTC (rev 121212)
+++ trunk/Source/WebKit/chromium/public/WebView.h 2012-06-26 01:59:57 UTC (rev 121213)
@@ -249,6 +249,11 @@
virtual float minimumPageScaleFactor() const = 0;
virtual float maximumPageScaleFactor() const = 0;
+ // Prevent the web page from setting a maximum scale via the viewport meta
+ // tag. This is an accessibility feature that lets folks zoom in to web
+ // pages even if the web page tries to block scaling.
+ virtual void setIgnoreViewportTagMaximumScale(bool) = 0;
+
// The ratio of the current device's screen DPI to the target device's screen DPI.
virtual float deviceScaleFactor() const = 0;
Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (121212 => 121213)
--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp 2012-06-26 01:57:37 UTC (rev 121212)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp 2012-06-26 01:59:57 UTC (rev 121213)
@@ -657,6 +657,11 @@
args, settings->layoutFallbackWidth(), deviceRect.width, deviceRect.height,
dpi, IntSize(deviceRect.width, deviceRect.height));
+ if (m_webView->ignoreViewportTagMaximumScale()) {
+ computed.maximumScale = max(computed.maximumScale, m_webView->maxPageScaleFactor);
+ computed.userScalable = true;
+ }
+
int layoutWidth = computed.layoutSize.width();
int layoutHeight = computed.layoutSize.height();
m_webView->setFixedLayoutSize(IntSize(layoutWidth, layoutHeight));
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (121212 => 121213)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-06-26 01:57:37 UTC (rev 121212)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-06-26 01:59:57 UTC (rev 121213)
@@ -386,6 +386,7 @@
, m_pageDefinedMaximumPageScaleFactor(-1)
, m_minimumPageScaleFactor(minPageScaleFactor)
, m_maximumPageScaleFactor(maxPageScaleFactor)
+ , m_ignoreViewportTagMaximumScale(false)
, m_pageScaleFactorIsSet(false)
, m_contextMenuAllowed(false)
, m_doingDragAndDrop(false)
@@ -2607,6 +2608,16 @@
computePageScaleFactorLimits();
}
+void WebViewImpl::setIgnoreViewportTagMaximumScale(bool flag)
+{
+ m_ignoreViewportTagMaximumScale = flag;
+
+ if (!page() || !page()->mainFrame())
+ return;
+
+ m_page->chrome()->client()->dispatchViewportPropertiesDidChange(page()->mainFrame()->document()->viewportArguments());
+}
+
bool WebViewImpl::computePageScaleFactorLimits()
{
if (m_pageDefinedMinimumPageScaleFactor == -1 || m_pageDefinedMaximumPageScaleFactor == -1)
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (121212 => 121213)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-06-26 01:57:37 UTC (rev 121212)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-06-26 01:59:57 UTC (rev 121213)
@@ -207,6 +207,7 @@
virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale);
virtual float minimumPageScaleFactor() const;
virtual float maximumPageScaleFactor() const;
+ virtual void setIgnoreViewportTagMaximumScale(bool);
virtual float deviceScaleFactor() const;
virtual void setDeviceScaleFactor(float);
@@ -451,6 +452,8 @@
return m_emulatedTextZoomFactor;
}
+ bool ignoreViewportTagMaximumScale() const { return m_ignoreViewportTagMaximumScale; }
+
// Determines whether a page should e.g. be opened in a background tab.
// Returns false if it has no opinion, in which case it doesn't set *policy.
static bool navigationPolicyFromMouseEvent(
@@ -709,6 +712,8 @@
float m_minimumPageScaleFactor;
float m_maximumPageScaleFactor;
+ bool m_ignoreViewportTagMaximumScale;
+
bool m_pageScaleFactorIsSet;
bool m_contextMenuAllowed;
Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (121212 => 121213)
--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-06-26 01:57:37 UTC (rev 121212)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-06-26 01:59:57 UTC (rev 121213)
@@ -284,6 +284,28 @@
}
#endif
+TEST_F(WebFrameTest, CanOverrideMaximumScaleFactor)
+{
+ registerMockedHttpURLLoad("no_scale_for_you.html");
+
+ FixedLayoutTestWebViewClient client;
+ client.m_screenInfo.horizontalDPI = 160;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+ client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
+
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_scale_for_you.html", true, 0, &client));
+ webViewImpl->enableFixedLayoutMode(true);
+ webViewImpl->settings()->setViewportEnabled(true);
+ webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
+
+ EXPECT_EQ(1.0f, webViewImpl->maximumPageScaleFactor());
+
+ webViewImpl->setIgnoreViewportTagMaximumScale(true);
+
+ EXPECT_EQ(4.0f, webViewImpl->maximumPageScaleFactor());
+}
+
#if ENABLE(GESTURE_EVENTS)
TEST_F(WebFrameTest, DivAutoZoomParamsTest)
{
Added: trunk/Source/WebKit/chromium/tests/data/no_scale_for_you.html (0 => 121213)
--- trunk/Source/WebKit/chromium/tests/data/no_scale_for_you.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/no_scale_for_you.html 2012-06-26 01:59:57 UTC (rev 121213)
@@ -0,0 +1 @@
+<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" >