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

Changeset 176470 in webkit


Ignore:
Timestamp:
Nov 21, 2014, 1:08:55 PM (12 years ago)
Author:
Alan Bujtas
Message:

REGRESSION(r175259) Simple line layout text measuring behavior changed.
https://bugs.webkit.org/show_bug.cgi?id=138947
rdar://problem/19050653

Reviewed by Antti Koivisto.

In certain cases, when block flow needs to compute the preferred width of a particular text
renderer, we use the non-simple line layout text measuring.
However, the same text renderer might end up at simple line layout later.
Complex line layout measures text including the trailing space and it subtracts
(the constant value of) space width afterwards, while simple line layout measures
runs without the extra space.
In such cases, this may result different word widths and produce unexpected line breaking. (preferred width != final width)
In long term, any text renderer qualified for simple line layout should go through the simple
text measuring code path. (https://bugs.webkit.org/show_bug.cgi?id=138973)
For now, just copy complex line layout behaviour. This also matches the previous simple line layout line breaking implementation.

Source/WebCore:

Test: fast/text/simple-line-text-measuring-with-trailing-space.html

  • rendering/SimpleLineLayoutFlowContents.cpp:

(WebCore::SimpleLineLayout::FlowContents::textWidth):

LayoutTests:

  • fast/text/simple-line-text-measuring-with-trailing-space-expected.html: Added.
  • fast/text/simple-line-text-measuring-with-trailing-space.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r176458 r176470  
     12014-11-21  Zalan Bujtas  <zalan@apple.com>
     2
     3        REGRESSION(r175259) Simple line layout text measuring behavior changed.
     4        https://bugs.webkit.org/show_bug.cgi?id=138947
     5        rdar://problem/19050653
     6
     7        Reviewed by Antti Koivisto.
     8
     9        In certain cases, when block flow needs to compute the preferred width of a particular text
     10        renderer, we use the non-simple line layout text measuring.
     11        However, the same text renderer might end up at simple line layout later.
     12        Complex line layout measures text including the trailing space and it subtracts
     13        (the constant value of) space width afterwards, while simple line layout measures
     14        runs without the extra space.
     15        In such cases, this may result different word widths and produce unexpected line breaking. (preferred width != final width)
     16        In long term, any text renderer qualified for simple line layout should go through the simple
     17        text measuring code path. (https://bugs.webkit.org/show_bug.cgi?id=138973)
     18        For now, just copy complex line layout behaviour. This also matches the previous simple line layout line breaking implementation.
     19
     20        * fast/text/simple-line-text-measuring-with-trailing-space-expected.html: Added.
     21        * fast/text/simple-line-text-measuring-with-trailing-space.html: Added.
     22
    1232014-11-21  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/Source/WebCore/ChangeLog

    r176466 r176470  
     12014-11-21  Zalan Bujtas  <zalan@apple.com>
     2
     3        REGRESSION(r175259) Simple line layout text measuring behavior changed.
     4        https://bugs.webkit.org/show_bug.cgi?id=138947
     5        rdar://problem/19050653
     6
     7        Reviewed by Antti Koivisto.
     8
     9        In certain cases, when block flow needs to compute the preferred width of a particular text
     10        renderer, we use the non-simple line layout text measuring.
     11        However, the same text renderer might end up at simple line layout later.
     12        Complex line layout measures text including the trailing space and it subtracts
     13        (the constant value of) space width afterwards, while simple line layout measures
     14        runs without the extra space.
     15        In such cases, this may result different word widths and produce unexpected line breaking. (preferred width != final width)
     16        In long term, any text renderer qualified for simple line layout should go through the simple
     17        text measuring code path. (https://bugs.webkit.org/show_bug.cgi?id=138973)
     18        For now, just copy complex line layout behaviour. This also matches the previous simple line layout line breaking implementation.
     19
     20        Test: fast/text/simple-line-text-measuring-with-trailing-space.html
     21
     22        * rendering/SimpleLineLayoutFlowContents.cpp:
     23        (WebCore::SimpleLineLayout::FlowContents::textWidth):
     24
    1252014-11-21  Anders Carlsson  <andersca@apple.com>
    226
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp

    r176401 r176470  
    181181    ASSERT(from < to);
    182182    String string = renderer.text();
     183    bool measureWithEndSpace = m_style.collapseWhitespace && to < string.length() && string[to] == ' ';
     184    if (measureWithEndSpace)
     185        ++to;
    183186    TextRun run(string.characters8() + from, to - from);
    184187    run.setXPos(xPosition);
    185188    run.setTabSize(!!m_style.tabWidth, m_style.tabWidth);
    186     return m_style.font.width(run);
     189    float width = m_style.font.width(run);
     190    if (measureWithEndSpace)
     191        width -= m_style.spaceWidth;
     192    return width;
    187193}
    188194
Note: See TracChangeset for help on using the changeset viewer.