OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 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 11 matching lines...) Expand all Loading... |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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/V8HTMLDocument.h" | 32 #include "bindings/core/v8/V8Document.h" |
33 | 33 |
34 #include "bindings/core/v8/ScriptController.h" | 34 #include "bindings/core/v8/ScriptController.h" |
35 #include "bindings/core/v8/V8Binding.h" | 35 #include "bindings/core/v8/V8Binding.h" |
36 #include "bindings/core/v8/V8HTMLAllCollection.h" | 36 #include "bindings/core/v8/V8HTMLAllCollection.h" |
37 #include "bindings/core/v8/V8HTMLCollection.h" | 37 #include "bindings/core/v8/V8HTMLCollection.h" |
38 #include "bindings/core/v8/V8Node.h" | 38 #include "bindings/core/v8/V8Node.h" |
39 #include "bindings/core/v8/V8Window.h" | 39 #include "bindings/core/v8/V8Window.h" |
40 #include "core/HTMLNames.h" | 40 #include "core/HTMLNames.h" |
| 41 #include "core/dom/Document.h" |
41 #include "core/frame/LocalDOMWindow.h" | 42 #include "core/frame/LocalDOMWindow.h" |
42 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
43 #include "core/html/HTMLAllCollection.h" | 44 #include "core/html/HTMLAllCollection.h" |
44 #include "core/html/HTMLCollection.h" | 45 #include "core/html/HTMLCollection.h" |
45 #include "core/html/HTMLDocument.h" | |
46 #include "core/html/HTMLIFrameElement.h" | 46 #include "core/html/HTMLIFrameElement.h" |
47 #include "wtf/OwnPtr.h" | 47 #include "wtf/OwnPtr.h" |
48 #include "wtf/RefPtr.h" | 48 #include "wtf/RefPtr.h" |
49 #include "wtf/StdLibExtras.h" | 49 #include "wtf/StdLibExtras.h" |
50 | 50 |
51 namespace blink { | 51 namespace blink { |
52 | 52 |
53 // HTMLDocument ---------------------------------------------------------------- | 53 // HTMLDocument ---------------------------------------------------------------- |
54 | 54 |
55 void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) | 55 void V8Document::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& inf
o) |
56 { | 56 { |
57 HTMLDocument* htmlDocument = V8HTMLDocument::toImpl(info.Holder()); | 57 Document* document = V8Document::toImpl(info.Holder()); |
58 | 58 |
59 if (info.Length() > 2) { | 59 if (info.Length() > 2) { |
60 RefPtrWillBeRawPtr<LocalFrame> frame = htmlDocument->frame(); | 60 RefPtrWillBeRawPtr<LocalFrame> frame = document->frame(); |
61 if (!frame) | 61 if (!frame) |
62 return; | 62 return; |
63 | |
64 // Fetch the global object for the frame. | 63 // Fetch the global object for the frame. |
65 v8::Local<v8::Context> context = toV8Context(frame.get(), DOMWrapperWorl
d::current(info.GetIsolate())); | 64 v8::Local<v8::Context> context = toV8Context(frame.get(), DOMWrapperWorl
d::current(info.GetIsolate())); |
66 // Bail out if we cannot get the context. | 65 // Bail out if we cannot get the context. |
67 if (context.IsEmpty()) | 66 if (context.IsEmpty()) |
68 return; | 67 return; |
69 v8::Local<v8::Object> global = context->Global(); | 68 v8::Local<v8::Object> global = context->Global(); |
70 // Get the open property of the global object. | 69 // Get the open property of the global object. |
71 v8::Local<v8::Value> function = global->Get(v8AtomicString(info.GetIsola
te(), "open")); | 70 v8::Local<v8::Value> function = global->Get(v8AtomicString(info.GetIsola
te(), "open")); |
72 // Failed; return without throwing (new) exception. | 71 // Failed; return without throwing (new) exception. |
73 if (function.IsEmpty()) | 72 if (function.IsEmpty()) |
74 return; | 73 return; |
75 // If the open property is not a function throw a type error. | 74 // If the open property is not a function throw a type error. |
76 if (!function->IsFunction()) { | 75 if (!function->IsFunction()) { |
77 V8ThrowException::throwTypeError(info.GetIsolate(), "open is not a f
unction"); | 76 V8ThrowException::throwTypeError(info.GetIsolate(), "open is not a f
unction"); |
78 return; | 77 return; |
79 } | 78 } |
80 // Wrap up the arguments and call the function. | 79 // Wrap up the arguments and call the function. |
81 OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local<v8::
Value>[info.Length()]); | 80 OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local<v8::
Value>[info.Length()]); |
82 for (int i = 0; i < info.Length(); i++) | 81 for (int i = 0; i < info.Length(); i++) |
83 params[i] = info[i]; | 82 params[i] = info[i]; |
84 | 83 |
85 v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Functi
on>::Cast(function), global, info.Length(), params.get())); | 84 v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Functi
on>::Cast(function), global, info.Length(), params.get())); |
86 return; | 85 return; |
87 } | 86 } |
88 | 87 |
89 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Doc
ument", info.Holder(), info.GetIsolate()); | 88 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Doc
ument", info.Holder(), info.GetIsolate()); |
90 htmlDocument->open(callingDOMWindow(info.GetIsolate())->document(), exceptio
nState); | 89 document->open(callingDOMWindow(info.GetIsolate())->document(), exceptionSta
te); |
91 if (exceptionState.throwIfNeeded()) | 90 if (exceptionState.throwIfNeeded()) |
92 return; | 91 return; |
93 | 92 |
94 v8SetReturnValue(info, info.Holder()); | 93 v8SetReturnValue(info, info.Holder()); |
95 } | 94 } |
96 | 95 |
97 } // namespace blink | 96 } // namespace blink |
OLD | NEW |