Diff
Modified: trunk/Source/WebCore/ChangeLog (270714 => 270715)
--- trunk/Source/WebCore/ChangeLog 2020-12-11 23:34:24 UTC (rev 270714)
+++ trunk/Source/WebCore/ChangeLog 2020-12-11 23:38:50 UTC (rev 270715)
@@ -1,3 +1,27 @@
+2020-12-11 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Use InlineTextItem::shouldPreserveSpacesAndTabs throughout the inline line layout code
+ https://bugs.webkit.org/show_bug.cgi?id=219799
+
+ Reviewed by Antti Koivisto.
+
+ Remove redundant local functions.
+
+ * layout/inlineformatting/InlineContentBreaker.cpp:
+ (WebCore::Layout::InlineContentBreaker::processInlineContent):
+ (WebCore::Layout::shouldKeepBeginningOfLineWhitespace): Deleted.
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::appendTextContent):
+ (WebCore::Layout::Line::Run::Run):
+ (WebCore::Layout::Line::Run::expand):
+ (WebCore::Layout::Line::Run::visuallyCollapseTrailingWhitespace):
+ (WebCore::Layout::isWhitespacePreserved): Deleted.
+ * layout/inlineformatting/InlineLine.h:
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineCandidate::InlineContent::appendInlineItem):
+ * layout/inlineformatting/text/TextUtil.h:
+ (WebCore::Layout::TextUtil::shouldPreserveTrailingWhitespace): Deleted.
+
2020-12-11 Aditya Keerthi <[email protected]>
[iOS][FCR] Add new look for select elements
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp (270714 => 270715)
--- trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2020-12-11 23:34:24 UTC (rev 270714)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp 2020-12-11 23:38:50 UTC (rev 270715)
@@ -103,12 +103,6 @@
return style.whiteSpace() != WhiteSpace::Pre && style.whiteSpace() != WhiteSpace::NoWrap;
}
-static inline bool shouldKeepBeginningOfLineWhitespace(const RenderStyle& style)
-{
- auto whitespace = style.whiteSpace();
- return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces;
-}
-
static inline Optional<size_t> lastWrapOpportunityIndex(const InlineContentBreaker::ContinuousContent::RunList& runList)
{
// <span style="white-space: pre">no_wrap</span><span>yes wrap</span><span style="white-space: pre">no_wrap</span>.
@@ -158,10 +152,11 @@
// to this position if no other line breaking opportunity exists in this content.
if (auto lastLineWrapOpportunityIndex = lastWrapOpportunityIndex(candidateContent.runs())) {
auto isEligibleLineWrapOpportunity = [&] (auto& candidateItem) {
- // Just check for leading collapsible whitespace for now.
- if (!lineStatus.isEmpty || !candidateItem.isText() || !downcast<InlineTextItem>(candidateItem).isWhitespace())
+ // Just check for leading preserved whitespace for now.
+ if (!lineStatus.isEmpty || !is<InlineTextItem>(candidateItem))
return true;
- return shouldKeepBeginningOfLineWhitespace(candidateItem.style());
+ auto inlineTextItem = downcast<InlineTextItem>(candidateItem);
+ return !inlineTextItem.isWhitespace() || InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem);
};
auto& lastWrapOpportunityCandidateItem = candidateContent.runs()[*lastLineWrapOpportunityIndex].inlineItem;
if (isEligibleLineWrapOpportunity(lastWrapOpportunityCandidateItem)) {
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (270714 => 270715)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2020-12-11 23:34:24 UTC (rev 270714)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2020-12-11 23:38:50 UTC (rev 270715)
@@ -40,12 +40,6 @@
namespace WebCore {
namespace Layout {
-static inline bool isWhitespacePreserved(const RenderStyle& style)
-{
- auto whitespace = style.whiteSpace();
- return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces;
-}
-
Line::Line(const InlineFormattingContext& inlineFormattingContext)
: m_inlineFormattingContext(inlineFormattingContext)
, m_trimmableTrailingContent(m_runs)
@@ -285,7 +279,7 @@
m_runs.append({ inlineTextItem, contentLogicalRight(), logicalWidth });
m_contentLogicalWidth += logicalWidth;
// Set the trailing trimmable content.
- if (inlineTextItem.isWhitespace() && !TextUtil::shouldPreserveTrailingWhitespace(style)) {
+ if (inlineTextItem.isWhitespace() && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem)) {
m_trimmableTrailingContent.addFullyTrimmableContent(m_runs.size() - 1, logicalWidth);
// If we ever trim this content, we need to know if the line visibility state needs to be recomputed.
if (m_trimmableTrailingContent.isEmpty())
@@ -478,12 +472,13 @@
, m_layoutBox(&inlineTextItem.layoutBox())
, m_logicalLeft(logicalLeft)
, m_logicalWidth(logicalWidth)
+ , m_shouldPreserveWhitespace(inlineTextItem.isWhitespace() && InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem))
, m_trailingWhitespaceType(trailingWhitespaceType(inlineTextItem))
, m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.inlineTextBox().content() })
{
if (m_trailingWhitespaceType != TrailingWhitespace::None) {
m_trailingWhitespaceWidth = logicalWidth;
- if (!isWhitespacePreserved(inlineTextItem.style()))
+ if (!m_shouldPreserveWhitespace)
m_expansionOpportunityCount = 1;
}
}
@@ -505,7 +500,7 @@
return;
}
m_trailingWhitespaceWidth += logicalWidth;
- if (!isWhitespacePreserved(inlineTextItem.style()))
+ if (!InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem))
++m_expansionOpportunityCount;
setExpansionBehavior(DefaultExpansion);
m_textContent->expand(m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length());
@@ -547,7 +542,7 @@
m_trailingWhitespaceWidth = { };
m_trailingWhitespaceType = TrailingWhitespace::None;
- if (!isWhitespacePreserved(style())) {
+ if (!m_shouldPreserveWhitespace) {
ASSERT(m_expansionOpportunityCount);
m_expansionOpportunityCount--;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (270714 => 270715)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2020-12-11 23:34:24 UTC (rev 270714)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2020-12-11 23:38:50 UTC (rev 270715)
@@ -124,6 +124,7 @@
const Box* m_layoutBox { nullptr };
InlineLayoutUnit m_logicalLeft { 0 };
InlineLayoutUnit m_logicalWidth { 0 };
+ bool m_shouldPreserveWhitespace { false };
TrailingWhitespace m_trailingWhitespaceType { TrailingWhitespace::None };
InlineLayoutUnit m_trailingWhitespaceWidth { 0 };
Optional<LineRun::Text> m_textContent;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (270714 => 270715)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-12-11 23:34:24 UTC (rev 270714)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-12-11 23:38:50 UTC (rev 270715)
@@ -171,7 +171,7 @@
if (!inlineItem.isText())
return { };
auto& inlineTextItem = downcast<InlineTextItem>(inlineItem);
- if (inlineTextItem.isWhitespace() && !TextUtil::shouldPreserveTrailingWhitespace(inlineTextItem.style())) {
+ if (inlineTextItem.isWhitespace() && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem)) {
// Fully collapsible trailing content.
return logicalWidth;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h (270714 => 270715)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2020-12-11 23:34:24 UTC (rev 270714)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2020-12-11 23:38:50 UTC (rev 270715)
@@ -52,7 +52,6 @@
InlineLayoutUnit logicalWidth { 0 };
};
static SplitData split(const InlineTextItem&, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft);
- static bool shouldPreserveTrailingWhitespace(const RenderStyle&);
static unsigned findNextBreakablePosition(LazyLineBreakIterator&, unsigned startPosition, const RenderStyle&);
private:
@@ -59,12 +58,6 @@
static InlineLayoutUnit fixedPitchWidth(const StringView&, const RenderStyle&, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft);
};
-inline bool TextUtil::shouldPreserveTrailingWhitespace(const RenderStyle& style)
-{
- auto whitespace = style.whiteSpace();
- return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces;
}
-
}
-}
#endif