Changeset 287043 in webkit
- Timestamp:
- Dec 14, 2021, 12:57:19 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287040 r287043 1 2021-12-14 Alan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Take text-align offset into account when computing the RTL display box geometry 4 https://bugs.webkit.org/show_bug.cgi?id=234287 5 6 Reviewed by Antti Koivisto. 7 8 Use LineBox::rootInlineBoxAlignmentOffset to offset the visual start position for RTL display boxes. 9 10 * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp: 11 (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent): 12 (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent): 13 1 14 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp
r287028 r287043 289 289 void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes& boxes) 290 290 { 291 // Create the inline boxes on the current line. This is mostly text and atomic inline boxes.291 auto rootInlineBoxWidth = lineBox.logicalRectForRootInlineBox().width(); 292 292 auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset(); 293 auto needsDirectionAdjustment = !root().style().isLeftToRightDirection(); 293 294 294 295 for (auto& lineRun : lineContent.runs) { 295 296 auto& layoutBox = lineRun.layoutBox(); 296 297 297 auto logicalRectRelativeToRoot = [&](auto logicalRect) { 298 logicalRect.moveBy({ lineBoxLogicalTopLeft.x() + rootInlineBoxAlignmentOffset, lineBoxLogicalTopLeft.y() }); 298 auto visualRectRelativeToRoot = [&](auto logicalRect) { 299 // When the logical order == visual order, RTL inline direction is just an offset. 300 auto horizontalOffset = needsDirectionAdjustment ? lineContent.lineLogicalWidth - rootInlineBoxWidth - rootInlineBoxAlignmentOffset : rootInlineBoxAlignmentOffset; 301 logicalRect.moveBy({ lineBoxLogicalTopLeft.x() + horizontalOffset, lineBoxLogicalTopLeft.y() }); 299 302 return logicalRect; 300 303 }; 301 304 302 305 if (lineRun.isText()) { 303 appendTextDisplayBox(lineRun, logicalRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);306 appendTextDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes); 304 307 continue; 305 308 } 306 309 if (lineRun.isSoftLineBreak()) { 307 appendSoftLineBreakDisplayBox(lineRun, logicalRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);310 appendSoftLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes); 308 311 continue; 309 312 } 310 313 if (lineRun.isHardLineBreak()) { 311 appendHardLineBreakDisplayBox(lineRun, logicalRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)), boxes);314 appendHardLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)), boxes); 312 315 continue; 313 316 } 314 317 if (lineRun.isBox()) { 315 318 appendAtomicInlineLevelDisplayBox(lineRun 316 , logicalRectRelativeToRoot(lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, formattingState().boxGeometry(layoutBox)))319 , visualRectRelativeToRoot(lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, formattingState().boxGeometry(layoutBox))) 317 320 , boxes); 318 321 continue; … … 321 324 appendInlineBoxDisplayBox(lineRun 322 325 , lineBox.inlineLevelBoxForLayoutBox(lineRun.layoutBox()) 323 , logicalRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox)))326 , visualRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox))) 324 327 , lineBox.hasContent() 325 328 , boxes); … … 335 338 appendSpanningInlineBoxDisplayBox(lineRun 336 339 , lineBox.inlineLevelBoxForLayoutBox(lineRun.layoutBox()) 337 , logicalRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox)))340 , visualRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox))) 338 341 , boxes); 339 342 continue; … … 485 488 486 489 auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset(); 487 auto contentStartInVisualOrder = InlineLayoutUnit { };490 auto contentStartInVisualOrder = rootInlineBoxAlignmentOffset; 488 491 auto createDisplayBoxesInVisualOrder = [&] { 489 auto rootInlineBoxRect = lineBox.logicalRectForRootInlineBox();490 492 // First visual run's initial content position depends on the block's inline direction. 491 if (!root().style().isLeftToRightDirection()) { 492 // FIXME: This needs the block end position instead of the lineLogicalWidth. 493 contentStartInVisualOrder += lineContent.lineLogicalWidth - rootInlineBoxRect.width(); 494 } 495 // Adjust the content start position with the (text)alignment offset (root inline box has the alignment offset and not the individual runs). 496 contentStartInVisualOrder += rootInlineBoxAlignmentOffset; 493 if (!root().style().isLeftToRightDirection()) 494 contentStartInVisualOrder = lineContent.lineLogicalWidth - lineBox.logicalRectForRootInlineBox().width() - rootInlineBoxAlignmentOffset; 497 495 498 496 auto contentRightInVisualOrder = contentStartInVisualOrder; … … 508 506 continue; 509 507 510 auto visualRectRelativeToRoot = [&](auto logical lRect) {511 logical lRect.setLeft(contentRightInVisualOrder);512 logical lRect.moveBy(lineBoxLogicalTopLeft);513 return logical lRect;508 auto visualRectRelativeToRoot = [&](auto logicalRect) { 509 logicalRect.setLeft(contentRightInVisualOrder); 510 logicalRect.moveBy(lineBoxLogicalTopLeft); 511 return logicalRect; 514 512 }; 515 513
Note:
See TracChangeset
for help on using the changeset viewer.