Source/WebCore: Turn on move caret by word visually for Windows platform.
authorxji@chromium.org <xji@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 19:05:50 +0000 (19:05 +0000)
committerxji@chromium.org <xji@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 19:05:50 +0000 (19:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=59652

Reviewed by Ryosuke Niwa.

We already support (arrow key) moving cursor by character in visual order.
This patch implements (ctrl/alt-arrow) moving cursor by word in visual order (in Windows).
It matches Firefox's default behavior.

Without this patch, ctrl(alt for mac)-arrow key or
selection.modify("move", "left"/"right", "word") moves cursor by word in logical order.

IE implements moving cursor by logical order for both arrow key and ctrl-arrow key.
Firefox implements moving cursor by visual order for both operations.
From Chromium bug report, native speakers would like moving cursor by visual order since it
is more intuitive.

The patch is only enabled for Windows (by EditingBehavior) because current implementation
matches Windows' native behavior.
For exmaple, if the logical text is "abc def hij", the cursor positions are
"|abc |def |hij|" no matter pressing ctrl-left-arrow or ctrl-right-arrow.

Mac and Linux's native behavior is slightly different. In which, when pressing
ctrl-left-arrow, the cursor positions are "|abc |def |hij|". When pressing ctrl-right-arrow,
the cursor positions are "|abc| def| hij|". We will implement it next.

Test: editing/selection/move-left-right-by-word-mac.html

* editing/EditingBehavior.h:
(WebCore::EditingBehavior::shouldMoveLeftRightByWordInVisualOrder):
* editing/FrameSelection.cpp: Remove experimental enum WebKitVisualWordGranularity.
(WebCore::FrameSelection::modifyExtendingRight):
(WebCore::FrameSelection::modifyExtendingForward):
(WebCore::FrameSelection::modifyMovingRight):
(WebCore::FrameSelection::modifyMovingForward):
(WebCore::FrameSelection::modifyExtendingLeft):
(WebCore::FrameSelection::modifyExtendingBackward):
(WebCore::FrameSelection::modifyMovingLeft):
(WebCore::FrameSelection::modifyMovingBackward):
* editing/TextGranularity.h: Remove experimental enum WebKitVisualWordGranularity.
* editing/VisibleSelection.cpp: Remove experimental enum WebKitVisualWordGranularity.
(WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
* page/DOMSelection.cpp: Remove experimental experimental flag -webkit-visual-word.
(WebCore::DOMSelection::modify):

LayoutTests: Turn on move caret by word visually for windows platform.
https://bugs.webkit.org/show_bug.cgi?id=59652

Reviewed by Ryosuke Niwa.

* editing/selection/caret-mode-paragraph-keys-navigation.html:
* editing/selection/move-by-word-visually-crash-test-1.html:
* editing/selection/move-by-word-visually-crash-test-2.html:
* editing/selection/move-by-word-visually-crash-test-3.html:
* editing/selection/move-by-word-visually-crash-test-4.html:
* editing/selection/move-by-word-visually-crash-test-textarea.html:
* editing/selection/move-by-word-visually-inline-block-positioned-element.html:
* editing/selection/move-by-word-visually-multi-line.html:
* editing/selection/move-by-word-visually-multi-space.html:
* editing/selection/move-by-word-visually-null-box.html:
* editing/selection/move-by-word-visually-single-space-inline-element.html:
* editing/selection/move-by-word-visually-single-space-one-element.html:
* editing/selection/move-by-word-visually-textarea.html:
* editing/selection/move-left-right-by-word-mac-expected.txt: Added.
* editing/selection/move-left-right-by-word-mac.html: Added.
* editing/selection/resources/move-by-word-visually.js:
(moveByWord):
(moveByWordOnEveryChar):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@102252 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/selection/caret-mode-paragraph-keys-navigation.html
LayoutTests/editing/selection/move-by-word-visually-crash-test-1.html
LayoutTests/editing/selection/move-by-word-visually-crash-test-2.html
LayoutTests/editing/selection/move-by-word-visually-crash-test-3.html
LayoutTests/editing/selection/move-by-word-visually-crash-test-4.html
LayoutTests/editing/selection/move-by-word-visually-crash-test-textarea.html
LayoutTests/editing/selection/move-by-word-visually-inline-block-positioned-element.html
LayoutTests/editing/selection/move-by-word-visually-multi-line.html
LayoutTests/editing/selection/move-by-word-visually-multi-space.html
LayoutTests/editing/selection/move-by-word-visually-null-box.html
LayoutTests/editing/selection/move-by-word-visually-single-space-inline-element.html
LayoutTests/editing/selection/move-by-word-visually-single-space-one-element.html
LayoutTests/editing/selection/move-by-word-visually-textarea.html
LayoutTests/editing/selection/move-left-right-by-word-mac-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/move-left-right-by-word-mac.html [new file with mode: 0644]
LayoutTests/editing/selection/resources/move-by-word-visually.js
Source/WebCore/ChangeLog
Source/WebCore/editing/EditingBehavior.h
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/TextGranularity.h
Source/WebCore/editing/VisibleSelection.cpp
Source/WebCore/page/DOMSelection.cpp

index 66564d4..181a996 100644 (file)
@@ -1,3 +1,29 @@
+2011-12-07  Xiaomei Ji  <xji@chromium.org>
+
+        Turn on move caret by word visually for windows platform.
+        https://bugs.webkit.org/show_bug.cgi?id=59652
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/selection/caret-mode-paragraph-keys-navigation.html:
+        * editing/selection/move-by-word-visually-crash-test-1.html:
+        * editing/selection/move-by-word-visually-crash-test-2.html:
+        * editing/selection/move-by-word-visually-crash-test-3.html:
+        * editing/selection/move-by-word-visually-crash-test-4.html:
+        * editing/selection/move-by-word-visually-crash-test-textarea.html:
+        * editing/selection/move-by-word-visually-inline-block-positioned-element.html:
+        * editing/selection/move-by-word-visually-multi-line.html:
+        * editing/selection/move-by-word-visually-multi-space.html:
+        * editing/selection/move-by-word-visually-null-box.html:
+        * editing/selection/move-by-word-visually-single-space-inline-element.html:
+        * editing/selection/move-by-word-visually-single-space-one-element.html:
+        * editing/selection/move-by-word-visually-textarea.html:
+        * editing/selection/move-left-right-by-word-mac-expected.txt: Added.
+        * editing/selection/move-left-right-by-word-mac.html: Added.
+        * editing/selection/resources/move-by-word-visually.js:
+        (moveByWord):
+        (moveByWordOnEveryChar):
+
 2011-12-07  Balazs Kelemen  <kbalazs@webkit.org>
 
         Unreviewed gardening.
index 3d97172..d205289 100644 (file)
@@ -13,6 +13,7 @@ description("This tests that keys navigation through a paragraph work as expecte
 if (window.layoutTestController) {
   layoutTestController.overridePreference("WebKitEnableCaretBrowsing", true);
   layoutTestController.dumpAsText();
+  layoutTestController.setEditingBehavior('mac');
 
   var target = document.getElementById("target");
   target.focus();
index 35ce466..e8d8da5 100644 (file)
@@ -9,8 +9,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 <textarea></textarea>
 <base><div title="0|0" class="test_move_by_word">
index c8323aa..d10abe3 100644 (file)
@@ -9,8 +9,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 <vkern></vkern><marquee><div title="0|0" class="test_move_by_word">abc def
 
index 0c8782c..968ec02 100644 (file)
@@ -9,8 +9,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 <video></video><meter><image class="test_move_by_word" title="0|0">
 
index 33f4f06..fad8b1c 100644 (file)
@@ -9,7 +9,9 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 ><div title="0|0" class="test_move_by_word" dir=ltr><keygen><base>
index 94778fb..b069940 100644 (file)
@@ -15,8 +15,10 @@ onload = function() {
     document.body.innerHTML = "Crash test passed";
 };
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 
 <textarea dir=ltr title="0|0" id="test_move_by_word">At where are you</textarea>
index 54f04c4..36836d2 100644 (file)
@@ -9,8 +9,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 
 <div id="testMoveByWord" contenteditable style="width:2000px; height:2000px">
index 094f933..403539d 100644 (file)
@@ -17,8 +17,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController) 
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 </head>
 <body>
index a413fd4..b1096df 100644 (file)
@@ -17,8 +17,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController) 
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 </head>
 <body>
index f302279..1016ca2 100644 (file)
@@ -15,8 +15,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 <div id="console"></div>
 <div id="testMoveByWord">
index f0b369d..4869c98 100644 (file)
@@ -17,8 +17,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController) 
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 </head>
 <body>
index 9c257c0..3fbd3a6 100644 (file)
@@ -17,8 +17,10 @@ onload = function() {
     }
 };
 
