Title: [266056] trunk/Source/WebCore
Revision
266056
Author
za...@apple.com
Date
2020-08-24 07:50:31 -0700 (Mon, 24 Aug 2020)

Log Message

[LFC][IFC] Use the term 'baseline' to indicate alignment baseline
https://bugs.webkit.org/show_bug.cgi?id=214779

Reviewed by Antti Koivisto.

This patch is in preparation for decoupling the line box and the root inline box geometry.
Inline boxes have ascent/descent pairs, while line boxes have inline boxes and a baseline.

* layout/displaytree/DisplayPainter.cpp:
(WebCore::Display::paintInlineContent):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::lineHeightConstraints const):
* layout/inlineformatting/InlineLineBox.h:
(WebCore::Layout::AscentAndDescent::height const):
(WebCore::Layout::LineBox::ascentAndDescent const):
(WebCore::Layout::LineBox::LineBox):
(WebCore::Layout::LineBox::InlineBox::InlineBox):
(WebCore::Layout::LineBox::setBaselineIfGreater):
(WebCore::Layout::LineBox::setAscentIfGreater):
(WebCore::Layout::LineBox::setDescentIfGreater):
(WebCore::Layout::LineBox::baseline const):
(WebCore::Layout::LineBox::resetBaseline):
(WebCore::Layout::LineBox::InlineBox::Baseline::height const): Deleted.
(WebCore::Layout::LineBox::setBaselineOffsetIfGreater): Deleted.
(WebCore::Layout::LineBox::baselineOffset const): Deleted.
(WebCore::Layout::LineBox::InlineBox::Baseline::Baseline): Deleted.
(WebCore::Layout::LineBox::InlineBox::Baseline::setAscent): Deleted.
(WebCore::Layout::LineBox::InlineBox::Baseline::setDescent): Deleted.
(WebCore::Layout::LineBox::InlineBox::Baseline::reset): Deleted.
(WebCore::Layout::LineBox::InlineBox::Baseline::ascent const): Deleted.
(WebCore::Layout::LineBox::InlineBox::Baseline::descent const): Deleted.
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::initialize):
(WebCore::Layout::LineBuilder::alignContentVertically):
(WebCore::Layout::LineBuilder::adjustBaselineAndLineHeight):
(WebCore::Layout::LineBuilder::halfLeadingMetrics):
* layout/inlineformatting/InlineLineBuilder.h:
(WebCore::Layout::LineBuilder::baseline const):
(WebCore::Layout::LineBuilder::baselineOffset const): Deleted.
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::paint):
* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
(WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
(WebCore::Layout::TableFormattingContext::computeAndDistributeExtraSpace):
* layout/tableformatting/TableFormattingContextGeometry.cpp:
(WebCore::Layout::TableFormattingContext::Geometry::usedBaselineForCell):
* layout/tableformatting/TableGrid.h:
(WebCore::Layout::TableGrid::Row::setBaseline):
(WebCore::Layout::TableGrid::Row::baseline const):
(WebCore::Layout::TableGrid::Cell::setBaseline):
(WebCore::Layout::TableGrid::Cell::baseline const):
(WebCore::Layout::TableGrid::Row::setBaselineOffset): Deleted.
(WebCore::Layout::TableGrid::Row::baselineOffset const): Deleted.
(WebCore::Layout::TableGrid::Cell::setBaselineOffset): Deleted.
(WebCore::Layout::TableGrid::Cell::baselineOffset const): Deleted.
* layout/tableformatting/TableLayout.cpp:
(WebCore::Layout::TableFormattingContext::TableLayout::distributedVerticalSpace):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (266055 => 266056)


--- trunk/Source/WebCore/ChangeLog	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/ChangeLog	2020-08-24 14:50:31 UTC (rev 266056)
@@ -1,3 +1,66 @@
+2020-08-24  Zalan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Use the term 'baseline' to indicate alignment baseline
+        https://bugs.webkit.org/show_bug.cgi?id=214779
+
+        Reviewed by Antti Koivisto.
+
+        This patch is in preparation for decoupling the line box and the root inline box geometry.
+        Inline boxes have ascent/descent pairs, while line boxes have inline boxes and a baseline. 
+
+        * layout/displaytree/DisplayPainter.cpp:
+        (WebCore::Display::paintInlineContent):
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
+        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+        (WebCore::Layout::InlineFormattingContext::Quirks::lineHeightConstraints const):
+        * layout/inlineformatting/InlineLineBox.h:
+        (WebCore::Layout::AscentAndDescent::height const):
+        (WebCore::Layout::LineBox::ascentAndDescent const):
+        (WebCore::Layout::LineBox::LineBox):
+        (WebCore::Layout::LineBox::InlineBox::InlineBox):
+        (WebCore::Layout::LineBox::setBaselineIfGreater):
+        (WebCore::Layout::LineBox::setAscentIfGreater):
+        (WebCore::Layout::LineBox::setDescentIfGreater):
+        (WebCore::Layout::LineBox::baseline const):
+        (WebCore::Layout::LineBox::resetBaseline):
+        (WebCore::Layout::LineBox::InlineBox::Baseline::height const): Deleted.
+        (WebCore::Layout::LineBox::setBaselineOffsetIfGreater): Deleted.
+        (WebCore::Layout::LineBox::baselineOffset const): Deleted.
+        (WebCore::Layout::LineBox::InlineBox::Baseline::Baseline): Deleted.
+        (WebCore::Layout::LineBox::InlineBox::Baseline::setAscent): Deleted.
+        (WebCore::Layout::LineBox::InlineBox::Baseline::setDescent): Deleted.
+        (WebCore::Layout::LineBox::InlineBox::Baseline::reset): Deleted.
+        (WebCore::Layout::LineBox::InlineBox::Baseline::ascent const): Deleted.
+        (WebCore::Layout::LineBox::InlineBox::Baseline::descent const): Deleted.
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::initialize):
+        (WebCore::Layout::LineBuilder::alignContentVertically):
+        (WebCore::Layout::LineBuilder::adjustBaselineAndLineHeight):
+        (WebCore::Layout::LineBuilder::halfLeadingMetrics):
+        * layout/inlineformatting/InlineLineBuilder.h:
+        (WebCore::Layout::LineBuilder::baseline const):
+        (WebCore::Layout::LineBuilder::baselineOffset const): Deleted.
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::paint):
+        * layout/tableformatting/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
+        (WebCore::Layout::TableFormattingContext::computeAndDistributeExtraSpace):
+        * layout/tableformatting/TableFormattingContextGeometry.cpp:
+        (WebCore::Layout::TableFormattingContext::Geometry::usedBaselineForCell):
+        * layout/tableformatting/TableGrid.h:
+        (WebCore::Layout::TableGrid::Row::setBaseline):
+        (WebCore::Layout::TableGrid::Row::baseline const):
+        (WebCore::Layout::TableGrid::Cell::setBaseline):
+        (WebCore::Layout::TableGrid::Cell::baseline const):
+        (WebCore::Layout::TableGrid::Row::setBaselineOffset): Deleted.
+        (WebCore::Layout::TableGrid::Row::baselineOffset const): Deleted.
+        (WebCore::Layout::TableGrid::Cell::setBaselineOffset): Deleted.
+        (WebCore::Layout::TableGrid::Cell::baselineOffset const): Deleted.
+        * layout/tableformatting/TableLayout.cpp:
+        (WebCore::Layout::TableFormattingContext::TableLayout::distributedVerticalSpace):
+
 2020-08-24  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Unreviewed. Fix GTK4 build

Modified: trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -129,11 +129,11 @@
             auto absoluteLeft = absoluteOffset.x() + run.left();
             // FIXME: Add non-baseline align painting
             auto& lineBox = displayInlineContent->lineBoxForRun(run);
-            auto baselineOffset = absoluteOffset.y() + lineBox.top() + lineBox.baseline();
+            auto baseline = absoluteOffset.y() + lineBox.top() + lineBox.baseline();
             auto expansion = run.expansion();
             auto textRun = TextRun { textContent->content(), run.left() - lineBox.left(), expansion.horizontalExpansion, expansion.behavior };
             textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
-            context.drawText(style.fontCascade(), textRun, { absoluteLeft, baselineOffset });
+            context.drawText(style.fontCascade(), textRun, { absoluteLeft, baseline });
         } else if (auto* cachedImage = run.image()) {
             auto runAbsoluteRect = FloatRect { absoluteOffset.x() + run.left(), absoluteOffset.y() + run.top(), run.width(), run.height() };
             context.drawImage(*cachedImage->image(), runAbsoluteRect);

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -569,7 +569,7 @@
         ASSERT_NOT_REACHED();
     }
     // FIXME: This is where the logical to physical translate should happen.
-    inlineContent.lineBoxes.append({ lineBox.logicalRect(), lineBox.scrollableOverflow(), lineInkOverflow, lineBox.baselineOffset() });
+    inlineContent.lineBoxes.append({ lineBox.logicalRect(), lineBox.scrollableOverflow(), lineInkOverflow, lineBox.baseline() });
 }
 
 void InlineFormattingContext::invalidateFormattingState(const InvalidationState&)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -76,19 +76,19 @@
     // computedLineHeight takes font-size into account when line-height is not set.
     // Strut is the imaginary box that we put on every line. It sets the initial vertical constraints for each new line.
     InlineLayoutUnit strutHeight = formattingRoot.style().computedLineHeight();
-    auto strutBaselineOffset = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), strutHeight).ascent();
+    auto strutBaseline = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), strutHeight).ascent;
     if (layoutState().inNoQuirksMode())
-        return { strutHeight, strutBaselineOffset, { } };
+        return { strutHeight, strutBaseline, { } };
 
     auto lineHeight = formattingRoot.style().lineHeight();
     if (lineHeight.isPercentOrCalculated()) {
-        auto initialBaselineOffset = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), 0_lu).ascent();
-        return { initialBaselineOffset, initialBaselineOffset, LineBox::InlineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
+        auto initialBaseline = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), 0_lu).ascent;
+        return { initialBaseline, initialBaseline, AscentAndDescent { strutBaseline, strutHeight - strutBaseline } };
     }
     // FIXME: The only reason why we use intValue() here is to match current inline tree (integral)behavior.
     InlineLayoutUnit initialLineHeight = lineHeight.intValue();
-    auto initialBaselineOffset = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), initialLineHeight).ascent();
-    return { initialLineHeight, initialBaselineOffset, LineBox::InlineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
+    auto initialBaseline = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), initialLineHeight).ascent;
+    return { initialLineHeight, initialBaseline, AscentAndDescent { strutBaseline, strutHeight - strutBaseline } };
 }
 
 }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (266055 => 266056)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-08-24 14:50:31 UTC (rev 266056)
@@ -33,38 +33,24 @@
 namespace WebCore {
 namespace Layout {
 
+struct AscentAndDescent {
+    InlineLayoutUnit height() const { return ascent + descent; }
+
+    InlineLayoutUnit ascent { 0 };
+    InlineLayoutUnit descent { 0 };
+};
+
 class LineBox {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     struct InlineBox {
-        struct Baseline {
-            Baseline(InlineLayoutUnit ascent, InlineLayoutUnit descent);
-            Baseline() = default;
-
-            void setAscent(InlineLayoutUnit);
-            void setDescent(InlineLayoutUnit);
-
-            void reset();
-
-            InlineLayoutUnit height() const { return ascent() + descent(); }
-            InlineLayoutUnit ascent() const;
-            InlineLayoutUnit descent() const;
-
-        private:
-#if ASSERT_ENABLED
-            bool m_hasValidAscent { false };
-            bool m_hasValidDescent { false };
-#endif
-            InlineLayoutUnit m_ascent { 0 };
-            InlineLayoutUnit m_descent { 0 };
-        };
-        InlineBox(const Baseline&);
+        InlineBox(const AscentAndDescent&);
         InlineBox() = default;
 
-        Baseline baseline;
+        AscentAndDescent ascentAndDescent;
     };
 
-    LineBox(const Display::InlineRect&, const InlineBox::Baseline&, InlineLayoutUnit baselineOffset);
+    LineBox(const Display::InlineRect&, const AscentAndDescent&, InlineLayoutUnit baseline);
     LineBox() = default;
 
     const Display::InlineRect& logicalRect() const { return m_rect; }
@@ -78,13 +64,12 @@
     InlineLayoutUnit logicalWidth() const { return m_rect.width(); }
     InlineLayoutUnit logicalHeight() const { return m_rect.height(); }
 
-    const InlineBox::Baseline& baseline() const;
-    // Baseline offset from line logical top. Note that offset does not necessarily equal to ascent.
+    // Baseline from line logical top. Note that the baseline does not necessarily equal to ascent.
     //
     // -------------------    line logical top     ------------------- (top align)
     //             ^                                              ^
     //             |                                  ^           |
-    //   ^         | baseline offset                  |           | baseline offset
+    //   ^         | baseline                         |           | baseline
     //   |         |                                  |           |
     //   | ascent  |                                  | ascent    |
     //   |         |                                  v           v
@@ -94,13 +79,15 @@
     //   | descent                                    v
     //   v
     // -------------------    line logical bottom  -------------------
-    InlineLayoutUnit baselineOffset() const;
-    void setBaselineOffsetIfGreater(InlineLayoutUnit);
+    InlineLayoutUnit baseline() const;
+    const AscentAndDescent& ascentAndDescent() const { return m_rootInlineBox.ascentAndDescent; }
+
+    void setBaselineIfGreater(InlineLayoutUnit);
     void setAscentIfGreater(InlineLayoutUnit);
     void setDescentIfGreater(InlineLayoutUnit);
 
     void resetBaseline();
-    void resetDescent() { m_rootInlineBox.baseline.setDescent(0_lu); }
+    void resetDescent() { m_rootInlineBox.ascentAndDescent.descent = { }; }
 
     void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_rect.setHeight(logicalHeight); }
 
@@ -130,28 +117,26 @@
 private:
 #if ASSERT_ENABLED
     bool m_hasValidBaseline { false };
-    bool m_hasValidBaselineOffset { false };
 #endif
     Display::InlineRect m_rect;
     Display::InlineRect m_scrollableOverflow;
-    InlineLayoutUnit m_baselineOffset { 0 };
+    InlineLayoutUnit m_baseline { 0 };
     bool m_isConsideredEmpty { true };
     InlineBox m_rootInlineBox;
 };
 
-inline LineBox::LineBox(const Display::InlineRect& rect, const InlineBox::Baseline& baseline, InlineLayoutUnit baselineOffset)
+inline LineBox::LineBox(const Display::InlineRect& rect, const AscentAndDescent& ascentAndDescent, InlineLayoutUnit baseline)
     : m_rect(rect)
-    , m_baselineOffset(baselineOffset)
-    , m_rootInlineBox(baseline)
+    , m_baseline(baseline)
+    , m_rootInlineBox(ascentAndDescent)
 {
 #if ASSERT_ENABLED
     m_hasValidBaseline = true;
-    m_hasValidBaselineOffset = true;
 #endif
 }
 
-inline LineBox::InlineBox::InlineBox(const Baseline& baseline)
-    : baseline(baseline)
+inline LineBox::InlineBox::InlineBox(const AscentAndDescent& ascentAndDescent)
+    : ascentAndDescent(ascentAndDescent)
 {
 }
 
@@ -162,99 +147,46 @@
     m_rect.setHeight(logicalHeight);
 }
 
-inline const LineBox::InlineBox::Baseline& LineBox::baseline() const
+inline void LineBox::setBaselineIfGreater(InlineLayoutUnit baseline)
 {
-    ASSERT(m_hasValidBaseline);
-    return m_rootInlineBox.baseline;
-}
-
-inline void LineBox::setBaselineOffsetIfGreater(InlineLayoutUnit baselineOffset)
-{
 #if ASSERT_ENABLED
-    m_hasValidBaselineOffset = true;
+    m_hasValidBaseline = true;
 #endif
-    m_baselineOffset = std::max(baselineOffset, m_baselineOffset);
+    m_baseline = std::max(baseline, m_baseline);
 }
 
 inline void LineBox::setAscentIfGreater(InlineLayoutUnit ascent)
 {
-    if (ascent < m_rootInlineBox.baseline.ascent())
+    if (ascent < m_rootInlineBox.ascentAndDescent.ascent)
         return;
-    setBaselineOffsetIfGreater(ascent);
-    m_rootInlineBox.baseline.setAscent(ascent);
+    setBaselineIfGreater(ascent);
+    m_rootInlineBox.ascentAndDescent.ascent = ascent;
 }
 
 inline void LineBox::setDescentIfGreater(InlineLayoutUnit descent)
 {
-    if (descent < m_rootInlineBox.baseline.descent())
+    if (descent < m_rootInlineBox.ascentAndDescent.descent)
         return;
-    m_rootInlineBox.baseline.setDescent(descent);
+    m_rootInlineBox.ascentAndDescent.descent = descent;
 }
 
-inline InlineLayoutUnit LineBox::baselineOffset() const
+inline InlineLayoutUnit LineBox::baseline() const
 {
-    ASSERT(m_hasValidBaselineOffset);
-    return m_baselineOffset;
+    ASSERT(m_hasValidBaseline);
+    return m_baseline;
 }
 
 inline void LineBox::resetBaseline()
 {
 #if ASSERT_ENABLED
-    m_hasValidBaselineOffset = true;
+    m_hasValidBaseline = true;
 #endif
-    m_baselineOffset = 0_lu;
-    m_rootInlineBox.baseline.reset();
+    m_baseline = 0_lu;
+    m_rootInlineBox.ascentAndDescent.descent = { };
+    m_rootInlineBox.ascentAndDescent.ascent = { };
 }
 
-inline LineBox::InlineBox::Baseline::Baseline(InlineLayoutUnit ascent, InlineLayoutUnit descent)
-    : m_ascent(ascent)
-    , m_descent(descent)
-{
-#if ASSERT_ENABLED
-    m_hasValidAscent = true;
-    m_hasValidDescent = true;
-#endif
 }
-
-inline void LineBox::InlineBox::Baseline::setAscent(InlineLayoutUnit ascent)
-{
-#if ASSERT_ENABLED
-    m_hasValidAscent = true;
-#endif
-    m_ascent = ascent;
 }
 
-inline void LineBox::InlineBox::Baseline::setDescent(InlineLayoutUnit descent)
-{
-#if ASSERT_ENABLED
-    m_hasValidDescent = true;
 #endif
-    m_descent = descent;
-}
-
-inline void LineBox::InlineBox::Baseline::reset()
-{
-#if ASSERT_ENABLED
-    m_hasValidAscent = true;
-    m_hasValidDescent = true;
-#endif
-    m_ascent = 0_lu;
-    m_descent = 0_lu;
-}
-
-inline InlineLayoutUnit LineBox::InlineBox::Baseline::ascent() const
-{
-    ASSERT(m_hasValidAscent);
-    return m_ascent;
-}
-
-inline InlineLayoutUnit LineBox::InlineBox::Baseline::descent() const
-{
-    ASSERT(m_hasValidDescent);
-    return m_descent;
-}
-
-}
-}
-
-#endif

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -82,17 +82,17 @@
     ASSERT(m_isIntrinsicSizing || constraints.heightAndBaseline);
 
     InlineLayoutUnit initialLineHeight = 0;
-    InlineLayoutUnit initialBaselineOffset = 0;
+    InlineLayoutUnit initialBaseline = 0;
     if (constraints.heightAndBaseline) {
         m_initialStrut = constraints.heightAndBaseline->strut;
         initialLineHeight = constraints.heightAndBaseline->height;
-        initialBaselineOffset = constraints.heightAndBaseline->baselineOffset;
+        initialBaseline = constraints.heightAndBaseline->baseline;
     } else
         m_initialStrut = { };
 
     auto lineRect = Display::InlineRect { constraints.logicalTopLeft, 0_lu, initialLineHeight };
-    auto baseline = LineBox::InlineBox::Baseline { initialBaselineOffset, initialLineHeight - initialBaselineOffset };
-    m_lineBox = LineBox { lineRect, baseline, initialBaselineOffset };
+    auto ascentAndDescent = AscentAndDescent { initialBaseline, initialLineHeight - initialBaseline };
+    m_lineBox = LineBox { lineRect, ascentAndDescent, initialBaseline };
     m_lineLogicalWidth = constraints.availableLogicalWidth;
     m_hasIntrusiveFloat = constraints.lineIsConstrainedByFloat;
 
@@ -125,7 +125,7 @@
     }
     // Remove descent when all content is baseline aligned but none of them have descent.
     if (formattingContext().quirks().lineDescentNeedsCollapsing(m_runs)) {
-        m_lineBox.shrinkVertically(m_lineBox.baseline().descent());
+        m_lineBox.shrinkVertically(m_lineBox.ascentAndDescent().descent);
         m_lineBox.resetDescent();
     }
     alignContentVertically();
@@ -146,10 +146,10 @@
         switch (verticalAlign) {
         case VerticalAlign::Baseline:
             if (run.isLineBreak() || run.isText())
-                logicalTop = baselineOffset() - ascent;
+                logicalTop = baseline() - ascent;
             else if (run.isContainerStart()) {
                 auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
-                logicalTop = baselineOffset() - ascent - boxGeometry.borderTop() - boxGeometry.paddingTop().valueOr(0);
+                logicalTop = baseline() - ascent - boxGeometry.borderTop() - boxGeometry.paddingTop().valueOr(0);
             } else if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
                 auto& formattingState = layoutState().establishedInlineFormattingState(downcast<ContainerBox>(layoutBox));
                 // Spec makes us generate at least one line -even if it is empty.
@@ -167,11 +167,11 @@
                 //     -----|-|-|---------- <- baseline
                 //
                 auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
-                auto baselineOffsetFromMarginBox = boxGeometry.marginBefore() + boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
-                logicalTop = baselineOffset() - baselineOffsetFromMarginBox;
+                auto baselineFromMarginBox = boxGeometry.marginBefore() + boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
+                logicalTop = baseline() - baselineFromMarginBox;
             } else {
                 auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
-                logicalTop = baselineOffset() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().valueOr(0_lu) + run.logicalRect().height() + boxGeometry.marginAfter());
+                logicalTop = baseline() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().valueOr(0_lu) + run.logicalRect().height() + boxGeometry.marginAfter());
             }
             break;
         case VerticalAlign::Top:
