Changeset 84710 in webkit


Ignore:
Timestamp:
Apr 22, 2011 5:12:23 PM (13 years ago)
Author:
xji@chromium.org
Message:

2011-04-22 Xiaomei Ji <xji@chromium.org>

Reviewed by Ryosuke Niwa.

move caret by word in visual order returns wrong result when caret itself is at word boundary.
https://bugs.webkit.org/show_bug.cgi?id=58504.

Add test case to test moving left/right by word visually on every character position.
Remove a specific test added before for testing a specific code path since the test case
is covered now.

  • editing/selection/move-by-word-visually-expected.txt:
  • editing/selection/move-by-word-visually.html:

2011-04-22 Xiaomei Ji <xji@chromium.org>

Reviewed by Ryosuke Niwa.

move caret by word in visual order returns wrong result when caret itself is at word boundary.
https://bugs.webkit.org/show_bug.cgi?id=58504.

positionBeforeNextWord should take care that the current position is after current word.
positionAfterPreviousWord should take care that the current positin is before current word.

  • editing/visible_units.cpp: (WebCore::positionBeforeNextWord): (WebCore::positionAfterPreviousWord):
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84709 r84710  
     12011-04-22  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        move caret by word in visual order returns wrong result when caret itself is at word boundary.
     6        https://bugs.webkit.org/show_bug.cgi?id=58504.
     7
     8        Add test case to test moving left/right by word visually on every character position.
     9        Remove a specific test added before for testing a specific code path since the test case
     10        is covered now.
     11
     12        * editing/selection/move-by-word-visually-expected.txt:
     13        * editing/selection/move-by-word-visually.html:
     14
    1152011-04-22  Xiaomei Ji  <xji@chromium.org>
    216
  • trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt

    r84425 r84710  
    8989Move right by one word
    9090"abc def    hij opq"[0, 4, 15]    FAIL expected: [0, 4, 11, 15]
     91"abc def    hij opq"[4, 15]   FAIL expected 11
     92"abc def    hij opq"[5, 15]   FAIL expected 11
     93"abc def    hij opq"[6, 15]   FAIL expected 11
     94"abc def    hij opq"[7, 15]   FAIL expected 11
     95"abc def    hij opq"[8, 15]   FAIL expected 11
    9196Move left by one word
    9297"abc def    hij opq"[18, 15, 4, 0]    FAIL expected: [18, 15, 11, 4, 0]
     98"abc def    hij opq"[15, 4]   FAIL expected 11
     99"abc def    hij opq"[14, 4]   FAIL expected 11
     100"abc def    hij opq"[13, 4]   FAIL expected 11
     101"abc def    hij opq"[12, 4]   FAIL expected 11
    93102Test 19, LTR:
    94103Move right by one word
     
    108117Test 22, RTL:
    109118Move left by one word
    110 "abc def "[0], " rst uvw"[4], "hij opq"[3], "abc def "[7, 3]    FAIL expected: ["abc def "[ 0, ]" rst uvw"[ 4,  0, ]"hij opq"[ 3, ]"abc def "[ 7,  3]
    111 Move right by one word
    112 " rst uvw"[8], "abc def "[3, 7], "hij opq"[3], " rst uvw"[4], "abc def "[0]    FAIL expected: [" rst uvw"[ 8, ]"abc def "[ 3,  7, ]"hij opq"[ 3, ]" rst uvw"[ 0,  4, ]"abc def "[ 0]
     119"abc def "[0], " rst uvw"[4], "hij opq"[3], "abc def "[7, 3]    FAIL expected: ["abc def "[ 0, ]" rst uvw"[ 4, ]"hij opq"[ 7,  3, ]"abc def "[ 7,  3]
     120" rst uvw"[4], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     121" rst uvw"[3], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     122" rst uvw"[2], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     123" rst uvw"[1], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     124Move right by one word
     125" rst uvw"[8], "abc def "[3, 7], "hij opq"[3], " rst uvw"[4], "abc def "[0]    FAIL expected: [" rst uvw"[ 8, ]"abc def "[ 3,  7, ]"hij opq"[ 3,  7, ]" rst uvw"[ 4, ]"abc def "[ 0]
     126"hij opq"[3], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
     127"hij opq"[4], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
     128"hij opq"[5], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
     129"hij opq"[6], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
    113130Test 23, RTL:
    114131Move left by one word
    115 "abc def "[0], " rst uvw"[4], "hij opq"[3], "abc def "[7, 3]    FAIL expected: ["abc def "[ 0, ]" rst uvw"[ 4,  0, ]"hij opq"[ 3, ]"abc def "[ 7,  3]
    116 Move right by one word
    117 " rst uvw"[8], "abc def "[3, 7], "hij opq"[3], " rst uvw"[4], "abc def "[0]    FAIL expected: [" rst uvw"[ 8, ]"abc def "[ 3,  7, ]"hij opq"[ 3, ]" rst uvw"[ 0,  4, ]"abc def "[ 0]
     132"abc def "[0], " rst uvw"[4], "hij opq"[3], "abc def "[7, 3]    FAIL expected: ["abc def "[ 0, ]" rst uvw"[ 4, ]"hij opq"[ 7,  3, ]"abc def "[ 7,  3]
     133" rst uvw"[4], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     134" rst uvw"[3], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     135" rst uvw"[2], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     136" rst uvw"[1], "hij opq"[3]   FAIL expected "hij opq"[ 7]
     137Move right by one word
     138" rst uvw"[8], "abc def "[3, 7], "hij opq"[3], " rst uvw"[4], "abc def "[0]    FAIL expected: [" rst uvw"[ 8, ]"abc def "[ 3,  7, ]"hij opq"[ 3,  7, ]" rst uvw"[ 4, ]"abc def "[ 0]
     139"hij opq"[3], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
     140"hij opq"[4], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
     141"hij opq"[5], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
     142"hij opq"[6], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
    118143Test 24, LTR:
    119144Move right by one word
     
    151176Move left by one word
    152177"FFZ LIG"[7], "ABD DSU "[3, 7], "abc def"[4], "ABD DSU "[8], "FFZ LIG"[3]    FAIL expected: ["FFZ LIG"[ 7, ]"ABD DSU "[ 3,  7, ]"abc def"[ 4, ]"ABD DSU "[ 8, ]"FFZ LIG"[ 3, ]"ABD DSU "[ 0]
     178"FFZ LIG"[3, 3]   FAIL expected "ABD DSU "[ 0]
     179"FFZ LIG"[4, 4]   FAIL expected "ABD DSU "[ 0]
     180"FFZ LIG"[5, 5]   FAIL expected "ABD DSU "[ 0]
     181"FFZ LIG"[6, 6]   FAIL expected "ABD DSU "[ 0]
    153182Test 31, RTL:
    154183Move left by one word
     
    160189"ABD DSU "[0, 3, 8], "abc def"[4], "FFZ LIG"[3]
    161190Move left by one word
    162 "FFZ LIG"[7, 3], "abc def"[4], "ABD DSU "[8, 4, 0]
     191"FFZ LIG"[7, 3], "abc def"[4], "ABD DSU "[8, 4, 0]    FAIL expected: ["FFZ LIG"[ 7,  3, ]"abc def"[ 4, ]"ABD DSU "[ 8,  3,  0]
     192"ABD DSU "[8, 4]   FAIL expected "ABD DSU "[ 3]
    163193Test 33, RTL:
    164194Move left by one word
    165195"ABD opq DSU "[0, 4, 8], "abc AAA def"[8, 4, 3], "FFZ rst LIG"[4, 8]    FAIL expected: ["ABD opq DSU "[ 0,  4,  8,  12, ]"abc AAA def"[ 4,  3, ]"FFZ rst LIG"[ 4,  8]
     196"ABD opq DSU "[8], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
     197"ABD opq DSU "[9], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
     198"ABD opq DSU "[10], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
     199"ABD opq DSU "[11], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
     200"ABD opq DSU "[12], "abc AAA def"[8]   FAIL expected "abc AAA def"[ 4]
     201"abc AAA def"[10, 8]   FAIL expected "abc AAA def"[ 4]
     202"abc AAA def"[9, 8]   FAIL expected "abc AAA def"[ 4]
    166203Move right by one word
    167204"FFZ rst LIG"[11, 8, 4], "abc AAA def"[4, 8], "ABD opq DSU "[8, 4, 0]    FAIL expected: ["FFZ rst LIG"[ 11,  8,  4, ]"abc AAA def"[ 3,  4, ]"ABD opq DSU "[ 12,  8,  4,  0]
     205"FFZ rst LIG"[4], "abc AAA def"[4]   FAIL expected "abc AAA def"[ 3]
     206"abc AAA def"[4, 8]   FAIL expected "ABD opq DSU "[ 12]
     207"abc AAA def"[8], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
     208"abc AAA def"[9], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
     209"abc AAA def"[10], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
    168210Test 34, LTR:
    169211Move right by one word
    170212"ABD opq DSU "[0, 4], "abc AAA def"[8, 4], "ABD opq DSU "[12, 11], "FFZ rst LIG"[4, 8, 11]    FAIL expected: ["ABD opq DSU "[ 0,  4,  8, ]"abc AAA def"[ 8,  7, ]"ABD opq DSU "[ 12,  11, ]"FFZ rst LIG"[ 4,  8,  11]
     213"ABD opq DSU "[4], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 8]
     214"ABD opq DSU "[5], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 8]
     215"ABD opq DSU "[6], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 8]
     216"ABD opq DSU "[7], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 8]
     217"abc AAA def"[8, 4]   FAIL expected "abc AAA def"[ 7]
     218"abc AAA def"[9, 4]   FAIL expected "abc AAA def"[ 7]
     219"abc AAA def"[10, 4]   FAIL expected "abc AAA def"[ 7]
     220"abc AAA def"[11, 4]   FAIL expected "abc AAA def"[ 7]
     221"abc AAA def"[7, 4]   FAIL expected "ABD opq DSU "[ 12]
     222"abc AAA def"[6, 4]   FAIL expected "ABD opq DSU "[ 12]
     223"abc AAA def"[5, 4]   FAIL expected "ABD opq DSU "[ 12]
    171224Move left by one word
    172225"FFZ rst LIG"[11, 8, 4], "ABD opq DSU "[11, 12], "abc AAA def"[7, 8], "ABD opq DSU "[7, 4, 0]    FAIL expected: ["FFZ rst LIG"[ 11,  8,  4, ]"ABD opq DSU "[ 11,  12, ]"abc AAA def"[ 7,  8, ]"ABD opq DSU "[ 8,  4,  0]
     226"abc AAA def"[8], "ABD opq DSU "[7]   FAIL expected "ABD opq DSU "[ 8]
     227"FFZ rst LIG"[1], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
     228"FFZ rst LIG"[2], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
    173229Test 35, RTL:
    174230Move left by one word
    175231"ABD opq DSU "[0, 4, 8], "abc AAA def"[4, 8], "FFZ rst LIG"[4, 8]    FAIL expected: ["ABD opq DSU "[ 0,  4,  8,  12, ]"abc AAA def"[ 4,  8, ]"FFZ rst LIG"[ 4,  8]
     232"ABD opq DSU "[8], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
     233"ABD opq DSU "[9], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
     234"ABD opq DSU "[10], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
     235"ABD opq DSU "[11], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
    176236Move right by one word
    177237"FFZ rst LIG"[11, 8, 4], "abc AAA def"[8, 4], "ABD opq DSU "[11, 8, 4, 0]    FAIL expected: ["FFZ rst LIG"[ 11,  8,  4, ]"abc AAA def"[ 8,  4, ]"ABD opq DSU "[ 12,  8,  4,  0]
     238"abc AAA def"[4], "ABD opq DSU "[11]   FAIL expected "ABD opq DSU "[ 12]
     239"abc AAA def"[3], "ABD opq DSU "[11]   FAIL expected "ABD opq DSU "[ 12]
     240"abc AAA def"[1], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
     241"abc AAA def"[2], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
    178242Test 36, LTR:
    179243Move right by one word
     
    187251"FFZ"[3], "bbb AAA "[7, 4], "aaa "[4, 0]
    188252
    189 ======== Move By Word Specific Test ====
    190 Test 1
    191 Move left by one word
    192 "BB"[1], "AAA "[0]
  • trunk/LayoutTests/editing/selection/move-by-word-visually.html

    r84425 r84710  
    7878var wordBreaks;
    7979
    80 function logWordBreak(index)
    81 {
     80function logWordBreak(index, first)
     81{
     82    var withNodeData = false;
    8283    var wordBreak = wordBreaks[index];
    8384    if (wordBreak.search(',') == -1)
     
    8889
    8990        var differentNode = false;
    90         if (index != 0) {
     91        if (first == false) {
    9192            differentNode = nodeOfWordBreak(nodeAndOffset) != nodeOfWordBreak(wordBreaks[index - 1].split(','));
    9293       
    9394        }
     95
    9496        if (differentNode == true)
    9597            log("]");
    96         if (index == 0 || differentNode == true)
     98
     99        if (first == true || differentNode == true) {
     100            withNodeData = (node instanceof Text);
    97101            log((node instanceof Text ? '"' + fold(node.data) + '"' : "<" + node.tagName + ">") + "[");
     102        }
    98103        log(nodeAndOffset[1]);
    99104    }
     105    return withNodeData;
    100106}
    101107
     
    124130        log("    FAIL expected: [");
    125131        for (var i = 0; i < wordBreaks.length; ++i) {
    126             logWordBreak(i);
     132            logWordBreak(i, i == 0);
    127133            if (i != wordBreaks.length - 1)
    128134                log(", ");
     
    183189}
    184190
     191function positionPassWordBreak(position, wordBreak, searchDirection)
     192{
     193    // Hack for space collapse.
     194    // sel.modify("move", dir, "character") not reach multi-space.
     195    var node = position.node;
     196    if (node.parentNode.id == "multispace") {
     197        if (searchDirection == "right" && position.offset >= wordBreak
     198            || searchDirection == "left" && position.offset <= wordBreak)
     199            return true;
     200    }
     201    return false;
     202}
     203
     204function moveByWordOnEveryChar(sel, test, searchDirection, dir)
     205{
     206    collectWordBreaks(test, searchDirection);
     207    var wordBreakIndex = 1;
     208    var prevOffset = sel.anchorOffset;
     209    var prevNode = sel.anchorNode;
     210
     211    while (1) {
     212        var positions = [];
     213        positions.push({ node: sel.anchorNode, offset: sel.anchorOffset });
     214        sel.modify("move", searchDirection, "-webkit-visual-word");
     215
     216        var position = { node: sel.anchorNode, offset: sel.anchorOffset };
     217
     218        if (wordBreakIndex >= wordBreaks.length) {
     219            if (sel.anchorNode != prevNode || sel.anchorOffset != prevOffset) {
     220                positions.push(position);
     221                logPositions(positions);
     222                log("   FAIL expected to stay in the same position\n");
     223            }
     224        } else if (!positionEqualToWordBreak(position, wordBreaks[wordBreakIndex])) {
     225            positions.push(position);
     226            logPositions(positions);
     227            log("   FAIL expected ");
     228            var withNodeData = logWordBreak(wordBreakIndex, true);
     229            if (withNodeData)
     230                log("]");
     231            log("\n");
     232        }
     233
     234        // Restore position and move by 1 character.
     235        sel.setPosition(prevNode, prevOffset);
     236        sel.modify("move", searchDirection, "character");
     237        if (prevNode == sel.anchorNode && prevOffset == sel.anchorOffset)
     238            break;
     239
     240        position = { node: sel.anchorNode, offset: sel.anchorOffset };
     241        if (wordBreakIndex < wordBreaks.length
     242            && (positionEqualToWordBreak(position, wordBreaks[wordBreakIndex])
     243            || positionPassWordBreak(position, wordBreaks[wordBreakIndex], searchDirection)))
     244            ++wordBreakIndex;
     245
     246        prevNode = sel.anchorNode;
     247        prevOffset = sel.anchorOffset;
     248    };
     249}
     250
    185251function moveByWordForEveryPosition(sel, test, dir)
    186252{
     
    191257        direction = "left";   
    192258    moveByWord(sel, test, direction, dir);   
     259    sel.setPosition(test, 0);
     260    moveByWordOnEveryChar(sel, test, direction, dir);
    193261
    194262    sel.modify("move", "forward", "lineBoundary");
     
    199267        direction = "right";   
    200268    moveByWord(sel, test, direction, dir);   
     269    sel.modify("move", "forward", "lineBoundary");
     270    moveByWordOnEveryChar(sel, test, direction, dir);
    201271}
    202272
     
    216286            moveByWordForEveryPosition(sel, tests[i], "rtl");
    217287        }
    218 
    219     }
    220 }
    221 
    222 function runSpecificTest(tests)
    223 {
    224     var sel = getSelection();
    225     log("\n======== Move By Word Specific Test ====\n");
    226     for (var i = 0; i < tests.length; ++i) {
    227         log("Test " + (i + 1) + "\n");
    228         var components = tests[i].title.split(" ");
    229         var startOffset = components[0];
    230         var movingDirection = components[1];
    231         var endingNode = components[2];
    232         var endingOffset = components[3];
    233  
    234         log("Move " + movingDirection + " by one word\n");
    235 
    236         var positions = [];
    237         sel.setPosition(tests[i].firstChild, startOffset);
    238         positions.push({ node: sel.anchorNode, offset: sel.anchorOffset });
    239 
    240         sel.modify("move", movingDirection, "-webkit-visual-word");
    241         positions.push({ node: sel.anchorNode, offset: sel.anchorOffset });
    242 
    243         logPositions(positions);
    244 
    245         if (sel.anchorNode.parentNode != document.getElementById(endingNode) || sel.anchorOffset != endingOffset) {
    246             log("    FAIL: expected ");
    247             var endingChildNode = document.getElementById(endingNode).firstChild;
    248             log((endingChildNode instanceof Text ? '"' + fold(endingChildNode.data) + '"' : "<" + endingChildNode.tagName + ">") + "[" + endingOffset + "]");
    249         }
    250     }
     288    }
     289
    251290    document.getElementById("testMoveByWord").style.display = "none";
    252291}
     
    256295    var tests = document.getElementsByClassName("test_move_by_word");
    257296    runMoveLeftRight(tests, "word");
    258    
    259     tests = document.getElementsByClassName("specific_test");
    260     runSpecificTest(tests);
    261297}
    262298
     
    320356     FAILED: word break between "def" and "hij" is unreachable.
    321357-->
    322 <div dir=ltr class="test_move_by_word" title="0 4 11 15|18 15 11 4 0" contenteditable>abc def    hij opq</div>
     358<div id="multispace" dir=ltr class="test_move_by_word" title="0 4 11 15|18 15 11 4 0" contenteditable>abc def    hij opq</div>
    323359
    324360<!-- Inline element -->
     
    330366
    331367<!-- FAILED -->
    332 <div dir=rtl id="div_4" class="test_move_by_word" title="[div_4, 8, 3][div_4, 3, 1][div_4, 7, 1][span_4, 3, 1][div_4, 0, 3][div_4, 4, 3][div_4, 0, 1]|[div_4, 0, 1][div_4, 4, 3][div_4, 0, 3][span_4, 3, 1][div_4, 7, 1][div_4, 3, 1]" contenteditable>abc def <span id="span_4">hij opq</span> rst uvw</div>
    333 
    334 <!-- FAILED -->
    335 <div id="div_5" dir=rtl class="test_move_by_word" title="[div_5, 8, 3][div_5, 3, 1][div_5, 7, 1][span_5, 3, 1][div_5, 0, 3][div_5, 4, 3][div_5, 0, 1]|[div_5, 0, 1][div_5, 4, 3][div_5, 0, 3][span_5, 3, 1][div_5, 7, 1][div_5, 3, 1]"contenteditable>abc def <span dir=ltr id="span_5">hij opq</span> rst uvw</div>
     368<div dir=rtl id="div_4" class="test_move_by_word" title="[div_4, 8, 3][div_4, 3, 1][div_4, 7, 1][span_4, 3, 1][span_4, 7, 1][div_4, 4, 3][div_4, 0, 1]|[div_4, 0, 1][div_4, 4, 3][span_4, 7, 1][span_4, 3, 1][div_4, 7, 1][div_4, 3, 1]" contenteditable>abc def <span id="span_4">hij opq</span> rst uvw</div>
     369
     370<!-- FAILED. The render result is the same as div_4. -->
     371<div id="div_5" dir=rtl class="test_move_by_word" title="[div_5, 8, 3][div_5, 3, 1][div_5, 7, 1][span_5, 3, 1][span_5, 7, 1][div_5, 4, 3][div_5, 0, 1]|[div_5, 0, 1][div_5, 4, 3][span_5, 7, 1][span_5, 3, 1][div_5, 7, 1][div_5, 3, 1]"contenteditable>abc def <span dir=ltr id="span_5">hij opq</span> rst uvw</div>
    336372
    337373<div id="div_6" dir=ltr class="test_move_by_word" title="[div_6, 0, 1][div_6, 4, 1][div_6, 8, 1][span_6, 4, 1][div_6, 1, 3][div_6, 5, 3]|[div_6, 8, 3][div_6, 5, 3][div_6, 1, 3][span_6, 4, 1][div_6, 8, 1][div_6, 4, 1][div_6, 0, 1]" contenteditable>abc def <span dir=rtl id="span_6">hij opq</span> rst uvw</div>
     
    355391<div id="div_13" dir=rtl class="test_move_by_word" title="[div_13, 7, 3][div_13, 4, 3][span_13, 3, 1][div_13, 8, 1][div_13, 4, 1][div_13, 0, 1]|[div_13, 0, 1][div_13, 4, 1][div_13, 8, 1][span_13, 3, 1][div_13, 4, 3]" contenteditable>אבד דעפ <span id="span_13">abc def</span>ווש כטז</div>
    356392
    357 <div id="div_14" dir=ltr class="test_move_by_word" title="[div_14, 0, 1][div_14, 3, 1][div_14, 8, 1][span_14, 4, 1][div_14, 3, 3]|[div_14, 7, 3][div_14, 3, 3][span_14, 4, 1][div_14, 8, 1][div_14, 4, 1][div_14, 0, 1]" contenteditable>אבד דעפ <span id="span_14">abc def</span>ווש כטז</div>
     393<div id="div_14" dir=ltr class="test_move_by_word" title="[div_14, 0, 1][div_14, 3, 1][div_14, 8, 1][span_14, 4, 1][div_14, 3, 3]|[div_14, 7, 3][div_14, 3, 3][span_14, 4, 1][div_14, 8, 1][div_14, 3, 1][div_14, 0, 1]" contenteditable>אבד דעפ <span id="span_14">abc def</span>ווש כטז</div>
    358394
    359395<!-- FAILED -->
    360 <div id="div_15" dir=rtl class="test_move_by_word" title="[div_15, 11, 3][div_15, 8, 3][div_15, 4, 3][span_15, 3, 1][span_15, 4, 1][div_15, 12, 1][div_15, 8, 1][div_15, 4, 1][div_15, 0, 1]|[div_15, 0, 1][div_15, 4, 1][div_15, 8, 1][div_15, 12, 1][span_15, 4, 1][span_15, 3, 1][div_15, 4, 3][div_15, 8, 3]"
    361 contenteditable>אבד opq דעפ <span dir=ltr id="span_15">abc אאא def</span>ווש rst כטז</div>
     396<div id="div_15" dir=rtl class="test_move_by_word" title="[div_15, 11, 3][div_15, 8, 3][div_15, 4, 3][span_15, 3, 1][span_15, 4, 1][div_15, 12, 1][div_15, 8, 1][div_15, 4, 1][div_15, 0, 1]|[div_15, 0, 1][div_15, 4, 1][div_15, 8, 1][div_15, 12, 1][span_15, 4, 1][span_15, 3, 1][div_15, 4, 3][div_15, 8, 3]" contenteditable>אבד opq דעפ <span dir=ltr id="span_15">abc אאא def</span>ווש rst כטז</div>
    362397
    363398<!-- FAILED, and wrong printing result -->
     
    371406<div id="div_19" dir=ltr class="test_move_by_word" title="[div_19, 0, 1][div_19, 4, 1][span_19, 4, 1][span_19, 7, 1]|[div_19, 3, 3][span_19, 7, 1][span_19, 4, 1][div_19, 4, 1][div_19, 0, 1]" contenteditable>aaa <span id="span_19">bbb אאא </span>ווש</div>
    372407
    373 <!-- The content in title means "startOffsetInCurrentNode movingDirectionByWord endingNode endingOffsetInEndingNode" -->
    374 <div id="div_100" contenteditable>אאא <span id="span_100" class="specific_test" title="1 left div_100 0">בב</span></div>
    375408</div>
    376409
  • trunk/Source/WebCore/ChangeLog

    r84706 r84710  
     12011-04-22  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        move caret by word in visual order returns wrong result when caret itself is at word boundary.
     6        https://bugs.webkit.org/show_bug.cgi?id=58504.
     7
     8        positionBeforeNextWord should take care that the current position is after current word.
     9        positionAfterPreviousWord should take care that the current positin is before current word.
     10
     11        * editing/visible_units.cpp:
     12        (WebCore::positionBeforeNextWord):
     13        (WebCore::positionAfterPreviousWord):
     14
    1152011-04-19  Jer Noble  <jer.noble@apple.com>
    216
  • trunk/Source/WebCore/editing/visible_units.cpp

    r84678 r84710  
    14811481static VisiblePosition positionBeforeNextWord(const VisiblePosition& position)
    14821482{
    1483     VisiblePosition positionAfterCurrentWord = nextWordPosition(position);
     1483    VisiblePosition positionAfterCurrentWord;
     1484    if (nextWordPosition(previousWordPosition(position)) == position)
     1485        positionAfterCurrentWord = position;
     1486    else
     1487        positionAfterCurrentWord = nextWordPosition(position);
    14841488    VisiblePosition positionAfterNextWord = nextWordPosition(positionAfterCurrentWord);
    14851489    if (positionAfterCurrentWord == positionAfterNextWord)
     
    14901494static VisiblePosition positionAfterPreviousWord(const VisiblePosition& position)
    14911495{
    1492     VisiblePosition positionBeforeCurrentWord = previousWordPosition(position);
     1496    VisiblePosition positionBeforeCurrentWord;
     1497    if (previousWordPosition(nextWordPosition(position)) == position)
     1498        positionBeforeCurrentWord = position;
     1499    else
     1500        positionBeforeCurrentWord = previousWordPosition(position);
    14931501    VisiblePosition positionBeforePreviousWord = previousWordPosition(positionBeforeCurrentWord);
    14941502    if (positionBeforeCurrentWord == positionBeforePreviousWord)
Note: See TracChangeset for help on using the changeset viewer.