Diff
Modified: trunk/LayoutTests/ChangeLog (284089 => 284090)
--- trunk/LayoutTests/ChangeLog 2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/LayoutTests/ChangeLog 2021-10-13 13:24:16 UTC (rev 284090)
@@ -1,3 +1,13 @@
+2021-10-13 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Do not break at the inline box boundary when wrapping is not allowed
+ https://bugs.webkit.org/show_bug.cgi?id=231581
+
+ Reviewed by Antti Koivisto.
+
+ * fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html: Added.
+ * fast/inline/no-soft-wrap-opportunity-at-inline-box.html: Added.
+
2021-10-13 Alicia Boya GarcĂa <[email protected]>
Unreviewed, reverting r283609
Added: trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html (0 => 284090)
--- trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html (rev 0)
+++ trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html 2021-10-13 13:24:16 UTC (rev 284090)
@@ -0,0 +1,6 @@
+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
Added: trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box.html (0 => 284090)
--- trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box.html (rev 0)
+++ trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box.html 2021-10-13 13:24:16 UTC (rev 284090)
@@ -0,0 +1,12 @@
+<style>
+div {
+ width: 0px;
+}
+</style>
+<!-- While the whitespace character normally indicates soft wrap opportunities, pre/nowrap white-space property values disable them -->
+<div><span style="white-space: pre">should not </span>wrap</div>
+<div><span style="white-space: nowrap">should not </span>wrap</div>
+<div><span style="white-space: pre">should not </span><span style="white-space: normal">wrap</span></div>
+<div><span style="white-space: nowrap">should not </span><span style="white-space: normal">wrap</span></div>
+<div>should<span style="white-space: pre"> not </span>wrap</div>
+<div>should<span style="white-space: nowrap"> not </span>wrap</div>
Modified: trunk/Source/WebCore/ChangeLog (284089 => 284090)
--- trunk/Source/WebCore/ChangeLog 2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/ChangeLog 2021-10-13 13:24:16 UTC (rev 284090)
@@ -1,3 +1,25 @@
+2021-10-13 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Do not break at the inline box boundary when wrapping is not allowed
+ https://bugs.webkit.org/show_bug.cgi?id=231581
+
+ Reviewed by Antti Koivisto.
+
+ This patch ensures that we don't consider whitespace characters as soft wrap opportunities when wrapping is not allowed.
+
+ Test: fast/inline/no-soft-wrap-opportunity-at-inline-box.html
+
+ * layout/formattingContexts/inline/InlineContentBreaker.cpp:
+ (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+ (WebCore::Layout::isWrappableRun):
+ (WebCore::Layout::InlineContentBreaker::isWrappingAllowed): Deleted.
+ * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+ (WebCore::Layout::isAtSoftWrapOpportunity):
+ (WebCore::Layout::LineBuilder::handleInlineContent):
+ * layout/formattingContexts/inline/text/TextUtil.cpp:
+ (WebCore::Layout::TextUtil::isWrappingAllowed):
+ * layout/formattingContexts/inline/text/TextUtil.h:
+
2021-10-13 Philippe Normand <[email protected]>
Unreviewed, THUNDER build fix
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp (284089 => 284090)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp 2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp 2021-10-13 13:24:16 UTC (rev 284090)
@@ -130,12 +130,6 @@
return { };
}
-bool InlineContentBreaker::isWrappingAllowed(const ContinuousContent::Run& run)
-{
- // Do not try to wrap overflown 'pre' and 'no-wrap' content to next line.
- return run.style.whiteSpace() != WhiteSpace::Pre && run.style.whiteSpace() != WhiteSpace::NoWrap;
-}
-
bool InlineContentBreaker::shouldKeepEndOfLineWhitespace(const ContinuousContent& continuousContent) const
{
// Grab the style and check for white-space property to decide whether we should let this whitespace content overflow the current line.
@@ -269,7 +263,7 @@
// Parent style drives the wrapping behavior here.
// e.g. <div style="white-space: nowrap">some text<div style="display: inline-block; white-space: pre-wrap"></div></div>.
// While the inline-block has pre-wrap which allows wrapping, the content lives in a nowrap context.
- return isWrappingAllowed(continuousContent.runs()[overflowingRunIndex]);
+ return TextUtil::isWrappingAllowed(continuousContent.runs()[overflowingRunIndex].style);
};
if (shouldWrapUnbreakableContentToNextLine())
return { Result::Action::Wrap, IsEndOfLine::Yes };
@@ -300,7 +294,7 @@
return false;
}
// Check if this text run needs to stay on the current line.
- return InlineContentBreaker::isWrappingAllowed(run);
+ return TextUtil::isWrappingAllowed(run.style);
}
std::optional<InlineContentBreaker::OverflowingTextContent::BreakingPosition> InlineContentBreaker::tryBreakingOverflowingRun(const LineStatus& lineStatus, const ContinuousContent::RunList& runs, size_t overflowingRunIndex, InlineLayoutUnit nonOverflowingContentWidth) const
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (284089 => 284090)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2021-10-13 13:24:16 UTC (rev 284090)
@@ -77,6 +77,7 @@
static inline bool isAtSoftWrapOpportunity(const InlineFormattingContext& inlineFormattingContext, const InlineItem& current, const InlineItem& next)
{
+ // FIXME: Transition no-wrapping logic from InlineContentBreaker to here where we compute the soft wrap opportunity indexes.
// "is at" simple means that there's a soft wrap opportunity right after the [current].
// [text][ ][text][inline box start]... (<div>text content<span>..</div>)
// soft wrap indexes: 0 and 1 definitely, 2 depends on the content after the [inline box start].
@@ -93,12 +94,12 @@
auto& nextInlineTextItem = downcast<InlineTextItem>(next);
if (currentInlineTextItem.isWhitespace()) {
// [ ][text] : after [whitespace] position is a soft wrap opportunity.
- return true;
+ return TextUtil::isWrappingAllowed(currentInlineTextItem.style());
}
if (nextInlineTextItem.isWhitespace()) {
// [text][ ] (<span>text</span> )
// white-space: break-spaces: line breaking opportunity exists after every preserved white space character, but not before.
- return nextInlineTextItem.style().whiteSpace() != WhiteSpace::BreakSpaces;
+ return TextUtil::isWrappingAllowed(nextInlineTextItem.style()) && nextInlineTextItem.style().whiteSpace() != WhiteSpace::BreakSpaces;
}
if (current.style().lineBreak() == LineBreak::Anywhere || next.style().lineBreak() == LineBreak::Anywhere) {
// There is a soft wrap opportunity around every typographic character unit, including around any punctuation character
@@ -711,7 +712,7 @@
auto& trailingRun = candidateRuns.last();
// FIXME: There must be a way to decide if the trailing run actually ended up on the line.
// Let's just deal with collapsed leading whitespace for now.
- if (!m_line.runs().isEmpty() && InlineContentBreaker::isWrappingAllowed(trailingRun))
+ if (!m_line.runs().isEmpty() && TextUtil::isWrappingAllowed(trailingRun.style))
m_wrapOpportunityList.append(&trailingRun.inlineItem);
}
return { result.isEndOfLine, { candidateRuns.size(), false } };
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp (284089 => 284090)
--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp 2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp 2021-10-13 13:24:16 UTC (rev 284090)
@@ -222,6 +222,12 @@
return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces || whitespace == WhiteSpace::PreLine;
}
+bool TextUtil::isWrappingAllowed(const RenderStyle& style)
+{
+ // Do not try to wrap overflown 'pre' and 'no-wrap' content to next line.
+ return style.whiteSpace() != WhiteSpace::Pre && style.whiteSpace() != WhiteSpace::NoWrap;
+}
+
LineBreakIteratorMode TextUtil::lineBreakIteratorMode(LineBreak lineBreak)
{
switch (lineBreak) {
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h (284089 => 284090)
--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h 2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h 2021-10-13 13:24:16 UTC (rev 284090)
@@ -64,6 +64,7 @@
static bool shouldPreserveSpacesAndTabs(const Box&);
static bool shouldPreserveNewline(const Box&);
static bool canUseSimplifiedTextMeasuringForFirstLine(const RenderStyle&, const RenderStyle& firstLineStyle);
+ static bool isWrappingAllowed(const RenderStyle&);
};
}