Changeset 115788 in webkit
- Timestamp:
- May 1, 2012 8:41:29 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r115787 r115788 1 2012-05-01 Xiaomei Ji <xji@chromium.org> 2 3 enable ctrl-arrow move by word visually in other platforms (besides Windows) 4 https://bugs.webkit.org/show_bug.cgi?id=85017 5 6 Reviewed by Ryosuke Niwa. 7 8 Since DOMSelection.modify('move', 'left'/'right', 'word') moves caret by word in visual order (instead of 9 logical order) now, there are several changes to the test file: 10 1. file name renamed from move-left-right-by-word-mac.html to move-by-word-visually-mac.html. 11 2. test expectations change from moving caret by word in logical order to moving caret by word in visual order. 12 3. since test expectations are inside test file itself, test file itself changes accordingly. 13 14 * editing/selection/move-by-word-visually-mac-expected.txt: Copied from LayoutTests/editing/selection/move-left-right-by-word-mac-expected.txt. 15 * editing/selection/move-by-word-visually-mac.html: Copied from LayoutTests/editing/selection/move-left-right-by-word-mac.html. 16 * editing/selection/move-left-right-by-word-mac-expected.txt: Removed. 17 * editing/selection/move-left-right-by-word-mac.html: Removed. 18 1 19 2012-05-01 Raymond Liu <raymond.liu@intel.com> 2 20 -
trunk/Source/WebCore/ChangeLog
r115787 r115788 1 2012-05-01 Xiaomei Ji <xji@chromium.org> 2 3 enable ctrl-arrow move by word visually in non-Windows platforms. 4 https://bugs.webkit.org/show_bug.cgi?id=85017 5 6 Reviewed by Ryosuke Niwa. 7 8 Enable ctrl-arrow moves caret by word in visual order in non-Windows platforms that use ICU word 9 break iterator (it is not enabled for WinCE and Qt where ICU is not used). For those platforms, ctrl-arrow 10 moves caret to word break position before spaces. For example, given a logical text "abc def hij", the word 11 break positions using ctrl-left-arrow from rightmost position are "|abc |def |hij". 12 The word break positions using ctrl-right-arrow from leftmost position are "abc| def| hij|". 13 14 Test: editing/selection/move-by-word-visually-mac.html 15 16 * editing/EditingBehavior.h: 17 (EditingBehavior): 18 (WebCore::EditingBehavior::shouldEatSpaceToNextWord): To control different word break positions 19 (regards to space) for different platforms. 20 * editing/FrameSelection.cpp: 21 (WebCore::FrameSelection::modifyMovingRight): Enable visual word movement for all platforms that use ICU. 22 (WebCore::FrameSelection::modifyMovingLeft): 23 * editing/visible_units.cpp: 24 (WebCore::visualWordPosition): Determine the right word break position (regards to space) based on EditingBehavior. 25 (WebCore::leftWordPosition): 26 (WebCore::rightWordPosition): 27 * editing/visible_units.h: 28 1 29 2012-05-01 Raymond Liu <raymond.liu@intel.com> 2 30 -
trunk/Source/WebCore/editing/EditingBehavior.h
r105473 r115788 61 61 bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior; } 62 62 63 // On Windows, moving caret left or right by word moves the caret by word in visual order.64 // It moves the caret by word in logical order in other platforms.65 bool shouldMoveLeftRightByWordInVisualOrder() const { return m_type == EditingWindowsBehavior; }66 67 63 // On Mac and Windows, pressing backspace (when it isn't handled otherwise) should navigate back. 68 64 bool shouldNavigateBackOnBackspace() const { return m_type != EditingUnixBehavior; } … … 73 69 bool shouldExtendSelectionByWordOrLineAcrossCaret() const { return m_type != EditingMacBehavior; } 74 70 71 // Based on native behavior, when using ctrl(alt)+arrow to move caret by word, ctrl(alt)+left arrow moves caret to 72 // immediately before the word in all platforms, for example, the word break positions are: "|abc |def |hij |opq". 73 // But ctrl+right arrow moves caret to "abc |def |hij |opq" on Windows and "abc| def| hij| opq|" on Mac and Linux. 74 bool shouldSkipSpaceWhenMovingRight() const { return m_type == EditingWindowsBehavior; } 75 75 76 private: 76 77 EditingBehaviorType m_type; -
trunk/Source/WebCore/editing/FrameSelection.cpp
r115097 r115788 641 641 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).right(true); 642 642 break; 643 case WordGranularity: 644 #if !OS(WINCE) 645 // Visual word movement relies on isWordTextBreak which is not implemented in WinCE. 646 if (visualWordMovementEnabled() 647 || (m_frame && m_frame->editor()->behavior().shouldMoveLeftRightByWordInVisualOrder())) { 648 pos = rightWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity())); 649 break; 650 } 643 case WordGranularity: { 644 #if USE(ICU_UNICODE) 645 // Visual word movement relies on isWordTextBreak which is not implemented in WinCE and QT. 646 // https://bugs.webkit.org/show_bug.cgi?id=81136. 647 bool skipsSpaceWhenMovingRight = m_frame && m_frame->editor()->behavior().shouldSkipSpaceWhenMovingRight(); 648 pos = rightWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()), skipsSpaceWhenMovingRight); 649 break; 651 650 #endif 651 } 652 652 case SentenceGranularity: 653 653 case LineGranularity: … … 811 811 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).left(true); 812 812 break; 813 case WordGranularity: 814 #if !OS(WINCE) 815 if (visualWordMovementEnabled() 816 || (m_frame && m_frame->editor()->behavior().shouldMoveLeftRightByWordInVisualOrder())) { 817 pos = leftWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity())); 818 break; 819 } 813 case WordGranularity: { 814 #if USE(ICU_UNICODE) 815 bool skipsSpaceWhenMovingRight = m_frame && m_frame->editor()->behavior().shouldSkipSpaceWhenMovingRight(); 816 pos = leftWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()), skipsSpaceWhenMovingRight); 817 break; 820 818 #endif 819 } 821 820 case SentenceGranularity: 822 821 case LineGranularity: -
trunk/Source/WebCore/editing/visible_units.cpp
r113990 r115788 368 368 enum CursorMovementDirection { MoveLeft, MoveRight }; 369 369 370 static VisiblePosition visualWordPosition(const VisiblePosition& visiblePosition, CursorMovementDirection direction) 370 static VisiblePosition visualWordPosition(const VisiblePosition& visiblePosition, CursorMovementDirection direction, 371 bool skipsSpaceWhenMovingRight) 371 372 { 372 373 if (visiblePosition.isNull()) … … 419 420 420 421 bool isWordBreak; 421 if (box->direction() == blockDirection) { 422 bool boxHasSameDirectionalityAsBlock = box->direction() == blockDirection; 423 bool movingBackward = (direction == MoveLeft && box->direction() == LTR) || (direction == MoveRight && box->direction() == RTL); 424 if ((skipsSpaceWhenMovingRight && boxHasSameDirectionalityAsBlock) 425 || (!skipsSpaceWhenMovingRight && movingBackward)) { 422 426 bool logicalStartInRenderer = offsetInBox == static_cast<int>(textBox->start()) && previousBoxInDifferentBlock; 423 427 isWordBreak = isLogicalStartOfWord(iter, offsetInIterator, logicalStartInRenderer); … … 435 439 } 436 440 437 VisiblePosition leftWordPosition(const VisiblePosition& visiblePosition )438 { 439 VisiblePosition leftWordBreak = visualWordPosition(visiblePosition, MoveLeft );441 VisiblePosition leftWordPosition(const VisiblePosition& visiblePosition, bool skipsSpaceWhenMovingRight) 442 { 443 VisiblePosition leftWordBreak = visualWordPosition(visiblePosition, MoveLeft, skipsSpaceWhenMovingRight); 440 444 leftWordBreak = visiblePosition.honorEditingBoundaryAtOrBefore(leftWordBreak); 441 445 … … 448 452 } 449 453 450 VisiblePosition rightWordPosition(const VisiblePosition& visiblePosition )451 { 452 VisiblePosition rightWordBreak = visualWordPosition(visiblePosition, MoveRight );454 VisiblePosition rightWordPosition(const VisiblePosition& visiblePosition, bool skipsSpaceWhenMovingRight) 455 { 456 VisiblePosition rightWordBreak = visualWordPosition(visiblePosition, MoveRight, skipsSpaceWhenMovingRight); 453 457 rightWordBreak = visiblePosition.honorEditingBoundaryAtOrBefore(rightWordBreak); 454 458 -
trunk/Source/WebCore/editing/visible_units.h
r104276 r115788 27 27 #define visible_units_h 28 28 29 #include "EditingBehaviorTypes.h" 29 30 #include "EditingBoundary.h" 30 31 #include "TextDirection.h" … … 42 43 VisiblePosition previousWordPosition(const VisiblePosition &); 43 44 VisiblePosition nextWordPosition(const VisiblePosition &); 44 VisiblePosition rightWordPosition(const VisiblePosition& );45 VisiblePosition leftWordPosition(const VisiblePosition& );45 VisiblePosition rightWordPosition(const VisiblePosition&, bool skipsSpaceWhenMovingRight); 46 VisiblePosition leftWordPosition(const VisiblePosition&, bool skipsSpaceWhenMovingRight); 46 47 bool isStartOfWord(const VisiblePosition&); 47 48
Note: See TracChangeset
for help on using the changeset viewer.