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

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

Issue 22908011: Change viewport error messages in preparation for use with @viewport rule (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ViewportArguments.h ('k') | no next file » | 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 else if (keyString == "target-densitydpi") { 389 else if (keyString == "target-densitydpi") {
390 arguments->deprecatedTargetDensityDPI = findTargetDensityDPIValue(keyStr ing, valueString, document); 390 arguments->deprecatedTargetDensityDPI = findTargetDensityDPIValue(keyStr ing, valueString, document);
391 reportViewportWarning(document, TargetDensityDpiUnsupported, String(), S tring()); 391 reportViewportWarning(document, TargetDensityDpiUnsupported, String(), S tring());
392 } else 392 } else
393 reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, ke yString, String()); 393 reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, ke yString, String());
394 } 394 }
395 395
396 static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode) 396 static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode)
397 { 397 {
398 static const char* const errors[] = { 398 static const char* const errors[] = {
399 "Viewport argument key \"%replacement1\" not recognized and ignored.", 399 "Note that ';' is not a key-value pair separator. The list should be com ma-separated.",
400 "Viewport argument value \"%replacement1\" for key \"%replacement2\" is invalid, and has been ignored.", 400 "The key \"%replacement1\" is not recognized and ignored.",
401 "Viewport argument value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.", 401 "The value \"%replacement1\" for key \"%replacement2\" is invalid, and h as been ignored.",
402 "Viewport maximum-scale cannot be larger than 10.0. The maximum-scale wi ll be set to 10.0.", 402 "The value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.",
403 "Viewport target-densitydpi is not supported.", 403 "The value for key \"maximum-scale\" is out of bounds and the value has been clamped.",
404 "The key \"target-densitydpi\" is not supported.",
404 }; 405 };
405 406
406 return errors[errorCode]; 407 return errors[errorCode];
407 } 408 }
408 409
409 static MessageLevel viewportErrorMessageLevel(ViewportErrorCode errorCode) 410 static MessageLevel viewportErrorMessageLevel(ViewportErrorCode errorCode)
410 { 411 {
411 switch (errorCode) { 412 switch (errorCode) {
413 case InvalidKeyValuePairSeparatorError:
412 case TruncatedViewportArgumentValueError: 414 case TruncatedViewportArgumentValueError:
413 case TargetDensityDpiUnsupported: 415 case TargetDensityDpiUnsupported:
414 return WarningMessageLevel; 416 return WarningMessageLevel;
415 case UnrecognizedViewportArgumentKeyError: 417 case UnrecognizedViewportArgumentKeyError:
416 case UnrecognizedViewportArgumentValueError: 418 case UnrecognizedViewportArgumentValueError:
417 case MaximumScaleTooLargeError: 419 case MaximumScaleTooLargeError:
418 return ErrorMessageLevel; 420 return ErrorMessageLevel;
419 } 421 }
420 422
421 ASSERT_NOT_REACHED(); 423 ASSERT_NOT_REACHED();
422 return ErrorMessageLevel; 424 return ErrorMessageLevel;
423 } 425 }
424 426
425 void reportViewportWarning(Document* document, ViewportErrorCode errorCode, cons t String& replacement1, const String& replacement2) 427 void reportViewportWarning(Document* document, ViewportErrorCode errorCode, cons t String& replacement1, const String& replacement2)
426 { 428 {
427 Frame* frame = document->frame(); 429 Frame* frame = document->frame();
428 if (!frame) 430 if (!frame)
429 return; 431 return;
430 432
431 String message = viewportErrorMessageTemplate(errorCode); 433 String message = viewportErrorMessageTemplate(errorCode);
432 if (!replacement1.isNull()) 434 if (!replacement1.isNull())
433 message.replace("%replacement1", replacement1); 435 message.replace("%replacement1", replacement1);
434 if (!replacement2.isNull()) 436 if (!replacement2.isNull())
435 message.replace("%replacement2", replacement2); 437 message.replace("%replacement2", replacement2);
436 438
437 if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == Tru ncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound)
438 message.append(" Note that ';' is not a separator in viewport values. Th e list should be comma-separated.");
439
440 // FIXME: This message should be moved off the console once a solution to ht tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. 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.
441 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve l(errorCode), message); 440 document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLeve l(errorCode), message);
442 } 441 }
443 442
444 } // namespace WebCore 443 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ViewportArguments.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698