Changeset 287317 in webkit


Ignore:
Timestamp:
Dec 21, 2021, 8:46:39 AM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Start using Display::Line geometry in InlineDisplayContentBuilder
https://bugs.webkit.org/show_bug.cgi?id=234532

Reviewed by Antti Koivisto.

This is in preparation for using Display::Line geometry for things like contentStartInVisualOrder in InlineDisplayContentBuilder.

  • layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:

(WebCore::Layout::InlineDisplayContentBuilder::build):
(WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent):
(WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):

  • layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287314 r287317  
     12021-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
    1162021-12-21  Alan Bujtas  <zalan@apple.com>
    217
  • trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp

    r287314 r287317  
    8888}
    8989
    90 DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line displayLine, const size_t lineIndex)
     90DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, const size_t lineIndex)
    9191{
    9292    DisplayBoxes boxes;
     
    102102    auto contentNeedsBidiReordering = !lineContent.visualOrderList.isEmpty();
    103103    if (contentNeedsBidiReordering)
    104         processBidiContent(lineContent, lineBox, lineBoxRect.topLeft(), boxes);
     104        processBidiContent(lineContent, lineBox, displayLine, boxes);
    105105    else
    106         processNonBidiContent(lineContent, lineBox, lineBoxRect.topLeft(), boxes);
     106        processNonBidiContent(lineContent, lineBox, displayLine, boxes);
    107107    processOverflownRunsForEllipsis(boxes, lineBoxRect.right());
    108108    collectInkOverflowForInlineBoxes(boxes);
     
    318318}
    319319
    320 void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxTopLeft, DisplayBoxes& boxes)
    321 {
    322     auto rootInlineBoxWidth = lineBox.logicalRectForRootInlineBox().width();
    323     auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
    324     auto needsDirectionAdjustment = !root().style().isLeftToRightDirection();
     320void 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();
    325325
    326326    for (auto& lineRun : lineContent.runs) {
     
    328328
    329329        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() });
    333331            return logicalRect;
    334332        };
     
    532530}
    533531
    534 void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxTopLeft, DisplayBoxes& boxes)
     532void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, DisplayBoxes& boxes)
    535533{
    536534    ASSERT(lineContent.visualOrderList.size() <= lineContent.runs.size());
     
    540538    ancestorStack.push({ }, root());
    541539
    542     auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
    543     auto contentStartInVisualOrder = rootInlineBoxAlignmentOffset;
     540    auto lineBoxRect = displayLine.lineBoxRect();
     541    auto contentStartInVisualOrder = lineBoxRect.left() + displayLine.contentLeft();
    544542    auto createDisplayBoxesInVisualOrder = [&] {
    545543        // 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        }
    548548
    549549        auto contentRightInVisualOrder = contentStartInVisualOrder;
     
    561561            auto visualRectRelativeToRoot = [&](auto logicalRect) {
    562562                logicalRect.setLeft(contentRightInVisualOrder);
    563                 logicalRect.moveBy(lineBoxTopLeft);
     563                logicalRect.moveVertically(lineBoxRect.top());
    564564                return logicalRect;
    565565            };
     
    639639
    640640        auto adjustVisualGeometryWithInlineBoxes = [&] {
    641             auto contentRightInVisualOrder = lineBoxTopLeft.x() + contentStartInVisualOrder;
     641            auto contentRightInVisualOrder = contentStartInVisualOrder;
    642642
    643643            for (auto childDisplayBoxNodeIndex : displayBoxTree.root().children)
    644                 adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxTopLeft.y(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
     644                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxRect.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
    645645        };
    646646        adjustVisualGeometryWithInlineBoxes();
  • trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h

    r287314 r287317  
    4545    InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState&);
    4646
    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);
    4848
    4949    static void computeIsFirstIsLastBoxForInlineContent(DisplayBoxes&);
    5050
    5151private:
    52     void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& lineBoxTopLeft, DisplayBoxes&);
    53     void processBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& 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&);
    5454    void processOverflownRunsForEllipsis(DisplayBoxes&, InlineLayoutUnit lineBoxRight);
    5555    void collectInkOverflowForInlineBoxes(DisplayBoxes&);
Note: See TracChangeset for help on using the changeset viewer.