Changeset 266995 in webkit


Ignore:
Timestamp:
Sep 13, 2020 9:19:09 AM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Text run is at incorrect vertical position when parent inline box is stretched
https://bugs.webkit.org/show_bug.cgi?id=216453

Reviewed by Antti Koivisto.

Text runs don't necessarily start at the top of the parent inline box. When the inline box is
stretched by some other content (nested inline box or atomic inline-level box) the run is pushed down.
This patch computes the correct vertical position by using the inline box's baseline (text always sits on the baseline).

  • layout/inlineformatting/InlineLineBox.cpp:

(WebCore::Layout::LineBox::logicalRectForTextRun const):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r266994 r266995  
     12020-09-13  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Text run is at incorrect vertical position when parent inline box is stretched
     4        https://bugs.webkit.org/show_bug.cgi?id=216453
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Text runs don't necessarily start at the top of the parent inline box. When the inline box is
     9        stretched by some other content (nested inline box or atomic inline-level box) the run is pushed down.
     10        This patch computes the correct vertical position by using the inline box's baseline (text always sits on the baseline).
     11
     12        * layout/inlineformatting/InlineLineBox.cpp:
     13        (WebCore::Layout::LineBox::logicalRectForTextRun const):
     14
    1152020-09-13  Zalan Bujtas  <zalan@apple.com>
    216
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp

    r266978 r266995  
    148148    ASSERT(run.isText() || run.isLineBreak());
    149149    auto& parentInlineBox = inlineBoxForLayoutBox(run.layoutBox().parent());
    150     auto inlineBoxRect = parentInlineBox.logicalRect();
    151     return { inlineBoxRect.top(), m_horizontalAlignmentOffset.valueOr(InlineLayoutUnit { }) + run.logicalLeft(), run.logicalWidth(), inlineBoxRect.height() };
     150    auto& fontMetrics = parentInlineBox.fontMetrics();
     151    auto runlogicalTop = parentInlineBox.logicalTop() + parentInlineBox.baseline() - fontMetrics.ascent();
     152    InlineLayoutUnit logicalHeight = fontMetrics.height();
     153    return { runlogicalTop, m_horizontalAlignmentOffset.valueOr(InlineLayoutUnit { }) + run.logicalLeft(), run.logicalWidth(), logicalHeight };
    152154}
    153155
Note: See TracChangeset for help on using the changeset viewer.