Title: [267921] trunk/Source/WebCore
- Revision
- 267921
- Author
- [email protected]
- Date
- 2020-10-03 07:01:27 -0700 (Sat, 03 Oct 2020)
Log Message
[LFC][IFC][Soft hyphen] LineBuilder should hold on to all the wrap opportunities
https://bugs.webkit.org/show_bug.cgi?id=217265
Reviewed by Antti Koivisto.
This is in preparation for adding support for reverting content when the soft hyphen
overflows the line so as the last wrap opportunity InlineTextItem.
In such cases we need to go further back(front) on the line and revert even more content.
e.g <div>1­2­3­4</div>
Depending on the horizontal constraint the first line may be:
1-
12-
123-
1234
If character '4' overflows the line, we would go with '123-' by reverting to the last wrap opportunity.
However in case of a wide hyphen, '123-' may overflow the line as well and we have to revert
the content further back to e.g. '12-' or even '1-'.
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::initialize):
(WebCore::Layout::LineBuilder::handleFloatsAndInlineContent):
(WebCore::Layout::LineBuilder::rebuildLine):
* layout/inlineformatting/InlineLineBuilder.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (267920 => 267921)
--- trunk/Source/WebCore/ChangeLog 2020-10-03 13:22:26 UTC (rev 267920)
+++ trunk/Source/WebCore/ChangeLog 2020-10-03 14:01:27 UTC (rev 267921)
@@ -1,5 +1,31 @@
2020-10-03 Zalan Bujtas <[email protected]>
+ [LFC][IFC][Soft hyphen] LineBuilder should hold on to all the wrap opportunities
+ https://bugs.webkit.org/show_bug.cgi?id=217265
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for adding support for reverting content when the soft hyphen
+ overflows the line so as the last wrap opportunity InlineTextItem.
+ In such cases we need to go further back(front) on the line and revert even more content.
+ e.g <div>1­2­3­4</div>
+ Depending on the horizontal constraint the first line may be:
+ 1-
+ 12-
+ 123-
+ 1234
+ If character '4' overflows the line, we would go with '123-' by reverting to the last wrap opportunity.
+ However in case of a wide hyphen, '123-' may overflow the line as well and we have to revert
+ the content further back to e.g. '12-' or even '1-'.
+
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::initialize):
+ (WebCore::Layout::LineBuilder::handleFloatsAndInlineContent):
+ (WebCore::Layout::LineBuilder::rebuildLine):
+ * layout/inlineformatting/InlineLineBuilder.h:
+
+2020-10-03 Zalan Bujtas <[email protected]>
+
[LFC][IFC][Soft hyphen] Soft hyphen is always the trailing character
https://bugs.webkit.org/show_bug.cgi?id=217264
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (267920 => 267921)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-10-03 13:22:26 UTC (rev 267920)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-10-03 14:01:27 UTC (rev 267921)
@@ -340,7 +340,7 @@
{
m_floats.clear();
m_partialLeadingTextItem = { };
- m_lastWrapOpportunityItem = { };
+ m_wrapOpportunityList.clear();
m_line.initialize(lineConstraints.availableLogicalWidth);
m_contentIsConstrainedByFloat = lineConstraints.isConstrainedByFloat;
@@ -595,7 +595,7 @@
auto lineStatus = InlineContentBreaker::LineStatus { availableWidth, m_line.trimmableTrailingWidth(), m_line.isTrailingRunFullyTrimmable(), isLineConsideredEmpty };
auto result = inlineContentBreaker.processInlineContent(continuousInlineContent, lineStatus);
if (result.lastWrapOpportunityItem)
- m_lastWrapOpportunityItem = result.lastWrapOpportunityItem;
+ m_wrapOpportunityList.append(result.lastWrapOpportunityItem);
auto& candidateRuns = continuousInlineContent.runs();
if (result.action == InlineContentBreaker::Result::Action::Keep) {
// This continuous content can be fully placed on the current line including non-intrusive floats.
@@ -612,7 +612,7 @@
if (result.action == InlineContentBreaker::Result::Action::RevertToLastWrapOpportunity) {
ASSERT(result.isEndOfLine == InlineContentBreaker::IsEndOfLine::Yes);
// Not only this content can't be placed on the current line, but we even need to revert the line back to an earlier position.
- ASSERT(m_lastWrapOpportunityItem);
+ ASSERT(!m_wrapOpportunityList.isEmpty());
return { InlineContentBreaker::IsEndOfLine::Yes, { rebuildLine(layoutRange), true } };
}
if (result.action == InlineContentBreaker::Result::Action::Break) {
@@ -661,10 +661,11 @@
size_t LineBuilder::rebuildLine(const InlineItemRange& layoutRange)
{
- ASSERT(m_lastWrapOpportunityItem);
+ ASSERT(!m_wrapOpportunityList.isEmpty());
// We might already have added intrusive floats. They shrink the avilable horizontal space for the line.
// Let's just reuse what the line has at this point.
m_line.initialize(m_line.horizontalConstraint());
+ auto* lastWrapOpportunityItem = m_wrapOpportunityList.last();
auto currentItemIndex = layoutRange.start;
auto logicalRight = InlineLayoutUnit { };
if (m_partialLeadingTextItem) {
@@ -671,7 +672,7 @@
auto logicalWidth = inlineItemWidth(*m_partialLeadingTextItem, logicalRight);
m_line.append(*m_partialLeadingTextItem, logicalWidth);
logicalRight += logicalWidth;
- if (&m_partialLeadingTextItem.value() == m_lastWrapOpportunityItem)
+ if (&m_partialLeadingTextItem.value() == lastWrapOpportunityItem)
return 1;
++currentItemIndex;
}
@@ -680,7 +681,7 @@
auto logicalWidth = inlineItemWidth(inlineItem, logicalRight);
m_line.append(inlineItem, logicalWidth);
logicalRight += logicalWidth;
- if (&inlineItem == m_lastWrapOpportunityItem)
+ if (&inlineItem == lastWrapOpportunityItem)
return currentItemIndex - layoutRange.start + 1;
}
return layoutRange.size();
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (267920 => 267921)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2020-10-03 13:22:26 UTC (rev 267920)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2020-10-03 14:01:27 UTC (rev 267921)
@@ -116,7 +116,7 @@
const InlineItems& m_inlineItems;
LineContent::FloatList m_floats;
Optional<InlineTextItem> m_partialLeadingTextItem;
- const InlineItem* m_lastWrapOpportunityItem { nullptr };
+ Vector<const InlineItem*> m_wrapOpportunityList;
unsigned m_successiveHyphenatedLineCount { 0 };
bool m_contentIsConstrainedByFloat { false };
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes