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

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

Issue 19632002: Support 'extend-to-zoom' viewport descriptor value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed isExtendToZoom() 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/dom/ViewportArguments.h ('k') | Source/core/platform/Length.h » ('j') | 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 d6a56f98c46bba374558a2660e04ae2d3157e406..92ae2cf0ae0dc57aecb8c5f2da81ca7e8984a384 100644
--- a/Source/core/dom/ViewportArguments.cpp
+++ b/Source/core/dom/ViewportArguments.cpp
@@ -6,7 +6,7 @@
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -37,8 +37,6 @@ namespace WebCore {
static const float& compareIgnoringAuto(const float& value1, const float& value2, const float& (*compare) (const float&, const float&))
{
- ASSERT(value1 != ViewportArguments::ValueAuto || value2 != ViewportArguments::ValueAuto);
-
if (value1 == ViewportArguments::ValueAuto)
return value2;
@@ -78,29 +76,12 @@ PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
float resultHeight = height;
float resultMinHeight = minHeight;
float resultMaxHeight = maxHeight;
+
float resultZoom = zoom;
float resultMinZoom = minZoom;
float resultMaxZoom = maxZoom;
float resultUserZoom = userZoom;
- switch (int(resultWidth)) {
- case ViewportArguments::ValueDeviceWidth:
- resultWidth = deviceSize.width();
- break;
- case ViewportArguments::ValueDeviceHeight:
- resultWidth = deviceSize.height();
- break;
- }
-
- switch (int(resultHeight)) {
- case ViewportArguments::ValueDeviceWidth:
- resultHeight = deviceSize.width();
- break;
- case ViewportArguments::ValueDeviceHeight:
- resultHeight = deviceSize.height();
- break;
- }
-
if (type == ViewportArguments::CSSDeviceAdaptation) {
// device-width/device-height not supported for @viewport.
@@ -113,35 +94,97 @@ PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport
ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceWidth);
ASSERT(resultMaxHeight != ViewportArguments::ValueDeviceHeight);
- if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
- resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, initialViewportSize.width(), min), max);
-
- if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != ViewportArguments::ValueAuto)
- resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, initialViewportSize.height(), min), max);
-
+ // 1. Resolve min-zoom and max-zoom values.
if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != ViewportArguments::ValueAuto)
resultMaxZoom = max(resultMinZoom, resultMaxZoom);
+ // 2. Constrain zoom value to the [min-zoom, max-zoom] range.
if (resultZoom != ViewportArguments::ValueAuto)
resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(resultMaxZoom, resultZoom, min), max);
- if (resultWidth == ViewportArguments::ValueAuto && (resultHeight == ViewportArguments::ValueAuto || !initialViewportSize.height()))
- resultWidth = initialViewportSize.width();
+ float extendZoom = compareIgnoringAuto(resultZoom, resultMaxZoom, min);
+
+ if (extendZoom == ViewportArguments::ValueAuto) {
+ if (resultMaxWidth == ViewportArguments::ValueExtendToZoom)
+ resultMaxWidth = ViewportArguments::ValueAuto;
+
+ if (resultMaxHeight == ViewportArguments::ValueExtendToZoom)
+ resultMaxHeight = ViewportArguments::ValueAuto;
+
+ if (resultMinWidth == ViewportArguments::ValueExtendToZoom)
+ resultMinWidth = resultMaxWidth;
+
+ if (resultMinHeight == ViewportArguments::ValueExtendToZoom)
+ resultMinHeight = resultMaxHeight;
+ } else {
+ float extendWidth = initialViewportSize.width() / extendZoom;
+ float extendHeight = initialViewportSize.height() / extendZoom;
+
+ if (resultMaxWidth == ViewportArguments::ValueExtendToZoom)
+ resultMaxWidth = extendWidth;
+
+ if (resultMaxHeight == ViewportArguments::ValueExtendToZoom)
+ resultMaxHeight = extendHeight;
+ if (resultMinWidth == ViewportArguments::ValueExtendToZoom)
+ resultMinWidth = compareIgnoringAuto(extendWidth, resultMaxWidth, max);
+
+ if (resultMinHeight == ViewportArguments::ValueExtendToZoom)
+ resultMinHeight = compareIgnoringAuto(extendHeight, resultMaxHeight, max);
+ }
+
+ // 4. Resolve initial width from min/max descriptors.
+ if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
+ resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, initialViewportSize.width(), min), max);
+
+ // 5. Resolve initial height from min/max descriptors.
+ if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != ViewportArguments::ValueAuto)
+ resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, initialViewportSize.height(), min), max);
+
+ // 6-7. Resolve width value.
if (resultWidth == ViewportArguments::ValueAuto) {
- ASSERT(initialViewportSize.height()); // If height is 0, resultWidth should be resolved above.
- resultWidth = resultHeight * initialViewportSize.width() / initialViewportSize.height();
+ if (resultHeight == ViewportArguments::ValueAuto || !initialViewportSize .height())
+ resultWidth = initialViewportSize.width();
+ else
+ resultWidth = resultHeight * (initialViewportSize.width() / initialViewportSize.height());
}
+ // 8. Resolve height value.
if (resultHeight == ViewportArguments::ValueAuto) {
if (!initialViewportSize.width())
resultHeight = initialViewportSize.height();
else
resultHeight = resultWidth * initialViewportSize.height() / initialViewportSize.width();
}
+
+ PageScaleConstraints result;
+ result.minimumScale = resultMinZoom;
+ result.maximumScale = resultMaxZoom;
+ result.initialScale = resultZoom;
+ result.layoutSize.setWidth(resultWidth);
+ result.layoutSize.setHeight(resultHeight);
+ return result;
+ }
+
+ switch (static_cast<int>(resultWidth)) {
+ case ViewportArguments::ValueDeviceWidth:
+ resultWidth = deviceSize.width();
+ break;
+ case ViewportArguments::ValueDeviceHeight:
+ resultWidth = deviceSize.height();
+ break;
+ }
+
+ switch (static_cast<int>(resultHeight)) {
+ case ViewportArguments::ValueDeviceWidth:
+ resultHeight = deviceSize.width();
+ break;
+ case ViewportArguments::ValueDeviceHeight:
+ resultHeight = deviceSize.height();
+ break;
}
- if (type != ViewportArguments::CSSDeviceAdaptation && type != ViewportArguments::Implicit) {
+ if (type != ViewportArguments::Implicit) {
// Clamp values to a valid range, but not for @viewport since is
// not mandated by the specification.
resultWidth = clampLengthValue(resultWidth);
« no previous file with comments | « Source/core/dom/ViewportArguments.h ('k') | Source/core/platform/Length.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698