OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef DummyPageHolder_h | 31 #ifndef DummyPageHolder_h |
32 #define DummyPageHolder_h | 32 #define DummyPageHolder_h |
33 | 33 |
34 #include "core/loader/EmptyClients.h" | 34 #include "core/loader/FrameLoaderClient.h" |
35 #include "core/page/Page.h" | 35 #include "core/page/Page.h" |
36 #include "platform/geometry/IntSize.h" | 36 #include "platform/geometry/IntSize.h" |
37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
38 #include "wtf/FastAllocBase.h" | 38 #include "wtf/FastAllocBase.h" |
39 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
40 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
41 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 class Document; | 45 class Document; |
46 class LocalFrame; | 46 class LocalFrame; |
47 class FrameView; | 47 class FrameView; |
48 class IntSize; | 48 class IntSize; |
49 | 49 |
50 // Creates a dummy Page, LocalFrame, and FrameView whose clients are all no-op. | 50 // Creates a dummy Page, LocalFrame, and FrameView whose clients are all no-op. |
51 // | 51 // |
52 // This class can be used when you write unit tests for components which do not
work correctly without renderers. | 52 // This class can be used when you write unit tests for components which do not
work correctly without renderers. |
53 // To make sure the renderers are created, you need to call |frameView().layout(
)| after you add nodes into | 53 // To make sure the renderers are created, you need to call |frameView().layout(
)| after you add nodes into |
54 // |document()|. | 54 // |document()|. |
55 // | 55 // |
56 // Since DummyPageHolder stores empty clients in it, it must outlive the Page, L
ocalFrame, FrameView and any other objects | 56 // Since DummyPageHolder stores empty clients in it, it must outlive the Page, L
ocalFrame, FrameView and any other objects |
57 // created by it. DummyPageHolder's destructor ensures this condition by checkin
g remaining references to the LocalFrame. | 57 // created by it. DummyPageHolder's destructor ensures this condition by checkin
g remaining references to the LocalFrame. |
58 | 58 |
59 class DummyPageHolder { | 59 class DummyPageHolder { |
60 WTF_MAKE_NONCOPYABLE(DummyPageHolder); | 60 WTF_MAKE_NONCOPYABLE(DummyPageHolder); |
61 WTF_MAKE_FAST_ALLOCATED; | 61 WTF_MAKE_FAST_ALLOCATED; |
62 public: | 62 public: |
63 static PassOwnPtr<DummyPageHolder> create(const IntSize& initialViewSize = I
ntSize(), Page::PageClients* = 0); | 63 static PassOwnPtr<DummyPageHolder> create( |
| 64 const IntSize& initialViewSize = IntSize(), |
| 65 Page::PageClients* = 0, |
| 66 PassOwnPtr<FrameLoaderClient> = PassOwnPtr<FrameLoaderClient>()); |
64 ~DummyPageHolder(); | 67 ~DummyPageHolder(); |
65 | 68 |
66 Page& page() const; | 69 Page& page() const; |
67 LocalFrame& frame() const; | 70 LocalFrame& frame() const; |
68 FrameView& frameView() const; | 71 FrameView& frameView() const; |
69 Document& document() const; | 72 Document& document() const; |
70 | 73 |
71 private: | 74 private: |
72 explicit DummyPageHolder(const IntSize& initialViewSize, Page::PageClients*)
; | 75 explicit DummyPageHolder( |
| 76 const IntSize& initialViewSize, |
| 77 Page::PageClients*, |
| 78 PassOwnPtr<FrameLoaderClient>); |
73 | 79 |
74 OwnPtrWillBePersistent<Page> m_page; | 80 OwnPtrWillBePersistent<Page> m_page; |
75 RefPtr<LocalFrame> m_frame; | 81 RefPtr<LocalFrame> m_frame; |
76 | 82 |
77 Page::PageClients m_pageClients; | 83 Page::PageClients m_pageClients; |
78 EmptyFrameLoaderClient m_frameLoaderClient; | 84 OwnPtr<FrameLoaderClient> m_frameLoaderClient; |
79 }; | 85 }; |
80 | 86 |
81 } // namespace blink | 87 } // namespace blink |
82 | 88 |
83 #endif // DummyPageHolder_h | 89 #endif // DummyPageHolder_h |
OLD | NEW |