Changeset 146630 in webkit


Ignore:
Timestamp:
Mar 22, 2013 10:51:11 AM (11 years ago)
Author:
allan.jensen@digia.com
Message:

[Qt] New fast/text/word-space-with-kerning-3.html fails on Qt.
https://bugs.webkit.org/show_bug.cgi?id=112668

Reviewed by Jocelyn Turcotte.

Source/WebCore:

Qt adds word-spacing to leading spaces, but WebCore only expects
us to add for trailing spaces. We only corrected for this in width
calculation but do need to also do it for drawing.

Instead of subtracting the extra word-spacing we now configure the
FormatRange not to apply to leading spaces. This means this behavior
will be applied everywhere reliably.

  • platform/graphics/Font.h:

(Font):

  • platform/graphics/qt/FontQt.cpp:

(WebCore::Font::drawComplexText):
(WebCore::Font::floatWidthForComplexText):
(WebCore::Font::offsetForPositionForComplexText):
(WebCore::Font::selectionRectForComplexText):
(WebCore::Font::initFormatForTextLayout):

LayoutTests:

  • platform/qt/TestExpectations:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r146626 r146630  
     12013-03-22  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt] New fast/text/word-space-with-kerning-3.html fails on Qt.
     4        https://bugs.webkit.org/show_bug.cgi?id=112668
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        * platform/qt/TestExpectations:
     9
    1102013-03-22  Nate Chapin  <japhet@chromium.org>
    211
  • trunk/LayoutTests/platform/qt/TestExpectations

    r146579 r146630  
    18241824fast/text/international/spaces-combined-in-vertical-text.html
    18251825
    1826 webkit.org/b/112668 fast/text/word-space-with-kerning-3.html [ Skip ]
    1827 
    18281826fast/writing-mode/border-styles-vertical-lr.html
    18291827fast/writing-mode/border-styles-vertical-rl.html
  • trunk/Source/WebCore/ChangeLog

    r146629 r146630  
     12013-03-22  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt] New fast/text/word-space-with-kerning-3.html fails on Qt.
     4        https://bugs.webkit.org/show_bug.cgi?id=112668
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        Qt adds word-spacing to leading spaces, but WebCore only expects
     9        us to add for trailing spaces. We only corrected for this in width
     10        calculation but do need to also do it for drawing.
     11
     12        Instead of subtracting the extra word-spacing we now configure the
     13        FormatRange not to apply to leading spaces. This means this behavior
     14        will be applied everywhere reliably.
     15
     16        * platform/graphics/Font.h:
     17        (Font):
     18        * platform/graphics/qt/FontQt.cpp:
     19        (WebCore::Font::drawComplexText):
     20        (WebCore::Font::floatWidthForComplexText):
     21        (WebCore::Font::offsetForPositionForComplexText):
     22        (WebCore::Font::selectionRectForComplexText):
     23        (WebCore::Font::initFormatForTextLayout):
     24
    1252013-03-22  Joshua Bell  <jsbell@chromium.org>
    226
  • trunk/Source/WebCore/platform/graphics/Font.h

    r135888 r146630  
    298298
    299299#if PLATFORM(QT)
    300     void initFormatForTextLayout(QTextLayout*) const;
     300    void initFormatForTextLayout(QTextLayout*, const TextRun&) const;
    301301#endif
    302302
  • trunk/Source/WebCore/platform/graphics/qt/FontQt.cpp

    r146334 r146630  
    183183    QTextLayout layout(string);
    184184    layout.setRawFont(rawFont());
    185     initFormatForTextLayout(&layout);
     185    initFormatForTextLayout(&layout, run);
    186186    QTextLine line = setupLayout(&layout, run);
    187187    const QPointF adjustedPoint(point.x(), point.y() - line.ascent());
     
    207207    QTextLayout layout(string);
    208208    layout.setRawFont(rawFont());
    209     initFormatForTextLayout(&layout);
     209    initFormatForTextLayout(&layout, run);
    210210    QTextLine line = setupLayout(&layout, run);
    211211    float x1 = line.cursorToX(0);
    212212    float x2 = line.cursorToX(run.length());
    213213    float width = qAbs(x2 - x1);
    214     // RenderBlockLineLayout expects us to only add word-spacing for trailing spaces, not for leading spaces.
    215     if (treatAsSpace(run[0]))
    216         width -= m_wordSpacing;
    217214
    218215    return width + run.expansion();
     
    226223    QTextLayout layout(string);
    227224    layout.setRawFont(rawFont());
    228     initFormatForTextLayout(&layout);
     225    initFormatForTextLayout(&layout, run);
    229226    QTextLine line = setupLayout(&layout, run);
    230227    return line.xToCursor(position);
     
    238235    QTextLayout layout(string);
    239236    layout.setRawFont(rawFont());
    240     initFormatForTextLayout(&layout);
     237    initFormatForTextLayout(&layout, run);
    241238    QTextLine line = setupLayout(&layout, run);
    242239
     
    249246}
    250247
    251 void Font::initFormatForTextLayout(QTextLayout* layout) const
     248void Font::initFormatForTextLayout(QTextLayout* layout, const TextRun& run) const
    252249{
    253250    QTextLayout::FormatRange range;
    254     range.start = 0;
    255     range.length = layout->text().length();
     251    // WebCore expects word-spacing to be ignored on leading spaces contrary to what Qt does.
     252    // To avoid word-spacing on any leading spaces, we exclude them from FormatRange which
     253    // word-spacing along with other options would be applied to. This is safe since the other
     254    // formatting options does not affect spaces.
     255    unsigned length = layout->text().length();
     256    for (range.start = 0; treatAsSpace(run[range.start]) && range.start < length; ++range.start) { }
     257    range.length = length - range.start;
     258
    256259    if (m_wordSpacing)
    257260        range.format.setFontWordSpacing(m_wordSpacing);
     
    263266        range.format.setFontCapitalization(QFont::SmallCaps);
    264267
    265     if (range.format.propertyCount())
     268    if (range.format.propertyCount() && range.length)
    266269        layout->setAdditionalFormats(QList<QTextLayout::FormatRange>() << range);
    267270}
Note: See TracChangeset for help on using the changeset viewer.