Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't. | 68 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't. |
| 69 static bool isSeparator(UChar c) | 69 static bool isSeparator(UChar c) |
| 70 { | 70 { |
| 71 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ' ,' || c == '\0'; | 71 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ' ,' || c == '\0'; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void HTMLMetaElement::parseContentAttribute(const String& content, void* data, D ocument* document, bool viewportMetaZeroValuesQuirk) | 74 void HTMLMetaElement::parseContentAttribute(const String& content, void* data, D ocument* document, bool viewportMetaZeroValuesQuirk) |
| 75 { | 75 { |
| 76 bool error = false; | 76 bool hasInvalidSeparator = false; |
| 77 | 77 |
| 78 // Tread lightly in this code -- it was specifically designed to mimic Win I E's parsing behavior. | 78 // Tread lightly in this code -- it was specifically designed to mimic Win I E's parsing behavior. |
| 79 unsigned keyBegin, keyEnd; | 79 unsigned keyBegin, keyEnd; |
| 80 unsigned valueBegin, valueEnd; | 80 unsigned valueBegin, valueEnd; |
| 81 | 81 |
| 82 String buffer = content.lower(); | 82 String buffer = content.lower(); |
| 83 unsigned length = buffer.length(); | 83 unsigned length = buffer.length(); |
| 84 for (unsigned i = 0; i < length; /* no increment here */) { | 84 for (unsigned i = 0; i < length; /* no increment here */) { |
| 85 // skip to first non-separator, but don't skip past the end of the strin g | 85 // skip to first non-separator, but don't skip past the end of the strin g |
| 86 while (isSeparator(buffer[i])) { | 86 while (isSeparator(buffer[i])) { |
| 87 if (i >= length) | 87 if (i >= length) |
| 88 break; | 88 break; |
| 89 i++; | 89 i++; |
| 90 } | 90 } |
| 91 keyBegin = i; | 91 keyBegin = i; |
| 92 | 92 |
| 93 // skip to first separator | 93 // skip to first separator |
| 94 while (!isSeparator(buffer[i])) { | 94 while (!isSeparator(buffer[i])) { |
| 95 error |= isInvalidSeparator(buffer[i]); | 95 hasInvalidSeparator |= isInvalidSeparator(buffer[i]); |
| 96 if (i >= length) | 96 if (i >= length) |
| 97 break; | 97 break; |
| 98 i++; | 98 i++; |
| 99 } | 99 } |
| 100 keyEnd = i; | 100 keyEnd = i; |
| 101 | 101 |
| 102 // skip to first '=', but don't skip past a ',' or the end of the string | 102 // skip to first '=', but don't skip past a ',' or the end of the string |
| 103 while (buffer[i] != '=') { | 103 while (buffer[i] != '=') { |
| 104 error |= isInvalidSeparator(buffer[i]); | 104 hasInvalidSeparator |= isInvalidSeparator(buffer[i]); |
| 105 if (buffer[i] == ',' || i >= length) | 105 if (buffer[i] == ',' || i >= length) |
| 106 break; | 106 break; |
| 107 i++; | 107 i++; |
| 108 } | 108 } |
| 109 | 109 |
| 110 // skip to first non-separator, but don't skip past a ',' or the end of the string | 110 // skip to first non-separator, but don't skip past a ',' or the end of the string |
| 111 while (isSeparator(buffer[i])) { | 111 while (isSeparator(buffer[i])) { |
| 112 if (buffer[i] == ',' || i >= length) | 112 if (buffer[i] == ',' || i >= length) |
| 113 break; | 113 break; |
| 114 i++; | 114 i++; |
| 115 } | 115 } |
| 116 valueBegin = i; | 116 valueBegin = i; |
| 117 | 117 |
| 118 // skip to first separator | 118 // skip to first separator |
| 119 while (!isSeparator(buffer[i])) { | 119 while (!isSeparator(buffer[i])) { |
| 120 error |= isInvalidSeparator(buffer[i]); | 120 hasInvalidSeparator |= isInvalidSeparator(buffer[i]); |
| 121 if (i >= length) | 121 if (i >= length) |
| 122 break; | 122 break; |
| 123 i++; | 123 i++; |
| 124 } | 124 } |
| 125 valueEnd = i; | 125 valueEnd = i; |
| 126 | 126 |
| 127 SECURITY_DCHECK(i <= length); | 127 SECURITY_DCHECK(i <= length); |
| 128 | 128 |
| 129 String keyString = buffer.substring(keyBegin, keyEnd - keyBegin); | 129 String keyString = buffer.substring(keyBegin, keyEnd - keyBegin); |
| 130 String valueString = buffer.substring(valueBegin, valueEnd - valueBegin) ; | 130 String valueString = buffer.substring(valueBegin, valueEnd - valueBegin) ; |
| 131 processViewportKeyValuePair(document, keyString, valueString, viewportMe taZeroValuesQuirk, data); | 131 processViewportKeyValuePair(document, hasInvalidSeparator, keyString, va lueString, viewportMetaZeroValuesQuirk, data); |
| 132 } | 132 } |
| 133 if (error && document) { | 133 if (hasInvalidSeparator && document) { |
| 134 String message = "Error parsing a meta element's content: ';' is not a v alid key-value pair separator. Please use ',' instead."; | 134 String message = "Error parsing a meta element's content: ';' is not a v alid key-value pair separator. Please use ',' instead."; |
| 135 document->addConsoleMessage(ConsoleMessage::create(RenderingMessageSourc e, WarningMessageLevel, message)); | 135 document->addConsoleMessage(ConsoleMessage::create(RenderingMessageSourc e, WarningMessageLevel, message)); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 static inline float clampLengthValue(float value) | 139 static inline float clampLengthValue(float value) |
| 140 { | 140 { |
| 141 // Limits as defined in the css-device-adapt spec. | 141 // Limits as defined in the css-device-adapt spec. |
| 142 if (value != ViewportDescription::ValueAuto) | 142 if (value != ViewportDescription::ValueAuto) |
| 143 return std::min(float(10000), std::max(value, float(1))); | 143 return std::min(float(10000), std::max(value, float(1))); |
| 144 return value; | 144 return value; |
| 145 } | 145 } |
| 146 | 146 |
| 147 static inline float clampScaleValue(float value) | 147 static inline float clampScaleValue(float value) |
| 148 { | 148 { |
| 149 // Limits as defined in the css-device-adapt spec. | 149 // Limits as defined in the css-device-adapt spec. |
| 150 if (value != ViewportDescription::ValueAuto) | 150 if (value != ViewportDescription::ValueAuto) |
| 151 return std::min(float(10), std::max(value, float(0.1))); | 151 return std::min(float(10), std::max(value, float(0.1))); |
| 152 return value; | 152 return value; |
| 153 } | 153 } |
| 154 | 154 |
| 155 float HTMLMetaElement::parsePositiveNumber(Document* document, const String& key String, const String& valueString, bool* ok) | 155 float HTMLMetaElement::parsePositiveNumber(Document* document, bool& hasInvalidS eparator, const String& keyString, const String& valueString, bool* ok) |
|
bokan
2016/09/07 15:13:06
In this method and others, lets call the parameter
| |
| 156 { | 156 { |
| 157 size_t parsedLength; | 157 size_t parsedLength; |
| 158 float value; | 158 float value; |
| 159 if (valueString.is8Bit()) | 159 if (valueString.is8Bit()) |
| 160 value = charactersToFloat(valueString.characters8(), valueString.length( ), parsedLength); | 160 value = charactersToFloat(valueString.characters8(), valueString.length( ), parsedLength); |
| 161 else | 161 else |
| 162 value = charactersToFloat(valueString.characters16(), valueString.length (), parsedLength); | 162 value = charactersToFloat(valueString.characters16(), valueString.length (), parsedLength); |
| 163 if (!parsedLength) { | 163 if (!parsedLength) { |
| 164 reportViewportWarning(document, UnrecognizedViewportArgumentValueError, valueString, keyString); | 164 reportViewportWarning(document, hasInvalidSeparator, UnrecognizedViewpor tArgumentValueError, valueString, keyString); |
| 165 if (ok) | 165 if (ok) |
| 166 *ok = false; | 166 *ok = false; |
| 167 return 0; | 167 return 0; |
| 168 } | 168 } |
| 169 if (parsedLength < valueString.length()) | 169 if (parsedLength < valueString.length()) |
| 170 reportViewportWarning(document, TruncatedViewportArgumentValueError, val ueString, keyString); | 170 reportViewportWarning(document, hasInvalidSeparator, TruncatedViewportAr gumentValueError, valueString, keyString); |
| 171 if (ok) | 171 if (ok) |
| 172 *ok = true; | 172 *ok = true; |
| 173 return value; | 173 return value; |
| 174 } | 174 } |
| 175 | 175 |
| 176 Length HTMLMetaElement::parseViewportValueAsLength(Document* document, const Str ing& keyString, const String& valueString) | 176 Length HTMLMetaElement::parseViewportValueAsLength(Document* document, bool& has InvalidSeparator, const String& keyString, const String& valueString) |
| 177 { | 177 { |
| 178 // 1) Non-negative number values are translated to px lengths. | 178 // 1) Non-negative number values are translated to px lengths. |
| 179 // 2) Negative number values are translated to auto. | 179 // 2) Negative number values are translated to auto. |
| 180 // 3) device-width and device-height are used as keywords. | 180 // 3) device-width and device-height are used as keywords. |
| 181 // 4) Other keywords and unknown values translate to 0.0. | 181 // 4) Other keywords and unknown values translate to 0.0. |
| 182 | 182 |
| 183 unsigned length = valueString.length(); | 183 unsigned length = valueString.length(); |
| 184 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13); | 184 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13); |
| 185 SWITCH(characters, length) { | 185 SWITCH(characters, length) { |
| 186 CASE("device-width") { | 186 CASE("device-width") { |
| 187 return Length(DeviceWidth); | 187 return Length(DeviceWidth); |
| 188 } | 188 } |
| 189 CASE("device-height") { | 189 CASE("device-height") { |
| 190 return Length(DeviceHeight); | 190 return Length(DeviceHeight); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 float value = parsePositiveNumber(document, keyString, valueString); | 194 float value = parsePositiveNumber(document, hasInvalidSeparator, keyString, valueString); |
| 195 | 195 |
| 196 if (value < 0) | 196 if (value < 0) |
| 197 return Length(); // auto | 197 return Length(); // auto |
| 198 | 198 |
| 199 return Length(clampLengthValue(value), Fixed); | 199 return Length(clampLengthValue(value), Fixed); |
| 200 } | 200 } |
| 201 | 201 |
| 202 float HTMLMetaElement::parseViewportValueAsZoom(Document* document, const String & keyString, const String& valueString, bool& computedValueMatchesParsedValue, b ool viewportMetaZeroValuesQuirk) | 202 float HTMLMetaElement::parseViewportValueAsZoom(Document* document, bool& hasInv alidSeparator, const String& keyString, const String& valueString, bool& compute dValueMatchesParsedValue, bool viewportMetaZeroValuesQuirk) |
| 203 { | 203 { |
| 204 // 1) Non-negative number values are translated to <number> values. | 204 // 1) Non-negative number values are translated to <number> values. |
| 205 // 2) Negative number values are translated to auto. | 205 // 2) Negative number values are translated to auto. |
| 206 // 3) yes is translated to 1.0. | 206 // 3) yes is translated to 1.0. |
| 207 // 4) device-width and device-height are translated to 10.0. | 207 // 4) device-width and device-height are translated to 10.0. |
| 208 // 5) no and unknown values are translated to 0.0 | 208 // 5) no and unknown values are translated to 0.0 |
| 209 | 209 |
| 210 computedValueMatchesParsedValue = false; | 210 computedValueMatchesParsedValue = false; |
| 211 unsigned length = valueString.length(); | 211 unsigned length = valueString.length(); |
| 212 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13); | 212 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13); |
| 213 SWITCH(characters, length) { | 213 SWITCH(characters, length) { |
| 214 CASE("yes") { | 214 CASE("yes") { |
| 215 return 1; | 215 return 1; |
| 216 } | 216 } |
| 217 CASE("no") { | 217 CASE("no") { |
| 218 return 0; | 218 return 0; |
| 219 } | 219 } |
| 220 CASE("device-width") { | 220 CASE("device-width") { |
| 221 return 10; | 221 return 10; |
| 222 } | 222 } |
| 223 CASE("device-height") { | 223 CASE("device-height") { |
| 224 return 10; | 224 return 10; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 float value = parsePositiveNumber(document, keyString, valueString); | 228 float value = parsePositiveNumber(document, hasInvalidSeparator, keyString, valueString); |
| 229 | 229 |
| 230 if (value < 0) | 230 if (value < 0) |
| 231 return ViewportDescription::ValueAuto; | 231 return ViewportDescription::ValueAuto; |
| 232 | 232 |
| 233 if (value > 10.0) | 233 if (value > 10.0) |
| 234 reportViewportWarning(document, MaximumScaleTooLargeError, String(), Str ing()); | 234 reportViewportWarning(document, hasInvalidSeparator, MaximumScaleTooLarg eError, String(), String()); |
| 235 | 235 |
| 236 if (!value && viewportMetaZeroValuesQuirk) | 236 if (!value && viewportMetaZeroValuesQuirk) |
| 237 return ViewportDescription::ValueAuto; | 237 return ViewportDescription::ValueAuto; |
| 238 | 238 |
| 239 float clampedValue = clampScaleValue(value); | 239 float clampedValue = clampScaleValue(value); |
| 240 if (clampedValue == value) | 240 if (clampedValue == value) |
| 241 computedValueMatchesParsedValue = true; | 241 computedValueMatchesParsedValue = true; |
| 242 | 242 |
| 243 return clampedValue; | 243 return clampedValue; |
| 244 } | 244 } |
| 245 | 245 |
| 246 bool HTMLMetaElement::parseViewportValueAsUserZoom(Document* document, const Str ing& keyString, const String& valueString, bool& computedValueMatchesParsedValue ) | 246 bool HTMLMetaElement::parseViewportValueAsUserZoom(Document* document, bool& has InvalidSeparator, const String& keyString, const String& valueString, bool& comp utedValueMatchesParsedValue) |
| 247 { | 247 { |
| 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 yes. | 249 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to yes. |
| 250 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. | 250 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. |
| 251 | 251 |
| 252 computedValueMatchesParsedValue = false; | 252 computedValueMatchesParsedValue = false; |
| 253 unsigned length = valueString.length(); | 253 unsigned length = valueString.length(); |
| 254 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13); | 254 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13); |
| 255 SWITCH(characters, length) { | 255 SWITCH(characters, length) { |
| 256 CASE("yes") { | 256 CASE("yes") { |
| 257 computedValueMatchesParsedValue = true; | 257 computedValueMatchesParsedValue = true; |
| 258 return true; | 258 return true; |
| 259 } | 259 } |
| 260 CASE("no") { | 260 CASE("no") { |
| 261 computedValueMatchesParsedValue = true; | 261 computedValueMatchesParsedValue = true; |
| 262 return false; | 262 return false; |
| 263 } | 263 } |
| 264 CASE("device-width") { | 264 CASE("device-width") { |
| 265 return true; | 265 return true; |
| 266 } | 266 } |
| 267 CASE("device-height") { | 267 CASE("device-height") { |
| 268 return true; | 268 return true; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 float value = parsePositiveNumber(document, keyString, valueString); | 272 float value = parsePositiveNumber(document, hasInvalidSeparator, keyString, valueString); |
| 273 if (fabs(value) < 1) | 273 if (fabs(value) < 1) |
| 274 return false; | 274 return false; |
| 275 | 275 |
| 276 return true; | 276 return true; |
| 277 } | 277 } |
| 278 | 278 |
| 279 float HTMLMetaElement::parseViewportValueAsDPI(Document* document, const String& keyString, const String& valueString) | 279 float HTMLMetaElement::parseViewportValueAsDPI(Document* document, bool& hasInva lidSeparator, const String& keyString, const String& valueString) |
| 280 { | 280 { |
| 281 unsigned length = valueString.length(); | 281 unsigned length = valueString.length(); |
| 282 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 10); | 282 DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 10); |
| 283 SWITCH(characters, length) { | 283 SWITCH(characters, length) { |
| 284 CASE("device-dpi") { | 284 CASE("device-dpi") { |
| 285 return ViewportDescription::ValueDeviceDPI; | 285 return ViewportDescription::ValueDeviceDPI; |
| 286 } | 286 } |
| 287 CASE("low-dpi") { | 287 CASE("low-dpi") { |
| 288 return ViewportDescription::ValueLowDPI; | 288 return ViewportDescription::ValueLowDPI; |
| 289 } | 289 } |
| 290 CASE("medium-dpi") { | 290 CASE("medium-dpi") { |
| 291 return ViewportDescription::ValueMediumDPI; | 291 return ViewportDescription::ValueMediumDPI; |
| 292 } | 292 } |
| 293 CASE("high-dpi") { | 293 CASE("high-dpi") { |
| 294 return ViewportDescription::ValueHighDPI; | 294 return ViewportDescription::ValueHighDPI; |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool ok; | 298 bool ok; |
| 299 float value = parsePositiveNumber(document, keyString, valueString, &ok); | 299 float value = parsePositiveNumber(document, hasInvalidSeparator, keyString, valueString, &ok); |
| 300 if (!ok || value < 70 || value > 400) | 300 if (!ok || value < 70 || value > 400) |
| 301 return ViewportDescription::ValueAuto; | 301 return ViewportDescription::ValueAuto; |
| 302 | 302 |
| 303 return value; | 303 return value; |
| 304 } | 304 } |
| 305 | 305 |
| 306 void HTMLMetaElement::processViewportKeyValuePair(Document* document, const Stri ng& keyString, const String& valueString, bool viewportMetaZeroValuesQuirk, void * data) | 306 void HTMLMetaElement::processViewportKeyValuePair(Document* document, bool& hasI nvalidSeparator, const String& keyString, const String& valueString, bool viewpo rtMetaZeroValuesQuirk, void* data) |
| 307 { | 307 { |
| 308 ViewportDescription* description = static_cast<ViewportDescription*>(data); | 308 ViewportDescription* description = static_cast<ViewportDescription*>(data); |
| 309 | 309 |
| 310 unsigned length = keyString.length(); | 310 unsigned length = keyString.length(); |
| 311 | 311 |
| 312 DEFINE_ARRAY_FOR_MATCHING(characters, keyString, 17); | 312 DEFINE_ARRAY_FOR_MATCHING(characters, keyString, 17); |
| 313 SWITCH(characters, length) { | 313 SWITCH(characters, length) { |
| 314 CASE("width") { | 314 CASE("width") { |
| 315 const Length& width = parseViewportValueAsLength(document, keyString , valueString); | 315 const Length& width = parseViewportValueAsLength(document, hasInvali dSeparator, keyString, valueString); |
| 316 if (width.isAuto()) | 316 if (width.isAuto()) |
| 317 return; | 317 return; |
| 318 description->minWidth = Length(ExtendToZoom); | 318 description->minWidth = Length(ExtendToZoom); |
| 319 description->maxWidth = width; | 319 description->maxWidth = width; |
| 320 return; | 320 return; |
| 321 } | 321 } |
| 322 CASE("height") { | 322 CASE("height") { |
| 323 const Length& height = parseViewportValueAsLength(document, keyStrin g, valueString); | 323 const Length& height = parseViewportValueAsLength(document, hasInval idSeparator, keyString, valueString); |
| 324 if (height.isAuto()) | 324 if (height.isAuto()) |
| 325 return; | 325 return; |
| 326 description->minHeight = Length(ExtendToZoom); | 326 description->minHeight = Length(ExtendToZoom); |
| 327 description->maxHeight = height; | 327 description->maxHeight = height; |
| 328 return; | 328 return; |
| 329 } | 329 } |
| 330 CASE("initial-scale") { | 330 CASE("initial-scale") { |
| 331 description->zoom = parseViewportValueAsZoom(document, keyString, va lueString, description->zoomIsExplicit, viewportMetaZeroValuesQuirk); | 331 description->zoom = parseViewportValueAsZoom(document, hasInvalidSep arator, keyString, valueString, description->zoomIsExplicit, viewportMetaZeroVal uesQuirk); |
| 332 return; | 332 return; |
| 333 } | 333 } |
| 334 CASE("minimum-scale") { | 334 CASE("minimum-scale") { |
| 335 description->minZoom = parseViewportValueAsZoom(document, keyString, valueString, description->minZoomIsExplicit, viewportMetaZeroValuesQuirk); | 335 description->minZoom = parseViewportValueAsZoom(document, hasInvalid Separator, keyString, valueString, description->minZoomIsExplicit, viewportMetaZ eroValuesQuirk); |
| 336 return; | 336 return; |
| 337 } | 337 } |
| 338 CASE("maximum-scale") { | 338 CASE("maximum-scale") { |
| 339 description->maxZoom = parseViewportValueAsZoom(document, keyString, valueString, description->maxZoomIsExplicit, viewportMetaZeroValuesQuirk); | 339 description->maxZoom = parseViewportValueAsZoom(document, hasInvalid Separator, keyString, valueString, description->maxZoomIsExplicit, viewportMetaZ eroValuesQuirk); |
| 340 return; | 340 return; |
| 341 } | 341 } |
| 342 CASE("user-scalable") { | 342 CASE("user-scalable") { |
| 343 description->userZoom = parseViewportValueAsUserZoom(document, keySt ring, valueString, description->userZoomIsExplicit); | 343 description->userZoom = parseViewportValueAsUserZoom(document, hasIn validSeparator, keyString, valueString, description->userZoomIsExplicit); |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 CASE("target-densitydpi") { | 346 CASE("target-densitydpi") { |
| 347 description->deprecatedTargetDensityDPI = parseViewportValueAsDPI(do cument, keyString, valueString); | 347 description->deprecatedTargetDensityDPI = parseViewportValueAsDPI(do cument, hasInvalidSeparator, keyString, valueString); |
| 348 reportViewportWarning(document, TargetDensityDpiUnsupported, String( ), String()); | 348 reportViewportWarning(document, hasInvalidSeparator, TargetDensityDp iUnsupported, String(), String()); |
| 349 return; | 349 return; |
| 350 } | 350 } |
| 351 CASE("minimal-ui") { | 351 CASE("minimal-ui") { |
| 352 // Ignore vendor-specific argument. | 352 // Ignore vendor-specific argument. |
| 353 return; | 353 return; |
| 354 } | 354 } |
| 355 CASE("shrink-to-fit") { | 355 CASE("shrink-to-fit") { |
| 356 // Ignore vendor-specific argument. | 356 // Ignore vendor-specific argument. |
| 357 return; | 357 return; |
| 358 } | 358 } |
| 359 } | 359 } |
| 360 reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, keyStr ing, String()); | 360 reportViewportWarning(document, hasInvalidSeparator, UnrecognizedViewportArg umentKeyError, keyString, String()); |
| 361 } | 361 } |
| 362 | 362 |
| 363 static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode) | 363 static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode) |
| 364 { | 364 { |
| 365 static const char* const errors[] = { | 365 static const char* const errors[] = { |
| 366 "The key \"%replacement1\" is not recognized and ignored.", | 366 "The key \"%replacement1\" is not recognized and ignored.", |
| 367 "The value \"%replacement1\" for key \"%replacement2\" is invalid, and h as been ignored.", | 367 "The value \"%replacement1\" for key \"%replacement2\" is invalid, and h as been ignored.", |
| 368 "The value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.", | 368 "The value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.", |
| 369 "The value for key \"maximum-scale\" is out of bounds and the value has been clamped.", | 369 "The value for key \"maximum-scale\" is out of bounds and the value has been clamped.", |
| 370 "The key \"target-densitydpi\" is not supported.", | 370 "The key \"target-densitydpi\" is not supported.", |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 381 case UnrecognizedViewportArgumentKeyError: | 381 case UnrecognizedViewportArgumentKeyError: |
| 382 case UnrecognizedViewportArgumentValueError: | 382 case UnrecognizedViewportArgumentValueError: |
| 383 case MaximumScaleTooLargeError: | 383 case MaximumScaleTooLargeError: |
| 384 return WarningMessageLevel; | 384 return WarningMessageLevel; |
| 385 } | 385 } |
| 386 | 386 |
| 387 NOTREACHED(); | 387 NOTREACHED(); |
| 388 return ErrorMessageLevel; | 388 return ErrorMessageLevel; |
| 389 } | 389 } |
| 390 | 390 |
| 391 void HTMLMetaElement::reportViewportWarning(Document* document, ViewportErrorCod e errorCode, const String& replacement1, const String& replacement2) | 391 void HTMLMetaElement::reportViewportWarning(Document* document, bool& hasInvalid Separator, ViewportErrorCode errorCode, const String& replacement1, const String & replacement2) |
|
bokan
2016/09/07 15:13:06
This method shouldn't have this param. Instead, th
| |
| 392 { | 392 { |
| 393 if (!document || !document->frame()) | 393 if (!document || !document->frame() || hasInvalidSeparator) |
| 394 return; | 394 return; |
| 395 | 395 |
| 396 String message = viewportErrorMessageTemplate(errorCode); | 396 String message = viewportErrorMessageTemplate(errorCode); |
| 397 if (!replacement1.isNull()) | 397 if (!replacement1.isNull()) |
| 398 message.replace("%replacement1", replacement1); | 398 message.replace("%replacement1", replacement1); |
| 399 if (!replacement2.isNull()) | 399 if (!replacement2.isNull()) |
| 400 message.replace("%replacement2", replacement2); | 400 message.replace("%replacement2", replacement2); |
| 401 | 401 |
| 402 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 402 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
| 403 document->addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, v iewportErrorMessageLevel(errorCode), message)); | 403 document->addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, v iewportErrorMessageLevel(errorCode), message)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 { | 514 { |
| 515 return getAttribute(http_equivAttr); | 515 return getAttribute(http_equivAttr); |
| 516 } | 516 } |
| 517 | 517 |
| 518 const AtomicString& HTMLMetaElement::name() const | 518 const AtomicString& HTMLMetaElement::name() const |
| 519 { | 519 { |
| 520 return getNameAttribute(); | 520 return getNameAttribute(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 } | 523 } |
| OLD | NEW |