Title: [283059] trunk/Source/WebCore
Revision
283059
Author
[email protected]
Date
2021-09-24 14:46:41 -0700 (Fri, 24 Sep 2021)

Log Message

[LFC][IFC] LineBuilder should have the option of passing in the correct style when a run is added to the line
https://bugs.webkit.org/show_bug.cgi?id=230760

Reviewed by Antti Koivisto.

Now the Line only uses the passed in style information. It's up to the LineBuilder to pass in the line index dependent style when attaching a run.

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::append):
(WebCore::Layout::Line::appendNonBreakableSpace):
(WebCore::Layout::Line::appendInlineBoxStart):
(WebCore::Layout::Line::appendInlineBoxEnd):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::appendNonReplacedInlineLevelBox):
(WebCore::Layout::Line::appendReplacedInlineLevelBox):
* layout/formattingContexts/inline/InlineLine.h:
* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::placeInlineContent):
(WebCore::Layout::LineBuilder::handleInlineContent):
(WebCore::Layout::LineBuilder::commitPartialContent):
(WebCore::Layout::LineBuilder::rebuildLine):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283058 => 283059)


--- trunk/Source/WebCore/ChangeLog	2021-09-24 21:43:26 UTC (rev 283058)
+++ trunk/Source/WebCore/ChangeLog	2021-09-24 21:46:41 UTC (rev 283059)
@@ -1,5 +1,29 @@
 2021-09-24  Alan Bujtas  <[email protected]>
 
+        [LFC][IFC] LineBuilder should have the option of passing in the correct style when a run is added to the line
+        https://bugs.webkit.org/show_bug.cgi?id=230760
+
+        Reviewed by Antti Koivisto.
+
+        Now the Line only uses the passed in style information. It's up to the LineBuilder to pass in the line index dependent style when attaching a run.
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::append):
+        (WebCore::Layout::Line::appendNonBreakableSpace):
+        (WebCore::Layout::Line::appendInlineBoxStart):
+        (WebCore::Layout::Line::appendInlineBoxEnd):
+        (WebCore::Layout::Line::appendTextContent):
+        (WebCore::Layout::Line::appendNonReplacedInlineLevelBox):
+        (WebCore::Layout::Line::appendReplacedInlineLevelBox):
+        * layout/formattingContexts/inline/InlineLine.h:
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::placeInlineContent):
+        (WebCore::Layout::LineBuilder::handleInlineContent):
+        (WebCore::Layout::LineBuilder::commitPartialContent):
+        (WebCore::Layout::LineBuilder::rebuildLine):
+
+2021-09-24  Alan Bujtas  <[email protected]>
+
         r283047 broke some hyphen related debug tests.
 
         Apparently we can't access the hyphen string when the hyphen property is not set.

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-09-24 21:43:26 UTC (rev 283058)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp	2021-09-24 21:46:41 UTC (rev 283059)
@@ -198,42 +198,42 @@
     m_contentLogicalWidth -= trimmedContentWidth;
 }
 
