Changeset 219291 in webkit


Ignore:
Timestamp:
Jul 10, 2017 9:03:03 AM (7 years ago)
Author:
Alan Bujtas
Message:

Block of text is missing in iBooks sample books.
https://bugs.webkit.org/show_bug.cgi?id=174295
<rdar://problem/32955620>

Reviewed by Antti Koivisto.

Source/WebCore:

In the simple line layout context, translating y coordinate to a line index is
normally just a (y / line height) operation. However in case of strut offsets (pagination)
we need to take these extra paddings into account while resolving the line index.
This patch fixes the boundary checking for a given line by using the font size only
when the font is taller than the line.

  • rendering/SimpleLineLayoutResolver.cpp:

(WebCore::SimpleLineLayout::RunResolver::adjustLineIndexForStruts):

LayoutTests:

  • fast/multicol/simple-line-layout-line-index-after-strut-2-expected.html: Added.
  • fast/multicol/simple-line-layout-line-index-after-strut-2.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r219284 r219291  
     12017-07-10  Zalan Bujtas  <zalan@apple.com>
     2
     3        Block of text is missing in iBooks sample books.
     4        https://bugs.webkit.org/show_bug.cgi?id=174295
     5        <rdar://problem/32955620>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        * fast/multicol/simple-line-layout-line-index-after-strut-2-expected.html: Added.
     10        * fast/multicol/simple-line-layout-line-index-after-strut-2.html: Added.
     11
    1122017-07-08  John Wilander  <wilander@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r219290 r219291  
     12017-07-10  Zalan Bujtas  <zalan@apple.com>
     2
     3        Block of text is missing in iBooks sample books.
     4        https://bugs.webkit.org/show_bug.cgi?id=174295
     5        <rdar://problem/32955620>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        In the simple line layout context, translating y coordinate to a line index is
     10        normally just a (y / line height) operation. However in case of strut offsets (pagination)
     11        we need to take these extra paddings into account while resolving the line index.
     12        This patch fixes the boundary checking for a given line by using the font size only
     13        when the font is taller than the line.
     14
     15        * rendering/SimpleLineLayoutResolver.cpp:
     16        (WebCore::SimpleLineLayout::RunResolver::adjustLineIndexForStruts):
     17
    1182017-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp

    r215054 r219291  
    142142    unsigned strutIndex = 0;
    143143    std::optional<unsigned> lastIndexCandidate;
    144     float topPosition = strut.lineBreak * m_lineHeight + (m_baseline - m_ascent);
     144    auto top = strut.lineBreak * m_lineHeight;
     145    auto lineHeightWithOverflow = m_lineHeight;
     146    // If font is larger than the line height (glyphs overflow), use the font size when checking line boundaries.
     147    if (m_ascent + m_descent > m_lineHeight) {
     148        lineHeightWithOverflow = m_ascent + m_descent;
     149        top += m_baseline - m_ascent;
     150    }
     151    auto bottom = top + lineHeightWithOverflow;
    145152    for (auto lineIndex = strut.lineBreak; lineIndex < m_layout.lineCount(); ++lineIndex) {
    146153        float strutOffset = 0;
    147154        if (strutIndex < struts.size() && struts.at(strutIndex).lineBreak == lineIndex)
    148155            strutOffset = struts.at(strutIndex++).offset;
    149         if (y >= topPosition && y < (topPosition + m_ascent + m_descent + strutOffset)) {
     156        bottom = top + strutOffset + lineHeightWithOverflow;
     157        if (y >= top && y < bottom) {
    150158            if (type == IndexType::First)
    151159                return lineIndex;
     
    153161        } else if (lastIndexCandidate)
    154162            return *lastIndexCandidate;
    155         topPosition += m_lineHeight + strutOffset;
    156     }
    157     return m_layout.lineCount() - 1;
     163        top += m_lineHeight + strutOffset;
     164    }
     165    if (lastIndexCandidate || y >= bottom)
     166        return m_layout.lineCount() - 1;
     167    // We missed the line.
     168    ASSERT_NOT_REACHED();
     169    return lineIndexCandidate;
    158170}
    159171
Note: See TracChangeset for help on using the changeset viewer.