OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "core/loader/FrameLoader.h" | 25 #include "core/loader/FrameLoader.h" |
26 #include "core/page/Page.h" | 26 #include "core/page/Page.h" |
27 #include "public/platform/Platform.h" | 27 #include "public/platform/Platform.h" |
28 #include "public/platform/WebScheduler.h" | 28 #include "public/platform/WebScheduler.h" |
29 #include "wtf/HashSet.h" | 29 #include "wtf/HashSet.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) | 33 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) |
34 { | 34 { |
35 const WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page>>& pages = Pag
e::ordinaryPages(); | 35 for (const Page* page : Page::ordinaryPages()) { |
36 for (const Page* page : pages) { | |
37 if (page == exclusion || page->defersLoading()) | 36 if (page == exclusion || page->defersLoading()) |
38 continue; | 37 continue; |
39 | 38 |
40 if (page->mainFrame()->isLocalFrame()) { | 39 if (!page->mainFrame()->isLocalFrame()) |
41 m_deferredFrames.append(page->deprecatedLocalMainFrame()); | 40 continue; |
42 | 41 |
43 // Ensure that we notify the client if the initial empty document is
accessed before | 42 m_deferredFrames.append(page->deprecatedLocalMainFrame()); |
44 // showing anything modal, to prevent spoofs while the modal window
or sheet is visible. | 43 |
45 page->deprecatedLocalMainFrame()->loader().notifyIfInitialDocumentAc
cessed(); | 44 // Ensure that we notify the client if the initial empty document is acc
essed before |
46 } | 45 // showing anything modal, to prevent spoofs while the modal window or s
heet is visible. |
| 46 page->deprecatedLocalMainFrame()->loader().notifyIfInitialDocumentAccess
ed(); |
47 } | 47 } |
48 | 48 |
49 size_t count = m_deferredFrames.size(); | 49 setDefersLoading(true); |
50 for (size_t i = 0; i < count; ++i) { | |
51 if (Page* page = m_deferredFrames[i]->page()) | |
52 page->setDefersLoading(true); | |
53 } | |
54 Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); | 50 Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); |
55 } | 51 } |
56 | 52 |
57 void ScopedPageLoadDeferrer::detach() | |
58 { | |
59 for (size_t i = 0; i < m_deferredFrames.size(); ++i) { | |
60 if (Page* page = m_deferredFrames[i]->page()) | |
61 page->setDefersLoading(false); | |
62 } | |
63 | |
64 Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); | |
65 } | |
66 | |
67 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() | 53 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() |
68 { | 54 { |
69 detach(); | 55 setDefersLoading(false); |
| 56 Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); |
| 57 } |
| 58 |
| 59 void ScopedPageLoadDeferrer::setDefersLoading(bool isDeferred) |
| 60 { |
| 61 for (const auto& frame : m_deferredFrames) { |
| 62 if (Page* page = frame->page()) |
| 63 page->setDefersLoading(isDeferred); |
| 64 } |
70 } | 65 } |
71 | 66 |
72 } // namespace blink | 67 } // namespace blink |
OLD | NEW |