OLD | NEW |
---|---|
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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
617 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 617 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
618 | 618 |
619 // The difference between modifyExtendingRight and modifyExtendingForward is : | 619 // The difference between modifyExtendingRight and modifyExtendingForward is : |
620 // modifyExtendingForward always extends forward logically. | 620 // modifyExtendingForward always extends forward logically. |
621 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word, | 621 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word, |
622 // it extends forward logically if the enclosing block is LTR direction, | 622 // it extends forward logically if the enclosing block is LTR direction, |
623 // but it extends backward logically if the enclosing block is RTL direction . | 623 // but it extends backward logically if the enclosing block is RTL direction . |
624 switch (granularity) { | 624 switch (granularity) { |
625 case CharacterGranularity: | 625 case CharacterGranularity: |
626 if (directionOfEnclosingBlock() == LTR) | 626 if (directionOfEnclosingBlock() == LTR) |
627 pos = pos.next(CannotCrossEditingBoundary); | 627 pos = pos.next(CanSkipOverEditingBoundary); |
yosin_UTC9
2013/08/31 01:00:47
Should we pass CanSkipOverEditingBoundary for othe
dmazzoni
2013/09/05 07:57:29
Not needed. I updated the test to show that word a
yosin_UTC9
2013/09/05 08:42:48
Will be them in patch #3? I'm not sure why Line an
| |
628 else | 628 else |
629 pos = pos.previous(CannotCrossEditingBoundary); | 629 pos = pos.previous(CanSkipOverEditingBoundary); |
yosin_UTC9
2013/08/31 01:00:47
What happen if caret is at the end of text field?
dmazzoni
2013/09/05 07:57:29
Yes.
yosin_UTC9
2013/09/05 08:42:48
We want to have internals.getSelection() which ret
dmazzoni
2013/09/05 17:17:21
I think I figured out a solution using internals.y
| |
630 break; | 630 break; |
631 case WordGranularity: | 631 case WordGranularity: |
632 if (directionOfEnclosingBlock() == LTR) | 632 if (directionOfEnclosingBlock() == LTR) |
633 pos = nextWordPositionForPlatform(pos); | 633 pos = nextWordPositionForPlatform(pos); |
634 else | 634 else |
635 pos = previousWordPosition(pos); | 635 pos = previousWordPosition(pos); |
636 break; | 636 break; |
637 case LineBoundary: | 637 case LineBoundary: |
638 if (directionOfEnclosingBlock() == LTR) | 638 if (directionOfEnclosingBlock() == LTR) |
639 pos = modifyExtendingForward(granularity); | 639 pos = modifyExtendingForward(granularity); |
(...skipping 14 matching lines...) Expand all Loading... | |
654 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); | 654 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); |
655 #endif | 655 #endif |
656 return pos; | 656 return pos; |
657 } | 657 } |
658 | 658 |
659 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty) | 659 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty) |
660 { | 660 { |
661 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 661 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
662 switch (granularity) { | 662 switch (granularity) { |
663 case CharacterGranularity: | 663 case CharacterGranularity: |
664 pos = pos.next(CannotCrossEditingBoundary); | 664 pos = pos.next(CanSkipOverEditingBoundary); |
665 break; | 665 break; |
666 case WordGranularity: | 666 case WordGranularity: |
667 pos = nextWordPositionForPlatform(pos); | 667 pos = nextWordPositionForPlatform(pos); |
668 break; | 668 break; |
669 case SentenceGranularity: | 669 case SentenceGranularity: |
670 pos = nextSentencePosition(pos); | 670 pos = nextSentencePosition(pos); |
671 break; | 671 break; |
672 case LineGranularity: | 672 case LineGranularity: |
673 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio n(EXTENT)); | 673 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio n(EXTENT)); |
674 break; | 674 break; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 | 734 |
735 VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity) | 735 VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity) |
736 { | 736 { |
737 VisiblePosition pos; | 737 VisiblePosition pos; |
738 // FIXME: Stay in editable content for the less common granularities. | 738 // FIXME: Stay in editable content for the less common granularities. |
739 switch (granularity) { | 739 switch (granularity) { |
740 case CharacterGranularity: | 740 case CharacterGranularity: |
741 if (isRange()) | 741 if (isRange()) |
742 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); | 742 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); |
743 else | 743 else |
744 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). next(CannotCrossEditingBoundary); | 744 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). next(CanSkipOverEditingBoundary); |
745 break; | 745 break; |
746 case WordGranularity: | 746 case WordGranularity: |
747 pos = nextWordPositionForPlatform(VisiblePosition(m_selection.extent(), m_selection.affinity())); | 747 pos = nextWordPositionForPlatform(VisiblePosition(m_selection.extent(), m_selection.affinity())); |
748 break; | 748 break; |
749 case SentenceGranularity: | 749 case SentenceGranularity: |
750 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity())); | 750 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity())); |
751 break; | 751 break; |
752 case LineGranularity: { | 752 case LineGranularity: { |
753 // down-arrowing from a range selection that ends at the start of a line needs | 753 // down-arrowing from a range selection that ends at the start of a line needs |
754 // to leave the selection at that line start (no need to call nextLinePo sition!) | 754 // to leave the selection at that line start (no need to call nextLinePo sition!) |
(...skipping 30 matching lines...) Expand all Loading... | |
785 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 785 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
786 | 786 |
787 // The difference between modifyExtendingLeft and modifyExtendingBackward is : | 787 // The difference between modifyExtendingLeft and modifyExtendingBackward is : |
788 // modifyExtendingBackward always extends backward logically. | 788 // modifyExtendingBackward always extends backward logically. |
789 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo r extending character or word, | 789 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo r extending character or word, |
790 // it extends backward logically if the enclosing block is LTR direction, | 790 // it extends backward logically if the enclosing block is LTR direction, |
791 // but it extends forward logically if the enclosing block is RTL direction. | 791 // but it extends forward logically if the enclosing block is RTL direction. |
792 switch (granularity) { | 792 switch (granularity) { |
793 case CharacterGranularity: | 793 case CharacterGranularity: |
794 if (directionOfEnclosingBlock() == LTR) | 794 if (directionOfEnclosingBlock() == LTR) |
795 pos = pos.previous(CannotCrossEditingBoundary); | 795 pos = pos.previous(CanSkipOverEditingBoundary); |
796 else | 796 else |
797 pos = pos.next(CannotCrossEditingBoundary); | 797 pos = pos.next(CanSkipOverEditingBoundary); |
798 break; | 798 break; |
799 case WordGranularity: | 799 case WordGranularity: |
800 if (directionOfEnclosingBlock() == LTR) | 800 if (directionOfEnclosingBlock() == LTR) |
801 pos = previousWordPosition(pos); | 801 pos = previousWordPosition(pos); |
802 else | 802 else |
803 pos = nextWordPositionForPlatform(pos); | 803 pos = nextWordPositionForPlatform(pos); |
804 break; | 804 break; |
805 case LineBoundary: | 805 case LineBoundary: |
806 if (directionOfEnclosingBlock() == LTR) | 806 if (directionOfEnclosingBlock() == LTR) |
807 pos = modifyExtendingBackward(granularity); | 807 pos = modifyExtendingBackward(granularity); |
(...skipping 18 matching lines...) Expand all Loading... | |
826 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity) | 826 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity) |
827 { | 827 { |
828 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 828 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
829 | 829 |
830 // Extending a selection backward by word or character from just after a tab le selects | 830 // Extending a selection backward by word or character from just after a tab le selects |
831 // the table. This "makes sense" from the user perspective, esp. when delet ing. | 831 // the table. This "makes sense" from the user perspective, esp. when delet ing. |
832 // It was done here instead of in VisiblePosition because we want VPs to ite rate | 832 // It was done here instead of in VisiblePosition because we want VPs to ite rate |
833 // over everything. | 833 // over everything. |
834 switch (granularity) { | 834 switch (granularity) { |
835 case CharacterGranularity: | 835 case CharacterGranularity: |
836 pos = pos.previous(CannotCrossEditingBoundary); | 836 pos = pos.previous(CanSkipOverEditingBoundary); |
837 break; | 837 break; |
838 case WordGranularity: | 838 case WordGranularity: |
839 pos = previousWordPosition(pos); | 839 pos = previousWordPosition(pos); |
840 break; | 840 break; |
841 case SentenceGranularity: | 841 case SentenceGranularity: |
842 pos = previousSentencePosition(pos); | 842 pos = previousSentencePosition(pos); |
843 break; | 843 break; |
844 case LineGranularity: | 844 case LineGranularity: |
845 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig ation(EXTENT)); | 845 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig ation(EXTENT)); |
846 break; | 846 break; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 } | 905 } |
906 | 906 |
907 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity ) | 907 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity ) |
908 { | 908 { |
909 VisiblePosition pos; | 909 VisiblePosition pos; |
910 switch (granularity) { | 910 switch (granularity) { |
911 case CharacterGranularity: | 911 case CharacterGranularity: |
912 if (isRange()) | 912 if (isRange()) |
913 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); | 913 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); |
914 else | 914 else |
915 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). previous(CannotCrossEditingBoundary); | 915 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()). previous(CanSkipOverEditingBoundary); |
916 break; | 916 break; |
917 case WordGranularity: | 917 case WordGranularity: |
918 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity())); | 918 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec tion.affinity())); |
919 break; | 919 break; |
920 case SentenceGranularity: | 920 case SentenceGranularity: |
921 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s election.affinity())); | 921 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s election.affinity())); |
922 break; | 922 break; |
923 case LineGranularity: | 923 case LineGranularity: |
924 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc kDirectionNavigation(START)); | 924 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc kDirectionNavigation(START)); |
925 break; | 925 break; |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2126 sel.showTreeForThis(); | 2126 sel.showTreeForThis(); |
2127 } | 2127 } |
2128 | 2128 |
2129 void showTree(const WebCore::FrameSelection* sel) | 2129 void showTree(const WebCore::FrameSelection* sel) |
2130 { | 2130 { |
2131 if (sel) | 2131 if (sel) |
2132 sel->showTreeForThis(); | 2132 sel->showTreeForThis(); |
2133 } | 2133 } |
2134 | 2134 |
2135 #endif | 2135 #endif |
OLD | NEW |