Title: [253681] trunk/Source/WebCore
- Revision
- 253681
- Author
- [email protected]
- Date
- 2019-12-18 07:34:47 -0800 (Wed, 18 Dec 2019)
Log Message
[LFC][IFC] Add lastInlineItemWithContent to LineBreaker::Content::isAtSoftWrapOpportunity
https://bugs.webkit.org/show_bug.cgi?id=205362
<rdar://problem/58025349>
Reviewed by Antti Koivisto.
This is in preparation for being able to return a previous run index as the soft wrapping opportunity.
* layout/inlineformatting/InlineLineBreaker.cpp:
(WebCore::Layout::endsWithSoftWrapOpportunity):
(WebCore::Layout::LineBreaker::Content::isAtSoftWrapOpportunity):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (253680 => 253681)
--- trunk/Source/WebCore/ChangeLog 2019-12-18 15:27:15 UTC (rev 253680)
+++ trunk/Source/WebCore/ChangeLog 2019-12-18 15:34:47 UTC (rev 253681)
@@ -1,3 +1,17 @@
+2019-12-18 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Add lastInlineItemWithContent to LineBreaker::Content::isAtSoftWrapOpportunity
+ https://bugs.webkit.org/show_bug.cgi?id=205362
+ <rdar://problem/58025349>
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for being able to return a previous run index as the soft wrapping opportunity.
+
+ * layout/inlineformatting/InlineLineBreaker.cpp:
+ (WebCore::Layout::endsWithSoftWrapOpportunity):
+ (WebCore::Layout::LineBreaker::Content::isAtSoftWrapOpportunity):
+
2019-12-18 Dean Jackson <[email protected]>
Reverting libANGLE.a -> libANGLE-shared.dylib.
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (253680 => 253681)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-18 15:27:15 UTC (rev 253680)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2019-12-18 15:34:47 UTC (rev 253681)
@@ -261,6 +261,9 @@
// they are split at a soft breaking opportunity. See InlineTextItem::moveToNextBreakablePosition.
if (&previousTextItem.layoutBox() == &nextInlineTextItem.layoutBox())
return true;
+ // We are at the position after a whitespace.
+ if (previousTextItem.isWhitespace())
+ return true;
// Now we need to collect at least 3 adjacent characters to be able to make a descision whether the previous text item ends with breaking opportunity.
// [ex-][ample] <- second to last[x] last[-] current[a]
// We need at least 1 character in the current inline text item and 2 more from previous inline items.
@@ -289,6 +292,17 @@
// Can't decide it yet.
return false;
}
+
+ auto lastInlineItemWithContent = [&] () -> const InlineItem* {
+ for (auto& previousRun : WTF::makeReversedRange(priorContent.runs())) {
+ auto& previousInlineItem = previousRun.inlineItem;
+ if (previousInlineItem.isText() || previousInlineItem.isBox())
+ return &previousInlineItem;
+ ASSERT(previousInlineItem.isContainerStart() || previousInlineItem.isContainerEnd());
+ }
+ return nullptr;
+ };
+
auto* lastUncomittedContent = &priorContent.runs().last().inlineItem;
if (inlineItem.isText()) {
if (inlineItem.style().lineBreak() == LineBreak::Anywhere) {
@@ -315,31 +329,17 @@
// e.g.
// [text][container end][text] (text</span>text) : there's no soft wrap opportunity here.
// [inline box][container end][text] (<img></span>text) : after [container end] position is a soft wrap opportunity.
- auto& runs = priorContent.runs();
- auto didFindContent = false;
- for (auto i = priorContent.size(); i--;) {
- auto& previousInlineItem = runs[i].inlineItem;
- if (previousInlineItem.isContainerStart() || previousInlineItem.isContainerEnd())
- continue;
- if (previousInlineItem.isText() || previousInlineItem.isBox()) {
- lastUncomittedContent = &previousInlineItem;
- didFindContent = true;
- break;
- }
- ASSERT_NOT_REACHED();
+ lastUncomittedContent = lastInlineItemWithContent();
+ if (!lastUncomittedContent) {
+ // Did not find any content at all (e.g. [container start][container end][text] (<span></span>text)).
+ return false;
}
- // Did not find any content at all (e.g. [container start][container end][text] (<span></span>text)).
- if (!didFindContent)
- return false;
}
if (lastUncomittedContent->isText()) {
// [text][text] : is a continuous content.
// [text-][text] : after [hyphen] position is a soft wrap opportunity.
// [ ][text] : after [whitespace] position is a soft wrap opportunity.
- auto& lastInlineTextItem = downcast<InlineTextItem>(*lastUncomittedContent);
- if (lastInlineTextItem.isWhitespace())
- return true;
- return endsWithSoftWrapOpportunity(lastInlineTextItem, downcast<InlineTextItem>(inlineItem));
+ return endsWithSoftWrapOpportunity(downcast<InlineTextItem>(*lastUncomittedContent), downcast<InlineTextItem>(inlineItem));
}
if (lastUncomittedContent->isBox()) {
// [inline box][text] (<img>text) : after [inline box] position is a soft wrap opportunity.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes