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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "core/page/ChromeClient.h" | 42 #include "core/page/ChromeClient.h" |
43 #include "core/page/ContextMenuController.h" | 43 #include "core/page/ContextMenuController.h" |
44 #include "core/page/DragController.h" | 44 #include "core/page/DragController.h" |
45 #include "core/page/FocusController.h" | 45 #include "core/page/FocusController.h" |
46 #include "core/page/PointerLockController.h" | 46 #include "core/page/PointerLockController.h" |
47 #include "core/page/ValidationMessageClient.h" | 47 #include "core/page/ValidationMessageClient.h" |
48 #include "core/page/scrolling/ScrollingCoordinator.h" | 48 #include "core/page/scrolling/ScrollingCoordinator.h" |
49 #include "core/paint/PaintLayer.h" | 49 #include "core/paint/PaintLayer.h" |
50 #include "platform/graphics/GraphicsLayer.h" | 50 #include "platform/graphics/GraphicsLayer.h" |
51 #include "platform/plugins/PluginData.h" | 51 #include "platform/plugins/PluginData.h" |
52 #include "platform/text/CompressibleString.h" | |
53 #include "public/platform/Platform.h" | 52 #include "public/platform/Platform.h" |
54 | 53 |
55 namespace blink { | 54 namespace blink { |
56 | 55 |
57 // Set of all live pages; includes internal Page objects that are | 56 // Set of all live pages; includes internal Page objects that are |
58 // not observable from scripts. | 57 // not observable from scripts. |
59 static Page::PageSet& allPages() | 58 static Page::PageSet& allPages() |
60 { | 59 { |
61 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); | 60 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); |
62 return allPages; | 61 return allPages; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 , m_openedByDOM(false) | 120 , m_openedByDOM(false) |
122 , m_tabKeyCyclesThroughElements(true) | 121 , m_tabKeyCyclesThroughElements(true) |
123 , m_defersLoading(false) | 122 , m_defersLoading(false) |
124 , m_deviceScaleFactor(1) | 123 , m_deviceScaleFactor(1) |
125 , m_visibilityState(PageVisibilityStateVisible) | 124 , m_visibilityState(PageVisibilityStateVisible) |
126 , m_isCursorVisible(true) | 125 , m_isCursorVisible(true) |
127 #if ENABLE(ASSERT) | 126 #if ENABLE(ASSERT) |
128 , m_isPainting(false) | 127 , m_isPainting(false) |
129 #endif | 128 #endif |
130 , m_frameHost(FrameHost::create(*this)) | 129 , m_frameHost(FrameHost::create(*this)) |
131 , m_timerForCompressStrings(this, &Page::compressStrings) | |
132 { | 130 { |
133 ASSERT(m_editorClient); | 131 ASSERT(m_editorClient); |
134 | 132 |
135 ASSERT(!allPages().contains(this)); | 133 ASSERT(!allPages().contains(this)); |
136 allPages().add(this); | 134 allPages().add(this); |
137 } | 135 } |
138 | 136 |
139 Page::~Page() | 137 Page::~Page() |
140 { | 138 { |
141 // willBeDestroyed() must be called before Page destruction. | 139 // willBeDestroyed() must be called before Page destruction. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 for (const Page* page : ordinaryPages()) { | 306 for (const Page* page : ordinaryPages()) { |
309 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav
erseNext()) { | 307 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav
erseNext()) { |
310 if (frame->isLocalFrame()) | 308 if (frame->isLocalFrame()) |
311 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt
yleForLink(linkHash); | 309 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt
yleForLink(linkHash); |
312 } | 310 } |
313 } | 311 } |
314 } | 312 } |
315 | 313 |
316 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
lState) | 314 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
lState) |
317 { | 315 { |
318 static const double waitingTimeBeforeCompressingString = 10; | |
319 | |
320 if (m_visibilityState == visibilityState) | 316 if (m_visibilityState == visibilityState) |
321 return; | 317 return; |
322 m_visibilityState = visibilityState; | 318 m_visibilityState = visibilityState; |
323 | 319 |
324 if (!isInitialState) | 320 if (!isInitialState) |
325 notifyPageVisibilityChanged(); | 321 notifyPageVisibilityChanged(); |
326 | 322 |
327 if (!isInitialState && m_mainFrame) | 323 if (!isInitialState && m_mainFrame) |
328 m_mainFrame->didChangeVisibilityState(); | 324 m_mainFrame->didChangeVisibilityState(); |
329 | |
330 // Compress CompressibleStrings when 10 seconds have passed since the page | |
331 // went to background. | |
332 if (m_visibilityState == PageVisibilityStateHidden) { | |
333 if (!m_timerForCompressStrings.isActive()) | |
334 m_timerForCompressStrings.startOneShot(waitingTimeBeforeCompressingS
tring, BLINK_FROM_HERE); | |
335 } else if (m_timerForCompressStrings.isActive()) { | |
336 m_timerForCompressStrings.stop(); | |
337 } | |
338 } | 325 } |
339 | 326 |
340 PageVisibilityState Page::visibilityState() const | 327 PageVisibilityState Page::visibilityState() const |
341 { | 328 { |
342 return m_visibilityState; | 329 return m_visibilityState; |
343 } | 330 } |
344 | 331 |
345 bool Page::isPageVisible() const | 332 bool Page::isPageVisible() const |
346 { | 333 { |
347 return visibilityState() == PageVisibilityStateVisible; | 334 return visibilityState() == PageVisibilityStateVisible; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 // an event so we keep the frames alive until we are done. | 441 // an event so we keep the frames alive until we are done. |
455 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext()
) { | 442 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext()
) { |
456 if (frame->isLocalFrame()) | 443 if (frame->isLocalFrame()) |
457 frames.append(toLocalFrame(frame)); | 444 frames.append(toLocalFrame(frame)); |
458 } | 445 } |
459 | 446 |
460 for (unsigned i = 0; i < frames.size(); ++i) | 447 for (unsigned i = 0; i < frames.size(); ++i) |
461 frames[i]->localDOMWindow()->acceptLanguagesChanged(); | 448 frames[i]->localDOMWindow()->acceptLanguagesChanged(); |
462 } | 449 } |
463 | 450 |
| 451 void Page::purgeMemory() |
| 452 { |
| 453 // Ask each frame to purge memory. |
| 454 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext()
) { |
| 455 if (frame->isLocalFrame()) |
| 456 toLocalFrame(frame)->purgeMemory(); |
| 457 } |
| 458 } |
| 459 |
| 460 void Page::onMemoryPressure() |
| 461 { |
| 462 for (Page* page : allPages()) |
| 463 page->purgeMemory(); |
| 464 } |
| 465 |
464 DEFINE_TRACE(Page) | 466 DEFINE_TRACE(Page) |
465 { | 467 { |
466 visitor->trace(m_animator); | 468 visitor->trace(m_animator); |
467 visitor->trace(m_autoscrollController); | 469 visitor->trace(m_autoscrollController); |
468 visitor->trace(m_chromeClient); | 470 visitor->trace(m_chromeClient); |
469 visitor->trace(m_dragCaretController); | 471 visitor->trace(m_dragCaretController); |
470 visitor->trace(m_dragController); | 472 visitor->trace(m_dragController); |
471 visitor->trace(m_focusController); | 473 visitor->trace(m_focusController); |
472 visitor->trace(m_contextMenuController); | 474 visitor->trace(m_contextMenuController); |
473 visitor->trace(m_pointerLockController); | 475 visitor->trace(m_pointerLockController); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 m_scrollingCoordinator->willBeDestroyed(); | 512 m_scrollingCoordinator->willBeDestroyed(); |
511 | 513 |
512 chromeClient().chromeDestroyed(); | 514 chromeClient().chromeDestroyed(); |
513 if (m_validationMessageClient) | 515 if (m_validationMessageClient) |
514 m_validationMessageClient->willBeDestroyed(); | 516 m_validationMessageClient->willBeDestroyed(); |
515 m_mainFrame = nullptr; | 517 m_mainFrame = nullptr; |
516 | 518 |
517 PageLifecycleNotifier::notifyContextDestroyed(); | 519 PageLifecycleNotifier::notifyContextDestroyed(); |
518 } | 520 } |
519 | 521 |
520 void Page::compressStrings(Timer<Page>* timer) | |
521 { | |
522 ASSERT_UNUSED(timer, timer == &m_timerForCompressStrings); | |
523 if (m_visibilityState == PageVisibilityStateHidden) | |
524 CompressibleStringImpl::compressAll(); | |
525 } | |
526 | |
527 Page::PageClients::PageClients() | 522 Page::PageClients::PageClients() |
528 : chromeClient(nullptr) | 523 : chromeClient(nullptr) |
529 , contextMenuClient(nullptr) | 524 , contextMenuClient(nullptr) |
530 , editorClient(nullptr) | 525 , editorClient(nullptr) |
531 , spellCheckerClient(nullptr) | 526 , spellCheckerClient(nullptr) |
532 { | 527 { |
533 } | 528 } |
534 | 529 |
535 Page::PageClients::~PageClients() | 530 Page::PageClients::~PageClients() |
536 { | 531 { |
537 } | 532 } |
538 | 533 |
539 template class CORE_TEMPLATE_EXPORT Supplement<Page>; | 534 template class CORE_TEMPLATE_EXPORT Supplement<Page>; |
540 | 535 |
541 } // namespace blink | 536 } // namespace blink |
OLD | NEW |