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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 569 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
570 | 570 |
571 // The difference between modifyExtendingRight and modifyExtendingForward is
: | 571 // The difference between modifyExtendingRight and modifyExtendingForward is
: |
572 // modifyExtendingForward always extends forward logically. | 572 // modifyExtendingForward always extends forward logically. |
573 // modifyExtendingRight behaves the same as modifyExtendingForward except fo
r extending character or word, | 573 // modifyExtendingRight behaves the same as modifyExtendingForward except fo
r extending character or word, |
574 // it extends forward logically if the enclosing block is LTR direction, | 574 // it extends forward logically if the enclosing block is LTR direction, |
575 // but it extends backward logically if the enclosing block is RTL direction
. | 575 // but it extends backward logically if the enclosing block is RTL direction
. |
576 switch (granularity) { | 576 switch (granularity) { |
577 case CharacterGranularity: | 577 case CharacterGranularity: |
578 if (directionOfEnclosingBlock() == LTR) | 578 if (directionOfEnclosingBlock() == LTR) |
579 pos = pos.next(CannotCrossEditingBoundary); | 579 pos = pos.next(CanSkipOverEditingBoundary); |
580 else | 580 else |
581 pos = pos.previous(CannotCrossEditingBoundary); | 581 pos = pos.previous(CanSkipOverEditingBoundary); |
582 break; | 582 break; |
583 case WordGranularity: | 583 case WordGranularity: |
584 if (directionOfEnclosingBlock() == LTR) | 584 if (directionOfEnclosingBlock() == LTR) |
585 pos = nextWordPositionForPlatform(pos); | 585 pos = nextWordPositionForPlatform(pos); |
586 else | 586 else |
587 pos = previousWordPosition(pos); | 587 pos = previousWordPosition(pos); |
588 break; | 588 break; |
589 case LineBoundary: | 589 case LineBoundary: |
590 if (directionOfEnclosingBlock() == LTR) | 590 if (directionOfEnclosingBlock() == LTR) |
591 pos = modifyExtendingForward(granularity); | 591 pos = modifyExtendingForward(granularity); |
(...skipping 12 matching lines...) Expand all Loading... |
604 } | 604 } |
605 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); | 605 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); |
606 return pos; | 606 return pos; |
607 } | 607 } |
608 | 608 |
609 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari
ty) | 609 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari
ty) |
610 { | 610 { |
611 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 611 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
612 switch (granularity) { | 612 switch (granularity) { |
613 case CharacterGranularity: | 613 case CharacterGranularity: |
614 pos = pos.next(CannotCrossEditingBoundary); | 614 pos = pos.next(CanSkipOverEditingBoundary); |
615 break; | 615 break; |
616 case WordGranularity: | 616 case WordGranularity: |
617 pos = nextWordPositionForPlatform(pos); | 617 pos = nextWordPositionForPlatform(pos); |
618 break; | 618 break; |
619 case SentenceGranularity: | 619 case SentenceGranularity: |
620 pos = nextSentencePosition(pos); | 620 pos = nextSentencePosition(pos); |
621 break; | 621 break; |
622 case LineGranularity: | 622 case LineGranularity: |
623 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio
n(EXTENT)); | 623 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio
n(EXTENT)); |
624 break; | 624 break; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 682 |
683 VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity) | 683 VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity) |
684 { | 684 { |
685 VisiblePosition pos; | 685 VisiblePosition pos; |
686 // FIXME: Stay in editable content for the less common granularities. | 686 // FIXME: Stay in editable content for the less common granularities. |
687 switch (granularity) { | 687 switch (granularity) { |
688 case CharacterGranularity: | 688 case CharacterGranularity: |
689 if (isRange()) | 689 if (isRange()) |
690 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); | 690 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); |
691 else | 691 else |
692 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
next(CannotCrossEditingBoundary); | 692 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
next(CanSkipOverEditingBoundary); |
693 break; | 693 break; |
694 case WordGranularity: | 694 case WordGranularity: |
695 pos = nextWordPositionForPlatform(VisiblePosition(m_selection.extent(),
m_selection.affinity())); | 695 pos = nextWordPositionForPlatform(VisiblePosition(m_selection.extent(),
m_selection.affinity())); |
696 break; | 696 break; |
697 case SentenceGranularity: | 697 case SentenceGranularity: |
698 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); | 698 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); |
699 break; | 699 break; |
700 case LineGranularity: { | 700 case LineGranularity: { |
701 // down-arrowing from a range selection that ends at the start of a line
needs | 701 // down-arrowing from a range selection that ends at the start of a line
needs |
702 // to leave the selection at that line start (no need to call nextLinePo
sition!) | 702 // to leave the selection at that line start (no need to call nextLinePo
sition!) |
(...skipping 30 matching lines...) Expand all Loading... |
733 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 733 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
734 | 734 |
735 // The difference between modifyExtendingLeft and modifyExtendingBackward is
: | 735 // The difference between modifyExtendingLeft and modifyExtendingBackward is
: |
736 // modifyExtendingBackward always extends backward logically. | 736 // modifyExtendingBackward always extends backward logically. |
737 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo
r extending character or word, | 737 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo
r extending character or word, |
738 // it extends backward logically if the enclosing block is LTR direction, | 738 // it extends backward logically if the enclosing block is LTR direction, |
739 // but it extends forward logically if the enclosing block is RTL direction. | 739 // but it extends forward logically if the enclosing block is RTL direction. |
740 switch (granularity) { | 740 switch (granularity) { |
741 case CharacterGranularity: | 741 case CharacterGranularity: |
742 if (directionOfEnclosingBlock() == LTR) | 742 if (directionOfEnclosingBlock() == LTR) |
743 pos = pos.previous(CannotCrossEditingBoundary); | 743 pos = pos.previous(CanSkipOverEditingBoundary); |
744 else | 744 else |
745 pos = pos.next(CannotCrossEditingBoundary); | 745 pos = pos.next(CanSkipOverEditingBoundary); |
746 break; | 746 break; |
747 case WordGranularity: | 747 case WordGranularity: |
748 if (directionOfEnclosingBlock() == LTR) | 748 if (directionOfEnclosingBlock() == LTR) |
749 pos = previousWordPosition(pos); | 749 pos = previousWordPosition(pos); |
750 else | 750 else |
751 pos = nextWordPositionForPlatform(pos); | 751 pos = nextWordPositionForPlatform(pos); |
752 break; | 752 break; |
753 case LineBoundary: | 753 case LineBoundary: |
754 if (directionOfEnclosingBlock() == LTR) | 754 if (directionOfEnclosingBlock() == LTR) |
755 pos = modifyExtendingBackward(granularity); | 755 pos = modifyExtendingBackward(granularity); |
(...skipping 16 matching lines...) Expand all Loading... |
772 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular
ity) | 772 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular
ity) |
773 { | 773 { |
774 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 774 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
775 | 775 |
776 // Extending a selection backward by word or character from just after a tab
le selects | 776 // Extending a selection backward by word or character from just after a tab
le selects |
777 // the table. This "makes sense" from the user perspective, esp. when delet
ing. | 777 // the table. This "makes sense" from the user perspective, esp. when delet
ing. |
778 // It was done here instead of in VisiblePosition because we want VPs to ite
rate | 778 // It was done here instead of in VisiblePosition because we want VPs to ite
rate |
779 // over everything. | 779 // over everything. |
780 switch (granularity) { | 780 switch (granularity) { |
781 case CharacterGranularity: | 781 case CharacterGranularity: |
782 pos = pos.previous(CannotCrossEditingBoundary); | 782 pos = pos.previous(CanSkipOverEditingBoundary); |
783 break; | 783 break; |
784 case WordGranularity: | 784 case WordGranularity: |
785 pos = previousWordPosition(pos); | 785 pos = previousWordPosition(pos); |
786 break; | 786 break; |
787 case SentenceGranularity: | 787 case SentenceGranularity: |
788 pos = previousSentencePosition(pos); | 788 pos = previousSentencePosition(pos); |
789 break; | 789 break; |
790 case LineGranularity: | 790 case LineGranularity: |
791 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig
ation(EXTENT)); | 791 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig
ation(EXTENT)); |
792 break; | 792 break; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 } | 849 } |
850 | 850 |
851 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
) | 851 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
) |
852 { | 852 { |
853 VisiblePosition pos; | 853 VisiblePosition pos; |
854 switch (granularity) { | 854 switch (granularity) { |
855 case CharacterGranularity: | 855 case CharacterGranularity: |
856 if (isRange()) | 856 if (isRange()) |
857 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); | 857 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); |
858 else | 858 else |
859 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
previous(CannotCrossEditingBoundary); | 859 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
previous(CanSkipOverEditingBoundary); |
860 break; | 860 break; |
861 case WordGranularity: | 861 case WordGranularity: |
862 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); | 862 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); |
863 break; | 863 break; |
864 case SentenceGranularity: | 864 case SentenceGranularity: |
865 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s
election.affinity())); | 865 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s
election.affinity())); |
866 break; | 866 break; |
867 case LineGranularity: | 867 case LineGranularity: |
868 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc
kDirectionNavigation(START)); | 868 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc
kDirectionNavigation(START)); |
869 break; | 869 break; |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 sel.showTreeForThis(); | 1931 sel.showTreeForThis(); |
1932 } | 1932 } |
1933 | 1933 |
1934 void showTree(const WebCore::FrameSelection* sel) | 1934 void showTree(const WebCore::FrameSelection* sel) |
1935 { | 1935 { |
1936 if (sel) | 1936 if (sel) |
1937 sel->showTreeForThis(); | 1937 sel->showTreeForThis(); |
1938 } | 1938 } |
1939 | 1939 |
1940 #endif | 1940 #endif |
OLD | NEW |