| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "core/page/ContextMenuController.h" | 45 #include "core/page/ContextMenuController.h" |
| 46 #include "core/page/DragController.h" | 46 #include "core/page/DragController.h" |
| 47 #include "core/page/FocusController.h" | 47 #include "core/page/FocusController.h" |
| 48 #include "core/page/PointerLockController.h" | 48 #include "core/page/PointerLockController.h" |
| 49 #include "core/page/ScopedPageLoadDeferrer.h" | 49 #include "core/page/ScopedPageLoadDeferrer.h" |
| 50 #include "core/page/ValidationMessageClient.h" | 50 #include "core/page/ValidationMessageClient.h" |
| 51 #include "core/page/scrolling/ScrollingCoordinator.h" | 51 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 52 #include "core/paint/PaintLayer.h" | 52 #include "core/paint/PaintLayer.h" |
| 53 #include "platform/graphics/GraphicsLayer.h" | 53 #include "platform/graphics/GraphicsLayer.h" |
| 54 #include "platform/plugins/PluginData.h" | 54 #include "platform/plugins/PluginData.h" |
| 55 #include "platform/text/CompressibleString.h" | |
| 56 #include "public/platform/Platform.h" | 55 #include "public/platform/Platform.h" |
| 57 | 56 |
| 58 namespace blink { | 57 namespace blink { |
| 59 | 58 |
| 60 // Set of all live pages; includes internal Page objects that are | 59 // Set of all live pages; includes internal Page objects that are |
| 61 // not observable from scripts. | 60 // not observable from scripts. |
| 62 static Page::PageSet& allPages() | 61 static Page::PageSet& allPages() |
| 63 { | 62 { |
| 64 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); | 63 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); |
| 65 return allPages; | 64 return allPages; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 , m_openedByDOM(false) | 125 , m_openedByDOM(false) |
| 127 , m_tabKeyCyclesThroughElements(true) | 126 , m_tabKeyCyclesThroughElements(true) |
| 128 , m_defersLoading(false) | 127 , m_defersLoading(false) |
| 129 , m_deviceScaleFactor(1) | 128 , m_deviceScaleFactor(1) |
| 130 , m_visibilityState(PageVisibilityStateVisible) | 129 , m_visibilityState(PageVisibilityStateVisible) |
| 131 , m_isCursorVisible(true) | 130 , m_isCursorVisible(true) |
| 132 #if ENABLE(ASSERT) | 131 #if ENABLE(ASSERT) |
| 133 , m_isPainting(false) | 132 , m_isPainting(false) |
| 134 #endif | 133 #endif |
| 135 , m_frameHost(FrameHost::create(*this)) | 134 , m_frameHost(FrameHost::create(*this)) |
| 136 , m_timerForCompressStrings(this, &Page::compressStrings) | |
| 137 { | 135 { |
| 138 ASSERT(m_editorClient); | 136 ASSERT(m_editorClient); |
| 139 | 137 |
| 140 ASSERT(!allPages().contains(this)); | 138 ASSERT(!allPages().contains(this)); |
| 141 allPages().add(this); | 139 allPages().add(this); |
| 142 } | 140 } |
| 143 | 141 |
| 144 Page::~Page() | 142 Page::~Page() |
| 145 { | 143 { |
| 146 // willBeDestroyed() must be called before Page destruction. | 144 // willBeDestroyed() must be called before Page destruction. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 for (const Page* page : ordinaryPages()) { | 311 for (const Page* page : ordinaryPages()) { |
| 314 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav
erseNext()) { | 312 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav
erseNext()) { |
| 315 if (frame->isLocalFrame()) | 313 if (frame->isLocalFrame()) |
| 316 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt
yleForLink(linkHash); | 314 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt
yleForLink(linkHash); |
| 317 } | 315 } |
| 318 } | 316 } |
| 319 } | 317 } |
| 320 | 318 |
| 321 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
lState) | 319 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
lState) |
| 322 { | 320 { |
| 323 static const double waitingTimeBeforeCompressingString = 10; | |
| 324 | |
| 325 if (m_visibilityState == visibilityState) | 321 if (m_visibilityState == visibilityState) |
| 326 return; | 322 return; |
| 327 m_visibilityState = visibilityState; | 323 m_visibilityState = visibilityState; |
| 328 | 324 |
| 329 if (!isInitialState) | 325 if (!isInitialState) |
| 330 notifyPageVisibilityChanged(); | 326 notifyPageVisibilityChanged(); |
| 331 | 327 |
| 332 if (!isInitialState && m_mainFrame) | 328 if (!isInitialState && m_mainFrame) |
| 333 m_mainFrame->didChangeVisibilityState(); | 329 m_mainFrame->didChangeVisibilityState(); |
| 334 | |
| 335 // Compress CompressibleStrings when 10 seconds have passed since the page | |
| 336 // went to background. | |
| 337 if (m_visibilityState == PageVisibilityStateHidden) { | |
| 338 if (!m_timerForCompressStrings.isActive()) | |
| 339 m_timerForCompressStrings.startOneShot(waitingTimeBeforeCompressingS
tring, BLINK_FROM_HERE); | |
| 340 } else if (m_timerForCompressStrings.isActive()) { | |
| 341 m_timerForCompressStrings.stop(); | |
| 342 } | |
| 343 } | 330 } |
| 344 | 331 |
| 345 PageVisibilityState Page::visibilityState() const | 332 PageVisibilityState Page::visibilityState() const |
| 346 { | 333 { |
| 347 return m_visibilityState; | 334 return m_visibilityState; |
| 348 } | 335 } |
| 349 | 336 |
| 350 bool Page::isPageVisible() const | 337 bool Page::isPageVisible() const |
| 351 { | 338 { |
| 352 return visibilityState() == PageVisibilityStateVisible; | 339 return visibilityState() == PageVisibilityStateVisible; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 m_scrollingCoordinator->willBeDestroyed(); | 516 m_scrollingCoordinator->willBeDestroyed(); |
| 530 | 517 |
| 531 chromeClient().chromeDestroyed(); | 518 chromeClient().chromeDestroyed(); |
| 532 if (m_validationMessageClient) | 519 if (m_validationMessageClient) |
| 533 m_validationMessageClient->willBeDestroyed(); | 520 m_validationMessageClient->willBeDestroyed(); |
| 534 m_mainFrame = nullptr; | 521 m_mainFrame = nullptr; |
| 535 | 522 |
| 536 PageVisibilityNotifier::notifyContextDestroyed(); | 523 PageVisibilityNotifier::notifyContextDestroyed(); |
| 537 } | 524 } |
| 538 | 525 |
| 539 void Page::compressStrings(TimerBase* timer) | |
| 540 { | |
| 541 ASSERT_UNUSED(timer, timer == &m_timerForCompressStrings); | |
| 542 if (m_visibilityState == PageVisibilityStateHidden) | |
| 543 CompressibleStringImpl::compressAll(); | |
| 544 } | |
| 545 | |
| 546 Page::PageClients::PageClients() | 526 Page::PageClients::PageClients() |
| 547 : chromeClient(nullptr) | 527 : chromeClient(nullptr) |
| 548 , contextMenuClient(nullptr) | 528 , contextMenuClient(nullptr) |
| 549 , editorClient(nullptr) | 529 , editorClient(nullptr) |
| 550 , spellCheckerClient(nullptr) | 530 , spellCheckerClient(nullptr) |
| 551 { | 531 { |
| 552 } | 532 } |
| 553 | 533 |
| 554 Page::PageClients::~PageClients() | 534 Page::PageClients::~PageClients() |
| 555 { | 535 { |
| 556 } | 536 } |
| 557 | 537 |
| 558 template class CORE_TEMPLATE_EXPORT Supplement<Page>; | 538 template class CORE_TEMPLATE_EXPORT Supplement<Page>; |
| 559 | 539 |
| 560 } // namespace blink | 540 } // namespace blink |
| OLD | NEW |