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 11 matching lines...) Expand all Loading... |
22 #include "core/page/ScopedPageLoadDeferrer.h" | 22 #include "core/page/ScopedPageLoadDeferrer.h" |
23 | 23 |
24 #include "core/dom/Document.h" | 24 #include "core/dom/Document.h" |
25 #include "core/frame/LocalFrame.h" | 25 #include "core/frame/LocalFrame.h" |
26 #include "core/loader/FrameLoader.h" | 26 #include "core/loader/FrameLoader.h" |
27 #include "core/page/Page.h" | 27 #include "core/page/Page.h" |
28 #include "wtf/HashSet.h" | 28 #include "wtf/HashSet.h" |
29 | 29 |
30 namespace WebCore { | 30 namespace WebCore { |
31 | 31 |
32 using namespace std; | |
33 | |
34 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) | 32 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) |
35 { | 33 { |
36 const HashSet<Page*>& pages = Page::ordinaryPages(); | 34 const HashSet<Page*>& pages = Page::ordinaryPages(); |
37 | 35 |
38 HashSet<Page*>::const_iterator end = pages.end(); | 36 HashSet<Page*>::const_iterator end = pages.end(); |
39 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { | 37 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { |
40 Page* page = *it; | 38 Page* page = *it; |
41 if (page == exclusion || page->defersLoading()) | 39 if (page == exclusion || page->defersLoading()) |
42 continue; | 40 continue; |
43 | 41 |
44 m_deferredFrames.append(page->mainFrame()); | 42 m_deferredFrames.append(page->mainFrame()); |
45 | 43 |
46 // Ensure that we notify the client if the initial empty document is acc
essed before | 44 // Ensure that we notify the client if the initial empty document is acc
essed before |
47 // showing anything modal, to prevent spoofs while the modal window or s
heet is visible. | 45 // showing anything modal, to prevent spoofs while the modal window or s
heet is visible. |
48 page->mainFrame()->loader().notifyIfInitialDocumentAccessed(); | 46 page->mainFrame()->loader().notifyIfInitialDocumentAccessed(); |
49 | 47 |
50 // This code is not logically part of load deferring, but we do not want
JS code executed | 48 // This code is not logically part of load deferring, but we do not want
JS code executed |
51 // beneath modal windows or sheets, which is exactly when ScopedPageLoad
Deferrer is used. | 49 // beneath modal windows or sheets, which is exactly when ScopedPageLoad
Deferrer is used. |
52 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav
erseNext()) { | 50 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav
erseNext()) { |
53 if (frame->isLocalFrame()) | 51 if (frame->isLocalFrame()) |
54 toLocalFrame(frame)->document()->suspendScheduledTasks(); | 52 toLocalFrame(frame)->document()->suspendScheduledTasks(); |
55 } | 53 } |
56 } | 54 } |
57 | 55 |
58 size_t count = m_deferredFrames.size(); | 56 std::size_t count = m_deferredFrames.size(); |
59 for (size_t i = 0; i < count; ++i) { | 57 for (std::size_t i = 0; i < count; ++i) { |
60 if (Page* page = m_deferredFrames[i]->page()) | 58 if (Page* page = m_deferredFrames[i]->page()) |
61 page->setDefersLoading(true); | 59 page->setDefersLoading(true); |
62 } | 60 } |
63 } | 61 } |
64 | 62 |
65 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() | 63 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() |
66 { | 64 { |
67 for (size_t i = 0; i < m_deferredFrames.size(); ++i) { | 65 for (std::size_t i = 0; i < m_deferredFrames.size(); ++i) { |
68 if (Page* page = m_deferredFrames[i]->page()) { | 66 if (Page* page = m_deferredFrames[i]->page()) { |
69 page->setDefersLoading(false); | 67 page->setDefersLoading(false); |
70 | 68 |
71 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().
traverseNext()) { | 69 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().
traverseNext()) { |
72 if (frame->isLocalFrame()) | 70 if (frame->isLocalFrame()) |
73 toLocalFrame(frame)->document()->resumeScheduledTasks(); | 71 toLocalFrame(frame)->document()->resumeScheduledTasks(); |
74 } | 72 } |
75 } | 73 } |
76 } | 74 } |
77 } | 75 } |
78 | 76 |
79 } // namespace WebCore | 77 } // namespace WebCore |
OLD | NEW |