OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved. |
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
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 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #include "core/page/PointerLockController.h" | 47 #include "core/page/PointerLockController.h" |
48 #include "core/page/ValidationMessageClient.h" | 48 #include "core/page/ValidationMessageClient.h" |
49 #include "core/page/scrolling/ScrollingCoordinator.h" | 49 #include "core/page/scrolling/ScrollingCoordinator.h" |
50 #include "core/paint/PaintLayer.h" | 50 #include "core/paint/PaintLayer.h" |
51 #include "platform/graphics/GraphicsLayer.h" | 51 #include "platform/graphics/GraphicsLayer.h" |
52 #include "platform/plugins/PluginData.h" | 52 #include "platform/plugins/PluginData.h" |
53 #include "public/platform/Platform.h" | 53 #include "public/platform/Platform.h" |
54 | 54 |
55 namespace blink { | 55 namespace blink { |
56 | 56 |
57 // static | 57 // Set of all live pages; includes internal Page objects that are |
58 WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page>>& Page::allPages() | 58 // not observable from scripts. |
59 static Page::PageSet& allPages() | |
59 { | 60 { |
60 DEFINE_STATIC_LOCAL(WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page> >, allPages, ()); | 61 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); |
61 return allPages; | 62 return allPages; |
62 } | 63 } |
63 | 64 |
64 // static | 65 Page::PageSet& Page::ordinaryPages() |
65 WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page>>& Page::ordinaryPages() | |
66 { | 66 { |
67 DEFINE_STATIC_LOCAL(WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page> >, ordinaryPages, ()); | 67 DEFINE_STATIC_LOCAL(Page::PageSet, ordinaryPages, ()); |
68 return ordinaryPages; | 68 return ordinaryPages; |
69 } | 69 } |
70 | 70 |
71 void Page::networkStateChanged(bool online) | 71 void Page::networkStateChanged(bool online) |
72 { | 72 { |
73 WillBeHeapVector<RefPtrWillBeMember<LocalFrame>> frames; | 73 WillBeHeapVector<RefPtrWillBeMember<LocalFrame>> frames; |
74 | 74 |
75 // Get all the frames of all the pages in all the page groups | 75 // Get all the frames of all the pages in all the page groups |
76 for (Page* page : allPages()) { | 76 for (Page* page : allPages()) { |
77 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav erseNext()) { | 77 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav erseNext()) { |
78 // FIXME: There is currently no way to dispatch events to out-of-pro cess frames. | 78 // FIXME: There is currently no way to dispatch events to out-of-pro cess frames. |
79 if (frame->isLocalFrame()) | 79 if (frame->isLocalFrame()) |
80 frames.append(toLocalFrame(frame)); | 80 frames.append(toLocalFrame(frame)); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 AtomicString eventName = online ? EventTypeNames::online : EventTypeNames::o ffline; | 84 AtomicString eventName = online ? EventTypeNames::online : EventTypeNames::o ffline; |
85 for (unsigned i = 0; i < frames.size(); i++) { | 85 for (const auto& frame : frames) { |
86 frames[i]->domWindow()->dispatchEvent(Event::create(eventName)); | 86 frame->domWindow()->dispatchEvent(Event::create(eventName)); |
87 InspectorInstrumentation::networkStateChanged(frames[i].get(), online); | 87 InspectorInstrumentation::networkStateChanged(frame.get(), online); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void Page::onMemoryPressure() | 91 void Page::onMemoryPressure() |
92 { | 92 { |
93 for (auto& page : ordinaryPages()) | 93 for (Page* page : ordinaryPages()) |
94 page->memoryPurgeController().purgeMemory(); | 94 page->memoryPurgeController().purgeMemory(); |
95 } | 95 } |
96 | 96 |
97 float deviceScaleFactor(LocalFrame* frame) | 97 float deviceScaleFactor(LocalFrame* frame) |
98 { | 98 { |
99 if (!frame) | 99 if (!frame) |
100 return 1; | 100 return 1; |
101 Page* page = frame->page(); | 101 Page* page = frame->page(); |
102 if (!page) | 102 if (!page) |
103 return 1; | 103 return 1; |
104 return page->deviceScaleFactor(); | 104 return page->deviceScaleFactor(); |
105 } | 105 } |
106 | 106 |
107 PassOwnPtrWillBeRawPtr<Page> Page::createOrdinary(PageClients& pageClients) | |
108 { | |
109 OwnPtrWillBeRawPtr<Page> page = create(pageClients); | |
110 ordinaryPages().add(page.get()); | |
111 page->memoryPurgeController().registerClient(page.get()); | |
112 return page.release(); | |
113 } | |
114 | |
107 Page::Page(PageClients& pageClients) | 115 Page::Page(PageClients& pageClients) |
108 : SettingsDelegate(Settings::create()) | 116 : SettingsDelegate(Settings::create()) |
109 , m_animator(PageAnimator::create(*this)) | 117 , m_animator(PageAnimator::create(*this)) |
110 , m_autoscrollController(AutoscrollController::create(*this)) | 118 , m_autoscrollController(AutoscrollController::create(*this)) |
111 , m_chromeClient(pageClients.chromeClient) | 119 , m_chromeClient(pageClients.chromeClient) |
112 , m_dragCaretController(DragCaretController::create()) | 120 , m_dragCaretController(DragCaretController::create()) |
113 , m_dragController(DragController::create(this, pageClients.dragClient)) | 121 , m_dragController(DragController::create(this, pageClients.dragClient)) |
114 , m_focusController(FocusController::create(this)) | 122 , m_focusController(FocusController::create(this)) |
115 , m_contextMenuController(ContextMenuController::create(this, pageClients.co ntextMenuClient)) | 123 , m_contextMenuController(ContextMenuController::create(this, pageClients.co ntextMenuClient)) |
116 , m_pointerLockController(PointerLockController::create(this)) | 124 , m_pointerLockController(PointerLockController::create(this)) |
(...skipping 14 matching lines...) Expand all Loading... | |
131 { | 139 { |
132 ASSERT(m_editorClient); | 140 ASSERT(m_editorClient); |
133 | 141 |
134 ASSERT(!allPages().contains(this)); | 142 ASSERT(!allPages().contains(this)); |
135 allPages().add(this); | 143 allPages().add(this); |
136 } | 144 } |
137 | 145 |
138 Page::~Page() | 146 Page::~Page() |
139 { | 147 { |
140 #if !ENABLE(OILPAN) | 148 #if !ENABLE(OILPAN) |
141 ASSERT(!ordinaryPages().contains(this)); | 149 ASSERT(!ordinaryPages().contains(this)); |
haraken
2016/01/03 15:43:19
I'm curious why we can't enable the ASSERT in oilp
sof
2016/01/03 15:58:19
It would be valid to test for it if LEAK_SANITIZER
| |
142 #endif | 150 #endif |
143 // willBeDestroyed() must be called before Page destruction. | 151 // willBeDestroyed() must be called before Page destruction. |
144 ASSERT(!m_mainFrame); | 152 ASSERT(!m_mainFrame); |
145 } | 153 } |
146 | 154 |
147 void Page::makeOrdinary() | |
148 { | |
149 ASSERT(!ordinaryPages().contains(this)); | |
150 ordinaryPages().add(this); | |
151 memoryPurgeController().registerClient(this); | |
152 } | |
153 | |
154 ViewportDescription Page::viewportDescription() const | 155 ViewportDescription Page::viewportDescription() const |
155 { | 156 { |
156 return mainFrame() && mainFrame()->isLocalFrame() && deprecatedLocalMainFram e()->document() ? deprecatedLocalMainFrame()->document()->viewportDescription() : ViewportDescription(); | 157 return mainFrame() && mainFrame()->isLocalFrame() && deprecatedLocalMainFram e()->document() ? deprecatedLocalMainFrame()->document()->viewportDescription() : ViewportDescription(); |
157 } | 158 } |
158 | 159 |
159 ScrollingCoordinator* Page::scrollingCoordinator() | 160 ScrollingCoordinator* Page::scrollingCoordinator() |
160 { | 161 { |
161 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled()) | 162 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled()) |
162 m_scrollingCoordinator = ScrollingCoordinator::create(this); | 163 m_scrollingCoordinator = ScrollingCoordinator::create(this); |
163 | 164 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 if (scrollingCoordinator()) | 547 if (scrollingCoordinator()) |
547 scrollingCoordinator()->layerTreeViewInitialized(layerTreeView); | 548 scrollingCoordinator()->layerTreeViewInitialized(layerTreeView); |
548 } | 549 } |
549 | 550 |
550 void Page::willCloseLayerTreeView(WebLayerTreeView& layerTreeView) | 551 void Page::willCloseLayerTreeView(WebLayerTreeView& layerTreeView) |
551 { | 552 { |
552 if (m_scrollingCoordinator) | 553 if (m_scrollingCoordinator) |
553 m_scrollingCoordinator->willCloseLayerTreeView(layerTreeView); | 554 m_scrollingCoordinator->willCloseLayerTreeView(layerTreeView); |
554 } | 555 } |
555 | 556 |
557 void Page::willBeClosed() | |
558 { | |
559 ordinaryPages().remove(this); | |
560 } | |
561 | |
556 void Page::willBeDestroyed() | 562 void Page::willBeDestroyed() |
557 { | 563 { |
558 RefPtrWillBeRawPtr<Frame> mainFrame = m_mainFrame; | 564 RefPtrWillBeRawPtr<Frame> mainFrame = m_mainFrame; |
559 | 565 |
560 mainFrame->detach(FrameDetachType::Remove); | 566 mainFrame->detach(FrameDetachType::Remove); |
561 | 567 |
562 ASSERT(allPages().contains(this)); | 568 ASSERT(allPages().contains(this)); |
563 allPages().remove(this); | 569 allPages().remove(this); |
564 ordinaryPages().remove(this); | 570 ordinaryPages().remove(this); |
565 #if !ENABLE(OILPAN) | 571 #if !ENABLE(OILPAN) |
566 if (m_memoryPurgeController) | 572 if (m_memoryPurgeController) |
567 m_memoryPurgeController->unregisterClient(this); | 573 m_memoryPurgeController->unregisterClient(this); |
568 #endif | 574 #endif |
569 | 575 |
570 if (m_scrollingCoordinator) | 576 if (m_scrollingCoordinator) |
571 m_scrollingCoordinator->willBeDestroyed(); | 577 m_scrollingCoordinator->willBeDestroyed(); |
572 | 578 |
573 chromeClient().chromeDestroyed(); | 579 chromeClient().chromeDestroyed(); |
574 if (m_validationMessageClient) | 580 if (m_validationMessageClient) |
575 m_validationMessageClient->willBeDestroyed(); | 581 m_validationMessageClient->willBeDestroyed(); |
576 m_mainFrame = nullptr; | 582 m_mainFrame = nullptr; |
577 | 583 |
578 Page::notifyContextDestroyed(); | 584 PageLifecycleNotifier::notifyContextDestroyed(); |
579 } | 585 } |
580 | 586 |
581 Page::PageClients::PageClients() | 587 Page::PageClients::PageClients() |
582 : chromeClient(nullptr) | 588 : chromeClient(nullptr) |
583 , contextMenuClient(nullptr) | 589 , contextMenuClient(nullptr) |
584 , editorClient(nullptr) | 590 , editorClient(nullptr) |
585 , dragClient(nullptr) | 591 , dragClient(nullptr) |
586 , spellCheckerClient(nullptr) | 592 , spellCheckerClient(nullptr) |
587 { | 593 { |
588 } | 594 } |
589 | 595 |
590 Page::PageClients::~PageClients() | 596 Page::PageClients::~PageClients() |
591 { | 597 { |
592 } | 598 } |
593 | 599 |
594 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Page>; | 600 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Page>; |
595 | 601 |
596 } // namespace blink | 602 } // namespace blink |
OLD | NEW |