Title: [272310] trunk/Source/WebCore
- Revision
- 272310
- Author
- [email protected]
- Date
- 2021-02-03 06:28:16 -0800 (Wed, 03 Feb 2021)
Log Message
[LFC][IFC] Use the overflowing run to decide if the unbreakable content should stay on the current line
https://bugs.webkit.org/show_bug.cgi?id=221295
Reviewed by Antti Koivisto.
When an unbreakable set of runs overflow the available space, we need to check if the content is allowed to get wrapped to the next line.
Let's use the _overflowing_ run's style to decided if the content stays on the line (e.g. white-space: nowrap)
e.g. <span><nowrap>this_content_should_not_wrapped</nowrap>this_overflows</span>
^^ in this case the overflowing run's style allows wrapping so we wrap entire content (see imported/w3c/web-platform-tests/css/css-text/overflow-wrap/overflow-wrap-break-word-white-space-crash-002.html)
* layout/inlineformatting/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (272309 => 272310)
--- trunk/Source/WebCore/ChangeLog 2021-02-03 14:04:58 UTC (rev 272309)
+++ trunk/Source/WebCore/ChangeLog 2021-02-03 14:28:16 UTC (rev 272310)
@@ -1,3 +1,18 @@
+2021-02-03 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Use the overflowing run to decide if the unbreakable content should stay on the current line
+ https://bugs.webkit.org/show_bug.cgi?id=221295
+
+ Reviewed by Antti Koivisto.
+
+ When an unbreakable set of runs overflow the available space, we need to check if the content is allowed to get wrapped to the next line.
+ Let's use the _overflowing_ run's style to decided if the content stays on the line (e.g. white-space: nowrap)
+ e.g. <span><nowrap>this_content_should_not_wrapped</nowrap>this_overflows</span>
+ ^^ in this case the overflowing run's style allows wrapping so we wrap entire content (see imported/w3c/web-platform-tests/css/css-text/overflow-wrap/overflow-wrap-break-word-white-space-crash-002.html)
+
+ * layout/inlineformatting/InlineContentBreaker.cpp:
+ (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+
2021-02-03 Ziran Sun <[email protected]>
[css-grid] max-height percentages are wrongly resolved for replaced grid items
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp (272309 => 272310)
--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2021-02-03 14:04:58 UTC (rev 272309)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2021-02-03 14:28:16 UTC (rev 272310)
@@ -202,6 +202,7 @@
return { Result::Action::Keep };
}
+ size_t overflowingRunIndex = 0;
if (isTextContent(continuousContent)) {
auto tryBreakingTextContent = [&]() -> Optional<Result> {
// 1. This text content is not breakable.
@@ -209,6 +210,7 @@
// 3. We can break the content but it still overflows.
// 4. Managed to break the content before the overflow point.
auto overflowingContent = processOverflowingTextContent(continuousContent, lineStatus);
+ overflowingRunIndex = overflowingContent.runIndex;
if (!overflowingContent.breakingPosition)
return { };
auto trailingContent = overflowingContent.breakingPosition->trailingContent;
@@ -236,6 +238,15 @@
};
if (auto result = tryBreakingTextContent())
return *result;
+ } else if (continuousContent.runs().size() > 1) {
+ // FIXME: Add support for various content.
+ auto& runs = continuousContent.runs();
+ for (size_t i = 0; i < runs.size(); ++i) {
+ if (runs[i].inlineItem.isBox()) {
+ overflowingRunIndex = i;
+ break;
+ }
+ }
}
// If we are not allowed to break this overflowing content, we still need to decide whether keep it or wrap it to the next line.
@@ -244,33 +255,16 @@
return { Result::Action::Keep, IsEndOfLine::No };
}
// Now either wrap this content over to the next line or revert back to an earlier wrapping opportunity, or not wrap at all.
- auto shouldWrapThisContentToNextLine = [&] {
+ auto shouldWrapUnbreakableContentToNextLine = [&] {
+ auto overflowingInlineItem = continuousContent.runs()[overflowingRunIndex].inlineItem;
+ auto& styleToUse = overflowingInlineItem.isBox() ? overflowingInlineItem.layoutBox().parent().style() : overflowingInlineItem.layoutBox().style();
// The individual runs in this continuous content don't break, let's check if we are allowed to wrap this content to next line (e.g. pre would prevent us from wrapping).
- auto& runs = continuousContent.runs();
- auto& lastInlineItem = runs.last().inlineItem;
// 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.
- if (lastInlineItem.isBox() || lastInlineItem.isInlineBoxStart() || lastInlineItem.isInlineBoxEnd())
- return isWrappingAllowed(lastInlineItem.layoutBox().parent().style());
- if (lastInlineItem.isText()) {
- if (runs.size() == 1) {
- // Fast path for the most common case of an individual text item.
- return isWrappingAllowed(lastInlineItem.layoutBox().style());
- }
- for (auto& run : WTF::makeReversedRange(runs)) {
- auto& inlineItem = run.inlineItem;
- if (inlineItem.isInlineBoxStart() || inlineItem.isInlineBoxStart())
- return isWrappingAllowed(inlineItem.layoutBox().parent().style());
- ASSERT(!inlineItem.isBox());
- }
- // This must be a set of individual text runs. We could just check the last item.
- return isWrappingAllowed(lastInlineItem.layoutBox().style());
- }
- ASSERT_NOT_REACHED();
- return true;
+ return isWrappingAllowed(styleToUse);
};
- if (shouldWrapThisContentToNextLine())
+ if (shouldWrapUnbreakableContentToNextLine())
return { Result::Action::Wrap, IsEndOfLine::Yes };
if (m_hasWrapOpportunityAtPreviousPosition)
return { Result::Action::RevertToLastWrapOpportunity, IsEndOfLine::Yes };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes