Skip to content

Commit

Permalink
Cherry-pick 2c41110. rdar://122811940
Browse files Browse the repository at this point in the history
    [IFC][Ruby] Ruby base content may wrap even when style says no
    https://bugs.webkit.org/show_bug.cgi?id=269235
    <rdar://122811940>

    Reviewed by Antti Koivisto.

    There's no soft wrap opportunity between 2 adjacent non-whitespace characters when style says nowrap.

    * LayoutTests/fast/ruby/ruby-base-content-should-not-wrap-expected.html: Added.
    * LayoutTests/fast/ruby/ruby-base-content-should-not-wrap.html: Added.
    * Source/WebCore/layout/formattingContexts/inline/InlineFormattingUtils.cpp:
    (WebCore::Layout::isAtSoftWrapOpportunity):

    Canonical link: https://commits.webkit.org/272448.537@safari-7618-branch

Identifier: 272448.559@safari-7618.1.15.10-branch
  • Loading branch information
alanbaradlay authored and MyahCobbs committed Feb 13, 2024
1 parent 63a32a0 commit 485b612
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<meta charset="UTF-8">
<style>
div {
font-family: Ahem;
font-size: 20px;
width: 40px;
border: 1px solid green;
overflow: hidden;
}
</style>
<div>X <ruby>稲稲</ruby></div>
12 changes: 12 additions & 0 deletions LayoutTests/fast/ruby/ruby-base-content-should-not-wrap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<meta charset="UTF-8">
<style>
div {
font-family: Ahem;
font-size: 20px;
width: 40px;
border: 1px solid green;
overflow: hidden;
}
</style>
<!-- while there's a natural breaking position between 稲 and 稲, nowrap should prevent wrapping -->
<div>X <ruby>稲稲</ruby>,X</div>
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ static inline bool isAtSoftWrapOpportunity(const InlineItem& previous, const Inl
// Both previous and next items are non-whitespace text.
// [text][text] : is a continuous content.
// [text-][text] : after [hyphen] position is a soft wrap opportunity.
auto currentAndNextHaveSameParent = &currentInlineTextItem.layoutBox().parent() == &nextInlineTextItem.layoutBox().parent();
if (currentAndNextHaveSameParent && !TextUtil::isWrappingAllowed(currentInlineTextItem.style()))
return false;
return endsWithSoftWrapOpportunity(currentInlineTextItem, nextInlineTextItem);
}
if (previous.layoutBox().isListMarkerBox()) {
Expand Down

0 comments on commit 485b612

Please sign in to comment.