@@ -577,8 +577,8 @@
             hasSeenDirectTextOrLineBreak = true;
             // We are in quirks mode where the font-metrics might change the line line height/baseline and this is the first text content on the line
             // outside of an inline container.
-            m_lineBox.setAscentIfGreater(m_initialStrut->ascent());
-            m_lineBox.setDescentIfGreater(m_initialStrut->descent());
+            m_lineBox.setAscentIfGreater(m_initialStrut->ascent);
+            m_lineBox.setDescentIfGreater(m_initialStrut->descent);
             m_lineBox.setLogicalHeightIfGreater(m_initialStrut->height());
             continue;
         }
@@ -591,11 +591,11 @@
             if (style.verticalAlign() == VerticalAlign::Baseline) {
                 auto halfLeading = halfLeadingMetrics(fontMetrics, style.computedLineHeight());
                 // Both halfleading ascent and descent could be negative (tall font vs. small line-height value)
-                if (halfLeading.descent() > 0)
-                    m_lineBox.setDescentIfGreater(halfLeading.descent());
-                if (halfLeading.ascent() > 0)
-                    m_lineBox.setAscentIfGreater(halfLeading.ascent());
-                m_lineBox.setLogicalHeightIfGreater(m_lineBox.baseline().height());
+                if (halfLeading.descent > 0)
+                    m_lineBox.setDescentIfGreater(halfLeading.descent);
+                if (halfLeading.ascent > 0)
+                    m_lineBox.setAscentIfGreater(halfLeading.ascent);
+                m_lineBox.setLogicalHeightIfGreater(m_lineBox.ascentAndDescent().height());
             } else
                 m_lineBox.setLogicalHeightIfGreater(fontMetrics.height());
             continue;
@@ -620,13 +620,13 @@
                     // There has to be at least one line -even if it is empty.
                     auto& lastLineBox = formattingState.displayInlineContent()->lineBoxes.last();
                     auto beforeHeight = boxGeometry.marginBefore() + boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0);
-                    m_lineBox.setBaselineOffsetIfGreater(beforeHeight + lastLineBox.baseline());
+                    m_lineBox.setBaselineIfGreater(beforeHeight + lastLineBox.baseline());
                     m_lineBox.setLogicalHeightIfGreater(marginBoxHeight);
                 } else {
                     // Non inline-block boxes sit on the baseline (including their bottom margin).
                     m_lineBox.setAscentIfGreater(marginBoxHeight);
                     // Ignore negative descent (yes, negative descent is a thing).
-                    m_lineBox.setLogicalHeightIfGreater(marginBoxHeight + std::max<InlineLayoutUnit>(0, m_lineBox.baseline().descent()));
+                    m_lineBox.setLogicalHeightIfGreater(marginBoxHeight + std::max<InlineLayoutUnit>(0, m_lineBox.ascentAndDescent().descent));
                 }
                 break;
             }
@@ -639,7 +639,7 @@
                 auto lineLogicalHeight = m_lineBox.logicalHeight();
                 if (marginBoxHeight > lineLogicalHeight) {
                     m_lineBox.setLogicalHeightIfGreater(marginBoxHeight);
-                    m_lineBox.setBaselineOffsetIfGreater(m_lineBox.baselineOffset() + (marginBoxHeight - lineLogicalHeight));
+                    m_lineBox.setBaselineIfGreater(m_lineBox.baseline() + (marginBoxHeight - lineLogicalHeight));
                 }
                 break;
             }
@@ -705,7 +705,7 @@
     return false;
 }
 
-LineBox::InlineBox::Baseline LineBuilder::halfLeadingMetrics(const FontMetrics& fontMetrics, InlineLayoutUnit lineLogicalHeight)
+AscentAndDescent LineBuilder::halfLeadingMetrics(const FontMetrics& fontMetrics, InlineLayoutUnit lineLogicalHeight)
 {
     auto ascent = fontMetrics.ascent();
     auto descent = fontMetrics.descent();

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (266055 => 266056)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-08-24 14:50:31 UTC (rev 266056)
@@ -49,8 +49,8 @@
         bool lineIsConstrainedByFloat { false };
         struct HeightAndBaseline {
             InlineLayoutUnit height { 0 };
-            InlineLayoutUnit baselineOffset { 0 };
-            Optional<LineBox::InlineBox::Baseline> strut;
+            InlineLayoutUnit baseline { 0 };
+            Optional<AscentAndDescent> strut;
         };
         Optional<HeightAndBaseline> heightAndBaseline;
     };
