Diff
Modified: trunk/Source/WebCore/ChangeLog (250438 => 250439)
--- trunk/Source/WebCore/ChangeLog 2019-09-27 19:12:16 UTC (rev 250438)
+++ trunk/Source/WebCore/ChangeLog 2019-09-27 19:25:53 UTC (rev 250439)
@@ -1,3 +1,27 @@
+2019-09-27 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Line::close should merge the text runs.
+ https://bugs.webkit.org/show_bug.cgi?id=202319
+ <rdar://problem/55785949>
+
+ Reviewed by Antti Koivisto.
+
+ Now Line::close returns the final Display::Run list.
+
+ * layout/displaytree/DisplayRect.h:
+ (WebCore::Display::Rect::expandHorizontally):
+ (WebCore::Display::Rect::expandVertically):
+ (WebCore::Display::Rect::expand):
+ * layout/displaytree/DisplayRun.h:
+ (WebCore::Display::Run::expandVertically):
+ (WebCore::Display::Run::expandHorizontally):
+ * layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
+ (WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns):
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::close):
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::Run::displayRun):
+
2019-09-27 Chris Dumez <[email protected]>
Allow pages served over HTTPS with `Cache-Control: no-store` header to enter the back/forward cache
Modified: trunk/Source/WebCore/layout/displaytree/DisplayRect.h (250438 => 250439)
--- trunk/Source/WebCore/layout/displaytree/DisplayRect.h 2019-09-27 19:12:16 UTC (rev 250438)
+++ trunk/Source/WebCore/layout/displaytree/DisplayRect.h 2019-09-27 19:25:53 UTC (rev 250439)
@@ -68,9 +68,9 @@
void moveHorizontally(LayoutUnit);
void moveVertically(LayoutUnit);
- void expand(LayoutUnit, LayoutUnit);
- void expandHorizontally(LayoutUnit delta) { expand(delta, 0); }
- void expandVertically(LayoutUnit delta) { expand(0, delta); }
+ void expand(Optional<LayoutUnit>, Optional<LayoutUnit>);
+ void expandHorizontally(LayoutUnit delta) { expand(delta, { }); }
+ void expandVertically(LayoutUnit delta) { expand({ }, delta); }
bool intersects(const Rect& rect) const { return m_rect.intersects(rect); }
Rect clone() const;
@@ -273,10 +273,11 @@
m_rect.move(LayoutSize { 0, offset });
}
-inline void Rect::expand(LayoutUnit width, LayoutUnit height)
+inline void Rect::expand(Optional<LayoutUnit> width, Optional<LayoutUnit> height)
{
- ASSERT(hasValidGeometry());
- m_rect.expand(width, height);
+ ASSERT(!width || m_hasValidWidth);
+ ASSERT(!height || m_hasValidHeight);
+ m_rect.expand(width.valueOr(0), height.valueOr(0));
}
inline Rect Rect::clone() const
Modified: trunk/Source/WebCore/layout/displaytree/DisplayRun.h (250438 => 250439)
--- trunk/Source/WebCore/layout/displaytree/DisplayRun.h 2019-09-27 19:12:16 UTC (rev 250438)
+++ trunk/Source/WebCore/layout/displaytree/DisplayRun.h 2019-09-27 19:25:53 UTC (rev 250439)
@@ -74,8 +74,8 @@
void setLogicalRight(LayoutUnit logicalRight) { m_logicalRect.shiftRightTo(logicalRight); }
void moveVertically(LayoutUnit delta) { m_logicalRect.moveVertically(delta); }
void moveHorizontally(LayoutUnit delta) { m_logicalRect.moveHorizontally(delta); }
- void expandVertically(LayoutUnit delta) { m_logicalRect.expand(0, delta); }
- void expandHorizontally(LayoutUnit delta) { m_logicalRect.expand(delta, 0); }
+ void expandVertically(LayoutUnit delta) { m_logicalRect.expandVertically(delta); }
+ void expandHorizontally(LayoutUnit delta) { m_logicalRect.expandHorizontally(delta); }
void setTextContext(TextContext textContext) { m_textContext.emplace(textContext); }
Optional<TextContext>& textContext() { return m_textContext; }
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (250438 => 250439)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2019-09-27 19:12:16 UTC (rev 250438)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2019-09-27 19:25:53 UTC (rev 250439)
@@ -67,7 +67,7 @@
LayoutUnit widthConstraint() const { return m_usedHorizontalValues.constraints.width; }
LineContent placeInlineItems(const LineInput&) const;
- void createDisplayRuns(const LineContent&);
+ void setupDisplayBoxes(const LineContent&);
void alignRuns(TextAlignMode, InlineRuns&, unsigned firstRunIndex, LayoutUnit availableWidth) const;
private:
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (250438 => 250439)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-09-27 19:12:16 UTC (rev 250438)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp 2019-09-27 19:25:53 UTC (rev 250439)
@@ -285,7 +285,7 @@
auto lineLayout = LineLayout { formattingContext(), lineInput };
auto lineContent = lineLayout.layout();
- createDisplayRuns(lineContent);
+ setupDisplayBoxes(lineContent);
if (lineContent.lastCommitted) {
currentInlineItem = { lineContent.lastCommitted->index + 1, WTF::nullopt };
@@ -358,7 +358,7 @@
return maximumLineWidth;
}
-void InlineFormattingContext::InlineLayout::createDisplayRuns(const LineContent& lineContent)
+void InlineFormattingContext::InlineLayout::setupDisplayBoxes(const LineContent& lineContent)
{
auto& formattingContext = this->formattingContext();
auto& formattingState = this->formattingState();
@@ -381,40 +381,16 @@
// 9.4.2 Inline formatting contexts
// A line box is always tall enough for all of the boxes it contains.
- // Create final display runs.
- auto& lineRuns = lineContent.runList;
- for (unsigned index = 0; index < lineRuns.size(); ++index) {
- auto& run = lineRuns.at(index);
+ // Add final display runs to state.
+ for (auto& lineRun : lineContent.runList) {
// Inline level containers (<span>) don't generate inline runs.
- if (run->isContainerStart() || run->isContainerEnd())
+ if (lineRun->isContainerStart() || lineRun->isContainerEnd())
continue;
- auto& logicalRect = run->logicalRect();
- // Inline level box (replaced or inline-block) or <br>/<wbr>
- if (run->isLineBreak() || run->isBox()) {
- formattingState.addInlineRun(run->displayRun());
- continue;
- }
- if (run->isText()) {
- // Collapsed line runs don't generate display runs.
- if (run->isVisuallyEmpty())
- continue;
- // Try to join multiple text runs when possible.
- const Line::Run* previousRun = !index ? nullptr : lineRuns[index - 1].get();
- auto previousRunCanBeExtended = previousRun && previousRun->canBeExtended();
- auto currentRunCanBeMergedWithPrevious = !previousRun || &run->layoutBox() == &previousRun->layoutBox();
-
- if (previousRunCanBeExtended && currentRunCanBeMergedWithPrevious) {
- auto& previousDisplayRun = formattingState.inlineRuns().last();
- previousDisplayRun.expandHorizontally(logicalRect.width());
- previousDisplayRun.textContext()->expand(run->displayRun().textContext()->length());
- } else
- formattingState.addInlineRun(run->displayRun());
- continue;
- }
- ASSERT_NOT_REACHED();
+ formattingState.addInlineRun(lineRun->displayRun());
}
auto geometry = formattingContext.geometry();
+ auto& lineRuns = lineContent.runList;
for (unsigned index = 0; index < lineRuns.size(); ++index) {
auto& lineRun = lineRuns.at(index);
auto& logicalRect = lineRun->logicalRect();
@@ -458,7 +434,6 @@
continue;
}
- // Text content. Try to join multiple text runs when possible.
if (lineRun->isText()) {
const Line::Run* previousLineRun = !index ? nullptr : lineRuns[index - 1].get();
// FIXME take content breaking into account when part of the layout box is on the previous line.
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (250438 => 250439)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-09-27 19:12:16 UTC (rev 250438)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-09-27 19:25:53 UTC (rev 250439)
@@ -159,6 +159,31 @@
run->moveHorizontally(this->logicalLeft());
}
}
+
+ // Let's join text runs together when possible.
+ // FIXME: Check if we can do it as part of the loop above.
+ unsigned index = 1;
+ while (index < m_runList.size()) {
+ auto& previousRun = m_runList[index - 1];
+ if (!previousRun->canBeExtended()) {
+ ++index;
+ continue;
+ }
+ auto& currentRun = m_runList[index];
+ if (¤tRun->layoutBox() != &previousRun->layoutBox()) {
+ // Do not merge runs from different boxes (<span>foo</span><span>bar</span>).
+ ++index;
+ continue;
+ }
+ // Only text content can be extended atm.
+ ASSERT(previousRun->isText());
+ ASSERT(currentRun->isText());
+ auto& previousDisplayRun = previousRun->displayRun();
+ auto& currentDisplayRun = currentRun->displayRun();
+ previousDisplayRun.expandHorizontally(currentDisplayRun.logicalWidth());
+ previousDisplayRun.textContext()->expand(currentDisplayRun.textContext()->length());
+ m_runList.remove(index);
+ }
return WTFMove(m_runList);
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (250438 => 250439)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-09-27 19:12:16 UTC (rev 250438)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2019-09-27 19:25:53 UTC (rev 250439)
@@ -69,6 +69,7 @@
Run(const InlineItem&, const Display::Run&);
const Display::Run& displayRun() const { return m_displayRun; }
+ Display::Run& displayRun() { return m_displayRun; }
const Box& layoutBox() const { return m_inlineItem.layoutBox(); }
const Display::Rect& logicalRect() const { return m_displayRun.logicalRect(); }