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