Changeset 76312 in webkit
- Timestamp:
- Jan 20, 2011 5:21:11 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r76307 r76312 1 2011-01-20 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 RTL: Caret goes to the opposite direction when pressing an arrow key after selection is made 6 https://bugs.webkit.org/show_bug.cgi?id=49511 7 8 * editing/editing.js: 9 (execMoveSelectionLeftByCharacterCommand): 10 (moveSelectionLeftByCharacterCommand): 11 (execMoveSelectionRightByCharacterCommand): 12 (moveSelectionRightByCharacterCommand): 13 (execExtendSelectionLeftByCharacterCommand): 14 (extendSelectionLeftByCharacterCommand): 15 (execExtendSelectionRightByCharacterCommand): 16 (extendSelectionRightByCharacterCommand): 17 Adding some left/right selection convenience methods for use with RTL tests. 18 19 * editing/selection/rtl-move-selection-right-left-expected.txt: Added. 20 * editing/selection/rtl-move-selection-right-left.html: Added. 21 1 22 2011-01-20 Tony Chang <tony@chromium.org> 2 23 -
trunk/LayoutTests/editing/editing.js
r55913 r76312 35 35 else { 36 36 execTransposeCharactersCommand(); 37 } 38 } 39 40 //------------------------------------------------------------------------------------------------------- 41 42 function execMoveSelectionLeftByCharacterCommand() { 43 selection.modify("move", "left", "character"); 44 } 45 function moveSelectionLeftByCharacterCommand() { 46 if (commandDelay > 0) { 47 window.setTimeout(execMoveSelectionLeftByCharacterCommand, commandCount * commandDelay); 48 commandCount++; 49 } 50 else { 51 execMoveSelectionLeftByCharacterCommand(); 52 } 53 } 54 55 //------------------------------------------------------------------------------------------------------- 56 57 function execMoveSelectionRightByCharacterCommand() { 58 selection.modify("move", "Right", "character"); 59 } 60 function moveSelectionRightByCharacterCommand() { 61 if (commandDelay > 0) { 62 window.setTimeout(execMoveSelectionRightByCharacterCommand, commandCount * commandDelay); 63 commandCount++; 64 } 65 else { 66 execMoveSelectionRightByCharacterCommand(); 67 } 68 } 69 70 //------------------------------------------------------------------------------------------------------- 71 72 function execExtendSelectionLeftByCharacterCommand() { 73 selection.modify("extend", "left", "character"); 74 } 75 function extendSelectionLeftByCharacterCommand() { 76 if (commandDelay > 0) { 77 window.setTimeout(execExtendSelectionLeftByCharacterCommand, commandCount * commandDelay); 78 commandCount++; 79 } 80 else { 81 execExtendSelectionLeftByCharacterCommand(); 82 } 83 } 84 85 //------------------------------------------------------------------------------------------------------- 86 87 function execExtendSelectionRightByCharacterCommand() { 88 selection.modify("extend", "Right", "character"); 89 } 90 function extendSelectionRightByCharacterCommand() { 91 if (commandDelay > 0) { 92 window.setTimeout(execExtendSelectionRightByCharacterCommand, commandCount * commandDelay); 93 commandCount++; 94 } 95 else { 96 execExtendSelectionRightByCharacterCommand(); 37 97 } 38 98 } -
trunk/Source/WebCore/ChangeLog
r76303 r76312 1 2011-01-20 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 RTL: Caret goes to the opposite direction when pressing an arrow key after selection is made 6 https://bugs.webkit.org/show_bug.cgi?id=49511 7 8 Test: editing/selection/rtl-move-selection-right-left.html 9 10 * editing/SelectionController.cpp: 11 (WebCore::SelectionController::willBeModified): 12 Respecting the direction of the containing block when switching selection base and extent in 13 RTL content. 14 15 (WebCore::SelectionController::modifyMovingRight): 16 (WebCore::SelectionController::modifyMovingLeft): 17 Using directionOfEnclosingBlock when deciding to use the selection start or end to do the 18 correct thing for RTL. 19 1 20 2011-01-20 Nate Chapin <japhet@chromium.org> 2 21 -
trunk/Source/WebCore/editing/SelectionController.cpp
r75018 r76312 314 314 Position end = m_selection.end(); 315 315 316 bool baseIsStart; 317 316 318 if (m_isDirectional) { 317 319 // Make base and extent match start and end so we extend the user-visible selection. 318 320 // This only matters for cases where base and extend point to different positions than 319 321 // start and end (e.g. after a double-click to select a word). 320 if (m_selection.isBaseFirst()) { 321 m_selection.setBase(start); 322 m_selection.setExtent(end); 323 } else { 324 m_selection.setBase(end); 325 m_selection.setExtent(start); 326 } 322 if (m_selection.isBaseFirst()) 323 baseIsStart = true; 324 else 325 baseIsStart = false; 327 326 } else { 328 // FIXME: This is probably not correct for right and left when the direction is RTL.329 327 switch (direction) { 330 328 case DirectionRight: 329 if (directionOfEnclosingBlock() == LTR) 330 baseIsStart = true; 331 else 332 baseIsStart = false; 333 break; 331 334 case DirectionForward: 332 m_selection.setBase(start); 333 m_selection.setExtent(end); 335 baseIsStart = true; 334 336 break; 335 337 case DirectionLeft: 338 if (directionOfEnclosingBlock() == LTR) 339 baseIsStart = false; 340 else 341 baseIsStart = true; 342 break; 336 343 case DirectionBackward: 337 m_selection.setBase(end); 338 m_selection.setExtent(start); 344 baseIsStart = false; 339 345 break; 340 346 } 347 } 348 if (baseIsStart) { 349 m_selection.setBase(start); 350 m_selection.setExtent(end); 351 } else { 352 m_selection.setBase(end); 353 m_selection.setExtent(start); 341 354 } 342 355 } … … 456 469 switch (granularity) { 457 470 case CharacterGranularity: 458 if (isRange()) 459 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); 460 else 471 if (isRange()) { 472 if (directionOfEnclosingBlock() == LTR) 473 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); 474 else 475 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); 476 } else 461 477 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).right(true); 462 478 break; … … 610 626 case CharacterGranularity: 611 627 if (isRange()) 612 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); 628 if (directionOfEnclosingBlock() == LTR) 629 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); 630 else 631 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); 613 632 else 614 633 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).left(true);
Note: See TracChangeset
for help on using the changeset viewer.