Diff
Modified: trunk/Source/WebCore/ChangeLog (256489 => 256490)
--- trunk/Source/WebCore/ChangeLog 2020-02-13 00:24:40 UTC (rev 256489)
+++ trunk/Source/WebCore/ChangeLog 2020-02-13 00:24:44 UTC (rev 256490)
@@ -1,3 +1,32 @@
+2020-02-12 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] LineBuilder should be able to take a partial trailing inline text item
+ https://bugs.webkit.org/show_bug.cgi?id=207640
+ <rdar://problem/59390284>
+
+ Reviewed by Antti Koivisto.
+
+ With this patch, now the trailing run on the line has the needsHyphen bit set.
+ When constructing the final Display:Runs in InlineFormattingContext::setDisplayBoxesForLine using
+ the line runs, we transfer the needsHyphen bit instead of explicitly set on the trailing run.
+
+ * layout/displaytree/DisplayRun.h:
+ (WebCore::Display::Run::TextContent::TextContent):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::appendPartialTrailingTextItem):
+ (WebCore::Layout::LineBuilder::appendTextContent):
+ (WebCore::Layout::m_textContent):
+ (WebCore::Layout::LineBuilder::Run::Run):
+ * layout/inlineformatting/InlineLineBuilder.h:
+ (WebCore::Layout::LineBuilder::Run::setNeedsHyphen):
+ * layout/inlineformatting/LineLayoutContext.cpp:
+ (WebCore::Layout::LineLayoutContext::close):
+ (WebCore::Layout::LineLayoutContext::tryAddingInlineItems):
+ (WebCore::Layout::LineLayoutContext::commitPartialContent):
+ * layout/inlineformatting/LineLayoutContext.h:
+
2020-02-12 Basuke Suzuki <[email protected]>
[Curl] Force HTTP/1.1 for WebSocket connection
Modified: trunk/Source/WebCore/layout/displaytree/DisplayRun.h (256489 => 256490)
--- trunk/Source/WebCore/layout/displaytree/DisplayRun.h 2020-02-13 00:24:40 UTC (rev 256489)
+++ trunk/Source/WebCore/layout/displaytree/DisplayRun.h 2020-02-13 00:24:44 UTC (rev 256490)
@@ -43,7 +43,7 @@
struct TextContent {
WTF_MAKE_STRUCT_FAST_ALLOCATED;
public:
- TextContent(unsigned position, unsigned length, const String&);
+ TextContent(unsigned position, unsigned length, const String&, bool needsHyphen);
unsigned start() const { return m_start; }
unsigned end() const { return start() + length(); }
@@ -116,9 +116,10 @@
{
}
-inline Run::TextContent::TextContent(unsigned start, unsigned length, const String& contentString)
+inline Run::TextContent::TextContent(unsigned start, unsigned length, const String& contentString, bool needsHyphen)
: m_start(start)
, m_length(length)
+ , m_needsHyphen(needsHyphen)
, m_contentString(contentString)
{
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (256489 => 256490)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-02-13 00:24:40 UTC (rev 256489)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-02-13 00:24:44 UTC (rev 256490)
@@ -454,7 +454,6 @@
auto& inlineContent = formattingState.ensureDisplayInlineContent();
auto lineIndex = inlineContent.lineBoxes.size();
auto lineInkOverflow = lineBox.scrollableOverflow();
- Optional<unsigned> lastTextItemIndex;
// Compute box final geometry.
auto& lineRuns = lineContent.runList;
for (unsigned index = 0; index < lineRuns.size(); ++index) {
@@ -487,6 +486,9 @@
inlineContent.runs.append({ lineIndex, lineRun.layoutBox(), logicalRect, inkOverflow, lineRun.expansion(), lineRun.textContent() });
}
+ if (lineRun.isText())
+ continue;
+
if (lineRun.isLineBreak()) {
// FIXME: Since <br> and <wbr> runs have associated DOM elements, we might need to construct a display box here.
continue;
@@ -525,16 +527,8 @@
continue;
}
- if (lineRun.isText()) {
- // Anonymous inline text boxes do not create display boxes.
- lastTextItemIndex = inlineContent.runs.size() - 1;
- continue;
- }
ASSERT_NOT_REACHED();
}
- // Make sure the trailing text run gets a hyphen when it needs one.
- if (lineContent.partialContent && lineContent.partialContent->trailingContentNeedsHyphen)
- inlineContent.runs[*lastTextItemIndex].textContent()->setNeedsHyphen();
// FIXME: This is where the logical to physical translate should happen.
auto& baseline = lineBox.baseline();
inlineContent.lineBoxes.append({ lineBox.logicalRect(), lineBox.scrollableOverflow(), lineInkOverflow, { baseline.ascent(), baseline.descent() }, lineBox.baselineOffset(), lineBox.isConsideredEmpty() });
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (256489 => 256490)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-02-13 00:24:40 UTC (rev 256489)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-02-13 00:24:44 UTC (rev 256490)
@@ -393,18 +393,28 @@
void LineBuilder::append(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
{
+ appendWith(inlineItem, { logicalWidth, false });
+}
+
+void LineBuilder::appendPartialTrailingTextItem(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalWidth, bool needsHyphen)
+{
+ appendWith(inlineTextItem, { logicalWidth, needsHyphen });
+}
+
+void LineBuilder::appendWith(const InlineItem& inlineItem, const InlineRunDetails& inlineRunDetails)
+{
if (inlineItem.isText())
- appendTextContent(downcast<InlineTextItem>(inlineItem), logicalWidth);
+ appendTextContent(downcast<InlineTextItem>(inlineItem), inlineRunDetails.logicalWidth, inlineRunDetails.needsHyphen);
else if (inlineItem.isLineBreak())
appendLineBreak(inlineItem);
else if (inlineItem.isContainerStart())
- appendInlineContainerStart(inlineItem, logicalWidth);
+ appendInlineContainerStart(inlineItem, inlineRunDetails.logicalWidth);
else if (inlineItem.isContainerEnd())
- appendInlineContainerEnd(inlineItem, logicalWidth);
+ appendInlineContainerEnd(inlineItem, inlineRunDetails.logicalWidth);
else if (inlineItem.layoutBox().isReplacedBox())
- appendReplacedInlineBox(inlineItem, logicalWidth);
+ appendReplacedInlineBox(inlineItem, inlineRunDetails.logicalWidth);
else if (inlineItem.isBox())
- appendNonReplacedInlineBox(inlineItem, logicalWidth);
+ appendNonReplacedInlineBox(inlineItem, inlineRunDetails.logicalWidth);
else
ASSERT_NOT_REACHED();
@@ -439,7 +449,7 @@
appendNonBreakableSpace(inlineItem, contentLogicalRight(), logicalWidth);
}
-void LineBuilder::appendTextContent(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalWidth)
+void LineBuilder::appendTextContent(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalWidth, bool needsHyphen)
{
auto willCollapseCompletely = [&] {
if (!inlineTextItem.isCollapsible())
@@ -470,11 +480,16 @@
if (!m_runs.isEmpty()) {
auto& lastRun = m_runs.last();
inlineTextItemNeedsNewRun = lastRun.hasCollapsedTrailingWhitespace() || !lastRun.isText() || &lastRun.layoutBox() != &inlineTextItem.layoutBox();
- if (!inlineTextItemNeedsNewRun)
+ if (!inlineTextItemNeedsNewRun) {
lastRun.expand(inlineTextItem, logicalWidth);
+ if (needsHyphen) {
+ ASSERT(!lastRun.textContent()->needsHyphen());
+ lastRun.setNeedsHyphen();
+ }
+ }
}
if (inlineTextItemNeedsNewRun)
- m_runs.append({ inlineTextItem, contentLogicalWidth(), logicalWidth });
+ m_runs.append({ inlineTextItem, contentLogicalWidth(), logicalWidth, needsHyphen });
m_lineBox.expandHorizontally(logicalWidth);
@@ -750,16 +765,16 @@
: m_type(softLineBreakItem.type())
, m_layoutBox(&softLineBreakItem.layoutBox())
, m_logicalRect({ 0, logicalLeft, 0, 0 })
- , m_textContent({ softLineBreakItem.position(), 1, softLineBreakItem.inlineTextBox().content() })
+ , m_textContent({ softLineBreakItem.position(), 1, softLineBreakItem.inlineTextBox().content(), false })
{
}
-LineBuilder::Run::Run(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
+LineBuilder::Run::Run(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth, bool needsHyphen)
: m_type(InlineItem::Type::Text)
, m_layoutBox(&inlineTextItem.layoutBox())
, m_logicalRect({ 0, logicalLeft, logicalWidth, 0 })
, m_trailingWhitespaceType(trailingWhitespaceType(inlineTextItem))
- , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.inlineTextBox().content() })
+ , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.inlineTextBox().content(), needsHyphen })
{
if (m_trailingWhitespaceType != TrailingWhitespace::None) {
m_trailingWhitespaceWidth = logicalWidth;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (256489 => 256490)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2020-02-13 00:24:40 UTC (rev 256489)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2020-02-13 00:24:44 UTC (rev 256490)
@@ -61,6 +61,7 @@
void initialize(const Constraints&);
void append(const InlineItem&, InlineLayoutUnit logicalWidth);
+ void appendPartialTrailingTextItem(const InlineTextItem&, InlineLayoutUnit logicalWidth, bool needsHypen);
void resetContent();
bool isVisuallyEmpty() const { return m_lineBox.isConsideredEmpty(); }
bool hasIntrusiveFloat() const { return m_hasIntrusiveFloat; }
@@ -93,7 +94,7 @@
private:
friend class LineBuilder;
- Run(const InlineTextItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
+ Run(const InlineTextItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth, bool needsHypen);
Run(const InlineSoftLineBreakItem&, InlineLayoutUnit logicalLeft);
Run(const InlineItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
@@ -114,6 +115,8 @@
void setComputedHorizontalExpansion(InlineLayoutUnit logicalExpansion);
void setExpansionBehavior(ExpansionBehavior);
+ void setNeedsHyphen() { m_textContent->setNeedsHyphen(); }
+
enum class TrailingWhitespace {
None,
NotCollapsible,
@@ -161,8 +164,13 @@
InlineLayoutUnit contentLogicalRight() const { return m_lineBox.logicalRight(); }
InlineLayoutUnit baselineOffset() const { return m_lineBox.baselineOffset(); }
+ struct InlineRunDetails {
+ InlineLayoutUnit logicalWidth { 0 };
+ bool needsHyphen { false };
+ };
+ void appendWith(const InlineItem&, const InlineRunDetails&);
void appendNonBreakableSpace(const InlineItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
- void appendTextContent(const InlineTextItem&, InlineLayoutUnit logicalWidth);
+ void appendTextContent(const InlineTextItem&, InlineLayoutUnit logicalWidth, bool needsHyphen);
void appendNonReplacedInlineBox(const InlineItem&, InlineLayoutUnit logicalWidth);
void appendReplacedInlineBox(const InlineItem&, InlineLayoutUnit logicalWidth);
void appendInlineContainerStart(const InlineItem&, InlineLayoutUnit logicalWidth);
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (256489 => 256490)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2020-02-13 00:24:40 UTC (rev 256489)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2020-02-13 00:24:44 UTC (rev 256490)
@@ -311,11 +311,10 @@
return LineContent { { }, { }, WTFMove(m_floats), line.close(), line.lineBox() };
// Adjust hyphenated line count.
- if (partialContent && partialContent->trailingContentNeedsHyphen)
+ if (partialContent && partialContent->trailingContentHasHyphen)
++m_successiveHyphenatedLineCount;
else
m_successiveHyphenatedLineCount = 0;
-
unsigned trailingInlineItemIndex = layoutRange.start + committedInlineItemCount - 1;
ASSERT(trailingInlineItemIndex < layoutRange.end);
auto isLastLineWithInlineContent = [&] {
@@ -467,7 +466,7 @@
// FIXME: LineBuilder should not hold on to the InlineItem.
ASSERT(!m_partialTrailingTextItem);
m_partialTrailingTextItem = trailingInlineTextItem.left(partialRun->length);
- line.append(*m_partialTrailingTextItem, partialRun->logicalWidth);
+ line.appendPartialTrailingTextItem(*m_partialTrailingTextItem, partialRun->logicalWidth, partialRun->needsHyphen);
return;
}
// The partial run is the last content to commit.
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h (256489 => 256490)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h 2020-02-13 00:24:40 UTC (rev 256489)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h 2020-02-13 00:24:44 UTC (rev 256490)
@@ -41,7 +41,7 @@
struct LineContent {
struct PartialContent {
- bool trailingContentNeedsHyphen { false };
+ bool trailingContentHasHyphen { false };
unsigned overflowContentLength { 0 };
};
Optional<unsigned> trailingInlineItemIndex;