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

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

Issue 1310043003: Introduce previousPositionOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T16:28:03 Created 5 years, 3 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/Editor.cpp ('k') | Source/core/editing/VisiblePosition.h » ('j') | 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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // The difference between modifyExtendingRight and modifyExtendingForward is : 661 // The difference between modifyExtendingRight and modifyExtendingForward is :
662 // modifyExtendingForward always extends forward logically. 662 // modifyExtendingForward always extends forward logically.
663 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word, 663 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word,
664 // it extends forward logically if the enclosing block is LTR direction, 664 // it extends forward logically if the enclosing block is LTR direction,
665 // but it extends backward logically if the enclosing block is RTL direction . 665 // but it extends backward logically if the enclosing block is RTL direction .
666 switch (granularity) { 666 switch (granularity) {
667 case CharacterGranularity: 667 case CharacterGranularity:
668 if (directionOfEnclosingBlock() == LTR) 668 if (directionOfEnclosingBlock() == LTR)
669 pos = pos.next(CanSkipOverEditingBoundary); 669 pos = pos.next(CanSkipOverEditingBoundary);
670 else 670 else
671 pos = pos.previous(CanSkipOverEditingBoundary); 671 pos = previousPositionOf(pos, CanSkipOverEditingBoundary);
672 break; 672 break;
673 case WordGranularity: 673 case WordGranularity:
674 if (directionOfEnclosingBlock() == LTR) 674 if (directionOfEnclosingBlock() == LTR)
675 pos = nextWordPositionForPlatform(pos); 675 pos = nextWordPositionForPlatform(pos);
676 else 676 else
677 pos = previousWordPosition(pos); 677 pos = previousWordPosition(pos);
678 break; 678 break;
679 case LineBoundary: 679 case LineBoundary:
680 if (directionOfEnclosingBlock() == LTR) 680 if (directionOfEnclosingBlock() == LTR)
681 pos = modifyExtendingForward(granularity); 681 pos = modifyExtendingForward(granularity);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); 824 VisiblePosition pos(m_selection.extent(), m_selection.affinity());
825 825
826 // The difference between modifyExtendingLeft and modifyExtendingBackward is : 826 // The difference between modifyExtendingLeft and modifyExtendingBackward is :
827 // modifyExtendingBackward always extends backward logically. 827 // modifyExtendingBackward always extends backward logically.
828 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo r extending character or word, 828 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo r extending character or word,
829 // it extends backward logically if the enclosing block is LTR direction, 829 // it extends backward logically if the enclosing block is LTR direction,
830 // but it extends forward logically if the enclosing block is RTL direction. 830 // but it extends forward logically if the enclosing block is RTL direction.
831 switch (granularity) { 831 switch (granularity) {
832 case CharacterGranularity: 832 case CharacterGranularity:
833 if (directionOfEnclosingBlock() == LTR) 833 if (directionOfEnclosingBlock() == LTR)
834 pos = pos.previous(CanSkipOverEditingBoundary); 834 pos = previousPositionOf(pos, CanSkipOverEditingBoundary);
835 else 835 else
836 pos = pos.next(CanSkipOverEditingBoundary); 836 pos = pos.next(CanSkipOverEditingBoundary);
837 break; 837 break;
838 case WordGranularity: 838 case WordGranularity:
839 if (directionOfEnclosingBlock() == LTR) 839 if (directionOfEnclosingBlock() == LTR)
840 pos = previousWordPosition(pos); 840 pos = previousWordPosition(pos);
841 else 841 else
842 pos = nextWordPositionForPlatform(pos); 842 pos = nextWordPositionForPlatform(pos);
843 break; 843 break;
844 case LineBoundary: 844 case LineBoundary:
(...skipping 18 matching lines...) Expand all
863 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity) 863 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity)
864 { 864 {
865 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); 865 VisiblePosition pos(m_selection.extent(), m_selection.affinity());
866 866
867 // Extending a selection backward by word or character from just after a tab le selects 867 // Extending a selection backward by word or character from just after a tab le selects
868 // the table. This "makes sense" from the user perspective, esp. when delet ing. 868 // the table. This "makes sense" from the user perspective, esp. when delet ing.
869 // It was done here instead of in VisiblePosition because we want VPs to ite rate 869 // It was done here instead of in VisiblePosition because we want VPs to ite rate
870 // over everything. 870 // over everything.
871 switch (granularity) { 871 switch (granularity) {
872 case CharacterGranularity: 872 case CharacterGranularity:
873 pos = pos.previous(CanSkipOverEditingBoundary); 873 pos = previousPositionOf(pos, CanSkipOverEditingBoundary);
874 break; 874 break;
875 case WordGranularity: 875 case WordGranularity:
876 pos = previousWordPosition(pos); 876 pos = previousWordPosition(pos);
877 break; 877 break;
878 case SentenceGranularity: 878 case SentenceGranularity:
879 pos = previousSentencePosition(pos); 879 pos = previousSentencePosition(pos);
880 break; 880 break;
881 case LineGranularity: 881 case LineGranularity:
882 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig ation(EXTENT)); 882 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig ation(EXTENT));
883 break; 883 break;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 } 941 }
942 942
943 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity ) 943 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity )
944 { 944 {
945 VisiblePosition pos; 945 VisiblePosition pos;
946 switch (granularity) { 946 switch (granularity) {
947 case CharacterGranularity: 947 case CharacterGranularity:
948 if (isRange()) 948 if (isRange())
949 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); 949 pos = VisiblePosition(m_selection.start(), m_selection.affinity());
950 else 950 else
951 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). previous(CanSkipOverEditingBoundary); 951 pos = previousPositionOf(VisiblePosition(m_selection.extent(), m_sel ection.affinity()), CanSkipOverEditingBoundary);
952 break; 952 break;
953 case WordGranularity: 953 case WordGranularity:
954 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity())); 954 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity()));
955 break; 955 break;
956 case SentenceGranularity: 956 case SentenceGranularity:
957 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s election.affinity())); 957 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s election.affinity()));
958 break; 958 break;
959 case LineGranularity: 959 case LineGranularity:
960 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc kDirectionNavigation(START)); 960 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc kDirectionNavigation(START));
961 break; 961 break;
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 2069
2070 void showTree(const blink::FrameSelection* sel) 2070 void showTree(const blink::FrameSelection* sel)
2071 { 2071 {
2072 if (sel) 2072 if (sel)
2073 sel->showTreeForThis(); 2073 sel->showTreeForThis();
2074 else 2074 else
2075 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 2075 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
2076 } 2076 }
2077 2077
2078 #endif 2078 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/Editor.cpp ('k') | Source/core/editing/VisiblePosition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698