Title: [287819] trunk/Source/WebCore
Revision
287819
Author
za...@apple.com
Date
2022-01-09 05:50:27 -0800 (Sun, 09 Jan 2022)

Log Message

[LFC][IFC] Line::Run needs access to FontCascade
https://bugs.webkit.org/show_bug.cgi?id=235009

Reviewed by Antti Koivisto.

This is in preparation for computing trimmed trailing content width properly.

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::append):
(WebCore::Layout::Line::appendLineBreak):
(WebCore::Layout::Line::appendWordBreakOpportunity):
(WebCore::Layout::Line::Run::Run):
(WebCore::Layout::m_textContent):
(WebCore::Layout::m_style): Deleted. - We learnt in the past that expanding structures like this (stack backed, large in number) could
lead to measurable perf regression.
* layout/formattingContexts/inline/InlineLine.h:
(WebCore::Layout::Line::Run::shouldTrailingWhitespaceHang const):
(WebCore::Layout::Line::Run::inlineDirection const):
(WebCore::Layout::Line::Run::letterSpacing const):
(WebCore::Layout::Line::Run::hasTextCombine const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287818 => 287819)


--- trunk/Source/WebCore/ChangeLog	2022-01-09 09:01:48 UTC (rev 287818)
+++ trunk/Source/WebCore/ChangeLog	2022-01-09 13:50:27 UTC (rev 287819)
@@ -1,3 +1,26 @@
+2022-01-09  Alan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Line::Run needs access to FontCascade
+        https://bugs.webkit.org/show_bug.cgi?id=235009
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for computing trimmed trailing content width properly.
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::append):
+        (WebCore::Layout::Line::appendLineBreak):
+        (WebCore::Layout::Line::appendWordBreakOpportunity):
+        (WebCore::Layout::Line::Run::Run):
+        (WebCore::Layout::m_textContent):
+        (WebCore::Layout::m_style): Deleted. - We learnt in the past that expanding structures like this (stack backed, large in number) could
+        lead to measurable perf regression.
+        * layout/formattingContexts/inline/InlineLine.h:
+        (WebCore::Layout::Line::Run::shouldTrailingWhitespaceHang const):
+        (WebCore::Layout::Line::Run::inlineDirection const):
+        (WebCore::Layout::Line::Run::letterSpacing const):
+        (WebCore::Layout::Line::Run::hasTextCombine const):
+
 2022-01-09  Antti Koivisto  <an...@apple.com>
 
         Use IsNegation bit for more efficient pseudo-class style invalidation

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (287818 => 287819)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2022-01-09 09:01:48 UTC (rev 287818)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2022-01-09 13:50:27 UTC (rev 287819)
@@ -205,9 +205,9 @@
     if (inlineItem.isText())
         appendTextContent(downcast<InlineTextItem>(inlineItem), style, logicalWidth);
     else if (inlineItem.isLineBreak())
-        appendLineBreak(inlineItem);
+        appendLineBreak(inlineItem, style);
     else if (inlineItem.isWordBreakOpportunity())
-        appendWordBreakOpportunity(inlineItem);
+        appendWordBreakOpportunity(inlineItem, style);
     else if (inlineItem.isInlineBoxStart())
         appendInlineBoxStart(inlineItem, style, logicalWidth);
     else if (inlineItem.isInlineBoxEnd())
@@ -372,21 +372,21 @@
     appendNonReplacedInlineLevelBox(inlineItem, style, marginBoxLogicalWidth);
 }
 
-void Line::appendLineBreak(const InlineItem& inlineItem)
+void Line::appendLineBreak(const InlineItem& inlineItem, const RenderStyle& style)
 {
     m_trailingSoftHyphenWidth = { };
     if (inlineItem.isHardLineBreak()) {
         ++m_nonSpanningInlineLevelBoxCount;
-        return m_runs.append({ inlineItem, lastRunLogicalRight() });
+        return m_runs.append({ inlineItem, style, lastRunLogicalRight() });
     }
     // Soft line breaks (preserved new line characters) require inline text boxes for compatibility reasons.
     ASSERT(inlineItem.isSoftLineBreak());
-    m_runs.append({ downcast<InlineSoftLineBreakItem>(inlineItem), lastRunLogicalRight() });
+    m_runs.append({ downcast<InlineSoftLineBreakItem>(inlineItem), inlineItem.style(), lastRunLogicalRight() });
 }
 
-void Line::appendWordBreakOpportunity(const InlineItem& inlineItem)
+void Line::appendWordBreakOpportunity(const InlineItem& inlineItem, const RenderStyle& style)
 {
-    m_runs.append({ inlineItem, lastRunLogicalRight() });
+    m_runs.append({ inlineItem, style, lastRunLogicalRight() });
 }
 
 InlineLayoutUnit Line::addBorderAndPaddingEndForInlineBoxDecorationClone(const InlineItem& inlineBoxStartItem)
