Skip to content

Commit

Permalink
[IFC] Do don't consider natural breaking opportunities as soft-wrap b…
Browse files Browse the repository at this point in the history
…oundaries when style does not allow wrapping (part2)

https://bugs.webkit.org/show_bug.cgi?id=269152

Reviewed by Antti Koivisto.

Expand the same parent no-wrap rule to all types of content.
(This is in preparation for taking care of FIXME at isAtSoftWrapOpportunity)

* Source/WebCore/layout/formattingContexts/inline/InlineFormattingUtils.cpp:
(WebCore::Layout::isAtSoftWrapOpportunity):

Canonical link: https://commits.webkit.org/274444@main
  • Loading branch information
alanbaradlay committed Feb 11, 2024
1 parent 40981b4 commit 7cd0829
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,18 @@ static inline bool isAtSoftWrapOpportunity(const InlineItem& previous, const Inl
// but an incoming text content would not necessarily.
ASSERT(previous.isText() || previous.isBox() || previous.layoutBox().isRubyInlineBox());
ASSERT(next.isText() || next.isBox() || next.layoutBox().isRubyInlineBox());

if (previous.layoutBox().isRubyInlineBox() || next.layoutBox().isRubyInlineBox())
return RubyFormattingContext::isAtSoftWrapOpportunity(previous, next);

auto mayWrapPrevious = TextUtil::isWrappingAllowed(previous.layoutBox().parent().style());
auto mayWrapNext = TextUtil::isWrappingAllowed(next.layoutBox().parent().style());
if (&previous.layoutBox().parent() == &next.layoutBox().parent() && !mayWrapPrevious && !mayWrapNext)
return false;

if (previous.isText() && next.isText()) {
auto& previousInlineTextItem = downcast<InlineTextItem>(previous);
auto& nextInlineTextItem = downcast<InlineTextItem>(next);

auto mayWrapPrevious = TextUtil::isWrappingAllowed(previousInlineTextItem.style());
auto mayWrapNext = TextUtil::isWrappingAllowed(nextInlineTextItem.style());
if (&previousInlineTextItem.layoutBox().parent() == &nextInlineTextItem.layoutBox().parent() && !mayWrapPrevious && !mayWrapNext)
return false;
if (previousInlineTextItem.isWhitespace()) {
// "<nowrap> </nowrap>after"
return mayWrapPrevious;
Expand Down Expand Up @@ -423,8 +427,6 @@ static inline bool isAtSoftWrapOpportunity(const InlineItem& previous, const Inl
// The line breaking behavior of a replaced element or other atomic inline is equivalent to an ideographic character.
return true;
}
if (previous.layoutBox().isRubyInlineBox() || next.layoutBox().isRubyInlineBox())
return RubyFormattingContext::isAtSoftWrapOpportunity(previous, next);

ASSERT_NOT_REACHED();
return true;
Expand Down

0 comments on commit 7cd0829

Please sign in to comment.