Changeset 287028 in webkit
- Timestamp:
- Dec 14, 2021, 9:20:18 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (modified) (3 diffs)
-
layout/formattingContexts/inline/InlineLineBox.cpp (modified) (2 diffs)
-
layout/formattingContexts/inline/InlineLineBox.h (modified) (3 diffs)
-
layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287023 r287028 1 2021-12-14 Alan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Make the LineBox content (text runs and inline level boxes) relative to the root inline box. 4 https://bugs.webkit.org/show_bug.cgi?id=234285 5 6 Reviewed by Antti Koivisto. 7 8 Let's decouple the root inline box's logical left and the text-align based horizontal offset and 9 also make the content inside the root inline box relative to it. 10 This is in preparation for handling text-align with non-RTL content. 11 12 * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp: 13 (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent): 14 (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent): 15 * layout/formattingContexts/inline/InlineLineBox.cpp: 16 (WebCore::Layout::LineBox::LineBox): 17 (WebCore::Layout::LineBox::logicalRectForTextRun const): 18 * layout/formattingContexts/inline/InlineLineBox.h: 19 (WebCore::Layout::LineBox::rootInlineBoxAlignmentOffset const): 20 * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp: 21 (WebCore::Layout::LineBoxBuilder::build): 22 1 23 2021-12-14 Rob Buis <rbuis@igalia.com> 2 24 -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp
r286957 r287028 290 290 { 291 291 // Create the inline boxes on the current line. This is mostly text and atomic inline boxes. 292 auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset(); 293 292 294 for (auto& lineRun : lineContent.runs) { 293 295 auto& layoutBox = lineRun.layoutBox(); 294 296 295 297 auto logicalRectRelativeToRoot = [&](auto logicalRect) { 296 logicalRect.moveBy( lineBoxLogicalTopLeft);298 logicalRect.moveBy({ lineBoxLogicalTopLeft.x() + rootInlineBoxAlignmentOffset, lineBoxLogicalTopLeft.y() }); 297 299 return logicalRect; 298 300 }; … … 482 484 ancestorStack.push({ }, root()); 483 485 486 auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset(); 484 487 auto contentStartInVisualOrder = InlineLayoutUnit { }; 485 488 auto createDisplayBoxesInVisualOrder = [&] { … … 491 494 } 492 495 // Adjust the content start position with the (text)alignment offset (root inline box has the alignment offset and not the individual runs). 493 contentStartInVisualOrder += rootInlineBox Rect.left();496 contentStartInVisualOrder += rootInlineBoxAlignmentOffset; 494 497 495 498 auto contentRightInVisualOrder = contentStartInVisualOrder; -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp
r283715 r287028 35 35 namespace Layout { 36 36 37 LineBox::LineBox(const Box& rootLayoutBox, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount) 38 : m_rootInlineBox({ rootLayoutBox, !lineIndex ? rootLayoutBox.firstLineStyle() : rootLayoutBox.style(), contentLogicalLeft, InlineLayoutSize { contentLogicalWidth, { } }, InlineLevelBox::Type::RootInlineBox }) 37 LineBox::LineBox(const Box& rootLayoutBox, InlineLayoutUnit rootInlineBoxAlignmentOffset, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount) 38 : m_rootInlineBoxAlignmentOffset(rootInlineBoxAlignmentOffset) 39 , m_rootInlineBox({ rootLayoutBox, !lineIndex ? rootLayoutBox.firstLineStyle() : rootLayoutBox.style(), { }, InlineLayoutSize { contentLogicalWidth, { } }, InlineLevelBox::Type::RootInlineBox }) 39 40 { 40 41 m_nonRootInlineLevelBoxList.reserveInitialCapacity(nonSpanningInlineLevelBoxCount); … … 63 64 } 64 65 InlineLayoutUnit logicalHeight = fontMetrics.height(); 65 return { runlogicalTop, m_rootInlineBox.logicalLeft() +run.logicalLeft(), run.logicalWidth(), logicalHeight };66 return { runlogicalTop, run.logicalLeft(), run.logicalWidth(), logicalHeight }; 66 67 } 67 68 -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h
r283314 r287028 60 60 WTF_MAKE_FAST_ALLOCATED; 61 61 public: 62 LineBox(const Box& rootLayoutBox, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount);62 LineBox(const Box& rootLayoutBox, InlineLayoutUnit rootInlineBoxAlignmentOffset, InlineLayoutUnit contentLogicalWidth, size_t lineIndex, size_t nonSpanningInlineLevelBoxCount); 63 63 64 64 // Note that the line can have many inline boxes and be "empty" the same time e.g. <div><span></span><span></span></div> … … 80 80 const InlineLevelBoxList& nonRootInlineLevelBoxes() const { return m_nonRootInlineLevelBoxList; } 81 81 82 InlineLayoutUnit rootInlineBoxAlignmentOffset() const { return m_rootInlineBoxAlignmentOffset; } 83 82 84 private: 83 85 friend class LineBoxBuilder; … … 98 100 OptionSet<InlineLevelBox::Type> m_boxTypes; 99 101 102 InlineLayoutUnit m_rootInlineBoxAlignmentOffset { 0 }; 100 103 InlineLevelBox m_rootInlineBox; 101 104 InlineLevelBoxList m_nonRootInlineLevelBoxList; -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp
r284432 r287028 101 101 { 102 102 auto textAlign = !lineIndex ? rootBox().firstLineStyle().textAlign() : rootBox().style().textAlign(); 103 auto contentLogicalLeft = Layout::horizontalAlignmentOffset(textAlign, lineContent).value_or(InlineLayoutUnit { });104 auto lineBox = LineBox { rootBox(), contentLogicalLeft, lineContent.contentLogicalWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount };103 auto rootInlineBoxAlignmentOffset = Layout::horizontalAlignmentOffset(textAlign, lineContent).value_or(InlineLayoutUnit { }); 104 auto lineBox = LineBox { rootBox(), rootInlineBoxAlignmentOffset, lineContent.contentLogicalWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount }; 105 105 106 106 auto lineBoxLogicalHeight = constructAndAlignInlineLevelBoxes(lineBox, lineContent.runs, lineIndex); … … 141 141 enclosingTopAndBottom.bottom = std::max(enclosingTopAndBottom.bottom, borderBox.bottom()); 142 142 } 143 return InlineDisplay::Line { lineBoxLogicalRect, scrollableOverflowRect, enclosingTopAndBottom, rootInlineBox.logicalTop() + rootInlineBox.baseline(), rootInlineBox .logicalLeft(), rootInlineBox.logicalWidth() };143 return InlineDisplay::Line { lineBoxLogicalRect, scrollableOverflowRect, enclosingTopAndBottom, rootInlineBox.logicalTop() + rootInlineBox.baseline(), rootInlineBoxAlignmentOffset + rootInlineBox.logicalLeft(), rootInlineBox.logicalWidth() }; 144 144 }; 145 145 return { line(), lineBox };
Note:
See TracChangeset
for help on using the changeset viewer.