Title: [207620] trunk
Revision
207620
Author
akl...@apple.com
Date
2016-10-20 09:38:50 -0700 (Thu, 20 Oct 2016)

Log Message

Drop StyleResolver and SelectorQueryCache when entering PageCache.
<https://webkit.org/b/154238>

Reviewed by Antti Koivisto.

Source/WebCore:

Stop keeping these around for cached pages to save lots of memory.
We can easily rebuild them if a cached navigation occurs, and this
way we also don't need to worry about invalidating style for cached
pages in all the right places.

Restoring a cached page will now lead to a forced style recalc.
We don't try to defer this (beyond a zero-timer) since it's going
to happen anyway, and it's nicer to front-load the cost rather than
stuttering on the first user content interaction.

* dom/Document.cpp:
(WebCore::Document::setPageCacheState):
* history/CachedPage.cpp:
(WebCore::CachedPage::restore):
(WebCore::CachedPage::clear):
* history/CachedPage.h:
(WebCore::CachedPage::markForVisitedLinkStyleRecalc): Deleted.
(WebCore::CachedPage::markForFullStyleRecalc): Deleted.
* history/PageCache.cpp:
(WebCore::PageCache::markPagesForVisitedLinkStyleRecalc): Deleted.
(WebCore::PageCache::markPagesForFullStyleRecalc): Deleted.
* history/PageCache.h:
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):
* page/Page.cpp:
(WebCore::Page::setViewScaleFactor):
(WebCore::Page::setDeviceScaleFactor):
(WebCore::Page::setPagination):
(WebCore::Page::setPaginationLineGridEnabled):
(WebCore::Page::setVisitedLinkStore):

LayoutTests:

Progression in compositing/iframes/page-cache-layer-tree.html, when navigating back,
the two iframes' dimensions correctly exclude the horizontal scrollbar's height since
it's not present after a style recalc.

* compositing/iframes/page-cache-layer-tree-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207619 => 207620)


--- trunk/LayoutTests/ChangeLog	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/LayoutTests/ChangeLog	2016-10-20 16:38:50 UTC (rev 207620)
@@ -1,3 +1,16 @@
+2016-10-20  Andreas Kling  <akl...@apple.com>
+
+        Drop StyleResolver and SelectorQueryCache when entering PageCache.
+        <https://webkit.org/b/154238>
+
+        Reviewed by Antti Koivisto.
+
+        Progression in compositing/iframes/page-cache-layer-tree.html, when navigating back,
+        the two iframes' dimensions correctly exclude the horizontal scrollbar's height since
+        it's not present after a style recalc.
+
+        * compositing/iframes/page-cache-layer-tree-expected.txt:
+
 2016-10-20  Nael Ouedraogo  <nael.ouedra...@crf.canon.fr>
 
         WebRTC: The MediaStreamTrackEvent init dictionary needs a required track member

Modified: trunk/LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt (207619 => 207620)


