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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 596 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
597 | 597 |
598 // The difference between modifyExtendingRight and modifyExtendingForward is
: | 598 // The difference between modifyExtendingRight and modifyExtendingForward is
: |
599 // modifyExtendingForward always extends forward logically. | 599 // modifyExtendingForward always extends forward logically. |
600 // modifyExtendingRight behaves the same as modifyExtendingForward except fo
r extending character or word, | 600 // modifyExtendingRight behaves the same as modifyExtendingForward except fo
r extending character or word, |
601 // it extends forward logically if the enclosing block is LTR direction, | 601 // it extends forward logically if the enclosing block is LTR direction, |
602 // but it extends backward logically if the enclosing block is RTL direction
. | 602 // but it extends backward logically if the enclosing block is RTL direction
. |
603 switch (granularity) { | 603 switch (granularity) { |
604 case CharacterGranularity: | 604 case CharacterGranularity: |
605 if (directionOfEnclosingBlock() == LTR) | 605 if (directionOfEnclosingBlock() == LTR) |
606 pos = pos.next(CannotCrossEditingBoundary); | 606 pos = pos.next(CanSkipOverEditingBoundary); |
607 else | 607 else |
608 pos = pos.previous(CannotCrossEditingBoundary); | 608 pos = pos.previous(CanSkipOverEditingBoundary); |
609 break; | 609 break; |
610 case WordGranularity: | 610 case WordGranularity: |
611 if (directionOfEnclosingBlock() == LTR) | 611 if (directionOfEnclosingBlock() == LTR) |
612 pos = nextWordPositionForPlatform(pos); | 612 pos = nextWordPositionForPlatform(pos); |
613 else | 613 else |
614 pos = previousWordPosition(pos); | 614 pos = previousWordPosition(pos); |
615 break; | 615 break; |
616 case LineBoundary: | 616 case LineBoundary: |
617 if (directionOfEnclosingBlock() == LTR) | 617 if (directionOfEnclosingBlock() == LTR) |
618 pos = modifyExtendingForward(granularity); | 618 pos = modifyExtendingForward(granularity); |
(...skipping 12 matching lines...) Expand all Loading... |
631 } | 631 } |
632 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); | 632 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); |
633 return pos; | 633 return pos; |
634 } | 634 } |
635 | 635 |
636 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari
ty) | 636 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari
ty) |
637 { | 637 { |
638 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 638 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
639 switch (granularity) { | 639 switch (granularity) { |
640 case CharacterGranularity: | 640 case CharacterGranularity: |
641 pos = pos.next(CannotCrossEditingBoundary); | 641 pos = pos.next(CanSkipOverEditingBoundary); |
642 break; | 642 break; |
643 case WordGranularity: | 643 case WordGranularity: |
644 pos = nextWordPositionForPlatform(pos); | 644 pos = nextWordPositionForPlatform(pos); |
645 break; | 645 break; |
646 case SentenceGranularity: | 646 case SentenceGranularity: |
647 pos = nextSentencePosition(pos); | 647 pos = nextSentencePosition(pos); |
648 break; | 648 break; |
649 case LineGranularity: | 649 case LineGranularity: |
650 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio
n(EXTENT)); | 650 pos = nextLinePosition(pos, lineDirectionPointForBlockDirectionNavigatio
n(EXTENT)); |
651 break; | 651 break; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 709 |
710 VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity) | 710 VisiblePosition FrameSelection::modifyMovingForward(TextGranularity granularity) |
711 { | 711 { |
712 VisiblePosition pos; | 712 VisiblePosition pos; |
713 // FIXME: Stay in editable content for the less common granularities. | 713 // FIXME: Stay in editable content for the less common granularities. |
714 switch (granularity) { | 714 switch (granularity) { |
715 case CharacterGranularity: | 715 case CharacterGranularity: |
716 if (isRange()) | 716 if (isRange()) |
717 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); | 717 pos = VisiblePosition(m_selection.end(), m_selection.affinity()); |
718 else | 718 else |
719 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
next(CannotCrossEditingBoundary); | 719 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
next(CanSkipOverEditingBoundary); |
720 break; | 720 break; |
721 case WordGranularity: | 721 case WordGranularity: |
722 pos = nextWordPositionForPlatform(VisiblePosition(m_selection.extent(),
m_selection.affinity())); | 722 pos = nextWordPositionForPlatform(VisiblePosition(m_selection.extent(),
m_selection.affinity())); |
723 break; | 723 break; |
724 case SentenceGranularity: | 724 case SentenceGranularity: |
725 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); | 725 pos = nextSentencePosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); |
726 break; | 726 break; |
727 case LineGranularity: { | 727 case LineGranularity: { |
728 // down-arrowing from a range selection that ends at the start of a line
needs | 728 // down-arrowing from a range selection that ends at the start of a line
needs |
729 // to leave the selection at that line start (no need to call nextLinePo
sition!) | 729 // to leave the selection at that line start (no need to call nextLinePo
sition!) |
(...skipping 30 matching lines...) Expand all Loading... |
760 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 760 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
761 | 761 |
762 // The difference between modifyExtendingLeft and modifyExtendingBackward is
: | 762 // The difference between modifyExtendingLeft and modifyExtendingBackward is
: |
763 // modifyExtendingBackward always extends backward logically. | 763 // modifyExtendingBackward always extends backward logically. |
764 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo
r extending character or word, | 764 // modifyExtendingLeft behaves the same as modifyExtendingBackward except fo
r extending character or word, |
765 // it extends backward logically if the enclosing block is LTR direction, | 765 // it extends backward logically if the enclosing block is LTR direction, |
766 // but it extends forward logically if the enclosing block is RTL direction. | 766 // but it extends forward logically if the enclosing block is RTL direction. |
767 switch (granularity) { | 767 switch (granularity) { |
768 case CharacterGranularity: | 768 case CharacterGranularity: |
769 if (directionOfEnclosingBlock() == LTR) | 769 if (directionOfEnclosingBlock() == LTR) |
770 pos = pos.previous(CannotCrossEditingBoundary); | 770 pos = pos.previous(CanSkipOverEditingBoundary); |
771 else | 771 else |
772 pos = pos.next(CannotCrossEditingBoundary); | 772 pos = pos.next(CanSkipOverEditingBoundary); |
773 break; | 773 break; |
774 case WordGranularity: | 774 case WordGranularity: |
775 if (directionOfEnclosingBlock() == LTR) | 775 if (directionOfEnclosingBlock() == LTR) |
776 pos = previousWordPosition(pos); | 776 pos = previousWordPosition(pos); |
777 else | 777 else |
778 pos = nextWordPositionForPlatform(pos); | 778 pos = nextWordPositionForPlatform(pos); |
779 break; | 779 break; |
780 case LineBoundary: | 780 case LineBoundary: |
781 if (directionOfEnclosingBlock() == LTR) | 781 if (directionOfEnclosingBlock() == LTR) |
782 pos = modifyExtendingBackward(granularity); | 782 pos = modifyExtendingBackward(granularity); |
(...skipping 16 matching lines...) Expand all Loading... |
799 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular
ity) | 799 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular
ity) |
800 { | 800 { |
801 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 801 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
802 | 802 |
803 // Extending a selection backward by word or character from just after a tab
le selects | 803 // Extending a selection backward by word or character from just after a tab
le selects |
804 // the table. This "makes sense" from the user perspective, esp. when delet
ing. | 804 // the table. This "makes sense" from the user perspective, esp. when delet
ing. |
805 // It was done here instead of in VisiblePosition because we want VPs to ite
rate | 805 // It was done here instead of in VisiblePosition because we want VPs to ite
rate |
806 // over everything. | 806 // over everything. |
807 switch (granularity) { | 807 switch (granularity) { |
808 case CharacterGranularity: | 808 case CharacterGranularity: |
809 pos = pos.previous(CannotCrossEditingBoundary); | 809 pos = pos.previous(CanSkipOverEditingBoundary); |
810 break; | 810 break; |
811 case WordGranularity: | 811 case WordGranularity: |
812 pos = previousWordPosition(pos); | 812 pos = previousWordPosition(pos); |
813 break; | 813 break; |
814 case SentenceGranularity: | 814 case SentenceGranularity: |
815 pos = previousSentencePosition(pos); | 815 pos = previousSentencePosition(pos); |
816 break; | 816 break; |
817 case LineGranularity: | 817 case LineGranularity: |
818 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig
ation(EXTENT)); | 818 pos = previousLinePosition(pos, lineDirectionPointForBlockDirectionNavig
ation(EXTENT)); |
819 break; | 819 break; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 } | 876 } |
877 | 877 |
878 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
) | 878 VisiblePosition FrameSelection::modifyMovingBackward(TextGranularity granularity
) |
879 { | 879 { |
880 VisiblePosition pos; | 880 VisiblePosition pos; |
881 switch (granularity) { | 881 switch (granularity) { |
882 case CharacterGranularity: | 882 case CharacterGranularity: |
883 if (isRange()) | 883 if (isRange()) |
884 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); | 884 pos = VisiblePosition(m_selection.start(), m_selection.affinity()); |
885 else | 885 else |
886 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
previous(CannotCrossEditingBoundary); | 886 pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).
previous(CanSkipOverEditingBoundary); |
887 break; | 887 break; |
888 case WordGranularity: | 888 case WordGranularity: |
889 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); | 889 pos = previousWordPosition(VisiblePosition(m_selection.extent(), m_selec
tion.affinity())); |
890 break; | 890 break; |
891 case SentenceGranularity: | 891 case SentenceGranularity: |
892 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s
election.affinity())); | 892 pos = previousSentencePosition(VisiblePosition(m_selection.extent(), m_s
election.affinity())); |
893 break; | 893 break; |
894 case LineGranularity: | 894 case LineGranularity: |
895 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc
kDirectionNavigation(START)); | 895 pos = previousLinePosition(startForPlatform(), lineDirectionPointForBloc
kDirectionNavigation(START)); |
896 break; | 896 break; |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 sel.showTreeForThis(); | 1958 sel.showTreeForThis(); |
1959 } | 1959 } |
1960 | 1960 |
1961 void showTree(const WebCore::FrameSelection* sel) | 1961 void showTree(const WebCore::FrameSelection* sel) |
1962 { | 1962 { |
1963 if (sel) | 1963 if (sel) |
1964 sel->showTreeForThis(); | 1964 sel->showTreeForThis(); |
1965 } | 1965 } |
1966 | 1966 |
1967 #endif | 1967 #endif |
OLD | NEW |