@@ -148,7 +148,7 @@
     enum class IsLastLineWithInlineContent { No, Yes };
     RunList close(IsLastLineWithInlineContent = IsLastLineWithInlineContent::No);
 
-    static LineBox::InlineBox::Baseline halfLeadingMetrics(const FontMetrics&, InlineLayoutUnit lineLogicalHeight);
+    static AscentAndDescent halfLeadingMetrics(const FontMetrics&, InlineLayoutUnit lineLogicalHeight);
 
 private:
     InlineLayoutUnit logicalTop() const { return m_lineBox.logicalTop(); }
@@ -162,7 +162,7 @@
 
     InlineLayoutUnit contentLogicalWidth() const { return m_lineBox.logicalWidth(); }
     InlineLayoutUnit contentLogicalRight() const { return m_lineBox.logicalRight(); }
-    InlineLayoutUnit baselineOffset() const { return m_lineBox.baselineOffset(); }
+    InlineLayoutUnit baseline() const { return m_lineBox.baseline(); }
 
     struct InlineRunDetails {
         InlineLayoutUnit logicalWidth { 0 };
@@ -219,7 +219,7 @@
     const InlineFormattingContext& m_inlineFormattingContext;
     RunList m_runs;
     TrimmableTrailingContent m_trimmableTrailingContent;
-    Optional<LineBox::InlineBox::Baseline> m_initialStrut;
+    Optional<AscentAndDescent> m_initialStrut;
     InlineLayoutUnit m_lineLogicalWidth { 0 };
     Optional<TextAlignMode> m_horizontalAlignment;
     bool m_isIntrinsicSizing { false };

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -294,7 +294,7 @@
         }
 
         auto& lineBox = inlineContent.lineBoxForRun(run);
-        auto baselineOffset = paintOffset.y() + lineBox.top() + lineBox.baseline();
+        auto baseline = paintOffset.y() + lineBox.top() + lineBox.baseline();
         auto expansion = run.expansion();
 
         String textWithHyphen;
@@ -302,7 +302,7 @@
             textWithHyphen = makeString(textContent.content(), style.hyphenString());
         TextRun textRun { !textWithHyphen.isEmpty() ? textWithHyphen : textContent.content(), run.left() - lineBox.left(), expansion.horizontalExpansion, expansion.behavior };
         textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
-        FloatPoint textOrigin { rect.x() + paintOffset.x(), roundToDevicePixel(baselineOffset, deviceScaleFactor) };
+        FloatPoint textOrigin { rect.x() + paintOffset.x(), roundToDevicePixel(baseline, deviceScaleFactor) };
 
         TextPainter textPainter(paintInfo.context());
         textPainter.setFont(style.fontCascade());

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -104,9 +104,9 @@
             break;
         }
         case VerticalAlign::Baseline: {
-            auto rowBaselineOffset = LayoutUnit { rowList[cell->startRow()].baselineOffset() };
-            auto cellBaselineOffset = LayoutUnit { cell->baselineOffset() };
-            intrinsicPaddingTop = std::max(0_lu, rowBaselineOffset - cellBaselineOffset - cellDisplayBox.borderTop());
+            auto rowBaseline = LayoutUnit { rowList[cell->startRow()].baseline() };
+            auto cellBaseline = LayoutUnit { cell->baseline() };
+            intrinsicPaddingTop = std::max(0_lu, rowBaseline - cellBaseline - cellDisplayBox.borderTop());
             intrinsicPaddingBottom = std::max(0_lu, availableVerticalSpace - cellDisplayBox.verticalMarginBorderAndPadding() - intrinsicPaddingTop - cellDisplayBox.contentBoxHeight());
             break;
         }
@@ -214,11 +214,11 @@
             if (slot.hasRowSpan())
                 continue;
             auto& cell = slot.cell();
-            rowBaselines[rowIndex] = std::max(rowBaselines[rowIndex], cell.baselineOffset());
+            rowBaselines[rowIndex] = std::max(rowBaselines[rowIndex], cell.baseline());
         }
     }
     for (size_t rowIndex = 0; rowIndex < rows.size(); ++rowIndex)
-        rows[rowIndex].setBaselineOffset(rowBaselines[rowIndex]);
+        rows[rowIndex].setBaseline(rowBaselines[rowIndex]);
 }
 
 void TableFormattingContext::setUsedGeometryForSections(const ConstraintsForInFlowContent& constraints)
@@ -490,7 +490,7 @@
             // The minimum height of a row (without spanning-related height distribution) is defined as the height of an hypothetical
             // linebox containing the cells originating in the row.
             auto& cell = slot.cell();
-            cell.setBaselineOffset(geometry().usedBaselineForCell(cell.box()));
+            cell.setBaseline(geometry().usedBaselineForCell(cell.box()));
         }
     }
 

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -154,7 +154,7 @@
                 return displayInlineContent->lineBoxes[0].baseline();
         }
         if (cellDescendant.establishesTableFormattingContext())
-            return layoutState().establishedTableFormattingState(cellDescendant).tableGrid().rows().list()[0].baselineOffset();
+            return layoutState().establishedTableFormattingState(cellDescendant).tableGrid().rows().list()[0].baseline();
     }
     return formattingContext().geometryForBox(cellBox).contentBoxBottom();
 }

Modified: trunk/Source/WebCore/layout/tableformatting/TableGrid.h (266055 => 266056)


--- trunk/Source/WebCore/layout/tableformatting/TableGrid.h	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.h	2020-08-24 14:50:31 UTC (rev 266056)
@@ -120,8 +120,8 @@
         void setLogicalHeight(LayoutUnit logicalHeight) { m_logicalHeight = logicalHeight; }
         LayoutUnit logicalHeight() const { return m_logicalHeight; }
 
-        void setBaselineOffset(InlineLayoutUnit baselineOffset) { m_baselineOffset = baselineOffset; }
-        InlineLayoutUnit baselineOffset() const { return m_baselineOffset; }
+        void setBaseline(InlineLayoutUnit baseline) { m_baseline = baseline; }
+        InlineLayoutUnit baseline() const { return m_baseline; }
 
         const ContainerBox& box() const { return *m_layoutBox.get(); }
 
@@ -128,7 +128,7 @@
     private:
         LayoutUnit m_logicalTop;
         LayoutUnit m_logicalHeight;
-        InlineLayoutUnit m_baselineOffset;
+        InlineLayoutUnit m_baseline;
         WeakPtr<const ContainerBox> m_layoutBox;
     };
 
@@ -164,8 +164,8 @@
         SlotPosition position() const { return m_position; }
         CellSpan span() const { return m_span; }
 
-        void setBaselineOffset(InlineLayoutUnit baselineOffset) { m_baselineOffset = baselineOffset; }
-        InlineLayoutUnit baselineOffset() const { return m_baselineOffset; }
+        void setBaseline(InlineLayoutUnit baseline) { m_baseline = baseline; }
+        InlineLayoutUnit baseline() const { return m_baseline; }
 
         bool isFixedWidth() const;
 
@@ -175,7 +175,7 @@
         WeakPtr<const ContainerBox> m_layoutBox;
         SlotPosition m_position;
         CellSpan m_span;
-        InlineLayoutUnit m_baselineOffset { 0 };
+        InlineLayoutUnit m_baseline { 0 };
     };
 
     class Slot {

Modified: trunk/Source/WebCore/layout/tableformatting/TableLayout.cpp (266055 => 266056)


--- trunk/Source/WebCore/layout/tableformatting/TableLayout.cpp	2020-08-24 13:10:57 UTC (rev 266055)
+++ trunk/Source/WebCore/layout/tableformatting/TableLayout.cpp	2020-08-24 14:50:31 UTC (rev 266056)
@@ -281,8 +281,8 @@
             auto& cellBox = cell.box();
             auto height = formattingContext().geometryForBox(cellBox).height();
             if (cellBox.style().verticalAlign() == VerticalAlign::Baseline) {
-                maximumColumnAscent = std::max(maximumColumnAscent, cell.baselineOffset());
-                maximumColumnDescent = std::max(maximumColumnDescent, height - cell.baselineOffset());
+                maximumColumnAscent = std::max(maximumColumnAscent, cell.baseline());
+                maximumColumnDescent = std::max(maximumColumnDescent, height - cell.baseline());
                 rowHeight[rowIndex] = std::max(rowHeight[rowIndex], LayoutUnit { maximumColumnAscent + maximumColumnDescent });
             } else
                 rowHeight[rowIndex] = std::max(rowHeight[rowIndex], height);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to