| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/dom/ContextLifecycleObserver.h" | 5 #include "core/dom/ContextLifecycleObserver.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalDOMWindow.h" |
| 8 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 13 ContextClient::ContextClient(ExecutionContext* executionContext) |
| 14 : m_executionContext(executionContext) {} |
| 15 |
| 12 ContextClient::ContextClient(LocalFrame* frame) | 16 ContextClient::ContextClient(LocalFrame* frame) |
| 13 : m_executionContext(frame ? frame->document() : nullptr) {} | 17 : m_executionContext(frame ? frame->document() : nullptr) {} |
| 14 | 18 |
| 15 ExecutionContext* ContextClient::getExecutionContext() const { | 19 ExecutionContext* ContextClient::getExecutionContext() const { |
| 16 return m_executionContext && !m_executionContext->isContextDestroyed() | 20 return m_executionContext && !m_executionContext->isContextDestroyed() |
| 17 ? m_executionContext | 21 ? m_executionContext |
| 18 : nullptr; | 22 : nullptr; |
| 19 } | 23 } |
| 20 | 24 |
| 21 LocalFrame* ContextClient::frame() const { | 25 LocalFrame* ContextClient::frame() const { |
| 22 return m_executionContext && m_executionContext->isDocument() | 26 return m_executionContext && m_executionContext->isDocument() |
| 23 ? toDocument(m_executionContext)->frame() | 27 ? toDocument(m_executionContext)->frame() |
| 24 : nullptr; | 28 : nullptr; |
| 25 } | 29 } |
| 26 | 30 |
| 27 DEFINE_TRACE(ContextClient) { | 31 DEFINE_TRACE(ContextClient) { |
| 28 visitor->trace(m_executionContext); | 32 visitor->trace(m_executionContext); |
| 29 } | 33 } |
| 30 | 34 |
| 31 LocalFrame* ContextLifecycleObserver::frame() const { | 35 LocalFrame* ContextLifecycleObserver::frame() const { |
| 32 return getExecutionContext() && getExecutionContext()->isDocument() | 36 return getExecutionContext() && getExecutionContext()->isDocument() |
| 33 ? toDocument(getExecutionContext())->frame() | 37 ? toDocument(getExecutionContext())->frame() |
| 34 : nullptr; | 38 : nullptr; |
| 35 } | 39 } |
| 40 |
| 41 DOMWindowClient::DOMWindowClient(LocalDOMWindow* window) |
| 42 : m_domWindow(window) {} |
| 43 |
| 44 DOMWindowClient::DOMWindowClient(LocalFrame* frame) |
| 45 : m_domWindow(frame ? frame->domWindow() : nullptr) {} |
| 46 |
| 47 LocalDOMWindow* DOMWindowClient::domWindow() const { |
| 48 return m_domWindow && m_domWindow->frame() ? m_domWindow : nullptr; |
| 36 } | 49 } |
| 50 |
| 51 LocalFrame* DOMWindowClient::frame() const { |
| 52 return m_domWindow ? m_domWindow->frame() : nullptr; |
| 53 } |
| 54 |
| 55 DEFINE_TRACE(DOMWindowClient) { |
| 56 visitor->trace(m_domWindow); |
| 57 } |
| 58 } |
| OLD | NEW |