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

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

Issue 2272613003: binding: Retires ExceptionState::throwIfNeeded(). (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 /* 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (info.Length() < 1) 331 if (info.Length() < 1)
332 return; 332 return;
333 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); 333 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]);
334 if (selector.isEmpty()) 334 if (selector.isEmpty())
335 return; 335 return;
336 Node* node = secondArgumentAsNode(info); 336 Node* node = secondArgumentAsNode(info);
337 if (!node || !node->isContainerNode()) 337 if (!node || !node->isContainerNode())
338 return; 338 return;
339 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$", "Comman dLineAPI", info.Holder(), info.GetIsolate()); 339 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$", "Comman dLineAPI", info.Holder(), info.GetIsolate());
340 Element* element = toContainerNode(node)->querySelector(AtomicString(selecto r), exceptionState); 340 Element* element = toContainerNode(node)->querySelector(AtomicString(selecto r), exceptionState);
341 if (exceptionState.throwIfNeeded()) 341 if (exceptionState.hadException())
342 return; 342 return;
343 if (element) 343 if (element)
344 info.GetReturnValue().Set(toV8(element, info.Holder(), info.GetIsolate() )); 344 info.GetReturnValue().Set(toV8(element, info.Holder(), info.GetIsolate() ));
345 else 345 else
346 info.GetReturnValue().Set(v8::Null(info.GetIsolate())); 346 info.GetReturnValue().Set(v8::Null(info.GetIsolate()));
347 } 347 }
348 348
349 void MainThreadDebugger::querySelectorAllCallback(const v8::FunctionCallbackInfo <v8::Value>& info) 349 void MainThreadDebugger::querySelectorAllCallback(const v8::FunctionCallbackInfo <v8::Value>& info)
350 { 350 {
351 if (info.Length() < 1) 351 if (info.Length() < 1)
352 return; 352 return;
353 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); 353 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]);
354 if (selector.isEmpty()) 354 if (selector.isEmpty())
355 return; 355 return;
356 Node* node = secondArgumentAsNode(info); 356 Node* node = secondArgumentAsNode(info);
357 if (!node || !node->isContainerNode()) 357 if (!node || !node->isContainerNode())
358 return; 358 return;
359 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$$", "Comma ndLineAPI", info.Holder(), info.GetIsolate()); 359 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$$", "Comma ndLineAPI", info.Holder(), info.GetIsolate());
360 // toV8(elementList) doesn't work here, since we need a proper Array instanc e, not NodeList. 360 // toV8(elementList) doesn't work here, since we need a proper Array instanc e, not NodeList.
361 StaticElementList* elementList = toContainerNode(node)->querySelectorAll(Ato micString(selector), exceptionState); 361 StaticElementList* elementList = toContainerNode(node)->querySelectorAll(Ato micString(selector), exceptionState);
362 if (exceptionState.throwIfNeeded() || !elementList) 362 if (exceptionState.hadException() || !elementList)
363 return; 363 return;
364 v8::Isolate* isolate = info.GetIsolate(); 364 v8::Isolate* isolate = info.GetIsolate();
365 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 365 v8::Local<v8::Context> context = isolate->GetCurrentContext();
366 v8::Local<v8::Array> nodes = v8::Array::New(isolate, elementList->length()); 366 v8::Local<v8::Array> nodes = v8::Array::New(isolate, elementList->length());
367 for (size_t i = 0; i < elementList->length(); ++i) { 367 for (size_t i = 0; i < elementList->length(); ++i) {
368 Element* element = elementList->item(i); 368 Element* element = elementList->item(i);
369 if (!createDataPropertyInArray(context, nodes, i, toV8(element, info.Hol der(), info.GetIsolate())).FromMaybe(false)) 369 if (!createDataPropertyInArray(context, nodes, i, toV8(element, info.Hol der(), info.GetIsolate())).FromMaybe(false))
370 return; 370 return;
371 } 371 }
372 info.GetReturnValue().Set(nodes); 372 info.GetReturnValue().Set(nodes);
373 } 373 }
374 374
375 void MainThreadDebugger::xpathSelectorCallback(const v8::FunctionCallbackInfo<v8 ::Value>& info) 375 void MainThreadDebugger::xpathSelectorCallback(const v8::FunctionCallbackInfo<v8 ::Value>& info)
376 { 376 {
377 if (info.Length() < 1) 377 if (info.Length() < 1)
378 return; 378 return;
379 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); 379 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]);
380 if (selector.isEmpty()) 380 if (selector.isEmpty())
381 return; 381 return;
382 Node* node = secondArgumentAsNode(info); 382 Node* node = secondArgumentAsNode(info);
383 if (!node || !node->isContainerNode()) 383 if (!node || !node->isContainerNode())
384 return; 384 return;
385 385
386 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x", "Comma ndLineAPI", info.Holder(), info.GetIsolate()); 386 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x", "Comma ndLineAPI", info.Holder(), info.GetIsolate());
387 XPathResult* result = XPathEvaluator::create()->evaluate(selector, node, nul lptr, XPathResult::kAnyType, ScriptValue(), exceptionState); 387 XPathResult* result = XPathEvaluator::create()->evaluate(selector, node, nul lptr, XPathResult::kAnyType, ScriptValue(), exceptionState);
388 if (exceptionState.throwIfNeeded() || !result) 388 if (exceptionState.hadException() || !result)
389 return; 389 return;
390 if (result->resultType() == XPathResult::kNumberType) { 390 if (result->resultType() == XPathResult::kNumberType) {
391 info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), info .Holder(), info.GetIsolate())); 391 info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), info .Holder(), info.GetIsolate()));
392 } else if (result->resultType() == XPathResult::kStringType) { 392 } else if (result->resultType() == XPathResult::kStringType) {
393 info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), info .Holder(), info.GetIsolate())); 393 info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), info .Holder(), info.GetIsolate()));
394 } else if (result->resultType() == XPathResult::kBooleanType) { 394 } else if (result->resultType() == XPathResult::kBooleanType) {
395 info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), inf o.Holder(), info.GetIsolate())); 395 info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), inf o.Holder(), info.GetIsolate()));
396 } else { 396 } else {
397 v8::Isolate* isolate = info.GetIsolate(); 397 v8::Isolate* isolate = info.GetIsolate();
398 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 398 v8::Local<v8::Context> context = isolate->GetCurrentContext();
399 v8::Local<v8::Array> nodes = v8::Array::New(isolate); 399 v8::Local<v8::Array> nodes = v8::Array::New(isolate);
400 size_t index = 0; 400 size_t index = 0;
401 while (Node* node = result->iterateNext(exceptionState)) { 401 while (Node* node = result->iterateNext(exceptionState)) {
402 if (exceptionState.throwIfNeeded()) 402 if (exceptionState.hadException())
403 return; 403 return;
404 if (!createDataPropertyInArray(context, nodes, index++, toV8(node, i nfo.Holder(), info.GetIsolate())).FromMaybe(false)) 404 if (!createDataPropertyInArray(context, nodes, index++, toV8(node, i nfo.Holder(), info.GetIsolate())).FromMaybe(false))
405 return; 405 return;
406 } 406 }
407 info.GetReturnValue().Set(nodes); 407 info.GetReturnValue().Set(nodes);
408 } 408 }
409 exceptionState.throwIfNeeded();
410 } 409 }
411 410
412 } // namespace blink 411 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698