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

Side by Side Diff: Source/core/dom/ViewportArguments.cpp

Issue 23742003: Use css-device-adapt constraining for legacy viewport tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review issue: one assignent per line/statement Created 7 years, 3 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/core/dom/ViewportArguments.h ('k') | Source/core/page/PageScaleConstraintsSet.h » ('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) 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 reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return value2; 43 return value2;
44 44
45 if (value2 == ViewportArguments::ValueAuto) 45 if (value2 == ViewportArguments::ValueAuto)
46 return value1; 46 return value1;
47 47
48 return compare(value1, value2); 48 return compare(value1, value2);
49 } 49 }
50 50
51 static inline float clampLengthValue(float value) 51 static inline float clampLengthValue(float value)
52 { 52 {
53 ASSERT(value != ViewportArguments::ValueDeviceWidth);
54 ASSERT(value != ViewportArguments::ValueDeviceHeight);
55
56 // Limits as defined in the css-device-adapt spec. 53 // Limits as defined in the css-device-adapt spec.
57 if (value != ViewportArguments::ValueAuto) 54 if (value != ViewportArguments::ValueAuto)
58 return min(float(10000), max(value, float(1))); 55 return min(float(10000), max(value, float(1)));
59 return value; 56 return value;
60 } 57 }
61 58
62 static inline float clampScaleValue(float value) 59 static inline float clampScaleValue(float value)
63 { 60 {
64 ASSERT(value != ViewportArguments::ValueDeviceWidth);
65 ASSERT(value != ViewportArguments::ValueDeviceHeight);
66
67 // Limits as defined in the css-device-adapt spec. 61 // Limits as defined in the css-device-adapt spec.
68 if (value != ViewportArguments::ValueAuto) 62 if (value != ViewportArguments::ValueAuto)
69 return min(float(10), max(value, float(0.1))); 63 return min(float(10), max(value, float(0.1)));
70 return value; 64 return value;
71 } 65 }
72 66
73 float ViewportArguments::resolveViewportLength(const Length& length, const Float Size& initialViewportSize, Direction direction) 67 float ViewportArguments::resolveViewportLength(const Length& length, const Float Size& initialViewportSize, Direction direction)
74 { 68 {
75 if (length.isAuto()) 69 if (length.isAuto())
76 return ViewportArguments::ValueAuto; 70 return ViewportArguments::ValueAuto;
(...skipping 13 matching lines...) Expand all
90 if (length.type() == ViewportPercentageMin) 84 if (length.type() == ViewportPercentageMin)
91 return min(initialViewportSize.width(), initialViewportSize.height()) * length.viewportPercentageLength() / 100.0f; 85 return min(initialViewportSize.width(), initialViewportSize.height()) * length.viewportPercentageLength() / 100.0f;
92 86
93 if (length.type() == ViewportPercentageMax) 87 if (length.type() == ViewportPercentageMax)
94 return max(initialViewportSize.width(), initialViewportSize.height()) * length.viewportPercentageLength() / 100.0f; 88 return max(initialViewportSize.width(), initialViewportSize.height()) * length.viewportPercentageLength() / 100.0f;
95 89
96 ASSERT_NOT_REACHED(); 90 ASSERT_NOT_REACHED();
97 return ViewportArguments::ValueAuto; 91 return ViewportArguments::ValueAuto;
98 } 92 }
99 93
100 PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport Size, int defaultWidth) const 94 PageScaleConstraints ViewportArguments::resolve(const FloatSize& initialViewport Size) const
101 { 95 {
102 float resultWidth = width; 96 float resultWidth = ValueAuto;
103 float resultHeight = height; 97 float resultMaxWidth = resolveViewportLength(maxWidth, initialViewportSize, Horizontal);
98 float resultMinWidth = resolveViewportLength(minWidth, initialViewportSize, Horizontal);
99 float resultHeight = ValueAuto;
100 float resultMaxHeight = resolveViewportLength(maxHeight, initialViewportSize , Vertical);
101 float resultMinHeight = resolveViewportLength(minHeight, initialViewportSize , Vertical);
102
104 float resultZoom = zoom; 103 float resultZoom = zoom;
105 float resultMinZoom = minZoom; 104 float resultMinZoom = minZoom;
106 float resultMaxZoom = maxZoom; 105 float resultMaxZoom = maxZoom;
107 float resultUserZoom = userZoom; 106 float resultUserZoom = userZoom;
108 107
109 if (type == ViewportArguments::CSSDeviceAdaptation) { 108 // 1. Resolve min-zoom and max-zoom values.
109 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Viewpo rtArguments::ValueAuto)
110 resultMaxZoom = max(resultMinZoom, resultMaxZoom);
110 111
111 float resultMaxWidth = resolveViewportLength(maxWidth, initialViewportSi ze, Horizontal); 112 // 2. Constrain zoom value to the [min-zoom, max-zoom] range.
112 float resultMinWidth = resolveViewportLength(minWidth, initialViewportSi ze, Horizontal); 113 if (resultZoom != ViewportArguments::ValueAuto)
113 float resultMaxHeight = resolveViewportLength(maxHeight, initialViewport Size, Vertical); 114 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(resu ltMaxZoom, resultZoom, min), max);
114 float resultMinHeight = resolveViewportLength(minHeight, initialViewport Size, Vertical);
115 115
116 // 1. Resolve min-zoom and max-zoom values. 116 float extendZoom = compareIgnoringAuto(resultZoom, resultMaxZoom, min);
117 if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != Vi ewportArguments::ValueAuto)
118 resultMaxZoom = max(resultMinZoom, resultMaxZoom);
119 117
120 // 2. Constrain zoom value to the [min-zoom, max-zoom] range. 118 // 3. Resolve non-"auto" lengths to pixel lengths.
121 if (resultZoom != ViewportArguments::ValueAuto) 119 if (extendZoom == ViewportArguments::ValueAuto) {
122 resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto( resultMaxZoom, resultZoom, min), max); 120 if (resultMaxWidth == ViewportArguments::ValueExtendToZoom)
121 resultMaxWidth = ViewportArguments::ValueAuto;
123 122
124 float extendZoom = compareIgnoringAuto(resultZoom, resultMaxZoom, min); 123 if (resultMaxHeight == ViewportArguments::ValueExtendToZoom)
124 resultMaxHeight = ViewportArguments::ValueAuto;
125 125
126 if (extendZoom == ViewportArguments::ValueAuto) { 126 if (resultMinWidth == ViewportArguments::ValueExtendToZoom)
127 if (resultMaxWidth == ViewportArguments::ValueExtendToZoom) 127 resultMinWidth = resultMaxWidth;
128 resultMaxWidth = ViewportArguments::ValueAuto;
129 128
130 if (resultMaxHeight == ViewportArguments::ValueExtendToZoom) 129 if (resultMinHeight == ViewportArguments::ValueExtendToZoom)
131 resultMaxHeight = ViewportArguments::ValueAuto; 130 resultMinHeight = resultMaxHeight;
131 } else {
132 float extendWidth = initialViewportSize.width() / extendZoom;
133 float extendHeight = initialViewportSize.height() / extendZoom;
132 134
133 if (resultMinWidth == ViewportArguments::ValueExtendToZoom) 135 if (resultMaxWidth == ViewportArguments::ValueExtendToZoom)
134 resultMinWidth = resultMaxWidth; 136 resultMaxWidth = extendWidth;
135 137
136 if (resultMinHeight == ViewportArguments::ValueExtendToZoom) 138 if (resultMaxHeight == ViewportArguments::ValueExtendToZoom)
137 resultMinHeight = resultMaxHeight; 139 resultMaxHeight = extendHeight;
138 } else {
139 float extendWidth = initialViewportSize.width() / extendZoom;
140 float extendHeight = initialViewportSize.height() / extendZoom;
141 140
142 if (resultMaxWidth == ViewportArguments::ValueExtendToZoom) 141 if (resultMinWidth == ViewportArguments::ValueExtendToZoom)
143 resultMaxWidth = extendWidth; 142 resultMinWidth = compareIgnoringAuto(extendWidth, resultMaxWidth, ma x);
144 143
145 if (resultMaxHeight == ViewportArguments::ValueExtendToZoom) 144 if (resultMinHeight == ViewportArguments::ValueExtendToZoom)
146 resultMaxHeight = extendHeight; 145 resultMinHeight = compareIgnoringAuto(extendHeight, resultMaxHeight, max);
147
148 if (resultMinWidth == ViewportArguments::ValueExtendToZoom)
149 resultMinWidth = compareIgnoringAuto(extendWidth, resultMaxWidth , max);
150
151 if (resultMinHeight == ViewportArguments::ValueExtendToZoom)
152 resultMinHeight = compareIgnoringAuto(extendHeight, resultMaxHei ght, max);
153 }
154
155 // 4. Resolve initial width from min/max descriptors.
156 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
157 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAut o(resultMaxWidth, initialViewportSize.width(), min), max);
158
159 // 5. Resolve initial height from min/max descriptors.
160 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight ! = ViewportArguments::ValueAuto)
161 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringA uto(resultMaxHeight, initialViewportSize.height(), min), max);
162
163 // 6-7. Resolve width value.
164 if (resultWidth == ViewportArguments::ValueAuto) {
165 if (resultHeight == ViewportArguments::ValueAuto || !initialViewport Size.height())
166 resultWidth = initialViewportSize.width();
167 else
168 resultWidth = resultHeight * (initialViewportSize.width() / init ialViewportSize.height());
169 }
170
171 // 8. Resolve height value.
172 if (resultHeight == ViewportArguments::ValueAuto) {
173 if (!initialViewportSize.width())
174 resultHeight = initialViewportSize.height();
175 else
176 resultHeight = resultWidth * initialViewportSize.height() / init ialViewportSize.width();
177 }
178
179 PageScaleConstraints result;
180 result.minimumScale = resultMinZoom;
181 result.maximumScale = resultMaxZoom;
182 result.initialScale = resultZoom;
183 result.layoutSize.setWidth(resultWidth);
184 result.layoutSize.setHeight(resultHeight);
185 return result;
186 } 146 }
187 147
188 switch (static_cast<int>(resultWidth)) { 148 // 4. Resolve initial width from min/max descriptors.
189 case ViewportArguments::ValueDeviceWidth: 149 if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != View portArguments::ValueAuto)
190 resultWidth = initialViewportSize.width(); 150 resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(re sultMaxWidth, initialViewportSize.width(), min), max);
191 break; 151
192 case ViewportArguments::ValueDeviceHeight: 152 // 5. Resolve initial height from min/max descriptors.
193 resultWidth = initialViewportSize.height(); 153 if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != Vi ewportArguments::ValueAuto)
194 break; 154 resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto( resultMaxHeight, initialViewportSize.height(), min), max);
155
156 // 6-7. Resolve width value.
157 if (resultWidth == ViewportArguments::ValueAuto) {
158 if (resultHeight == ViewportArguments::ValueAuto || !initialViewportSize .height())
159 resultWidth = initialViewportSize.width();
160 else
161 resultWidth = resultHeight * (initialViewportSize.width() / initialV iewportSize.height());
195 } 162 }
196 163
197 switch (static_cast<int>(resultHeight)) { 164 // 8. Resolve height value.
198 case ViewportArguments::ValueDeviceWidth: 165 if (resultHeight == ViewportArguments::ValueAuto) {
199 resultHeight = initialViewportSize.width(); 166 if (!initialViewportSize.width())
200 break; 167 resultHeight = initialViewportSize.height();
201 case ViewportArguments::ValueDeviceHeight: 168 else
202 resultHeight = initialViewportSize.height(); 169 resultHeight = resultWidth * initialViewportSize.height() / initialV iewportSize.width();
203 break;
204 } 170 }
205 171
206 if (type != ViewportArguments::Implicit) {
207 // Clamp values to a valid range, but not for @viewport since is
208 // not mandated by the specification.
209 resultWidth = clampLengthValue(resultWidth);
210 resultHeight = clampLengthValue(resultHeight);
211 resultZoom = clampScaleValue(resultZoom);
212 resultMinZoom = clampScaleValue(resultMinZoom);
213 resultMaxZoom = clampScaleValue(resultMaxZoom);
214 }
215
216 PageScaleConstraints result;
217
218 // Resolve minimum-scale and maximum-scale values according to spec.
219 if (resultMinZoom == ViewportArguments::ValueAuto)
220 result.minimumScale = float(0.25);
221 else
222 result.minimumScale = resultMinZoom;
223
224 if (resultMaxZoom == ViewportArguments::ValueAuto) {
225 result.maximumScale = float(5.0);
226 result.minimumScale = min(float(5.0), result.minimumScale);
227 } else
228 result.maximumScale = resultMaxZoom;
229 result.maximumScale = max(result.minimumScale, result.maximumScale);
230
231 // Resolve initial-scale value. 172 // Resolve initial-scale value.
232 result.initialScale = resultZoom;
233 if (resultZoom == ViewportArguments::ValueAuto) { 173 if (resultZoom == ViewportArguments::ValueAuto) {
234 result.initialScale = initialViewportSize.width() / defaultWidth;
235 if (resultWidth != ViewportArguments::ValueAuto && resultWidth > 0) 174 if (resultWidth != ViewportArguments::ValueAuto && resultWidth > 0)
236 result.initialScale = initialViewportSize.width() / resultWidth; 175 resultZoom = initialViewportSize.width() / resultWidth;
237 if (resultHeight != ViewportArguments::ValueAuto && resultHeight > 0) { 176 if (resultHeight != ViewportArguments::ValueAuto && resultHeight > 0) {
238 // if 'auto', the initial-scale will be negative here and thus ignor ed. 177 // if 'auto', the initial-scale will be negative here and thus ignor ed.
239 result.initialScale = max<float>(result.initialScale, initialViewpor tSize.height() / resultHeight); 178 resultZoom = max<float>(resultZoom, initialViewportSize.height() / r esultHeight);
240 } 179 }
241 } 180 }
242 181
243 // Constrain initial-scale value to minimum-scale/maximum-scale range.
244 result.initialScale = min(result.maximumScale, max(result.minimumScale, resu lt.initialScale));
245
246 // Resolve width value.
247 if (resultWidth == ViewportArguments::ValueAuto) {
248 if (resultZoom == ViewportArguments::ValueAuto)
249 resultWidth = defaultWidth;
250 else if (resultHeight != ViewportArguments::ValueAuto)
251 resultWidth = resultHeight * (initialViewportSize.width() / initialV iewportSize.height());
252 else
253 resultWidth = initialViewportSize.width() / result.initialScale;
254 }
255
256 // Resolve height value.
257 if (resultHeight == ViewportArguments::ValueAuto)
258 resultHeight = resultWidth * (initialViewportSize.height() / initialView portSize.width());
259
260 if (type == ViewportArguments::ViewportMeta) {
261 // Extend width and height to fill the visual viewport for the resolved initial-scale.
262 resultWidth = max<float>(resultWidth, initialViewportSize.width() / resu lt.initialScale);
263 resultHeight = max<float>(resultHeight, initialViewportSize.height() / r esult.initialScale);
264 }
265
266 result.layoutSize.setWidth(resultWidth);
267 result.layoutSize.setHeight(resultHeight);
268
269 // If user-scalable = no, lock the min/max scale to the computed initial 182 // If user-scalable = no, lock the min/max scale to the computed initial
270 // scale. 183 // scale.
271 if (!resultUserZoom) 184 if (!resultUserZoom)
272 result.maximumScale = result.minimumScale = result.initialScale; 185 resultMinZoom = resultMaxZoom = resultZoom;
273 186
274 // Only set initialScale to a value if it was explicitly set. 187 // Only set initialScale to a value if it was explicitly set.
275 if (resultZoom == ViewportArguments::ValueAuto) 188 if (zoom == ViewportArguments::ValueAuto)
276 result.initialScale = ViewportArguments::ValueAuto; 189 resultZoom = ViewportArguments::ValueAuto;
277 190
191 PageScaleConstraints result;
192 result.minimumScale = resultMinZoom;
193 result.maximumScale = resultMaxZoom;
194 result.initialScale = resultZoom;
195 result.layoutSize.setWidth(resultWidth);
196 result.layoutSize.setHeight(resultHeight);
278 return result; 197 return result;
279 } 198 }
280 199
281 static float numericPrefix(const String& keyString, const String& valueString, D ocument* document, bool* ok = 0) 200 static float numericPrefix(const String& keyString, const String& valueString, D ocument* document, bool* ok = 0)
282 { 201 {
283 size_t parsedLength; 202 size_t parsedLength;
284 float value; 203 float value;
285 if (valueString.is8Bit()) 204 if (valueString.is8Bit())
286 value = charactersToFloat(valueString.characters8(), valueString.length( ), parsedLength); 205 value = charactersToFloat(valueString.characters8(), valueString.length( ), parsedLength);
287 else 206 else
288 value = charactersToFloat(valueString.characters16(), valueString.length (), parsedLength); 207 value = charactersToFloat(valueString.characters16(), valueString.length (), parsedLength);
289 if (!parsedLength) { 208 if (!parsedLength) {
290 reportViewportWarning(document, UnrecognizedViewportArgumentValueError, valueString, keyString); 209 reportViewportWarning(document, UnrecognizedViewportArgumentValueError, valueString, keyString);
291 if (ok) 210 if (ok)
292 *ok = false; 211 *ok = false;
293 return 0; 212 return 0;
294 } 213 }
295 if (parsedLength < valueString.length()) 214 if (parsedLength < valueString.length())
296 reportViewportWarning(document, TruncatedViewportArgumentValueError, val ueString, keyString); 215 reportViewportWarning(document, TruncatedViewportArgumentValueError, val ueString, keyString);
297 if (ok) 216 if (ok)
298 *ok = true; 217 *ok = true;
299 return value; 218 return value;
300 } 219 }
301 220
302 static float findSizeValue(const String& keyString, const String& valueString, D ocument* document) 221 static Length findSizeValue(const String& keyString, const String& valueString, Document* document)
303 { 222 {
304 // 1) Non-negative number values are translated to px lengths. 223 // 1) Non-negative number values are translated to px lengths.
305 // 2) Negative number values are translated to auto. 224 // 2) Negative number values are translated to auto.
306 // 3) device-width and device-height are used as keywords. 225 // 3) device-width and device-height are used as keywords.
307 // 4) Other keywords and unknown values translate to 0.0. 226 // 4) Other keywords and unknown values translate to 0.0.
308 227
309 if (equalIgnoringCase(valueString, "device-width")) 228 if (equalIgnoringCase(valueString, "device-width"))
310 return ViewportArguments::ValueDeviceWidth; 229 return Length(100, ViewportPercentageWidth);
311 if (equalIgnoringCase(valueString, "device-height")) 230 if (equalIgnoringCase(valueString, "device-height"))
312 return ViewportArguments::ValueDeviceHeight; 231 return Length(100, ViewportPercentageHeight);
313 232
314 float value = numericPrefix(keyString, valueString, document); 233 float value = numericPrefix(keyString, valueString, document);
315 234
316 if (value < 0) 235 if (value < 0)
317 return ViewportArguments::ValueAuto; 236 return Length(); // auto
318 237
319 if (!static_cast<int>(value) && document->page() && document->page()->settin gs().viewportMetaZeroValuesQuirk()) { 238 if (!static_cast<int>(value) && document->page() && document->page()->settin gs().viewportMetaZeroValuesQuirk()) {
320 if (keyString == "width") 239 if (keyString == "width")
321 return ViewportArguments::ValueDeviceWidth; 240 return Length(100, ViewportPercentageWidth);
322 if (keyString == "height") 241 if (keyString == "height")
323 return ViewportArguments::ValueDeviceHeight; 242 return Length(100, ViewportPercentageHeight);
324 } 243 }
325 244
326 return value; 245 return Length(clampLengthValue(value), Fixed);
327 } 246 }
328 247
329 static float findScaleValue(const String& keyString, const String& valueString, Document* document) 248 static float findScaleValue(const String& keyString, const String& valueString, Document* document)
330 { 249 {
331 // 1) Non-negative number values are translated to <number> values. 250 // 1) Non-negative number values are translated to <number> values.
332 // 2) Negative number values are translated to auto. 251 // 2) Negative number values are translated to auto.
333 // 3) yes is translated to 1.0. 252 // 3) yes is translated to 1.0.
334 // 4) device-width and device-height are translated to 10.0. 253 // 4) device-width and device-height are translated to 10.0.
335 // 5) no and unknown values are translated to 0.0 254 // 5) no and unknown values are translated to 0.0
336 255
(...skipping 10 matching lines...) Expand all
347 266
348 if (value < 0) 267 if (value < 0)
349 return ViewportArguments::ValueAuto; 268 return ViewportArguments::ValueAuto;
350 269
351 if (value > 10.0) 270 if (value > 10.0)
352 reportViewportWarning(document, MaximumScaleTooLargeError, String(), Str ing()); 271 reportViewportWarning(document, MaximumScaleTooLargeError, String(), Str ing());
353 272
354 if (!static_cast<int>(value) && document->page() && document->page()->settin gs().viewportMetaZeroValuesQuirk() && (keyString == "minimum-scale" || keyString == "maximum-scale")) 273 if (!static_cast<int>(value) && document->page() && document->page()->settin gs().viewportMetaZeroValuesQuirk() && (keyString == "minimum-scale" || keyString == "maximum-scale"))
355 return ViewportArguments::ValueAuto; 274 return ViewportArguments::ValueAuto;
356 275
357 return value; 276 return clampScaleValue(value);
358 } 277 }
359 278
360 static float findUserScalableValue(const String& keyString, const String& valueS tring, Document* document) 279 static float findUserScalableValue(const String& keyString, const String& valueS tring, Document* document)
361 { 280 {
362 // yes and no are used as keywords. 281 // yes and no are used as keywords.
363 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to yes. 282 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to yes.
364 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. 283 // Numbers in the range <-1, 1>, and unknown values, are mapped to no.
365 284
366 if (equalIgnoringCase(valueString, "yes")) 285 if (equalIgnoringCase(valueString, "yes"))
367 return 1; 286 return 1;
(...skipping 28 matching lines...) Expand all
396 if (!ok || value < 70 || value > 400) 315 if (!ok || value < 70 || value > 400)
397 return ViewportArguments::ValueAuto; 316 return ViewportArguments::ValueAuto;
398 317
399 return value; 318 return value;
400 } 319 }
401 320
402 void setViewportFeature(const String& keyString, const String& valueString, Docu ment* document, void* data) 321 void setViewportFeature(const String& keyString, const String& valueString, Docu ment* document, void* data)
403 { 322 {
404 ViewportArguments* arguments = static_cast<ViewportArguments*>(data); 323 ViewportArguments* arguments = static_cast<ViewportArguments*>(data);
405 324
406 if (keyString == "width") 325 if (keyString == "width") {
407 arguments->width = findSizeValue(keyString, valueString, document); 326 const Length& width = findSizeValue(keyString, valueString, document);
408 else if (keyString == "height") 327 if (!width.isAuto()) {
409 arguments->height = findSizeValue(keyString, valueString, document); 328 arguments->minWidth = Length(ExtendToZoom);
410 else if (keyString == "initial-scale") 329 arguments->maxWidth = width;
330 }
331 } else if (keyString == "height") {
332 const Length& height = findSizeValue(keyString, valueString, document);
333 if (!height.isAuto()) {
334 arguments->minHeight = Length(ExtendToZoom);
335 arguments->maxHeight = height;
336 }
337 } else if (keyString == "initial-scale") {
411 arguments->zoom = findScaleValue(keyString, valueString, document); 338 arguments->zoom = findScaleValue(keyString, valueString, document);
412 else if (keyString == "minimum-scale") 339 } else if (keyString == "minimum-scale") {
413 arguments->minZoom = findScaleValue(keyString, valueString, document); 340 arguments->minZoom = findScaleValue(keyString, valueString, document);
414 else if (keyString == "maximum-scale") 341 } else if (keyString == "maximum-scale") {
415 arguments->maxZoom = findScaleValue(keyString, valueString, document); 342 arguments->maxZoom = findScaleValue(keyString, valueString, document);
416 else if (keyString == "user-scalable") 343 } else if (keyString == "user-scalable") {
417 arguments->userZoom = findUserScalableValue(keyString, valueString, docu ment); 344 arguments->userZoom = findUserScalableValue(keyString, valueString, docu ment);
418 else if (keyString == "target-densitydpi") { 345 } else if (keyString == "target-densitydpi") {
419 arguments->deprecatedTargetDensityDPI = findTargetDensityDPIValue(keyStr ing, valueString, document); 346 arguments->deprecatedTargetDensityDPI = findTargetDensityDPIValue(keyStr ing, valueString, document);
420 reportViewportWarning(document, TargetDensityDpiUnsupported, String(), S tring()); 347 reportViewportWarning(document, TargetDensityDpiUnsupported, String(), S tring());
421 } else 348 } else {
422 reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, ke yString, String()); 349 reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, ke yString, String());
350 }
423 } 351 }
424 352
425 static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode) 353 static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode)
426 { 354 {
427 static const char* const errors[] = { 355 static const char* const errors[] = {
428 "Note that ';' is not a key-value pair separator. The list should be com ma-separated.", 356 "Note that ';' is not a key-value pair separator. The list should be com ma-separated.",
429 "The key \"%replacement1\" is not recognized and ignored.", 357 "The key \"%replacement1\" is not recognized and ignored.",
430 "The value \"%replacement1\" for key \"%replacement2\" is invalid, and h as been ignored.", 358 "The value \"%replacement1\" for key \"%replacement2\" is invalid, and h as been ignored.",
431 "The value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.", 359 "The value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.",
432 "The value for key \"maximum-scale\" is out of bounds and the value has been clamped.", 360 "The value for key \"maximum-scale\" is out of bounds and the value has been clamped.",
(...skipping 30 matching lines...) Expand all
463 if (!replacement1.isNull()) 391 if (!replacement1.isNull())
464 message.replace("%replacement1", replacement1); 392 message.replace("%replacement1", replacement1);
465 if (!replacement2.isNull()) 393 if (!replacement2.isNull())
466 message.replace("%replacement2", replacement2); 394 message.replace("%replacement2", replacement2);
467 395
468 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. 396 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists.
469 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve l(errorCode), message); 397 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve l(errorCode), message);
470 } 398 }
471 399
472 } // namespace WebCore 400 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ViewportArguments.h ('k') | Source/core/page/PageScaleConstraintsSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698