Title: [251848] trunk/Source/WebCore
- Revision
- 251848
- Author
- [email protected]
- Date
- 2019-10-31 08:40:10 -0700 (Thu, 31 Oct 2019)
Log Message
[LFC][IFC] Do not merge completely collapsed run with the previous run
https://bugs.webkit.org/show_bug.cgi?id=203658
<rdar://problem/56769334>
Reviewed by Antti Koivisto.
When a whitespace run is completely collapsed (and visually empty), we should not try to merge it with previous text runs.
E.g. [before \nafter] -> [before][ ][\n][after] -> [before ][][after] -> [before ][after]
^content ^inline items ^line runs ^display runs
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::close):
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::Run::hasTrailingCollapsedContent const):
(WebCore::Layout::Line::Run::canBeExtended const): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (251847 => 251848)
--- trunk/Source/WebCore/ChangeLog 2019-10-31 15:23:10 UTC (rev 251847)
+++ trunk/Source/WebCore/ChangeLog 2019-10-31 15:40:10 UTC (rev 251848)
@@ -1,5 +1,23 @@
2019-10-31 Zalan Bujtas <[email protected]>
+ [LFC][IFC] Do not merge completely collapsed run with the previous run
+ https://bugs.webkit.org/show_bug.cgi?id=203658
+ <rdar://problem/56769334>
+
+ Reviewed by Antti Koivisto.
+
+ When a whitespace run is completely collapsed (and visually empty), we should not try to merge it with previous text runs.
+ E.g. [before \nafter] -> [before][ ][\n][after] -> [before ][][after] -> [before ][after]
+ ^content ^inline items ^line runs ^display runs
+
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::close):
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::Run::hasTrailingCollapsedContent const):
+ (WebCore::Layout::Line::Run::canBeExtended const): Deleted.
+
+2019-10-31 Zalan Bujtas <[email protected]>
+
[LFC][IFC] Set setIsCollapsed on the line item when its content is actually collapsed
https://bugs.webkit.org/show_bug.cgi?id=203655
<rdar://problem/56767543>
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (251847 => 251848)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-10-31 15:23:10 UTC (rev 251847)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-10-31 15:40:10 UTC (rev 251848)
@@ -115,25 +115,29 @@
// Join text runs together when possible.
unsigned index = 1;
while (index < m_runList.size()) {
+ auto canMergeRuns = [](const auto& previousRun, const auto& currentRun) {
+ // Do not merge runs across inline boxes (<span>foo</span><span>bar</span>)
+ if (&previousRun->layoutBox() != ¤tRun->layoutBox())
+ return false;
+ // Only text content can be merged.
+ if (!previousRun->isText() || !currentRun->isText())
+ return false;
+ // Merged content needs to be continuous.
+ if (previousRun->hasTrailingCollapsedContent())
+ return false;
+ // Visually empty runs are ignored.
+ if (currentRun->isCollapsedToZeroAdvanceWidth())
+ return false;
+ return true;
+ };
auto& previousRun = m_runList[index - 1];
- if (!previousRun->canBeExtended()) {
- ++index;
- continue;
- }
auto& currentRun = m_runList[index];
- // Do not merge runs from different boxes (<span>foo</span><span>bar</span>)
- // or within the same layout box but with preserved \n
- // (<span>text\n<span <- both the "text" and "\" belong to the same layout box)
- auto canAppendToPreviousRun = currentRun->isText() && ¤tRun->layoutBox() == &previousRun->layoutBox();
- if (!canAppendToPreviousRun) {
- ++index;
+ if (canMergeRuns(previousRun, currentRun)) {
+ previousRun->expand(*currentRun);
+ m_runList.remove(index);
continue;
}
- // Only text content can be extended atm.
- ASSERT(previousRun->isText());
- ASSERT(currentRun->isText());
- previousRun->expand(*currentRun);
- m_runList.remove(index);
+ ++index;
}
if (!m_skipAlignment) {
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (251847 => 251848)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-10-31 15:23:10 UTC (rev 251847)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-10-31 15:40:10 UTC (rev 251848)
@@ -94,8 +94,8 @@
void setCollapsesToZeroAdvanceWidth();
bool isCollapsible() const { return m_inlineItem.isText() && downcast<InlineTextItem>(m_inlineItem).isCollapsible(); }
+ bool hasTrailingCollapsedContent() const { return m_hasTrailingCollapsedContent; }
bool isWhitespace() const;
- bool canBeExtended() const;
const InlineItem& m_inlineItem;
Display::Run m_displayRun;
@@ -177,11 +177,6 @@
m_hasTrailingCollapsedContent = true;
}
-inline bool Line::Run::canBeExtended() const
-{
- return isText() && !m_hasTrailingCollapsedContent;
-}
-
inline bool Line::Run::isCollapsedToZeroAdvanceWidth() const
{
ASSERT(!m_collapsedToZeroAdvanceWidth || !m_displayRun.logicalWidth());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes