Title: [255071] trunk/Source/WebCore
Revision
255071
Author
[email protected]
Date
2020-01-24 07:26:24 -0800 (Fri, 24 Jan 2020)

Log Message

[LFC][Integration] Clear inline item caches on low memory notification
https://bugs.webkit.org/show_bug.cgi?id=206740
<rdar://problem/58773905>

Reviewed by Zalan Bujtas.

Clear inline item caches on low memory notification.

* layout/inlineformatting/InlineFormattingState.h:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::releaseCaches):
(WebCore::LayoutIntegration::LineLayout::releaseInlineItemCache):
* layout/integration/LayoutIntegrationLineLayout.h:

Remove inline capacity. It is rarely optimal and we can afford the heap allocation.

* page/MemoryRelease.cpp:
(WebCore::releaseNoncriticalMemory):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255070 => 255071)


--- trunk/Source/WebCore/ChangeLog	2020-01-24 15:14:28 UTC (rev 255070)
+++ trunk/Source/WebCore/ChangeLog	2020-01-24 15:26:24 UTC (rev 255071)
@@ -1,3 +1,24 @@
+2020-01-24  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Clear inline item caches on low memory notification
+        https://bugs.webkit.org/show_bug.cgi?id=206740
+        <rdar://problem/58773905>
+
+        Reviewed by Zalan Bujtas.
+
+        Clear inline item caches on low memory notification.
+
+        * layout/inlineformatting/InlineFormattingState.h:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::releaseCaches):
+        (WebCore::LayoutIntegration::LineLayout::releaseInlineItemCache):
+        * layout/integration/LayoutIntegrationLineLayout.h:
+
+        Remove inline capacity. It is rarely optimal and we can afford the heap allocation.
+
+        * page/MemoryRelease.cpp:
+        (WebCore::releaseNoncriticalMemory):
+
 2020-01-24  Adrian Perez de Castro  <[email protected]>
 
         Fix various non-unified build issues introduced since r254751

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (255070 => 255071)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h	2020-01-24 15:14:28 UTC (rev 255070)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h	2020-01-24 15:26:24 UTC (rev 255071)
@@ -35,7 +35,7 @@
 namespace WebCore {
 namespace Layout {
 
-using InlineItems = Vector<InlineItem, 30>;
+using InlineItems = Vector<InlineItem>;
 
 // InlineFormattingState holds the state for a particular inline formatting context tree.
 class InlineFormattingState : public FormattingState {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (255070 => 255071)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-01-24 15:14:28 UTC (rev 255070)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-01-24 15:26:24 UTC (rev 255071)
@@ -41,7 +41,9 @@
 #include "PaintInfo.h"
 #include "RenderBlockFlow.h"
 #include "RenderChildIterator.h"
+#include "RenderDescendantIterator.h"
 #include "RenderLineBreak.h"
+#include "RenderView.h"
 #include "RuntimeEnabledFeatures.h"
 #include "Settings.h"
 #include "SimpleLineLayout.h"
@@ -329,7 +331,24 @@
     return &debugTextShadow.get();
 }
 
+void LineLayout::releaseCaches(RenderView& view)
+{
+    if (!RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled())
+        return;
+
+    for (auto& renderer : descendantsOfType<RenderBlockFlow>(view)) {
+        if (auto* lineLayout = renderer.layoutFormattingContextLineLayout())
+            lineLayout->releaseInlineItemCache();
+    }
 }
+
+void LineLayout::releaseInlineItemCache()
+{
+    m_inlineFormattingState.inlineItems().clear();
 }
 
+
+}
+}
+
 #endif

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (255070 => 255071)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-01-24 15:14:28 UTC (rev 255070)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-01-24 15:26:24 UTC (rev 255071)
@@ -80,10 +80,13 @@
     LineLayoutTraversal::TextBoxIterator textBoxesFor(const RenderText&) const;
     LineLayoutTraversal::ElementBoxIterator elementBoxFor(const RenderLineBreak&) const;
 
+    static void releaseCaches(RenderView&);
+
 private:
     const Layout::Container& rootLayoutBox() const;
     Layout::Container& rootLayoutBox();
     ShadowData* debugTextShadow();
+    void releaseInlineItemCache();
 
     const RenderBlockFlow& m_flow;
     BoxTree m_boxTree;

Modified: trunk/Source/WebCore/page/MemoryRelease.cpp (255070 => 255071)


--- trunk/Source/WebCore/page/MemoryRelease.cpp	2020-01-24 15:14:28 UTC (rev 255070)
+++ trunk/Source/WebCore/page/MemoryRelease.cpp	2020-01-24 15:26:24 UTC (rev 255071)
@@ -40,6 +40,7 @@
 #include "HTMLMediaElement.h"
 #include "InlineStyleSheetOwner.h"
 #include "InspectorInstrumentation.h"
+#include "LayoutIntegrationLineLayout.h"
 #include "Logging.h"
 #include "MemoryCache.h"
 #include "Page.h"
@@ -68,9 +69,15 @@
     clearWidthCaches();
     TextPainter::clearGlyphDisplayLists();
 
-    for (auto* document : Document::allDocuments())
+    for (auto* document : Document::allDocuments()) {
         document->clearSelectorQueryCache();
 
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+        if (auto* renderView = document->renderView())
+            LayoutIntegration::LineLayout::releaseCaches(*renderView);
+#endif
+    }
+
     if (maintainMemoryCache == MaintainMemoryCache::No)
         MemoryCache::singleton().pruneDeadResourcesToSize(0);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to