Changeset 246680 in webkit


Ignore:
Timestamp:
Jun 21, 2019 8:49:21 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Adjust baseline top when the baseline moves.
https://bugs.webkit.org/show_bug.cgi?id=199091
<rdar://problem/51966257>

Reviewed by Antti Koivisto.

Currently only "text-align: bottom" adjusts the baseline top. This patch fixes the "text-align: baseline" case when
the growing ascent pushes the baseline top closer to the line top.

  • layout/inlineformatting/InlineLine.cpp:

(WebCore::Layout::Line::adjustBaselineAndLineHeight):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246679 r246680  
     12019-06-21  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Adjust baseline top when the baseline moves.
     4        https://bugs.webkit.org/show_bug.cgi?id=199091
     5        <rdar://problem/51966257>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Currently only "text-align: bottom" adjusts the baseline top. This patch fixes the "text-align: baseline" case when
     10        the growing ascent pushes the baseline top closer to the line top.
     11
     12        * layout/inlineformatting/InlineLine.cpp:
     13        (WebCore::Layout::Line::adjustBaselineAndLineHeight):
     14
    1152019-06-21  Zalan Bujtas  <zalan@apple.com>
    216
  • trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp

    r246679 r246680  
    314314
    315315    if (inlineItem.isContainerStart()) {
     316        // FIXME: This implies baseline vertical aligment for the inline container.
    316317        auto& fontMetrics = style.fontMetrics();
    317318        auto halfLeading = halfLeadingMetrics(fontMetrics, style.computedLineHeight());
     
    335336    // Replaced and non-replaced inline level box.
    336337    switch (inlineItem.style().verticalAlign()) {
    337     case VerticalAlign::Baseline:
     338     case VerticalAlign::Baseline: {
     339        auto newBaselineCandidate = LineBox::Baseline { runHeight, 0 };
    338340        if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
    339341            // Inline-blocks with inline content always have baselines.
     
    341343            // Spec makes us generate at least one line -even if it is empty.
    342344            ASSERT(!formattingState.lineBoxes().isEmpty());
    343             auto inlineBlockBaseline = formattingState.lineBoxes().last().baseline();
    344             m_baseline.descent = std::max(inlineBlockBaseline.descent, m_baseline.descent);
    345             m_baseline.ascent = std::max(inlineBlockBaseline.ascent, m_baseline.ascent);
    346             m_lineLogicalHeight = std::max(std::max(m_lineLogicalHeight, runHeight), m_baseline.height());
    347             break;
    348         }
    349         m_baseline.descent = std::max<LayoutUnit>(0, m_baseline.descent);
    350         m_baseline.ascent = std::max(runHeight, m_baseline.ascent);
    351         m_lineLogicalHeight = std::max(m_lineLogicalHeight, m_baseline.height());
     345            newBaselineCandidate = formattingState.lineBoxes().last().baseline();
     346        }
     347        m_baseline.ascent = std::max(newBaselineCandidate.ascent, m_baseline.ascent);
     348        m_baseline.descent = std::max(newBaselineCandidate.descent, m_baseline.descent);
     349        m_lineLogicalHeight = std::max(std::max(m_lineLogicalHeight, runHeight), m_baseline.height());
     350        // Baseline ascent/descent never shrink -> max.
     351        m_baselineTop = std::max(m_baselineTop, m_lineLogicalHeight - m_baseline.height());
    352352        break;
     353    }
    353354    case VerticalAlign::Top:
    354355        // Top align content never changes the baseline offset, it only pushes the bottom of the line further down.
     
    356357        break;
    357358    case VerticalAlign::Bottom:
    358         if (m_lineLogicalHeight < runHeight) {
    359             m_baselineTop += runHeight - m_lineLogicalHeight;
     359        // Bottom aligned, tall content pushes the baseline further down from the line top.
     360        if (runHeight > m_lineLogicalHeight) {
     361            m_baselineTop += (runHeight - m_lineLogicalHeight);
    360362            m_lineLogicalHeight = runHeight;
    361363        }
Note: See TracChangeset for help on using the changeset viewer.