| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "core/page/Page.h" | 20 #include "core/page/Page.h" |
| 21 | 21 |
| 22 #include "core/css/resolver/ViewportStyleResolver.h" | 22 #include "core/css/resolver/ViewportStyleResolver.h" |
| 23 #include "core/dom/ClientRectList.h" | 23 #include "core/dom/ClientRectList.h" |
| 24 #include "core/dom/StyleChangeReason.h" | 24 #include "core/dom/StyleChangeReason.h" |
| 25 #include "core/dom/VisitedLinkState.h" | 25 #include "core/dom/VisitedLinkState.h" |
| 26 #include "core/editing/DragCaretController.h" | 26 #include "core/editing/DragCaretController.h" |
| 27 #include "core/editing/commands/UndoStack.h" | 27 #include "core/editing/commands/UndoStack.h" |
| 28 #include "core/editing/markers/DocumentMarkerController.h" | 28 #include "core/editing/markers/DocumentMarkerController.h" |
| 29 #include "core/events/Event.h" | 29 #include "core/events/Event.h" |
| 30 #include "core/fetch/MemoryCache.h" | |
| 31 #include "core/fetch/ResourceFetcher.h" | 30 #include "core/fetch/ResourceFetcher.h" |
| 32 #include "core/frame/DOMTimer.h" | 31 #include "core/frame/DOMTimer.h" |
| 33 #include "core/frame/FrameConsole.h" | 32 #include "core/frame/FrameConsole.h" |
| 34 #include "core/frame/FrameHost.h" | 33 #include "core/frame/FrameHost.h" |
| 35 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
| 36 #include "core/frame/RemoteFrame.h" | 35 #include "core/frame/RemoteFrame.h" |
| 37 #include "core/frame/RemoteFrameView.h" | 36 #include "core/frame/RemoteFrameView.h" |
| 38 #include "core/frame/Settings.h" | 37 #include "core/frame/Settings.h" |
| 39 #include "core/frame/VisualViewport.h" | 38 #include "core/frame/VisualViewport.h" |
| 40 #include "core/html/HTMLMediaElement.h" | 39 #include "core/html/HTMLMediaElement.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 82 } |
| 84 } | 83 } |
| 85 | 84 |
| 86 AtomicString eventName = online ? EventTypeNames::online : EventTypeNames::o
ffline; | 85 AtomicString eventName = online ? EventTypeNames::online : EventTypeNames::o
ffline; |
| 87 for (const auto& frame : frames) { | 86 for (const auto& frame : frames) { |
| 88 frame->domWindow()->dispatchEvent(Event::create(eventName)); | 87 frame->domWindow()->dispatchEvent(Event::create(eventName)); |
| 89 InspectorInstrumentation::networkStateChanged(frame.get(), online); | 88 InspectorInstrumentation::networkStateChanged(frame.get(), online); |
| 90 } | 89 } |
| 91 } | 90 } |
| 92 | 91 |
| 93 void Page::onMemoryPressure() | |
| 94 { | |
| 95 for (Page* page : ordinaryPages()) | |
| 96 page->memoryPurgeController().purgeMemory(); | |
| 97 } | |
| 98 | |
| 99 float deviceScaleFactor(LocalFrame* frame) | 92 float deviceScaleFactor(LocalFrame* frame) |
| 100 { | 93 { |
| 101 if (!frame) | 94 if (!frame) |
| 102 return 1; | 95 return 1; |
| 103 Page* page = frame->page(); | 96 Page* page = frame->page(); |
| 104 if (!page) | 97 if (!page) |
| 105 return 1; | 98 return 1; |
| 106 return page->deviceScaleFactor(); | 99 return page->deviceScaleFactor(); |
| 107 } | 100 } |
| 108 | 101 |
| 109 Page* Page::createOrdinary(PageClients& pageClients) | 102 Page* Page::createOrdinary(PageClients& pageClients) |
| 110 { | 103 { |
| 111 Page* page = create(pageClients); | 104 Page* page = create(pageClients); |
| 112 ordinaryPages().add(page); | 105 ordinaryPages().add(page); |
| 113 page->memoryPurgeController().registerClient(page); | |
| 114 return page; | 106 return page; |
| 115 } | 107 } |
| 116 | 108 |
| 117 Page::Page(PageClients& pageClients) | 109 Page::Page(PageClients& pageClients) |
| 118 : SettingsDelegate(Settings::create()) | 110 : SettingsDelegate(Settings::create()) |
| 119 , m_animator(PageAnimator::create(*this)) | 111 , m_animator(PageAnimator::create(*this)) |
| 120 , m_autoscrollController(AutoscrollController::create(*this)) | 112 , m_autoscrollController(AutoscrollController::create(*this)) |
| 121 , m_chromeClient(pageClients.chromeClient) | 113 , m_chromeClient(pageClients.chromeClient) |
| 122 , m_dragCaretController(DragCaretController::create()) | 114 , m_dragCaretController(DragCaretController::create()) |
| 123 , m_dragController(DragController::create(this)) | 115 , m_dragController(DragController::create(this)) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 150 } |
| 159 | 151 |
| 160 ScrollingCoordinator* Page::scrollingCoordinator() | 152 ScrollingCoordinator* Page::scrollingCoordinator() |
| 161 { | 153 { |
| 162 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled()) | 154 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled()) |
| 163 m_scrollingCoordinator = ScrollingCoordinator::create(this); | 155 m_scrollingCoordinator = ScrollingCoordinator::create(this); |
| 164 | 156 |
| 165 return m_scrollingCoordinator.get(); | 157 return m_scrollingCoordinator.get(); |
| 166 } | 158 } |
| 167 | 159 |
| 168 MemoryPurgeController& Page::memoryPurgeController() | |
| 169 { | |
| 170 if (!m_memoryPurgeController) | |
| 171 m_memoryPurgeController = MemoryPurgeController::create(); | |
| 172 | |
| 173 return *m_memoryPurgeController; | |
| 174 } | |
| 175 | |
| 176 String Page::mainThreadScrollingReasonsAsText() | 160 String Page::mainThreadScrollingReasonsAsText() |
| 177 { | 161 { |
| 178 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(
)) | 162 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(
)) |
| 179 return scrollingCoordinator->mainThreadScrollingReasonsAsText(); | 163 return scrollingCoordinator->mainThreadScrollingReasonsAsText(); |
| 180 | 164 |
| 181 return String(); | 165 return String(); |
| 182 } | 166 } |
| 183 | 167 |
| 184 ClientRectList* Page::nonFastScrollableRects(const LocalFrame* frame) | 168 ClientRectList* Page::nonFastScrollableRects(const LocalFrame* frame) |
| 185 { | 169 { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // an event so we keep the frames alive until we are done. | 457 // an event so we keep the frames alive until we are done. |
| 474 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext()
) { | 458 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext()
) { |
| 475 if (frame->isLocalFrame()) | 459 if (frame->isLocalFrame()) |
| 476 frames.append(toLocalFrame(frame)); | 460 frames.append(toLocalFrame(frame)); |
| 477 } | 461 } |
| 478 | 462 |
| 479 for (unsigned i = 0; i < frames.size(); ++i) | 463 for (unsigned i = 0; i < frames.size(); ++i) |
| 480 frames[i]->localDOMWindow()->acceptLanguagesChanged(); | 464 frames[i]->localDOMWindow()->acceptLanguagesChanged(); |
| 481 } | 465 } |
| 482 | 466 |
| 483 void Page::purgeMemory(DeviceKind deviceKind) | |
| 484 { | |
| 485 if (deviceKind == DeviceKind::LowEnd) | |
| 486 memoryCache()->pruneAll(); | |
| 487 } | |
| 488 | |
| 489 DEFINE_TRACE(Page) | 467 DEFINE_TRACE(Page) |
| 490 { | 468 { |
| 491 visitor->trace(m_animator); | 469 visitor->trace(m_animator); |
| 492 visitor->trace(m_autoscrollController); | 470 visitor->trace(m_autoscrollController); |
| 493 visitor->trace(m_chromeClient); | 471 visitor->trace(m_chromeClient); |
| 494 visitor->trace(m_dragCaretController); | 472 visitor->trace(m_dragCaretController); |
| 495 visitor->trace(m_dragController); | 473 visitor->trace(m_dragController); |
| 496 visitor->trace(m_focusController); | 474 visitor->trace(m_focusController); |
| 497 visitor->trace(m_contextMenuController); | 475 visitor->trace(m_contextMenuController); |
| 498 visitor->trace(m_pointerLockController); | 476 visitor->trace(m_pointerLockController); |
| 499 visitor->trace(m_scrollingCoordinator); | 477 visitor->trace(m_scrollingCoordinator); |
| 500 visitor->trace(m_undoStack); | 478 visitor->trace(m_undoStack); |
| 501 visitor->trace(m_mainFrame); | 479 visitor->trace(m_mainFrame); |
| 502 visitor->trace(m_validationMessageClient); | 480 visitor->trace(m_validationMessageClient); |
| 503 visitor->trace(m_frameHost); | 481 visitor->trace(m_frameHost); |
| 504 visitor->trace(m_memoryPurgeController); | |
| 505 Supplementable<Page>::trace(visitor); | 482 Supplementable<Page>::trace(visitor); |
| 506 PageLifecycleNotifier::trace(visitor); | 483 PageLifecycleNotifier::trace(visitor); |
| 507 MemoryPurgeClient::trace(visitor); | |
| 508 } | 484 } |
| 509 | 485 |
| 510 void Page::layerTreeViewInitialized(WebLayerTreeView& layerTreeView) | 486 void Page::layerTreeViewInitialized(WebLayerTreeView& layerTreeView) |
| 511 { | 487 { |
| 512 if (scrollingCoordinator()) | 488 if (scrollingCoordinator()) |
| 513 scrollingCoordinator()->layerTreeViewInitialized(layerTreeView); | 489 scrollingCoordinator()->layerTreeViewInitialized(layerTreeView); |
| 514 } | 490 } |
| 515 | 491 |
| 516 void Page::willCloseLayerTreeView(WebLayerTreeView& layerTreeView) | 492 void Page::willCloseLayerTreeView(WebLayerTreeView& layerTreeView) |
| 517 { | 493 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 { | 536 { |
| 561 } | 537 } |
| 562 | 538 |
| 563 Page::PageClients::~PageClients() | 539 Page::PageClients::~PageClients() |
| 564 { | 540 { |
| 565 } | 541 } |
| 566 | 542 |
| 567 template class CORE_TEMPLATE_EXPORT Supplement<Page>; | 543 template class CORE_TEMPLATE_EXPORT Supplement<Page>; |
| 568 | 544 |
| 569 } // namespace blink | 545 } // namespace blink |
| OLD | NEW |