| 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 * (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 11 matching lines...) Expand all Loading... |
| 22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
| 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
| 25 * | 25 * |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 #include "core/dom/ViewportArguments.h" | 29 #include "core/dom/ViewportArguments.h" |
| 30 | 30 |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/page/Page.h" |
| 33 #include "core/page/Settings.h" |
| 32 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 33 | 35 |
| 34 using namespace std; | 36 using namespace std; |
| 35 | 37 |
| 36 namespace WebCore { | 38 namespace WebCore { |
| 37 | 39 |
| 38 static const float& compareIgnoringAuto(const float& value1, const float& value2
, const float& (*compare) (const float&, const float&)) | 40 static const float& compareIgnoringAuto(const float& value1, const float& value2
, const float& (*compare) (const float&, const float&)) |
| 39 { | 41 { |
| 40 if (value1 == ViewportArguments::ValueAuto) | 42 if (value1 == ViewportArguments::ValueAuto) |
| 41 return value2; | 43 return value2; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (equalIgnoringCase(valueString, "device-width")) | 292 if (equalIgnoringCase(valueString, "device-width")) |
| 291 return ViewportArguments::ValueDeviceWidth; | 293 return ViewportArguments::ValueDeviceWidth; |
| 292 if (equalIgnoringCase(valueString, "device-height")) | 294 if (equalIgnoringCase(valueString, "device-height")) |
| 293 return ViewportArguments::ValueDeviceHeight; | 295 return ViewportArguments::ValueDeviceHeight; |
| 294 | 296 |
| 295 float value = numericPrefix(keyString, valueString, document); | 297 float value = numericPrefix(keyString, valueString, document); |
| 296 | 298 |
| 297 if (value < 0) | 299 if (value < 0) |
| 298 return ViewportArguments::ValueAuto; | 300 return ViewportArguments::ValueAuto; |
| 299 | 301 |
| 302 if (!static_cast<int>(value) && document->page() && document->page()->settin
gs().viewportMetaZeroValuesQuirk()) { |
| 303 if (keyString == "width") |
| 304 return ViewportArguments::ValueDeviceWidth; |
| 305 if (keyString == "height") |
| 306 return ViewportArguments::ValueDeviceHeight; |
| 307 } |
| 308 |
| 300 return value; | 309 return value; |
| 301 } | 310 } |
| 302 | 311 |
| 303 static float findScaleValue(const String& keyString, const String& valueString,
Document* document) | 312 static float findScaleValue(const String& keyString, const String& valueString,
Document* document) |
| 304 { | 313 { |
| 305 // 1) Non-negative number values are translated to <number> values. | 314 // 1) Non-negative number values are translated to <number> values. |
| 306 // 2) Negative number values are translated to auto. | 315 // 2) Negative number values are translated to auto. |
| 307 // 3) yes is translated to 1.0. | 316 // 3) yes is translated to 1.0. |
| 308 // 4) device-width and device-height are translated to 10.0. | 317 // 4) device-width and device-height are translated to 10.0. |
| 309 // 5) no and unknown values are translated to 0.0 | 318 // 5) no and unknown values are translated to 0.0 |
| 310 | 319 |
| 311 if (equalIgnoringCase(valueString, "yes")) | 320 if (equalIgnoringCase(valueString, "yes")) |
| 312 return 1; | 321 return 1; |
| 313 if (equalIgnoringCase(valueString, "no")) | 322 if (equalIgnoringCase(valueString, "no")) |
| 314 return 0; | 323 return 0; |
| 315 if (equalIgnoringCase(valueString, "device-width")) | 324 if (equalIgnoringCase(valueString, "device-width")) |
| 316 return 10; | 325 return 10; |
| 317 if (equalIgnoringCase(valueString, "device-height")) | 326 if (equalIgnoringCase(valueString, "device-height")) |
| 318 return 10; | 327 return 10; |
| 319 | 328 |
| 320 float value = numericPrefix(keyString, valueString, document); | 329 float value = numericPrefix(keyString, valueString, document); |
| 321 | 330 |
| 322 if (value < 0) | 331 if (value < 0) |
| 323 return ViewportArguments::ValueAuto; | 332 return ViewportArguments::ValueAuto; |
| 324 | 333 |
| 325 if (value > 10.0) | 334 if (value > 10.0) |
| 326 reportViewportWarning(document, MaximumScaleTooLargeError, String(), Str
ing()); | 335 reportViewportWarning(document, MaximumScaleTooLargeError, String(), Str
ing()); |
| 327 | 336 |
| 337 if (!static_cast<int>(value) && document->page() && document->page()->settin
gs().viewportMetaZeroValuesQuirk() && (keyString == "minimum-scale" || keyString
== "maximum-scale")) |
| 338 return ViewportArguments::ValueAuto; |
| 339 |
| 328 return value; | 340 return value; |
| 329 } | 341 } |
| 330 | 342 |
| 331 static float findUserScalableValue(const String& keyString, const String& valueS
tring, Document* document) | 343 static float findUserScalableValue(const String& keyString, const String& valueS
tring, Document* document) |
| 332 { | 344 { |
| 333 // yes and no are used as keywords. | 345 // yes and no are used as keywords. |
| 334 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to
yes. | 346 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to
yes. |
| 335 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. | 347 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. |
| 336 | 348 |
| 337 if (equalIgnoringCase(valueString, "yes")) | 349 if (equalIgnoringCase(valueString, "yes")) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if (!replacement1.isNull()) | 446 if (!replacement1.isNull()) |
| 435 message.replace("%replacement1", replacement1); | 447 message.replace("%replacement1", replacement1); |
| 436 if (!replacement2.isNull()) | 448 if (!replacement2.isNull()) |
| 437 message.replace("%replacement2", replacement2); | 449 message.replace("%replacement2", replacement2); |
| 438 | 450 |
| 439 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 451 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
| 440 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); | 452 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve
l(errorCode), message); |
| 441 } | 453 } |
| 442 | 454 |
| 443 } // namespace WebCore | 455 } // namespace WebCore |
| OLD | NEW |