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

Side by Side Diff: third_party/WebKit/Source/core/dom/ViewportDescription.cpp

Issue 2461143002: Reconstrain zoom value to the [min-zoom, max-zoom] range before it used (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights
7 * reserved. 7 * reserved.
8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // 8. Resolve height value. 195 // 8. Resolve height value.
196 if (resultHeight == ViewportDescription::ValueAuto) { 196 if (resultHeight == ViewportDescription::ValueAuto) {
197 if (!initialViewportSize.width()) 197 if (!initialViewportSize.width())
198 resultHeight = initialViewportSize.height(); 198 resultHeight = initialViewportSize.height();
199 else 199 else
200 resultHeight = resultWidth * initialViewportSize.height() / 200 resultHeight = resultWidth * initialViewportSize.height() /
201 initialViewportSize.width(); 201 initialViewportSize.width();
202 } 202 }
203 203
204 // Resolve initial-scale value. 204 // 9. Resolve initial-scale value.
rune 2016/10/31 14:45:03 The numbering used to correspond with the numberin
bokan 2016/10/31 14:47:55 In that case, since the numbers no longer correspo
205 if (resultZoom == ViewportDescription::ValueAuto) { 205 if (resultZoom == ViewportDescription::ValueAuto) {
206 if (resultWidth != ViewportDescription::ValueAuto && resultWidth > 0) 206 if (resultWidth != ViewportDescription::ValueAuto && resultWidth > 0)
207 resultZoom = initialViewportSize.width() / resultWidth; 207 resultZoom = initialViewportSize.width() / resultWidth;
208 if (resultHeight != ViewportDescription::ValueAuto && resultHeight > 0) { 208 if (resultHeight != ViewportDescription::ValueAuto && resultHeight > 0) {
209 // if 'auto', the initial-scale will be negative here and thus ignored. 209 // if 'auto', the initial-scale will be negative here and thus ignored.
210 resultZoom = std::max<float>(resultZoom, 210 resultZoom = std::max<float>(resultZoom,
211 initialViewportSize.height() / resultHeight); 211 initialViewportSize.height() / resultHeight);
212 } 212 }
213 } 213 }
214 214
215 // 10. Reconstrain zoom value to the [min-zoom, max-zoom] range. It will reset
216 // below, if it is ValueAuto.
217 resultZoom = compareIgnoringAuto(
218 resultMinZoom, compareIgnoringAuto(resultMaxZoom, resultZoom, std::min),
219 std::max);
rune 2016/10/31 14:45:03 This can be moved inside the block above, right?
220
215 // If user-scalable = no, lock the min/max scale to the computed initial 221 // If user-scalable = no, lock the min/max scale to the computed initial
216 // scale. 222 // scale.
217 if (!resultUserZoom) 223 if (!resultUserZoom)
218 resultMinZoom = resultMaxZoom = resultZoom; 224 resultMinZoom = resultMaxZoom = resultZoom;
219 225
220 // Only set initialScale to a value if it was explicitly set. 226 // Only set initialScale to a value if it was explicitly set.
221 if (zoom == ViewportDescription::ValueAuto) 227 if (zoom == ViewportDescription::ValueAuto)
222 resultZoom = ViewportDescription::ValueAuto; 228 resultZoom = ViewportDescription::ValueAuto;
223 229
224 PageScaleConstraints result; 230 PageScaleConstraints result;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 metaTagTypeHistogram.count(MobileOptimizedMeta); 298 metaTagTypeHistogram.count(MobileOptimizedMeta);
293 } 299 }
294 #endif 300 #endif
295 } 301 }
296 302
297 bool ViewportDescription::matchesHeuristicsForGpuRasterization() const { 303 bool ViewportDescription::matchesHeuristicsForGpuRasterization() const {
298 return isSpecifiedByAuthor(); 304 return isSpecifiedByAuthor();
299 } 305 }
300 306
301 } // namespace blink 307 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698