Changeset 287317 in webkit
- Timestamp:
- Dec 21, 2021, 8:46:39 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287314 r287317 1 2021-12-21 Alan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Start using Display::Line geometry in InlineDisplayContentBuilder 4 https://bugs.webkit.org/show_bug.cgi?id=234532 5 6 Reviewed by Antti Koivisto. 7 8 This is in preparation for using Display::Line geometry for things like contentStartInVisualOrder in InlineDisplayContentBuilder. 9 10 * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp: 11 (WebCore::Layout::InlineDisplayContentBuilder::build): 12 (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent): 13 (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent): 14 * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h: 15 1 16 2021-12-21 Alan Bujtas <zalan@apple.com> 2 17 -
trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp
r287314 r287317 88 88 } 89 89 90 DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line displayLine, const size_t lineIndex)90 DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, const size_t lineIndex) 91 91 { 92 92 DisplayBoxes boxes; … … 102 102 auto contentNeedsBidiReordering = !lineContent.visualOrderList.isEmpty(); 103 103 if (contentNeedsBidiReordering) 104 processBidiContent(lineContent, lineBox, lineBoxRect.topLeft(), boxes);104 processBidiContent(lineContent, lineBox, displayLine, boxes); 105 105 else 106 processNonBidiContent(lineContent, lineBox, lineBoxRect.topLeft(), boxes);106 processNonBidiContent(lineContent, lineBox, displayLine, boxes); 107 107 processOverflownRunsForEllipsis(boxes, lineBoxRect.right()); 108 108 collectInkOverflowForInlineBoxes(boxes); … … 318 318 } 319 319 320 void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const Inline LayoutPoint& lineBoxTopLeft, DisplayBoxes& boxes)321 { 322 auto rootInlineBoxWidth = lineBox.logicalRectForRootInlineBox().width();323 auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();324 auto needsDirectionAdjustment = !root().style().isLeftToRightDirection();320 void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, DisplayBoxes& boxes) 321 { 322 ASSERT(root().style().isLeftToRightDirection()); 323 auto lineBoxRect = displayLine.lineBoxRect(); 324 auto contentStartInVisualOrder = lineBoxRect.left() + displayLine.contentLeft(); 325 325 326 326 for (auto& lineRun : lineContent.runs) { … … 328 328 329 329 auto visualRectRelativeToRoot = [&](auto logicalRect) { 330 // When the logical order == visual order, RTL inline direction is just an offset. 331 auto horizontalOffset = needsDirectionAdjustment ? lineContent.lineLogicalWidth - rootInlineBoxWidth - rootInlineBoxAlignmentOffset : rootInlineBoxAlignmentOffset; 332 logicalRect.moveBy({ lineBoxTopLeft.x() + horizontalOffset, lineBoxTopLeft.y() }); 330 logicalRect.moveBy({ contentStartInVisualOrder, lineBoxRect.top() }); 333 331 return logicalRect; 334 332 }; … … 532 530 } 533 531 534 void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const Inline LayoutPoint& lineBoxTopLeft, DisplayBoxes& boxes)532 void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, DisplayBoxes& boxes) 535 533 { 536 534 ASSERT(lineContent.visualOrderList.size() <= lineContent.runs.size()); … … 540 538 ancestorStack.push({ }, root()); 541 539 542 auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();543 auto contentStartInVisualOrder = rootInlineBoxAlignmentOffset;540 auto lineBoxRect = displayLine.lineBoxRect(); 541 auto contentStartInVisualOrder = lineBoxRect.left() + displayLine.contentLeft(); 544 542 auto createDisplayBoxesInVisualOrder = [&] { 545 543 // First visual run's initial content position depends on the block's inline direction. 546 if (!root().style().isLeftToRightDirection()) 547 contentStartInVisualOrder = lineContent.lineLogicalWidth - lineBox.logicalRectForRootInlineBox().width() - rootInlineBoxAlignmentOffset; 544 if (!root().style().isLeftToRightDirection()) { 545 // FIXME: Turn display line's contentLeft to visual and just use that value. 546 contentStartInVisualOrder = lineBoxRect.width() - displayLine.contentWidth() - displayLine.contentLeft(); 547 } 548 548 549 549 auto contentRightInVisualOrder = contentStartInVisualOrder; … … 561 561 auto visualRectRelativeToRoot = [&](auto logicalRect) { 562 562 logicalRect.setLeft(contentRightInVisualOrder); 563 logicalRect.move By(lineBoxTopLeft);563 logicalRect.moveVertically(lineBoxRect.top()); 564 564 return logicalRect; 565 565 }; … … 639 639 640 640 auto adjustVisualGeometryWithInlineBoxes = [&] { 641 auto contentRightInVisualOrder = lineBoxTopLeft.x() +contentStartInVisualOrder;641 auto contentRightInVisualOrder = contentStartInVisualOrder; 642 642 643 643 for (auto childDisplayBoxNodeIndex : displayBoxTree.root().children) 644 adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBox TopLeft.y(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);644 adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxRect.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap); 645 645 }; 646 646 adjustVisualGeometryWithInlineBoxes(); -
trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h
r287314 r287317 45 45 InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState&); 46 46 47 DisplayBoxes build(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line displayLine, const size_t lineIndex);47 DisplayBoxes build(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, const size_t lineIndex); 48 48 49 49 static void computeIsFirstIsLastBoxForInlineContent(DisplayBoxes&); 50 50 51 51 private: 52 void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const Inline LayoutPoint& lineBoxTopLeft, DisplayBoxes&);53 void processBidiContent(const LineBuilder::LineContent&, const LineBox&, const Inline LayoutPoint& lineBoxTopLeft, DisplayBoxes&);52 void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, DisplayBoxes&); 53 void processBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, DisplayBoxes&); 54 54 void processOverflownRunsForEllipsis(DisplayBoxes&, InlineLayoutUnit lineBoxRight); 55 55 void collectInkOverflowForInlineBoxes(DisplayBoxes&);
Note:
See TracChangeset
for help on using the changeset viewer.