-void Line::append(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
+void Line::append(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit logicalWidth)
 {
     if (inlineItem.isText())
-        appendTextContent(downcast<InlineTextItem>(inlineItem), logicalWidth);
+        appendTextContent(downcast<InlineTextItem>(inlineItem), style, logicalWidth);
     else if (inlineItem.isLineBreak())
         appendLineBreak(inlineItem);
     else if (inlineItem.isWordBreakOpportunity())
         appendWordBreakOpportunity(inlineItem);
     else if (inlineItem.isInlineBoxStart())
-        appendInlineBoxStart(inlineItem, logicalWidth);
+        appendInlineBoxStart(inlineItem, style, logicalWidth);
     else if (inlineItem.isInlineBoxEnd())
-        appendInlineBoxEnd(inlineItem, logicalWidth);
+        appendInlineBoxEnd(inlineItem, style, logicalWidth);
     else if (inlineItem.layoutBox().isReplacedBox())
-        appendReplacedInlineLevelBox(inlineItem, logicalWidth);
+        appendReplacedInlineLevelBox(inlineItem, style, logicalWidth);
     else if (inlineItem.isBox())
-        appendNonReplacedInlineLevelBox(inlineItem, logicalWidth);
+        appendNonReplacedInlineLevelBox(inlineItem, style, logicalWidth);
     else
         ASSERT_NOT_REACHED();
 }
 
-void Line::appendNonBreakableSpace(const InlineItem& inlineItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
+void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
 {
-    m_runs.append({ inlineItem, inlineItem.style(), logicalLeft, logicalWidth });
+    m_runs.append({ inlineItem, style, logicalLeft, logicalWidth });
     // Do not let negative margin make the content shorter than it already is.
     auto runLogicalRight = logicalLeft + logicalWidth;
     m_contentLogicalWidth = std::max(m_contentLogicalWidth, runLogicalRight);
 }
 
-void Line::appendInlineBoxStart(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
+void Line::appendInlineBoxStart(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit logicalWidth)
 {
     // This is really just a placeholder to mark the start of the inline box <span>.
     ++m_nonSpanningInlineLevelBoxCount;
-    appendNonBreakableSpace(inlineItem, contentLogicalRight(), logicalWidth);
+    appendNonBreakableSpace(inlineItem, style, contentLogicalRight(), logicalWidth);
 }
 
-void Line::appendInlineBoxEnd(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
+void Line::appendInlineBoxEnd(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit logicalWidth)
 {
     // This is really just a placeholder to mark the end of the inline box </span>.
     auto removeTrailingLetterSpacing = [&] {
@@ -244,12 +244,11 @@
     // Prevent trailing letter-spacing from spilling out of the inline box.
     // https://drafts.csswg.org/css-text-3/#letter-spacing-property See example 21.
     removeTrailingLetterSpacing();
-    appendNonBreakableSpace(inlineItem, contentLogicalRight(), logicalWidth);
+    appendNonBreakableSpace(inlineItem, style, contentLogicalRight(), logicalWidth);
 }
 
-void Line::appendTextContent(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalWidth)
+void Line::appendTextContent(const InlineTextItem& inlineTextItem, const RenderStyle& style, InlineLayoutUnit logicalWidth)
 {
-    auto& style = inlineTextItem.style();
     auto willCollapseCompletely = [&] {
         if (inlineTextItem.isEmptyContent())
             return true;
@@ -295,7 +294,7 @@
     if (needsNewRun) {
         // Note, negative words spacing may cause glyph overlap.
         auto runLogicalLeft = contentLogicalRight() + (inlineTextItem.isWordSeparator() ? style.fontCascade().wordSpacing() : 0.0f);
-        m_runs.append({ inlineTextItem, inlineTextItem.style(), runLogicalLeft, logicalWidth });
+        m_runs.append({ inlineTextItem, style, runLogicalLeft, logicalWidth });
         m_contentLogicalWidth = std::max(oldContentLogicalWidth, runLogicalLeft + logicalWidth);
     } else {
         m_runs.last().expand(inlineTextItem, logicalWidth);
@@ -314,7 +313,7 @@
     m_trailingSoftHyphenWidth = inlineTextItem.hasTrailingSoftHyphen() ? std::make_optional(style.fontCascade().width(TextRun { StringView { style.hyphenString() } })) : std::nullopt;
 }
 
-void Line::appendNonReplacedInlineLevelBox(const InlineItem& inlineItem, InlineLayoutUnit marginBoxLogicalWidth)
+void Line::appendNonReplacedInlineLevelBox(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit marginBoxLogicalWidth)
 {
     m_trimmableTrailingContent.reset();
     m_trailingSoftHyphenWidth = { };
@@ -322,7 +321,7 @@
     ++m_nonSpanningInlineLevelBoxCount;
     auto marginStart = formattingContext().geometryForBox(inlineItem.layoutBox()).marginStart();
     if (marginStart >= 0) {
-        m_runs.append({ inlineItem, inlineItem.style(), contentLogicalRight(), marginBoxLogicalWidth });
+        m_runs.append({ inlineItem, style, contentLogicalRight(), marginBoxLogicalWidth });
         return;
     }
     // Negative margin-start pulls the content to the logical left direction.
@@ -329,14 +328,14 @@
     // Negative margin also squeezes the margin box, we need to stretch it to make sure the subsequent content won't overlap.
     // e.g. <img style="width: 100px; margin-left: -100px;"> pulls the replaced box to -100px with the margin box width of 0px.
     // Instead we need to position it at -100px and size it to 100px so the subsequent content starts at 0px. 
-    m_runs.append({ inlineItem, inlineItem.style(), contentLogicalRight() + marginStart, marginBoxLogicalWidth - marginStart });
+    m_runs.append({ inlineItem, style, contentLogicalRight() + marginStart, marginBoxLogicalWidth - marginStart });
 }
 
-void Line::appendReplacedInlineLevelBox(const InlineItem& inlineItem, InlineLayoutUnit marginBoxLogicalWidth)
+void Line::appendReplacedInlineLevelBox(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit marginBoxLogicalWidth)
 {
     ASSERT(inlineItem.layoutBox().isReplacedBox());
     // FIXME: Surely replaced boxes behave differently.
-    appendNonReplacedInlineLevelBox(inlineItem, marginBoxLogicalWidth);
+    appendNonReplacedInlineLevelBox(inlineItem, style, marginBoxLogicalWidth);
 }
 
 void Line::appendLineBreak(const InlineItem& inlineItem)

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-09-24 21:43:26 UTC (rev 283058)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h	2021-09-24 21:46:41 UTC (rev 283059)
@@ -44,7 +44,7 @@
 
     void initialize();
 
-    void append(const InlineItem&, InlineLayoutUnit logicalWidth);
+    void append(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalWidth);
 
     InlineLayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; }
     InlineLayoutUnit contentLogicalRight() const { return m_runs.isEmpty() ? 0.0f : m_runs.last().logicalRight(); }
@@ -142,12 +142,12 @@
     const RunList& runs() const { return m_runs; }
 
 private:
-    void appendNonBreakableSpace(const InlineItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
-    void appendTextContent(const InlineTextItem&, InlineLayoutUnit logicalWidth);
-    void appendNonReplacedInlineLevelBox(const InlineItem&, InlineLayoutUnit marginBoxLogicalWidth);
-    void appendReplacedInlineLevelBox(const InlineItem&, InlineLayoutUnit marginBoxLogicalWidth);
-    void appendInlineBoxStart(const InlineItem&, InlineLayoutUnit logicalWidth);
-    void appendInlineBoxEnd(const InlineItem&, InlineLayoutUnit logicalWidth);
+    void appendNonBreakableSpace(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
+    void appendTextContent(const InlineTextItem&, const RenderStyle&, InlineLayoutUnit logicalWidth);
+    void appendNonReplacedInlineLevelBox(const InlineItem&, const RenderStyle&, InlineLayoutUnit marginBoxLogicalWidth);
+    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&);
 

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (283058 => 283059)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-09-24 21:43:26 UTC (rev 283058)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-09-24 21:46:41 UTC (rev 283059)
@@ -330,7 +330,7 @@
                 if (auto* wordBreakOpportunity = inlineContent.trailingWordBreakOpportunity()) {
                     // <wbr> needs to be on the line as an empty run so that we can construct an inline box and compute basic geometry.
                     ++committedInlineItemCount;
-                    m_line.append(*wordBreakOpportunity, { });
+                    m_line.append(*wordBreakOpportunity, wordBreakOpportunity->style(), { });
                 }
                 if (inlineContent.trailingLineBreak()) {
                     // Fully committed (or empty) content followed by a line break means "end of line".
@@ -337,7 +337,8 @@
                     // FIXME: This will put the line break box at the end of the line while in case of some inline boxes, the line break
                     // could very well be at an earlier position. This has no visual implications at this point though (only geometry correctness on the line break box).
                     // e.g. <span style="border-right: 10px solid green">text<br></span> where the <br>'s horizontal position is before the right border and not after.
-                    m_line.append(*inlineContent.trailingLineBreak(), { });
+                    auto& trailingLineBreak = *inlineContent.trailingLineBreak();
+                    m_line.append(trailingLineBreak, trailingLineBreak.style(), { });
                     ++committedInlineItemCount;
                     isEndOfLine = true;
                 }
@@ -690,7 +691,7 @@
         // This continuous content can be fully placed on the current line.
         m_lineLogicalRect = lineLogicalRectForCandidateContent;
         for (auto& run : candidateRuns)
-            m_line.append(run.inlineItem, run.logicalWidth);
+            m_line.append(run.inlineItem, run.inlineItem.style(), run.logicalWidth);
         if (lineCandidate.inlineContent.hasTrailingSoftWrapOpportunity()) {
             // Check if we are allowed to wrap at this position.
             auto& trailingRun = candidateRuns.last();
@@ -773,16 +774,16 @@
                 ASSERT(run.inlineItem.isText());
                 auto& trailingInlineTextItem = downcast<InlineTextItem>(runs[partialTrailingContent.trailingRunIndex].inlineItem);
                 auto partialTrailingTextItem = trailingInlineTextItem.left(partialRun->length);
-                m_line.append(partialTrailingTextItem, partialRun->logicalWidth);
+                m_line.append(partialTrailingTextItem, trailingInlineTextItem.style(), partialRun->logicalWidth);
                 if (auto hyphenWidth = partialRun->hyphenWidth)
                     m_line.addTrailingHyphen(*hyphenWidth);
                 return;
             }
             // The partial run is the last content to commit.
-            m_line.append(run.inlineItem, run.logicalWidth);
+            m_line.append(run.inlineItem, run.inlineItem.style(), run.logicalWidth);
             return;
         }
-        m_line.append(run.inlineItem, run.logicalWidth);
+        m_line.append(run.inlineItem, run.inlineItem.style(), run.logicalWidth);
     }
 }
 
@@ -794,7 +795,7 @@
     m_line.initialize();
     auto currentItemIndex = layoutRange.start;
     if (m_partialLeadingTextItem) {
-        m_line.append(*m_partialLeadingTextItem, inlineItemWidth(*m_partialLeadingTextItem, { }));
+        m_line.append(*m_partialLeadingTextItem, m_partialLeadingTextItem->style(), inlineItemWidth(*m_partialLeadingTextItem, { }));
         if (&m_partialLeadingTextItem.value() == &lastInlineItemToAdd)
             return 1;
         ++currentItemIndex;
@@ -801,7 +802,7 @@
     }
     for (; currentItemIndex < layoutRange.end; ++currentItemIndex) {
         auto& inlineItem = m_inlineItems[currentItemIndex];
-        m_line.append(inlineItem, inlineItemWidth(inlineItem, m_line.contentLogicalRight()));
+        m_line.append(inlineItem, inlineItem.style(), inlineItemWidth(inlineItem, m_line.contentLogicalRight()));
         if (&inlineItem == &lastInlineItemToAdd)
             return currentItemIndex - layoutRange.start + 1;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to