OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 , m_constraintsDirty(false) | 42 , m_constraintsDirty(false) |
43 { | 43 { |
44 m_finalConstraints = defaultConstraints(); | 44 m_finalConstraints = defaultConstraints(); |
45 } | 45 } |
46 | 46 |
47 PageScaleConstraints PageScaleConstraintsSet::defaultConstraints() const | 47 PageScaleConstraints PageScaleConstraintsSet::defaultConstraints() const |
48 { | 48 { |
49 return PageScaleConstraints(-1, defaultMinimumScale, defaultMaximumScale); | 49 return PageScaleConstraints(-1, defaultMinimumScale, defaultMaximumScale); |
50 } | 50 } |
51 | 51 |
52 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportArgumen
ts& arguments, IntSize viewSize, int layoutFallbackWidth) | 52 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportArgumen
ts& arguments, IntSize viewSize) |
53 { | 53 { |
54 m_pageDefinedConstraints = arguments.resolve(viewSize, layoutFallbackWidth); | 54 m_pageDefinedConstraints = arguments.resolve(viewSize); |
55 | 55 |
56 m_constraintsDirty = true; | 56 m_constraintsDirty = true; |
57 } | 57 } |
58 | 58 |
59 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints
& userAgentConstraints) | 59 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints
& userAgentConstraints) |
60 { | 60 { |
61 m_userAgentConstraints = userAgentConstraints; | 61 m_userAgentConstraints = userAgentConstraints; |
62 m_constraintsDirty = true; | 62 m_constraintsDirty = true; |
63 } | 63 } |
64 | 64 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float
initialScale) | 117 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float
initialScale) |
118 { | 118 { |
119 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia
lScale; | 119 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia
lScale; |
120 } | 120 } |
121 | 121 |
122 void PageScaleConstraintsSet::adjustPageDefinedConstraintsForAndroidWebView(cons
t ViewportArguments& arguments, IntSize viewSize, int layoutFallbackWidth, float
deviceScaleFactor, bool useWideViewport, bool loadWithOverviewMode) | 122 void PageScaleConstraintsSet::adjustPageDefinedConstraintsForAndroidWebView(cons
t ViewportArguments& arguments, IntSize viewSize, int layoutFallbackWidth, float
deviceScaleFactor, bool useWideViewport, bool loadWithOverviewMode) |
123 { | 123 { |
124 float initialScale = m_pageDefinedConstraints.initialScale; | 124 float initialScale = m_pageDefinedConstraints.initialScale; |
125 if (arguments.zoom == -1 && !loadWithOverviewMode) { | 125 if (arguments.zoom == -1 && !loadWithOverviewMode) { |
126 if (arguments.width == -1 || (useWideViewport && arguments.width != View
portArguments::ValueDeviceWidth)) | 126 if (arguments.maxWidth == -1 || (useWideViewport && arguments.maxWidth !
= ViewportArguments::ValueDeviceWidth)) |
127 m_pageDefinedConstraints.initialScale = 1.0f; | 127 m_pageDefinedConstraints.initialScale = 1.0f; |
128 } | 128 } |
129 | 129 |
130 float targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(argum
ents, deviceScaleFactor); | 130 float targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(argum
ents, deviceScaleFactor); |
131 if (m_pageDefinedConstraints.initialScale != -1) | 131 if (m_pageDefinedConstraints.initialScale != -1) |
132 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; | 132 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; |
133 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; | 133 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; |
134 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; | 134 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; |
135 | 135 |
136 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); | 136 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); |
137 if (useWideViewport && arguments.width == -1 && arguments.zoom != 1.0f) | 137 if (useWideViewport && arguments.maxWidth == ViewportArguments::ValueExtendT
oZoom && arguments.zoom != 1.0f) |
138 adjustedLayoutSizeWidth = layoutFallbackWidth; | 138 adjustedLayoutSizeWidth = layoutFallbackWidth; |
139 else { | 139 else { |
140 if (!useWideViewport) | 140 if (!useWideViewport) |
141 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize,
initialScale); | 141 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize,
initialScale); |
142 if (!useWideViewport || arguments.width == -1 || arguments.width == View
portArguments::ValueDeviceWidth) | 142 if (!useWideViewport || arguments.maxWidth == ViewportArguments::ValueEx
tendToZoom || arguments.maxWidth == ViewportArguments::ValueDeviceWidth) |
143 adjustedLayoutSizeWidth /= targetDensityDPIFactor; | 143 adjustedLayoutSizeWidth /= targetDensityDPIFactor; |
144 } | 144 } |
145 | 145 |
146 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); | 146 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); |
147 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefinedCon
straints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); | 147 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefinedCon
straints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); |
148 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); | 148 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); |
149 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); | 149 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); |
150 } | 150 } |
151 | 151 |
152 } // namespace WebCore | 152 } // namespace WebCore |
OLD | NEW |