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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 else if (description.deprecatedTargetDensityDPI != ViewportDescription::Valu eAuto) | 116 else if (description.deprecatedTargetDensityDPI != ViewportDescription::Valu eAuto) |
117 targetDPI = description.deprecatedTargetDensityDPI; | 117 targetDPI = description.deprecatedTargetDensityDPI; |
118 return targetDPI > 0 ? 160.0f / targetDPI : 1.0f; | 118 return targetDPI > 0 ? 160.0f / targetDPI : 1.0f; |
119 } | 119 } |
120 | 120 |
121 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale) | 121 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale) |
122 { | 122 { |
123 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale; | 123 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale; |
124 } | 124 } |
125 | 125 |
126 void PageScaleConstraintsSet::adjustForAndroidWebViewQuirks(const ViewportDescri ption& description, IntSize viewSize, int layoutFallbackWidth, float deviceScale Factor, bool supportTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWid eViewport, bool loadWithOverviewMode) | 126 void PageScaleConstraintsSet::adjustForAndroidWebViewQuirks(const ViewportDescri ption& description, IntSize viewSize, int layoutFallbackWidth, float deviceScale Factor, bool supportTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWid eViewport, bool loadWithOverviewMode, bool nonUserScalableQuirkEnabled) |
127 { | 127 { |
128 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode) | 128 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode && !nonUserScalableQuirkEnabled) |
129 return; | 129 return; |
130 | 130 |
131 const float oldInitialScale = m_pageDefinedConstraints.initialScale; | 131 const float oldInitialScale = m_pageDefinedConstraints.initialScale; |
132 if (!loadWithOverviewMode) { | 132 if (!loadWithOverviewMode) { |
133 bool resetInitialScale = false; | 133 bool resetInitialScale = false; |
134 if (description.zoom == -1) { | 134 if (description.zoom == -1) { |
135 if (description.maxWidth.isAuto()) | 135 if (description.maxWidth.isAuto()) |
136 resetInitialScale = true; | 136 resetInitialScale = true; |
137 if (useWideViewport || !description.maxWidth.isFixed()) | 137 if (useWideViewport || !description.maxWidth.isFixed()) |
138 resetInitialScale = true; | 138 resetInitialScale = true; |
139 } | 139 } |
140 if (resetInitialScale) | 140 if (resetInitialScale) |
141 m_pageDefinedConstraints.initialScale = 1.0f; | 141 m_pageDefinedConstraints.initialScale = 1.0f; |
142 } | 142 } |
143 if (nonUserScalableQuirkEnabled && !description.userZoom) { | |
144 m_pageDefinedConstraints.initialScale = 1.0f; | |
145 m_pageDefinedConstraints.minimumScale = 1.0f; | |
146 m_pageDefinedConstraints.maximumScale = 1.0f; | |
147 } | |
143 | 148 |
144 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); | 149 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); |
145 float targetDensityDPIFactor = 1.0f; | 150 float targetDensityDPIFactor = 1.0f; |
146 | 151 |
147 if (supportTargetDensityDPI) { | 152 if (supportTargetDensityDPI) { |
148 targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(descrip tion, deviceScaleFactor); | 153 targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(descrip tion, deviceScaleFactor); |
149 if (m_pageDefinedConstraints.initialScale != -1) | 154 if (m_pageDefinedConstraints.initialScale != -1) |
150 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; | 155 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; |
151 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; | 156 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; |
152 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; | 157 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; |
153 if (wideViewportQuirkEnabled && (!useWideViewport || !description.maxWid th.isFixed())) | 158 if (wideViewportQuirkEnabled && (!useWideViewport || !description.maxWid th.isFixed())) |
154 adjustedLayoutSizeWidth /= targetDensityDPIFactor; | 159 adjustedLayoutSizeWidth /= targetDensityDPIFactor; |
155 } | 160 } |
156 | 161 |
157 if (wideViewportQuirkEnabled) { | 162 if (wideViewportQuirkEnabled) { |
158 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f) { | 163 const bool nonUserScalable = nonUserScalableQuirkEnabled && !description .userZoom; |
164 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f && !nonUserScalable) { | |
159 adjustedLayoutSizeWidth = layoutFallbackWidth; | 165 adjustedLayoutSizeWidth = layoutFallbackWidth; |
160 } else if (!useWideViewport) { | 166 } else if (!useWideViewport || (nonUserScalable && (description.maxWidth .isAuto() || description.maxWidth.type() == ExtendToZoom || !description.maxWidt h.isFixed()))) { |
161 const float nonWideScale = description.zoom < 1 && !description.maxW idth.isViewportPercentage() ? -1 : oldInitialScale; | 167 const float nonWideScale = nonUserScalable || (description.zoom < 1 && !description.maxWidth.isViewportPercentage()) ? -1 : oldInitialScale; |
162 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, nonWideScale) / targetDensityDPIFactor; | 168 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, nonWideScale) / targetDensityDPIFactor; |
163 if (description.zoom < 1) { | 169 if (nonUserScalable || description.zoom < 1) { |
164 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; | 170 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; |
165 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pageDe finedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); | 171 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pageDe finedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); |
166 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pageDe finedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); | 172 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pageDe finedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); |
167 } | 173 } |
168 } | 174 } |
169 } | 175 } |
170 | 176 |
aelias_OOO_until_Jul13
2013/11/01 23:58:00
The logic inside wideViewportQuirkEnabled is too t
mnaganov (inactive)
2013/11/05 11:01:38
OK, thanks for the suggestion! Rewritten.
| |
171 if (oldInitialScale != m_pageDefinedConstraints.initialScale && m_pageDefine dConstraints.initialScale != -1) | 177 if (oldInitialScale != m_pageDefinedConstraints.initialScale && m_pageDefine dConstraints.initialScale != -1) |
172 setNeedsReset(true); | 178 setNeedsReset(true); |
173 | 179 |
174 if (adjustedLayoutSizeWidth != m_pageDefinedConstraints.layoutSize.width()) { | 180 if (adjustedLayoutSizeWidth != m_pageDefinedConstraints.layoutSize.width()) { |
175 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); | 181 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); |
176 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefine dConstraints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); | 182 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefine dConstraints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); |
177 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); | 183 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); |
178 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); | 184 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); |
179 } | 185 } |
180 } | 186 } |
181 | 187 |
182 } // namespace WebCore | 188 } // namespace WebCore |
OLD | NEW |