Changeset 85411 in webkit


Ignore:
Timestamp:
May 1, 2011 2:19:17 AM (13 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/9155067> REGRESSION (float-based line boxes): Gaps and overlaps in selection highlight
https://bugs.webkit.org/show_bug.cgi?id=56658

Reviewed by Anders Carlsson.

Source/WebCore:

Test: fast/text/selection-rect-rounding.html

  • platform/graphics/FontFastPath.cpp:

(WebCore::Font::selectionRectForSimpleText): Account for non-integral anchor point coordinates.

  • platform/graphics/mac/FontComplexTextMac.cpp:

(WebCore::Font::selectionRectForComplexText): Ditto.

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::selectionRect): Floor the horizontal sides of the clip rect.
(WebCore::InlineTextBox::paintSelection): Pass the logical left location to Font::selectionRectForText(),
since it affects rounding.

LayoutTests:

  • fast/text/selection-rect-rounding.html: Added.
  • platform/mac/fast/text/selection-rect-rounding-expected.png: Added.
  • platform/mac/fast/text/selection-rect-rounding-expected.txt: Added.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85406 r85411  
     12011-05-01  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        <rdar://problem/9155067> REGRESSION (float-based line boxes): Gaps and overlaps in selection highlight
     6        https://bugs.webkit.org/show_bug.cgi?id=56658
     7
     8        * fast/text/selection-rect-rounding.html: Added.
     9        * platform/mac/fast/text/selection-rect-rounding-expected.png: Added.
     10        * platform/mac/fast/text/selection-rect-rounding-expected.txt: Added.
     11
    1122011-04-30  Justin Schuh  <jschuh@chromium.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r85406 r85411  
     12011-05-01  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        <rdar://problem/9155067> REGRESSION (float-based line boxes): Gaps and overlaps in selection highlight
     6        https://bugs.webkit.org/show_bug.cgi?id=56658
     7
     8        Test: fast/text/selection-rect-rounding.html
     9
     10        * platform/graphics/FontFastPath.cpp:
     11        (WebCore::Font::selectionRectForSimpleText): Account for non-integral anchor point coordinates.
     12        * platform/graphics/mac/FontComplexTextMac.cpp:
     13        (WebCore::Font::selectionRectForComplexText): Ditto.
     14        * rendering/InlineTextBox.cpp:
     15        (WebCore::InlineTextBox::selectionRect): Floor the horizontal sides of the clip rect.
     16        (WebCore::InlineTextBox::paintSelection): Pass the logical left location to Font::selectionRectForText(),
     17        since it affects rounding.
     18
    1192011-04-30  Justin Schuh  <jschuh@chromium.org>
    220
  • trunk/Source/WebCore/platform/graphics/FontFastPath.cpp

    r82056 r85411  
    474474        it.advance(run.length());
    475475        float totalWidth = it.m_runWidthSoFar;
    476         return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
    477     }
    478 
    479     return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
     476        return FloatRect(floorf(point.x() + totalWidth - afterWidth), point.y(), roundf(point.x() + totalWidth - beforeWidth) - floorf(point.x() + totalWidth - afterWidth), h);
     477    }
     478
     479    return FloatRect(floorf(point.x() + beforeWidth), point.y(), roundf(point.x() + afterWidth) - floorf(point.x() + beforeWidth), h);
    480480}
    481481
  • trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp

    r81684 r85411  
    5151    if (run.rtl()) {
    5252        float totalWidth = controller.totalWidth();
    53         return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
     53        return FloatRect(floorf(point.x() + totalWidth - afterWidth), point.y(), roundf(point.x() + totalWidth - beforeWidth) - floorf(point.x() + totalWidth - afterWidth), h);
    5454    }
    5555
    56     return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
     56    return FloatRect(floorf(point.x() + beforeWidth), point.y(), roundf(point.x() + afterWidth) - floorf(point.x() + beforeWidth), h);
    5757}
    5858
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r85143 r85411  
    195195
    196196    IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(characters, len, textObj->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride),
    197                                                         IntPoint(), selHeight, sPos, ePos));
    198                                                        
     197                                                        FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
     198
    199199    int logicalWidth = r.width();
    200     if (r.x() > m_logicalWidth)
     200    if (r.x() > logicalRight())
    201201        logicalWidth  = 0;
    202     else if (r.maxX() > m_logicalWidth)
    203         logicalWidth = m_logicalWidth - r.x();
    204    
    205     IntPoint topPoint = isHorizontal() ? IntPoint(tx + m_x + r.x(), ty + selTop) : IntPoint(tx + selTop, ty + m_y + r.x());
     202    else if (r.maxX() > logicalRight())
     203        logicalWidth = logicalRight() - r.x();
     204
     205    IntPoint topPoint = isHorizontal() ? IntPoint(r.x(), ty + selTop) : IntPoint(tx + selTop, r.x());
    206206    int width = isHorizontal() ? logicalWidth : selHeight;
    207207    int height = isHorizontal() ? selHeight : logicalWidth;
    208    
     208
    209209    return IntRect(topPoint, IntSize(width, height));
    210210}
     
    785785void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font)
    786786{
     787    if (context->paintingDisabled())
     788        return;
     789
    787790    // See if we have a selection to paint at all.
    788791    int sPos, ePos;
     
    818821    int selHeight = selectionHeight();
    819822    FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
    820     context->clip(FloatRect(localOrigin, FloatSize(m_logicalWidth, selHeight)));
     823
     824    FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight));
     825    float maxX = floorf(clipRect.maxX());
     826    clipRect.setX(floorf(clipRect.x()));
     827    clipRect.setWidth(maxX - clipRect.x());
     828    context->clip(clipRect);
     829
    821830    context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(),
    822831                                  direction(), m_dirOverride || style->visuallyOrdered()),
Note: See TracChangeset for help on using the changeset viewer.