⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267557 in webkit


Ignore:
Timestamp:
Sep 24, 2020, 9:49:46 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Add helper functions to create LineBox::InlineBox objects for inline level boxes.
https://bugs.webkit.org/show_bug.cgi?id=216957

Reviewed by Simon Fraser.

The overloaded LineBox::InlineBox constructors were representing different types of inline level boxes.
These new helper functions make it easier to figure out how to initiate LineBox::InlineBox objects depending on the type of
the inline level box.
This patch also removes an incorrect ASSERT on the inline box's height. It is okay to have a zero height inline box.

  • layout/inlineformatting/InlineFormattingContextGeometry.cpp:

(WebCore::Layout::LineBoxBuilder::constructInlineBoxes):

  • layout/inlineformatting/InlineLineBox.cpp:

(WebCore::Layout::LineBox::InlineBox::InlineBox):
(WebCore::Layout::m_baseline):

  • layout/inlineformatting/InlineLineBox.h:

(WebCore::Layout::LineBox::InlineBox::createBoxForRootInlineBox):
(WebCore::Layout::LineBox::InlineBox::createBoxForAtomicInlineLevelBox):
(WebCore::Layout::LineBox::InlineBox::createBoxForInlineBox):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267551 r267557  
     12020-09-24  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Add helper functions to create LineBox::InlineBox objects for inline level boxes.
     4        https://bugs.webkit.org/show_bug.cgi?id=216957
     5
     6        Reviewed by Simon Fraser.
     7
     8        The overloaded LineBox::InlineBox constructors were representing different types of inline level boxes.
     9        These new helper functions make it easier to figure out how to initiate LineBox::InlineBox objects depending on the type of
     10        the inline level box.
     11        This patch also removes an incorrect ASSERT on the inline box's height. It is okay to have a zero height inline box. 
     12
     13        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
     14        (WebCore::Layout::LineBoxBuilder::constructInlineBoxes):
     15        * layout/inlineformatting/InlineLineBox.cpp:
     16        (WebCore::Layout::LineBox::InlineBox::InlineBox):
     17        (WebCore::Layout::m_baseline):
     18        * layout/inlineformatting/InlineLineBox.h:
     19        (WebCore::Layout::LineBox::InlineBox::createBoxForRootInlineBox):
     20        (WebCore::Layout::LineBox::InlineBox::createBoxForAtomicInlineLevelBox):
     21        (WebCore::Layout::LineBox::InlineBox::createBoxForInlineBox):
     22
    1232020-09-24  Keith Miller  <keith_miller@apple.com>
    224
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

    r267308 r267557  
    180180            inlineBox.setLineSpacing(lineSpacing);
    181181    };
    182 
     182    auto horizontalAligmentOffset = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { });
    183183    auto constructRootInlineBox = [&] {
    184         auto rootInlineBox = makeUnique<LineBox::InlineBox>(rootBox(), lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }), lineBox.logicalWidth());
     184        auto rootInlineBox = LineBox::InlineBox::createBoxForRootInlineBox(rootBox(), horizontalAligmentOffset, lineBox.logicalWidth());
    185185
    186186        auto lineHasImaginaryStrut = !layoutState().inQuirksMode();
     
    216216            // Construct the missing LineBox::InlineBoxes starting with the topmost ancestor.
    217217            for (auto* ancestor : WTF::makeReversedRange(ancestorsWithoutInlineBoxes)) {
    218                 auto inlineBox = makeUnique<LineBox::InlineBox>(*ancestor, lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }), lineBox.logicalWidth());
     218                auto inlineBox = LineBox::InlineBox::createBoxForInlineBox(*ancestor, horizontalAligmentOffset, lineBox.logicalWidth());
    219219                inlineBox->setIsNonEmpty();
    220220                adjustVerticalGeometryForNonEmptyInlineBox(*inlineBox);
     
    227227        auto& inlineLevelBox = run.layoutBox();
    228228        if (run.isBox()) {
    229             auto logicalLeft = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }) + run.logicalLeft();
     229            auto logicalLeft = horizontalAligmentOffset + run.logicalLeft();
    230230            auto& inlineLevelBoxGeometry = formattingContext().geometryForBox(inlineLevelBox);
    231231            auto logicalHeight = inlineLevelBoxGeometry.marginBoxHeight();
     
    249249                baseline = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderTop() + inlineLevelBoxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
    250250            }
    251             auto rect = InlineRect { { }, logicalLeft, run.logicalWidth(), logicalHeight };
    252             lineBox.addInlineBox(makeUnique<LineBox::InlineBox>(inlineLevelBox, rect, baseline));
     251            auto inlineBox = LineBox::InlineBox::createBoxForAtomicInlineLevelBox(inlineLevelBox, logicalLeft, { run.logicalWidth(), logicalHeight }, baseline);
     252            if (logicalHeight)
     253                inlineBox->setIsNonEmpty();
     254            lineBox.addInlineBox(WTFMove(inlineBox));
    253255        } else if (run.isContainerStart()) {
    254             auto logicalLeft = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }) + run.logicalLeft();
     256            auto logicalLeft = horizontalAligmentOffset + run.logicalLeft();
    255257            auto initialLogicalWidth = lineBox.logicalWidth() - run.logicalLeft();
    256258            ASSERT(initialLogicalWidth >= 0);
    257             lineBox.addInlineBox(makeUnique<LineBox::InlineBox>(inlineLevelBox, logicalLeft, initialLogicalWidth));
     259            lineBox.addInlineBox(LineBox::InlineBox::createBoxForInlineBox(inlineLevelBox, logicalLeft, initialLogicalWidth));
    258260        } else if (run.isContainerEnd()) {
    259261            // Adjust the logical width when the inline level container closes on this line.
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp

    r267328 r267557  
    3333namespace Layout {
    3434
    35 LineBox::InlineBox::InlineBox(const Box& layoutBox, const InlineRect& rect, InlineLayoutUnit baseline)
     35LineBox::InlineBox::InlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, InlineLayoutUnit baseline)
    3636    : m_layoutBox(makeWeakPtr(layoutBox))
    37     , m_logicalRect(rect)
     37    , m_logicalRect({ }, logicalLeft, logicalSize.width(), logicalSize.height())
    3838    , m_baseline(baseline)
    39     , m_isEmpty(false)
    4039{
    41     ASSERT(rect.height());
    4240}
    4341
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h

    r267434 r267557  
    5858    WTF_MAKE_FAST_ALLOCATED;
    5959public:
     60    // FIXME: This name is in conflict with the actual inline box term: inline level box whose contents participate in this IFC.
     61    // This class represents a rectangle on the line (initiated by an inline level box) with some additional attributes like baseline, descent etc.
    6062    struct InlineBox {
    6163        WTF_MAKE_ISO_ALLOCATED_INLINE(InlineBox);
    6264    public:
    63         InlineBox(const Box&, const InlineRect&, InlineLayoutUnit baseline);
    64         InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
    65         InlineBox() = default;
     65        static std::unique_ptr<LineBox::InlineBox> createBoxForRootInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
     66        static std::unique_ptr<LineBox::InlineBox> createBoxForAtomicInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, InlineLayoutUnit baseline);
     67        static std::unique_ptr<LineBox::InlineBox> createBoxForInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
    6668
    6769        const InlineRect& logicalRect() const { return m_logicalRect; }
     
    8284        const Box& layoutBox() const { return *m_layoutBox; }
    8385
     86        InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, InlineLayoutUnit baseline);
     87        InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
     88        InlineBox() = default;
     89
    8490    private:
    8591        friend class LineBoxBuilder;
     
    9298        void setLineSpacing(InlineLayoutUnit lineSpacing) { m_lineSpacing = lineSpacing; }
    9399
     100    private:
    94101        WeakPtr<const Box> m_layoutBox;
    95102        InlineRect m_logicalRect;
     
    143150};
    144151
     152inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForRootInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
     153{
     154    return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalWidth);
     155}
     156
     157inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForAtomicInlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, InlineLayoutUnit baseline)
     158{
     159    return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalSize, baseline);
     160}
     161
     162inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
     163{
     164    return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalWidth);
     165}
     166
    145167}
    146168}
Note: See TracChangeset for help on using the changeset viewer.