Changeset 29483 in webkit


Ignore:
Timestamp:
Jan 14, 2008 5:31:19 PM (16 years ago)
Author:
eric@webkit.org
Message:

Reviewed by hyatt & eseidel.

This patch fixes an issue with addLineBoxRects not correctly calculating the
rects due to an off-by-one error in using box->end(). We were assuming that
end() gives the index past the last character, when in fact it gives the
index _of_ the last character.

Eric Seidel and I could not find a way to test this via DRT. This method is
only used by WebKit or Safari for displaying selection rects AFAICT.

  • rendering/RenderText.cpp: (WebCore::RenderText::addLineBoxRects):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r29482 r29483  
     12008-01-14  Finnur Thorarinsson  <finnur.webkit@gmail.com>
     2
     3        Reviewed by hyatt & eseidel.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=16844
     6        RenderText::addLineBoxRects erroneously includes last char for boundingBox
     7
     8        This patch fixes an issue with addLineBoxRects not correctly calculating the
     9        rects due to an off-by-one error in using box->end(). We were assuming that
     10        end() gives the index past the last character, when in fact it gives the
     11        index _of_ the last character.
     12
     13        Eric Seidel and I could not find a way to test this via DRT. This method is
     14        only used by WebKit or Safari for displaying selection rects AFAICT.
     15
     16        * rendering/RenderText.cpp:
     17        (WebCore::RenderText::addLineBoxRects):
     18
    1192008-01-14  Darin Adler  <darin@apple.com>
    220
  • trunk/WebCore/rendering/RenderText.cpp

    r29098 r29483  
    212212
    213213    for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
    214         if (start <= box->start() && box->end() <= end) {
     214        // Note: box->end() returns the index of the last character, not the index past it
     215        if (start <= box->start() && box->end() < end) {
    215216            IntRect r = IntRect(x + box->xPos(), y + box->yPos(), box->width(), box->height());
    216217            if (useSelectionHeight) {
     
    221222            rects.append(r);
    222223        } else {
    223             unsigned realEnd = min(box->end() + 1, end); // box->end() points at the last char, not after it
     224            unsigned realEnd = min(box->end() + 1, end);
    224225            IntRect r = box->selectionRect(x, y, start, realEnd);
    225226            if (!r.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.