Title: [271064] trunk/Source/WebCore
Revision
271064
Author
[email protected]
Date
2020-12-22 14:19:30 -0800 (Tue, 22 Dec 2020)

Log Message

[LFC][IFC] Use reserveInitialCapacity when applicable
https://bugs.webkit.org/show_bug.cgi?id=220100
<rdar://problem/72598083>

Reviewed by Simon Fraser.

* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::lineLayout): inlineItems size is a better approximation.
(WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
* layout/inlineformatting/InlineLineBox.cpp:
(WebCore::Layout::m_isConsideredEmpty):
* layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271063 => 271064)


--- trunk/Source/WebCore/ChangeLog	2020-12-22 21:18:52 UTC (rev 271063)
+++ trunk/Source/WebCore/ChangeLog	2020-12-22 22:19:30 UTC (rev 271064)
@@ -1,3 +1,20 @@
+2020-12-22  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Use reserveInitialCapacity when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=220100
+        <rdar://problem/72598083>
+
+        Reviewed by Simon Fraser.
+
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::lineLayout): inlineItems size is a better approximation.
+        (WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
+        * layout/inlineformatting/InlineLineBox.cpp:
+        (WebCore::Layout::m_isConsideredEmpty):
+        * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
+        (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
+        (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
+
 2020-12-22  Rob Buis  <[email protected]>
 
         Support aspect-ratio on positioned elements

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (271063 => 271064)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-12-22 21:18:52 UTC (rev 271063)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-12-22 22:19:30 UTC (rev 271064)
@@ -166,6 +166,8 @@
 
 void InlineFormattingContext::lineLayout(InlineItems& inlineItems, LineBuilder::InlineItemRange needsLayoutRange, const ConstraintsForInFlowContent& constraints)
 {
+    auto& formattingState = this->formattingState();
+    formattingState.lineRuns().reserveInitialCapacity(formattingState.inlineItems().size());
     InlineLayoutUnit lineLogicalTop = constraints.vertical.logicalTop;
     struct PreviousLine {
         LineBuilder::InlineItemRange range;
@@ -172,9 +174,9 @@
         size_t overflowContentLength { 0 };
     };
     Optional<PreviousLine> previousLine;
-    auto& floatingState = formattingState().floatingState();
+    auto& floatingState = formattingState.floatingState();
     auto floatingContext = FloatingContext { *this, floatingState };
-    auto isFirstLine = formattingState().lines().isEmpty();
+    auto isFirstLine = formattingState.lines().isEmpty();
 
     auto lineBuilder = LineBuilder { *this, floatingState, constraints.horizontal, inlineItems };
     while (!needsLayoutRange.isEmpty()) {
@@ -192,7 +194,7 @@
             lineLogicalTop = geometry().logicalTopForNextLine(lineContent, lineLogicalRect.bottom(), floatingContext);
             if (lineContent.isLastLineWithInlineContent) {
                 // The final content height of this inline formatting context should include the cleared floats as well.
-                formattingState().setClearGapAfterLastLine(lineLogicalTop - lineLogicalRect.bottom());
+                formattingState.setClearGapAfterLastLine(lineLogicalTop - lineLogicalRect.bottom());
             }
             // When the trailing content is partial, we need to reuse the last InlineTextItem.
             auto lastInlineItemNeedsPartialLayout = lineContent.partialTrailingContentLength;
@@ -445,7 +447,6 @@
 
     auto constructLineRunsAndUpdateBoxGeometry = [&] {
         // Create the inline runs on the current line. This is mostly text and atomic inline runs.
-        formattingState.lineRuns().reserveCapacity(lineContent.runs.size());
         for (auto& lineRun : lineContent.runs) {
             // FIXME: We should not need to construct a line run for <br>.
             auto& layoutBox = lineRun.layoutBox();

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp (271063 => 271064)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-12-22 21:18:52 UTC (rev 271063)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-12-22 22:19:30 UTC (rev 271064)
@@ -81,7 +81,8 @@
     : m_logicalRect(logicalTopleft, InlineLayoutSize { contentLogicalWidth, { } })
     , m_isConsideredEmpty(isLineConsideredEmpty == IsLineConsideredEmpty::Yes)
 {
-    m_nonRootInlineLevelBoxList.reserveCapacity(numberOfRuns);
+    m_nonRootInlineLevelBoxList.reserveInitialCapacity(numberOfRuns);
+    m_inlineLevelBoxRectMap.reserveInitialCapacity(numberOfRuns);
 }
 
 void LineBox::addRootInlineBox(std::unique_ptr<InlineLevelBox>&& rootInlineBox)

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp (271063 => 271064)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp	2020-12-22 21:18:52 UTC (rev 271063)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp	2020-12-22 22:19:30 UTC (rev 271064)
@@ -289,7 +289,7 @@
     auto& bidiRuns = bidiResolver.runs();
     if (bidiRuns.runCount() == 1) {
         // Fast path for cases when there's no bidi boundary.
-        inlineContent.runs.reserveCapacity(inlineFormattingState.lineRuns().size());
+        inlineContent.runs.reserveInitialCapacity(inlineFormattingState.lineRuns().size());
         for (auto& lineRun : inlineFormattingState.lineRuns()) {
             if (auto& text = lineRun.text())
                 createDisplayTextRunForRange(lineRun, text->start(), text->end());
@@ -305,7 +305,7 @@
     auto& lines = inlineFormattingState.lines();
     auto& runs = inlineContent.runs;
     size_t runIndex = 0;
-    inlineContent.lines.reserveCapacity(lines.size());
+    inlineContent.lines.reserveInitialCapacity(lines.size());
     for (size_t lineIndex = 0; lineIndex < lines.size(); ++lineIndex) {
         auto& line = lines[lineIndex];
         auto& lineBoxLogicalRect = line.lineBoxLogicalRect();
@@ -316,7 +316,6 @@
         auto lineInkOverflowRect = scrollableOverflowRect;
         while (runIndex < runs.size() && runs[runIndex].lineIndex() == lineIndex)
             lineInkOverflowRect.unite(runs[runIndex++].inkOverflow());
-        auto runCount = runIndex - firstRunIndex;
         auto adjustedLineBoxRect = FloatRect { lineBoxLogicalRect };
         auto enclosingTopAndBottom = line.enclosingTopAndBottom();
         if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition) {
@@ -324,6 +323,7 @@
             enclosingTopAndBottom.top = roundToInt(enclosingTopAndBottom.top);
             enclosingTopAndBottom.bottom = roundToInt(enclosingTopAndBottom.bottom);
         }
+        auto runCount = runIndex - firstRunIndex;
         inlineContent.lines.append({ firstRunIndex, runCount, adjustedLineBoxRect, enclosingTopAndBottom.top, enclosingTopAndBottom.bottom, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.contentLogicalLeftOffset(), line.contentLogicalWidth() });
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to