| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (info.Length() < 1) | 364 if (info.Length() < 1) |
| 365 return; | 365 return; |
| 366 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); | 366 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); |
| 367 if (selector.isEmpty()) | 367 if (selector.isEmpty()) |
| 368 return; | 368 return; |
| 369 Node* node = secondArgumentAsNode(info); | 369 Node* node = secondArgumentAsNode(info); |
| 370 if (!node || !node->isContainerNode()) | 370 if (!node || !node->isContainerNode()) |
| 371 return; | 371 return; |
| 372 | 372 |
| 373 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x", "Comma
ndLineAPI", info.Holder(), info.GetIsolate()); | 373 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x", "Comma
ndLineAPI", info.Holder(), info.GetIsolate()); |
| 374 XPathResult* result = XPathEvaluator::create()->evaluate(selector, node, nul
lptr, XPathResult::ANY_TYPE, ScriptValue(), exceptionState); | 374 XPathResult* result = XPathEvaluator::create()->evaluate(selector, node, nul
lptr, XPathResult::kAnyType, ScriptValue(), exceptionState); |
| 375 if (exceptionState.throwIfNeeded() || !result) | 375 if (exceptionState.throwIfNeeded() || !result) |
| 376 return; | 376 return; |
| 377 if (result->resultType() == XPathResult::NUMBER_TYPE) { | 377 if (result->resultType() == XPathResult::kNumberType) { |
| 378 info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), info
.Holder(), info.GetIsolate())); | 378 info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), info
.Holder(), info.GetIsolate())); |
| 379 } else if (result->resultType() == XPathResult::STRING_TYPE) { | 379 } else if (result->resultType() == XPathResult::kStringType) { |
| 380 info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), info
.Holder(), info.GetIsolate())); | 380 info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), info
.Holder(), info.GetIsolate())); |
| 381 } else if (result->resultType() == XPathResult::BOOLEAN_TYPE) { | 381 } else if (result->resultType() == XPathResult::kBooleanType) { |
| 382 info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), inf
o.Holder(), info.GetIsolate())); | 382 info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), inf
o.Holder(), info.GetIsolate())); |
| 383 } else { | 383 } else { |
| 384 v8::Isolate* isolate = info.GetIsolate(); | 384 v8::Isolate* isolate = info.GetIsolate(); |
| 385 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 385 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 386 v8::Local<v8::Array> nodes = v8::Array::New(isolate); | 386 v8::Local<v8::Array> nodes = v8::Array::New(isolate); |
| 387 size_t index = 0; | 387 size_t index = 0; |
| 388 while (Node* node = result->iterateNext(exceptionState)) { | 388 while (Node* node = result->iterateNext(exceptionState)) { |
| 389 if (exceptionState.throwIfNeeded()) | 389 if (exceptionState.throwIfNeeded()) |
| 390 return; | 390 return; |
| 391 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) | 391 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) |
| 392 return; | 392 return; |
| 393 } | 393 } |
| 394 info.GetReturnValue().Set(nodes); | 394 info.GetReturnValue().Set(nodes); |
| 395 } | 395 } |
| 396 exceptionState.throwIfNeeded(); | 396 exceptionState.throwIfNeeded(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace blink | 399 } // namespace blink |
| OLD | NEW |