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

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

Issue 1321033002: Introduce {left,right}PositionOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T21:59:15 Rebase after merge failure 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 | « no previous file | 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 { 740 {
741 VisiblePosition pos; 741 VisiblePosition pos;
742 switch (granularity) { 742 switch (granularity) {
743 case CharacterGranularity: 743 case CharacterGranularity:
744 if (isRange()) { 744 if (isRange()) {
745 if (directionOfSelection() == LTR) 745 if (directionOfSelection() == LTR)
746 pos = VisiblePosition(m_selection.end(), m_selection.affinity()) ; 746 pos = VisiblePosition(m_selection.end(), m_selection.affinity()) ;
747 else 747 else
748 pos = VisiblePosition(m_selection.start(), m_selection.affinity( )); 748 pos = VisiblePosition(m_selection.start(), m_selection.affinity( ));
749 } else { 749 } else {
750 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). right(); 750 pos = rightPositionOf(VisiblePosition(m_selection.extent(), m_select ion.affinity()));
751 } 751 }
752 break; 752 break;
753 case WordGranularity: { 753 case WordGranularity: {
754 bool skipsSpaceWhenMovingRight = m_frame && m_frame->editor().behavior() .shouldSkipSpaceWhenMovingRight(); 754 bool skipsSpaceWhenMovingRight = m_frame && m_frame->editor().behavior() .shouldSkipSpaceWhenMovingRight();
755 pos = rightWordPosition(VisiblePosition(m_selection.extent(), m_selectio n.affinity()), skipsSpaceWhenMovingRight); 755 pos = rightWordPosition(VisiblePosition(m_selection.extent(), m_selectio n.affinity()), skipsSpaceWhenMovingRight);
756 break; 756 break;
757 } 757 }
758 case SentenceGranularity: 758 case SentenceGranularity:
759 case LineGranularity: 759 case LineGranularity:
760 case ParagraphGranularity: 760 case ParagraphGranularity:
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 { 909 {
910 VisiblePosition pos; 910 VisiblePosition pos;
911 switch (granularity) { 911 switch (granularity) {
912 case CharacterGranularity: 912 case CharacterGranularity:
913 if (isRange()) { 913 if (isRange()) {
914 if (directionOfSelection() == LTR) 914 if (directionOfSelection() == LTR)
915 pos = VisiblePosition(m_selection.start(), m_selection.affinity( )); 915 pos = VisiblePosition(m_selection.start(), m_selection.affinity( ));
916 else 916 else
917 pos = VisiblePosition(m_selection.end(), m_selection.affinity()) ; 917 pos = VisiblePosition(m_selection.end(), m_selection.affinity()) ;
918 } else { 918 } else {
919 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). left(); 919 pos = leftPositionOf(VisiblePosition(m_selection.extent(), m_selecti on.affinity()));
920 } 920 }
921 break; 921 break;
922 case WordGranularity: { 922 case WordGranularity: {
923 bool skipsSpaceWhenMovingRight = m_frame && m_frame->editor().behavior() .shouldSkipSpaceWhenMovingRight(); 923 bool skipsSpaceWhenMovingRight = m_frame && m_frame->editor().behavior() .shouldSkipSpaceWhenMovingRight();
924 pos = leftWordPosition(VisiblePosition(m_selection.extent(), m_selection .affinity()), skipsSpaceWhenMovingRight); 924 pos = leftWordPosition(VisiblePosition(m_selection.extent(), m_selection .affinity()), skipsSpaceWhenMovingRight);
925 break; 925 break;
926 } 926 }
927 case SentenceGranularity: 927 case SentenceGranularity:
928 case LineGranularity: 928 case LineGranularity:
929 case ParagraphGranularity: 929 case ParagraphGranularity:
(...skipping 1139 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 | « no previous file | Source/core/editing/VisiblePosition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698