OLD | NEW |
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.throwIfNeeded() || !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 (!nodes->Set(context, i, toV8(element, info.Holder(), 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]); |
(...skipping 14 matching lines...) Expand all Loading... |
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.throwIfNeeded()) |
403 return; | 403 return; |
404 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).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(); | 409 exceptionState.throwIfNeeded(); |
410 } | 410 } |
411 | 411 |
412 } // namespace blink | 412 } // namespace blink |
OLD | NEW |