-if (window.layoutTestController) 
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 </head>
 <body>
index b0853fc..903fb9a 100644 (file)
@@ -17,7 +17,7 @@ onload = function() {
     var i;
     for (i = 0; i < 5; ++i) {
         var start = test.selectionStart;
-        sel.modify("move", "right", "-webkit-visual-word");
+        sel.modify("move", "right", "word");
         var wordBreak;
         if (i >= wordBreaks.length)
             wordBreak = wordBreaks[wordBreaks.length - 1];
@@ -33,8 +33,10 @@ onload = function() {
         testPassed("Pass");
 }
 
-if (window.layoutTestController)
+if (window.layoutTestController) {
     layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('win');
+}
 </script>
 
 <textarea title = "5 10 17 27" dir=ltr id="test_move_by_word"></textarea>
diff --git a/LayoutTests/editing/selection/move-left-right-by-word-mac-expected.txt b/LayoutTests/editing/selection/move-left-right-by-word-mac-expected.txt
new file mode 100644 (file)
index 0000000..9f7cfa0
--- /dev/null
@@ -0,0 +1,86 @@
+Test 1, LTR:
+Move right by one word
+"abc def hij opq rst"[0, 3, 7, 11, 15, 19]
+Move left by one word
+"abc def hij opq rst"[19, 16, 12, 8, 4, 0]
+Test 2, RTL:
+Move right by one word
+"abc def hij opq rst"[0, 3, 7, 11, 15, 19]
+Move left by one word
+"abc def hij opq rst"[19, 16, 12, 8, 4, 0]
+Test 3, LTR:
+Move right by one word
+"ZZZ QQQ BBB CCC XXX"[0, 3, 7, 11, 15, 19]
+Move left by one word
+"ZZZ QQQ BBB CCC XXX"[19, 16, 12, 8, 4, 0]
+Test 4, RTL:
+Move right by one word
+"ZZZ QQQ BBB CCC XXX"[0, 3, 7, 11, 15, 19]
+Move left by one word
+"ZZZ QQQ BBB CCC XXX"[19, 16, 12, 8, 4, 0]
+Test 5, LTR:
+Move right by one word
+"abc def hij AAA BBB WWW opr uvw xyz"[0, 3, 7, 11, 15, 19, 23, 27, 31, 35]
+Move left by one word
+"abc def hij AAA BBB WWW opr uvw xyz"[35, 32, 28, 24, 20, 16, 12, 8, 4, 0]
+Test 6, RTL:
+Move right by one word
+"abc def hij AAA BBB WWW opr uvw xyz"[0, 3, 7, 11, 15, 19, 23, 27, 31, 35]
+Move left by one word
+"abc def hij AAA BBB WWW opr uvw xyz"[35, 32, 28, 24, 20, 16, 12, 8, 4, 0]
+Test 7, LTR:
+Move right by one word
+"abc def ZQB RIG uvw xyz"[0, 3, 7, 11, 15, 19, 23]
+Move left by one word
+"abc def ZQB RIG uvw xyz"[23, 20, 16, 12, 8, 4, 0]
+Test 8, RTL:
+Move right by one word
+"abc def ZQB RIG uvw xyz"[0, 3, 7, 11, 15, 19, 23]
+Move left by one word
+"abc def ZQB RIG uvw xyz"[23, 20, 16, 12, 8, 4, 0]
+Test 9, LTR:
+Move right by one word
+"aaa AAA bbb"[0, 3, 7, 11]
+Move left by one word
+"aaa AAA bbb"[11, 8, 4, 0]
+Test 10, RTL:
+Move right by one word
+"aaa AAA bbb"[0, 3, 7, 11]
+Move left by one word
+"aaa AAA bbb"[11, 8, 4, 0]
+Test 11, LTR:
+Move right by one word
+"AAA BBB WWW aaa bbb ccc DDD SSS UUU"[0, 3, 7, 11, 15, 19, 23, 27, 31, 35]
+Move left by one word
+"AAA BBB WWW aaa bbb ccc DDD SSS UUU"[35, 32, 28, 24, 20, 16, 12, 8, 4, 0]
+Test 12, RTL:
+Move right by one word
+"AAA BBB WWW aaa bbb ccc DDD SSS UUU"[0, 3, 7, 11, 15, 19, 23, 27, 31, 35]
+Move left by one word
+"AAA BBB WWW aaa bbb ccc DDD SSS UUU"[35, 32, 28, 24, 20, 16, 12, 8, 4, 0]
+Test 13, LTR:
+Move right by one word
+"AAA BBB aaa bbb WWW DDD"[0, 3, 7, 11, 15, 19, 23]
+Move left by one word
+"AAA BBB aaa bbb WWW DDD"[23, 20, 16, 12, 8, 4, 0]
+Test 14, RTL:
+Move right by one word
+"AAA BBB aaa bbb WWW DDD"[0, 3, 7, 11, 15, 19, 23]
+Move left by one word
+"AAA BBB aaa bbb WWW DDD"[23, 20, 16, 12, 8, 4, 0]
+Test 15, LTR:
+Move right by one word
+"ZQB abc RIG"[0, 3, 7, 11]
+Move left by one word
+"ZQB abc RIG"[11, 8, 4, 0]
+Test 16, RTL:
+Move right by one word
+"ZQB abc RIG"[0, 3, 7, 11]
+Move left by one word
+"ZQB abc RIG"[11, 8, 4, 0]
+Test 17, LTR:
+Move right by one word
+"abc def    hij opq"[0, 3, 7, 14, 18]
+Move left by one word
+"abc def    hij opq"[18, 15, 8, 4, 0]
+
diff --git a/LayoutTests/editing/selection/move-left-right-by-word-mac.html b/LayoutTests/editing/selection/move-left-right-by-word-mac.html
new file mode 100644 (file)
index 0000000..16bfd60
--- /dev/null
@@ -0,0 +1,86 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link rel="stylesheet" type="text/css" href="resources/extend-selection.css" />
+<style>
+test_move_by_word {display: none;}
+</style>
+<script src="resources/move-by-word-visually.js"></script>
+<script>
+
+onload = function() {
+    try {
+        var tests = document.getElementsByClassName("test_move_by_word");
+        var sel = getSelection();
+        for (var i = 0; i < tests.length; ++i) {
+            if (tests[i].getAttribute("dir") == 'ltr')
+                log("Test " + (i + 1) + ", LTR:\n");
+            else
+                log("Test " + (i + 1) + ", RTL:\n");
+            sel.setPosition(tests[i], 0);
+            moveByWord(sel, tests[i], "right");
+            moveByWord(sel, tests[i], "left");
+        }
+        if (document.getElementById("testMoveByWord"))
+            document.getElementById("testMoveByWord").style.display = "none";
+    } finally {
+        flushLog();
+    }
+};
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.setEditingBehavior('mac');
+}
+</script>
+</head>
+<body>
+<div id="testMoveByWord">
+<!-- 
+Title saves the word breaks.
+The format of title is "xxx|xxxx".
+
+The sequence on the left of "|" is word boundaries when moving caret from left to right.
+The sequence on the right of "|" is word boundaries when moving caret from right to left.
+
+If there is a single node in the line, the sequence are offsets.
+If there are multiple nodes in the line, the sequence is array of [anchor_node_id, offset, child_node_index], 
+where child_node_index is optional, default is the first child of the anchor node.
+-->
+<!-- pure English -->
+<div dir=ltr class="test_move_by_word" title="0 3 7 11 15 19|19 16 12 8 4 0" contenteditable>abc def hij opq rst</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11 15 19|19 16 12 8 4 0" contenteditable>abc def hij opq rst</div>
+
+<!-- pure Hebrew -->
+<div dir=ltr class="test_move_by_word" title="0 3 7 11 15 19|19 16 12 8 4 0" contenteditable>ששש נננ בבב גגג קקק</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11 15 19|19 16 12 8 4 0" contenteditable>ששש נננ בבב גגג קקק</div>
+
+<!-- bidi text -->
+<!-- English Hebrew English -->
+<div dir=ltr class="test_move_by_word" title="0 3 7 11 15 19 23 27 31 35|35 32 28 24 20 16 12 8 4 0" contenteditable>abc def hij אאא בבב צצצ opr uvw xyz</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11 15 19 23 27 31 35|35 32 28 24 20 16 12 8 4 0" contenteditable>abc def hij אאא בבב צצצ opr uvw xyz</div>
+
+<div dir=ltr class="test_move_by_word" title="0 3 7 11 15 19 23|23 20 16 12 8 4 0" contenteditable>abc def שנב סטז uvw xyz</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11 15 19 23|23 20 16 12 8 4 0" contenteditable>abc def שנב סטז uvw xyz</div>
+
+<div dir=ltr class="test_move_by_word" title="0 3 7 11|11 8 4 0" contenteditable>aaa אאא bbb</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11|11 8 4 0" contenteditable>aaa אאא bbb</div>
+
+<!-- Hebrew English Hebrew -->
+<div dir=ltr class="test_move_by_word" title="0 3 7 11 15 19 23 27 31 35|35 32 28 24 20 16 12 8 4 0" contenteditable>אאא בבב צצצ aaa bbb ccc דדד עעע פפפ</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11 15 19 23 27 31 35|35 32 28 24 20 16 12 8 4 0" contenteditable>אאא בבב צצצ aaa bbb ccc דדד עעע פפפ</div>
+
+<div dir=ltr class="test_move_by_word" title="0 3 7 11 15 19 23|23 20 16 12 8 4 0" contenteditable>אאא בבב aaa bbb צצצ דדד</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11 15 19 23|23 20 16 12 8 4 0" contenteditable>אאא בבב aaa bbb צצצ דדד</div>
+
+<div dir=ltr class="test_move_by_word" title="0 3 7 11|11 8 4 0" contenteditable>שנב abc סטז</div>
+<div dir=rtl class="test_move_by_word" title="0 3 7 11|11 8 4 0" contenteditable>שנב abc סטז</div>
+
+<div id="multispace" dir=ltr class="test_move_by_word" title="0 3 7 14 18|18 15 8 4 0" contenteditable>abc def    hij opq</div>
+
+</div>
+
+<pre id="console"></pre>
+</body>
+</html>
index e97f762..0bcd335 100644 (file)
@@ -155,7 +155,7 @@ function moveByWord(sel, test, searchDirection, dir)
     positions.push({ node: sel.anchorNode, offset: sel.anchorOffset });
 
     while (1) {
-        sel.modify("move", searchDirection, "-webkit-visual-word");
+        sel.modify("move", searchDirection, "word");
         if (prevNode == sel.anchorNode && prevOffset == sel.anchorOffset)
             break;
         positions.push({ node: sel.anchorNode, offset: sel.anchorOffset });
@@ -178,7 +178,7 @@ function moveByWordOnEveryChar(sel, test, searchDirection, dir)
     while (1) {
         var positions = [];
         positions.push({ node: sel.anchorNode, offset: sel.anchorOffset });
-        sel.modify("move", searchDirection, "-webkit-visual-word");
+        sel.modify("move", searchDirection, "word");
 
         var position = { node: sel.anchorNode, offset: sel.anchorOffset };
 
index 8f86247..d673ef4 100644 (file)
@@ -1,3 +1,50 @@
+2011-12-07  Xiaomei Ji  <xji@chromium.org>
+
+        Turn on move caret by word visually for Windows platform.
+        https://bugs.webkit.org/show_bug.cgi?id=59652
+
+        Reviewed by Ryosuke Niwa.
+
+        We already support (arrow key) moving cursor by character in visual order.
+        This patch implements (ctrl/alt-arrow) moving cursor by word in visual order (in Windows).
+        It matches Firefox's default behavior.
+
+        Without this patch, ctrl(alt for mac)-arrow key or
+        selection.modify("move", "left"/"right", "word") moves cursor by word in logical order. 
+
+        IE implements moving cursor by logical order for both arrow key and ctrl-arrow key.
+        Firefox implements moving cursor by visual order for both operations.
+        From Chromium bug report, native speakers would like moving cursor by visual order since it
+        is more intuitive.
+
+        The patch is only enabled for Windows (by EditingBehavior) because current implementation
+        matches Windows' native behavior.
+        For exmaple, if the logical text is "abc def hij", the cursor positions are
+        "|abc |def |hij|" no matter pressing ctrl-left-arrow or ctrl-right-arrow.
+
+        Mac and Linux's native behavior is slightly different. In which, when pressing
+        ctrl-left-arrow, the cursor positions are "|abc |def |hij|". When pressing ctrl-right-arrow,
+        the cursor positions are "|abc| def| hij|". We will implement it next.
+
+        Test: editing/selection/move-left-right-by-word-mac.html
+
+        * editing/EditingBehavior.h:
+        (WebCore::EditingBehavior::shouldMoveLeftRightByWordInVisualOrder):
+        * editing/FrameSelection.cpp: Remove experimental enum WebKitVisualWordGranularity.
+        (WebCore::FrameSelection::modifyExtendingRight):
+        (WebCore::FrameSelection::modifyExtendingForward):
+        (WebCore::FrameSelection::modifyMovingRight):
+        (WebCore::FrameSelection::modifyMovingForward):
+        (WebCore::FrameSelection::modifyExtendingLeft):
+        (WebCore::FrameSelection::modifyExtendingBackward):
+        (WebCore::FrameSelection::modifyMovingLeft):
+        (WebCore::FrameSelection::modifyMovingBackward):
+        * editing/TextGranularity.h: Remove experimental enum WebKitVisualWordGranularity.
+        * editing/VisibleSelection.cpp: Remove experimental enum WebKitVisualWordGranularity.
+        (WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
+        * page/DOMSelection.cpp: Remove experimental experimental flag -webkit-visual-word.
+        (WebCore::DOMSelection::modify):
+
 2011-12-07  Jonathan Backer  <backer@chromium.org>
 
         [chromium] Plumb damage from WebExternalTextureLayer and WebPluginContainer to CCDamageTracker
index 003ddf8..720f38a 100644 (file)
@@ -59,6 +59,10 @@ public:
 
     // On Mac, when processing a contextual click, the object being clicked upon should be selected.
     bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior; }
+    
+    // On Windows, moving caret left or right by word moves the caret by word in visual order. 
+    // It moves the caret by word in logical order in other platforms.
+    bool shouldMoveLeftRightByWordInVisualOrder() const { return m_type == EditingWindowsBehavior; }
 
     // On Mac and Windows, pressing backspace (when it isn't handled otherwise) should navigate back.
     bool shouldNavigateBackOnBackspace() const { return m_type != EditingUnixBehavior; }
index 38861c5..89b665c 100644 (file)
@@ -572,8 +572,6 @@ VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity
         // FIXME: implement all of the above?
         pos = modifyExtendingForward(granularity);
         break;
-    case WebKitVisualWordGranularity:
-        break;
     }
     return pos;
 }
@@ -613,8 +611,6 @@ VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari
         else
             pos = endOfDocument(pos);
         break;
-    case WebKitVisualWordGranularity:
-        break;
     }
     
     return pos;
@@ -634,7 +630,8 @@ VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity)
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).right(true);
         break;
     case WordGranularity:
-        if (visualWordMovementEnabled()) {
+        if (visualWordMovementEnabled()
+            || (m_frame && m_frame->editor()->behavior().shouldMoveLeftRightByWordInVisualOrder())) {
             pos = rightWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()));
             break;
         }
@@ -650,9 +647,6 @@ VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity)
     case LineBoundary:
         pos = rightBoundaryOfLine(startForPlatform(), directionOfEnclosingBlock());
         break;
-    case WebKitVisualWordGranularity:
-        pos = rightWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()));
-        break;
     }
     return pos;
 }
@@ -701,8 +695,6 @@ VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity)
         else
             pos = endOfDocument(pos);
         break;
-    case WebKitVisualWordGranularity:
-        break;
     }
     return pos;
 }
@@ -743,8 +735,6 @@ VisiblePosition FrameSelection::modifyExtendingLeft(TextGranularity granularity)
     case DocumentBoundary:
         pos = modifyExtendingBackward(granularity);
         break;
-    case WebKitVisualWordGranularity:
-        break;
     }
     return pos;
 }
@@ -789,8 +779,6 @@ VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular
         else
             pos = startOfDocument(pos);
         break;
-    case WebKitVisualWordGranularity:
-        break;
     }
     return pos;
 }
