Title: [269535] trunk/Source/WebCore
- Revision
- 269535
- Author
- [email protected]
- Date
- 2020-11-06 13:07:37 -0800 (Fri, 06 Nov 2020)
Log Message
Empty text runs can't be split any further.
https://bugs.webkit.org/show_bug.cgi?id=218506
Reviewed by David Kilzer and Ryosuke Niwa.
This patch ensures that when we can't fit an empty text run on the line (available space is negative) we don't
try to split it even when the style says so.
* layout/inlineformatting/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
(WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const):
* layout/inlineformatting/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::fixedPitchWidth):
(WebCore::Layout::TextUtil::split):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (269534 => 269535)
--- trunk/Source/WebCore/ChangeLog 2020-11-06 21:05:19 UTC (rev 269534)
+++ trunk/Source/WebCore/ChangeLog 2020-11-06 21:07:37 UTC (rev 269535)
@@ -1,3 +1,20 @@
+2020-11-06 Zalan Bujtas <[email protected]>
+
+ Empty text runs can't be split any further.
+ https://bugs.webkit.org/show_bug.cgi?id=218506
+
+ Reviewed by David Kilzer and Ryosuke Niwa.
+
+ This patch ensures that when we can't fit an empty text run on the line (available space is negative) we don't
+ try to split it even when the style says so.
+
+ * layout/inlineformatting/InlineContentBreaker.cpp:
+ (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+ (WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const):
+ * layout/inlineformatting/text/TextUtil.cpp:
+ (WebCore::Layout::TextUtil::fixedPitchWidth):
+ (WebCore::Layout::TextUtil::split):
+
2020-11-06 Wenson Hsieh <[email protected]>
Move DisplayListFlushIdentifier into WebCore as DisplayList::FlushIdentifier
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp (269534 => 269535)
--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2020-11-06 21:05:19 UTC (rev 269534)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2020-11-06 21:07:37 UTC (rev 269535)
@@ -220,13 +220,12 @@
if (!trailingContent->runIndex && trailingContent->hasOverflow) {
// We tried to break the content but the available space can't even accommodate the first character.
// 1. Wrap the content over to the next line when we've got content on the line already.
- // 2. Keep the first character on the empty line (or keep the whole run if it has only one character).
+ // 2. Keep the first character on the empty line (or keep the whole run if it has only one character/completely empty).
if (!lineStatus.isEmpty)
return { Result::Action::Wrap, IsEndOfLine::Yes };
auto leadingTextRunIndex = *firstTextRunIndex(continuousContent);
auto& inlineTextItem = downcast<InlineTextItem>(continuousContent.runs()[leadingTextRunIndex].inlineItem);
- ASSERT(inlineTextItem.length());
- if (inlineTextItem.length() == 1)
+ if (inlineTextItem.length() <= 1)
return Result { Result::Action::Keep, IsEndOfLine::Yes };
auto firstCharacterWidth = TextUtil::width(inlineTextItem, inlineTextItem.start(), inlineTextItem.start() + 1);
auto firstCharacterRun = PartialRun { 1, firstCharacterWidth };
@@ -343,6 +342,10 @@
auto breakRule = wordBreakBehavior(style);
if (breakRule == WordBreakRule::AtArbitraryPosition) {
+ if (!inlineTextItem.length()) {
+ // Empty text runs may be breakable based on style, but in practice we can't really split them any further.
+ return PartialRun { };
+ }
if (findLastBreakablePosition) {
// When the run can be split at arbitrary position,
// let's just return the entire run when it is intended to fit on the line.
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (269534 => 269535)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2020-11-06 21:05:19 UTC (rev 269534)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2020-11-06 21:07:37 UTC (rev 269535)
@@ -83,6 +83,7 @@
InlineLayoutUnit TextUtil::fixedPitchWidth(const StringView& text, const RenderStyle& style, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft)
{
+ RELEASE_ASSERT(to <= text.length());
auto& font = style.fontCascade();
auto monospaceCharacterWidth = font.spaceWidth();
float width = 0;
@@ -96,12 +97,12 @@
if (i > from && (character == ' ' || character == '\t' || character == '\n'))
width += font.wordSpacing();
}
-
return std::max<InlineLayoutUnit>(0, InlineLayoutUnit(width));
}
TextUtil::SplitData TextUtil::split(const InlineTextBox& inlineTextBox, unsigned startPosition, unsigned length, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft)
{
+ ASSERT(length);
ASSERT(availableWidth >= 0);
auto left = startPosition;
// Pathological case of (extremely)long string and narrow lines.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes