Switch remaining users of Document::inPageCache() to pageCacheState()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Sep 2016 19:50:50 +0000 (19:50 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Sep 2016 19:50:50 +0000 (19:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161865

Reviewed by Darin Adler.

Switch remaining users of Document::inPageCache() to pageCacheState() as
the former one is confusing (given that it returns true while the
pagehide event is being fired).

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::scheduleStyleRecalc):
(WebCore::Document::fontsNeedUpdate):
(WebCore::Document::removeFocusedNodeOfSubtree):
(WebCore::Document::setFocusedElement):
(WebCore::Document::takeDOMWindowFrom):
(WebCore::Document::topDocument):
(WebCore::Document::webkitWillEnterFullScreenForElement):
(WebCore::Document::webkitDidEnterFullScreenForElement):
(WebCore::Document::webkitWillExitFullScreenForElement):
(WebCore::Document::webkitDidExitFullScreenForElement):
* dom/Document.h:
(WebCore::Document::needsStyleRecalc):
(WebCore::Document::inPageCache): Deleted.
* history/CachedFrame.cpp:
(WebCore::CachedFrame::CachedFrame):
(WebCore::CachedFrame::clear):
(WebCore::CachedFrame::destroy):
* html/HTMLMediaElement.cpp:
(WebCore::mediaElementIsAllowedToAutoplay):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::createElementRenderer):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/HistoryController.cpp:
(WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::decrementScrollEventListenersCount):
* page/FrameView.cpp:
(WebCore::FrameView::layout):
* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::setNeedsStyleRecalc):
* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::updateAnimations):
(WebCore::AnimationControllerPrivate::addElementChangeToDispatch):
(WebCore::AnimationController::cancelAnimations):
(WebCore::AnimationController::updateAnimations):
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::sendTransitionEvent):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::sendAnimationEvent):
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
* rendering/RenderElement.cpp:
(WebCore::shouldRepaintForImageAnimation):
(WebCore::RenderElement::newImageAnimationFrameAvailable):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::imageChanged):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateCompositingLayers):
(WebCore::RenderLayerCompositor::willRemoveScrollingLayerWithBacking):
(WebCore::RenderLayerCompositor::didAddScrollingLayer):
* rendering/RenderObject.cpp:
(WebCore::printRenderTreeForLiveDocuments):
(WebCore::printLayerTreeForLiveDocuments):
* rendering/RenderView.cpp:
(WebCore::RenderView::lazyRepaintTimerFired):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::collectNonEmptyLeafRenderBlockFlowsForCurrentPage):

Source/WebKit/mac:

* WebView/WebHTMLView.mm:
(-[WebHTMLView layoutToMinimumPageWidth:height:originalPageWidth:originalPageHeight:maximumShrinkRatio:adjustingViewSize:]):
(-[WebHTMLView setNeedsLayout:]):
(-[WebHTMLView setNeedsToApplyStyles:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@205818 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/history/CachedFrame.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/animation/AnimationBase.cpp
Source/WebCore/page/animation/AnimationController.cpp
Source/WebCore/page/animation/ImplicitAnimation.cpp
Source/WebCore/page/animation/KeyframeAnimation.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/SimpleLineLayout.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm

index c0dba4f..a60c8bf 100644 (file)
@@ -1,3 +1,74 @@
+2016-09-12  Chris Dumez  <cdumez@apple.com>
+
+        Switch remaining users of Document::inPageCache() to pageCacheState()
+        https://bugs.webkit.org/show_bug.cgi?id=161865
+
+        Reviewed by Darin Adler.
+
+        Switch remaining users of Document::inPageCache() to pageCacheState() as
+        the former one is confusing (given that it returns true while the
+        pagehide event is being fired).
+
+        * dom/Document.cpp:
+        (WebCore::Document::scheduleStyleRecalc):
+        (WebCore::Document::fontsNeedUpdate):
+        (WebCore::Document::removeFocusedNodeOfSubtree):
+        (WebCore::Document::setFocusedElement):
+        (WebCore::Document::takeDOMWindowFrom):
+        (WebCore::Document::topDocument):
+        (WebCore::Document::webkitWillEnterFullScreenForElement):
+        (WebCore::Document::webkitDidEnterFullScreenForElement):
+        (WebCore::Document::webkitWillExitFullScreenForElement):
+        (WebCore::Document::webkitDidExitFullScreenForElement):
+        * dom/Document.h:
+        (WebCore::Document::needsStyleRecalc):
+        (WebCore::Document::inPageCache): Deleted.
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrame::CachedFrame):
+        (WebCore::CachedFrame::clear):
+        (WebCore::CachedFrame::destroy):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::mediaElementIsAllowedToAutoplay):
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::createElementRenderer):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::addSubresourceLoader):
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::decrementScrollEventListenersCount):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::setNeedsStyleRecalc):
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::updateAnimations):
+        (WebCore::AnimationControllerPrivate::addElementChangeToDispatch):
+        (WebCore::AnimationController::cancelAnimations):
+        (WebCore::AnimationController::updateAnimations):
+        * page/animation/ImplicitAnimation.cpp:
+        (WebCore::ImplicitAnimation::sendTransitionEvent):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::sendAnimationEvent):
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
+        * rendering/RenderElement.cpp:
+        (WebCore::shouldRepaintForImageAnimation):
+        (WebCore::RenderElement::newImageAnimationFrameAvailable):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::imageChanged):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateCompositingLayers):
+        (WebCore::RenderLayerCompositor::willRemoveScrollingLayerWithBacking):
+        (WebCore::RenderLayerCompositor::didAddScrollingLayer):
+        * rendering/RenderObject.cpp:
+        (WebCore::printRenderTreeForLiveDocuments):
+        (WebCore::printLayerTreeForLiveDocuments):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::lazyRepaintTimerFired):
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::collectNonEmptyLeafRenderBlockFlowsForCurrentPage):
+
 2016-09-12  Keith Rollin  <krollin@apple.com>
 
         Enhance Network logging
index d3193dc..8d9338a 100644 (file)
@@ -1812,7 +1812,7 @@ void Document::scheduleForcedStyleRecalc()
 
 void Document::scheduleStyleRecalc()
 {
-    if (m_styleRecalcTimer.isActive() || inPageCache())
+    if (m_styleRecalcTimer.isActive() || pageCacheState() != NotInPageCache)
         return;
 
     ASSERT(childNeedsStyleRecalc() || m_pendingStyleRecalcShouldForce);
@@ -2220,7 +2220,7 @@ void Document::fontsNeedUpdate(FontSelector&)
 {
     if (m_styleResolver)
         m_styleResolver->invalidateMatchedPropertiesCache();
-    if (inPageCache() || !renderView())
+    if (pageCacheState() != NotInPageCache || !renderView())
         return;
     scheduleForcedStyleRecalc();
 }
@@ -3724,7 +3724,7 @@ static bool isNodeInSubtree(Node* node, Node* container, bool amongChildrenOnly)
 
 void Document::removeFocusedNodeOfSubtree(Node* node, bool amongChildrenOnly)
 {
-    if (!m_focusedElement || this->inPageCache()) // If the document is in the page cache, then we don't need to clear out the focused node.
+    if (!m_focusedElement || pageCacheState() != NotInPageCache) // If the document is in the page cache, then we don't need to clear out the focused node.
         return;
 
     Element* focusedElement = node->treeScope().focusedElement();
@@ -3786,7 +3786,7 @@ bool Document::setFocusedElement(Element* element, FocusDirection direction, Foc
     if (m_focusedElement == newFocusedElement)
         return true;
 
-    if (inPageCache())
+    if (pageCacheState() != NotInPageCache)
         return false;
 
     bool focusChangeBlocked = false;
@@ -4198,7 +4198,7 @@ void Document::takeDOMWindowFrom(Document* document)
     ASSERT(!m_domWindow);
     ASSERT(document->m_domWindow);
     // A valid DOMWindow is needed by CachedFrame for its documents.
-    ASSERT(!document->inPageCache());
+    ASSERT(pageCacheState() == NotInPageCache);
 
     m_domWindow = WTFMove(document->m_domWindow);
     m_domWindow->didSecureTransitionTo(this);
@@ -5070,7 +5070,7 @@ Document& Document::topDocument() const
 {
     // FIXME: This special-casing avoids incorrectly determined top documents during the process
     // of AXObjectCache teardown or notification posting for cached or being-destroyed documents.
-    if (!inPageCache() && !m_renderTreeBeingDestroyed) {
+    if (pageCacheState() == NotInPageCache && !m_renderTreeBeingDestroyed) {
         if (!m_frame)
             return const_cast<Document&>(*this);
         // This should always be non-null.
@@ -5977,7 +5977,7 @@ static void unwrapFullScreenRenderer(RenderFullScreen* fullScreenRenderer, Eleme
 
 void Document::webkitWillEnterFullScreenForElement(Element* element)
 {
-    if (!hasLivingRenderTree() || inPageCache())
+    if (!hasLivingRenderTree() || pageCacheState() != NotInPageCache)
         return;
 
     ASSERT(element);
@@ -6024,7 +6024,7 @@ void Document::webkitDidEnterFullScreenForElement(Element*)
     if (!m_fullScreenElement)
         return;
 
-    if (!hasLivingRenderTree() || inPageCache())
+    if (!hasLivingRenderTree() || pageCacheState() != NotInPageCache)
         return;
 
     m_fullScreenElement->didBecomeFullscreenElement();
@@ -6037,7 +6037,7 @@ void Document::webkitWillExitFullScreenForElement(Element*)
     if (!m_fullScreenElement)
         return;
 
-    if (!hasLivingRenderTree() || inPageCache())
+    if (!hasLivingRenderTree() || pageCacheState() != NotInPageCache)
         return;
 
     m_fullScreenElement->willStopBeingFullscreenElement();
@@ -6048,7 +6048,7 @@ void Document::webkitDidExitFullScreenForElement(Element*)
     if (!m_fullScreenElement)
         return;
 
-    if (!hasLivingRenderTree() || inPageCache())
+    if (!hasLivingRenderTree() || pageCacheState() != NotInPageCache)
         return;
 
     m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
index 5407f32..145f818 100644 (file)
@@ -561,7 +561,7 @@ public:
 
     void recalcStyle(Style::Change = Style::NoChange);
     WEBCORE_EXPORT void updateStyleIfNeeded();
-    bool needsStyleRecalc() const { return !inPageCache() && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); }
+    bool needsStyleRecalc() const { return pageCacheState() == NotInPageCache && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); }
 
     WEBCORE_EXPORT void updateLayout();
     
@@ -1006,9 +1006,6 @@ public:
     PageCacheState pageCacheState() const { return m_pageCacheState; }
     void setPageCacheState(PageCacheState);
 
-    // FIXME: Update callers to use pageCacheState() instead.
-    bool inPageCache() const { return m_pageCacheState != NotInPageCache; }
-
     // Elements can register themselves for the "suspend()" and
     // "resume()" callbacks
     void registerForDocumentSuspensionCallbacks(Element*);
index 4b686d3..6a6668c 100644 (file)
@@ -150,7 +150,7 @@ CachedFrame::CachedFrame(Frame& frame)
     // Custom scrollbar renderers will get reattached when the document comes out of the page cache
     m_view->detachCustomScrollbars();
 
-    ASSERT(m_document->inPageCache());
+    ASSERT(m_document->pageCacheState() == Document::InPageCache);
 
     // Create the CachedFrames for all Frames in the FrameTree.
     for (Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling())
@@ -220,7 +220,7 @@ void CachedFrame::clear()
     // This means the CachedFrame has been:
     // 1 - Successfully restore()'d by going back/forward.
     // 2 - destroy()'ed because the PageCache is pruning or the WebView was closed.
-    ASSERT(!m_document->inPageCache());
+    ASSERT(m_document->pageCacheState() == Document::NotInPageCache);
     ASSERT(m_view);
     ASSERT(!m_document->frame() || m_document->frame() == &m_view->frame());
 
@@ -241,7 +241,7 @@ void CachedFrame::destroy()
         return;
     
     // Only CachedFrames that are still in the PageCache should be destroyed in this manner
-    ASSERT(m_document->inPageCache());
+    ASSERT(m_document->pageCacheState() == Document::InPageCache);
     ASSERT(m_view);
     ASSERT(m_document->frame() == &m_view->frame());
 
index 17fb88b..7804c3b 100644 (file)
@@ -7221,7 +7221,7 @@ bool HTMLMediaElement::isVideoTooSmallForInlinePlayback()
 static bool mediaElementIsAllowedToAutoplay(const HTMLMediaElement& element)
 {
     const Document& document = element.document();
-    if (document.inPageCache())
+    if (document.pageCacheState() != Document::NotInPageCache)
         return false;
     if (document.activeDOMObjectsAreSuspended())
         return false;
index 2a80374..1cbc3e5 100644 (file)
@@ -198,7 +198,7 @@ bool HTMLPlugInImageElement::wouldLoadAsPlugIn(const String& url, const String&
 
 RenderPtr<RenderElement> HTMLPlugInImageElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition& insertionPosition)
 {
-    ASSERT(!document().inPageCache());
+    ASSERT(document().pageCacheState() == Document::NotInPageCache);
 
     if (displayState() >= PreparingPluginReplacement)
         return HTMLPlugInElement::createElementRenderer(WTFMove(style), insertionPosition);
index 3484c3d..de8ce31 100644 (file)
@@ -1406,8 +1406,8 @@ void DocumentLoader::addSubresourceLoader(ResourceLoader* loader)
     ASSERT(!m_subresourceLoaders.contains(loader->identifier()));
     ASSERT(!mainResourceLoader() || mainResourceLoader() != loader);
 
-    // A page in the PageCache should not be able to start loads.
-    ASSERT_WITH_SECURITY_IMPLICATION(!document() || !document()->inPageCache());
+    // A page in the PageCache or about to enter PageCache should not be able to start loads.
+    ASSERT_WITH_SECURITY_IMPLICATION(!document() || document()->pageCacheState() == Document::NotInPageCache);
 
     m_subresourceLoaders.add(loader->identifier(), loader);
 }
index a2c6234..cf6e19c 100644 (file)
@@ -75,7 +75,7 @@ void HistoryController::saveScrollPositionAndViewStateToItem(HistoryItem* item)
     if (!item || !frameView)
         return;
 
-    if (m_frame.document()->inPageCache())
+    if (m_frame.document()->pageCacheState() != Document::NotInPageCache)
         item->setScrollPosition(frameView->cachedScrollPosition());
     else
         item->setScrollPosition(frameView->scrollPosition());
index 36cdbca..56ea9ab 100644 (file)
@@ -1803,7 +1803,7 @@ void DOMWindow::decrementScrollEventListenersCount()
     Document* document = this->document();
     if (!--m_scrollEventListenerCount && document == &document->topDocument()) {
         Frame* frame = this->frame();
-        if (frame && frame->page() && !document->inPageCache())
+        if (frame && frame->page() && document->pageCacheState() == Document::NotInPageCache)
             frame->page()->chrome().client().setNeedsScrollNotifications(frame, false);
     }
 }
index 8331fc8..2c6d860 100644 (file)
@@ -1296,7 +1296,7 @@ void FrameView::layout(bool allowSubtree)
     ASSERT(frame().document());
 
     Document& document = *frame().document();
-    ASSERT(!document.inPageCache());
+    ASSERT(document.pageCacheState() == Document::NotInPageCache);
 
     {
         TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
index 5c1b3a8..28d499c 100644 (file)
@@ -89,7 +89,7 @@ AnimationBase::AnimationBase(const Animation& animation, RenderElement* renderer
 
 void AnimationBase::setNeedsStyleRecalc(Element* element)
 {
-    ASSERT(!element || !element->document().inPageCache());
+    ASSERT(!element || element->document().pageCacheState() == Document::NotInPageCache);
     if (element)
         element->setNeedsStyleRecalc(SyntheticStyleChange);
 }
index c3efb5d..2a0218f 100644 (file)
@@ -137,7 +137,7 @@ double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/*
                     break;
                 Element* element = compositeAnimation.key->element();
                 ASSERT(element);
-                ASSERT(!element->document().inPageCache());
+                ASSERT(element->document().pageCacheState() == Document::NotInPageCache);
                 element->setNeedsStyleRecalc(SyntheticStyleChange);
                 calledSetChanged = true;
             }
@@ -240,7 +240,7 @@ void AnimationControllerPrivate::addEventToDispatch(PassRefPtr<Element> element,
 void AnimationControllerPrivate::addElementChangeToDispatch(Ref<Element>&& element)
 {
     m_elementChangesToDispatch.append(WTFMove(element));
-    ASSERT(!m_elementChangesToDispatch.last()->document().inPageCache());
+    ASSERT(m_elementChangesToDispatch.last()->document().pageCacheState() == Document::NotInPageCache);
     startUpdateStyleIfNeededDispatcher();
 }
 
@@ -588,7 +588,7 @@ void AnimationController::cancelAnimations(RenderElement& renderer)
         return;
 
     Element* element = renderer.element();
-    ASSERT(!element || !element->document().inPageCache());
+    ASSERT(!element || element->document().pageCacheState() == Document::NotInPageCache);
     if (element)
         element->setNeedsStyleRecalc(SyntheticStyleChange);
 }
@@ -599,7 +599,7 @@ bool AnimationController::updateAnimations(RenderElement& renderer, const Render
     if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle.animations() && !newStyle.transitions()))
         return false;
 
-    if (renderer.document().inPageCache())
+    if (renderer.document().pageCacheState() != Document::NotInPageCache)
         return false;
 
     // Don't run transitions when printing.
index c70053e..8752dd2 100644 (file)
@@ -188,7 +188,7 @@ bool ImplicitAnimation::sendTransitionEvent(const AtomicString& eventType, doubl
             // Dispatch the event
             RefPtr<Element> element = m_object->element();
 
-            ASSERT(!element || !element->document().inPageCache());
+            ASSERT(!element || element->document().pageCacheState() == Document::NotInPageCache);
             if (!element)
                 return false;
 
index 6e9e5cc..ac8ab01 100644 (file)
@@ -313,7 +313,7 @@ bool KeyframeAnimation::sendAnimationEvent(const AtomicString& eventType, double
         // Dispatch the event
         RefPtr<Element> element = m_object->element();
 
-        ASSERT(!element || !element->document().inPageCache());
+        ASSERT(!element || element->document().pageCacheState() == Document::NotInPageCache);
         if (!element)
             return false;
 
index 34a74c8..94377bd 100644 (file)
@@ -212,12 +212,12 @@ bool AsyncScrollingCoordinator::requestScrollPositionUpdate(FrameView& frameView
         return false;
 
     bool isProgrammaticScroll = frameView.inProgrammaticScroll();
-    if (isProgrammaticScroll || frameView.frame().document()->inPageCache())
+    if (isProgrammaticScroll || frameView.frame().document()->pageCacheState() != Document::NotInPageCache)
         updateScrollPositionAfterAsyncScroll(frameView.scrollLayerID(), scrollPosition, isProgrammaticScroll, SetScrollingLayerPosition);
 
     // If this frame view's document is being put into the page cache, we don't want to update our
     // main frame scroll position. Just let the FrameView think that we did.
-    if (frameView.frame().document()->inPageCache())
+    if (frameView.frame().document()->pageCacheState() != Document::NotInPageCache)
         return true;
 
     ScrollingStateScrollingNode* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollLayerID()));
index 8090788..c5097f7 100644 (file)
@@ -1435,7 +1435,7 @@ bool RenderElement::mayCauseRepaintInsideViewport(const IntRect* optionalViewpor
 static bool shouldRepaintForImageAnimation(const RenderElement& renderer, const IntRect& visibleRect)
 {
     const Document& document = renderer.document();
-    if (document.inPageCache())
+    if (document.pageCacheState() != Document::NotInPageCache)
         return false;
     if (document.activeDOMObjectsAreSuspended())
         return false;
@@ -1495,7 +1495,7 @@ void RenderElement::visibleInViewportStateChanged(VisibleInViewportState state)
 
 void RenderElement::newImageAnimationFrameAvailable(CachedImage& image)
 {
-    if (document().inPageCache())
+    if (document().pageCacheState() != Document::NotInPageCache)
         return;
     auto& frameView = view().frameView();
     auto visibleRect = frameView.windowToContents(frameView.windowClipRect());
index 8c7f476..2c8340e 100644 (file)
@@ -233,7 +233,7 @@ void RenderImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect)
     // FIXME (86669): Instead of the RenderImage determining whether its document is in the page
     // cache, the RenderImage should remove itself as a client when its document is put into the
     // page cache.
-    if (documentBeingDestroyed() || document().inPageCache())
+    if (documentBeingDestroyed() || document().pageCacheState() != Document::NotInPageCache)
         return;
 
     if (hasVisibleBoxDecorations() || hasMask() || hasShapeOutside())
index 0f12f93..08c32ca 100644 (file)
@@ -661,7 +661,7 @@ bool RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
 
     m_updateCompositingLayersTimer.stop();
 
-    ASSERT(!m_renderView.document().inPageCache());
+    ASSERT(m_renderView.document().pageCacheState() == Document::NotInPageCache);
     
     // Compositing layers will be updated in Document::setVisualUpdatesAllowed(bool) if suppressed here.
     if (!m_renderView.document().visualUpdatesAllowed())
@@ -4097,7 +4097,7 @@ void RenderLayerCompositor::willRemoveScrollingLayerWithBacking(RenderLayer& lay
     m_scrollingLayersNeedingUpdate.remove(&layer);
     m_scrollingLayers.remove(&layer);
 
-    if (m_renderView.document().inPageCache())
+    if (m_renderView.document().pageCacheState() != Document::NotInPageCache)
         return;
 
     if (ChromeClient* client = this->chromeClient()) {
@@ -4119,7 +4119,7 @@ void RenderLayerCompositor::didAddScrollingLayer(RenderLayer& layer)
     }
 
 #if PLATFORM(IOS)
-    ASSERT(!m_renderView.document().inPageCache());
+    ASSERT(m_renderView.document().pageCacheState() == Document::NotInPageCache);
     m_scrollingLayers.add(&layer);
 #endif
 }
index b73ace8..41368d4 100644 (file)
@@ -2153,7 +2153,7 @@ void RenderObject::removeRareData()
 void printRenderTreeForLiveDocuments()
 {
     for (const auto* document : Document::allDocuments()) {
-        if (!document->renderView() || document->inPageCache())
+        if (!document->renderView() || document->pageCacheState() != Document::NotInPageCache)
             continue;
         if (document->frame() && document->frame()->isMainFrame())
             fprintf(stderr, "----------------------main frame--------------------------\n");
@@ -2165,7 +2165,7 @@ void printRenderTreeForLiveDocuments()
 void printLayerTreeForLiveDocuments()
 {
     for (const auto* document : Document::allDocuments()) {
-        if (!document->renderView() || document->inPageCache())
+        if (!document->renderView() || document->pageCacheState() != Document::NotInPageCache)
             continue;
         if (document->frame() && document->frame()->isMainFrame())
             fprintf(stderr, "----------------------main frame--------------------------\n");
index 1e7e2ec..f52968f 100644 (file)
@@ -165,7 +165,7 @@ void RenderView::unscheduleLazyRepaint(RenderBox& renderer)
 
 void RenderView::lazyRepaintTimerFired()
 {
-    bool shouldRepaint = !document().inPageCache();
+    bool shouldRepaint = document().pageCacheState() == Document::NotInPageCache;
 
     for (auto& renderer : m_renderersNeedingLazyRepaint) {
         if (shouldRepaint)
index 40954d4..9a23209 100644 (file)
@@ -1095,7 +1095,7 @@ static void collectNonEmptyLeafRenderBlockFlows(const RenderObject& renderer, Ha
 static void collectNonEmptyLeafRenderBlockFlowsForCurrentPage(HashSet<const RenderBlockFlow*>& leafRenderers)
 {
     for (const auto* document : Document::allDocuments()) {
-        if (!document->renderView() || document->inPageCache())
+        if (!document->renderView() || document->pageCacheState() != Document::NotInPageCache)
             continue;
         if (!document->isHTMLDocument() && !document->isXHTMLDocument())
             continue;
index 5147fef..f9bc737 100644 (file)
@@ -1,3 +1,19 @@
+2016-09-12  Chris Dumez  <cdumez@apple.com>
+
+        Switch remaining users of Document::inPageCache() to pageCacheState()
+        https://bugs.webkit.org/show_bug.cgi?id=161865
+
+        Reviewed by Darin Adler.
+
+        Switch remaining users of Document::inPageCache() to pageCacheState() as
+        the former one is confusing (given that it returns true while the
+        pagehide event is being fired).
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView layoutToMinimumPageWidth:height:originalPageWidth:originalPageHeight:maximumShrinkRatio:adjustingViewSize:]):
+        (-[WebHTMLView setNeedsLayout:]):
+        (-[WebHTMLView setNeedsToApplyStyles:]):
+
 2016-09-09  Tim Horton  <timothy_horton@apple.com>
 
         Text replacement candidates don't always overwrite the entire original string
index 1b0f08b..187fb73 100644 (file)
@@ -3627,7 +3627,7 @@ WEBCORE_COMMAND(toggleUnderline)
     if (!coreFrame)
         return;
     if (coreFrame->document()) {
-        if (coreFrame->document()->inPageCache())
+        if (coreFrame->document()->pageCacheState() != Document::NotInPageCache)
             return;
         coreFrame->document()->updateStyleIfNeeded();
     }
@@ -4127,7 +4127,7 @@ static RetainPtr<NSArray> customMenuFromDefaultItems(WebView *webView, const Con
     if (!flag)
         return; // There's no way to say you don't need a layout.
     if (Frame* frame = core([self _frame])) {
-        if (frame->document() && frame->document()->inPageCache())
+        if (frame->document() && frame->document()->pageCacheState() != Document::NotInPageCache)
             return;
         if (FrameView* view = frame->view())
             view->setNeedsLayout();
@@ -4140,7 +4140,7 @@ static RetainPtr<NSArray> customMenuFromDefaultItems(WebView *webView, const Con
     if (!flag)
         return; // There's no way to say you don't need a style recalc.
     if (Frame* frame = core([self _frame])) {
-        if (frame->document() && frame->document()->inPageCache())
+        if (frame->document() && frame->document()->pageCacheState() != Document::NotInPageCache)
             return;
         frame->document()->scheduleForcedStyleRecalc();
     }