@@ -809,7 +797,8 @@ VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity)
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).left(true);
         break;
     case WordGranularity:
-        if (visualWordMovementEnabled()) {
+        if (visualWordMovementEnabled()
+            || (m_frame && m_frame->editor()->behavior().shouldMoveLeftRightByWordInVisualOrder())) {
             pos = leftWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()));
             break;
         }
@@ -825,9 +814,6 @@ VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity)
     case LineBoundary:
         pos = leftBoundaryOfLine(startForPlatform(), directionOfEnclosingBlock());
         break;
-    case WebKitVisualWordGranularity:
-        pos = leftWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()));
-        break;
     }
     return pos;
 }
@@ -870,8 +856,6 @@ VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
         else
             pos = startOfDocument(pos);
         break;
-    case WebKitVisualWordGranularity:
-        break;
     }
     return pos;
 }
index 965d7a0..09cc4ed 100644 (file)
@@ -39,10 +39,7 @@ enum TextGranularity {
     SentenceBoundary,
     LineBoundary,
     ParagraphBoundary,
-    DocumentBoundary,
-    // FIXME: this is added temporarily for experiment with visually move
-    // caret by wordGranularity. Once all patches are landed, it should be removed.
-    WebKitVisualWordGranularity
+    DocumentBoundary
 };
 
 }
index 12d08f2..e64739d 100644 (file)
@@ -386,8 +386,6 @@ void VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity(Text
             m_start = startOfSentence(VisiblePosition(m_start, m_affinity)).deepEquivalent();
             m_end = endOfSentence(VisiblePosition(m_end, m_affinity)).deepEquivalent();
             break;
-        case WebKitVisualWordGranularity:
-            break;
     }
     
     // Make sure we do not have a dangling start or end.
index fe24e1e..23ad2de 100644 (file)
@@ -333,8 +333,6 @@ void DOMSelection::modify(const String& alterString, const String& directionStri
         granularity = ParagraphBoundary;
     else if (equalIgnoringCase(granularityString, "documentboundary"))
         granularity = DocumentBoundary;
-    else if (equalIgnoringCase(granularityString, "-webkit-visual-word"))
-        granularity = WebKitVisualWordGranularity;
     else
         return;