Changeset 270144 in webkit


Ignore:
Timestamp:
Nov 21, 2020 5:13:29 AM (3 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Remove InlineLineGeometry::logicalLeft/top/bottom/right/width/height helper functions
https://bugs.webkit.org/show_bug.cgi?id=219226

Reviewed by Antti Koivisto.

This is in preparation for having lineBoxLogicalRect() on InlineLineGeometry. It makes it absolutely clear
of what type of logical rect we have here.

  • layout/FormattingContextGeometry.cpp:

(WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):

  • layout/blockformatting/BlockFormattingContextGeometry.cpp:

(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedContentHeightAndMargin):

  • layout/inlineformatting/InlineFormattingContextGeometry.cpp:

(WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):

  • layout/inlineformatting/InlineLineGeometry.h:

(WebCore::Layout::InlineLineGeometry::logicalLeft const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalRight const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalTop const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalBottom const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalWidth const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalHeight const): Deleted.

  • layout/integration/LayoutIntegrationInlineContentBuilder.cpp:

(WebCore::LayoutIntegration::InlineContentBuilder::computeLineLevelVisualAdjustmentsForRuns const):
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):

  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::showInlineTreeAndRuns):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r270143 r270144  
     12020-11-21  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Remove InlineLineGeometry::logicalLeft/top/bottom/right/width/height helper functions
     4        https://bugs.webkit.org/show_bug.cgi?id=219226
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is in preparation for having lineBoxLogicalRect() on InlineLineGeometry. It makes it absolutely clear
     9        of what type of logical rect we have here.
     10
     11        * layout/FormattingContextGeometry.cpp:
     12        (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
     13        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
     14        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedContentHeightAndMargin):
     15        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
     16        (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
     17        * layout/inlineformatting/InlineLineGeometry.h:
     18        (WebCore::Layout::InlineLineGeometry::logicalLeft const): Deleted.
     19        (WebCore::Layout::InlineLineGeometry::logicalRight const): Deleted.
     20        (WebCore::Layout::InlineLineGeometry::logicalTop const): Deleted.
     21        (WebCore::Layout::InlineLineGeometry::logicalBottom const): Deleted.
     22        (WebCore::Layout::InlineLineGeometry::logicalWidth const): Deleted.
     23        (WebCore::Layout::InlineLineGeometry::logicalHeight const): Deleted.
     24        * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
     25        (WebCore::LayoutIntegration::InlineContentBuilder::computeLineLevelVisualAdjustmentsForRuns const):
     26        (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
     27        (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
     28        * layout/layouttree/LayoutTreeBuilder.cpp:
     29        (WebCore::Layout::showInlineTreeAndRuns):
     30
    1312020-11-21  Zalan Bujtas  <zalan@apple.com>
    232
  • trunk/Source/WebCore/layout/FormattingContextGeometry.cpp

    r269826 r270144  
    198198        // Even empty containers generate one line.
    199199        ASSERT(!lines.isEmpty());
    200         top = lines.first().logicalTop();
    201         bottom = lines.last().logicalBottom() + inlineFormattingState.clearGapAfterLastLine();
     200        top = lines.first().logicalRect().top();
     201        bottom = lines.last().logicalRect().bottom() + inlineFormattingState.clearGapAfterLastLine();
    202202    } else if (formattingContextRoot.establishesFlexFormattingContext()) {
    203203        auto& lines = layoutState.establishedFlexFormattingState(formattingContextRoot).lines();
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp

    r268974 r270144  
    8282            // Even empty containers generate one line.
    8383            ASSERT(!lines.isEmpty());
    84             return { toLayoutUnit(lines.last().logicalBottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
     84            return { toLayoutUnit(lines.last().logicalRect().bottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
    8585        }
    8686
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

    r270143 r270144  
    260260                auto& formattingState = layoutState().establishedInlineFormattingState(downcast<ContainerBox>(layoutBox));
    261261                auto& lastLine = formattingState.lines().last();
    262                 auto inlineBlockBaseline = lastLine.logicalTop() + lastLine.baseline();
     262                auto inlineBlockBaseline = lastLine.logicalRect().top() + lastLine.baseline();
    263263                ascent = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderTop() + inlineLevelBoxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
    264264            } else if (layoutBox.isReplacedBox())
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineGeometry.h

    r270143 r270144  
    3838    InlineLineGeometry(const InlineRect& lineLogicalRect, const InlineLayoutSize& lineBoxLogicalSize, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeftOffset, InlineLayoutUnit contentLogicalWidth);
    3939
    40     InlineLayoutUnit logicalLeft() const { return logicalRect().left(); };
    41     InlineLayoutUnit logicalRight() const { return logicalRect().right(); };
    42 
    43     InlineLayoutUnit logicalTop() const { return logicalRect().top(); };
    44     InlineLayoutUnit logicalBottom() const { return logicalRect().bottom(); };
    45 
    46     InlineLayoutUnit logicalWidth() const { return logicalRect().width(); };
    47     InlineLayoutUnit logicalHeight() const { return logicalRect().height(); };
    48 
    4940    const InlineRect& logicalRect() const { return m_logicalRect; }
    5041    const InlineLayoutSize& lineBoxLogicalSize() const { return m_lineBoxLogicalSize; }
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp

    r270143 r270144  
    187187        if (shouldCheckHorizontalOverflowForContentReplacement) {
    188188            auto& line = lines[lineIndex];
    189             auto overflowWidth = lineOverflowWidth(m_blockFlow, line.logicalWidth(), line.lineBoxLogicalSize().width());
    190             lineLevelVisualAdjustmentsForRuns[lineIndex].needsTrailingContentReplacement = overflowWidth > line.logicalWidth();
     189            auto& lineLogicalRect = line.logicalRect();
     190            auto overflowWidth = lineOverflowWidth(m_blockFlow, lineLogicalRect.width(), line.lineBoxLogicalSize().width());
     191            lineLevelVisualAdjustmentsForRuns[lineIndex].needsTrailingContentReplacement = overflowWidth > lineLogicalRect.width();
    191192        }
    192193    }
     
    213214        auto& layoutBox = lineRun.layoutBox();
    214215        auto lineIndex = lineRun.lineIndex();
    215         auto& line = lines[lineIndex];
     216        auto& lineLogicalRect = lines[lineIndex].logicalRect();
    216217        // Inline boxes are relative to the line box while final Runs need to be relative to the parent Box
    217218        // FIXME: Shouldn't we just leave them be relative to the line box?
     
    219220        // Line runs are margin box based, let's convert them to border box.
    220221        auto& geometry = m_layoutState.geometryForBox(layoutBox);
    221         runRect.moveBy({ line.logicalLeft() + std::max(geometry.marginStart(), 0_lu), line.logicalTop() + geometry.marginBefore() });
     222        runRect.moveBy({ lineLogicalRect.left() + std::max(geometry.marginStart(), 0_lu), lineLogicalRect.top() + geometry.marginBefore() });
    222223        runRect.setSize({ geometry.borderBoxWidth(), geometry.borderBoxHeight() });
    223224        if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition)
     
    232233        auto& layoutBox = lineRun.layoutBox();
    233234        auto lineIndex = lineRun.lineIndex();
    234         auto& line = lines[lineIndex];
     235        auto& lineLogicalRect = lines[lineIndex].logicalRect();
    235236        auto runRect = FloatRect { lineRun.logicalRect() };
    236237        // Inline boxes are relative to the line box while final Runs need to be relative to the parent Box
    237238        // FIXME: Shouldn't we just leave them be relative to the line box?
    238         runRect.moveBy({ line.logicalLeft(), line.logicalTop() });
     239        runRect.moveBy({ lineLogicalRect.left(), lineLogicalRect.top() });
    239240        if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition)
    240241            runRect.setY(roundToInt(runRect.y()));
     
    253254                }
    254255                auto runLogicalRect = lineRun.logicalRect();
    255                 auto lineLogicalRight = line.logicalRight();
    256256                auto ellipsisWidth = style.fontCascade().width(WebCore::TextRun { &horizontalEllipsis });
    257                 if (runLogicalRect.right() + ellipsisWidth > lineLogicalRight) {
     257                if (runLogicalRect.right() + ellipsisWidth > lineLogicalRect.right()) {
    258258                    // The next run with ellipsis would surely overflow. So let's just add it to this run even if
    259259                    // it makes the run wider than it originally was.
    260260                    hasAdjustedTrailingLineList[lineIndex] = true;
    261261                    float resultWidth = 0;
    262                     auto maxWidth = line.logicalWidth() - runLogicalRect.left();
     262                    auto maxWidth = lineLogicalRect.width() - runLogicalRect.left();
    263263                    return StringTruncator::rightTruncate(originalContent, maxWidth, style.fontCascade(), resultWidth, true);
    264264                }
     
    308308    for (size_t lineIndex = 0; lineIndex < lines.size(); ++lineIndex) {
    309309        auto& line = lines[lineIndex];
     310        auto& lineLogicalRect = line.logicalRect();
    310311        auto lineBoxLogicalSize = line.lineBoxLogicalSize();
    311312        // FIXME: This is where the logical to physical translate should happen.
    312         auto scrollableOverflowRect = FloatRect { line.logicalLeft(), line.logicalTop(), lineOverflowWidth(m_blockFlow, line.logicalWidth(), lineBoxLogicalSize.width()), line.logicalHeight() };
     313        auto scrollableOverflowRect = FloatRect { lineLogicalRect.left(), lineLogicalRect.top(), lineOverflowWidth(m_blockFlow, lineLogicalRect.width(), lineBoxLogicalSize.width()), lineLogicalRect.height() };
    313314
    314315        auto firstRunIndex = runIndex;
     
    317318            lineInkOverflowRect.unite(runs[runIndex++].inkOverflow());
    318319        auto runCount = runIndex - firstRunIndex;
    319         auto lineRect = FloatRect { line.logicalRect() };
     320        auto lineRect = FloatRect { lineLogicalRect };
    320321        auto enclosingTopAndBottom = [&] {
    321322            // Let's (vertically)enclose all the inline level boxes.
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

    r269989 r270144  
    395395        addSpacing();
    396396        auto& line = lines[lineIndex];
    397         stream << "line at (" << line.logicalLeft() << "," << line.logicalTop() << ") size (" << line.logicalWidth() << "x" << line.logicalHeight() << ") baseline (" << line.baseline() << ")";
     397        auto& lineLogicalRect = line.logicalRect();
     398        stream << "line at (" << lineLogicalRect.left() << "," << lineLogicalRect.top() << ") size (" << lineLogicalRect.width() << "x" << lineLogicalRect.height() << ") baseline (" << line.baseline() << ")";
    398399        stream.nextLine();
    399400
Note: See TracChangeset for help on using the changeset viewer.