Changeset 205805 in webkit


Ignore:
Timestamp:
Sep 12, 2016 2:26:19 AM (8 years ago)
Author:
Chris Dumez
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:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205791 r205805  
     12016-09-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Start using Document::pageCacheState() instead of Document::inPageCache()
     4        https://bugs.webkit.org/show_bug.cgi?id=161851
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Start using Document::pageCacheState() instead of Document::inPageCache()
     9        as the latter one is confusing (given that it is true when firing the
     10        pagehide event, when the document is about to enter page cache).
     11
     12        * loader/FrameLoader.cpp:
     13        (WebCore::FrameLoader::closeURL):
     14        (WebCore::FrameLoader::clear):
     15        (WebCore::FrameLoader::dispatchUnloadEvents):
     16        * loader/cache/CachedResource.cpp:
     17        (WebCore::CachedResource::load):
     18        * page/Page.cpp:
     19        (WebCore::incrementFrame): Deleted.
     20        * page/Page.h:
     21
    1222016-09-11  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r205786 r205805  
    518518    } else {
    519519        // Should only send the pagehide event here if the current document exists and has not been placed in the page cache.
    520         unloadEventPolicy = currentDocument && !currentDocument->inPageCache() ? UnloadEventPolicyUnloadAndPageHide : UnloadEventPolicyUnloadOnly;
     520        unloadEventPolicy = currentDocument && currentDocument->pageCacheState() == Document::NotInPageCache ? UnloadEventPolicyUnloadAndPageHide : UnloadEventPolicyUnloadOnly;
    521521    }
    522522
     
    591591    m_needsClear = false;
    592592   
    593     if (!m_frame.document()->inPageCache()) {
     593    if (m_frame.document()->pageCacheState() != Document::InPageCache) {
    594594        m_frame.document()->cancelParsing();
    595595        m_frame.document()->stopActiveDOMObjects();
     
    604604        InspectorInstrumentation::frameWindowDiscarded(&m_frame, m_frame.document()->domWindow());
    605605        m_frame.document()->domWindow()->resetUnlessSuspendedForDocumentSuspension();
    606         m_frame.script().clearWindowShell(newDocument->domWindow(), m_frame.document()->inPageCache());
     606        m_frame.script().clearWindowShell(newDocument->domWindow(), m_frame.document()->pageCacheState() == Document::AboutToEnterPageCache);
    607607    }
    608608
     
    29252925            if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
    29262926                m_pageDismissalEventBeingDispatched = PageDismissalType::PageHide;
    2927                 m_frame.document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()->inPageCache()), m_frame.document());
     2927                m_frame.document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()->pageCacheState() == Document::AboutToEnterPageCache), m_frame.document());
    29282928            }
    29292929
     
    29312931            // https://bugs.webkit.org/show_bug.cgi?id=116770
    29322932
    2933             if (!m_frame.document()->inPageCache()) {
     2933            if (m_frame.document()->pageCacheState() == Document::NotInPageCache) {
    29342934                Ref<Event> unloadEvent(Event::create(eventNames().unloadEvent, false, false));
    29352935                // The DocumentLoader (and thus its LoadTiming) might get destroyed
     
    29572957        return;
    29582958
    2959     if (m_frame.document()->inPageCache())
     2959    if (m_frame.document()->pageCacheState() != Document::NotInPageCache)
    29602960        return;
    29612961
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r205750 r205805  
    269269
    270270    // Prevent new loads if we are in the PageCache or being added to the PageCache.
    271     if (frame.page() && frame.page()->inPageCache()) {
    272         failBeforeStarting();
    273         return;
     271    // We query the top document because new frames may be created in pagehide event handlers
     272    // and their pageCacheState will not reflect the fact that they are about to enter page
     273    // cache.
     274    if (auto* topDocument = frame.mainFrame().document()) {
     275        if (topDocument->pageCacheState() != Document::NotInPageCache) {
     276            failBeforeStarting();
     277            return;
     278        }
    274279    }
    275280
  • trunk/Source/WebCore/page/Page.cpp

    r204637 r205805  
    580580}
    581581
    582 bool Page::inPageCache() const
    583 {
    584     auto* document = mainFrame().document();
    585     return document && document->inPageCache();
    586 }
    587 
    588582static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag)
    589583{
  • trunk/Source/WebCore/page/Page.h

    r204466 r205805  
    167167    const MainFrame& mainFrame() const { return m_mainFrame.get(); }
    168168
    169     bool inPageCache() const;
    170 
    171169    bool openedByDOM() const;
    172170    void setOpenedByDOM();
Note: See TracChangeset for help on using the changeset viewer.