Changeset 159105 in webkit


Ignore:
Timestamp:
Nov 12, 2013 6:44:37 AM (10 years ago)
Author:
Antti Koivisto
Message:

Text on simple lines sometimes paints one pixel off
https://bugs.webkit.org/show_bug.cgi?id=124200

Reviewed by Andreas Kling.

Source/WebCore:

Test: fast/text/line-runs-simple-lines.html

  • rendering/SimpleLineLayout.cpp:

(WebCore::SimpleLineLayout::adjustRunOffsets):

Don't round on run construction time.

(WebCore::SimpleLineLayout::createTextRuns):

  • rendering/SimpleLineLayoutResolver.h:

(WebCore::SimpleLineLayout::RunResolver::Run::rect):

Instead round when generating rects.

(WebCore::SimpleLineLayout::RunResolver::Run::baseline):

Provide the baseline (used by painting) as unrounded FloatPoint.

LayoutTests:

  • fast/text/line-runs-rounding-simple-lines-expected.html: Added.
  • fast/text/line-runs-rounding-simple-lines.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r159100 r159105  
     12013-11-12  Antti Koivisto  <antti@apple.com>
     2
     3        Text on simple lines sometimes paints one pixel off
     4        https://bugs.webkit.org/show_bug.cgi?id=124200
     5
     6        Reviewed by Andreas Kling.
     7
     8        * fast/text/line-runs-rounding-simple-lines-expected.html: Added.
     9        * fast/text/line-runs-rounding-simple-lines.html: Added.
     10
    1112013-11-12  Zan Dobersek  <zdobersek@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r159104 r159105  
     12013-11-12  Antti Koivisto  <antti@apple.com>
     2
     3        Text on simple lines sometimes paints one pixel off
     4        https://bugs.webkit.org/show_bug.cgi?id=124200
     5
     6        Reviewed by Andreas Kling.
     7
     8        Test: fast/text/line-runs-simple-lines.html
     9
     10        * rendering/SimpleLineLayout.cpp:
     11        (WebCore::SimpleLineLayout::adjustRunOffsets):
     12       
     13            Don't round on run construction time.
     14
     15        (WebCore::SimpleLineLayout::createTextRuns):
     16        * rendering/SimpleLineLayoutResolver.h:
     17        (WebCore::SimpleLineLayout::RunResolver::Run::rect):
     18       
     19            Instead round when generating rects.
     20
     21        (WebCore::SimpleLineLayout::RunResolver::Run::baseline):
     22       
     23            Provide the baseline (used by painting) as unrounded FloatPoint.
     24
    1252013-11-11  Andreas Kling  <akling@apple.com>
    226
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r159032 r159105  
    261261}
    262262
    263 static void adjustRunOffsets(Vector<Run, 4>& lineRuns, ETextAlign textAlign, float lineWidth, float availableWidth)
    264 {
    265     float lineLeft = computeLineLeft(textAlign, availableWidth - lineWidth);
     263static void adjustRunOffsets(Vector<Run, 4>& lineRuns, float adjustment)
     264{
     265    if (!adjustment)
     266        return;
    266267    for (unsigned i = 0; i < lineRuns.size(); ++i) {
    267         lineRuns[i].left = floor(lineLeft + lineRuns[i].left);
    268         lineRuns[i].right = ceil(lineLeft + lineRuns[i].right);
     268        lineRuns[i].left += adjustment;
     269        lineRuns[i].right += adjustment;
    269270    }
    270271}
     
    382383        lineRuns.last().isEndOfLine = true;
    383384
    384         adjustRunOffsets(lineRuns, textAlign, lineWidth.committedWidth(), lineWidth.availableWidth());
     385        float lineLeft = computeLineLeft(textAlign, lineWidth.availableWidth() - lineWidth.committedWidth());
     386        adjustRunOffsets(lineRuns, lineLeft);
    385387
    386388        for (unsigned i = 0; i < lineRuns.size(); ++i)
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h

    r159032 r159105  
    4646
    4747        LayoutRect rect() const;
    48         LayoutPoint baseline() const;
     48        FloatPoint baseline() const;
    4949        String text() const;
    5050
     
    131131    auto& run = m_iterator.simpleRun();
    132132
    133     LayoutPoint linePosition(run.left, resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
    134     LayoutSize lineSize(run.right - run.left, resolver.m_ascent + resolver.m_descent);
     133    LayoutPoint linePosition(floor(run.left), resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
     134    LayoutSize lineSize(ceil(run.right) - floor(run.left), resolver.m_ascent + resolver.m_descent);
    135135    return LayoutRect(linePosition + resolver.m_contentOffset, lineSize);
    136136}
    137137
    138 inline LayoutPoint RunResolver::Run::baseline() const
     138inline FloatPoint RunResolver::Run::baseline() const
    139139{
    140140    auto& resolver = m_iterator.resolver();
     
    142142
    143143    float baselineY = resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline;
    144     return LayoutPoint(run.left, baselineY) + resolver.m_contentOffset;
     144    return FloatPoint(run.left, baselineY) + resolver.m_contentOffset;
    145145}
    146146
Note: See TracChangeset for help on using the changeset viewer.