-
xji@chromium.org authored
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: http://svn.webkit.org/repository/webkit/trunk@102252 268f45cc-cd09-0410-ab3c-d52691b4dbfc
8fc6abdc