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

Side by Side Diff: third_party/WebKit/Source/core/inspector/MainThreadDebugger.cpp

Issue 2595543003: Rename toV8(...) function in Blink to ToV8(...). (Closed)
Patch Set: Rebasing... Created 3 years, 11 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 /* 1 /*
2 * Copyright (c) 2011 Google Inc. All rights reserved. 2 * Copyright (c) 2011 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 consoleAPITypeToMessageLevel(type), 321 consoleAPITypeToMessageLevel(type),
322 toCoreString(message), location.get()); 322 toCoreString(message), location.get());
323 } 323 }
324 324
325 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo( 325 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(
326 v8::Isolate* isolate, 326 v8::Isolate* isolate,
327 v8::Local<v8::Context> context) { 327 v8::Local<v8::Context> context) {
328 ExecutionContext* executionContext = toExecutionContext(context); 328 ExecutionContext* executionContext = toExecutionContext(context);
329 DCHECK(executionContext); 329 DCHECK(executionContext);
330 ASSERT(executionContext->isDocument()); 330 ASSERT(executionContext->isDocument());
331 return toV8(MemoryInfo::create(), context->Global(), isolate); 331 return ToV8(MemoryInfo::create(), context->Global(), isolate);
332 } 332 }
333 333
334 void MainThreadDebugger::installAdditionalCommandLineAPI( 334 void MainThreadDebugger::installAdditionalCommandLineAPI(
335 v8::Local<v8::Context> context, 335 v8::Local<v8::Context> context,
336 v8::Local<v8::Object> object) { 336 v8::Local<v8::Object> object) {
337 ThreadDebugger::installAdditionalCommandLineAPI(context, object); 337 ThreadDebugger::installAdditionalCommandLineAPI(context, object);
338 createFunctionProperty( 338 createFunctionProperty(
339 context, object, "$", MainThreadDebugger::querySelectorCallback, 339 context, object, "$", MainThreadDebugger::querySelectorCallback,
340 "function $(selector, [startNode]) { [Command Line API] }"); 340 "function $(selector, [startNode]) { [Command Line API] }");
341 createFunctionProperty( 341 createFunctionProperty(
(...skipping 28 matching lines...) Expand all
370 if (!node || !node->isContainerNode()) 370 if (!node || !node->isContainerNode())
371 return; 371 return;
372 ExceptionState exceptionState(info.GetIsolate(), 372 ExceptionState exceptionState(info.GetIsolate(),
373 ExceptionState::ExecutionContext, 373 ExceptionState::ExecutionContext,
374 "CommandLineAPI", "$"); 374 "CommandLineAPI", "$");
375 Element* element = toContainerNode(node)->querySelector( 375 Element* element = toContainerNode(node)->querySelector(
376 AtomicString(selector), exceptionState); 376 AtomicString(selector), exceptionState);
377 if (exceptionState.hadException()) 377 if (exceptionState.hadException())
378 return; 378 return;
379 if (element) 379 if (element)
380 info.GetReturnValue().Set(toV8(element, info.Holder(), info.GetIsolate())); 380 info.GetReturnValue().Set(ToV8(element, info.Holder(), info.GetIsolate()));
381 else 381 else
382 info.GetReturnValue().Set(v8::Null(info.GetIsolate())); 382 info.GetReturnValue().Set(v8::Null(info.GetIsolate()));
383 } 383 }
384 384
385 void MainThreadDebugger::querySelectorAllCallback( 385 void MainThreadDebugger::querySelectorAllCallback(
386 const v8::FunctionCallbackInfo<v8::Value>& info) { 386 const v8::FunctionCallbackInfo<v8::Value>& info) {
387 if (info.Length() < 1) 387 if (info.Length() < 1)
388 return; 388 return;
389 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); 389 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]);
390 if (selector.isEmpty()) 390 if (selector.isEmpty())
391 return; 391 return;
392 Node* node = secondArgumentAsNode(info); 392 Node* node = secondArgumentAsNode(info);
393 if (!node || !node->isContainerNode()) 393 if (!node || !node->isContainerNode())
394 return; 394 return;
395 ExceptionState exceptionState(info.GetIsolate(), 395 ExceptionState exceptionState(info.GetIsolate(),
396 ExceptionState::ExecutionContext, 396 ExceptionState::ExecutionContext,
397 "CommandLineAPI", "$$"); 397 "CommandLineAPI", "$$");
398 // toV8(elementList) doesn't work here, since we need a proper Array instance, 398 // ToV8(elementList) doesn't work here, since we need a proper Array instance,
399 // not NodeList. 399 // not NodeList.
400 StaticElementList* elementList = toContainerNode(node)->querySelectorAll( 400 StaticElementList* elementList = toContainerNode(node)->querySelectorAll(
401 AtomicString(selector), exceptionState); 401 AtomicString(selector), exceptionState);
402 if (exceptionState.hadException() || !elementList) 402 if (exceptionState.hadException() || !elementList)
403 return; 403 return;
404 v8::Isolate* isolate = info.GetIsolate(); 404 v8::Isolate* isolate = info.GetIsolate();
405 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 405 v8::Local<v8::Context> context = isolate->GetCurrentContext();
406 v8::Local<v8::Array> nodes = v8::Array::New(isolate, elementList->length()); 406 v8::Local<v8::Array> nodes = v8::Array::New(isolate, elementList->length());
407 for (size_t i = 0; i < elementList->length(); ++i) { 407 for (size_t i = 0; i < elementList->length(); ++i) {
408 Element* element = elementList->item(i); 408 Element* element = elementList->item(i);
409 if (!createDataPropertyInArray( 409 if (!createDataPropertyInArray(
410 context, nodes, i, toV8(element, info.Holder(), info.GetIsolate())) 410 context, nodes, i, ToV8(element, info.Holder(), info.GetIsolate()))
411 .FromMaybe(false)) 411 .FromMaybe(false))
412 return; 412 return;
413 } 413 }
414 info.GetReturnValue().Set(nodes); 414 info.GetReturnValue().Set(nodes);
415 } 415 }
416 416
417 void MainThreadDebugger::xpathSelectorCallback( 417 void MainThreadDebugger::xpathSelectorCallback(
418 const v8::FunctionCallbackInfo<v8::Value>& info) { 418 const v8::FunctionCallbackInfo<v8::Value>& info) {
419 if (info.Length() < 1) 419 if (info.Length() < 1)
420 return; 420 return;
421 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); 421 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]);
422 if (selector.isEmpty()) 422 if (selector.isEmpty())
423 return; 423 return;
424 Node* node = secondArgumentAsNode(info); 424 Node* node = secondArgumentAsNode(info);
425 if (!node || !node->isContainerNode()) 425 if (!node || !node->isContainerNode())
426 return; 426 return;
427 427
428 ExceptionState exceptionState(info.GetIsolate(), 428 ExceptionState exceptionState(info.GetIsolate(),
429 ExceptionState::ExecutionContext, 429 ExceptionState::ExecutionContext,
430 "CommandLineAPI", "$x"); 430 "CommandLineAPI", "$x");
431 XPathResult* result = XPathEvaluator::create()->evaluate( 431 XPathResult* result = XPathEvaluator::create()->evaluate(
432 selector, node, nullptr, XPathResult::kAnyType, ScriptValue(), 432 selector, node, nullptr, XPathResult::kAnyType, ScriptValue(),
433 exceptionState); 433 exceptionState);
434 if (exceptionState.hadException() || !result) 434 if (exceptionState.hadException() || !result)
435 return; 435 return;
436 if (result->resultType() == XPathResult::kNumberType) { 436 if (result->resultType() == XPathResult::kNumberType) {
437 info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), 437 info.GetReturnValue().Set(ToV8(result->numberValue(exceptionState),
438 info.Holder(), info.GetIsolate())); 438 info.Holder(), info.GetIsolate()));
439 } else if (result->resultType() == XPathResult::kStringType) { 439 } else if (result->resultType() == XPathResult::kStringType) {
440 info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), 440 info.GetReturnValue().Set(ToV8(result->stringValue(exceptionState),
441 info.Holder(), info.GetIsolate())); 441 info.Holder(), info.GetIsolate()));
442 } else if (result->resultType() == XPathResult::kBooleanType) { 442 } else if (result->resultType() == XPathResult::kBooleanType) {
443 info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), 443 info.GetReturnValue().Set(ToV8(result->booleanValue(exceptionState),
444 info.Holder(), info.GetIsolate())); 444 info.Holder(), info.GetIsolate()));
445 } else { 445 } else {
446 v8::Isolate* isolate = info.GetIsolate(); 446 v8::Isolate* isolate = info.GetIsolate();
447 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 447 v8::Local<v8::Context> context = isolate->GetCurrentContext();
448 v8::Local<v8::Array> nodes = v8::Array::New(isolate); 448 v8::Local<v8::Array> nodes = v8::Array::New(isolate);
449 size_t index = 0; 449 size_t index = 0;
450 while (Node* node = result->iterateNext(exceptionState)) { 450 while (Node* node = result->iterateNext(exceptionState)) {
451 if (exceptionState.hadException()) 451 if (exceptionState.hadException())
452 return; 452 return;
453 if (!createDataPropertyInArray( 453 if (!createDataPropertyInArray(
454 context, nodes, index++, 454 context, nodes, index++,
455 toV8(node, info.Holder(), info.GetIsolate())) 455 ToV8(node, info.Holder(), info.GetIsolate()))
456 .FromMaybe(false)) 456 .FromMaybe(false))
457 return; 457 return;
458 } 458 }
459 info.GetReturnValue().Set(nodes); 459 info.GetReturnValue().Set(nodes);
460 } 460 }
461 } 461 }
462 462
463 } // namespace blink 463 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698