| Index: Source/core/testing/Internals.cpp
|
| diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
|
| index 111e1fff839f2edd0a427a21dc15374fd0ab12e1..e2e59dc89b48809580fe92ece876d102ee41a925 100644
|
| --- a/Source/core/testing/Internals.cpp
|
| +++ b/Source/core/testing/Internals.cpp
|
| @@ -919,6 +919,35 @@ void Internals::setPagination(Document* document, const String& mode, int gap, i
|
| page->setPagination(pagination);
|
| }
|
|
|
| +static FloatSize convertToUserSpace(const FloatSize& deviceSize, float devicePixelRatio)
|
| +{
|
| + 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()));
|
| +}
|
| +
|
| String Internals::configurationForViewport(Document* document, float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight, ExceptionCode& ec)
|
| {
|
| if (!document || !document->page()) {
|
| @@ -932,9 +961,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)
|
|
|