Title: [205805] trunk/Source/WebCore
Revision
205805
Author
[email protected]
Date
2016-09-12 02:26:19 -0700 (Mon, 12 Sep 2016)

Log Message

Start using Document::pageCacheState() instead of Document::inPageCache()
https://bugs.webkit.org/show_bug.cgi?id=161851

Reviewed by Ryosuke Niwa.

Start using Document::pageCacheState() instead of Document::inPageCache()
as the latter one is confusing (given that it is true when firing the
pagehide event, when the document is about to enter page cache).

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::closeURL):
(WebCore::FrameLoader::clear):
(WebCore::FrameLoader::dispatchUnloadEvents):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::load):
* page/Page.cpp:
(WebCore::incrementFrame): Deleted.
* page/Page.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (205804 => 205805)


--- trunk/Source/WebCore/ChangeLog	2016-09-12 08:09:49 UTC (rev 205804)
+++ trunk/Source/WebCore/ChangeLog	2016-09-12 09:26:19 UTC (rev 205805)
@@ -1,3 +1,24 @@
+2016-09-12  Chris Dumez  <[email protected]>
+
+        Start using Document::pageCacheState() instead of Document::inPageCache()
+        https://bugs.webkit.org/show_bug.cgi?id=161851
+
+        Reviewed by Ryosuke Niwa.
+
+        Start using Document::pageCacheState() instead of Document::inPageCache()
+        as the latter one is confusing (given that it is true when firing the
+        pagehide event, when the document is about to enter page cache).
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::closeURL):
+        (WebCore::FrameLoader::clear):
+        (WebCore::FrameLoader::dispatchUnloadEvents):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::load):
+        * page/Page.cpp:
+        (WebCore::incrementFrame): Deleted.
+        * page/Page.h:
+
 2016-09-11  Chris Dumez  <[email protected]>
 
         HTMLTrackElement.kind's invalid value default should be the metadata state

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (205804 => 205805)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2016-09-12 08:09:49 UTC (rev 205804)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2016-09-12 09:26:19 UTC (rev 205805)
@@ -517,7 +517,7 @@
         unloadEventPolicy = UnloadEventPolicyNone;
     } else {
         // Should only send the pagehide event here if the current document exists and has not been placed in the page cache.
-        unloadEventPolicy = currentDocument && !currentDocument->inPageCache() ? UnloadEventPolicyUnloadAndPageHide : UnloadEventPolicyUnloadOnly;
+        unloadEventPolicy = currentDocument && currentDocument->pageCacheState() == Document::NotInPageCache ? UnloadEventPolicyUnloadAndPageHide : UnloadEventPolicyUnloadOnly;
     }
 
     stopLoading(unloadEventPolicy);
@@ -590,7 +590,7 @@
         return;
     m_needsClear = false;
     
-    if (!m_frame.document()->inPageCache()) {
+    if (m_frame.document()->pageCacheState() != Document::InPageCache) {
         m_frame.document()->cancelParsing();
         m_frame.document()->stopActiveDOMObjects();
         bool hadLivingRenderTree = m_frame.document()->hasLivingRenderTree();
@@ -603,7 +603,7 @@
     if (clearWindowProperties) {
         InspectorInstrumentation::frameWindowDiscarded(&m_frame, m_frame.document()->domWindow());
         m_frame.document()->domWindow()->resetUnlessSuspendedForDocumentSuspension();
-        m_frame.script().clearWindowShell(newDocument->domWindow(), m_frame.document()->inPageCache());
+        m_frame.script().clearWindowShell(newDocument->domWindow(), m_frame.document()->pageCacheState() == Document::AboutToEnterPageCache);
     }
 
     m_frame.selection().prepareForDestruction();
@@ -2924,13 +2924,13 @@
         if (m_pageDismissalEventBeingDispatched == PageDismissalType::None) {
             if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
                 m_pageDismissalEventBeingDispatched = PageDismissalType::PageHide;
-                m_frame.document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()->inPageCache()), m_frame.document());
+                m_frame.document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()->pageCacheState() == Document::AboutToEnterPageCache), m_frame.document());
             }
 
             // FIXME: update Page Visibility state here.
             // https://bugs.webkit.org/show_bug.cgi?id=116770
 
-            if (!m_frame.document()->inPageCache()) {
+            if (m_frame.document()->pageCacheState() == Document::NotInPageCache) {
                 Ref<Event> unloadEvent(Event::create(eventNames().unloadEvent, false, false));
                 // The DocumentLoader (and thus its LoadTiming) might get destroyed
                 // while dispatching the event, so protect it to prevent writing the end
@@ -2956,7 +2956,7 @@
     if (!m_frame.document())
         return;
 
-    if (m_frame.document()->inPageCache())
+    if (m_frame.document()->pageCacheState() != Document::NotInPageCache)
         return;
 
     // Don't remove event listeners from a transitional empty document (see bug 28716 for more information).

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (205804 => 205805)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2016-09-12 08:09:49 UTC (rev 205804)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2016-09-12 09:26:19 UTC (rev 205805)
@@ -268,9 +268,14 @@
     Frame& frame = *cachedResourceLoader.frame();
 
     // Prevent new loads if we are in the PageCache or being added to the PageCache.
-    if (frame.page() && frame.page()->inPageCache()) {
-        failBeforeStarting();
-        return;
+    // We query the top document because new frames may be created in pagehide event handlers
+    // and their pageCacheState will not reflect the fact that they are about to enter page
+    // cache.
+    if (auto* topDocument = frame.mainFrame().document()) {
+        if (topDocument->pageCacheState() != Document::NotInPageCache) {
+            failBeforeStarting();
+            return;
+        }
     }
 
     FrameLoader& frameLoader = frame.loader();

Modified: trunk/Source/WebCore/page/Page.cpp (205804 => 205805)


--- trunk/Source/WebCore/page/Page.cpp	2016-09-12 08:09:49 UTC (rev 205804)
+++ trunk/Source/WebCore/page/Page.cpp	2016-09-12 09:26:19 UTC (rev 205805)
@@ -579,12 +579,6 @@
     }
 }
 
-bool Page::inPageCache() const
-{
-    auto* document = mainFrame().document();
-    return document && document->inPageCache();
-}
-
 static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag)
 {
     return forward

Modified: trunk/Source/WebCore/page/Page.h (205804 => 205805)


--- trunk/Source/WebCore/page/Page.h	2016-09-12 08:09:49 UTC (rev 205804)
+++ trunk/Source/WebCore/page/Page.h	2016-09-12 09:26:19 UTC (rev 205805)
@@ -166,8 +166,6 @@
     MainFrame& mainFrame() { return m_mainFrame.get(); }
     const MainFrame& mainFrame() const { return m_mainFrame.get(); }
 
-    bool inPageCache() const;
-
     bool openedByDOM() const;
     void setOpenedByDOM();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to