Title: [196023] trunk/Source/WebCore
- Revision
- 196023
- Author
- [email protected]
- Date
- 2016-02-02 11:43:16 -0800 (Tue, 02 Feb 2016)
Log Message
Tab suspension code shouldn't use page cache cacheability logic
https://bugs.webkit.org/show_bug.cgi?id=153680
Reviewed by Andreas Kling.
Most of PageCache::canCache() is unnecessary for tab suspension.
Also improve robustness and introduce 1 minute delay before suspending.
* page/Page.cpp:
(WebCore::Page::setPageActivityState):
(WebCore::Page::setIsVisible):
(WebCore::Page::setIsVisibleInternal):
(WebCore::Page::setIsPrerender):
(WebCore::Page::canTabSuspend):
Include visibility test here.
Instead of calling PageCache::canCache() just check for each frame
- that the document is loaded
- that active DOM objects allow suspension
(WebCore::Page::setIsTabSuspended):
(WebCore::Page::setTabSuspensionEnabled):
(WebCore::Page::updateTabSuspensionState):
Refactor for robustness.
(WebCore::Page::tabSuspensionTimerFired):
Call canTabSuspend, the result might have changed.
(WebCore::Page::scheduleTabSuspension): Deleted.
* page/Page.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (196022 => 196023)
--- trunk/Source/WebCore/ChangeLog 2016-02-02 19:33:05 UTC (rev 196022)
+++ trunk/Source/WebCore/ChangeLog 2016-02-02 19:43:16 UTC (rev 196023)
@@ -1,3 +1,40 @@
+2016-02-01 Antti Koivisto <[email protected]>
+
+ Tab suspension code shouldn't use page cache cacheability logic
+ https://bugs.webkit.org/show_bug.cgi?id=153680
+
+ Reviewed by Andreas Kling.
+
+ Most of PageCache::canCache() is unnecessary for tab suspension.
+
+ Also improve robustness and introduce 1 minute delay before suspending.
+
+ * page/Page.cpp:
+ (WebCore::Page::setPageActivityState):
+ (WebCore::Page::setIsVisible):
+ (WebCore::Page::setIsVisibleInternal):
+ (WebCore::Page::setIsPrerender):
+ (WebCore::Page::canTabSuspend):
+
+ Include visibility test here.
+
+ Instead of calling PageCache::canCache() just check for each frame
+ - that the document is loaded
+ - that active DOM objects allow suspension
+
+ (WebCore::Page::setIsTabSuspended):
+ (WebCore::Page::setTabSuspensionEnabled):
+ (WebCore::Page::updateTabSuspensionState):
+
+ Refactor for robustness.
+
+ (WebCore::Page::tabSuspensionTimerFired):
+
+ Call canTabSuspend, the result might have changed.
+
+ (WebCore::Page::scheduleTabSuspension): Deleted.
+ * page/Page.h:
+
2016-02-02 Yusuke Suzuki <[email protected]>
[JSC] Introduce BytecodeIntrinsic constant rep like @undefined
Modified: trunk/Source/WebCore/page/Page.cpp (196022 => 196023)
--- trunk/Source/WebCore/page/Page.cpp 2016-02-02 19:33:05 UTC (rev 196022)
+++ trunk/Source/WebCore/page/Page.cpp 2016-02-02 19:43:16 UTC (rev 196023)
@@ -1305,10 +1305,7 @@
{
chrome().client().setPageActivityState(activityState);
- if (activityState == PageActivityState::NoFlags && !isVisible())
- scheduleTabSuspension(true);
- else
- scheduleTabSuspension(false);
+ updateTabSuspensionState();
}
void Page::setIsVisible(bool isVisible)
@@ -1361,7 +1358,7 @@
view->hide();
}
- scheduleTabSuspension(!isVisible);
+ updateTabSuspensionState();
}
void Page::setIsPrerender()
@@ -1867,17 +1864,29 @@
return false;
if (m_isPrerender)
return false;
+ if (isVisible())
+ return false;
if (m_pageThrottler.activityState() != PageActivityState::NoFlags)
return false;
- // FIXME: PageCache::canCache does a bunch of checks that are not needed for the tab suspension case. There should be a specific check.
- if (!PageCache::singleton().canCache(*this))
- return false;
+ for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ if (frame->loader().state() != FrameStateComplete)
+ return false;
+ if (frame->loader().isLoading())
+ return false;
+ if (!frame->document() || !frame->document()->canSuspendActiveDOMObjectsForDocumentSuspension(nullptr))
+ return false;
+ }
+
return true;
}
void Page::setIsTabSuspended(bool shouldSuspend)
{
+ if (m_isTabSuspended == shouldSuspend)
+ return;
+ m_isTabSuspended = shouldSuspend;
+
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (auto* document = frame->document()) {
if (shouldSuspend)
@@ -1893,26 +1902,20 @@
s_tabSuspensionIsEnabled = enable;
}
-void Page::scheduleTabSuspension(bool shouldSuspend)
+void Page::updateTabSuspensionState()
{
- if (m_shouldTabSuspend == shouldSuspend)
+ if (canTabSuspend()) {
+ const auto tabSuspensionDelay = std::chrono::minutes(1);
+ m_tabSuspensionTimer.startOneShot(tabSuspensionDelay);
return;
-
- if (shouldSuspend && canTabSuspend()) {
- m_shouldTabSuspend = shouldSuspend;
- m_tabSuspensionTimer.startOneShot(0);
- } else {
- m_tabSuspensionTimer.stop();
- if (!shouldSuspend) {
- m_shouldTabSuspend = shouldSuspend;
- setIsTabSuspended(false);
- }
}
+ m_tabSuspensionTimer.stop();
+ setIsTabSuspended(false);
}
void Page::tabSuspensionTimerFired()
{
- setIsTabSuspended(true);
+ setIsTabSuspended(canTabSuspend());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/page/Page.h (196022 => 196023)
--- trunk/Source/WebCore/page/Page.h 2016-02-02 19:33:05 UTC (rev 196022)
+++ trunk/Source/WebCore/page/Page.h 2016-02-02 19:43:16 UTC (rev 196023)
@@ -521,7 +521,7 @@
void hiddenPageDOMTimerThrottlingStateChanged();
void setTimerThrottlingEnabled(bool);
bool canTabSuspend();
- void scheduleTabSuspension(bool);
+ void updateTabSuspensionState();
void tabSuspensionTimerFired();
const std::unique_ptr<Chrome> m_chrome;
@@ -663,7 +663,7 @@
SessionID m_sessionID;
bool m_isClosing;
- bool m_shouldTabSuspend { false };
+ bool m_isTabSuspended { false };
Timer m_tabSuspensionTimer;
MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes