Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ToV8ForCore.cpp

Issue 2713623002: v8binding: Makes ToV8(window) work without a frame. (Closed)
Patch Set: Added a TODO comment. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ToV8ForCore.h" 5 #include "bindings/core/v8/ToV8ForCore.h"
6 6
7 #include "bindings/core/v8/WindowProxy.h" 7 #include "bindings/core/v8/WindowProxy.h"
8 #include "core/events/EventTarget.h" 8 #include "core/events/EventTarget.h"
9 #include "core/frame/DOMWindow.h" 9 #include "core/frame/DOMWindow.h"
10 #include "core/frame/Frame.h" 10 #include "core/frame/Frame.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 v8::Local<v8::Value> ToV8(DOMWindow* window, 14 v8::Local<v8::Value> ToV8(DOMWindow* window,
15 v8::Local<v8::Object> creation_context, 15 v8::Local<v8::Object> creation_context,
16 v8::Isolate* isolate) { 16 v8::Isolate* isolate) {
17 // Notice that we explicitly ignore creationContext because the DOMWindow 17 // Notice that we explicitly ignore creationContext because the DOMWindow
18 // has its own creationContext. 18 // has its own creationContext.
19 19
20 if (UNLIKELY(!window)) 20 if (UNLIKELY(!window))
21 return v8::Null(isolate); 21 return v8::Null(isolate);
22 // Initializes environment of a frame, and return the global object
23 // of the frame.
24 Frame* frame = window->GetFrame();
25 if (!frame)
26 return V8Undefined();
27 22
28 return frame->GetWindowProxy(DOMWrapperWorld::Current(isolate)) 23 return window->GlobalProxy(DOMWrapperWorld::Current(isolate));
29 ->GlobalProxyIfNotDetached();
30 } 24 }
31 25
32 v8::Local<v8::Value> ToV8(EventTarget* impl, 26 v8::Local<v8::Value> ToV8(EventTarget* impl,
33 v8::Local<v8::Object> creation_context, 27 v8::Local<v8::Object> creation_context,
34 v8::Isolate* isolate) { 28 v8::Isolate* isolate) {
35 if (UNLIKELY(!impl)) 29 if (UNLIKELY(!impl))
36 return v8::Null(isolate); 30 return v8::Null(isolate);
37 31
38 if (impl->InterfaceName() == EventTargetNames::DOMWindow) 32 if (impl->InterfaceName() == EventTargetNames::DOMWindow)
39 return ToV8(static_cast<DOMWindow*>(impl), creation_context, isolate); 33 return ToV8(static_cast<DOMWindow*>(impl), creation_context, isolate);
40 return ToV8(static_cast<ScriptWrappable*>(impl), creation_context, isolate); 34 return ToV8(static_cast<ScriptWrappable*>(impl), creation_context, isolate);
41 } 35 }
42 36
43 } // namespace blink 37 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698