Changeset 86966 in webkit


Ignore:
Timestamp:
May 20, 2011 10:45:18 AM (13 years ago)
Author:
xji@chromium.org
Message:

2011-05-20 Xiaomei Ji <xji@chromium.org>

Reviewed by Ryosuke Niwa.

ctrl-arrow does not work on words separated by multiple spaces.
https://bugs.webkit.org/show_bug.cgi?id=57543.

Add the leftmost boundary of a box in RTL block or the rightmost boundary of a box in LTR
block as word break if its inlineBox is the current box and it is a word break.

  • editing/visible_units.cpp: (WebCore::previousWordBreakInBoxInsideBlockWithSameDirectionality): Add the rightmost boundary of a box in LTR block or leftmost boundary of a box in RTL block as visually first word break. (WebCore::nextWordBreakInBoxInsideBlockWithDifferentDirectionality): (WebCore::collectWordBreaksInBoxInsideBlockWithDifferntDirectionality): (WebCore::leftWordBoundary): Fix bug change "box" to "adjacentBox". (WebCore::rightWordBoundary): Fix bug change "box" to "adjacentBox".

2011-05-20 Xiaomei Ji <xji@chromium.org>

Reviewed by Ryosuke Niwa.

ctrl-arrow does not work on words separated by multiple spaces.
https://bugs.webkit.org/show_bug.cgi?id=57543.

Add more test cases for mutiplespaces.

  • editing/selection/move-by-word-visually-expected.txt:
  • editing/selection/move-by-word-visually.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r86964 r86966  
     12011-05-20  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        ctrl-arrow does not work on words separated by multiple spaces.
     6        https://bugs.webkit.org/show_bug.cgi?id=57543.
     7
     8        Add more test cases for mutiplespaces.
     9
     10        * editing/selection/move-by-word-visually-expected.txt:
     11        * editing/selection/move-by-word-visually.html:
     12
    1132011-05-20  Andrew Scherkus  <scherkus@chromium.org>
    214
  • trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt

    r84710 r86966  
    8888Test 18, LTR:
    8989Move right by one word
    90 "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
    96 Move left by one word
    97 "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
     90"abc def    hij opq"[0, 4, 8, 15]
     91Move left by one word
     92"abc def    hij opq"[18, 15, 8, 4, 0]
    10293Test 19, LTR:
    10394Move right by one word
     95"    abc    def    hij    opq    "[4, 8, 15, 22]
     96Move left by one word
     97"    abc    def    hij    opq    "[28, 22, 15, 8, 4]
     98Test 20, LTR:
     99Move right by one word
     100"    abc    ABW    def    "[4, 8, 15]
     101Move left by one word
     102"    abc    ABW    def    "[21, 15, 8, 4]
     103Test 21, LTR:
     104Move right by one word
     105"    abc    def    ABW    DDU    hij    opq    "[4, 8, 15, 21, 29, 36]
     106Move left by one word
     107"    abc    def    ABW    DDU    hij    opq    "[42, 36, 29, 21, 15, 8, 4]
     108Test 22, LTR:
     109Move right by one word
     110"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[4, 8, 15, 22, 35, 28, 43, 50, 57]
     111Move left by one word
     112"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[63, 57, 50, 43, 28, 35, 22, 15, 8, 4]
     113Test 23, LTR:
     114Move right by one word
     115"    ABW    DSU    HJH    FUX    "[4, 21, 14, 7]
     116Move left by one word
     117"    ABW    DSU    HJH    FUX    "[28, 7, 14, 21, 4]
     118Test 24, LTR:
     119Move right by one word
     120"    ABW    abc    DSU     "[4, 8, 15, 21]    FAIL expected: [4, 8, 15]
     121"    ABW    abc    DSU     "[15, 21]   FAIL expected to stay in the same position
     122"    ABW    abc    DSU     "[20, 21]   FAIL expected to stay in the same position
     123"    ABW    abc    DSU     "[19, 21]   FAIL expected to stay in the same position
     124Move left by one word
     125"    ABW    abc    DSU     "[21, 15, 8, 4]
     126Test 25, LTR:
     127Move right by one word
     128"    ABW    DSU    abc   def   HJH    FUX    "[4, 7, 15, 22, 28, 33]
     129Move left by one word
     130"    ABW    DSU    abc   def   HJH    FUX    "[40, 33, 28, 22, 15, 7, 4]
     131Test 26, LTR:
     132Move right by one word
     133"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[4, 14, 7, 22, 29, 35, 41, 51, 46]
     134Move left by one word
     135"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[58, 46, 51, 41, 35, 29, 22, 7, 14, 4]
     136Test 27, LTR:
     137Move right by one word
     138"ABW DSU    EJH FUX"[0, 14, 7, 3]
     139Move left by one word
     140"ABW DSU    EJH FUX"[18, 3, 7, 14, 0]
     141Test 28, LTR:
     142Move right by one word
     143"ABW DSU EJH    abc def hij"[0, 7, 3, 12, 19, 23]
     144Move left by one word
     145"ABW DSU EJH    abc def hij"[26, 23, 19, 12, 3, 7, 0]
     146Test 29, LTR:
     147Move right by one word
     148"abc def hij    ABW DSU EJH    opq rst uvw"[0, 4, 8, 12, 22, 18, 27, 34, 38]
     149Move left by one word
     150"abc def hij    ABW DSU EJH    opq rst uvw"[41, 38, 34, 27, 18, 22, 12, 8, 4, 0]
     151Test 30, RTL:
     152Move left by one word
     153"abc def    hij opq"[0, 14, 7, 3]
     154Move right by one word
     155"abc def    hij opq"[18, 3, 7, 14, 0]
     156Test 31, RTL:
     157Move left by one word
     158"    abc    def    hij    opq    "[4, 21, 14, 7]
     159Move right by one word
     160"    abc    def    hij    opq    "[28, 7, 14, 21, 4]
     161Test 32, RTL:
     162Move left by one word
     163"    abc    ABW    def    "[4, 8, 15, 21]    FAIL expected: [4, 8, 15]
     164"    abc    ABW    def    "[15, 21]   FAIL expected to stay in the same position
     165"    abc    ABW    def    "[20, 21]   FAIL expected to stay in the same position
     166"    abc    ABW    def    "[19, 21]   FAIL expected to stay in the same position
     167Move right by one word
     168"    abc    ABW    def    "[21, 15, 8, 4]
     169Test 33, RTL:
     170Move left by one word
     171"    abc    def    ABW    DDU    hij    opq    "[4, 7, 15, 22, 29, 35]
     172Move right by one word
     173"    abc    def    ABW    DDU    hij    opq    "[42, 35, 29, 22, 15, 7, 4]
     174Test 34, RTL:
     175Move left by one word
     176"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[4, 14, 7, 22, 29, 36, 43, 56, 49]
     177Move right by one word
     178"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[63, 49, 56, 43, 36, 29, 22, 7, 14, 4]
     179Test 35, RTL:
     180Move left by one word
     181"    ABW    DSU    HJH    FUX    "[4, 8, 15, 22]
     182Move right by one word
     183"    ABW    DSU    HJH    FUX    "[28, 22, 15, 8, 4]
     184Test 36, RTL:
     185Move left by one word
     186"    ABW    abc    DSU     "[4, 8, 15]
     187Move right by one word
     188"    ABW    abc    DSU     "[21, 15, 8, 4]
     189Test 37, RTL:
     190Move left by one word
     191"    ABW    DSU    abc   def   HJH    FUX    "[4, 8, 15, 21, 28, 34]
     192Move right by one word
     193"    ABW    DSU    abc   def   HJH    FUX    "[40, 34, 28, 21, 15, 8, 4]
     194Test 38, RTL:
     195Move left by one word
     196"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[4, 8, 15, 22, 34, 28, 41, 47, 52]
     197Move right by one word
     198"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[58, 52, 47, 41, 28, 34, 22, 15, 8, 4]
     199Test 39, LTR:
     200Move right by one word
    104201"AAA "[0, 3]
    105202Move left by one word
    106203"BB"[2], "AAA "[3, 0]
    107 Test 20, RTL:
     204Test 40, RTL:
    108205Move left by one word
    109206"AAA "[0, 4]
    110207Move right by one word
    111208"BB"[2], "AAA "[4, 0]
    112 Test 21, LTR:
     209Test 41, LTR:
    113210Move right by one word
    114211"abc def "[0, 4, 8], "hij opq"[4], " rst uvw"[1, 5]
    115212Move left by one word
    116213" rst uvw"[8, 5, 1], "hij opq"[4], "abc def "[8, 4, 0]
    117 Test 22, RTL:
     214Test 42, RTL:
    118215Move left by one word
    119216"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]
     
    128225"hij opq"[5], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
    129226"hij opq"[6], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
    130 Test 23, RTL:
     227Test 43, RTL:
    131228Move left by one word
    132229"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]
     
    141238"hij opq"[5], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
    142239"hij opq"[6], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
    143 Test 24, LTR:
     240Test 44, LTR:
    144241Move right by one word
    145242"abc def "[0, 4, 8], "hij opq"[4], " rst uvw"[1, 5]
    146243Move left by one word
    147244" rst uvw"[8, 5, 1], "hij opq"[4], "abc def "[8, 4, 0]
    148 Test 25, RTL:
     245Test 45, RTL:
    149246Move left by one word
    150247"ABD DSU "[0, 4, 8], "EJH FUX"[4], "FFZ LIG"[4]
    151248Move right by one word
    152249"FFZ LIG"[7, 4], "EJH FUX"[4], "ABD DSU "[8, 4, 0]
    153 Test 26, LTR:
     250Test 46, LTR:
    154251Move right by one word
    155252"ABD DSU "[0], "FFZ LIG"[3], "EJH FUX"[3], "ABD DSU "[7, 3]
    156253Move left by one word
    157254"FFZ LIG"[7], "ABD DSU "[3, 7], "EJH FUX"[3], "FFZ LIG"[3], "ABD DSU "[0]
    158 Test 27, RTL:
     255Test 47, RTL:
    159256Move left by one word
    160257"ABD DSU "[0, 4, 8], "EJH FUX"[4], "FFZ LIG"[4]
    161258Move right by one word
    162259"FFZ LIG"[7, 4], "EJH FUX"[4], "ABD DSU "[8, 4, 0]
    163 Test 28, LTR:
     260Test 48, LTR:
    164261Move right by one word
    165262"ABD DSU "[0], "FFZ LIG"[3], "EJH FUX"[3], "ABD DSU "[7, 3]
    166263Move left by one word
    167264"FFZ LIG"[7], "ABD DSU "[3, 7], "EJH FUX"[3], "FFZ LIG"[3], "ABD DSU "[0]
    168 Test 29, RTL:
     265Test 49, RTL:
    169266Move left by one word
    170267"ABD DSU "[0, 4, 8], "abc def"[3], "FFZ LIG"[4]
    171268Move right by one word
    172269"FFZ LIG"[7, 4], "abc def"[3], "ABD DSU "[8, 4, 0]
    173 Test 30, LTR:
     270Test 50, LTR:
    174271Move right by one word
    175272"ABD DSU "[0], "FFZ LIG"[3], "ABD DSU "[8], "abc def"[4], "ABD DSU "[7, 3]
     
    180277"FFZ LIG"[5, 5]   FAIL expected "ABD DSU "[ 0]
    181278"FFZ LIG"[6, 6]   FAIL expected "ABD DSU "[ 0]
    182 Test 31, RTL:
     279Test 51, RTL:
    183280Move left by one word
    184281"ABD DSU "[0, 4, 8], "abc def"[3], "FFZ LIG"[4]
    185282Move right by one word
    186283"FFZ LIG"[7, 4], "abc def"[3], "ABD DSU "[8, 4, 0]
    187 Test 32, LTR:
     284Test 52, LTR:
    188285Move right by one word
    189286"ABD DSU "[0, 3, 8], "abc def"[4], "FFZ LIG"[3]
    190287Move left by one word
    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]
    193 Test 33, RTL:
    194 Move left by one word
    195 "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]
     288"FFZ LIG"[7, 3], "abc def"[4], "ABD DSU "[8, 3, 0]
     289Test 53, RTL:
     290Move left by one word
     291"ABD opq DSU "[0, 4, 8, 12], "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]
    200292"ABD opq DSU "[12], "abc AAA def"[8]   FAIL expected "abc AAA def"[ 4]
    201293"abc AAA def"[10, 8]   FAIL expected "abc AAA def"[ 4]
    202294"abc AAA def"[9, 8]   FAIL expected "abc AAA def"[ 4]
    203295Move right by one word
    204 "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]
     296"FFZ rst LIG"[11, 8, 4], "abc AAA def"[3, 4, 8], "ABD opq DSU "[12, 8, 4, 0]    FAIL expected: ["FFZ rst LIG"[ 11,  8,  4, ]"abc AAA def"[ 3,  4, ]"ABD opq DSU "[ 12,  8,  4,  0]
    206297"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]
    210 Test 34, LTR:
     298Test 54, LTR:
    211299Move right by one word
    212300"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]
     
    223311"abc AAA def"[5, 4]   FAIL expected "ABD opq DSU "[ 12]
    224312Move left by one word
    225 "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]
     313"FFZ rst LIG"[11, 8, 4], "ABD opq DSU "[11, 12], "abc AAA def"[7, 8], "ABD opq DSU "[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]
     314"abc AAA def"[8], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
    227315"FFZ rst LIG"[1], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
    228316"FFZ rst LIG"[2], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
    229 Test 35, RTL:
    230 Move left by one word
    231 "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]
    236 Move right by one word
    237 "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]
    242 Test 36, LTR:
     317Test 55, RTL:
     318Move left by one word
     319"ABD opq DSU "[0, 4, 8, 12], "abc AAA def"[4, 8], "FFZ rst LIG"[4, 8]
     320Move right by one word
     321"FFZ rst LIG"[11, 8, 4], "abc AAA def"[8, 4], "ABD opq DSU "[12, 8, 4, 0]
     322Test 56, LTR:
    243323Move right by one word
    244324"ABD opq DSU "[0, 4, 8, 12], "abc AAA def"[4, 8], "FFZ rst LIG"[4, 8, 11]
    245325Move left by one word
    246326"FFZ rst LIG"[11, 8, 4], "abc AAA def"[8, 4], "ABD opq DSU "[12, 8, 4, 0]
    247 Test 37, LTR:
     327Test 57, LTR:
    248328Move right by one word
    249329"aaa "[0, 4], "bbb AAA "[4, 7]
    250330Move left by one word
    251331"FFZ"[3], "bbb AAA "[7, 4], "aaa "[4, 0]
     332Test 58, RTL:
     333Move left by one word
     334"ABD opq rst DSU "[0, 4, 7, 12, 16], "abc uvw AAA def lmn"[12, 8, 7, 3], "ABW hij xyz FXX"[4, 7, 12]    FAIL expected: ["ABD opq rst DSU "[ 0,  4,  7,  12,  16, ]"abc uvw AAA def lmn"[ 15,  8,  7,  3, ]"ABW hij xyz FXX"[ 4,  7,  12]
     335"ABD opq rst DSU "[16], "abc uvw AAA def lmn"[12]   FAIL expected "abc uvw AAA def lmn"[ 15]
     336"abc uvw AAA def lmn"[15, 12]   FAIL expected "abc uvw AAA def lmn"[ 8]
     337"abc uvw AAA def lmn"[14, 12]   FAIL expected "abc uvw AAA def lmn"[ 8]
     338"abc uvw AAA def lmn"[13, 12]   FAIL expected "abc uvw AAA def lmn"[ 8]
     339Move right by one word
     340"ABW hij xyz FXX"[15, 12, 7, 4], "abc uvw AAA def lmn"[3, 7, 8, 15], "ABD opq rst DSU "[16, 12, 7, 4, 0]
    252341
  • trunk/LayoutTests/editing/selection/move-by-word-visually.html

    r84710 r86966  
    187187    validateData(positions);
    188188    log("\n");
    189 }
    190 
    191 function 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;
    202189}
    203190
     
    240227        position = { node: sel.anchorNode, offset: sel.anchorOffset };
    241228        if (wordBreakIndex < wordBreaks.length
    242             && (positionEqualToWordBreak(position, wordBreaks[wordBreakIndex])
    243             || positionPassWordBreak(position, wordBreaks[wordBreakIndex], searchDirection)))
     229            && positionEqualToWordBreak(position, wordBreaks[wordBreakIndex]))
    244230            ++wordBreakIndex;
    245231
     
    353339<div dir=rtl class="test_move_by_word" title="11 8 4 0|0 4 8" contenteditable>שנב abc סטז</div>
    354340
    355 <!-- multiple spaces between word.
    356      FAILED: word break between "def" and "hij" is unreachable.
    357 -->
    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>
     341<!-- test multispaces -->
     342<div dir=ltr class="test_move_by_word" title="0 4 8 15|18 15 8 4 0" contenteditable>abc def    hij opq</div>
     343<div dir=ltr class="test_move_by_word" title="4 8 15 22|28 22 15 8 4" contenteditable>    abc    def    hij    opq    </div>
     344<div dir=ltr class="test_move_by_word" title="4 8 15|21 15 8 4" contenteditable>    abc    אבצ    def    </div>
     345<div dir=ltr class="test_move_by_word" title="4 8 15 21 29 36|42 36 29 21 15 8 4" contenteditable>    abc    def    אבצ    דדפ    hij    opq    </div>
     346<div dir=ltr class="test_move_by_word" title="4 8 15 22 35 28 43 50 57|63 57 50 43 28 35 22 15 8 4" contenteditable>    abc    def    hij    אבצ    דעפ    היח    opq    rst    uvw    </div>
     347<div dir=ltr class="test_move_by_word" title="4 21 14 7|28 7 14 21 4" contenteditable>    אבצ    דעפ    חיח    ופק    </div>
     348<div dir=ltr class="test_move_by_word" title="4 8 15|21 15 8 4" contenteditable>    אבצ    abc    דעפ     </div>
     349<div dir=ltr class="test_move_by_word" title="4 7 15 22 28 33|40 33 28 22 15 7 4" contenteditable>    אבצ    דעפ    abc   def   חיח    ופק    </div>
     350<div dir=ltr class="test_move_by_word" title="4 14 7 22 29 35 41 51 46|58 46 51 41 35 29 22 7 14 4" contenteditable>    אבצ    דעפ    חיח    abc   def   jih   ופק  ופק    רסת     </div>
     351
     352<div dir=ltr class="test_move_by_word" title="0 14 7 3|18 3 7 14 0" contenteditable>אבצ דעפ    היח ופק</div>
     353<div dir=ltr class="test_move_by_word" title="0 7 3 12 19 23|26 23 19 12 3 7 0" contenteditable>אבצ דעפ היח    abc def hij</div>
     354<div dir=ltr class="test_move_by_word" title="0 4 8 12 22 18 27 34 38|41 38 34 27 18 22 12 8 4 0" contenteditable>abc def hij    אבצ דעפ היח    opq rst uvw</div>
     355
     356<div dir=rtl class="test_move_by_word" title="18 3 7 14 0|0 14 7 3" contenteditable>abc def    hij opq</div>
     357<div dir=rtl class="test_move_by_word" title="28 7 14 21 4|4 21 14 7" contenteditable>    abc    def    hij    opq    </div>
     358<div dir=rtl class="test_move_by_word" title="21 15 8 4|4 8 15" contenteditable>    abc    אבצ    def    </div>
     359<div dir=rtl class="test_move_by_word" title="42 35 29 22 15 7 4|4 7 15 22 29 35" contenteditable>    abc    def    אבצ    דדפ    hij    opq    </div>
     360<div dir=rtl class="test_move_by_word" title="63 49 56 43 36 29 22 7 14 4|4 14 7 22 29 36 43 56 49" contenteditable>    abc    def    hij    אבצ    דעפ    היח    opq    rst    uvw    </div>
     361<div dir=rtl class="test_move_by_word" title="28 22 15 8 4|4 8 15 22" contenteditable>    אבצ    דעפ    חיח    ופק    </div>
     362<div dir=rtl class="test_move_by_word" title="21 15 8 4|4 8 15" contenteditable>    אבצ    abc    דעפ     </div>
     363<div dir=rtl class="test_move_by_word" title="40 34 28 21 15 8 4|4 8 15 21 28 34" contenteditable>    אבצ    דעפ    abc   def   חיח    ופק    </div>
     364<div dir=rtl class="test_move_by_word" title="58 52 47 41 28 34 22 15 8 4|4 8 15 22 34 28 41 47 52" contenteditable>    אבצ    דעפ    חיח    abc   def   jih   ופק  ופק    רסת     </div>
     365
    359366
    360367<!-- Inline element -->
     
    406413<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>
    407414
     415<div id="div_20" dir=rtl class="test_move_by_word" title="[div_20, 15, 3][div_20, 12, 3][div_20, 7, 3][div_20, 4, 3][span_20, 3, 1][span_20, 7, 1][span_20, 8, 1][span_20, 15, 1][div_20, 16, 1][div_20, 12, 1][div_20, 7, 1][div_20, 4, 1][div_20, 0, 1]|[div_20, 0, 1][div_20, 4, 1][div_20, 7, 1][div_20, 12, 1][div_20, 16, 1][span_20, 15, 1][span_20, 8, 1][span_20, 7, 1][span_20, 3, 1][div_20, 4, 3][div_20, 7, 3][div_20, 12, 3]" contenteditable>אבד opq rst דעפ <span dir=ltr id="span_20">abc uvw אאא def lmn</span>אבצ hij xyz וקק</div>
    408416</div>
    409417
  • trunk/Source/WebCore/ChangeLog

    r86965 r86966  
     12011-05-20  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        ctrl-arrow does not work on words separated by multiple spaces.
     6        https://bugs.webkit.org/show_bug.cgi?id=57543.
     7
     8        Add the leftmost boundary of a box in RTL block or the rightmost boundary of a box in LTR
     9        block as word break if its inlineBox is the current box and it is a word break.
     10
     11        * editing/visible_units.cpp:
     12        (WebCore::previousWordBreakInBoxInsideBlockWithSameDirectionality): Add the rightmost
     13        boundary of a box in LTR block or leftmost boundary of a box in RTL block as visually
     14        first word break.
     15        (WebCore::nextWordBreakInBoxInsideBlockWithDifferentDirectionality):
     16        (WebCore::collectWordBreaksInBoxInsideBlockWithDifferntDirectionality):
     17        (WebCore::leftWordBoundary): Fix bug change "box" to "adjacentBox".
     18        (WebCore::rightWordBoundary): Fix bug change "box" to "adjacentBox".
     19
    1202011-05-19  Evan Martin  <evan@chromium.org>
    221
  • trunk/Source/WebCore/editing/visible_units.cpp

    r86325 r86966  
    11631163
    11641164static const int invalidOffset = -1;
    1165    
     1165
    11661166static VisiblePosition previousWordBreakInBoxInsideBlockWithSameDirectionality(const InlineBox* box, const VisiblePosition& previousWordBreak, int& offsetOfWordBreak)
    11671167{
    1168     bool hasSeenWordBreakInThisBox = previousWordBreak.isNotNull();
    11691168    // In a LTR block, the word break should be on the left boundary of a word.
    11701169    // In a RTL block, the word break should be on the right boundary of a word.
     
    11731172    // to find the previous word break (i.e. the first word break on the left). The same applies to RTL text.
    11741173   
    1175     VisiblePosition wordBreak = hasSeenWordBreakInThisBox ? previousWordBreak : Position(box->renderer()->node(), box->caretMaxOffset(), Position::PositionIsOffsetInAnchor);
    1176 
    1177     // FIXME: handle multi-spaces (http://webkit.org/b/57543).
    1178    
     1174    bool hasSeenWordBreakInThisBox = previousWordBreak.isNotNull();
     1175
     1176    VisiblePosition wordBreak;
     1177
     1178    if (hasSeenWordBreakInThisBox)
     1179        wordBreak = previousWordBreak;
     1180    else {
     1181        wordBreak = Position(box->renderer()->node(), box->caretMaxOffset(), Position::PositionIsOffsetInAnchor);
     1182        // Return the rightmost word boundary of LTR box or leftmost word boundary of RTL box if
     1183        // it is not in the previously visited boxes. For example, given a logical text
     1184        // "abc def     hij opq", there are 2 boxes: the "abc def " (starts at 0 and length is 8)
     1185        // and the "hij opq" (starts at 12 and length is 7). The word breaks are
     1186        // "abc |def |    hij |opq". We normally catch the word break between "def" and "hij" when
     1187        // we visit the box that contains "hij opq", but this word break doesn't exist in the box
     1188        // that contains "hij opq" when there are multiple spaces. So we detect it when we're
     1189        // traversing the box that contains "abc def " instead.
     1190
     1191        if ((box->isLeftToRightDirection() && box->nextLeafChild())
     1192            || (!box->isLeftToRightDirection() && box->prevLeafChild())) {
     1193   
     1194            VisiblePosition positionAfterWord = nextWordPosition(wordBreak);
     1195            VisiblePosition positionBeforeWord = previousWordPosition(positionAfterWord);
     1196       
     1197            InlineBox* boxContainingPreviousWordBreak;
     1198            positionBeforeWord.getInlineBoxAndOffset(boxContainingPreviousWordBreak, offsetOfWordBreak);
     1199       
     1200            if (boxContainingPreviousWordBreak == box)
     1201                return positionBeforeWord;
     1202        }
     1203    }
     1204 
    11791205    wordBreak = previousWordPosition(wordBreak);
    11801206    if (previousWordBreak == wordBreak)
     
    12831309    // we need to use nextWordPosition() to traverse words within the inline boxes from right to left to find the next word break.
    12841310    // The same applies to LTR text, in which words are traversed within the inline boxes from left to right.
    1285    
    1286     // FIXME: handle multi-spaces (http://webkit.org/b/57543).
    12871311   
    12881312    bool hasSeenWordBreakInThisBox = previousWordBreak.isNotNull();
     
    13441368    VisiblePosition wordBreak;
    13451369    int offsetOfWordBreak = invalidOffset;
     1370    bool isLastWordBreakInBox = false;
    13461371    while (1) {
    1347         bool isLastWordBreakInBox = false;
    13481372        wordBreak = nextWordBreakInBoxInsideBlockWithDifferentDirectionality(box, wordBreak, offsetOfWordBreak, isLastWordBreakInBox);
    13491373        if (wordBreak.isNotNull()) {
     
    14471471    for  (const InlineBox* adjacentBox = box; adjacentBox; adjacentBox = adjacentBox->prevLeafChild()) {
    14481472        if (blockDirection == LTR) {
    1449             if (box->isLeftToRightDirection())
     1473            if (adjacentBox->isLeftToRightDirection())
    14501474                wordBreak = previousWordBoundaryInBox(adjacentBox, adjacentBox == box ? offset : invalidOffset);
    14511475            else
     
    14651489    for (const InlineBox* adjacentBox = box; adjacentBox; adjacentBox = adjacentBox->nextLeafChild()) {
    14661490        if (blockDirection == RTL) {
    1467             if (box->isLeftToRightDirection())
     1491            if (adjacentBox->isLeftToRightDirection())
    14681492                wordBreak = nextWordBoundaryInBox(adjacentBox, adjacentBox == box ? offset : invalidOffset);
    14691493            else
Note: See TracChangeset for help on using the changeset viewer.