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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp

Issue 2151083002: DevTools: explicitly differentiate ints vs doubles in the protocol bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 years, 5 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/v8_inspector/V8StringUtil.h" 5 #include "platform/v8_inspector/V8StringUtil.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/V8DebuggerImpl.h" 8 #include "platform/v8_inspector/V8DebuggerImpl.h"
9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
10 #include "platform/v8_inspector/V8Regex.h" 10 #include "platform/v8_inspector/V8Regex.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 218
219 if (!maxDepth) 219 if (!maxDepth)
220 return nullptr; 220 return nullptr;
221 maxDepth--; 221 maxDepth--;
222 222
223 if (value->IsNull() || value->IsUndefined()) 223 if (value->IsNull() || value->IsUndefined())
224 return protocol::Value::null(); 224 return protocol::Value::null();
225 if (value->IsBoolean()) 225 if (value->IsBoolean())
226 return protocol::FundamentalValue::create(value.As<v8::Boolean>()->Value ()); 226 return protocol::FundamentalValue::create(value.As<v8::Boolean>()->Value ());
227 if (value->IsNumber()) 227 if (value->IsNumber()) {
228 return protocol::FundamentalValue::create(value.As<v8::Number>()->Value( )); 228 double doubleValue = value.As<v8::Number>()->Value();
229 int intValue = static_cast<int>(doubleValue);
230 if (intValue == doubleValue)
231 return protocol::FundamentalValue::create(intValue);
232 return protocol::FundamentalValue::create(doubleValue);
233 }
229 if (value->IsString()) 234 if (value->IsString())
230 return protocol::StringValue::create(toProtocolString(value.As<v8::Strin g>())); 235 return protocol::StringValue::create(toProtocolString(value.As<v8::Strin g>()));
231 if (value->IsArray()) { 236 if (value->IsArray()) {
232 v8::Local<v8::Array> array = value.As<v8::Array>(); 237 v8::Local<v8::Array> array = value.As<v8::Array>();
233 std::unique_ptr<protocol::ListValue> inspectorArray = protocol::ListValu e::create(); 238 std::unique_ptr<protocol::ListValue> inspectorArray = protocol::ListValu e::create();
234 uint32_t length = array->Length(); 239 uint32_t length = array->Length();
235 for (uint32_t i = 0; i < length; i++) { 240 for (uint32_t i = 0; i < length; i++) {
236 v8::Local<v8::Value> value; 241 v8::Local<v8::Value> value;
237 if (!array->Get(context, i).ToLocal(&value)) 242 if (!array->Get(context, i).ToLocal(&value))
238 return nullptr; 243 return nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return nullptr; 276 return nullptr;
272 jsonObject->setValue(toProtocolString(propertyName), std::move(prope rtyValue)); 277 jsonObject->setValue(toProtocolString(propertyName), std::move(prope rtyValue));
273 } 278 }
274 return std::move(jsonObject); 279 return std::move(jsonObject);
275 } 280 }
276 NOTREACHED(); 281 NOTREACHED();
277 return nullptr; 282 return nullptr;
278 } 283 }
279 284
280 } // namespace blink 285 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698