Chromium Code Reviews| 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) |