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

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, 4 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
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index e9deda3d5eeb72964a8914373a084910fb5ba4d6..63fbba2051d6130d00607ba65423236095c3bd72 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -31,22 +31,6 @@
#include "config.h"
#include "WebViewImpl.h"
-#include "public/platform/Platform.h"
-#include "public/platform/WebDragData.h"
-#include "public/platform/WebFloatPoint.h"
-#include "public/platform/WebGestureCurve.h"
-#include "public/platform/WebImage.h"
-#include "public/platform/WebLayer.h"
-#include "public/platform/WebLayerTreeView.h"
-#include "public/platform/WebPoint.h"
-#include "public/platform/WebRect.h"
-#include "public/platform/WebString.h"
-#include "public/platform/WebVector.h"
-#include "wtf/CurrentTime.h"
-#include "wtf/MainThread.h"
-#include "wtf/RefPtr.h"
-#include "wtf/TemporaryChange.h"
-#include "wtf/Uint8ClampedArray.h"
#include "AutofillPopupMenuClient.h"
#include "CSSValueKeywords.h"
#include "CompositionUnderlineVectorBuilder.h"
@@ -91,7 +75,9 @@
#include "WebViewClient.h"
#include "WebWindowFeatures.h"
#include "core/accessibility/AXObjectCache.h"
+#include "core/css/StyleSheetContents.h"
#include "core/css/resolver/StyleResolver.h"
+#include "core/css/resolver/ViewportStyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/DocumentMarkerController.h"
#include "core/dom/KeyboardEvent.h"
@@ -158,10 +144,27 @@
#include "core/rendering/RenderWidget.h"
#include "core/rendering/TextAutosizer.h"
#include "modules/geolocation/GeolocationController.h"
+#include "painting/ContinuousPainter.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebDragData.h"
+#include "public/platform/WebFloatPoint.h"
+#include "public/platform/WebGestureCurve.h"
+#include "public/platform/WebImage.h"
+#include "public/platform/WebLayer.h"
+#include "public/platform/WebLayerTreeView.h"
+#include "public/platform/WebPoint.h"
+#include "public/platform/WebRect.h"
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
#include "weborigin/SchemeRegistry.h"
#include "weborigin/SecurityOrigin.h"
#include "weborigin/SecurityPolicy.h"
-#include "painting/ContinuousPainter.h"
+#include "wtf/CurrentTime.h"
+#include "wtf/MainThread.h"
+#include "wtf/RefPtr.h"
+#include "wtf/TemporaryChange.h"
+#include "wtf/Uint8ClampedArray.h"
+#include "wtf/text/StringBuilder.h"
#if ENABLE(DEFAULT_RENDER_THEME)
#include "core/platform/chromium/PlatformThemeChromiumDefault.h"
@@ -2914,6 +2917,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;
@@ -2925,11 +2960,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);
}
@@ -2990,7 +3020,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());
@@ -4109,9 +4139,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

Powered by Google App Engine
This is Rietveld 408576698