Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "V8Document.h" | 32 #include "V8Document.h" |
| 33 | 33 |
| 34 #include "V8CanvasRenderingContext2D.h" | 34 #include "V8CanvasRenderingContext2D.h" |
| 35 #include "V8DOMImplementation.h" | 35 #include "V8DOMImplementation.h" |
| 36 #include "V8Event.h" | |
| 36 #include "V8Node.h" | 37 #include "V8Node.h" |
| 37 #include "V8Touch.h" | 38 #include "V8Touch.h" |
| 38 #include "V8TouchList.h" | 39 #include "V8TouchList.h" |
| 39 #include "V8WebGLRenderingContext.h" | 40 #include "V8WebGLRenderingContext.h" |
| 40 #include "V8XPathNSResolver.h" | 41 #include "V8XPathNSResolver.h" |
| 41 #include "V8XPathResult.h" | 42 #include "V8XPathResult.h" |
| 42 #include "bindings/v8/ExceptionMessages.h" | 43 #include "bindings/v8/ExceptionMessages.h" |
| 43 #include "bindings/v8/ExceptionState.h" | 44 #include "bindings/v8/ExceptionState.h" |
| 44 #include "bindings/v8/ScriptController.h" | 45 #include "bindings/v8/ScriptController.h" |
| 45 #include "bindings/v8/V8Binding.h" | 46 #include "bindings/v8/V8Binding.h" |
| 46 #include "bindings/v8/V8DOMWrapper.h" | 47 #include "bindings/v8/V8DOMWrapper.h" |
| 47 #include "bindings/v8/custom/V8CustomXPathNSResolver.h" | 48 #include "bindings/v8/custom/V8CustomXPathNSResolver.h" |
| 48 #include "core/dom/Document.h" | 49 #include "core/dom/Document.h" |
| 49 #include "core/dom/ExceptionCode.h" | 50 #include "core/dom/ExceptionCode.h" |
| 50 #include "core/dom/Node.h" | 51 #include "core/dom/Node.h" |
| 51 #include "core/dom/TouchList.h" | 52 #include "core/dom/TouchList.h" |
| 52 #include "core/frame/LocalFrame.h" | 53 #include "core/frame/LocalFrame.h" |
| 53 #include "core/html/canvas/CanvasRenderingContext.h" | 54 #include "core/html/canvas/CanvasRenderingContext.h" |
| 54 #include "core/xml/DocumentXPathEvaluator.h" | 55 #include "core/xml/DocumentXPathEvaluator.h" |
| 55 #include "core/xml/XPathNSResolver.h" | 56 #include "core/xml/XPathNSResolver.h" |
| 56 #include "core/xml/XPathResult.h" | 57 #include "core/xml/XPathResult.h" |
| 58 #include "modules/InitModules.h" | |
| 57 #include "wtf/RefPtr.h" | 59 #include "wtf/RefPtr.h" |
| 58 | 60 |
| 59 namespace WebCore { | 61 namespace WebCore { |
| 60 | 62 |
| 61 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 63 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 62 { | 64 { |
| 63 RefPtr<Document> document = V8Document::toNative(info.Holder()); | 65 RefPtr<Document> document = V8Document::toNative(info.Holder()); |
| 64 ASSERT(document); | 66 ASSERT(document); |
| 65 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate", "Document", info.Holder(), info.GetIsolate()); | 67 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate", "Document", info.Holder(), info.GetIsolate()); |
| 66 TOSTRING_VOID(V8StringResource<>, expression, info[0]); | 68 TOSTRING_VOID(V8StringResource<>, expression, info[0]); |
| 67 RefPtr<Node> contextNode = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]); | 69 RefPtr<Node> contextNode = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[1]); |
| 68 | 70 |
| 69 const int resolverArgumentIndex = 2; | 71 const int resolverArgumentIndex = 2; |
| 70 RefPtrWillBeRawPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolv erArgumentIndex], info.GetIsolate()); | 72 RefPtrWillBeRawPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolv erArgumentIndex], info.GetIsolate()); |
| 71 if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) { | 73 if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) { |
| 72 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(resolverArgumentIndex + 1, "XPathNSResolver")); | 74 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(resolverArgumentIndex + 1, "XPathNSResolver")); |
| 73 exceptionState.throwIfNeeded(); | 75 exceptionState.throwIfNeeded(); |
| 74 return; | 76 return; |
| 75 } | 77 } |
| 76 | 78 |
| 77 int type = toInt32(info[3]); | 79 int type = toInt32(info[3]); |
| 78 RefPtrWillBeRawPtr<XPathResult> inResult = V8XPathResult::toNativeWithTypeCh eck(info.GetIsolate(), info[4]); | 80 RefPtrWillBeRawPtr<XPathResult> inResult = V8XPathResult::toNativeWithTypeCh eck(info.GetIsolate(), info[4]); |
| 79 TONATIVE_VOID(RefPtrWillBeRawPtr<XPathResult>, result, DocumentXPathEvaluato r::evaluate(*document, expression, contextNode.get(), resolver.release(), type, inResult.get(), exceptionState)); | 81 TONATIVE_VOID(RefPtrWillBeRawPtr<XPathResult>, result, DocumentXPathEvaluato r::evaluate(*document, expression, contextNode.get(), resolver.release(), type, inResult.get(), exceptionState)); |
| 80 if (exceptionState.throwIfNeeded()) | 82 if (exceptionState.throwIfNeeded()) |
| 81 return; | 83 return; |
| 82 | 84 |
| 83 v8SetReturnValueFast(info, result.release(), document.get()); | 85 v8SetReturnValueFast(info, result.release(), document.get()); |
| 84 } | 86 } |
| 85 | 87 |
| 88 void V8Document::createEventMethodCustom(const v8::FunctionCallbackInfo<v8::Valu e>& info) | |
|
Nils Barth (inactive)
2014/05/27 06:01:27
Please add a comment explaining why there is custo
c.shu
2014/05/27 15:34:07
Done.
| |
| 89 { | |
| 90 ExceptionState exceptionState(ExceptionState::ExecutionContext, "createEvent ", "Document", info.Holder(), info.GetIsolate()); | |
| 91 if (UNLIKELY(info.Length() < 1)) { | |
| 92 throwMinimumArityTypeError(exceptionState, 1, info.Length()); | |
| 93 return; | |
| 94 } | |
| 95 Document* impl = V8Document::toNative(info.Holder()); | |
| 96 V8StringResource<> eventType; | |
| 97 { | |
| 98 TOSTRING_VOID_INTERNAL(eventType, info[0]); | |
| 99 } | |
| 100 RefPtrWillBeRawPtr<Event> result = createEventModules(eventType, exceptionSt ate); | |
| 101 if (exceptionState.throwIfNeeded()) | |
| 102 return; | |
| 103 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); | |
| 104 } | |
| 105 | |
| 86 } // namespace WebCore | 106 } // namespace WebCore |
| OLD | NEW |