Detach frame from document when entering page cache
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Feb 2017 02:53:53 +0000 (02:53 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Feb 2017 02:53:53 +0000 (02:53 +0000)
commit473bf2f6c51deec90eeb5fe355cac58c3a0fd8ec
treed7000b23f7ab4a0fa8941ef908514973ca334f1c
parent378c532fe322cda07afaefe471f1b6dc49b0c278
Detach frame from document when entering page cache
https://bugs.webkit.org/show_bug.cgi?id=166774
<rdar://problem/29904368>

Reviewed by Chris Dumez.

Source/WebCore:

When a page enters the page cache it is unnecessary for it to hold a reference to its
associated frame because subsequent interactions with the page do not need to make use
of it. Once a page exits the page cache we associate it with its frame.

* dom/Document.cpp:
(WebCore::Document::frameDestroyed): Update comment to reflect the renaming of disconnectFromFrame().
(WebCore::Document::attachToCachedFrame): Added.
(WebCore::Document::detachFromCachedFrame): Added.
(WebCore::Document::prepareForDestruction): Only call CSSAnimationController::detachFromDocument() if
we have a frame. Substitute detachFromFrame() for disconnectFromFrame() as the latter was renamed to
the former.
(WebCore::Document::hasEverCalledWindowOpen): Deleted.
(WebCore::Document::markHasCalledWindowOpen): Deleted.
(WebCore::Document::disconnectFromFrame): Renamed to detachFromFrame.
* dom/Document.h:
(WebCore::Document::detachFromFrame): Renamed; formerly named disconnectFromFrame(). Changed
visibility from public to private and made this function inline.
* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::pruneDetachedChildFrames): Remove cached child frames that were
removed from the page when it was in the page cache as there is no need to restore such frames.
(WebCore::CachedFrameBase::restore): Call pruneDetachedChildFrames() before restoring the
frame tree.
(WebCore::CachedFrame::CachedFrame): Detach from the frame.
(WebCore::CachedFrame::open): Assert that we have a document and re-attach the frame.
(WebCore::CachedFrame::destroy): Update assertion as this function should only be called for a
frameless document. Only detach the FrameView, DocumentLoader, and Page when the cached frame is for
subframe and is associated with a Page object. Call CSSAnimationController::detachFromDocument() to
detach the animation controller from the document as it is being destroyed. We have to do this here
because the document does not have a frame. And Document::prepareForDestruction() only calls
CSSAnimationController::detachFromDocument() if the document has a frame.
* history/CachedFrame.h:
* history/PageCache.cpp:
(WebCore::canCachePage): Remove logic that prevents caching of a page that called window.open()
or has an opener as it is feasible to keep such pages in the page cache.
* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::finishedInsertingSubtree): Fix style nit.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::frameDetached): Only stop all loaders and stop active DOM objects if the
page is not in- or about to enter- the page cache. A page in the page cache has finished loading
and its active DOM objects are suspended. Also fix style nit in comment.
(WebCore::FrameLoader::detachFromParent): Only stop all loaders if the page is not in- or about to
enter- the page cache. A page in the page cache has finished loading. Also added a comment to explain
that we protect the frame because stopAllLoaders() can cause the frame to be deallocated.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::createWindow): Remove logic to call markHasCalledWindowOpen() as this
function will be removed.
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::hasCalledWindowOpenKey): Deleted.
(WebCore::DiagnosticLoggingKeys::hasOpenerKey): Deleted.
* page/DiagnosticLoggingKeys.h:
* page/Page.cpp:
(WebCore::Page::openedByWindowOpen): Deleted.
* page/Page.h:
* page/Settings.in: Remove setting allowsPageCacheWithWindowOpener.

Source/WebKit/mac:

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences allowsPageCacheWithWindowOpener]): Deleted.
(-[WebPreferences setAllowsPageCacheWithWindowOpener:]): Deleted.
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKit/win:

* Interfaces/IWebPreferencesPrivate.idl:
* WebPreferenceKeysPrivate.h:
* WebPreferences.cpp:
(WebPreferences::initializeDefaultSettings):
(WebPreferences::setAllowsPageCacheWithWindowOpener): Deleted.
(WebPreferences::allowsPageCacheWithWindowOpener): Deleted.
* WebPreferences.h:
* WebView.cpp:
(WebView::notifyPreferencesChanged):

Source/WebKit2:

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetAllowsPageCacheWithWindowOpener): Deleted.
(WKPreferencesGetAllowsPageCacheWithWindowOpener): Deleted.
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
* DumpRenderTree/win/DumpRenderTree.cpp:
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212173 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/editing/mac/input/unconfirmed-text-navigation-with-page-cache.html
LayoutTests/fast/harness/page-cache-crash-on-data-urls.html
LayoutTests/fast/harness/use-page-cache.html
LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html
LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html
LayoutTests/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/history/CachedFrame.cpp
Source/WebCore/history/CachedFrame.h
Source/WebCore/history/PageCache.cpp
Source/WebCore/html/HTMLFrameElementBase.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/Settings.in
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl
Source/WebKit/win/WebPreferenceKeysPrivate.h
Source/WebKit/win/WebPreferences.cpp
Source/WebKit/win/WebPreferences.h
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/win/DumpRenderTree.cpp
Tools/WebKitTestRunner/TestController.cpp