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)
commit272e2129143a0c4409ae65fedc4e6053198d5fb3
treebc9f6b1811b6ff92225191cacb5ed53c269a6385
parentd73b17438b97ffec2976b39fee8861a4d542336e
Source/WebCore: 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):

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