Title: [267932] trunk/Source/WebCore
- Revision
- 267932
- Author
- [email protected]
- Date
- 2020-10-03 14:14:31 -0700 (Sat, 03 Oct 2020)
Log Message
[LFC][IFC][Soft hyphen] Mark the last run on the line when hyphenation is required.
https://bugs.webkit.org/show_bug.cgi?id=217281
Reviewed by Antti Koivisto.
In this patch we turn the trailing soft hyphen into an "real" hyphen when the content requires it.
* layout/inlineformatting/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::processInlineContent):
* layout/inlineformatting/InlineContentBreaker.h:
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::addTrailingHyphen):
* layout/inlineformatting/InlineLine.h:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::handleFloatsAndInlineContent):
(WebCore::Layout::LineBuilder::rebuildLineForTrailingSoftHyphen):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (267931 => 267932)
--- trunk/Source/WebCore/ChangeLog 2020-10-03 18:39:27 UTC (rev 267931)
+++ trunk/Source/WebCore/ChangeLog 2020-10-03 21:14:31 UTC (rev 267932)
@@ -1,3 +1,22 @@
+2020-10-03 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC][Soft hyphen] Mark the last run on the line when hyphenation is required.
+ https://bugs.webkit.org/show_bug.cgi?id=217281
+
+ Reviewed by Antti Koivisto.
+
+ In this patch we turn the trailing soft hyphen into an "real" hyphen when the content requires it.
+
+ * layout/inlineformatting/InlineContentBreaker.cpp:
+ (WebCore::Layout::InlineContentBreaker::processInlineContent):
+ * layout/inlineformatting/InlineContentBreaker.h:
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::addTrailingHyphen):
+ * layout/inlineformatting/InlineLine.h:
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::handleFloatsAndInlineContent):
+ (WebCore::Layout::LineBuilder::rebuildLineForTrailingSoftHyphen):
+
2020-10-03 Alex Christensen <[email protected]>
"http:" should not be a valid URL
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp (267931 => 267932)
--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2020-10-03 18:39:27 UTC (rev 267931)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2020-10-03 21:14:31 UTC (rev 267932)
@@ -169,10 +169,14 @@
m_hasWrapOpportunityAtPreviousPosition = true;
}
}
- } else if (result.action == Result::Action::Wrap && lineStatus.trailingSoftHyphenWidth) {
- // A trailing soft hyphen may turn action "Wrap" to action "Revert".
- if (*lineStatus.trailingSoftHyphenWidth > lineStatus.availableWidth && isTextContentOnly(candidateContent))
- result = { Result::Action::RevertToLastNonOverflowingWrapOpportunity, IsEndOfLine::Yes };
+ } else if (result.action == Result::Action::Wrap) {
+ if (lineStatus.trailingSoftHyphenWidth && isTextContentOnly(candidateContent)) {
+ // A trailing soft hyphen with a wrapped text content turns into a visible hyphen.
+ // Let's check if there's enough space for the hyphen character.
+ auto hyphenOverflows = *lineStatus.trailingSoftHyphenWidth > lineStatus.availableWidth;
+ auto action = "" ? Result::Action::RevertToLastNonOverflowingWrapOpportunity : Result::Action::WrapWithHyphen;
+ result = { action, IsEndOfLine::Yes };
+ }
}
return result;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.h (267931 => 267932)
--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.h 2020-10-03 18:39:27 UTC (rev 267931)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.h 2020-10-03 21:14:31 UTC (rev 267932)
@@ -51,6 +51,7 @@
Keep, // Keep content on the current line.
Break, // Partial content is on the current line.
Wrap, // Content is wrapped to the next line.
+ WrapWithHyphen, // Content is wrapped to the next line and the current line ends with a visible hyphen.
// The current content overflows and can't get broken up into smaller bits.
RevertToLastWrapOpportunity, // The content needs to be reverted back to the last wrap opportunity.
RevertToLastNonOverflowingWrapOpportunity // The content needs to be reverted back to a wrap opportunity that still fits the line.
@@ -60,7 +61,6 @@
Optional<PartialRun> partialRun; // nullopt partial run means the trailing run is a complete run.
};
Action action { Action::Keep };
-
IsEndOfLine isEndOfLine { IsEndOfLine::No };
Optional<PartialTrailingContent> partialTrailingContent { };
const InlineItem* lastWrapOpportunityItem { nullptr };
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (267931 => 267932)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2020-10-03 18:39:27 UTC (rev 267931)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2020-10-03 21:14:31 UTC (rev 267932)
@@ -395,6 +395,13 @@
return false;
}
+void Line::addTrailingHyphen()
+{
+ ASSERT(!m_runs.isEmpty());
+ ASSERT(trailingSoftHyphenWidth());
+ m_runs.last().setNeedsHyphen();
+}
+
const InlineFormattingContext& Line::formattingContext() const
{
return m_inlineFormattingContext;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (267931 => 267932)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2020-10-03 18:39:27 UTC (rev 267931)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2020-10-03 21:14:31 UTC (rev 267932)
@@ -57,6 +57,7 @@
bool isTrailingRunFullyTrimmable() const { return m_trimmableTrailingContent.isTrailingRunFullyTrimmable(); }
Optional<InlineLayoutUnit> trailingSoftHyphenWidth() const { return m_trailingSoftHyphenWidth; }
+ void addTrailingHyphen();
void moveLogicalLeft(InlineLayoutUnit);
void moveLogicalRight(InlineLayoutUnit);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (267931 => 267932)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-10-03 18:39:27 UTC (rev 267931)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-10-03 21:14:31 UTC (rev 267932)
@@ -609,6 +609,13 @@
// This continuous content can't be placed on the current line. Nothing to commit at this time.
return { InlineContentBreaker::IsEndOfLine::Yes };
}
+ if (result.action == InlineContentBreaker::Result::Action::WrapWithHyphen) {
+ ASSERT(result.isEndOfLine == InlineContentBreaker::IsEndOfLine::Yes);
+ // This continuous content can't be placed on the current line, nothing to commit.
+ // However we need to make sure that the current line gains a trailing hyphen.
+ m_line.addTrailingHyphen();
+ return { InlineContentBreaker::IsEndOfLine::Yes };
+ }
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.
@@ -696,8 +703,12 @@
// while watching the available width very closely.
auto index = rebuildLine(layoutRange, softWrapOpportunityItem);
auto trailingSoftHyphenWidth = m_line.trailingSoftHyphenWidth();
- if (!trailingSoftHyphenWidth || trailingSoftHyphenWidth <= m_line.availableWidth())
+ // Check if the trailing hyphen now fits the line (or we don't need hyhen anymore).
+ if (!trailingSoftHyphenWidth || trailingSoftHyphenWidth <= m_line.availableWidth()) {
+ if (trailingSoftHyphenWidth)
+ m_line.addTrailingHyphen();
return index;
+ }
}
// Have at least some content on the line.
return rebuildLine(layoutRange, *m_wrapOpportunityList.first());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes