Title: [270958] trunk/Source/WebCore
Revision
270958
Author
[email protected]
Date
2020-12-17 15:34:14 -0800 (Thu, 17 Dec 2020)

Log Message

[LFC][IFC] Reserve vector capacity for inline runs and line boxes
https://bugs.webkit.org/show_bug.cgi?id=219985

Reviewed by Simon Fraser.

...and some of the predefined vector capacities got lost at r267325.

* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
(WebCore::Layout::LineBoxBuilder::build):
* layout/inlineformatting/InlineFormattingState.h:
* layout/inlineformatting/InlineLineBox.cpp:
(WebCore::Layout::LineBox::InlineLevelBox::InlineLevelBox):
(WebCore::Layout::LineBox::LineBox):
(WebCore::Layout::m_isConsideredEmpty):
* layout/inlineformatting/InlineLineBox.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270957 => 270958)


--- trunk/Source/WebCore/ChangeLog	2020-12-17 23:31:52 UTC (rev 270957)
+++ trunk/Source/WebCore/ChangeLog	2020-12-17 23:34:14 UTC (rev 270958)
@@ -1,3 +1,23 @@
+2020-12-17  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Reserve vector capacity for inline runs and line boxes
+        https://bugs.webkit.org/show_bug.cgi?id=219985
+
+        Reviewed by Simon Fraser.
+
+        ...and some of the predefined vector capacities got lost at r267325.
+
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::LineBoxBuilder::build):
+        * layout/inlineformatting/InlineFormattingState.h:
+        * layout/inlineformatting/InlineLineBox.cpp:
+        (WebCore::Layout::LineBox::InlineLevelBox::InlineLevelBox):
+        (WebCore::Layout::LineBox::LineBox):
+        (WebCore::Layout::m_isConsideredEmpty):
+        * layout/inlineformatting/InlineLineBox.h:
+
 2020-12-17  Manuel Rego Casasnovas  <[email protected]>
 
         [selectors] Default namespace gets ignored inside non-type selectors for :is() and :not()

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (270957 => 270958)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-12-17 23:31:52 UTC (rev 270957)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-12-17 23:34:14 UTC (rev 270958)
@@ -420,6 +420,7 @@
     auto constructLineRuns = [&] {
         auto lineIndex = formattingState.lines().size();
         // 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/InlineFormattingContextGeometry.cpp (270957 => 270958)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2020-12-17 23:31:52 UTC (rev 270957)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2020-12-17 23:34:14 UTC (rev 270958)
@@ -157,7 +157,7 @@
     auto lineLogicalWidth = lineContent.lineLogicalWidth;
     auto contentLogicalWidth = lineContent.contentLogicalWidth;
     auto isLineConsideredEmpty = lineContent.isLineConsideredEmpty ? LineBox::IsLineConsideredEmpty::Yes : LineBox::IsLineConsideredEmpty::No;
-    auto lineBox = LineBox { lineContent.logicalTopLeft, contentLogicalWidth, isLineConsideredEmpty };
+    auto lineBox = LineBox { lineContent.logicalTopLeft, contentLogicalWidth, isLineConsideredEmpty, runs.size() };
 
     if (auto horizontalAlignmentOffset = Layout::horizontalAlignmentOffset(runs, rootBox().style().textAlign(), lineLogicalWidth, contentLogicalWidth, lineContent.isLastLineWithInlineContent))
         lineBox.setHorizontalAlignmentOffset(*horizontalAlignmentOffset);

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (270957 => 270958)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h	2020-12-17 23:31:52 UTC (rev 270957)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h	2020-12-17 23:34:14 UTC (rev 270958)
@@ -38,8 +38,8 @@
 namespace Layout {
 
 using InlineItems = Vector<InlineItem>;
-using InlineLines = Vector<InlineLineGeometry>;
-using InlineLineBoxes = Vector<LineBox>;
+using InlineLines = Vector<InlineLineGeometry, 10>;
+using InlineLineBoxes = Vector<LineBox, 10>;
 using InlineLineRuns = Vector<LineRun>;
 
 // InlineFormattingState holds the state for a particular inline formatting context tree.

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp (270957 => 270958)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-12-17 23:31:52 UTC (rev 270957)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-12-17 23:34:14 UTC (rev 270958)
@@ -34,7 +34,7 @@
 namespace WebCore {
 namespace Layout {
 
-LineBox::InlineLevelBox::InlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize,  Type type)
+LineBox::InlineLevelBox::InlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, Type type)
     : m_layoutBox(makeWeakPtr(layoutBox))
     , m_logicalRect({ }, logicalLeft, logicalSize.width(), logicalSize.height())
     , m_type(type)
@@ -77,10 +77,11 @@
     return verticalAlignment == VerticalAlign::Top || verticalAlignment == VerticalAlign::Bottom;
 }
 
-LineBox::LineBox(const InlineLayoutPoint& logicalTopleft, InlineLayoutUnit contentLogicalWidth, IsLineConsideredEmpty isLineConsideredEmpty)
+LineBox::LineBox(const InlineLayoutPoint& logicalTopleft, InlineLayoutUnit contentLogicalWidth, IsLineConsideredEmpty isLineConsideredEmpty, size_t numberOfRuns)
     : m_logicalRect(logicalTopleft, InlineLayoutSize { contentLogicalWidth, { } })
     , m_isConsideredEmpty(isLineConsideredEmpty == IsLineConsideredEmpty::Yes)
 {
+    m_nonRootInlineLevelBoxList.reserveCapacity(numberOfRuns);
 }
 
 void LineBox::addRootInlineBox(std::unique_ptr<InlineLevelBox>&& rootInlineBox)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (270957 => 270958)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-12-17 23:31:52 UTC (rev 270957)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-12-17 23:34:14 UTC (rev 270958)
@@ -129,7 +129,7 @@
     };
 
     enum class IsLineConsideredEmpty { No, Yes };
-    LineBox(const InlineLayoutPoint& logicalTopLeft, InlineLayoutUnit logicalWidth, IsLineConsideredEmpty);
+    LineBox(const InlineLayoutPoint& logicalTopLeft, InlineLayoutUnit logicalWidth, IsLineConsideredEmpty, size_t numberOfRuns);
 
     const InlineRect& logicalRect() const { return m_logicalRect; }
     InlineLayoutUnit logicalWidth() const { return logicalSize().width(); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to