--- trunk/LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/LayoutTests/compositing/iframes/page-cache-layer-tree-expected.txt	2016-10-20 16:38:50 UTC (rev 207620)
@@ -23,7 +23,7 @@
               (children 1
                 (GraphicsLayer
                   (anchor 0.00 0.00)
-                  (bounds 285.00 135.00)
+                  (bounds 285.00 150.00)
                   (children 1
                     (GraphicsLayer
                       (children 1
@@ -73,7 +73,7 @@
                   (children 1
                     (GraphicsLayer
                       (anchor 0.00 0.00)
-                      (bounds 285.00 135.00)
+                      (bounds 285.00 150.00)
                       (children 1
                         (GraphicsLayer
                           (children 1

Modified: trunk/Source/WebCore/ChangeLog (207619 => 207620)


--- trunk/Source/WebCore/ChangeLog	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/ChangeLog	2016-10-20 16:38:50 UTC (rev 207620)
@@ -1,3 +1,41 @@
+2016-10-20  Andreas Kling  <akl...@apple.com>
+
+        Drop StyleResolver and SelectorQueryCache when entering PageCache.
+        <https://webkit.org/b/154238>
+
+        Reviewed by Antti Koivisto.
+
+        Stop keeping these around for cached pages to save lots of memory.
+        We can easily rebuild them if a cached navigation occurs, and this
+        way we also don't need to worry about invalidating style for cached
+        pages in all the right places.
+
+        Restoring a cached page will now lead to a forced style recalc.
+        We don't try to defer this (beyond a zero-timer) since it's going
+        to happen anyway, and it's nicer to front-load the cost rather than
+        stuttering on the first user content interaction.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setPageCacheState):
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::restore):
+        (WebCore::CachedPage::clear):
+        * history/CachedPage.h:
+        (WebCore::CachedPage::markForVisitedLinkStyleRecalc): Deleted.
+        (WebCore::CachedPage::markForFullStyleRecalc): Deleted.
+        * history/PageCache.cpp:
+        (WebCore::PageCache::markPagesForVisitedLinkStyleRecalc): Deleted.
+        (WebCore::PageCache::markPagesForFullStyleRecalc): Deleted.
+        * history/PageCache.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::setPageAndTextZoomFactors):
+        * page/Page.cpp:
+        (WebCore::Page::setViewScaleFactor):
+        (WebCore::Page::setDeviceScaleFactor):
+        (WebCore::Page::setPagination):
+        (WebCore::Page::setPaginationLineGridEnabled):
+        (WebCore::Page::setVisitedLinkStore):
+
 2016-10-20  Carlos Alberto Lopez Perez  <clo...@igalia.com>
 
         [GTK] Build fix after r207616

Modified: trunk/Source/WebCore/dom/Document.cpp (207619 => 207620)


--- trunk/Source/WebCore/dom/Document.cpp	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-10-20 16:38:50 UTC (rev 207620)
@@ -4599,6 +4599,9 @@
             } else
                 v->resetScrollbars();
         }
+
+        styleScope().clearResolver();
+        clearSelectorQueryCache();
         m_styleRecalcTimer.stop();
 
         clearSharedObjectPool();

Modified: trunk/Source/WebCore/history/CachedPage.cpp (207619 => 207620)


--- trunk/Source/WebCore/history/CachedPage.cpp	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/history/CachedPage.cpp	2016-10-20 16:38:50 UTC (rev 207620)
@@ -100,16 +100,10 @@
 #endif
     }
 
-    if (m_needStyleRecalcForVisitedLinks) {
-        for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext())
-            frame->document()->visitedLinkState().invalidateStyleForAllLinks();
-    }
-
     if (m_needsDeviceOrPageScaleChanged)
         page.mainFrame().deviceOrPageScaleFactorChanged();
 
-    if (m_needsFullStyleRecalc)
-        page.setNeedsRecalcStyleInAllFrames();
+    page.setNeedsRecalcStyleInAllFrames();
 
 #if ENABLE(VIDEO_TRACK)
     if (m_needsCaptionPreferencesChanged)
@@ -129,8 +123,6 @@
     ASSERT(m_cachedMainFrame);
     m_cachedMainFrame->clear();
     m_cachedMainFrame = nullptr;
-    m_needStyleRecalcForVisitedLinks = false;
-    m_needsFullStyleRecalc = false;
 #if ENABLE(VIDEO_TRACK)
     m_needsCaptionPreferencesChanged = false;
 #endif

Modified: trunk/Source/WebCore/history/CachedPage.h (207619 => 207620)


--- trunk/Source/WebCore/history/CachedPage.h	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/history/CachedPage.h	2016-10-20 16:38:50 UTC (rev 207620)
@@ -50,8 +50,6 @@
     
     CachedFrame* cachedMainFrame() { return m_cachedMainFrame.get(); }
 
-    void markForVisitedLinkStyleRecalc() { m_needStyleRecalcForVisitedLinks = true; }
-    void markForFullStyleRecalc() { m_needsFullStyleRecalc = true; }
 #if ENABLE(VIDEO_TRACK)
     void markForCaptionPreferencesChanged() { m_needsCaptionPreferencesChanged = true; }
 #endif
@@ -63,8 +61,6 @@
 private:
     double m_expirationTime;
     std::unique_ptr<CachedFrame> m_cachedMainFrame;
-    bool m_needStyleRecalcForVisitedLinks { false };
-    bool m_needsFullStyleRecalc { false };
 #if ENABLE(VIDEO_TRACK)
     bool m_needsCaptionPreferencesChanged { false };
 #endif

Modified: trunk/Source/WebCore/history/PageCache.cpp (207619 => 207620)


--- trunk/Source/WebCore/history/PageCache.cpp	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/history/PageCache.cpp	2016-10-20 16:38:50 UTC (rev 207620)
@@ -312,23 +312,6 @@
     return frameCount;
 }
 
-void PageCache::markPagesForVisitedLinkStyleRecalc()
-{
-    for (auto& item : m_items) {
-        ASSERT(item->m_cachedPage);
-        item->m_cachedPage->markForVisitedLinkStyleRecalc();
-    }
-}
-
-void PageCache::markPagesForFullStyleRecalc(Page& page)
-{
-    for (auto& item : m_items) {
-        CachedPage& cachedPage = *item->m_cachedPage;
-        if (&page.mainFrame() == &cachedPage.cachedMainFrame()->view()->frame())
-            cachedPage.markForFullStyleRecalc();
-    }
-}
-
 void PageCache::markPagesForDeviceOrPageScaleChanged(Page& page)
 {
     for (auto& item : m_items) {

Modified: trunk/Source/WebCore/history/PageCache.h (207619 => 207620)


--- trunk/Source/WebCore/history/PageCache.h	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/history/PageCache.h	2016-10-20 16:38:50 UTC (rev 207620)
@@ -61,9 +61,6 @@
     unsigned pageCount() const { return m_items.size(); }
     WEBCORE_EXPORT unsigned frameCount() const;
 
-    WEBCORE_EXPORT void markPagesForVisitedLinkStyleRecalc();
-    // Will mark all cached pages associated with the given page as needing style recalc.
-    void markPagesForFullStyleRecalc(Page&);
     void markPagesForDeviceOrPageScaleChanged(Page&);
     void markPagesForContentsSizeChanged(Page&);
 #if ENABLE(VIDEO_TRACK)

Modified: trunk/Source/WebCore/page/Frame.cpp (207619 => 207620)


--- trunk/Source/WebCore/page/Frame.cpp	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/page/Frame.cpp	2016-10-20 16:38:50 UTC (rev 207620)
@@ -963,9 +963,6 @@
         if (document->renderView() && document->renderView()->needsLayout() && view->didFirstLayout())
             view->layout();
     }
-
-    if (isMainFrame())
-        PageCache::singleton().markPagesForFullStyleRecalc(*page);
 }
 
 float Frame::frameScaleFactor() const

Modified: trunk/Source/WebCore/page/Page.cpp (207619 => 207620)


--- trunk/Source/WebCore/page/Page.cpp	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebCore/page/Page.cpp	2016-10-20 16:38:50 UTC (rev 207620)
@@ -878,7 +878,6 @@
 
     m_viewScaleFactor = scale;
     PageCache::singleton().markPagesForDeviceOrPageScaleChanged(*this);
-    PageCache::singleton().markPagesForFullStyleRecalc(*this);
 }
 
 void Page::setDeviceScaleFactor(float scaleFactor)
@@ -896,7 +895,6 @@
     mainFrame().deviceOrPageScaleFactorChanged();
     PageCache::singleton().markPagesForDeviceOrPageScaleChanged(*this);
 
-    PageCache::singleton().markPagesForFullStyleRecalc(*this);
     GraphicsContext::updateDocumentMarkerResources();
 
     mainFrame().pageOverlayController().didChangeDeviceScaleFactor();
@@ -989,7 +987,6 @@
     m_pagination = pagination;
 
     setNeedsRecalcStyleInAllFrames();
-    PageCache::singleton().markPagesForFullStyleRecalc(*this);
 }
 
 void Page::setPaginationLineGridEnabled(bool enabled)
