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

Changeset 246481 in webkit


Ignore:
Timestamp:
Jun 16, 2019, 1:04:31 PM (7 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Ignore descent when in limited/full quirks mode
https://bugs.webkit.org/show_bug.cgi?id=198893
<rdar://problem/51780634>

Reviewed by Antti Koivisto.

In limited/full quirks mode, line's descent should be ignored when computing the final line height when

  1. the line has baseline aligned content only and
  2. these baseline aligned boxes don't have descent.
  • layout/inlineformatting/InlineLine.cpp:

(WebCore::Layout::Line::isVisuallyEmpty const):
(WebCore::Layout::Line::close):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246480 r246481  
     12019-06-16  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Ignore descent when in limited/full quirks mode
     4        https://bugs.webkit.org/show_bug.cgi?id=198893
     5        <rdar://problem/51780634>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        In limited/full quirks mode, line's descent should be ignored when computing the final line height when
     10        1. the line has baseline aligned content only and
     11        2. these baseline aligned boxes don't have descent.
     12
     13        * layout/inlineformatting/InlineLine.cpp:
     14        (WebCore::Layout::Line::isVisuallyEmpty const):
     15        (WebCore::Layout::Line::close):
     16
    1172019-06-16  Zalan Bujtas  <zalan@apple.com>
    218
  • trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp

    r246480 r246481  
    101101        }
    102102
     103        auto hasDescent = false;
     104        auto hasNonBaselineAlignedContent = false;
    103105        for (auto& run : m_content->runs()) {
    104106            LayoutUnit logicalTop;
    105107            auto& inlineItem = run->inlineItem;
    106108            auto& layoutBox = inlineItem.layoutBox();
     109            auto verticalAlign = inlineItem.style().verticalAlign();
    107110            auto ascent = inlineItem.style().fontMetrics().ascent();
    108111
    109             switch (inlineItem.style().verticalAlign()) {
     112            switch (verticalAlign) {
    110113            case VerticalAlign::Baseline:
    111                 if (inlineItem.isLineBreak() || inlineItem.isText())
     114                if (inlineItem.isLineBreak() || inlineItem.isText()) {
    112115                    logicalTop = baselineOffset() - ascent;
    113                 else if (inlineItem.isContainerStart()) {
     116                    hasDescent = hasDescent || !run->isCollapsed;
     117                } else if (inlineItem.isContainerStart()) {
    114118                    auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox);
    115119                    logicalTop = baselineOffset() - ascent - displayBox.borderTop() - displayBox.paddingTop().valueOr(0);
     120                    hasDescent = hasDescent || (displayBox.horizontalBorder() || (displayBox.horizontalPadding() && displayBox.horizontalPadding().value()));
    116121                } else if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
    117122                    auto& formattingState = downcast<InlineFormattingState>(m_layoutState.establishedFormattingState(layoutBox));
     
    120125                    auto inlineBlockBaseline = formattingState.lineBoxes().last().baseline();
    121126                    logicalTop = baselineOffset() - inlineBlockBaseline.ascent;
     127                    hasDescent = hasDescent || inlineBlockBaseline.descent;
    122128                } else
    123129                    logicalTop = baselineOffset() - run->logicalRect.height();
     
    133139                break;
    134140            }
     141            hasNonBaselineAlignedContent = hasNonBaselineAlignedContent || verticalAlign != VerticalAlign::Baseline;
    135142            run->logicalRect.setTop(logicalTop);
     143        }
     144        // Remove descent when all content is baseline aligned but none of them have descent.
     145        if (!m_layoutState.inNoQuirksMode() && !hasNonBaselineAlignedContent && !hasDescent) {
     146            m_contentLogicalHeight -= m_baseline.descent;
     147            m_baseline.descent = { };
    136148        }
    137149    }
Note: See TracChangeset for help on using the changeset viewer.