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