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

Unified Diff: Source/core/testing/Internals.cpp

Issue 14813025: Refactor viewport initialization logic out of WebViewImpl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Another RTL test fix 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/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 1042d3522647a53f607d2e7d96d40253c34b592f..f57023a4a9ee5478e5d5c2ec3c59d8d07478cf71 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -906,6 +906,35 @@ void Internals::setPagination(Document* document, const String& mode, int gap, i
page->setPagination(pagination);
}
+static FloatSize convertToUserSpace(const FloatSize& deviceSize, float devicePixelRatio)
abarth-chromium 2013/05/20 18:22:25 What is "user space" ?
+{
+ FloatSize result = deviceSize;
+ if (devicePixelRatio != 1)
+ result.scale(1 / devicePixelRatio);
+ return result;
+}
+
+static 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);
+}
+
+static 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()));
+}
+
+static 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()));
+}
abarth-chromium 2013/05/20 18:22:25 I don't understand why we need all of this code in
+
String Internals::configurationForViewport(Document* document, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
{
if (!document || !document->page()) {
@@ -919,9 +948,8 @@ String Internals::configurationForViewport(Document* document, float devicePixel
ViewportArguments arguments = page->viewportArguments();
ViewportAttributes attributes = computeViewportAttributes(arguments, defaultLayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSize(availableWidth, availableHeight));
restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight), devicePixelRatio);
- restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
- return "viewport size " + String::number(attributes.layoutSize.width()) + "x" + String::number(attributes.layoutSize.height()) + " scale " + String::number(attributes.initialScale) + " with limits [" + String::number(attributes.minimumScale) + ", " + String::number(attributes.maximumScale) + "] and userScalable " + (attributes.userScalable ? "true" : "false");
+ return "viewport size " + String::number(attributes.layoutSize.width()) + "x" + String::number(attributes.layoutSize.height()) + " scale " + String::number(attributes.initialScale) + " with limits [" + String::number(attributes.minimumScale) + ", " + String::number(attributes.maximumScale) + "] and userScalable " + (arguments.userZoom ? "true" : "false");
}
bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec)
« Source/WebKit/chromium/src/ViewportAttributesManager.h ('K') | « Source/core/page/Page.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698