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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 else { 899 else {
900 ec = SYNTAX_ERR; 900 ec = SYNTAX_ERR;
901 return; 901 return;
902 } 902 }
903 903
904 pagination.gap = gap; 904 pagination.gap = gap;
905 pagination.pageLength = pageLength; 905 pagination.pageLength = pageLength;
906 page->setPagination(pagination); 906 page->setPagination(pagination);
907 } 907 }
908 908
909 static FloatSize convertToUserSpace(const FloatSize& deviceSize, float devicePix elRatio)
abarth-chromium 2013/05/20 18:22:25 What is "user space" ?
910 {
911 FloatSize result = deviceSize;
912 if (devicePixelRatio != 1)
913 result.scale(1 / devicePixelRatio);
914 return result;
915 }
916
917 static ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, float devicePixelRatio, IntSize visibleViewport)
918 {
919 FloatSize initialViewportSize = convertToUserSpace(visibleViewport, devicePi xelRatio);
920 FloatSize deviceSize = convertToUserSpace(FloatSize(deviceWidth, deviceHeigh t), devicePixelRatio);
921
922 return args.resolve(initialViewportSize, deviceSize, desktopWidth);
923 }
924
925 static float computeMinimumScaleFactorForContentContained(const ViewportAttribut es& result, const IntSize& visibleViewport, const IntSize& contentsSize)
926 {
927 FloatSize viewportSize(visibleViewport);
928 return max<float>(result.minimumScale, max(viewportSize.width() / contentsSi ze.width(), viewportSize.height() / contentsSize.height()));
929 }
930
931 static void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport, float devicePixelRatio)
932 {
933 FloatSize viewportSize = convertToUserSpace(visibleViewport, devicePixelRati o);
934
935 result.minimumScale = max<float>(result.minimumScale, max(viewportSize.width () / result.layoutSize.width(), viewportSize.height() / result.layoutSize.height ()));
936 }
abarth-chromium 2013/05/20 18:22:25 I don't understand why we need all of this code in
937
909 String Internals::configurationForViewport(Document* document, float devicePixel Ratio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeigh t, ExceptionCode& ec) 938 String Internals::configurationForViewport(Document* document, float devicePixel Ratio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeigh t, ExceptionCode& ec)
910 { 939 {
911 if (!document || !document->page()) { 940 if (!document || !document->page()) {
912 ec = INVALID_ACCESS_ERR; 941 ec = INVALID_ACCESS_ERR;
913 return String(); 942 return String();
914 } 943 }
915 Page* page = document->page(); 944 Page* page = document->page();
916 945
917 const int defaultLayoutWidthForNonMobilePages = 980; 946 const int defaultLayoutWidthForNonMobilePages = 980;
918 947
919 ViewportArguments arguments = page->viewportArguments(); 948 ViewportArguments arguments = page->viewportArguments();
920 ViewportAttributes attributes = computeViewportAttributes(arguments, default LayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSi ze(availableWidth, availableHeight)); 949 ViewportAttributes attributes = computeViewportAttributes(arguments, default LayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSi ze(availableWidth, availableHeight));
921 restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight), devicePixelRatio); 950 restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth, availableHeight), devicePixelRatio);
922 restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
923 951
924 return "viewport size " + String::number(attributes.layoutSize.width()) + "x " + String::number(attributes.layoutSize.height()) + " scale " + String::number( attributes.initialScale) + " with limits [" + String::number(attributes.minimumS cale) + ", " + String::number(attributes.maximumScale) + "] and userScalable " + (attributes.userScalable ? "true" : "false"); 952 return "viewport size " + String::number(attributes.layoutSize.width()) + "x " + String::number(attributes.layoutSize.height()) + " scale " + String::number( attributes.initialScale) + " with limits [" + String::number(attributes.minimumS cale) + ", " + String::number(attributes.maximumScale) + "] and userScalable " + (arguments.userZoom ? "true" : "false");
925 } 953 }
926 954
927 bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec) 955 bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec)
928 { 956 {
929 if (!textField) { 957 if (!textField) {
930 ec = INVALID_ACCESS_ERR; 958 ec = INVALID_ACCESS_ERR;
931 return false; 959 return false;
932 } 960 }
933 961
934 if (HTMLInputElement* inputElement = textField->toInputElement()) 962 if (HTMLInputElement* inputElement = textField->toInputElement())
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 1966
1939 RenderObject* renderer = select->renderer(); 1967 RenderObject* renderer = select->renderer();
1940 if (!renderer->isMenuList()) 1968 if (!renderer->isMenuList())
1941 return false; 1969 return false;
1942 1970
1943 RenderMenuList* menuList = toRenderMenuList(renderer); 1971 RenderMenuList* menuList = toRenderMenuList(renderer);
1944 return menuList->popupIsVisible(); 1972 return menuList->popupIsVisible();
1945 } 1973 }
1946 1974
1947 } 1975 }
OLDNEW
« 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