| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2009 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "core/xml/DocumentXPathEvaluator.h" | 54 #include "core/xml/DocumentXPathEvaluator.h" |
| 55 #include "core/xml/XPathNSResolver.h" | 55 #include "core/xml/XPathNSResolver.h" |
| 56 #include "core/xml/XPathResult.h" | 56 #include "core/xml/XPathResult.h" |
| 57 #include "wtf/RefPtr.h" | 57 #include "wtf/RefPtr.h" |
| 58 | 58 |
| 59 namespace WebCore { | 59 namespace WebCore { |
| 60 | 60 |
| 61 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) | 61 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 62 { | 62 { |
| 63 RefPtr<Document> document = V8Document::toNative(info.Holder()); | 63 RefPtr<Document> document = V8Document::toNative(info.Holder()); |
| 64 ASSERT(document); |
| 64 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate",
"Document", info.Holder(), info.GetIsolate()); | 65 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate",
"Document", info.Holder(), info.GetIsolate()); |
| 65 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, expression, info[0]
); | 66 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, expression, info[0]
); |
| 66 RefPtr<Node> contextNode = V8Node::toNativeWithTypeCheck(info.GetIsolate(),
info[1]); | 67 RefPtr<Node> contextNode = V8Node::toNativeWithTypeCheck(info.GetIsolate(),
info[1]); |
| 67 | 68 |
| 68 const int resolverArgumentIndex = 2; | 69 const int resolverArgumentIndex = 2; |
| 69 RefPtrWillBeRawPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolv
erArgumentIndex], info.GetIsolate()); | 70 RefPtrWillBeRawPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolv
erArgumentIndex], info.GetIsolate()); |
| 70 if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) { | 71 if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) { |
| 71 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(resolverArgumentIndex + 1, "XPathNSResolver")); | 72 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(resolverArgumentIndex + 1, "XPathNSResolver")); |
| 72 exceptionState.throwIfNeeded(); | 73 exceptionState.throwIfNeeded(); |
| 73 return; | 74 return; |
| 74 } | 75 } |
| 75 | 76 |
| 76 int type = toInt32(info[3]); | 77 int type = toInt32(info[3]); |
| 77 RefPtrWillBeRawPtr<XPathResult> inResult = V8XPathResult::toNativeWithTypeCh
eck(info.GetIsolate(), info[4]); | 78 RefPtrWillBeRawPtr<XPathResult> inResult = V8XPathResult::toNativeWithTypeCh
eck(info.GetIsolate(), info[4]); |
| 78 V8TRYCATCH_VOID(RefPtrWillBeRawPtr<XPathResult>, result, DocumentXPathEvalua
tor::evaluate(document.get(), expression, contextNode.get(), resolver.release(),
type, inResult.get(), exceptionState)); | 79 V8TRYCATCH_VOID(RefPtrWillBeRawPtr<XPathResult>, result, DocumentXPathEvalua
tor::evaluate(*document, expression, contextNode.get(), resolver.release(), type
, inResult.get(), exceptionState)); |
| 79 if (exceptionState.throwIfNeeded()) | 80 if (exceptionState.throwIfNeeded()) |
| 80 return; | 81 return; |
| 81 | 82 |
| 82 v8SetReturnValueFast(info, result.release(), document.get()); | 83 v8SetReturnValueFast(info, result.release(), document.get()); |
| 83 } | 84 } |
| 84 | 85 |
| 85 } // namespace WebCore | 86 } // namespace WebCore |
| OLD | NEW |