| OLD | NEW |
| 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/Parser.h" | 5 #include "platform/inspector_protocol/Parser.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/String16.h" | 7 #include "platform/inspector_protocol/String16.h" |
| 8 #include "platform/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 result = FundamentalValue::create(true); | 375 result = FundamentalValue::create(true); |
| 376 break; | 376 break; |
| 377 case BoolFalse: | 377 case BoolFalse: |
| 378 result = FundamentalValue::create(false); | 378 result = FundamentalValue::create(false); |
| 379 break; | 379 break; |
| 380 case Number: { | 380 case Number: { |
| 381 bool ok; | 381 bool ok; |
| 382 double value = String16::charactersToDouble(tokenStart, tokenEnd - token
Start, &ok); | 382 double value = String16::charactersToDouble(tokenStart, tokenEnd - token
Start, &ok); |
| 383 if (!ok) | 383 if (!ok) |
| 384 return nullptr; | 384 return nullptr; |
| 385 result = FundamentalValue::create(value); | 385 int number = static_cast<int>(value); |
| 386 if (number == value) |
| 387 result = FundamentalValue::create(number); |
| 388 else |
| 389 result = FundamentalValue::create(value); |
| 386 break; | 390 break; |
| 387 } | 391 } |
| 388 case StringLiteral: { | 392 case StringLiteral: { |
| 389 String16 value; | 393 String16 value; |
| 390 bool ok = decodeString(tokenStart + 1, tokenEnd - 1, &value); | 394 bool ok = decodeString(tokenStart + 1, tokenEnd - 1, &value); |
| 391 if (!ok) | 395 if (!ok) |
| 392 return nullptr; | 396 return nullptr; |
| 393 result = StringValue::create(value); | 397 result = StringValue::create(value); |
| 394 break; | 398 break; |
| 395 } | 399 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 | 490 |
| 487 std::unique_ptr<Value> parseJSON(const String16& json) | 491 std::unique_ptr<Value> parseJSON(const String16& json) |
| 488 { | 492 { |
| 489 if (json.isEmpty()) | 493 if (json.isEmpty()) |
| 490 return nullptr; | 494 return nullptr; |
| 491 return parseJSONInternal(json.characters16(), json.length()); | 495 return parseJSONInternal(json.characters16(), json.length()); |
| 492 } | 496 } |
| 493 | 497 |
| 494 } // namespace protocol | 498 } // namespace protocol |
| 495 } // namespace blink | 499 } // namespace blink |
| OLD | NEW |