OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "core/frame/DOMWindow.h" | 5 #include "core/frame/DOMWindow.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "bindings/core/v8/WindowProxyManager.h" | 9 #include "bindings/core/v8/WindowProxyManager.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 DOMWindow::DOMWindow(Frame& frame) | 34 DOMWindow::DOMWindow(Frame& frame) |
35 : frame_(frame), | 35 : frame_(frame), |
36 window_proxy_manager_(frame.GetWindowProxyManager()), | 36 window_proxy_manager_(frame.GetWindowProxyManager()), |
37 window_is_closing_(false) {} | 37 window_is_closing_(false) {} |
38 | 38 |
39 DOMWindow::~DOMWindow() { | 39 DOMWindow::~DOMWindow() { |
40 // The frame must be disconnected before finalization. | 40 // The frame must be disconnected before finalization. |
41 DCHECK(!frame_); | 41 DCHECK(!frame_); |
| 42 |
| 43 // Because the wrapper object of a DOMWindow is the global proxy, which may |
| 44 // live much longer than the DOMWindow, we need to dissociate all wrappers |
| 45 // for this instance. |
| 46 DOMWrapperWorld::DissociateDOMWindowWrappersInAllWorlds(this); |
42 } | 47 } |
43 | 48 |
44 v8::Local<v8::Object> DOMWindow::Wrap(v8::Isolate*, | 49 v8::Local<v8::Object> DOMWindow::Wrap(v8::Isolate* isolate, |
45 v8::Local<v8::Object> creation_context) { | 50 v8::Local<v8::Object> creation_context) { |
46 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " | 51 // Notice that we explicitly ignore |creation_context| because the DOMWindow |
47 "wrappers must be created at WindowProxy::createContext() and " | 52 // has its own creation context. |
48 "setupWindowPrototypeChain()."; | 53 |
49 return v8::Local<v8::Object>(); | 54 // TODO(yukishiino): Make this function always return the non-empty handle |
| 55 // even if the frame is detached because the global proxy must always exist |
| 56 // per spec. |
| 57 return window_proxy_manager_ |
| 58 ->GetWindowProxy(DOMWrapperWorld::Current(isolate)) |
| 59 ->GlobalProxyIfNotDetached(); |
50 } | 60 } |
51 | 61 |
52 v8::Local<v8::Object> DOMWindow::AssociateWithWrapper( | 62 v8::Local<v8::Object> DOMWindow::AssociateWithWrapper( |
53 v8::Isolate*, | 63 v8::Isolate*, |
54 const WrapperTypeInfo*, | 64 const WrapperTypeInfo*, |
55 v8::Local<v8::Object> wrapper) { | 65 v8::Local<v8::Object> wrapper) { |
56 LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The " | 66 NOTREACHED(); |
57 "wrappers must be created at WindowProxy::createContext() and " | |
58 "setupWindowPrototypeChain()."; | |
59 return v8::Local<v8::Object>(); | 67 return v8::Local<v8::Object>(); |
60 } | 68 } |
61 | 69 |
62 const AtomicString& DOMWindow::InterfaceName() const { | 70 const AtomicString& DOMWindow::InterfaceName() const { |
63 return EventTargetNames::DOMWindow; | 71 return EventTargetNames::DOMWindow; |
64 } | 72 } |
65 | 73 |
66 const DOMWindow* DOMWindow::ToDOMWindow() const { | 74 const DOMWindow* DOMWindow::ToDOMWindow() const { |
67 return this; | 75 return this; |
68 } | 76 } |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 438 } |
431 | 439 |
432 // If we're a top level window, bring the window to the front. | 440 // If we're a top level window, bring the window to the front. |
433 if (GetFrame()->IsMainFrame() && allow_focus) | 441 if (GetFrame()->IsMainFrame() && allow_focus) |
434 page->GetChromeClient().Focus(); | 442 page->GetChromeClient().Focus(); |
435 | 443 |
436 page->GetFocusController().FocusDocumentView(GetFrame(), | 444 page->GetFocusController().FocusDocumentView(GetFrame(), |
437 true /* notifyEmbedder */); | 445 true /* notifyEmbedder */); |
438 } | 446 } |
439 | 447 |
440 v8::Local<v8::Object> DOMWindow::GlobalProxy(DOMWrapperWorld& world) { | |
441 // TODO(yukishiino): Make this function always return the non-empty handle | |
442 // even if the frame is detached because the global proxy must always exist | |
443 // per spec. | |
444 return window_proxy_manager_->GetWindowProxy(world) | |
445 ->GlobalProxyIfNotDetached(); | |
446 } | |
447 | |
448 InputDeviceCapabilitiesConstants* DOMWindow::GetInputDeviceCapabilities() { | 448 InputDeviceCapabilitiesConstants* DOMWindow::GetInputDeviceCapabilities() { |
449 if (!input_capabilities_) | 449 if (!input_capabilities_) |
450 input_capabilities_ = new InputDeviceCapabilitiesConstants; | 450 input_capabilities_ = new InputDeviceCapabilitiesConstants; |
451 return input_capabilities_; | 451 return input_capabilities_; |
452 } | 452 } |
453 | 453 |
454 DEFINE_TRACE(DOMWindow) { | 454 DEFINE_TRACE(DOMWindow) { |
455 visitor->Trace(frame_); | 455 visitor->Trace(frame_); |
456 visitor->Trace(window_proxy_manager_); | 456 visitor->Trace(window_proxy_manager_); |
457 visitor->Trace(input_capabilities_); | 457 visitor->Trace(input_capabilities_); |
458 visitor->Trace(location_); | 458 visitor->Trace(location_); |
459 EventTargetWithInlineData::Trace(visitor); | 459 EventTargetWithInlineData::Trace(visitor); |
460 } | 460 } |
461 | 461 |
462 } // namespace blink | 462 } // namespace blink |
OLD | NEW |