Changeset 38898 in webkit


Ignore:
Timestamp:
Dec 1, 2008 11:24:15 PM (15 years ago)
Author:
Beth Dakin
Message:

WebCore:

2008-12-01 Beth Dakin <Beth Dakin>

Reviewed by Dan Bernstein.

Fix for https://bugs.webkit.org/show_bug.cgi?id=13736 REGRESSION
(r19811): Using the down arrow in a textarea gets "stuck" at the
end of a wrapped line
And corresponding: <rdar://problem/5347931>

The basic problem here is that Position::getInlineBoxAndOffset()
failed to look beyond a single renderer. This patch looks for a
better match beyond the first renderer when the affinity is
downstream and we failed to find a "perfect" match.

  • dom/Position.cpp: (WebCore::isNonTextLeafChild): (WebCore::searchAheadForBetterMatch): (WebCore::Position::getInlineBoxAndOffset):

This is a fix I made based on code inspection. It looks like the
old code here and skipped over the parent as a possible match.

  • rendering/RenderObject.cpp: (WebCore::RenderObject::nextInPreOrderAfterChildren):

LayoutTests:

2008-12-01 Beth Dakin <Beth Dakin>

Reviewed by Dan Bernstein.

Tests for https://bugs.webkit.org/show_bug.cgi?id=13736 REGRESSION
(r19811): Using the down arrow in a textarea gets "stuck" at the
end of a wrapped line
And corresponding: <rdar://problem/5347931>

  • editing/selection/wrapped-line-caret-1.html: Added.
  • editing/selection/wrapped-line-caret-2.html: Added.
  • platform/mac/editing/selection/wrapped-line-caret-1- expected.checksum: Added.
  • platform/mac/editing/selection/wrapped-line-caret-1-expected.png: Added.
  • platform/mac/editing/selection/wrapped-line-caret-1-expected.txt: Added.
  • platform/mac/editing/selection/wrapped-line-caret-2- expected.checksum: Added.
  • platform/mac/editing/selection/wrapped-line-caret-2-expected.png: Added.
  • platform/mac/editing/selection/wrapped-line-caret-2-expected.txt: Added.
Location:
trunk
Files:
8 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r38892 r38898  
     12008-12-01  Beth Dakin  <bdakin@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Tests for https://bugs.webkit.org/show_bug.cgi?id=13736 REGRESSION
     6        (r19811): Using the down arrow in a textarea gets "stuck" at the
     7        end of a wrapped line
     8        And corresponding: <rdar://problem/5347931>
     9
     10        * editing/selection/wrapped-line-caret-1.html: Added.
     11        * editing/selection/wrapped-line-caret-2.html: Added.
     12        * platform/mac/editing/selection/wrapped-line-caret-1-
     13        expected.checksum: Added.
     14        * platform/mac/editing/selection/wrapped-line-caret-1-expected.png:
     15        Added.
     16        * platform/mac/editing/selection/wrapped-line-caret-1-expected.txt:
     17        Added.
     18        * platform/mac/editing/selection/wrapped-line-caret-2-
     19        expected.checksum: Added.
     20        * platform/mac/editing/selection/wrapped-line-caret-2-expected.png:
     21        Added.
     22        * platform/mac/editing/selection/wrapped-line-caret-2-expected.txt:
     23        Added.
     24
    1252008-12-01  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
    226
  • trunk/WebCore/ChangeLog

    r38897 r38898  
     12008-12-01  Beth Dakin  <bdakin@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=13736 REGRESSION
     6        (r19811): Using the down arrow in a textarea gets "stuck" at the
     7        end of a wrapped line
     8        And corresponding: <rdar://problem/5347931>
     9
     10        The basic problem here is that Position::getInlineBoxAndOffset()
     11        failed to look beyond a single renderer. This patch looks for a
     12        better match beyond the first renderer when the affinity is
     13        downstream and we failed to find a "perfect" match.
     14        * dom/Position.cpp:
     15        (WebCore::isNonTextLeafChild):
     16        (WebCore::searchAheadForBetterMatch):
     17        (WebCore::Position::getInlineBoxAndOffset):
     18
     19        This is a fix I made based on code inspection. It looks like the
     20        old code here and skipped over the parent as a possible match.
     21        * rendering/RenderObject.cpp:
     22        (WebCore::RenderObject::nextInPreOrderAfterChildren):
     23
    1242008-12-01  Brent Fulgham  <bfulgham@gmail.com>
    225
  • trunk/WebCore/dom/Position.cpp

    r36698 r38898  
    3535#include "Logging.h"
    3636#include "PositionIterator.h"
     37#include "RenderBlock.h"
    3738#include "Text.h"
    3839#include "TextIterator.h"
     
    772773}
    773774
     775static bool isNonTextLeafChild(RenderObject* object)
     776{
     777    if (object->firstChild())
     778        return false;
     779    if (object->isText())
     780        return false;
     781    return true;
     782}
     783
     784static InlineTextBox* searchAheadForBetterMatch(RenderObject* renderer)
     785{
     786    InlineTextBox* match = 0;
     787    int minOffset = INT_MAX;
     788    RenderBlock* container = renderer->containingBlock();
     789    RenderObject* next = renderer;
     790    while ((next = next->nextInPreOrder(container))) {
     791        if (next->isRenderBlock())
     792            break;
     793        if (next->isBR())
     794            break;
     795        if (isNonTextLeafChild(next))
     796            break;
     797        if (next->isText()) {
     798            for (InlineTextBox* box = static_cast<RenderText*>(next)->firstTextBox(); box; box = box->nextTextBox()) {
     799                int caretMinOffset = box->caretMinOffset();
     800                if (caretMinOffset < minOffset) {
     801                    match = box;
     802                    minOffset = caretMinOffset;
     803                }
     804            }
     805        }
     806    }
     807    return match;
     808}
     809
    774810void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDirection, InlineBox*& inlineBox, int& caretOffset) const
    775811{
     
    802838
    803839            candidate = box;
     840        }
     841        if (candidate && !box && affinity == DOWNSTREAM) {
     842            box = searchAheadForBetterMatch(textRenderer);
     843            if (box)
     844                caretOffset = box->caretMinOffset();
    804845        }
    805846        inlineBox = box ? box : candidate;
  • trunk/WebCore/rendering/RenderObject.cpp

    r38651 r38898  
    319319        o = parent();
    320320        while (o && !o->nextSibling()) {
    321             o = o->parent();
    322321            if (o == stayWithin)
    323322                return 0;
     323            o = o->parent();
    324324        }
    325325        if (o)
Note: See TracChangeset for help on using the changeset viewer.