| 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 #ifndef LayoutTestHelper_h | 5 #ifndef LayoutTestHelper_h |
| 6 #define LayoutTestHelper_h | 6 #define LayoutTestHelper_h |
| 7 | 7 |
| 8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/frame/FrameHost.h" | 12 #include "core/frame/FrameHost.h" |
| 13 #include "core/frame/FrameView.h" | 13 #include "core/frame/FrameView.h" |
| 14 #include "core/frame/LocalFrameClient.h" | 14 #include "core/frame/LocalFrameClient.h" |
| 15 #include "core/frame/Settings.h" | 15 #include "core/frame/Settings.h" |
| 16 #include "core/html/HTMLElement.h" | 16 #include "core/html/HTMLElement.h" |
| 17 #include "core/layout/api/LayoutAPIShim.h" | 17 #include "core/layout/api/LayoutAPIShim.h" |
| 18 #include "core/layout/api/LayoutViewItem.h" | 18 #include "core/layout/api/LayoutViewItem.h" |
| 19 #include "core/loader/EmptyClients.h" | 19 #include "core/loader/EmptyClients.h" |
| 20 #include "core/testing/DummyPageHolder.h" | 20 #include "core/testing/DummyPageHolder.h" |
| 21 #include "wtf/Allocator.h" | 21 #include "wtf/Allocator.h" |
| 22 | 22 |
| 23 namespace blink { | 23 namespace blink { |
| 24 | 24 |
| 25 class SingleChildFrameLoaderClient final : public EmptyLocalFrameClient { | 25 class SingleChildLocalFrameClient final : public EmptyLocalFrameClient { |
| 26 public: | 26 public: |
| 27 static SingleChildFrameLoaderClient* create() { | 27 static SingleChildLocalFrameClient* create() { |
| 28 return new SingleChildFrameLoaderClient(); | 28 return new SingleChildLocalFrameClient(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 DEFINE_INLINE_VIRTUAL_TRACE() { | 31 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 32 visitor->trace(m_child); | 32 visitor->trace(m_child); |
| 33 EmptyLocalFrameClient::trace(visitor); | 33 EmptyLocalFrameClient::trace(visitor); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // FrameLoaderClient overrides: | 36 // FrameLoaderClient overrides: |
| 37 LocalFrame* firstChild() const override { return m_child.get(); } | 37 LocalFrame* firstChild() const override { return m_child.get(); } |
| 38 LocalFrame* createFrame(const FrameLoadRequest&, | 38 LocalFrame* createFrame(const FrameLoadRequest&, |
| 39 const AtomicString& name, | 39 const AtomicString& name, |
| 40 HTMLFrameOwnerElement*) override; | 40 HTMLFrameOwnerElement*) override; |
| 41 | 41 |
| 42 void didDetachChild() { m_child = nullptr; } | 42 void didDetachChild() { m_child = nullptr; } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 explicit SingleChildFrameLoaderClient() {} | 45 explicit SingleChildLocalFrameClient() {} |
| 46 | 46 |
| 47 Member<LocalFrame> m_child; | 47 Member<LocalFrame> m_child; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class FrameLoaderClientWithParent final : public EmptyLocalFrameClient { | 50 class LocalFrameClientWithParent final : public EmptyLocalFrameClient { |
| 51 public: | 51 public: |
| 52 static FrameLoaderClientWithParent* create(LocalFrame* parent) { | 52 static LocalFrameClientWithParent* create(LocalFrame* parent) { |
| 53 return new FrameLoaderClientWithParent(parent); | 53 return new LocalFrameClientWithParent(parent); |
| 54 } | 54 } |
| 55 | 55 |
| 56 DEFINE_INLINE_VIRTUAL_TRACE() { | 56 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 57 visitor->trace(m_parent); | 57 visitor->trace(m_parent); |
| 58 EmptyLocalFrameClient::trace(visitor); | 58 EmptyLocalFrameClient::trace(visitor); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // FrameClient overrides: | 61 // FrameClient overrides: |
| 62 void detached(FrameDetachType) override; | 62 void detached(FrameDetachType) override; |
| 63 LocalFrame* parent() const override { return m_parent.get(); } | 63 LocalFrame* parent() const override { return m_parent.get(); } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 explicit FrameLoaderClientWithParent(LocalFrame* parent) : m_parent(parent) {} | 66 explicit LocalFrameClientWithParent(LocalFrame* parent) : m_parent(parent) {} |
| 67 | 67 |
| 68 Member<LocalFrame> m_parent; | 68 Member<LocalFrame> m_parent; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 class RenderingTest : public testing::Test { | 71 class RenderingTest : public testing::Test { |
| 72 USING_FAST_MALLOC(RenderingTest); | 72 USING_FAST_MALLOC(RenderingTest); |
| 73 | 73 |
| 74 public: | 74 public: |
| 75 virtual FrameSettingOverrideFunction settingOverrider() const { | 75 virtual FrameSettingOverrideFunction settingOverrider() const { |
| 76 return nullptr; | 76 return nullptr; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void loadAhem(); | 117 void loadAhem(); |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 Persistent<FrameLoaderClient> m_frameLoaderClient; | 120 Persistent<FrameLoaderClient> m_frameLoaderClient; |
| 121 std::unique_ptr<DummyPageHolder> m_pageHolder; | 121 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 } // namespace blink | 124 } // namespace blink |
| 125 | 125 |
| 126 #endif // LayoutTestHelper_h | 126 #endif // LayoutTestHelper_h |
| OLD | NEW |