OLD | NEW |
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 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 Length HTMLMetaElement::ParseViewportValueAsLength(Document* document, | 176 Length HTMLMetaElement::ParseViewportValueAsLength(Document* document, |
177 bool report_warnings, | 177 bool report_warnings, |
178 const String& key_string, | 178 const String& key_string, |
179 const String& value_string) { | 179 const String& value_string) { |
180 // 1) Non-negative number values are translated to px lengths. | 180 // 1) Non-negative number values are translated to px lengths. |
181 // 2) Negative number values are translated to auto. | 181 // 2) Negative number values are translated to auto. |
182 // 3) device-width and device-height are used as keywords. | 182 // 3) device-width and device-height are used as keywords. |
183 // 4) Other keywords and unknown values translate to 0.0. | 183 // 4) Other keywords and unknown values translate to 0.0. |
184 | 184 |
185 if (EqualIgnoringCase(value_string, "device-width")) | 185 if (DeprecatedEqualIgnoringCase(value_string, "device-width")) |
186 return Length(kDeviceWidth); | 186 return Length(kDeviceWidth); |
187 if (EqualIgnoringCase(value_string, "device-height")) | 187 if (DeprecatedEqualIgnoringCase(value_string, "device-height")) |
188 return Length(kDeviceHeight); | 188 return Length(kDeviceHeight); |
189 | 189 |
190 float value = | 190 float value = |
191 ParsePositiveNumber(document, report_warnings, key_string, value_string); | 191 ParsePositiveNumber(document, report_warnings, key_string, value_string); |
192 | 192 |
193 if (value < 0) | 193 if (value < 0) |
194 return Length(); // auto | 194 return Length(); // auto |
195 | 195 |
196 return Length(ClampLengthValue(value), kFixed); | 196 return Length(ClampLengthValue(value), kFixed); |
197 } | 197 } |
198 | 198 |
199 float HTMLMetaElement::ParseViewportValueAsZoom( | 199 float HTMLMetaElement::ParseViewportValueAsZoom( |
200 Document* document, | 200 Document* document, |
201 bool report_warnings, | 201 bool report_warnings, |
202 const String& key_string, | 202 const String& key_string, |
203 const String& value_string, | 203 const String& value_string, |
204 bool& computed_value_matches_parsed_value, | 204 bool& computed_value_matches_parsed_value, |
205 bool viewport_meta_zero_values_quirk) { | 205 bool viewport_meta_zero_values_quirk) { |
206 // 1) Non-negative number values are translated to <number> values. | 206 // 1) Non-negative number values are translated to <number> values. |
207 // 2) Negative number values are translated to auto. | 207 // 2) Negative number values are translated to auto. |
208 // 3) yes is translated to 1.0. | 208 // 3) yes is translated to 1.0. |
209 // 4) device-width and device-height are translated to 10.0. | 209 // 4) device-width and device-height are translated to 10.0. |
210 // 5) no and unknown values are translated to 0.0 | 210 // 5) no and unknown values are translated to 0.0 |
211 | 211 |
212 computed_value_matches_parsed_value = false; | 212 computed_value_matches_parsed_value = false; |
213 if (EqualIgnoringCase(value_string, "yes")) | 213 if (DeprecatedEqualIgnoringCase(value_string, "yes")) |
214 return 1; | 214 return 1; |
215 if (EqualIgnoringCase(value_string, "no")) | 215 if (DeprecatedEqualIgnoringCase(value_string, "no")) |
216 return 0; | 216 return 0; |
217 if (EqualIgnoringCase(value_string, "device-width")) | 217 if (DeprecatedEqualIgnoringCase(value_string, "device-width")) |
218 return 10; | 218 return 10; |
219 if (EqualIgnoringCase(value_string, "device-height")) | 219 if (DeprecatedEqualIgnoringCase(value_string, "device-height")) |
220 return 10; | 220 return 10; |
221 | 221 |
222 float value = | 222 float value = |
223 ParsePositiveNumber(document, report_warnings, key_string, value_string); | 223 ParsePositiveNumber(document, report_warnings, key_string, value_string); |
224 | 224 |
225 if (value < 0) | 225 if (value < 0) |
226 return ViewportDescription::kValueAuto; | 226 return ViewportDescription::kValueAuto; |
227 | 227 |
228 if (value > 10.0 && report_warnings) | 228 if (value > 10.0 && report_warnings) |
229 ReportViewportWarning(document, kMaximumScaleTooLargeError, String(), | 229 ReportViewportWarning(document, kMaximumScaleTooLargeError, String(), |
(...skipping 14 matching lines...) Expand all Loading... |
244 bool report_warnings, | 244 bool report_warnings, |
245 const String& key_string, | 245 const String& key_string, |
246 const String& value_string, | 246 const String& value_string, |
247 bool& computed_value_matches_parsed_value) { | 247 bool& computed_value_matches_parsed_value) { |
248 // yes and no are used as keywords. | 248 // yes and no are used as keywords. |
249 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to | 249 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to |
250 // yes. | 250 // yes. |
251 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. | 251 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. |
252 | 252 |
253 computed_value_matches_parsed_value = false; | 253 computed_value_matches_parsed_value = false; |
254 if (EqualIgnoringCase(value_string, "yes")) { | 254 if (DeprecatedEqualIgnoringCase(value_string, "yes")) { |
255 computed_value_matches_parsed_value = true; | 255 computed_value_matches_parsed_value = true; |
256 return true; | 256 return true; |
257 } | 257 } |
258 if (EqualIgnoringCase(value_string, "no")) { | 258 if (DeprecatedEqualIgnoringCase(value_string, "no")) { |
259 computed_value_matches_parsed_value = true; | 259 computed_value_matches_parsed_value = true; |
260 return false; | 260 return false; |
261 } | 261 } |
262 if (EqualIgnoringCase(value_string, "device-width")) | 262 if (DeprecatedEqualIgnoringCase(value_string, "device-width")) |
263 return true; | 263 return true; |
264 if (EqualIgnoringCase(value_string, "device-height")) | 264 if (DeprecatedEqualIgnoringCase(value_string, "device-height")) |
265 return true; | 265 return true; |
266 | 266 |
267 float value = | 267 float value = |
268 ParsePositiveNumber(document, report_warnings, key_string, value_string); | 268 ParsePositiveNumber(document, report_warnings, key_string, value_string); |
269 if (fabs(value) < 1) | 269 if (fabs(value) < 1) |
270 return false; | 270 return false; |
271 | 271 |
272 return true; | 272 return true; |
273 } | 273 } |
274 | 274 |
275 float HTMLMetaElement::ParseViewportValueAsDPI(Document* document, | 275 float HTMLMetaElement::ParseViewportValueAsDPI(Document* document, |
276 bool report_warnings, | 276 bool report_warnings, |
277 const String& key_string, | 277 const String& key_string, |
278 const String& value_string) { | 278 const String& value_string) { |
279 if (EqualIgnoringCase(value_string, "device-dpi")) | 279 if (DeprecatedEqualIgnoringCase(value_string, "device-dpi")) |
280 return ViewportDescription::kValueDeviceDPI; | 280 return ViewportDescription::kValueDeviceDPI; |
281 if (EqualIgnoringCase(value_string, "low-dpi")) | 281 if (DeprecatedEqualIgnoringCase(value_string, "low-dpi")) |
282 return ViewportDescription::kValueLowDPI; | 282 return ViewportDescription::kValueLowDPI; |
283 if (EqualIgnoringCase(value_string, "medium-dpi")) | 283 if (DeprecatedEqualIgnoringCase(value_string, "medium-dpi")) |
284 return ViewportDescription::kValueMediumDPI; | 284 return ViewportDescription::kValueMediumDPI; |
285 if (EqualIgnoringCase(value_string, "high-dpi")) | 285 if (DeprecatedEqualIgnoringCase(value_string, "high-dpi")) |
286 return ViewportDescription::kValueHighDPI; | 286 return ViewportDescription::kValueHighDPI; |
287 | 287 |
288 bool ok; | 288 bool ok; |
289 float value = ParsePositiveNumber(document, report_warnings, key_string, | 289 float value = ParsePositiveNumber(document, report_warnings, key_string, |
290 value_string, &ok); | 290 value_string, &ok); |
291 if (!ok || value < 70 || value > 400) | 291 if (!ok || value < 70 || value > 400) |
292 return ViewportDescription::kValueAuto; | 292 return ViewportDescription::kValueAuto; |
293 | 293 |
294 return value; | 294 return value; |
295 } | 295 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 return; | 466 return; |
467 | 467 |
468 // All below situations require a content attribute (which can be the empty | 468 // All below situations require a content attribute (which can be the empty |
469 // string). | 469 // string). |
470 const AtomicString& content_value = FastGetAttribute(contentAttr); | 470 const AtomicString& content_value = FastGetAttribute(contentAttr); |
471 if (content_value.IsNull()) | 471 if (content_value.IsNull()) |
472 return; | 472 return; |
473 | 473 |
474 const AtomicString& name_value = FastGetAttribute(nameAttr); | 474 const AtomicString& name_value = FastGetAttribute(nameAttr); |
475 if (!name_value.IsEmpty()) { | 475 if (!name_value.IsEmpty()) { |
476 if (EqualIgnoringCase(name_value, "viewport")) | 476 if (DeprecatedEqualIgnoringCase(name_value, "viewport")) |
477 ProcessViewportContentAttribute(content_value, | 477 ProcessViewportContentAttribute(content_value, |
478 ViewportDescription::kViewportMeta); | 478 ViewportDescription::kViewportMeta); |
479 else if (EqualIgnoringCase(name_value, "referrer")) | 479 else if (DeprecatedEqualIgnoringCase(name_value, "referrer")) |
480 GetDocument().ParseAndSetReferrerPolicy( | 480 GetDocument().ParseAndSetReferrerPolicy( |
481 content_value, true /* support legacy keywords */); | 481 content_value, true /* support legacy keywords */); |
482 else if (EqualIgnoringCase(name_value, "handheldfriendly") && | 482 else if (DeprecatedEqualIgnoringCase(name_value, "handheldfriendly") && |
483 EqualIgnoringCase(content_value, "true")) | 483 DeprecatedEqualIgnoringCase(content_value, "true")) |
484 ProcessViewportContentAttribute( | 484 ProcessViewportContentAttribute( |
485 "width=device-width", ViewportDescription::kHandheldFriendlyMeta); | 485 "width=device-width", ViewportDescription::kHandheldFriendlyMeta); |
486 else if (EqualIgnoringCase(name_value, "mobileoptimized")) | 486 else if (DeprecatedEqualIgnoringCase(name_value, "mobileoptimized")) |
487 ProcessViewportContentAttribute( | 487 ProcessViewportContentAttribute( |
488 "width=device-width, initial-scale=1", | 488 "width=device-width, initial-scale=1", |
489 ViewportDescription::kMobileOptimizedMeta); | 489 ViewportDescription::kMobileOptimizedMeta); |
490 else if (EqualIgnoringCase(name_value, "theme-color") && | 490 else if (DeprecatedEqualIgnoringCase(name_value, "theme-color") && |
491 GetDocument().GetFrame()) | 491 GetDocument().GetFrame()) |
492 GetDocument() | 492 GetDocument() |
493 .GetFrame() | 493 .GetFrame() |
494 ->Loader() | 494 ->Loader() |
495 .Client() | 495 .Client() |
496 ->DispatchDidChangeThemeColor(); | 496 ->DispatchDidChangeThemeColor(); |
497 } | 497 } |
498 | 498 |
499 // Get the document to process the tag, but only if we're actually part of DOM | 499 // Get the document to process the tag, but only if we're actually part of DOM |
500 // tree (changing a meta tag while it's not in the tree shouldn't have any | 500 // tree (changing a meta tag while it's not in the tree shouldn't have any |
(...skipping 20 matching lines...) Expand all Loading... |
521 } | 521 } |
522 | 522 |
523 const AtomicString& HTMLMetaElement::HttpEquiv() const { | 523 const AtomicString& HTMLMetaElement::HttpEquiv() const { |
524 return getAttribute(http_equivAttr); | 524 return getAttribute(http_equivAttr); |
525 } | 525 } |
526 | 526 |
527 const AtomicString& HTMLMetaElement::GetName() const { | 527 const AtomicString& HTMLMetaElement::GetName() const { |
528 return GetNameAttribute(); | 528 return GetNameAttribute(); |
529 } | 529 } |
530 } | 530 } |
OLD | NEW |