@@ -1000,7 +997,6 @@
     m_paginationLineGridEnabled = enabled;
     
     setNeedsRecalcStyleInAllFrames();
-    PageCache::singleton().markPagesForFullStyleRecalc(*this);
 }
 
 unsigned Page::pageCount() const
@@ -1899,7 +1895,6 @@
     m_visitedLinkStore->addPage(*this);
 
     invalidateStylesForAllLinks();
-    PageCache::singleton().markPagesForFullStyleRecalc(*this);
 }
 
 SessionID Page::sessionID() const

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm (207619 => 207620)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm	2016-10-20 16:38:50 UTC (rev 207620)
@@ -74,7 +74,6 @@
 {
     for (auto& visitedLinkStore : visitedLinkStores())
         visitedLinkStore->removeVisitedLinkHashes();
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::addVisitedLink(NSString *urlString)
@@ -103,7 +102,6 @@
     m_visitedLinkHashes.remove(linkHash);
 
     invalidateStylesForLink(linkHash);
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
@@ -152,7 +150,6 @@
     m_visitedLinkHashes.add(linkHash);
 
     invalidateStylesForLink(linkHash);
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::removeVisitedLinkHashes()

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp (207619 => 207620)


--- trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp	2016-10-20 16:38:50 UTC (rev 207620)
@@ -71,7 +71,6 @@
 {
     for (auto& visitedLinkStore : visitedLinkStores())
         visitedLinkStore->removeVisitedLinkHashes();
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::addVisitedLink(const String& urlString)
@@ -124,7 +123,6 @@
     m_visitedLinkHashes.add(linkHash);
 
     invalidateStylesForLink(linkHash);
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::removeVisitedLinkHashes()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.cpp (207619 => 207620)


--- trunk/Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.cpp	2016-10-20 15:57:25 UTC (rev 207619)
+++ trunk/Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.cpp	2016-10-20 16:38:50 UTC (rev 207620)
@@ -97,7 +97,6 @@
     m_visitedLinkTable.setSharedMemory(WTFMove(sharedMemory));
 
     invalidateStylesForAllLinks();
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 void VisitedLinkTableController::visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes)
@@ -104,13 +103,11 @@
 {
     for (auto linkHash : linkHashes)
         invalidateStylesForLink(linkHash);
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 void VisitedLinkTableController::allVisitedLinkStateChanged()
 {
     invalidateStylesForAllLinks();
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 void VisitedLinkTableController::removeAllVisitedLinks()
@@ -118,7 +115,6 @@
     m_visitedLinkTable.clear();
 
     invalidateStylesForAllLinks();
-    PageCache::singleton().markPagesForVisitedLinkStyleRecalc();
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to