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 "bindings/core/v8/V8Document.h" | 32 #include "bindings/core/v8/V8Document.h" |
33 | 33 |
34 #include "bindings/core/v8/V8CanvasRenderingContext2D.h" | 34 #include "bindings/core/v8/V8CanvasRenderingContext2D.h" |
35 #include "bindings/core/v8/V8DOMImplementation.h" | 35 #include "bindings/core/v8/V8DOMImplementation.h" |
36 #include "bindings/core/v8/V8Event.h" | |
37 #include "bindings/core/v8/V8Node.h" | 36 #include "bindings/core/v8/V8Node.h" |
38 #include "bindings/core/v8/V8Touch.h" | 37 #include "bindings/core/v8/V8Touch.h" |
39 #include "bindings/core/v8/V8TouchList.h" | 38 #include "bindings/core/v8/V8TouchList.h" |
40 #include "bindings/core/v8/V8WebGLRenderingContext.h" | 39 #include "bindings/core/v8/V8WebGLRenderingContext.h" |
41 #include "bindings/core/v8/V8XPathNSResolver.h" | 40 #include "bindings/core/v8/V8XPathNSResolver.h" |
42 #include "bindings/core/v8/V8XPathResult.h" | 41 #include "bindings/core/v8/V8XPathResult.h" |
43 #include "bindings/v8/ExceptionMessages.h" | 42 #include "bindings/v8/ExceptionMessages.h" |
44 #include "bindings/v8/ExceptionState.h" | 43 #include "bindings/v8/ExceptionState.h" |
45 #include "bindings/v8/ScriptController.h" | 44 #include "bindings/v8/ScriptController.h" |
46 #include "bindings/v8/V8Binding.h" | 45 #include "bindings/v8/V8Binding.h" |
47 #include "bindings/v8/V8DOMWrapper.h" | 46 #include "bindings/v8/V8DOMWrapper.h" |
48 #include "bindings/v8/custom/V8CustomXPathNSResolver.h" | 47 #include "bindings/v8/custom/V8CustomXPathNSResolver.h" |
49 #include "core/dom/Document.h" | 48 #include "core/dom/Document.h" |
50 #include "core/dom/ExceptionCode.h" | 49 #include "core/dom/ExceptionCode.h" |
51 #include "core/dom/Node.h" | 50 #include "core/dom/Node.h" |
52 #include "core/dom/TouchList.h" | 51 #include "core/dom/TouchList.h" |
53 #include "core/frame/LocalFrame.h" | 52 #include "core/frame/LocalFrame.h" |
54 #include "core/html/canvas/CanvasRenderingContext.h" | 53 #include "core/html/canvas/CanvasRenderingContext.h" |
55 #include "core/xml/DocumentXPathEvaluator.h" | 54 #include "core/xml/DocumentXPathEvaluator.h" |
56 #include "core/xml/XPathNSResolver.h" | 55 #include "core/xml/XPathNSResolver.h" |
57 #include "core/xml/XPathResult.h" | 56 #include "core/xml/XPathResult.h" |
58 #include "modules/InitModules.h" | |
59 #include "wtf/RefPtr.h" | 57 #include "wtf/RefPtr.h" |
60 | 58 |
61 namespace WebCore { | 59 namespace WebCore { |
62 | 60 |
63 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) | 61 void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) |
64 { | 62 { |
65 RefPtr<Document> document = V8Document::toNative(info.Holder()); | 63 RefPtr<Document> document = V8Document::toNative(info.Holder()); |
66 ASSERT(document); | 64 ASSERT(document); |
67 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate",
"Document", info.Holder(), info.GetIsolate()); | 65 ExceptionState exceptionState(ExceptionState::ExecutionContext, "evaluate",
"Document", info.Holder(), info.GetIsolate()); |
68 TOSTRING_VOID(V8StringResource<>, expression, info[0]); | 66 TOSTRING_VOID(V8StringResource<>, expression, info[0]); |
69 RefPtr<Node> contextNode = V8Node::toNativeWithTypeCheck(info.GetIsolate(),
info[1]); | 67 RefPtr<Node> contextNode = V8Node::toNativeWithTypeCheck(info.GetIsolate(),
info[1]); |
70 | 68 |
71 const int resolverArgumentIndex = 2; | 69 const int resolverArgumentIndex = 2; |
72 RefPtrWillBeRawPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolv
erArgumentIndex], info.GetIsolate()); | 70 RefPtrWillBeRawPtr<XPathNSResolver> resolver = toXPathNSResolver(info[resolv
erArgumentIndex], info.GetIsolate()); |
73 if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) { | 71 if (!resolver && !isUndefinedOrNull(info[resolverArgumentIndex])) { |
74 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(resolverArgumentIndex + 1, "XPathNSResolver")); | 72 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(resolverArgumentIndex + 1, "XPathNSResolver")); |
75 exceptionState.throwIfNeeded(); | 73 exceptionState.throwIfNeeded(); |
76 return; | 74 return; |
77 } | 75 } |
78 | 76 |
79 int type = toInt32(info[3]); | 77 int type = toInt32(info[3]); |
80 RefPtrWillBeRawPtr<XPathResult> inResult = V8XPathResult::toNativeWithTypeCh
eck(info.GetIsolate(), info[4]); | 78 RefPtrWillBeRawPtr<XPathResult> inResult = V8XPathResult::toNativeWithTypeCh
eck(info.GetIsolate(), info[4]); |
81 TONATIVE_VOID(RefPtrWillBeRawPtr<XPathResult>, result, DocumentXPathEvaluato
r::evaluate(*document, expression, contextNode.get(), resolver.release(), type,
inResult.get(), exceptionState)); | 79 TONATIVE_VOID(RefPtrWillBeRawPtr<XPathResult>, result, DocumentXPathEvaluato
r::evaluate(*document, expression, contextNode.get(), resolver.release(), type,
inResult.get(), exceptionState)); |
82 if (exceptionState.throwIfNeeded()) | 80 if (exceptionState.throwIfNeeded()) |
83 return; | 81 return; |
84 | 82 |
85 v8SetReturnValueFast(info, result.release(), document.get()); | 83 v8SetReturnValueFast(info, result.release(), document.get()); |
86 } | 84 } |
87 | 85 |
88 // Customize createEvent so it can call createEventModules in modules. | |
89 // FIXME: Use method registration approach instead. http://crbug.com/358074 | |
90 void V8Document::createEventMethodCustom(const v8::FunctionCallbackInfo<v8::Valu
e>& info) | |
91 { | |
92 ExceptionState exceptionState(ExceptionState::ExecutionContext, "createEvent
", "Document", info.Holder(), info.GetIsolate()); | |
93 if (UNLIKELY(info.Length() < 1)) { | |
94 throwMinimumArityTypeError(exceptionState, 1, info.Length()); | |
95 return; | |
96 } | |
97 Document* impl = V8Document::toNative(info.Holder()); | |
98 V8StringResource<> eventType; | |
99 { | |
100 TOSTRING_VOID_INTERNAL(eventType, info[0]); | |
101 } | |
102 RefPtrWillBeRawPtr<Event> result = createEventModules(eventType, exceptionSt
ate); | |
103 if (exceptionState.hadException()) { | |
104 exceptionState.throwIfNeeded(); | |
105 return; | |
106 } | |
107 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); | |
108 } | |
109 | |
110 } // namespace WebCore | 86 } // namespace WebCore |
OLD | NEW |