@@ -538,16 +538,17 @@
 Line::Run::Run(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
     : m_type(toLineRunType(inlineItem.type()))
     , m_layoutBox(&inlineItem.layoutBox())
+    , m_style(style)
     , m_logicalLeft(logicalLeft)
     , m_logicalWidth(logicalWidth)
-    , m_style({ { }, style.direction(), { }, { } })
     , m_bidiLevel(inlineItem.bidiLevel())
 {
 }
 
-Line::Run::Run(const InlineItem& zeroWidhtInlineItem, InlineLayoutUnit logicalLeft)
+Line::Run::Run(const InlineItem& zeroWidhtInlineItem, const RenderStyle& style, InlineLayoutUnit logicalLeft)
     : m_type(toLineRunType(zeroWidhtInlineItem.type()))
     , m_layoutBox(&zeroWidhtInlineItem.layoutBox())
+    , m_style(style)
     , m_logicalLeft(logicalLeft)
     , m_bidiLevel(zeroWidhtInlineItem.bidiLevel())
 {
@@ -556,6 +557,7 @@
 Line::Run::Run(const InlineItem& lineSpanningInlineBoxItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
     : m_type(Type::LineSpanningInlineBoxStart)
     , m_layoutBox(&lineSpanningInlineBoxItem.layoutBox())
+    , m_style(lineSpanningInlineBoxItem.style())
     , m_logicalLeft(logicalLeft)
     , m_logicalWidth(logicalWidth)
     , m_bidiLevel(lineSpanningInlineBoxItem.bidiLevel())
@@ -563,9 +565,10 @@
     ASSERT(lineSpanningInlineBoxItem.isInlineBoxStart());
 }
 
-Line::Run::Run(const InlineSoftLineBreakItem& softLineBreakItem, InlineLayoutUnit logicalLeft)
+Line::Run::Run(const InlineSoftLineBreakItem& softLineBreakItem, const RenderStyle& style, InlineLayoutUnit logicalLeft)
     : m_type(Type::SoftLineBreak)
     , m_layoutBox(&softLineBreakItem.layoutBox())
+    , m_style(style)
     , m_logicalLeft(logicalLeft)
     , m_textContent({ softLineBreakItem.position(), 1 })
     , m_bidiLevel(softLineBreakItem.bidiLevel())
@@ -575,12 +578,12 @@
 Line::Run::Run(const InlineTextItem& inlineTextItem, const RenderStyle& style, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
     : m_type(inlineTextItem.isWordSeparator() ? Type::WordSeparator : Type::Text)
     , m_layoutBox(&inlineTextItem.layoutBox())
+    , m_style(style)
     , m_logicalLeft(logicalLeft)
     , m_logicalWidth(logicalWidth)
     , m_trailingWhitespaceType(trailingWhitespaceType(inlineTextItem))
     , m_trailingWhitespaceWidth(m_trailingWhitespaceType != TrailingWhitespace::None ? logicalWidth : InlineLayoutUnit { })
     , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length() })
-    , m_style({ style.whiteSpace() == WhiteSpace::PreWrap, style.direction(), style.letterSpacing(), style.hasTextCombine() })
     , m_bidiLevel(inlineTextItem.bidiLevel())
 {
 }

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h (287818 => 287819)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2022-01-09 09:01:48 UTC (rev 287818)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2022-01-09 13:50:27 UTC (rev 287819)
@@ -120,9 +120,9 @@
         friend class Line;
 
         Run(const InlineTextItem&, const RenderStyle&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
-        Run(const InlineSoftLineBreakItem&, InlineLayoutUnit logicalLeft);
+        Run(const InlineSoftLineBreakItem&, const RenderStyle&, InlineLayoutUnit logicalLeft);
         Run(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
-        Run(const InlineItem&, InlineLayoutUnit logicalLeft);
+        Run(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalLeft);
         Run(const InlineItem& lineSpanningInlineBoxItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
 
         void expand(const InlineTextItem&, InlineLayoutUnit logicalWidth);
@@ -148,6 +148,7 @@
 
         Type m_type { Type::Text };
         const Box* m_layoutBox { nullptr };
+        const RenderStyle& m_style;
         InlineLayoutUnit m_logicalLeft { 0 };
         InlineLayoutUnit m_logicalWidth { 0 };
         TrailingWhitespace m_trailingWhitespaceType { TrailingWhitespace::None };
@@ -154,13 +155,6 @@
         InlineLayoutUnit m_trailingWhitespaceWidth { 0 };
         std::optional<Text> m_textContent;
         InlineDisplay::Box::Expansion m_expansion;
-        struct Style {
-            bool shouldTrailingWhitespaceHang { false };
-            TextDirection inlineDirection { TextDirection::RTL };
-            InlineLayoutUnit letterSpacing { 0 };
-            bool hasTextCombine { false };
-        };
-        Style m_style { };
         UBiDiLevel m_bidiLevel { UBIDI_DEFAULT_LTR };
     };
     using RunList = Vector<Run, 10>;
@@ -176,8 +170,8 @@
     void appendReplacedInlineLevelBox(const InlineItem&, const RenderStyle&, InlineLayoutUnit marginBoxLogicalWidth);
     void appendInlineBoxStart(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalWidth);
     void appendInlineBoxEnd(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalWidth);
-    void appendLineBreak(const InlineItem&);
-    void appendWordBreakOpportunity(const InlineItem&);
+    void appendLineBreak(const InlineItem&, const RenderStyle&);
+    void appendWordBreakOpportunity(const InlineItem&, const RenderStyle&);
 
     InlineLayoutUnit addBorderAndPaddingEndForInlineBoxDecorationClone(const InlineItem& inlineBoxStartItem);
     InlineLayoutUnit removeBorderAndPaddingEndForInlineBoxDecorationClone(const InlineItem& inlineBoxEndItem);
@@ -277,22 +271,22 @@
 
 inline bool Line::Run::shouldTrailingWhitespaceHang() const
 {
-    return m_style.shouldTrailingWhitespaceHang;
+    return m_style.whiteSpace() == WhiteSpace::PreWrap;
 }
 
 inline TextDirection Line::Run::inlineDirection() const
 {
-    return m_style.inlineDirection;
+    return m_style.direction();
 }
 
 inline InlineLayoutUnit Line::Run::letterSpacing() const
 {
-    return m_style.letterSpacing;
+    return m_style.letterSpacing();
 }
 
 inline bool Line::Run::hasTextCombine() const
 {
-    return m_style.hasTextCombine;
+    return m_style.hasTextCombine();
 }
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to