OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "bindings/core/v8/ToV8.h" | |
7 | |
8 #include "core/events/EventTarget.h" | |
9 #include "core/frame/DOMWindow.h" | |
10 #include "core/workers/WorkerGlobalScope.h" | |
11 | |
12 namespace blink { | |
13 | |
14 v8::Handle<v8::Value> toV8(DOMWindow* window, v8::Handle<v8::Object> creationCon text, v8::Isolate* isolate) | |
15 { | |
16 // Notice that we explicitly ignore creationContext because the DOMWindow is its own creationContext. | |
haraken
2015/04/24 11:57:38
is => has
Yuki
2015/04/27 12:42:33
Done.
| |
17 | |
18 if (!window) | |
19 return v8::Null(isolate); | |
20 // Initializes environment of a frame, and return the global object | |
21 // of the frame. | |
22 Frame * frame = window->frame(); | |
23 if (!frame) | |
24 return v8Undefined(); | |
25 | |
26 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current (isolate)); | |
27 if (context.IsEmpty()) | |
28 return v8Undefined(); | |
29 | |
30 v8::Local<v8::Object> global = context->Global(); | |
31 ASSERT(!global.IsEmpty()); | |
32 return global; | |
33 } | |
34 | |
35 v8::Handle<v8::Value> toV8(EventTarget* impl, v8::Handle<v8::Object> creationCon text, v8::Isolate* isolate) | |
36 { | |
37 if (UNLIKELY(!impl)) | |
haraken
2015/04/24 11:57:38
Remove UNLIKELY for consistency.
Yuki
2015/04/27 12:42:33
Well, other versions such as ScriptWrappable* and
haraken
2015/04/28 00:56:42
Sounds reasonable, then let's add UNLIKELY.
| |
38 return v8::Null(isolate); | |
39 | |
40 if (impl->interfaceName() == EventTargetNames::DOMWindow) | |
41 return toV8(static_cast<DOMWindow*>(impl), creationContext, isolate); | |
42 return toV8(static_cast<ScriptWrappable*>(impl), creationContext, isolate); | |
43 } | |
44 | |
45 v8::Handle<v8::Value> toV8(WorkerGlobalScope* impl, v8::Handle<v8::Object> creat ionContext, v8::Isolate* isolate) | |
46 { | |
47 // Notice that we explicitly ignore creationContext because the WorkerGlobal Scope is its own creationContext. | |
haraken
2015/04/24 11:57:38
is => has
Yuki
2015/04/27 12:42:33
Done.
| |
48 | |
49 if (!impl) | |
50 return v8::Null(isolate); | |
51 | |
52 WorkerScriptController* script = impl->script(); | |
53 if (!script) | |
54 return v8::Null(isolate); | |
55 | |
56 v8::Local<v8::Object> global = script->context()->Global(); | |
57 ASSERT(!global.IsEmpty()); | |
58 return global; | |
59 } | |
60 | |
61 } // namespace blink | |
OLD | NEW |