Title: [287443] trunk/Source/WebCore
- Revision
- 287443
- Author
- [email protected]
- Date
- 2021-12-26 07:02:35 -0800 (Sun, 26 Dec 2021)
Log Message
[LFC][IFC] ContinuousContent should tell InlineContentBreaker if the candidate content is hanging
https://bugs.webkit.org/show_bug.cgi?id=234671
Reviewed by Antti Koivisto.
ContinuousContent now keeps track of whether the candidate run is a hanging content.
It enables InlineContentBreaker to just simply look at the flag to decide if the overflowing
(hanging) content should stay on the line or not.
* layout/formattingContexts/inline/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
(WebCore::Layout::InlineContentBreaker::ContinuousContent::append):
(WebCore::Layout::InlineContentBreaker::ContinuousContent::reset):
* layout/formattingContexts/inline/InlineContentBreaker.h:
(WebCore::Layout::InlineContentBreaker::ContinuousContent::isHangingContent const):
* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineCandidate::InlineContent::appendInlineItem):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (287442 => 287443)
--- trunk/Source/WebCore/ChangeLog 2021-12-26 06:16:27 UTC (rev 287442)
+++ trunk/Source/WebCore/ChangeLog 2021-12-26 15:02:35 UTC (rev 287443)
@@ -1,3 +1,23 @@
+2021-12-26 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] ContinuousContent should tell InlineContentBreaker if the candidate content is hanging
+ https://bugs.webkit.org/show_bug.cgi?id=234671
+
+ Reviewed by Antti Koivisto.
+
+ ContinuousContent now keeps track of whether the candidate run is a hanging content.
+ It enables InlineContentBreaker to just simply look at the flag to decide if the overflowing
+ (hanging) content should stay on the line or not.
+
+ * layout/formattingContexts/inline/InlineContentBreaker.cpp:
+ (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+ (WebCore::Layout::InlineContentBreaker::ContinuousContent::append):
+ (WebCore::Layout::InlineContentBreaker::ContinuousContent::reset):
+ * layout/formattingContexts/inline/InlineContentBreaker.h:
+ (WebCore::Layout::InlineContentBreaker::ContinuousContent::isHangingContent const):
+ * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineCandidate::InlineContent::appendInlineItem):
+
2021-12-25 Alan Bujtas <[email protected]>
[LFC][IFC] Turn InlineContentBreaker::ContinuousContent's leading/trailing member variables to std::optional<InlineLayoutUnit>
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp (287442 => 287443)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp 2021-12-26 06:16:27 UTC (rev 287442)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp 2021-12-26 15:02:35 UTC (rev 287443)
@@ -171,6 +171,9 @@
}
}
+ if (continuousContent.isHangingContent())
+ return InlineContentBreaker::Result { Result::Action::Keep };
+
auto canIgnoreNonContentTrailingRuns = lineStatus.collapsibleOrHangingWidth && isNonContentRunsOnly(continuousContent);
if (canIgnoreNonContentTrailingRuns) {
// Let's see if the non-content runs fit when the line has trailing collapsible/hanging content.
@@ -179,14 +182,6 @@
return InlineContentBreaker::Result { Result::Action::Keep };
}
- if (isVisuallyEmptyWhitespaceContent(continuousContent)) {
- // This overflowing content apparently falls into the remove/hang end-of-line-spaces category.
- // see https://www.w3.org/TR/css-text-3/#white-space-property matrix
-
- // FIXME: Replace it with a hanging flag on the continuous content.
- if (continuousContent.runs()[*firstTextRunIndex(continuousContent)].style.whiteSpace() == WhiteSpace::PreWrap)
- return InlineContentBreaker::Result { Result::Action::Keep };
- }
return { };
};
if (auto result = checkForTrailingContentFit())
@@ -722,11 +717,19 @@
m_trailingCollapsibleWidth = *collapsibleWidth == logicalWidth ? m_trailingCollapsibleWidth.value_or(0.f) + logicalWidth : *collapsibleWidth;
}
+void InlineContentBreaker::ContinuousContent::append(const InlineTextItem& inlineTextItem, const RenderStyle& style, InlineLayoutUnit hangingWidth)
+{
+ appendToRunList(inlineTextItem, style, hangingWidth);
+ m_trailingHangingContentWidth = hangingWidth;
+ resetTrailingWhitespace();
+}
+
void InlineContentBreaker::ContinuousContent::reset()
{
m_logicalWidth = { };
m_leadingCollapsibleWidth = { };
m_trailingCollapsibleWidth = { };
+ m_trailingHangingContentWidth = { };
m_runs.clear();
}
}
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.h (287442 => 287443)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.h 2021-12-26 06:16:27 UTC (rev 287442)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.h 2021-12-26 15:02:35 UTC (rev 287443)
@@ -85,9 +85,11 @@
std::optional<InlineLayoutUnit> trailingCollapsibleWidth() const { return m_trailingCollapsibleWidth; }
bool hasCollapsibleContent() const { return trailingCollapsibleWidth() || leadingCollapsibleWidth(); }
bool isFullyCollapsible() const;
+ bool isHangingContent() const { return m_trailingHangingContentWidth && logicalWidth() == *m_trailingHangingContentWidth; }
void append(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalWidth);
void append(const InlineTextItem&, const RenderStyle&, InlineLayoutUnit logicalWidth, std::optional<InlineLayoutUnit> collapsibleWidth);
+ void append(const InlineTextItem&, const RenderStyle&, InlineLayoutUnit hangingWidth);
void reset();
struct Run {
@@ -110,6 +112,7 @@
InlineLayoutUnit m_logicalWidth { 0 };
std::optional<InlineLayoutUnit> m_leadingCollapsibleWidth { };
std::optional<InlineLayoutUnit> m_trailingCollapsibleWidth { };
+ std::optional<InlineLayoutUnit> m_trailingHangingContentWidth { };
};
struct LineStatus {
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (287442 => 287443)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2021-12-26 06:16:27 UTC (rev 287442)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2021-12-26 15:02:35 UTC (rev 287443)
@@ -202,6 +202,10 @@
auto& inlineTextItem = downcast<InlineTextItem>(inlineItem);
auto isWhitespace = inlineTextItem.isWhitespace();
+ auto isHangingContent = isWhitespace && style.whiteSpace() == WhiteSpace::PreWrap;
+ if (isHangingContent)
+ return m_continuousContent.append(inlineTextItem, style, logicalWidth);
+
auto collapsibleWidth = [&]() -> std::optional<InlineLayoutUnit> {
if (isWhitespace && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem)) {
// Fully collapsible trailing content.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes