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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/Values.cpp

Issue 2226863003: [DevTools] Reduce API surface of String16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/inspector_protocol/Values.h" 5 #include "platform/inspector_protocol/Values.h"
6 6
7 #include "platform/inspector_protocol/Parser.h" 7 #include "platform/inspector_protocol/Parser.h"
8 #include "platform/inspector_protocol/String16.h" 8 #include "platform/inspector_protocol/String16.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 17 matching lines...) Expand all
28 case '\r': dst->append("\\r"); break; 28 case '\r': dst->append("\\r"); break;
29 case '\t': dst->append("\\t"); break; 29 case '\t': dst->append("\\t"); break;
30 case '\\': dst->append("\\\\"); break; 30 case '\\': dst->append("\\\\"); break;
31 case '"': dst->append("\\\""); break; 31 case '"': dst->append("\\\""); break;
32 default: 32 default:
33 return false; 33 return false;
34 } 34 }
35 return true; 35 return true;
36 } 36 }
37 37
38 const LChar hexDigits[17] = "0123456789ABCDEF"; 38 const char hexDigits[17] = "0123456789ABCDEF";
39 39
40 void appendUnsignedAsHex(UChar number, String16Builder* dst) 40 void appendUnsignedAsHex(UChar number, String16Builder* dst)
41 { 41 {
42 dst->append("\\u"); 42 dst->append("\\u");
43 for (size_t i = 0; i < 4; ++i) { 43 for (size_t i = 0; i < 4; ++i) {
44 dst->append(hexDigits[(number & 0xF000) >> 12]); 44 UChar c = hexDigits[(number & 0xF000) >> 12];
45 dst->append(c);
45 number <<= 4; 46 number <<= 4;
46 } 47 }
47 } 48 }
48 49
49 void escapeStringForJSON(const String16& str, String16Builder* dst) 50 void escapeStringForJSON(const String16& str, String16Builder* dst)
50 { 51 {
51 for (unsigned i = 0; i < str.length(); ++i) { 52 for (unsigned i = 0; i < str.length(); ++i) {
52 UChar c = str[i]; 53 UChar c = str[i];
53 if (!escapeChar(c, dst)) { 54 if (!escapeChar(c, dst)) {
54 if (c < 32 || c > 126 || c == '<' || c == '>') { 55 if (c < 32 || c > 126 || c == '<' || c == '>') {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (type() == TypeBoolean) { 152 if (type() == TypeBoolean) {
152 if (m_boolValue) 153 if (m_boolValue)
153 output->append(trueString, 4); 154 output->append(trueString, 4);
154 else 155 else
155 output->append(falseString, 5); 156 output->append(falseString, 5);
156 } else if (type() == TypeDouble) { 157 } else if (type() == TypeDouble) {
157 if (!std::isfinite(m_doubleValue)) { 158 if (!std::isfinite(m_doubleValue)) {
158 output->append(nullString, 4); 159 output->append(nullString, 4);
159 return; 160 return;
160 } 161 }
161 output->append(String16::fromDouble(m_doubleValue)); 162 output->append(protocol::string16FromDouble(m_doubleValue));
162 } else if (type() == TypeInteger) { 163 } else if (type() == TypeInteger) {
163 output->append(String16::fromInteger(m_integerValue)); 164 output->append(protocol::string16FromInteger(m_integerValue));
164 } 165 }
165 } 166 }
166 167
167 std::unique_ptr<Value> FundamentalValue::clone() const 168 std::unique_ptr<Value> FundamentalValue::clone() const
168 { 169 {
169 switch (type()) { 170 switch (type()) {
170 case TypeDouble: return FundamentalValue::create(m_doubleValue); 171 case TypeDouble: return FundamentalValue::create(m_doubleValue);
171 case TypeInteger: return FundamentalValue::create(m_integerValue); 172 case TypeInteger: return FundamentalValue::create(m_integerValue);
172 case TypeBoolean: return FundamentalValue::create(m_boolValue); 173 case TypeBoolean: return FundamentalValue::create(m_boolValue);
173 default: 174 default:
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 402 }
402 403
403 protocol::Value* ListValue::at(size_t index) 404 protocol::Value* ListValue::at(size_t index)
404 { 405 {
405 DCHECK_LT(index, m_data.size()); 406 DCHECK_LT(index, m_data.size());
406 return m_data[index].get(); 407 return m_data[index].get();
407 } 408 }
408 409
409 } // namespace protocol 410 } // namespace protocol
410 } // namespace blink 411 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698