Diff
Modified: trunk/Source/WebCore/ChangeLog (287027 => 287028)
--- trunk/Source/WebCore/ChangeLog 2021-12-14 17:05:53 UTC (rev 287027)
+++ trunk/Source/WebCore/ChangeLog 2021-12-14 17:20:18 UTC (rev 287028)
@@ -1,3 +1,25 @@
+2021-12-14 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Make the LineBox content (text runs and inline level boxes) relative to the root inline box.
+ https://bugs.webkit.org/show_bug.cgi?id=234285
+
+ Reviewed by Antti Koivisto.
+
+ Let's decouple the root inline box's logical left and the text-align based horizontal offset and
+ also make the content inside the root inline box relative to it.
+ This is in preparation for handling text-align with non-RTL content.
+
+ * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
+ (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent):
+ (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+ * layout/formattingContexts/inline/InlineLineBox.cpp:
+ (WebCore::Layout::LineBox::LineBox):
+ (WebCore::Layout::LineBox::logicalRectForTextRun const):
+ * layout/formattingContexts/inline/InlineLineBox.h:
+ (WebCore::Layout::LineBox::rootInlineBoxAlignmentOffset const):
+ * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+ (WebCore::Layout::LineBoxBuilder::build):
+
2021-12-14 Rob Buis <[email protected]>
Incorrect aspect ratio size
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (287027 => 287028)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp 2021-12-14 17:05:53 UTC (rev 287027)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp 2021-12-14 17:20:18 UTC (rev 287028)
@@ -289,11 +289,13 @@
void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes& boxes)
{
// Create the inline boxes on the current line. This is mostly text and atomic inline boxes.
+ auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
+
for (auto& lineRun : lineContent.runs) {
auto& layoutBox = lineRun.layoutBox();
auto logicalRectRelativeToRoot = [&](auto logicalRect) {
- logicalRect.moveBy(lineBoxLogicalTopLeft);
+ logicalRect.moveBy({ lineBoxLogicalTopLeft.x() + rootInlineBoxAlignmentOffset, lineBoxLogicalTopLeft.y() });
return logicalRect;
};
@@ -481,6 +483,7 @@
auto displayBoxTree = DisplayBoxTree { };
ancestorStack.push({ }, root());
+ auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
auto contentStartInVisualOrder = InlineLayoutUnit { };
auto createDisplayBoxesInVisualOrder = [&] {
auto rootInlineBoxRect = lineBox.logicalRectForRootInlineBox();
@@ -490,7 +493,7 @@
contentStartInVisualOrder += lineContent.lineLogicalWidth - rootInlineBoxRect.width();
}
// Adjust the content start position with the (text)alignment offset (root inline box has the alignment offset and not the individual runs).
- contentStartInVisualOrder += rootInlineBoxRect.left();
+ contentStartInVisualOrder += rootInlineBoxAlignmentOffset;
auto contentRightInVisualOrder = contentStartInVisualOrder;
auto& runs = lineContent.runs;
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp (287027 => 287028)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp 2021-12-14 17:05:53 UTC (rev 287027)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp 2021-12-14 17:20:18 UTC (rev 287028)
@@ -34,8 +34,9 @@
namespace WebCore {
namespace Layout {
-LineBox::LineBox(const Box& rootLayoutBox, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount)
- : m_rootInlineBox({ rootLayoutBox, !lineIndex ? rootLayoutBox.firstLineStyle() : rootLayoutBox.style(), contentLogicalLeft, InlineLayoutSize { contentLogicalWidth, { } }, InlineLevelBox::Type::RootInlineBox })
+LineBox::LineBox(const Box& rootLayoutBox, InlineLayoutUnit rootInlineBoxAlignmentOffset, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount)
+ : m_rootInlineBoxAlignmentOffset(rootInlineBoxAlignmentOffset)
+ , m_rootInlineBox({ rootLayoutBox, !lineIndex ? rootLayoutBox.firstLineStyle() : rootLayoutBox.style(), { }, InlineLayoutSize { contentLogicalWidth, { } }, InlineLevelBox::Type::RootInlineBox })
{
m_nonRootInlineLevelBoxList.reserveInitialCapacity(nonSpanningInlineLevelBoxCount);
m_nonRootInlineLevelBoxMap.reserveInitialCapacity(nonSpanningInlineLevelBoxCount);
@@ -62,7 +63,7 @@
runlogicalTop += parentInlineBox->logicalTop();
}
InlineLayoutUnit logicalHeight = fontMetrics.height();
- return { runlogicalTop, m_rootInlineBox.logicalLeft() + run.logicalLeft(), run.logicalWidth(), logicalHeight };
+ return { runlogicalTop, run.logicalLeft(), run.logicalWidth(), logicalHeight };
}
InlineRect LineBox::logicalRectForLineBreakBox(const Box& layoutBox) const
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h (287027 => 287028)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h 2021-12-14 17:05:53 UTC (rev 287027)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h 2021-12-14 17:20:18 UTC (rev 287028)
@@ -59,7 +59,7 @@
class LineBox {
WTF_MAKE_FAST_ALLOCATED;
public:
- LineBox(const Box& rootLayoutBox, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount);
+ LineBox(const Box& rootLayoutBox, InlineLayoutUnit rootInlineBoxAlignmentOffset, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount);
// Note that the line can have many inline boxes and be "empty" the same time e.g. <div><span></span><span></span></div>
bool hasContent() const { return m_hasContent; }
@@ -79,6 +79,8 @@
using InlineLevelBoxList = Vector<InlineLevelBox>;
const InlineLevelBoxList& nonRootInlineLevelBoxes() const { return m_nonRootInlineLevelBoxList; }
+ InlineLayoutUnit rootInlineBoxAlignmentOffset() const { return m_rootInlineBoxAlignmentOffset; }
+
private:
friend class LineBoxBuilder;
friend class LineBoxVerticalAligner;
@@ -97,6 +99,7 @@
bool m_hasContent { false };
OptionSet<InlineLevelBox::Type> m_boxTypes;
+ InlineLayoutUnit m_rootInlineBoxAlignmentOffset { 0 };
InlineLevelBox m_rootInlineBox;
InlineLevelBoxList m_nonRootInlineLevelBoxList;
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (287027 => 287028)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2021-12-14 17:05:53 UTC (rev 287027)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2021-12-14 17:20:18 UTC (rev 287028)
@@ -100,8 +100,8 @@
LineBoxBuilder::LineAndLineBox LineBoxBuilder::build(const LineBuilder::LineContent& lineContent, size_t lineIndex)
{
auto textAlign = !lineIndex ? rootBox().firstLineStyle().textAlign() : rootBox().style().textAlign();
- auto contentLogicalLeft = Layout::horizontalAlignmentOffset(textAlign, lineContent).value_or(InlineLayoutUnit { });
- auto lineBox = LineBox { rootBox(), contentLogicalLeft, lineContent.contentLogicalWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount };
+ auto rootInlineBoxAlignmentOffset = Layout::horizontalAlignmentOffset(textAlign, lineContent).value_or(InlineLayoutUnit { });
+ auto lineBox = LineBox { rootBox(), rootInlineBoxAlignmentOffset, lineContent.contentLogicalWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount };
auto lineBoxLogicalHeight = constructAndAlignInlineLevelBoxes(lineBox, lineContent.runs, lineIndex);
@@ -140,7 +140,7 @@
enclosingTopAndBottom.top = std::min(enclosingTopAndBottom.top, borderBox.top());
enclosingTopAndBottom.bottom = std::max(enclosingTopAndBottom.bottom, borderBox.bottom());
}
- return InlineDisplay::Line { lineBoxLogicalRect, scrollableOverflowRect, enclosingTopAndBottom, rootInlineBox.logicalTop() + rootInlineBox.baseline(), rootInlineBox.logicalLeft(), rootInlineBox.logicalWidth() };
+ return InlineDisplay::Line { lineBoxLogicalRect, scrollableOverflowRect, enclosingTopAndBottom, rootInlineBox.logicalTop() + rootInlineBox.baseline(), rootInlineBoxAlignmentOffset + rootInlineBox.logicalLeft(), rootInlineBox.logicalWidth() };
};
return { line(), lineBox };
}