Skip to content

Commit 133a726

Browse files
committed
[IFC][Ruby] Fix fast/ruby/ruby-text-before-after-content.html
https://bugs.webkit.org/show_bug.cgi?id=264221 Reviewed by Antti Koivisto. Sum of the individual inline items' logical width may not match the final content width due to certain inline layout rules like white-space collapsing. Let's just get the content width off of the line when finished placing the ruby base content. * Source/WebCore/layout/formattingContexts/inline/ruby/RubyFormattingContext.cpp: (WebCore::Layout::RubyFormattingContext::layoutRubyBaseInlineAxis): (turn for loop into a while and handle content alignment outside of the loop). Canonical link: https://commits.webkit.org/270245@main
1 parent 3945b83 commit 133a726

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

Source/WebCore/layout/formattingContexts/inline/ruby/RubyFormattingContext.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,22 @@ RubyFormattingContext::BaseLayoutResult RubyFormattingContext::layoutRubyBaseInl
132132
{
133133
// Append ruby base content (including start/end inline box) to the line and apply "ruby-align: space-around" on the ruby subrange.
134134
auto& formattingUtils = parentFormattingContext().formattingUtils();
135-
auto lineLogicalRight = line.contentLogicalRight();
136-
auto baseContentLogicalWidth = InlineLayoutUnit { };
137135
auto baseRunStart = line.runs().size();
136+
auto baseContentLogicalLeft = line.contentLogicalRight();
138137

139-
for (size_t index = rubyBaseContentStartIndex; index < inlineItemList.size(); ++index) {
140-
auto& rubyBaseInlineItem = inlineItemList[index];
141-
if (&rubyBaseInlineItem.layoutBox() == &rubyBaseLayoutBox) {
142-
auto baseRunCount = line.runs().size() - baseRunStart;
143-
auto logicalRightSpacing = InlineLayoutUnit { };
144-
if (baseRunCount)
145-
logicalRightSpacing = applyRubyAlign(line, { baseRunStart, baseRunStart + baseRunCount }, rubyBaseLayoutBox, baseContentLogicalWidth);
146-
return { index - rubyBaseContentStartIndex, logicalRightSpacing };
147-
}
148-
auto logicalWidth = formattingUtils.inlineItemWidth(rubyBaseInlineItem, lineLogicalRight + baseContentLogicalWidth, { });
149-
line.append(rubyBaseInlineItem, rubyBaseInlineItem.style(), logicalWidth);
150-
baseContentLogicalWidth += logicalWidth;
138+
auto index = rubyBaseContentStartIndex;
139+
while (index < inlineItemList.size() && &inlineItemList[index].layoutBox() != &rubyBaseLayoutBox) {
140+
auto& rubyBaseContentItem = inlineItemList[index++];
141+
line.append(rubyBaseContentItem, rubyBaseContentItem.style(), formattingUtils.inlineItemWidth(rubyBaseContentItem, line.contentLogicalRight(), { }));
142+
}
143+
ASSERT(index < inlineItemList.size());
144+
auto logicalRightSpacing = InlineLayoutUnit { };
145+
auto baseRunCount = line.runs().size() - baseRunStart;
146+
if (baseRunCount) {
147+
auto baseContentLogicalWidth = line.contentLogicalRight() - baseContentLogicalLeft;
148+
logicalRightSpacing = applyRubyAlign(line, { baseRunStart, baseRunStart + baseRunCount }, rubyBaseLayoutBox, baseContentLogicalWidth);
151149
}
152-
ASSERT_NOT_REACHED();
153-
return { inlineItemList.size() - rubyBaseContentStartIndex, { } };
150+
return { index - rubyBaseContentStartIndex, logicalRightSpacing };
154151
}
155152

156153
InlineLayoutPoint RubyFormattingContext::placeAnnotationBox(const Box& rubyBaseLayoutBox)

0 commit comments

Comments
 (0)