Title: [210206] trunk/Source/WebCore
- Revision
- 210206
- Author
- akl...@apple.com
- Date
- 2016-12-30 00:54:25 -0800 (Fri, 30 Dec 2016)
Log Message
Drop the render tree for documents in the page cache.
<https://webkit.org/b/121798>
Reviewed by Darin Adler.
To save memory and reduce complexity, have documents tear down their render tree
when entering the page cache. I've wanted to do this for a long time and it seems
like we can actually do it now.
This patch will enable a number of clean-ups since it's no longer valid for renderers
to exist while the document is in page cache.
* dom/Document.cpp:
(WebCore::Document::destroyRenderTree): Remove assertion that we're not in the page cache
since we will now be tearing down render trees right as they enter the page cache.
(WebCore::Document::setPageCacheState): Tear down the render tree right before setting
the in-cache flag. From now on, there should not exist render objects for documents in
the page cache.
* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::restore):
* page/FrameView.h:
* page/FrameView.cpp:
(WebCore::FrameView::didRestoreFromPageCache): Update the scollable area set after restoring a
frame from the page cache. This dirties the scrolling tree, which was covered by tests.
* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::setNeedsStyleRecalc): Make this a no-op if the render tree is being
torn down. This fixes assertions firing on animation tests.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (210205 => 210206)
--- trunk/Source/WebCore/ChangeLog 2016-12-29 18:46:31 UTC (rev 210205)
+++ trunk/Source/WebCore/ChangeLog 2016-12-30 08:54:25 UTC (rev 210206)
@@ -1,3 +1,36 @@
+2016-12-30 Andreas Kling <akl...@apple.com>
+
+ Drop the render tree for documents in the page cache.
+ <https://webkit.org/b/121798>
+
+ Reviewed by Darin Adler.
+
+ To save memory and reduce complexity, have documents tear down their render tree
+ when entering the page cache. I've wanted to do this for a long time and it seems
+ like we can actually do it now.
+
+ This patch will enable a number of clean-ups since it's no longer valid for renderers
+ to exist while the document is in page cache.
+
+ * dom/Document.cpp:
+ (WebCore::Document::destroyRenderTree): Remove assertion that we're not in the page cache
+ since we will now be tearing down render trees right as they enter the page cache.
+
+ (WebCore::Document::setPageCacheState): Tear down the render tree right before setting
+ the in-cache flag. From now on, there should not exist render objects for documents in
+ the page cache.
+
+ * history/CachedFrame.cpp:
+ (WebCore::CachedFrameBase::restore):
+ * page/FrameView.h:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::didRestoreFromPageCache): Update the scollable area set after restoring a
+ frame from the page cache. This dirties the scrolling tree, which was covered by tests.
+
+ * page/animation/AnimationBase.cpp:
+ (WebCore::AnimationBase::setNeedsStyleRecalc): Make this a no-op if the render tree is being
+ torn down. This fixes assertions firing on animation tests.
+
2016-12-29 Chris Fleizach <cfleiz...@apple.com>
AX: Need to expose frames to iOS Accessibility
Modified: trunk/Source/WebCore/dom/Document.cpp (210205 => 210206)
--- trunk/Source/WebCore/dom/Document.cpp 2016-12-29 18:46:31 UTC (rev 210205)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-12-30 08:54:25 UTC (rev 210206)
@@ -2221,7 +2221,6 @@
void Document::destroyRenderTree()
{
ASSERT(hasLivingRenderTree());
- ASSERT(m_pageCacheState != InPageCache);
SetForScope<bool> change(m_renderTreeBeingDestroyed, true);
@@ -4524,6 +4523,13 @@
if (m_pageCacheState == state)
return;
+ if (state == InPageCache) {
+ // When entering page cache, tear down the render tree before setting the in-cache flag.
+ // This maintains the invariant that render trees are never present in the page cache.
+ if (hasLivingRenderTree())
+ destroyRenderTree();
+ }
+
m_pageCacheState = state;
FrameView* v = view();
Modified: trunk/Source/WebCore/history/CachedFrame.cpp (210205 => 210206)
--- trunk/Source/WebCore/history/CachedFrame.cpp 2016-12-29 18:46:31 UTC (rev 210205)
+++ trunk/Source/WebCore/history/CachedFrame.cpp 2016-12-30 08:54:25 UTC (rev 210206)
@@ -130,6 +130,7 @@
m_document->page()->chrome().client().needTouchEvents(true);
#endif
+ frame.view()->didRestoreFromPageCache();
}
CachedFrame::CachedFrame(Frame& frame)
Modified: trunk/Source/WebCore/page/FrameView.cpp (210205 => 210206)
--- trunk/Source/WebCore/page/FrameView.cpp 2016-12-29 18:46:31 UTC (rev 210205)
+++ trunk/Source/WebCore/page/FrameView.cpp 2016-12-30 08:54:25 UTC (rev 210206)
@@ -636,6 +636,13 @@
return ScrollView::createScrollbar(orientation);
}
+void FrameView::didRestoreFromPageCache()
+{
+ // When restoring from page cache, the main frame stays in place while subframes get swapped in.
+ // We update the scrollable area set to ensure that scrolling data structures get invalidated.
+ updateScrollableAreaSet();
+}
+
void FrameView::setContentsSize(const IntSize& size)
{
if (size == contentsSize())
Modified: trunk/Source/WebCore/page/FrameView.h (210205 => 210206)
--- trunk/Source/WebCore/page/FrameView.h 2016-12-29 18:46:31 UTC (rev 210205)
+++ trunk/Source/WebCore/page/FrameView.h 2016-12-30 08:54:25 UTC (rev 210206)
@@ -587,6 +587,8 @@
bool shouldPlaceBlockDirectionScrollbarOnLeft() const final;
+ void didRestoreFromPageCache();
+
protected:
bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) override;
void scrollContentsSlowPath(const IntRect& updateRect) override;
Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (210205 => 210206)
--- trunk/Source/WebCore/page/animation/AnimationBase.cpp 2016-12-29 18:46:31 UTC (rev 210205)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp 2016-12-30 08:54:25 UTC (rev 210206)
@@ -89,9 +89,11 @@
void AnimationBase::setNeedsStyleRecalc(Element* element)
{
- ASSERT(!element || element->document().pageCacheState() == Document::NotInPageCache);
- if (element)
- element->invalidateStyleAndLayerComposition();
+ if (!element || element->document().renderTreeBeingDestroyed())
+ return;
+
+ ASSERT(element->document().pageCacheState() == Document::NotInPageCache);
+ element->invalidateStyleAndLayerComposition();
}
double AnimationBase::duration() const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes