| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #ifndef DummyPageHolder_h | 31 #ifndef DummyPageHolder_h |
| 32 #define DummyPageHolder_h | 32 #define DummyPageHolder_h |
| 33 | 33 |
| 34 #include "core/loader/FrameLoaderClient.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/Allocator.h" | 38 #include "wtf/Allocator.h" |
| 39 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
| 40 #include "wtf/OwnPtr.h" | 40 #include <memory> |
| 41 #include "wtf/PassOwnPtr.h" | |
| 42 | 41 |
| 43 namespace blink { | 42 namespace blink { |
| 44 | 43 |
| 45 class Document; | 44 class Document; |
| 46 class LocalFrame; | 45 class LocalFrame; |
| 47 class FrameView; | 46 class FrameView; |
| 48 class IntSize; | 47 class IntSize; |
| 49 class Settings; | 48 class Settings; |
| 50 | 49 |
| 51 typedef void (*FrameSettingOverrideFunction)(Settings&); | 50 typedef void (*FrameSettingOverrideFunction)(Settings&); |
| 52 | 51 |
| 53 extern void RootLayerScrollsFrameSettingOverride(Settings&); | 52 extern void RootLayerScrollsFrameSettingOverride(Settings&); |
| 54 | 53 |
| 55 // Creates a dummy Page, LocalFrame, and FrameView whose clients are all no-op. | 54 // Creates a dummy Page, LocalFrame, and FrameView whose clients are all no-op. |
| 56 // | 55 // |
| 57 // This class can be used when you write unit tests for components which do not
work correctly without layoutObjects. | 56 // This class can be used when you write unit tests for components which do not
work correctly without layoutObjects. |
| 58 // To make sure the layoutObjects are created, you need to call |frameView().lay
out()| after you add nodes into | 57 // To make sure the layoutObjects are created, you need to call |frameView().lay
out()| after you add nodes into |
| 59 // |document()|. | 58 // |document()|. |
| 60 // | 59 // |
| 61 // Since DummyPageHolder stores empty clients in it, it must outlive the Page, L
ocalFrame, FrameView and any other objects | 60 // Since DummyPageHolder stores empty clients in it, it must outlive the Page, L
ocalFrame, FrameView and any other objects |
| 62 // created by it. DummyPageHolder's destructor ensures this condition by checkin
g remaining references to the LocalFrame. | 61 // created by it. DummyPageHolder's destructor ensures this condition by checkin
g remaining references to the LocalFrame. |
| 63 | 62 |
| 64 class DummyPageHolder { | 63 class DummyPageHolder { |
| 65 WTF_MAKE_NONCOPYABLE(DummyPageHolder); | 64 WTF_MAKE_NONCOPYABLE(DummyPageHolder); |
| 66 USING_FAST_MALLOC(DummyPageHolder); | 65 USING_FAST_MALLOC(DummyPageHolder); |
| 67 public: | 66 public: |
| 68 static PassOwnPtr<DummyPageHolder> create( | 67 static std::unique_ptr<DummyPageHolder> create( |
| 69 const IntSize& initialViewSize = IntSize(), | 68 const IntSize& initialViewSize = IntSize(), |
| 70 Page::PageClients* = 0, | 69 Page::PageClients* = 0, |
| 71 FrameLoaderClient* = nullptr, | 70 FrameLoaderClient* = nullptr, |
| 72 FrameSettingOverrideFunction = nullptr); | 71 FrameSettingOverrideFunction = nullptr); |
| 73 ~DummyPageHolder(); | 72 ~DummyPageHolder(); |
| 74 | 73 |
| 75 Page& page() const; | 74 Page& page() const; |
| 76 LocalFrame& frame() const; | 75 LocalFrame& frame() const; |
| 77 FrameView& frameView() const; | 76 FrameView& frameView() const; |
| 78 Document& document() const; | 77 Document& document() const; |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 DummyPageHolder(const IntSize& initialViewSize, Page::PageClients*, FrameLoa
derClient*, FrameSettingOverrideFunction settingOverrider); | 80 DummyPageHolder(const IntSize& initialViewSize, Page::PageClients*, FrameLoa
derClient*, FrameSettingOverrideFunction settingOverrider); |
| 82 | 81 |
| 83 Persistent<Page> m_page; | 82 Persistent<Page> m_page; |
| 84 Persistent<LocalFrame> m_frame; | 83 Persistent<LocalFrame> m_frame; |
| 85 | 84 |
| 86 Persistent<FrameLoaderClient> m_frameLoaderClient; | 85 Persistent<FrameLoaderClient> m_frameLoaderClient; |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace blink | 88 } // namespace blink |
| 90 | 89 |
| 91 #endif // DummyPageHolder_h | 90 #endif // DummyPageHolder_h |
| OLD | NEW |