Title: [86966] trunk
Revision
86966
Author
x...@chromium.org
Date
2011-05-20 10:45:18 -0700 (Fri, 20 May 2011)

Log Message

2011-05-20  Xiaomei Ji  <x...@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  <x...@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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (86965 => 86966)


--- trunk/LayoutTests/ChangeLog	2011-05-20 17:20:53 UTC (rev 86965)
+++ trunk/LayoutTests/ChangeLog	2011-05-20 17:45:18 UTC (rev 86966)
@@ -1,3 +1,15 @@
+2011-05-20  Xiaomei Ji  <x...@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:
+
 2011-05-20  Andrew Scherkus  <scher...@chromium.org>
 
         Unreviewed, updating media/event-attributes.html as passing for Chromium.

Modified: trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt (86965 => 86966)


--- trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt	2011-05-20 17:20:53 UTC (rev 86965)
+++ trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt	2011-05-20 17:45:18 UTC (rev 86966)
@@ -87,34 +87,131 @@
 "ZQB abc RIG"[11, 8, 4, 0]
 Test 18, LTR:
 Move right by one word
-"abc def    hij opq"[0, 4, 15]    FAIL expected: [0, 4, 11, 15]
-"abc def    hij opq"[4, 15]   FAIL expected 11
-"abc def    hij opq"[5, 15]   FAIL expected 11
-"abc def    hij opq"[6, 15]   FAIL expected 11
-"abc def    hij opq"[7, 15]   FAIL expected 11
-"abc def    hij opq"[8, 15]   FAIL expected 11
+"abc def    hij opq"[0, 4, 8, 15]
 Move left by one word
-"abc def    hij opq"[18, 15, 4, 0]    FAIL expected: [18, 15, 11, 4, 0]
-"abc def    hij opq"[15, 4]   FAIL expected 11
-"abc def    hij opq"[14, 4]   FAIL expected 11
-"abc def    hij opq"[13, 4]   FAIL expected 11
-"abc def    hij opq"[12, 4]   FAIL expected 11
+"abc def    hij opq"[18, 15, 8, 4, 0]
 Test 19, LTR:
 Move right by one word
+"    abc    def    hij    opq    "[4, 8, 15, 22]
+Move left by one word
+"    abc    def    hij    opq    "[28, 22, 15, 8, 4]
+Test 20, LTR:
+Move right by one word
+"    abc    ABW    def    "[4, 8, 15]
+Move left by one word
+"    abc    ABW    def    "[21, 15, 8, 4]
+Test 21, LTR:
+Move right by one word
+"    abc    def    ABW    DDU    hij    opq    "[4, 8, 15, 21, 29, 36]
+Move left by one word
+"    abc    def    ABW    DDU    hij    opq    "[42, 36, 29, 21, 15, 8, 4]
+Test 22, LTR:
+Move right by one word
+"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[4, 8, 15, 22, 35, 28, 43, 50, 57]
+Move left by one word
+"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[63, 57, 50, 43, 28, 35, 22, 15, 8, 4]
+Test 23, LTR:
+Move right by one word
+"    ABW    DSU    HJH    FUX    "[4, 21, 14, 7]
+Move left by one word
+"    ABW    DSU    HJH    FUX    "[28, 7, 14, 21, 4]
+Test 24, LTR:
+Move right by one word
+"    ABW    abc    DSU     "[4, 8, 15, 21]    FAIL expected: [4, 8, 15]
+"    ABW    abc    DSU     "[15, 21]   FAIL expected to stay in the same position
+"    ABW    abc    DSU     "[20, 21]   FAIL expected to stay in the same position
+"    ABW    abc    DSU     "[19, 21]   FAIL expected to stay in the same position
+Move left by one word
+"    ABW    abc    DSU     "[21, 15, 8, 4]
+Test 25, LTR:
+Move right by one word
+"    ABW    DSU    abc   def   HJH    FUX    "[4, 7, 15, 22, 28, 33]
+Move left by one word
+"    ABW    DSU    abc   def   HJH    FUX    "[40, 33, 28, 22, 15, 7, 4]
+Test 26, LTR:
+Move right by one word
+"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[4, 14, 7, 22, 29, 35, 41, 51, 46]
+Move left by one word
+"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[58, 46, 51, 41, 35, 29, 22, 7, 14, 4]
+Test 27, LTR:
+Move right by one word
+"ABW DSU    EJH FUX"[0, 14, 7, 3]
+Move left by one word
+"ABW DSU    EJH FUX"[18, 3, 7, 14, 0]
+Test 28, LTR:
+Move right by one word
+"ABW DSU EJH    abc def hij"[0, 7, 3, 12, 19, 23]
+Move left by one word
+"ABW DSU EJH    abc def hij"[26, 23, 19, 12, 3, 7, 0]
+Test 29, LTR:
+Move right by one word
+"abc def hij    ABW DSU EJH    opq rst uvw"[0, 4, 8, 12, 22, 18, 27, 34, 38]
+Move left by one word
+"abc def hij    ABW DSU EJH    opq rst uvw"[41, 38, 34, 27, 18, 22, 12, 8, 4, 0]
+Test 30, RTL:
+Move left by one word
+"abc def    hij opq"[0, 14, 7, 3]
+Move right by one word
+"abc def    hij opq"[18, 3, 7, 14, 0]
+Test 31, RTL:
+Move left by one word
+"    abc    def    hij    opq    "[4, 21, 14, 7]
+Move right by one word
+"    abc    def    hij    opq    "[28, 7, 14, 21, 4]
+Test 32, RTL:
+Move left by one word
+"    abc    ABW    def    "[4, 8, 15, 21]    FAIL expected: [4, 8, 15]
+"    abc    ABW    def    "[15, 21]   FAIL expected to stay in the same position
+"    abc    ABW    def    "[20, 21]   FAIL expected to stay in the same position
+"    abc    ABW    def    "[19, 21]   FAIL expected to stay in the same position
+Move right by one word
+"    abc    ABW    def    "[21, 15, 8, 4]
+Test 33, RTL:
+Move left by one word
+"    abc    def    ABW    DDU    hij    opq    "[4, 7, 15, 22, 29, 35]
+Move right by one word
+"    abc    def    ABW    DDU    hij    opq    "[42, 35, 29, 22, 15, 7, 4]
+Test 34, RTL:
+Move left by one word
+"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[4, 14, 7, 22, 29, 36, 43, 56, 49]
+Move right by one word
+"    abc    def    hij    ABW    DSU    EJH    opq    rst    uvw    "[63, 49, 56, 43, 36, 29, 22, 7, 14, 4]
+Test 35, RTL:
+Move left by one word
+"    ABW    DSU    HJH    FUX    "[4, 8, 15, 22]
+Move right by one word
+"    ABW    DSU    HJH    FUX    "[28, 22, 15, 8, 4]
+Test 36, RTL:
+Move left by one word
+"    ABW    abc    DSU     "[4, 8, 15]
+Move right by one word
+"    ABW    abc    DSU     "[21, 15, 8, 4]
+Test 37, RTL:
+Move left by one word
+"    ABW    DSU    abc   def   HJH    FUX    "[4, 8, 15, 21, 28, 34]
+Move right by one word
+"    ABW    DSU    abc   def   HJH    FUX    "[40, 34, 28, 21, 15, 8, 4]
+Test 38, RTL:
+Move left by one word
+"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[4, 8, 15, 22, 34, 28, 41, 47, 52]
+Move right by one word
+"    ABW    DSU    HJH    abc   def   jih   FUX  FUX    YR[     "[58, 52, 47, 41, 28, 34, 22, 15, 8, 4]
+Test 39, LTR:
+Move right by one word
 "AAA "[0, 3]
 Move left by one word
 "BB"[2], "AAA "[3, 0]
-Test 20, RTL:
+Test 40, RTL:
 Move left by one word
 "AAA "[0, 4]
 Move right by one word
 "BB"[2], "AAA "[4, 0]
-Test 21, LTR:
+Test 41, LTR:
 Move right by one word
 "abc def "[0, 4, 8], "hij opq"[4], " rst uvw"[1, 5]
 Move left by one word
 " rst uvw"[8, 5, 1], "hij opq"[4], "abc def "[8, 4, 0]
-Test 22, RTL:
+Test 42, RTL:
 Move left by one word
 "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]
 " rst uvw"[4], "hij opq"[3]   FAIL expected "hij opq"[ 7]
@@ -127,7 +224,7 @@
 "hij opq"[4], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
 "hij opq"[5], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
 "hij opq"[6], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
-Test 23, RTL:
+Test 43, RTL:
 Move left by one word
 "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]
 " rst uvw"[4], "hij opq"[3]   FAIL expected "hij opq"[ 7]
@@ -140,37 +237,37 @@
 "hij opq"[4], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
 "hij opq"[5], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
 "hij opq"[6], " rst uvw"[4]   FAIL expected "hij opq"[ 7]
-Test 24, LTR:
+Test 44, LTR:
 Move right by one word
 "abc def "[0, 4, 8], "hij opq"[4], " rst uvw"[1, 5]
 Move left by one word
 " rst uvw"[8, 5, 1], "hij opq"[4], "abc def "[8, 4, 0]
-Test 25, RTL:
+Test 45, RTL:
 Move left by one word
 "ABD DSU "[0, 4, 8], "EJH FUX"[4], "FFZ LIG"[4]
 Move right by one word
 "FFZ LIG"[7, 4], "EJH FUX"[4], "ABD DSU "[8, 4, 0]
-Test 26, LTR:
+Test 46, LTR:
 Move right by one word
 "ABD DSU "[0], "FFZ LIG"[3], "EJH FUX"[3], "ABD DSU "[7, 3]
 Move left by one word
 "FFZ LIG"[7], "ABD DSU "[3, 7], "EJH FUX"[3], "FFZ LIG"[3], "ABD DSU "[0]
-Test 27, RTL:
+Test 47, RTL:
 Move left by one word
 "ABD DSU "[0, 4, 8], "EJH FUX"[4], "FFZ LIG"[4]
 Move right by one word
 "FFZ LIG"[7, 4], "EJH FUX"[4], "ABD DSU "[8, 4, 0]
-Test 28, LTR:
+Test 48, LTR:
 Move right by one word
 "ABD DSU "[0], "FFZ LIG"[3], "EJH FUX"[3], "ABD DSU "[7, 3]
 Move left by one word
 "FFZ LIG"[7], "ABD DSU "[3, 7], "EJH FUX"[3], "FFZ LIG"[3], "ABD DSU "[0]
-Test 29, RTL:
+Test 49, RTL:
 Move left by one word
 "ABD DSU "[0, 4, 8], "abc def"[3], "FFZ LIG"[4]
 Move right by one word
 "FFZ LIG"[7, 4], "abc def"[3], "ABD DSU "[8, 4, 0]
-Test 30, LTR:
+Test 50, LTR:
 Move right by one word
 "ABD DSU "[0], "FFZ LIG"[3], "ABD DSU "[8], "abc def"[4], "ABD DSU "[7, 3]
 Move left by one word
@@ -179,35 +276,26 @@
 "FFZ LIG"[4, 4]   FAIL expected "ABD DSU "[ 0]
 "FFZ LIG"[5, 5]   FAIL expected "ABD DSU "[ 0]
 "FFZ LIG"[6, 6]   FAIL expected "ABD DSU "[ 0]
-Test 31, RTL:
+Test 51, RTL:
 Move left by one word
 "ABD DSU "[0, 4, 8], "abc def"[3], "FFZ LIG"[4]
 Move right by one word
 "FFZ LIG"[7, 4], "abc def"[3], "ABD DSU "[8, 4, 0]
-Test 32, LTR:
+Test 52, LTR:
 Move right by one word
 "ABD DSU "[0, 3, 8], "abc def"[4], "FFZ LIG"[3]
 Move left by one word
-"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]
-"ABD DSU "[8, 4]   FAIL expected "ABD DSU "[ 3]
-Test 33, RTL:
+"FFZ LIG"[7, 3], "abc def"[4], "ABD DSU "[8, 3, 0]
+Test 53, RTL:
 Move left by one word
-"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]
-"ABD opq DSU "[8], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
-"ABD opq DSU "[9], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
-"ABD opq DSU "[10], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
-"ABD opq DSU "[11], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 12]
+"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]
 "ABD opq DSU "[12], "abc AAA def"[8]   FAIL expected "abc AAA def"[ 4]
 "abc AAA def"[10, 8]   FAIL expected "abc AAA def"[ 4]
 "abc AAA def"[9, 8]   FAIL expected "abc AAA def"[ 4]
 Move right by one word
-"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]
-"FFZ rst LIG"[4], "abc AAA def"[4]   FAIL expected "abc AAA def"[ 3]
+"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]
 "abc AAA def"[4, 8]   FAIL expected "ABD opq DSU "[ 12]
-"abc AAA def"[8], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
-"abc AAA def"[9], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
-"abc AAA def"[10], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
-Test 34, LTR:
+Test 54, LTR:
 Move right by one word
 "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]
 "ABD opq DSU "[4], "abc AAA def"[8]   FAIL expected "ABD opq DSU "[ 8]
@@ -222,31 +310,32 @@
 "abc AAA def"[6, 4]   FAIL expected "ABD opq DSU "[ 12]
 "abc AAA def"[5, 4]   FAIL expected "ABD opq DSU "[ 12]
 Move left by one word
-"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]
-"abc AAA def"[8], "ABD opq DSU "[7]   FAIL expected "ABD opq DSU "[ 8]
+"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]
+"abc AAA def"[8], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
 "FFZ rst LIG"[1], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
 "FFZ rst LIG"[2], "ABD opq DSU "[4]   FAIL expected "ABD opq DSU "[ 8]
-Test 35, RTL:
+Test 55, RTL:
 Move left by one word
-"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]
-"ABD opq DSU "[8], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
-"ABD opq DSU "[9], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
-"ABD opq DSU "[10], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
-"ABD opq DSU "[11], "abc AAA def"[4]   FAIL expected "ABD opq DSU "[ 12]
+"ABD opq DSU "[0, 4, 8, 12], "abc AAA def"[4, 8], "FFZ rst LIG"[4, 8]
 Move right by one word
-"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]
-"abc AAA def"[4], "ABD opq DSU "[11]   FAIL expected "ABD opq DSU "[ 12]
-"abc AAA def"[3], "ABD opq DSU "[11]   FAIL expected "ABD opq DSU "[ 12]
-"abc AAA def"[1], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
-"abc AAA def"[2], "ABD opq DSU "[8]   FAIL expected "ABD opq DSU "[ 12]
-Test 36, LTR:
+"FFZ rst LIG"[11, 8, 4], "abc AAA def"[8, 4], "ABD opq DSU "[12, 8, 4, 0]
+Test 56, LTR:
 Move right by one word
 "ABD opq DSU "[0, 4, 8, 12], "abc AAA def"[4, 8], "FFZ rst LIG"[4, 8, 11]
 Move left by one word
 "FFZ rst LIG"[11, 8, 4], "abc AAA def"[8, 4], "ABD opq DSU "[12, 8, 4, 0]
-Test 37, LTR:
+Test 57, LTR:
 Move right by one word
 "aaa "[0, 4], "bbb AAA "[4, 7]
 Move left by one word
 "FFZ"[3], "bbb AAA "[7, 4], "aaa "[4, 0]
+Test 58, RTL:
+Move left by one word
+"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]
+"ABD opq rst DSU "[16], "abc uvw AAA def lmn"[12]   FAIL expected "abc uvw AAA def lmn"[ 15]
+"abc uvw AAA def lmn"[15, 12]   FAIL expected "abc uvw AAA def lmn"[ 8]
+"abc uvw AAA def lmn"[14, 12]   FAIL expected "abc uvw AAA def lmn"[ 8]
+"abc uvw AAA def lmn"[13, 12]   FAIL expected "abc uvw AAA def lmn"[ 8]
+Move right by one word
+"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]
 

Modified: trunk/LayoutTests/editing/selection/move-by-word-visually.html (86965 => 86966)


--- trunk/LayoutTests/editing/selection/move-by-word-visually.html	2011-05-20 17:20:53 UTC (rev 86965)
+++ trunk/LayoutTests/editing/selection/move-by-word-visually.html	2011-05-20 17:45:18 UTC (rev 86966)
@@ -188,19 +188,6 @@
     log("\n");
 }
 
-function positionPassWordBreak(position, wordBreak, searchDirection)
-{
-    // Hack for space collapse.
-    // sel.modify("move", dir, "character") not reach multi-space.
-    var node = position.node;
-    if (node.parentNode.id == "multispace") {
-        if (searchDirection == "right" && position.offset >= wordBreak
-            || searchDirection == "left" && position.offset <= wordBreak) 
-            return true;
-    }
-    return false;
-}
-
 function moveByWordOnEveryChar(sel, test, searchDirection, dir)
 {
     collectWordBreaks(test, searchDirection);
@@ -239,8 +226,7 @@
 
         position = { node: sel.anchorNode, offset: sel.anchorOffset };
         if (wordBreakIndex < wordBreaks.length 
-            && (positionEqualToWordBreak(position, wordBreaks[wordBreakIndex]) 
-            || positionPassWordBreak(position, wordBreaks[wordBreakIndex], searchDirection)))
+            && positionEqualToWordBreak(position, wordBreaks[wordBreakIndex]))
             ++wordBreakIndex;
 
         prevNode = sel.anchorNode;
@@ -352,11 +338,32 @@
 <div dir=ltr class="test_move_by_word" title="0 4 8 11|11 8 4 0" contenteditable>שנב abc סטז</div>
 <div dir=rtl class="test_move_by_word" title="11 8 4 0|0 4 8" contenteditable>שנב abc סטז</div>
 
-<!-- multiple spaces between word. 
-     FAILED: word break between "def" and "hij" is unreachable.
--->
-<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>
+<!-- test multispaces -->
+<div dir=ltr class="test_move_by_word" title="0 4 8 15|18 15 8 4 0" contenteditable>abc def    hij opq</div>
+<div dir=ltr class="test_move_by_word" title="4 8 15 22|28 22 15 8 4" contenteditable>    abc    def    hij    opq    </div>
+<div dir=ltr class="test_move_by_word" title="4 8 15|21 15 8 4" contenteditable>    abc    אבצ    def    </div>
+<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>
+<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>
+<div dir=ltr class="test_move_by_word" title="4 21 14 7|28 7 14 21 4" contenteditable>    אבצ    דעפ    חיח    ופק    </div>
+<div dir=ltr class="test_move_by_word" title="4 8 15|21 15 8 4" contenteditable>    אבצ    abc    דעפ     </div>
+<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>
+<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>
 
+<div dir=ltr class="test_move_by_word" title="0 14 7 3|18 3 7 14 0" contenteditable>אבצ דעפ    היח ופק</div>
+<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>
+<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>
+
+<div dir=rtl class="test_move_by_word" title="18 3 7 14 0|0 14 7 3" contenteditable>abc def    hij opq</div>
+<div dir=rtl class="test_move_by_word" title="28 7 14 21 4|4 21 14 7" contenteditable>    abc    def    hij    opq    </div>
+<div dir=rtl class="test_move_by_word" title="21 15 8 4|4 8 15" contenteditable>    abc    אבצ    def    </div>
+<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>
+<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>
+<div dir=rtl class="test_move_by_word" title="28 22 15 8 4|4 8 15 22" contenteditable>    אבצ    דעפ    חיח    ופק    </div>
+<div dir=rtl class="test_move_by_word" title="21 15 8 4|4 8 15" contenteditable>    אבצ    abc    דעפ     </div>
+<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>
+<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>
+
+
 <!-- Inline element -->
 <div dir=ltr id="div_1" class="test_move_by_word" title="[div_1, 0][div_1, 3]|[span_1, 2][div_1, 3][div_1,0]" contenteditable>אאא <span id="span_1">בב</span></div>
 <div dir=rtl id="div_2" class="test_move_by_word" title="[span_2, 2][div_2, 4][div_2, 0]|[div_2, 0][div_2, 4]" contenteditable>אאא <span id="span_2">בב</span></div>
@@ -405,6 +412,7 @@
 
 <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>
 
+<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>
 </div>
 
 <pre id="console"></pre>

Modified: trunk/Source/WebCore/ChangeLog (86965 => 86966)


--- trunk/Source/WebCore/ChangeLog	2011-05-20 17:20:53 UTC (rev 86965)
+++ trunk/Source/WebCore/ChangeLog	2011-05-20 17:45:18 UTC (rev 86966)
@@ -1,3 +1,22 @@
+2011-05-20  Xiaomei Ji  <x...@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-19  Evan Martin  <e...@chromium.org>
 
         Reviewed by Tony Chang.

Modified: trunk/Source/WebCore/editing/visible_units.cpp (86965 => 86966)


--- trunk/Source/WebCore/editing/visible_units.cpp	2011-05-20 17:20:53 UTC (rev 86965)
+++ trunk/Source/WebCore/editing/visible_units.cpp	2011-05-20 17:45:18 UTC (rev 86966)
@@ -1162,20 +1162,46 @@
 }
 
 static const int invalidOffset = -1;
-    
+
 static VisiblePosition previousWordBreakInBoxInsideBlockWithSameDirectionality(const InlineBox* box, const VisiblePosition& previousWordBreak, int& offsetOfWordBreak)
 {
-    bool hasSeenWordBreakInThisBox = previousWordBreak.isNotNull();
     // In a LTR block, the word break should be on the left boundary of a word.
     // In a RTL block, the word break should be on the right boundary of a word.
     // Because nextWordPosition() returns the word break on the right boundary of the word for LTR text,
     // we need to use previousWordPosition() to traverse words within the inline boxes from right to left
     // to find the previous word break (i.e. the first word break on the left). The same applies to RTL text.
     
-    VisiblePosition wordBreak = hasSeenWordBreakInThisBox ? previousWordBreak : Position(box->renderer()->node(), box->caretMaxOffset(), Position::PositionIsOffsetInAnchor);
+    bool hasSeenWordBreakInThisBox = previousWordBreak.isNotNull();
 
-    // FIXME: handle multi-spaces (http://webkit.org/b/57543).
+    VisiblePosition wordBreak;
+
+    if (hasSeenWordBreakInThisBox)
+        wordBreak = previousWordBreak;
+    else {
+        wordBreak = Position(box->renderer()->node(), box->caretMaxOffset(), Position::PositionIsOffsetInAnchor);
+        // Return the rightmost word boundary of LTR box or leftmost word boundary of RTL box if
+        // it is not in the previously visited boxes. For example, given a logical text 
+        // "abc def     hij opq", there are 2 boxes: the "abc def " (starts at 0 and length is 8) 
+        // and the "hij opq" (starts at 12 and length is 7). The word breaks are 
+        // "abc |def |    hij |opq". We normally catch the word break between "def" and "hij" when
+        // we visit the box that contains "hij opq", but this word break doesn't exist in the box
+        // that contains "hij opq" when there are multiple spaces. So we detect it when we're
+        // traversing the box that contains "abc def " instead.
+
+        if ((box->isLeftToRightDirection() && box->nextLeafChild())
+            || (!box->isLeftToRightDirection() && box->prevLeafChild())) {
     
+            VisiblePosition positionAfterWord = nextWordPosition(wordBreak);
+            VisiblePosition positionBeforeWord = previousWordPosition(positionAfterWord);
+        
+            InlineBox* boxContainingPreviousWordBreak;
+            positionBeforeWord.getInlineBoxAndOffset(boxContainingPreviousWordBreak, offsetOfWordBreak);
+        
+            if (boxContainingPreviousWordBreak == box)
+                return positionBeforeWord;
+        }
+    }
+  
     wordBreak = previousWordPosition(wordBreak);
     if (previousWordBreak == wordBreak)
         return VisiblePosition();
@@ -1283,8 +1309,6 @@
     // we need to use nextWordPosition() to traverse words within the inline boxes from right to left to find the next word break.
     // The same applies to LTR text, in which words are traversed within the inline boxes from left to right.
     
-    // FIXME: handle multi-spaces (http://webkit.org/b/57543).
-    
     bool hasSeenWordBreakInThisBox = previousWordBreak.isNotNull();
     VisiblePosition wordBreak = hasSeenWordBreakInThisBox ? previousWordBreak : Position(box->renderer()->node(), box->caretMinOffset(), Position::PositionIsOffsetInAnchor);
     wordBreak = nextWordPosition(wordBreak);
@@ -1343,8 +1367,8 @@
     
     VisiblePosition wordBreak;
     int offsetOfWordBreak = invalidOffset;
+    bool isLastWordBreakInBox = false;
     while (1) {
-        bool isLastWordBreakInBox = false;
         wordBreak = nextWordBreakInBoxInsideBlockWithDifferentDirectionality(box, wordBreak, offsetOfWordBreak, isLastWordBreakInBox);
         if (wordBreak.isNotNull()) {
             WordBoundaryEntry wordBoundaryEntry(wordBreak, offsetOfWordBreak);
@@ -1446,7 +1470,7 @@
     VisiblePosition wordBreak;
     for  (const InlineBox* adjacentBox = box; adjacentBox; adjacentBox = adjacentBox->prevLeafChild()) {
         if (blockDirection == LTR) {
-            if (box->isLeftToRightDirection()) 
+            if (adjacentBox->isLeftToRightDirection()) 
                 wordBreak = previousWordBoundaryInBox(adjacentBox, adjacentBox == box ? offset : invalidOffset);
             else
                 wordBreak = nextWordBoundaryInBox(adjacentBox, adjacentBox == box ? offset : invalidOffset);
@@ -1464,7 +1488,7 @@
     VisiblePosition wordBreak;
     for (const InlineBox* adjacentBox = box; adjacentBox; adjacentBox = adjacentBox->nextLeafChild()) {
         if (blockDirection == RTL) {
-            if (box->isLeftToRightDirection())
+            if (adjacentBox->isLeftToRightDirection())
                 wordBreak = nextWordBoundaryInBox(adjacentBox, adjacentBox == box ? offset : invalidOffset);
             else
                 wordBreak = previousWordBoundaryInBox(adjacentBox, adjacentBox == box ? offset : invalidOffset);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to