OLD | NEW |
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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 else { | 912 else { |
913 ec = SYNTAX_ERR; | 913 ec = SYNTAX_ERR; |
914 return; | 914 return; |
915 } | 915 } |
916 | 916 |
917 pagination.gap = gap; | 917 pagination.gap = gap; |
918 pagination.pageLength = pageLength; | 918 pagination.pageLength = pageLength; |
919 page->setPagination(pagination); | 919 page->setPagination(pagination); |
920 } | 920 } |
921 | 921 |
| 922 static FloatSize convertToUserSpace(const FloatSize& deviceSize, float devicePix
elRatio) |
| 923 { |
| 924 FloatSize result = deviceSize; |
| 925 if (devicePixelRatio != 1) |
| 926 result.scale(1 / devicePixelRatio); |
| 927 return result; |
| 928 } |
| 929 |
| 930 static ViewportAttributes computeViewportAttributes(ViewportArguments args, int
desktopWidth, int deviceWidth, int deviceHeight, float devicePixelRatio, IntSize
visibleViewport) |
| 931 { |
| 932 FloatSize initialViewportSize = convertToUserSpace(visibleViewport, devicePi
xelRatio); |
| 933 FloatSize deviceSize = convertToUserSpace(FloatSize(deviceWidth, deviceHeigh
t), devicePixelRatio); |
| 934 |
| 935 return args.resolve(initialViewportSize, deviceSize, desktopWidth); |
| 936 } |
| 937 |
| 938 static float computeMinimumScaleFactorForContentContained(const ViewportAttribut
es& result, const IntSize& visibleViewport, const IntSize& contentsSize) |
| 939 { |
| 940 FloatSize viewportSize(visibleViewport); |
| 941 return max<float>(result.minimumScale, max(viewportSize.width() / contentsSi
ze.width(), viewportSize.height() / contentsSize.height())); |
| 942 } |
| 943 |
| 944 static void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result,
IntSize visibleViewport, float devicePixelRatio) |
| 945 { |
| 946 FloatSize viewportSize = convertToUserSpace(visibleViewport, devicePixelRati
o); |
| 947 |
| 948 result.minimumScale = max<float>(result.minimumScale, max(viewportSize.width
() / result.layoutSize.width(), viewportSize.height() / result.layoutSize.height
())); |
| 949 } |
| 950 |
922 String Internals::configurationForViewport(Document* document, float devicePixel
Ratio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeigh
t, ExceptionCode& ec) | 951 String Internals::configurationForViewport(Document* document, float devicePixel
Ratio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeigh
t, ExceptionCode& ec) |
923 { | 952 { |
924 if (!document || !document->page()) { | 953 if (!document || !document->page()) { |
925 ec = INVALID_ACCESS_ERR; | 954 ec = INVALID_ACCESS_ERR; |
926 return String(); | 955 return String(); |
927 } | 956 } |
928 Page* page = document->page(); | 957 Page* page = document->page(); |
929 | 958 |
930 const int defaultLayoutWidthForNonMobilePages = 980; | 959 const int defaultLayoutWidthForNonMobilePages = 980; |
931 | 960 |
932 ViewportArguments arguments = page->viewportArguments(); | 961 ViewportArguments arguments = page->viewportArguments(); |
933 ViewportAttributes attributes = computeViewportAttributes(arguments, default
LayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSi
ze(availableWidth, availableHeight)); | 962 ViewportAttributes attributes = computeViewportAttributes(arguments, default
LayoutWidthForNonMobilePages, deviceWidth, deviceHeight, devicePixelRatio, IntSi
ze(availableWidth, availableHeight)); |
934 restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth,
availableHeight), devicePixelRatio); | 963 restrictMinimumScaleFactorToViewportSize(attributes, IntSize(availableWidth,
availableHeight), devicePixelRatio); |
935 restrictScaleFactorToInitialScaleIfNotUserScalable(attributes); | |
936 | 964 |
937 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"); | 965 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"); |
938 } | 966 } |
939 | 967 |
940 bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec) | 968 bool Internals::wasLastChangeUserEdit(Element* textField, ExceptionCode& ec) |
941 { | 969 { |
942 if (!textField) { | 970 if (!textField) { |
943 ec = INVALID_ACCESS_ERR; | 971 ec = INVALID_ACCESS_ERR; |
944 return false; | 972 return false; |
945 } | 973 } |
946 | 974 |
947 if (HTMLInputElement* inputElement = textField->toInputElement()) | 975 if (HTMLInputElement* inputElement = textField->toInputElement()) |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 | 1976 |
1949 RenderObject* renderer = select->renderer(); | 1977 RenderObject* renderer = select->renderer(); |
1950 if (!renderer->isMenuList()) | 1978 if (!renderer->isMenuList()) |
1951 return false; | 1979 return false; |
1952 | 1980 |
1953 RenderMenuList* menuList = toRenderMenuList(renderer); | 1981 RenderMenuList* menuList = toRenderMenuList(renderer); |
1954 return menuList->popupIsVisible(); | 1982 return menuList->popupIsVisible(); |
1955 } | 1983 } |
1956 | 1984 |
1957 } | 1985 } |
OLD | NEW |