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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ExceptionMessages.h

Issue 2017053003: Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. Created 4 years, 6 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 | « no previous file | third_party/WebKit/Source/core/css/CSSBasicShapeValues.cpp » ('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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return formatFiniteNumber(number); 68 return formatFiniteNumber(number);
69 } 69 }
70 70
71 static String incorrectPropertyType(const String& property, const String& de tail); 71 static String incorrectPropertyType(const String& property, const String& de tail);
72 72
73 template <typename NumberType> 73 template <typename NumberType>
74 static String indexExceedsMaximumBound(const char* name, NumberType given, N umberType bound) 74 static String indexExceedsMaximumBound(const char* name, NumberType given, N umberType bound)
75 { 75 {
76 bool eq = given == bound; 76 bool eq = given == bound;
77 StringBuilder result; 77 StringBuilder result;
78 result.appendLiteral("The "); 78 result.append("The ");
79 result.append(name); 79 result.append(name);
80 result.appendLiteral(" provided ("); 80 result.append(" provided (");
81 result.append(formatNumber(given)); 81 result.append(formatNumber(given));
82 result.appendLiteral(") is greater than "); 82 result.append(") is greater than ");
83 result.append(eq ? "or equal to " : ""); 83 result.append(eq ? "or equal to " : "");
84 result.appendLiteral("the maximum bound ("); 84 result.append("the maximum bound (");
85 result.append(formatNumber(bound)); 85 result.append(formatNumber(bound));
86 result.appendLiteral(")."); 86 result.append(").");
87 return result.toString(); 87 return result.toString();
88 } 88 }
89 89
90 template <typename NumberType> 90 template <typename NumberType>
91 static String indexExceedsMinimumBound(const char* name, NumberType given, N umberType bound) 91 static String indexExceedsMinimumBound(const char* name, NumberType given, N umberType bound)
92 { 92 {
93 bool eq = given == bound; 93 bool eq = given == bound;
94 StringBuilder result; 94 StringBuilder result;
95 result.appendLiteral("The "); 95 result.append("The ");
96 result.append(name); 96 result.append(name);
97 result.appendLiteral(" provided ("); 97 result.append(" provided (");
98 result.append(formatNumber(given)); 98 result.append(formatNumber(given));
99 result.appendLiteral(") is less than "); 99 result.append(") is less than ");
100 result.append(eq ? "or equal to " : ""); 100 result.append(eq ? "or equal to " : "");
101 result.appendLiteral("the minimum bound ("); 101 result.append("the minimum bound (");
102 result.append(formatNumber(bound)); 102 result.append(formatNumber(bound));
103 result.appendLiteral(")."); 103 result.append(").");
104 return result.toString(); 104 return result.toString();
105 } 105 }
106 106
107 template <typename NumberType> 107 template <typename NumberType>
108 static String indexOutsideRange(const char* name, NumberType given, NumberTy pe lowerBound, BoundType lowerType, NumberType upperBound, BoundType upperType) 108 static String indexOutsideRange(const char* name, NumberType given, NumberTy pe lowerBound, BoundType lowerType, NumberType upperBound, BoundType upperType)
109 { 109 {
110 StringBuilder result; 110 StringBuilder result;
111 result.appendLiteral("The "); 111 result.append("The ");
112 result.append(name); 112 result.append(name);
113 result.appendLiteral(" provided ("); 113 result.append(" provided (");
114 result.append(formatNumber(given)); 114 result.append(formatNumber(given));
115 result.appendLiteral(") is outside the range "); 115 result.append(") is outside the range ");
116 result.append(lowerType == ExclusiveBound ? '(' : '['); 116 result.append(lowerType == ExclusiveBound ? '(' : '[');
117 result.append(formatNumber(lowerBound)); 117 result.append(formatNumber(lowerBound));
118 result.appendLiteral(", "); 118 result.append(", ");
119 result.append(formatNumber(upperBound)); 119 result.append(formatNumber(upperBound));
120 result.append(upperType == ExclusiveBound ? ')' : ']'); 120 result.append(upperType == ExclusiveBound ? ')' : ']');
121 result.append('.'); 121 result.append('.');
122 return result.toString(); 122 return result.toString();
123 } 123 }
124 124
125 static String invalidArity(const char* expected, unsigned provided); 125 static String invalidArity(const char* expected, unsigned provided);
126 126
127 // If > 0, the argument index that failed type check (1-indexed.) 127 // If > 0, the argument index that failed type check (1-indexed.)
128 // If == 0, a (non-argument) value (e.g., a setter) failed the same check. 128 // If == 0, a (non-argument) value (e.g., a setter) failed the same check.
(...skipping 29 matching lines...) Expand all
158 158
159 static String ordinalNumber(int number); 159 static String ordinalNumber(int number);
160 }; 160 };
161 161
162 template <> String ExceptionMessages::formatNumber<float>(float number); 162 template <> String ExceptionMessages::formatNumber<float>(float number);
163 template <> String ExceptionMessages::formatNumber<double>(double number); 163 template <> String ExceptionMessages::formatNumber<double>(double number);
164 164
165 } // namespace blink 165 } // namespace blink
166 166
167 #endif // ExceptionMessages_h 167 #endif // ExceptionMessages_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSBasicShapeValues.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698