| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 if (info.Length() < 1) | 320 if (info.Length() < 1) |
| 321 return; | 321 return; |
| 322 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); | 322 String selector = toCoreStringWithUndefinedOrNullCheck(info[0]); |
| 323 if (selector.isEmpty()) | 323 if (selector.isEmpty()) |
| 324 return; | 324 return; |
| 325 Node* node = secondArgumentAsNode(info); | 325 Node* node = secondArgumentAsNode(info); |
| 326 if (!node || !node->isContainerNode()) | 326 if (!node || !node->isContainerNode()) |
| 327 return; | 327 return; |
| 328 | 328 |
| 329 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x", "Comma
ndLineAPI", info.Holder(), info.GetIsolate()); | 329 ExceptionState exceptionState(ExceptionState::ExecutionContext, "$x", "Comma
ndLineAPI", info.Holder(), info.GetIsolate()); |
| 330 XPathResult* result = XPathEvaluator::create()->evaluate(selector, node, nul
lptr, XPathResult::ANY_TYPE, ScriptValue(), exceptionState); | 330 XPathResult* result = XPathEvaluator::create()->evaluate(selector, node, nul
lptr, XPathResult::kAnyType, ScriptValue(), exceptionState); |
| 331 if (exceptionState.throwIfNeeded() || !result) | 331 if (exceptionState.throwIfNeeded() || !result) |
| 332 return; | 332 return; |
| 333 if (result->resultType() == XPathResult::NUMBER_TYPE) { | 333 if (result->resultType() == XPathResult::kNumberType) { |
| 334 info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), info
.Holder(), info.GetIsolate())); | 334 info.GetReturnValue().Set(toV8(result->numberValue(exceptionState), info
.Holder(), info.GetIsolate())); |
| 335 } else if (result->resultType() == XPathResult::STRING_TYPE) { | 335 } else if (result->resultType() == XPathResult::kStringType) { |
| 336 info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), info
.Holder(), info.GetIsolate())); | 336 info.GetReturnValue().Set(toV8(result->stringValue(exceptionState), info
.Holder(), info.GetIsolate())); |
| 337 } else if (result->resultType() == XPathResult::BOOLEAN_TYPE) { | 337 } else if (result->resultType() == XPathResult::kBooleanType) { |
| 338 info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), inf
o.Holder(), info.GetIsolate())); | 338 info.GetReturnValue().Set(toV8(result->booleanValue(exceptionState), inf
o.Holder(), info.GetIsolate())); |
| 339 } else { | 339 } else { |
| 340 v8::Isolate* isolate = info.GetIsolate(); | 340 v8::Isolate* isolate = info.GetIsolate(); |
| 341 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 341 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 342 v8::Local<v8::Array> nodes = v8::Array::New(isolate); | 342 v8::Local<v8::Array> nodes = v8::Array::New(isolate); |
| 343 size_t index = 0; | 343 size_t index = 0; |
| 344 while (Node* node = result->iterateNext(exceptionState)) { | 344 while (Node* node = result->iterateNext(exceptionState)) { |
| 345 if (exceptionState.throwIfNeeded()) | 345 if (exceptionState.throwIfNeeded()) |
| 346 return; | 346 return; |
| 347 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) | 347 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) |
| 348 return; | 348 return; |
| 349 } | 349 } |
| 350 info.GetReturnValue().Set(nodes); | 350 info.GetReturnValue().Set(nodes); |
| 351 } | 351 } |
| 352 exceptionState.throwIfNeeded(); | 352 exceptionState.throwIfNeeded(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace blink | 355 } // namespace blink |
| OLD | NEW |