Skip to content

Commit

Permalink
Cherry-pick 06f1371. rdar://122586549
Browse files Browse the repository at this point in the history
    [IFC][Ruby] Text are clipped at the bottom on some pages with ruby in Books
    https://bugs.webkit.org/show_bug.cgi?id=269079
    <rdar://122586549>

    Reviewed by Antti Koivisto.

    Take ruby width adjustment (annotation box is wider than base content) into account when non-trivial line breaking requires us to rebuild the current line.

    * LayoutTests/fast/ruby/ruby-with-unbreakable-characters-incorrect-width-expected.html: Added.
    * LayoutTests/fast/ruby/ruby-with-unbreakable-characters-incorrect-width.html: Added.
    * Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp:
    (WebCore::Layout::LineBuilder::rebuildLineWithInlineContent): This is the exact copy of what we do in candidateContentForLine when collecting the content for current line.

    Canonical link: https://commits.webkit.org/274387@main

Identifier: 272448.543@safari-7618.1.15.10-branch
  • Loading branch information
alanbaradlay authored and MyahCobbs committed Feb 9, 2024
1 parent 59de8c4 commit 1c342af
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<meta charset="UTF-8">
<style>
div {
font-family: Ahem;
font-size: 20px;
width: 200px;
border: 1px solid green;
text-align-last: justify;
height: 30px;
overflow: hidden;
}
</style>
<div><ruby>XX<rt>XXXXXX</rt></ruby> <ruby>X<rt>XXX</rt></ruby></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<meta charset="UTF-8">
<style>
div {
font-family: Ahem;
font-size: 20px;
width: 200px;
border: 1px solid green;
text-align: justify;
height: 30px;
overflow: hidden;
}
</style>
<!-- PASS if all content is inside the green box -->
<div><ruby>XX<rt>XXXXXX</rt></ruby> <ruby>X<rt>XXX</rt></ruby><ruby>X<rt>XXX</rt></ruby><ruby>XXXX</ruby></div>
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,9 @@ size_t LineBuilder::rebuildLineWithInlineContent(const InlineItemRange& layoutRa
}
auto& style = isFirstFormattedLine() ? inlineItem.firstLineStyle() : inlineItem.style();
auto inlineItemWidth = !inlineItem.isOpaque() ? formattingContext().formattingUtils().inlineItemWidth(inlineItem, m_line.contentLogicalRight(), isFirstFormattedLine()) : InlineLayoutUnit();
if (inlineItem.isInlineBoxEnd() && inlineItem.layoutBox().isRubyBase())
inlineItemWidth += RubyFormattingContext::baseEndAdditionalLogicalWidth(inlineItem.layoutBox(), m_line.runs(), { }, formattingContext());

m_line.append(inlineItem, style, inlineItemWidth);
++numberOfInlineItemsOnLine;
if (&inlineItem == &lastInlineItemToAdd)
Expand Down

0 comments on commit 1c342af

Please sign in to comment.