| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "core/page/PageGroupLoadDeferrer.h" | 22 #include "core/page/PageGroupLoadDeferrer.h" |
| 23 | 23 |
| 24 #include "core/dom/Document.h" | 24 #include "core/dom/Document.h" |
| 25 #include "core/loader/FrameLoader.h" |
| 25 #include "core/page/Frame.h" | 26 #include "core/page/Frame.h" |
| 26 #include "core/page/Page.h" | 27 #include "core/page/Page.h" |
| 27 #include "core/page/PageGroup.h" | 28 #include "core/page/PageGroup.h" |
| 28 #include "wtf/HashSet.h" | 29 #include "wtf/HashSet.h" |
| 29 | 30 |
| 30 namespace WebCore { | 31 namespace WebCore { |
| 31 | 32 |
| 32 using namespace std; | 33 using namespace std; |
| 33 | 34 |
| 34 PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf) | 35 PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf) |
| 35 { | 36 { |
| 36 const HashSet<Page*>& pages = page->group().pages(); | 37 const HashSet<Page*>& pages = page->group().pages(); |
| 37 | 38 |
| 38 HashSet<Page*>::const_iterator end = pages.end(); | 39 HashSet<Page*>::const_iterator end = pages.end(); |
| 39 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { | 40 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { |
| 40 Page* otherPage = *it; | 41 Page* otherPage = *it; |
| 41 if ((deferSelf || otherPage != page)) { | 42 if ((deferSelf || otherPage != page)) { |
| 42 if (!otherPage->defersLoading()) { | 43 if (!otherPage->defersLoading()) { |
| 43 m_deferredFrames.append(otherPage->mainFrame()); | 44 m_deferredFrames.append(otherPage->mainFrame()); |
| 44 | 45 |
| 46 // Ensure that we notify the client if the initial empty documen
t is accessed before showing anything |
| 47 // modal, to prevent spoofs while the modal window or sheet is v
isible. |
| 48 otherPage->mainFrame()->loader()->notifyIfInitialDocumentAccesse
d(); |
| 49 |
| 45 // This code is not logically part of load deferring, but we do
not want JS code executed beneath modal | 50 // This code is not logically part of load deferring, but we do
not want JS code executed beneath modal |
| 46 // windows or sheets, which is exactly when PageGroupLoadDeferre
r is used. | 51 // windows or sheets, which is exactly when PageGroupLoadDeferre
r is used. |
| 47 for (Frame* frame = otherPage->mainFrame(); frame; frame = frame
->tree()->traverseNext()) | 52 for (Frame* frame = otherPage->mainFrame(); frame; frame = frame
->tree()->traverseNext()) |
| 48 frame->document()->suspendScheduledTasks(ActiveDOMObject::Wi
llDeferLoading); | 53 frame->document()->suspendScheduledTasks(ActiveDOMObject::Wi
llDeferLoading); |
| 49 } | 54 } |
| 50 } | 55 } |
| 51 } | 56 } |
| 52 | 57 |
| 53 size_t count = m_deferredFrames.size(); | 58 size_t count = m_deferredFrames.size(); |
| 54 for (size_t i = 0; i < count; ++i) | 59 for (size_t i = 0; i < count; ++i) |
| 55 if (Page* page = m_deferredFrames[i]->page()) | 60 if (Page* page = m_deferredFrames[i]->page()) |
| 56 page->setDefersLoading(true); | 61 page->setDefersLoading(true); |
| 57 } | 62 } |
| 58 | 63 |
| 59 PageGroupLoadDeferrer::~PageGroupLoadDeferrer() | 64 PageGroupLoadDeferrer::~PageGroupLoadDeferrer() |
| 60 { | 65 { |
| 61 for (size_t i = 0; i < m_deferredFrames.size(); ++i) { | 66 for (size_t i = 0; i < m_deferredFrames.size(); ++i) { |
| 62 if (Page* page = m_deferredFrames[i]->page()) { | 67 if (Page* page = m_deferredFrames[i]->page()) { |
| 63 page->setDefersLoading(false); | 68 page->setDefersLoading(false); |
| 64 | 69 |
| 65 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()-
>traverseNext()) | 70 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()-
>traverseNext()) |
| 66 frame->document()->resumeScheduledTasks(); | 71 frame->document()->resumeScheduledTasks(); |
| 67 } | 72 } |
| 68 } | 73 } |
| 69 } | 74 } |
| 70 | 75 |
| 71 | 76 |
| 72 } // namespace WebCore | 77 } // namespace WebCore |
| OLD | NEW |