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

Side by Side Diff: Source/web/PageScaleConstraintsSet.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rename browser zoom to page zoom Created 6 years, 11 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
« no previous file with comments | « Source/platform/LengthFunctions.cpp ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 { 138 {
139 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode && !nonUserScalableQuirkEnabled) 139 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode && !nonUserScalableQuirkEnabled)
140 return; 140 return;
141 141
142 const float oldInitialScale = m_pageDefinedConstraints.initialScale; 142 const float oldInitialScale = m_pageDefinedConstraints.initialScale;
143 if (!loadWithOverviewMode) { 143 if (!loadWithOverviewMode) {
144 bool resetInitialScale = false; 144 bool resetInitialScale = false;
145 if (description.zoom == -1) { 145 if (description.zoom == -1) {
146 if (description.maxWidth.isAuto() || description.maxWidth.type() == ExtendToZoom) 146 if (description.maxWidth.isAuto() || description.maxWidth.type() == ExtendToZoom)
147 resetInitialScale = true; 147 resetInitialScale = true;
148 if (useWideViewport || description.maxWidth == Length(100, ViewportP ercentageWidth)) 148 if (useWideViewport || description.maxWidth.type() == DeviceWidth)
149 resetInitialScale = true; 149 resetInitialScale = true;
150 } 150 }
151 if (resetInitialScale) 151 if (resetInitialScale)
152 m_pageDefinedConstraints.initialScale = 1.0f; 152 m_pageDefinedConstraints.initialScale = 1.0f;
153 } 153 }
154 154
155 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); 155 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width();
156 float adjustedLayoutSizeHeight = m_pageDefinedConstraints.layoutSize.height( ); 156 float adjustedLayoutSizeHeight = m_pageDefinedConstraints.layoutSize.height( );
157 float targetDensityDPIFactor = 1.0f; 157 float targetDensityDPIFactor = 1.0f;
158 158
159 if (supportTargetDensityDPI) { 159 if (supportTargetDensityDPI) {
160 targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(descrip tion, deviceScaleFactor); 160 targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(descrip tion, deviceScaleFactor);
161 if (m_pageDefinedConstraints.initialScale != -1) 161 if (m_pageDefinedConstraints.initialScale != -1)
162 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; 162 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor;
163 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; 163 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor;
164 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; 164 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor;
165 if (wideViewportQuirkEnabled && (!useWideViewport || description.maxWidt h == Length(100, ViewportPercentageWidth))) { 165 if (wideViewportQuirkEnabled && (!useWideViewport || description.maxWidt h.type() == DeviceWidth)) {
166 adjustedLayoutSizeWidth /= targetDensityDPIFactor; 166 adjustedLayoutSizeWidth /= targetDensityDPIFactor;
167 adjustedLayoutSizeHeight /= targetDensityDPIFactor; 167 adjustedLayoutSizeHeight /= targetDensityDPIFactor;
168 } 168 }
169 } 169 }
170 170
171 if (wideViewportQuirkEnabled) { 171 if (wideViewportQuirkEnabled) {
172 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f) { 172 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f) {
173 adjustedLayoutSizeWidth = layoutFallbackWidth; 173 adjustedLayoutSizeWidth = layoutFallbackWidth;
174 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, viewSize); 174 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, viewSize);
175 } else if (!useWideViewport) { 175 } else if (!useWideViewport) {
176 const float nonWideScale = description.zoom < 1 && !description.maxW idth.isViewportPercentage() ? -1 : oldInitialScale; 176 const float nonWideScale = description.zoom < 1 && description.maxWi dth.type() != DeviceWidth && description.maxWidth.type() != DeviceHeight ? -1 : oldInitialScale;
177 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, nonWideScale) / targetDensityDPIFactor; 177 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, nonWideScale) / targetDensityDPIFactor;
178 float newInitialScale = targetDensityDPIFactor; 178 float newInitialScale = targetDensityDPIFactor;
179 if (m_userAgentConstraints.initialScale != -1 && (description.maxWid th == Length(100, ViewportPercentageWidth) || ((description.maxWidth.isAuto() || description.maxWidth.type() == ExtendToZoom) && description.zoom == -1))) { 179 if (m_userAgentConstraints.initialScale != -1 && (description.maxWid th.type() == DeviceWidth || ((description.maxWidth.isAuto() || description.maxWi dth.type() == ExtendToZoom) && description.zoom == -1))) {
180 adjustedLayoutSizeWidth /= m_userAgentConstraints.initialScale; 180 adjustedLayoutSizeWidth /= m_userAgentConstraints.initialScale;
181 newInitialScale = m_userAgentConstraints.initialScale; 181 newInitialScale = m_userAgentConstraints.initialScale;
182 } 182 }
183 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, viewSize); 183 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, viewSize);
184 if (description.zoom < 1) { 184 if (description.zoom < 1) {
185 m_pageDefinedConstraints.initialScale = newInitialScale; 185 m_pageDefinedConstraints.initialScale = newInitialScale;
186 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pageDe finedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); 186 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pageDe finedConstraints.minimumScale, m_pageDefinedConstraints.initialScale);
187 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pageDe finedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); 187 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pageDe finedConstraints.maximumScale, m_pageDefinedConstraints.initialScale);
188 } 188 }
189 } 189 }
190 } 190 }
191 191
192 if (nonUserScalableQuirkEnabled && !description.userZoom) { 192 if (nonUserScalableQuirkEnabled && !description.userZoom) {
193 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; 193 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor;
194 m_pageDefinedConstraints.minimumScale = m_pageDefinedConstraints.initial Scale; 194 m_pageDefinedConstraints.minimumScale = m_pageDefinedConstraints.initial Scale;
195 m_pageDefinedConstraints.maximumScale = m_pageDefinedConstraints.initial Scale; 195 m_pageDefinedConstraints.maximumScale = m_pageDefinedConstraints.initial Scale;
196 if (description.maxWidth.isAuto() || description.maxWidth.type() == Exte ndToZoom || description.maxWidth == Length(100, ViewportPercentageWidth)) { 196 if (description.maxWidth.isAuto() || description.maxWidth.type() == Exte ndToZoom || description.maxWidth.type() == DeviceWidth) {
197 adjustedLayoutSizeWidth = viewSize.width() / targetDensityDPIFactor; 197 adjustedLayoutSizeWidth = viewSize.width() / targetDensityDPIFactor;
198 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, viewSize); 198 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, viewSize);
199 } 199 }
200 } 200 }
201 201
202 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); 202 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth);
203 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); 203 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight);
204 } 204 }
205 205
206 } // namespace WebCore 206 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/LengthFunctions.cpp ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698