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

Unified Diff: Source/core/dom/ViewportArguments.cpp

Issue 16826008: [css-device-adapt] Implemented spec changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Corrected expectations for tests added after original upload. 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
« no previous file with comments | « Source/core/css/resolver/ViewportStyleResolver.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ViewportArguments.cpp
diff --git a/Source/core/dom/ViewportArguments.cpp b/Source/core/dom/ViewportArguments.cpp
index e0b346da8d03f9d2076a2e3109555ded960b3e2f..d6a56f98c46bba374558a2660e04ae2d3157e406 100644
--- a/Source/core/dom/ViewportArguments.cpp
+++ b/Source/core/dom/ViewportArguments.cpp
@@ -114,10 +114,10 @@ PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceHeight);
if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
- resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, deviceSize.width(), min), max);
+ resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, initialViewportSize.width(), min), max);
if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != ViewportArguments::ValueAuto)
- resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, deviceSize.height(), min), max);
+ resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, initialViewportSize.height(), min), max);
if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != ViewportArguments::ValueAuto)
resultMaxZoom = max(resultMinZoom, resultMaxZoom);
@@ -125,25 +125,20 @@ PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
if (resultZoom != ViewportArguments::ValueAuto)
resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(resultMaxZoom, resultZoom, min), max);
- if (resultWidth == ViewportArguments::ValueAuto && resultZoom == ViewportArguments::ValueAuto)
- resultWidth = deviceSize.width();
+ if (resultWidth == ViewportArguments::ValueAuto && (resultHeight == ViewportArguments::ValueAuto || !initialViewportSize.height()))
+ resultWidth = initialViewportSize.width();
- if (resultWidth == ViewportArguments::ValueAuto && resultHeight == ViewportArguments::ValueAuto)
- resultWidth = deviceSize.width() / resultZoom;
-
- if (resultWidth == ViewportArguments::ValueAuto)
- resultWidth = resultHeight * deviceSize.width() / deviceSize.height();
-
- if (resultHeight == ViewportArguments::ValueAuto)
- resultHeight = resultWidth * deviceSize.height() / deviceSize.width();
-
- if (resultZoom != ViewportArguments::ValueAuto || resultMaxZoom != ViewportArguments::ValueAuto) {
- resultWidth = compareIgnoringAuto(resultWidth, deviceSize.width() / compareIgnoringAuto(resultZoom, resultMaxZoom, min), max);
- resultHeight = compareIgnoringAuto(resultHeight, deviceSize.height() / compareIgnoringAuto(resultZoom, resultMaxZoom, min), max);
+ if (resultWidth == ViewportArguments::ValueAuto) {
+ ASSERT(initialViewportSize.height()); // If height is 0, resultWidth should be resolved above.
+ resultWidth = resultHeight * initialViewportSize.width() / initialViewportSize.height();
}
- resultWidth = max<float>(1, resultWidth);
- resultHeight = max<float>(1, resultHeight);
+ if (resultHeight == ViewportArguments::ValueAuto) {
+ if (!initialViewportSize.width())
+ resultHeight = initialViewportSize.height();
+ else
+ resultHeight = resultWidth * initialViewportSize.height() / initialViewportSize.width();
+ }
}
if (type != ViewportArguments::CSSDeviceAdaptation && type != ViewportArguments::Implicit) {
@@ -175,9 +170,9 @@ PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
result.initialScale = resultZoom;
if (resultZoom == ViewportArguments::ValueAuto) {
result.initialScale = initialViewportSize.width() / defaultWidth;
- if (resultWidth != ViewportArguments::ValueAuto)
+ if (resultWidth != ViewportArguments::ValueAuto && resultWidth > 0)
result.initialScale = initialViewportSize.width() / resultWidth;
- if (resultHeight != ViewportArguments::ValueAuto) {
+ if (resultHeight != ViewportArguments::ValueAuto && resultHeight > 0) {
// if 'auto', the initial-scale will be negative here and thus ignored.
result.initialScale = max<float>(result.initialScale, initialViewportSize.height() / resultHeight);
}
« no previous file with comments | « Source/core/css/resolver/ViewportStyleResolver.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698