Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 19555002: Translate viewport related meta tags into @viewport descriptors as suggested by the CSS Device Adap… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/core/testing/Internals.cpp ('K') | « Source/core/testing/Internals.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 4f23298076d330f7892464fa0870eb8c8e04ed2f..446a4a9b8e4eb219c2e32ba2e9575129d59d77a8 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -87,6 +87,7 @@
#include "WebTextInputInfo.h"
#include "WebViewClient.h"
#include "core/accessibility/AXObjectCache.h"
+#include "core/css/StyleSheetContents.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/DocumentMarkerController.h"
@@ -2967,6 +2968,38 @@ void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst
return;
m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints);
+ m_pageScaleConstraintsSet.setNeedsReset(true);
+
+ Vector<String> whitelist;
+ Document* document = m_page->mainFrame()->document();
+ whitelist.append(document->url());
+
+ StringBuilder builder;
+
+ builder.append("@viewport{");
+
+ if (newConstraints.initialScale > 0) {
+ builder.appendLiteral("zoom:");
+ builder.append(String::number(newConstraints.initialScale));
+ builder.appendLiteral("!important;");
+ }
+
+ if (newConstraints.minimumScale > 0) {
+ builder.appendLiteral("min-zoom:");
+ builder.append(String::number(newConstraints.minimumScale));
+ builder.appendLiteral("!important;");
+ }
+
+ if (newConstraints.maximumScale > 0) {
+ builder.appendLiteral("max-zoom:");
+ builder.append(String::number(newConstraints.maximumScale));
+ builder.appendLiteral("!important;");
+ }
+
+ builder.append("}");
+
+ removeAllUserContent();
+ addUserStyleSheet(builder.toString(), whitelist, UserContentInjectInAllFrames, UserStyleInjectInExistingDocuments);
if (!mainFrameImpl() || !mainFrameImpl()->frameView())
return;
@@ -2978,11 +3011,6 @@ void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri
{
PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstraints();
constraints.initialScale = initialPageScaleFactorOverride;
-
- if (constraints == m_pageScaleConstraintsSet.userAgentConstraints())
- return;
-
- m_pageScaleConstraintsSet.setNeedsReset(true);
setUserAgentPageScaleConstraints(constraints);
}
@@ -3043,7 +3071,7 @@ void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments&
if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page() || !m_size.width || !m_size.height)
return;
- m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size, page()->settings()->layoutFallbackWidth());
+ m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size);
if (settingsImpl()->supportDeprecatedTargetDensityDPI())
m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView(arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor(), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMode());
@@ -4141,9 +4169,8 @@ void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event)
bool WebViewImpl::shouldDisableDesktopWorkarounds()
{
- ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewportArguments();
- return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.userZoom
- || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != ViewportArguments::ValueAuto);
+ Document* document = mainFrameImpl()->frame()->document();
+ return document->styleResolver()->viewportStyleResolver()->shouldDisableDesktopWorkarounds();
}
} // namespace WebKit
« Source/core/testing/Internals.cpp ('K') | « Source/core/testing/Internals.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698