Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: Source/core/editing/FrameSelection.cpp

Issue 14930006: Ctrl+Shift+Right in Windows should select the spacing after the word (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added expectations for chromium-mac for delete-cell-contents-win.html Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 VisiblePosition FrameSelection::startForPlatform() const 570 VisiblePosition FrameSelection::startForPlatform() const
571 { 571 {
572 return positionForPlatform(true); 572 return positionForPlatform(true);
573 } 573 }
574 574
575 VisiblePosition FrameSelection::endForPlatform() const 575 VisiblePosition FrameSelection::endForPlatform() const
576 { 576 {
577 return positionForPlatform(false); 577 return positionForPlatform(false);
578 } 578 }
579 579
580 VisiblePosition FrameSelection::nextWordPositionForPlatform(const VisiblePositio n &originalPosition)
581 {
582 VisiblePosition positionAfterCurrentWord = nextWordPosition(originalPosition );
583
584 if (m_frame && m_frame->editor()->behavior().shouldSkipSpaceWhenMovingRight( )) {
585 // In order to skip spaces when moving right, we advance one
586 // word further and then move one word back. Given the
587 // semantics of previousWordPosition() this will put us at the
588 // beginning of the word following.
589 VisiblePosition positionAfterSpacingAndFollowingWord = nextWordPosition( positionAfterCurrentWord);
590 if (positionAfterSpacingAndFollowingWord.isNotNull() && positionAfterSpa cingAndFollowingWord != positionAfterCurrentWord)
591 positionAfterCurrentWord = previousWordPosition(positionAfterSpacing AndFollowingWord);
592
593 bool movingBackwardsMovedPositionToStartOfCurrentWord = positionAfterCur rentWord == previousWordPosition(nextWordPosition(originalPosition));
594 if (movingBackwardsMovedPositionToStartOfCurrentWord)
595 positionAfterCurrentWord = positionAfterSpacingAndFollowingWord;
596 }
597 return positionAfterCurrentWord;
598 }
599
580 #if ENABLE(USERSELECT_ALL) 600 #if ENABLE(USERSELECT_ALL)
581 static void adjustPositionForUserSelectAll(VisiblePosition& pos, bool isForward) 601 static void adjustPositionForUserSelectAll(VisiblePosition& pos, bool isForward)
582 { 602 {
583 if (Node* rootUserSelectAll = Position::rootUserSelectAllForNode(pos.deepEqu ivalent().anchorNode())) 603 if (Node* rootUserSelectAll = Position::rootUserSelectAllForNode(pos.deepEqu ivalent().anchorNode()))
584 pos = isForward ? positionAfterNode(rootUserSelectAll).downstream(CanCro ssEditingBoundary) : positionBeforeNode(rootUserSelectAll).upstream(CanCrossEdit ingBoundary); 604 pos = isForward ? positionAfterNode(rootUserSelectAll).downstream(CanCro ssEditingBoundary) : positionBeforeNode(rootUserSelectAll).upstream(CanCrossEdit ingBoundary);
585 } 605 }
586 #endif 606 #endif
587 607
588 VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity ) 608 VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity )
589 { 609 {
590 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); 610 VisiblePosition pos(m_selection.extent(), m_selection.affinity());
591 611
592 // The difference between modifyExtendingRight and modifyExtendingForward is : 612 // The difference between modifyExtendingRight and modifyExtendingForward is :
593 // modifyExtendingForward always extends forward logically. 613 // modifyExtendingForward always extends forward logically.
594 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word, 614 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word,
595 // it extends forward logically if the enclosing block is LTR direction, 615 // it extends forward logically if the enclosing block is LTR direction,
596 // but it extends backward logically if the enclosing block is RTL direction . 616 // but it extends backward logically if the enclosing block is RTL direction .
597 switch (granularity) { 617 switch (granularity) {
598 case CharacterGranularity: 618 case CharacterGranularity:
599 if (directionOfEnclosingBlock() == LTR) 619 if (directionOfEnclosingBlock() == LTR)
600 pos = pos.next(CannotCrossEditingBoundary); 620 pos = pos.next(CannotCrossEditingBoundary);
601 else 621 else
602 pos = pos.previous(CannotCrossEditingBoundary); 622 pos = pos.previous(CannotCrossEditingBoundary);
603 break; 623 break;
604 case WordGranularity: 624 case WordGranularity:
605 if (directionOfEnclosingBlock() == LTR) 625 if (directionOfEnclosingBlock() == LTR)
606 pos = nextWordPosition(pos); 626 pos = nextWordPositionForPlatform(pos);
607 else 627 else
608 pos = previousWordPosition(pos); 628 pos = previousWordPosition(pos);
609 break; 629 break;
610 case LineBoundary: 630 case LineBoundary:
611 if (directionOfEnclosingBlock() == LTR) 631 if (directionOfEnclosingBlock() == LTR)
612 pos = modifyExtendingForward(granularity); 632 pos = modifyExtendingForward(granularity);
613 else 633 else
614 pos = modifyExtendingBackward(granularity); 634 pos = modifyExtendingBackward(granularity);
615 break; 635 break;
616 case SentenceGranularity: 636 case SentenceGranularity:
(...skipping 13 matching lines...) Expand all
630 } 650 }
631 651
632 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty) 652 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty)
633 { 653 {
634 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); 654 VisiblePosition pos(m_selection.extent(), m_selection.affinity());
635 switch (granularity) { 655 switch (granularity) {
636 case CharacterGranularity: 656 case CharacterGranularity:
637 pos = pos.next(CannotCrossEditingBoundary); 657 pos = pos.next(CannotCrossEditingBoundary);
638 break; 658 break;
639 case WordGranularity: 659 case WordGranularity:
640 pos = nextWordPosition(pos); 660 pos = nextWordPositionForPlatform(pos);
641 break; 661 break;
642 case SentenceGranularity: 662 case SentenceGranularity:
643 pos = nextSentencePosition(pos); 663 pos = nextSentencePosition(pos);
644 break; 664 break;
645 case LineGranularity: 665 case LineGranularity:
646 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio n(EXTENT)); 666 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio n(EXTENT));
647 break; 667 break;
648 case ParagraphGranularity: 668 case ParagraphGranularity:
649 pos = nextParagraphPosition(pos, lineDirectionPointForBlockDirectionNavi gation(EXTENT)); 669 pos = nextParagraphPosition(pos, lineDirectionPointForBlockDirectionNavi gation(EXTENT));
650 break; 670 break;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 VisiblePosition pos; 730 VisiblePosition pos;
711 // FIXME: Stay in editable content for the less common granularities. 731 // FIXME: Stay in editable content for the less common granularities.
712 switch (granularity) { 732 switch (granularity) {
713 case CharacterGranularity: 733 case CharacterGranularity:
714 if (isRange()) 734 if (isRange())
715 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); 735 pos = VisiblePosition(m_selection.end(), m_selection.affinity());
716 else 736 else
717 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). next(CannotCrossEditingBoundary); 737 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). next(CannotCrossEditingBoundary);
718 break; 738 break;
719 case WordGranularity: 739 case WordGranularity:
720 pos = nextWordPosition(VisiblePosition(m_selection.extent(), m_selection .affinity())); 740 pos = nextWordPositionForPlatform(VisiblePosition(m_selection.extent(), m_selection.affinity()));
721 break; 741 break;
722 case SentenceGranularity: 742 case SentenceGranularity:
723 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity())); 743 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity()));
724 break; 744 break;
725 case LineGranularity: { 745 case LineGranularity: {
726 // down-arrowing from a range selection that ends at the start of a line needs 746 // down-arrowing from a range selection that ends at the start of a line needs
727 // to leave the selection at that line start (no need to call nextLinePo sition!) 747 // to leave the selection at that line start (no need to call nextLinePo sition!)
728 pos = endForPlatform(); 748 pos = endForPlatform();
729 if (!isRange() || !isStartOfLine(pos)) 749 if (!isRange() || !isStartOfLine(pos))
730 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavig ation(START)); 750 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavig ation(START));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 case CharacterGranularity: 786 case CharacterGranularity:
767 if (directionOfEnclosingBlock() == LTR) 787 if (directionOfEnclosingBlock() == LTR)
768 pos = pos.previous(CannotCrossEditingBoundary); 788 pos = pos.previous(CannotCrossEditingBoundary);
769 else 789 else
770 pos = pos.next(CannotCrossEditingBoundary); 790 pos = pos.next(CannotCrossEditingBoundary);
771 break; 791 break;
772 case WordGranularity: 792 case WordGranularity:
773 if (directionOfEnclosingBlock() == LTR) 793 if (directionOfEnclosingBlock() == LTR)
774 pos = previousWordPosition(pos); 794 pos = previousWordPosition(pos);
775 else 795 else
776 pos = nextWordPosition(pos); 796 pos = nextWordPositionForPlatform(pos);
777 break; 797 break;
778 case LineBoundary: 798 case LineBoundary:
779 if (directionOfEnclosingBlock() == LTR) 799 if (directionOfEnclosingBlock() == LTR)
780 pos = modifyExtendingBackward(granularity); 800 pos = modifyExtendingBackward(granularity);
781 else 801 else
782 pos = modifyExtendingForward(granularity); 802 pos = modifyExtendingForward(granularity);
783 break; 803 break;
784 case SentenceGranularity: 804 case SentenceGranularity:
785 case LineGranularity: 805 case LineGranularity:
786 case ParagraphGranularity: 806 case ParagraphGranularity:
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 sel.showTreeForThis(); 2067 sel.showTreeForThis();
2048 } 2068 }
2049 2069
2050 void showTree(const WebCore::FrameSelection* sel) 2070 void showTree(const WebCore::FrameSelection* sel)
2051 { 2071 {
2052 if (sel) 2072 if (sel)
2053 sel->showTreeForThis(); 2073 sel->showTreeForThis();
2054 } 2074 }
2055 2075
2056 #endif 2076 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698