Title: [295363] trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp
Revision
295363
Author
za...@apple.com
Date
2022-06-07 13:24:49 -0700 (Tue, 07 Jun 2022)

Log Message

LineBuilder::rebuildLineForTrailingSoftHyphen may end up with no wrapping opportunities
https://bugs.webkit.org/show_bug.cgi?id=241375
<rdar://94516475>

Reviewed by Antti Koivisto.

This is a speculative fix to address the overflow issue in rebuildLineForTrailingSoftHyphen, where we assume a non-empty m_wrapOpportunityList vector.

* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::handleInlineContent):
(WebCore::Layout::LineBuilder::rebuildLineForTrailingSoftHyphen):

Canonical link: https://commits.webkit.org/251371@main

Modified Paths

Diff

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (295362 => 295363)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2022-06-07 20:15:44 UTC (rev 295362)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2022-06-07 20:24:49 UTC (rev 295363)
@@ -1034,7 +1034,9 @@
     if (result.action == InlineContentBreaker::Result::Action::RevertToLastNonOverflowingWrapOpportunity) {
         ASSERT(result.isEndOfLine == InlineContentBreaker::IsEndOfLine::Yes);
         ASSERT(!m_wrapOpportunityList.isEmpty());
-        return { InlineContentBreaker::IsEndOfLine::Yes, { rebuildLineForTrailingSoftHyphen(layoutRange), true } };
+        if (auto committedCount = rebuildLineForTrailingSoftHyphen(layoutRange))
+            return { InlineContentBreaker::IsEndOfLine::Yes, { committedCount, true } };
+        return { InlineContentBreaker::IsEndOfLine::Yes };
     }
     if (result.action == InlineContentBreaker::Result::Action::Break) {
         ASSERT(result.isEndOfLine == InlineContentBreaker::IsEndOfLine::Yes);
@@ -1106,7 +1108,11 @@
 
 size_t LineBuilder::rebuildLineForTrailingSoftHyphen(const InlineItemRange& layoutRange)
 {
-    ASSERT(!m_wrapOpportunityList.isEmpty());
+    if (m_wrapOpportunityList.isEmpty()) {
+        // We are supposed to have a wrapping opportunity on the current line at this point.
+        ASSERT_NOT_REACHED();
+        return { };
+    }
     // Revert all the way back to a wrap opportunity when either a soft hyphen fits or no hyphen is required.
     for (auto i = m_wrapOpportunityList.size(); i-- > 1;) {
         auto& softWrapOpportunityItem = *m_wrapOpportunityList[i];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to