Log Message
2011-05-25 Xiaomei Ji <x...@chromium.org> Reviewed by Ryosuke Niwa.
--webkit-visual-word does not work well in words separated by multiple spaces https://bugs.webkit.org/show_bug.cgi?id=61324 Remove positionBeforeNextWord and positionAfterPreviousWord short-cuts. They try to find the right word boundary (before the space or after the space) by using previousWordPosition and nextWordPosition. But they assume words are separated by single space and are not correct for words separated by multiple spaces and words not separated by space. Consider positionBeforeNextWord() for example, First, it checks whether the current position is after the current word by checking current position's previousWordPosition's nextWordPosition is the same as current position, which is wrong for words separated by multiple spaces. For example, given words A and B separated by 3 continuous spaces "A B", position "A|", "A |", and "A |" should all be considered as position after current word. But for position "A |", its previousWordPosition's nextWordPosition is position "A|", which is different from its current position, so the current position is not considered as a position after current word, consequently, instead of returning the right position as "A |B", positionBeforeNextWord returns the position before next next word, as "A B |C". Similar happens for position "A |". Second, given 3 Chinese words "ABC" that are not segmented by space, when cursor is at "A|BC", positionBeforeNextWord() returns the same position after calling current position's nextWordPosition's previousWordPosition. It should returns position "AB|C". For those cases, we will have to collect all the word breaks inside the box and look for the one at left or right of current position. * editing/visible_units.cpp: (WebCore::leftWordPosition): (WebCore::rightWordPosition): 2011-05-25 Xiaomei Ji <x...@chromium.org> Reviewed by Ryosuke Niwa. --webkit-visual-word does not work well in words separated by multiple spaces https://bugs.webkit.org/show_bug.cgi?id=61324 Add test cases for preserving white spaces and test case for words not separated by space. * editing/selection/move-by-word-visually-expected.txt: * editing/selection/move-by-word-visually.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (88358 => 88359)
--- trunk/LayoutTests/ChangeLog 2011-06-08 17:50:29 UTC (rev 88358)
+++ trunk/LayoutTests/ChangeLog 2011-06-08 18:03:07 UTC (rev 88359)
@@ -1,3 +1,15 @@
+2011-05-25 Xiaomei Ji <x...@chromium.org>
+
+ Reviewed by Ryosuke Niwa.
+
+ --webkit-visual-word does not work well in words separated by multiple spaces
+ https://bugs.webkit.org/show_bug.cgi?id=61324
+
+ Add test cases for preserving white spaces and test case for words not separated by space.
+
+ * editing/selection/move-by-word-visually-expected.txt:
+ * editing/selection/move-by-word-visually.html:
+
2011-06-08 Greg Simon <gregsi...@chromium.org>
Reviewed by Dimitri Glazkov.
Modified: trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt (88358 => 88359)
--- trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt 2011-06-08 17:50:29 UTC (rev 88358)
+++ trunk/LayoutTests/editing/selection/move-by-word-visually-expected.txt 2011-06-08 18:03:07 UTC (rev 88359)
@@ -198,20 +198,125 @@
" 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
+"abc def hij opq"[0, 4, 11, 15]
+Move left by one word
+"abc def hij opq"[18, 15, 11, 4, 0]
+Test 40, LTR:
+Move right by one word
+" abc def hij opq "[0, 4, 11, 18, 25]
+Move left by one word
+" abc def hij opq "[32, 25, 18, 11, 4, 0]
+Test 41, LTR:
+Move right by one word
+" abc ABW def "[0, 4, 11, 18]
+Move left by one word
+" abc ABW def "[25, 18, 11, 4, 0]
+Test 42, LTR:
+Move right by one word
+" abc def ABW DDU hij opq "[0, 4, 11, 18, 21, 32, 39]
+Move left by one word
+" abc def ABW DDU hij opq "[46, 39, 32, 21, 18, 11, 4, 0]
+Test 43, LTR:
+Move right by one word
+" abc def hij ABW DSU EJH opq rst uvw "[0, 4, 11, 18, 25, 35, 28, 46, 53, 60]
+Move left by one word
+" abc def hij ABW DSU EJH opq rst uvw "[67, 60, 53, 46, 28, 35, 25, 18, 11, 4, 0]
+Test 44, LTR:
+Move right by one word
+" ABW DSU HJH FUX "[0, 4, 21, 14, 7]
+Move left by one word
+" ABW DSU HJH FUX "[32, 7, 14, 21, 4, 0]
+Test 45, LTR:
+Move right by one word
+" ABW abc DSU "[0, 4, 11, 18]
+Move left by one word
+" ABW abc DSU "[26, 18, 11, 4, 0]
+Test 46, LTR:
+Move right by one word
+" ABW DSU abc def HJH FUX "[0, 4, 7, 18, 24, 30, 33]
+Move left by one word
+" ABW DSU abc def HJH FUX "[44, 33, 30, 24, 18, 7, 4, 0]
+Test 47, LTR:
+Move right by one word
+" ABW DSU HJH abc def jih FUX FUX YR[ "[0, 4, 14, 7, 25, 31, 37, 43, 51, 46]
+Move left by one word
+" ABW DSU HJH abc def jih FUX FUX YR[ "[63, 46, 51, 43, 37, 31, 25, 7, 14, 4, 0]
+Test 48, 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 49, LTR:
+Move right by one word
+"ABW DSU EJH abc def hij"[0, 7, 3, 15, 19, 23]
+Move left by one word
+"ABW DSU EJH abc def hij"[26, 23, 19, 15, 3, 7, 0]
+Test 50, LTR:
+Move right by one word
+"abc def hij ABW DSU EJH opq rst uvw"[0, 4, 8, 15, 22, 18, 30, 34, 38]
+Move left by one word
+"abc def hij ABW DSU EJH opq rst uvw"[41, 38, 34, 30, 18, 22, 15, 8, 4, 0]
+Test 51, 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 52, RTL:
+Move left by one word
+" abc def hij opq "[0, 4, 21, 14, 7]
+Move right by one word
+" abc def hij opq "[32, 7, 14, 21, 4, 0]
+Test 53, RTL:
+Move left by one word
+" abc ABW def "[0, 4, 11, 18]
+Move right by one word
+" abc ABW def "[25, 18, 11, 4, 0]
+Test 54, RTL:
+Move left by one word
+" abc def ABW DDU hij opq "[0, 4, 7, 18, 25, 32, 35]
+Move right by one word
+" abc def ABW DDU hij opq "[46, 35, 32, 25, 18, 7, 4, 0]
+Test 55, RTL:
+Move left by one word
+" abc def hij ABW DSU EJH opq rst uvw "[0, 4, 14, 7, 25, 32, 39, 46, 56, 49]
+Move right by one word
+" abc def hij ABW DSU EJH opq rst uvw "[67, 49, 56, 46, 39, 32, 25, 7, 14, 4, 0]
+Test 56, RTL:
+Move left by one word
+" ABW DSU HJH FUX "[0, 4, 11, 18, 25]
+Move right by one word
+" ABW DSU HJH FUX "[32, 25, 18, 11, 4, 0]
+Test 57, RTL:
+Move left by one word
+" ABW abc DSU "[0, 4, 11, 18]
+Move right by one word
+" ABW abc DSU "[26, 18, 11, 4, 0]
+Test 58, RTL:
+Move left by one word
+" ABW DSU abc def HJH FUX "[0, 4, 11, 18, 21, 30, 37]
+Move right by one word
+" ABW DSU abc def HJH FUX "[44, 37, 30, 21, 18, 11, 4, 0]
+Test 59, RTL:
+Move left by one word
+" ABW DSU HJH abc def jih FUX FUX YR[ "[0, 4, 11, 18, 25, 34, 28, 43, 48, 55]
+Move right by one word
+" ABW DSU HJH abc def jih FUX FUX YR[ "[63, 55, 48, 43, 28, 34, 25, 18, 11, 4, 0]
+Test 60, LTR:
+Move right by one word
"AAA "[0, 3]
Move left by one word
"BB"[2], "AAA "[3, 0]
-Test 40, RTL:
+Test 61, RTL:
Move left by one word
"AAA "[0, 4]
Move right by one word
"BB"[2], "AAA "[4, 0]
-Test 41, LTR:
+Test 62, 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 42, RTL:
+Test 63, 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]
@@ -224,7 +329,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 43, RTL:
+Test 64, 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]
@@ -237,37 +342,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 44, LTR:
+Test 65, 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 45, RTL:
+Test 66, 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 46, LTR:
+Test 67, 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 47, RTL:
+Test 68, 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 48, LTR:
+Test 69, 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 49, RTL:
+Test 70, 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 50, LTR:
+Test 71, 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
@@ -276,17 +381,17 @@
"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 51, RTL:
+Test 72, 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 52, LTR:
+Test 73, 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, 3, 0]
-Test 53, RTL:
+Test 74, RTL:
Move left by one word
"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]
@@ -295,7 +400,7 @@
Move right by one word
"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]
-Test 54, LTR:
+Test 75, 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]
@@ -314,28 +419,36 @@
"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 55, RTL:
+Test 76, RTL:
Move left by one word
"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 "[12, 8, 4, 0]
-Test 56, LTR:
+Test 77, 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 57, LTR:
+Test 78, 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:
+Test 79, 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"[18, 12] FAIL expected "abc uvw AAA def lmn"[ 15]
+"abc uvw AAA def lmn"[17, 12] FAIL expected "abc uvw AAA def lmn"[ 15]
+"abc uvw AAA def lmn"[16, 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]
+Test 80, LTR:
+Move right by one word
+"䤫䡱暘倎厘 疂崝烵 abc def"[0, 1, 2, 3, 4, 9, 10, 11, 17, 21]
+Move left by one word
+"䤫䡱暘倎厘 疂崝烵 abc def"[24, 21, 17, 11, 10, 9, 4, 3, 2, 1, 0]
Modified: trunk/LayoutTests/editing/selection/move-by-word-visually.html (88358 => 88359)
--- trunk/LayoutTests/editing/selection/move-by-word-visually.html 2011-06-08 17:50:29 UTC (rev 88358)
+++ trunk/LayoutTests/editing/selection/move-by-word-visually.html 2011-06-08 18:03:07 UTC (rev 88359)
@@ -120,10 +120,12 @@
var equal = true;
if (positions.length != wordBreaks.length)
equal = false;
- for (var i = 0; i < wordBreaks.length - 1; ++i) {
- if (!positionEqualToWordBreak(positions[i], wordBreaks[i])) {
- equal = false;
- break;
+ else {
+ for (var i = 0; i < wordBreaks.length - 1; ++i) {
+ if (!positionEqualToWordBreak(positions[i], wordBreaks[i])) {
+ equal = false;
+ break;
+ }
}
}
if (equal == false) {
@@ -363,7 +365,32 @@
<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>
+<!-- multispaces while preserving spaces -->
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 11 15|18 15 11 4 0" contenteditable>abc def hij opq</div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 11 18 25|32 25 18 11 4 0" contenteditable> abc def hij opq </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 11 18|25 18 11 4 0" contenteditable> abc אבצ def </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 11 18 21 32 39|46 39 32 21 18 11 4 0" contenteditable> abc def אבצ דדפ hij opq </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 11 18 25 35 28 46 53 60|67 60 53 46 28 35 25 18 11 4 0" contenteditable> abc def hij אבצ דעפ היח opq rst uvw </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 21 14 7|32 7 14 21 4 0" contenteditable> אבצ דעפ חיח ופק </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 11 18|26 18 11 4 0" contenteditable> אבצ abc דעפ </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 7 18 24 30 33|44 33 30 24 18 7 4 0" contenteditable> אבצ דעפ abc def חיח ופק </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 14 7 25 31 37 43 51 46|63 46 51 43 37 31 25 7 14 4 0" contenteditable> אבצ דעפ חיח abc def jih ופק ופק רסת </div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 14 7 3|18 3 7 14 0" contenteditable>אבצ דעפ היח ופק</div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 7 3 15 19 23|26 23 19 15 3 7 0" contenteditable>אבצ דעפ היח abc def hij</div>
+<div style="white-space:pre" dir=ltr class="test_move_by_word" title="0 4 8 15 22 18 30 34 38|41 38 34 30 18 22 15 8 4 0" contenteditable>abc def hij אבצ דעפ היח opq rst uvw</div>
+
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="18 3 7 14 0|0 14 7 3" contenteditable>abc def hij opq</div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="32 7 14 21 4 0|0 4 21 14 7" contenteditable> abc def hij opq </div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="25 18 11 4 0|0 4 11 18" contenteditable> abc אבצ def </div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="46 35 32 25 18 7 4 0|0 4 7 18 25 32 35" contenteditable> abc def אבצ דדפ hij opq </div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="67 49 56 46 39 32 25 7 14 4 0|0 4 14 7 25 32 39 46 56 49" contenteditable> abc def hij אבצ דעפ היח opq rst uvw </div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="32 25 18 11 4 0|0 4 11 18 25" contenteditable> אבצ דעפ חיח ופק </div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="26 18 11 4 0|0 4 11 18" contenteditable> אבצ abc דעפ </div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="44 37 30 21 18 11 4 0|0 4 11 18 21 30 37" contenteditable> אבצ דעפ abc def חיח ופק </div>
+<div style="white-space:pre" dir=rtl class="test_move_by_word" title="63 55 48 43 28 34 25 18 11 4 0|0 4 11 18 25 34 28 43 48 55" 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>
@@ -413,8 +440,11 @@
<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>
+
+<!-- test words not separated by spaces -->
+<div style="white-space:pre" contenteditable dir=ltr class="test_move_by_word" title="0 1 2 3 4 9 10 11 17 21|24 21 17 11 10 9 4 3 2 1 0">人一氧喝大 笑抬的 abc def</div>
+
</div>
-
<pre id="console"></pre>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (88358 => 88359)
--- trunk/Source/WebCore/ChangeLog 2011-06-08 17:50:29 UTC (rev 88358)
+++ trunk/Source/WebCore/ChangeLog 2011-06-08 18:03:07 UTC (rev 88359)
@@ -1,3 +1,38 @@
+2011-05-25 Xiaomei Ji <x...@chromium.org>
+
+ Reviewed by Ryosuke Niwa.
+
+ --webkit-visual-word does not work well in words separated by multiple spaces
+ https://bugs.webkit.org/show_bug.cgi?id=61324
+
+ Remove positionBeforeNextWord and positionAfterPreviousWord short-cuts. They try to find the
+ right word boundary (before the space or after the space) by using previousWordPosition and
+ nextWordPosition. But they assume words are separated by single space and are not correct
+ for words separated by multiple spaces and words not separated by space.
+
+ Consider positionBeforeNextWord() for example,
+
+ First, it checks whether the current position is after the current word by checking current
+ position's previousWordPosition's nextWordPosition is the same as current position, which is
+ wrong for words separated by multiple spaces. For example, given words A and B separated by
+ 3 continuous spaces "A B", position "A|", "A |", and "A |" should all be considered as
+ position after current word. But for position "A |", its previousWordPosition's
+ nextWordPosition is position "A|", which is different from its current position, so the
+ current position is not considered as a position after current word, consequently,
+ instead of returning the right position as "A |B", positionBeforeNextWord returns the
+ position before next next word, as "A B |C". Similar happens for position "A |".
+
+ Second, given 3 Chinese words "ABC" that are not segmented by space, when cursor is at
+ "A|BC", positionBeforeNextWord() returns the same position after calling current position's
+ nextWordPosition's previousWordPosition. It should returns position "AB|C".
+
+ For those cases, we will have to collect all the word breaks inside the box and look for
+ the one at left or right of current position.
+
+ * editing/visible_units.cpp:
+ (WebCore::leftWordPosition):
+ (WebCore::rightWordPosition):
+
2011-06-08 Greg Simon <gregsi...@chromium.org>
Reviewed by Dimitri Glazkov.
Modified: trunk/Source/WebCore/editing/visible_units.cpp (88358 => 88359)
--- trunk/Source/WebCore/editing/visible_units.cpp 2011-06-08 17:50:29 UTC (rev 88358)
+++ trunk/Source/WebCore/editing/visible_units.cpp 2011-06-08 18:03:07 UTC (rev 88359)
@@ -1508,32 +1508,6 @@
return box == boxOfWordBreak && offsetOfWordBreak != box->caretMaxOffset() && offsetOfWordBreak != box->caretMinOffset();
}
-static VisiblePosition positionBeforeNextWord(const VisiblePosition& position)
-{
- VisiblePosition positionAfterCurrentWord;
- if (nextWordPosition(previousWordPosition(position)) == position)
- positionAfterCurrentWord = position;
- else
- positionAfterCurrentWord = nextWordPosition(position);
- VisiblePosition positionAfterNextWord = nextWordPosition(positionAfterCurrentWord);
- if (positionAfterCurrentWord == positionAfterNextWord)
- return positionAfterCurrentWord;
- return previousWordPosition(positionAfterNextWord);
-}
-
-static VisiblePosition positionAfterPreviousWord(const VisiblePosition& position)
-{
- VisiblePosition positionBeforeCurrentWord;
- if (previousWordPosition(nextWordPosition(position)) == position)
- positionBeforeCurrentWord = position;
- else
- positionBeforeCurrentWord = previousWordPosition(position);
- VisiblePosition positionBeforePreviousWord = previousWordPosition(positionBeforeCurrentWord);
- if (positionBeforeCurrentWord == positionBeforePreviousWord)
- return positionBeforeCurrentWord;
- return nextWordPosition(positionBeforePreviousWord);
-}
-
VisiblePosition leftWordPosition(const VisiblePosition& visiblePosition)
{
InlineBox* box;
@@ -1551,18 +1525,13 @@
VisiblePosition wordBreak;
- if (box->direction() == blockDirection) {
- if (blockDirection == RTL)
- wordBreak = positionBeforeNextWord(visiblePosition);
- else
+ if (blockDirection == LTR) {
+ if (box->direction() == blockDirection)
wordBreak = previousWordPosition(visiblePosition);
- } else {
- if (blockDirection == RTL)
- wordBreak = positionAfterPreviousWord(visiblePosition);
else
wordBreak = nextWordPosition(visiblePosition);
}
- if (positionIsInsideBox(wordBreak, box))
+ if (wordBreak.isNotNull() && positionIsInsideBox(wordBreak, box))
return wordBreak;
WordBoundaryVector orderedWordBoundaries;
@@ -1589,18 +1558,13 @@
return rightWordBoundary(box->nextLeafChild(), invalidOffset, blockDirection);
VisiblePosition wordBreak;
- if (box->direction() == blockDirection) {
- if (blockDirection == LTR)
- wordBreak = positionBeforeNextWord(visiblePosition);
- else
+ if (blockDirection == RTL) {
+ if (box->direction() == blockDirection)
wordBreak = previousWordPosition(visiblePosition);
- } else {
- if (blockDirection == LTR)
- wordBreak = positionAfterPreviousWord(visiblePosition);
else
wordBreak = nextWordPosition(visiblePosition);
- }
- if (positionIsInsideBox(wordBreak, box))
+ }
+ if (wordBreak.isNotNull() && positionIsInsideBox(wordBreak, box))
return wordBreak;
WordBoundaryVector orderedWordBoundaries;
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes