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

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

Issue 14813025: Refactor viewport initialization logic out of WebViewImpl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add tests for new behavior Created 7 years, 7 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/core/dom/ViewportArguments.cpp
diff --git a/Source/core/dom/ViewportArguments.cpp b/Source/core/dom/ViewportArguments.cpp
index ec88fbcaa8ada9c49926872aa4c675cd2a218a6c..edb94e64627c230f12b47339d587b96ee8c0f8be 100644
--- a/Source/core/dom/ViewportArguments.cpp
+++ b/Source/core/dom/ViewportArguments.cpp
@@ -42,8 +42,6 @@ using namespace std;
namespace WebCore {
-const float ViewportArguments::deprecatedTargetDPI = 160;
-
static const float& compareIgnoringAuto(const float& value1, const float& value2, const float& (*compare) (const float&, const float&))
{
ASSERT(value1 != ViewportArguments::ValueAuto || value2 != ViewportArguments::ValueAuto);
@@ -191,7 +189,6 @@ ViewportAttributes ViewportArguments::resolve(const FloatSize& initialViewportSi
}
ViewportAttributes result;
- result.orientation = orientation;
// Resolve minimum-scale and maximum-scale values according to spec.
if (resultMinZoom == ViewportArguments::ValueAuto)
@@ -244,52 +241,14 @@ ViewportAttributes ViewportArguments::resolve(const FloatSize& initialViewportSi
result.layoutSize.setWidth(resultWidth);
result.layoutSize.setHeight(resultHeight);
- // FIXME: This might affect some ports, but is the right thing to do.
- // Only set initialScale to a value if it was explicitly set.
- // if (resultZoom == ViewportArguments::ValueAuto)
- // result.initialScale = ViewportArguments::ValueAuto;
-
- result.userScalable = resultUserZoom;
- result.orientation = orientation;
+ // If user-scalable = no, lock the min/max scale to the computed initial
+ // scale.
+ if (!resultUserZoom)
+ result.maximumScale = result.minimumScale = result.initialScale;
return result;
}
-static FloatSize convertToUserSpace(const FloatSize& deviceSize, float devicePixelRatio)
-{
- FloatSize result = deviceSize;
- if (devicePixelRatio != 1)
- result.scale(1 / devicePixelRatio);
- return result;
-}
-
-ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, float devicePixelRatio, IntSize visibleViewport)
-{
- FloatSize initialViewportSize = convertToUserSpace(visibleViewport, devicePixelRatio);
- FloatSize deviceSize = convertToUserSpace(FloatSize(deviceWidth, deviceHeight), devicePixelRatio);
-
- return args.resolve(initialViewportSize, deviceSize, desktopWidth);
-}
-
-float computeMinimumScaleFactorForContentContained(const ViewportAttributes& result, const IntSize& visibleViewport, const IntSize& contentsSize)
-{
- FloatSize viewportSize(visibleViewport);
- return max<float>(result.minimumScale, max(viewportSize.width() / contentsSize.width(), viewportSize.height() / contentsSize.height()));
-}
-
-void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport, float devicePixelRatio)
-{
- FloatSize viewportSize = convertToUserSpace(visibleViewport, devicePixelRatio);
-
- result.minimumScale = max<float>(result.minimumScale, max(viewportSize.width() / result.layoutSize.width(), viewportSize.height() / result.layoutSize.height()));
-}
-
-void restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes& result)
-{
- if (!result.userScalable)
- result.maximumScale = result.minimumScale = result.initialScale;
-}
-
static float numericPrefix(const String& keyString, const String& valueString, Document* document, bool* ok = 0)
{
size_t parsedLength;

Powered by Google App Engine
This is Rietveld 408576698