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

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

Issue 22751005: Convert USERSELECT_ALL to a runtime enabled feature. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: undo reordering of if statements Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 if (positionAfterSpacingAndFollowingWord.isNotNull() && positionAfterSpa cingAndFollowingWord != positionAfterCurrentWord) 550 if (positionAfterSpacingAndFollowingWord.isNotNull() && positionAfterSpa cingAndFollowingWord != positionAfterCurrentWord)
551 positionAfterCurrentWord = previousWordPosition(positionAfterSpacing AndFollowingWord); 551 positionAfterCurrentWord = previousWordPosition(positionAfterSpacing AndFollowingWord);
552 552
553 bool movingBackwardsMovedPositionToStartOfCurrentWord = positionAfterCur rentWord == previousWordPosition(nextWordPosition(originalPosition)); 553 bool movingBackwardsMovedPositionToStartOfCurrentWord = positionAfterCur rentWord == previousWordPosition(nextWordPosition(originalPosition));
554 if (movingBackwardsMovedPositionToStartOfCurrentWord) 554 if (movingBackwardsMovedPositionToStartOfCurrentWord)
555 positionAfterCurrentWord = positionAfterSpacingAndFollowingWord; 555 positionAfterCurrentWord = positionAfterSpacingAndFollowingWord;
556 } 556 }
557 return positionAfterCurrentWord; 557 return positionAfterCurrentWord;
558 } 558 }
559 559
560 #if ENABLE(USERSELECT_ALL)
561 static void adjustPositionForUserSelectAll(VisiblePosition& pos, bool isForward) 560 static void adjustPositionForUserSelectAll(VisiblePosition& pos, bool isForward)
562 { 561 {
563 if (Node* rootUserSelectAll = Position::rootUserSelectAllForNode(pos.deepEqu ivalent().anchorNode())) 562 if (Node* rootUserSelectAll = Position::rootUserSelectAllForNode(pos.deepEqu ivalent().anchorNode()))
564 pos = isForward ? positionAfterNode(rootUserSelectAll).downstream(CanCro ssEditingBoundary) : positionBeforeNode(rootUserSelectAll).upstream(CanCrossEdit ingBoundary); 563 pos = isForward ? positionAfterNode(rootUserSelectAll).downstream(CanCro ssEditingBoundary) : positionBeforeNode(rootUserSelectAll).upstream(CanCrossEdit ingBoundary);
565 } 564 }
566 #endif
567 565
568 VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity ) 566 VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity )
569 { 567 {
570 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); 568 VisiblePosition pos(m_selection.extent(), m_selection.affinity());
571 569
572 // The difference between modifyExtendingRight and modifyExtendingForward is : 570 // The difference between modifyExtendingRight and modifyExtendingForward is :
573 // modifyExtendingForward always extends forward logically. 571 // modifyExtendingForward always extends forward logically.
574 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word, 572 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word,
575 // it extends forward logically if the enclosing block is LTR direction, 573 // it extends forward logically if the enclosing block is LTR direction,
576 // but it extends backward logically if the enclosing block is RTL direction . 574 // but it extends backward logically if the enclosing block is RTL direction .
(...skipping 19 matching lines...) Expand all
596 case SentenceGranularity: 594 case SentenceGranularity:
597 case LineGranularity: 595 case LineGranularity:
598 case ParagraphGranularity: 596 case ParagraphGranularity:
599 case SentenceBoundary: 597 case SentenceBoundary:
600 case ParagraphBoundary: 598 case ParagraphBoundary:
601 case DocumentBoundary: 599 case DocumentBoundary:
602 // FIXME: implement all of the above? 600 // FIXME: implement all of the above?
603 pos = modifyExtendingForward(granularity); 601 pos = modifyExtendingForward(granularity);
604 break; 602 break;
605 } 603 }
606 #if ENABLE(USERSELECT_ALL)
607 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); 604 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR);
608 #endif
609 return pos; 605 return pos;
610 } 606 }
611 607
612 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty) 608 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty)
613 { 609 {
614 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); 610 VisiblePosition pos(m_selection.extent(), m_selection.affinity());
615 switch (granularity) { 611 switch (granularity) {
616 case CharacterGranularity: 612 case CharacterGranularity:
617 pos = pos.next(CannotCrossEditingBoundary); 613 pos = pos.next(CannotCrossEditingBoundary);
618 break; 614 break;
(...skipping 19 matching lines...) Expand all
638 pos = endOfParagraph(endForPlatform()); 634 pos = endOfParagraph(endForPlatform());
639 break; 635 break;
640 case DocumentBoundary: 636 case DocumentBoundary:
641 pos = endForPlatform(); 637 pos = endForPlatform();
642 if (isEditablePosition(pos.deepEquivalent())) 638 if (isEditablePosition(pos.deepEquivalent()))
643 pos = endOfEditableContent(pos); 639 pos = endOfEditableContent(pos);
644 else 640 else
645 pos = endOfDocument(pos); 641 pos = endOfDocument(pos);
646 break; 642 break;
647 } 643 }
648 #if ENABLE(USERSELECT_ALL) 644 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR);
649 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR);
650 #endif
651 return pos; 645 return pos;
652 } 646 }
653 647
654 VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity) 648 VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity)
655 { 649 {
656 VisiblePosition pos; 650 VisiblePosition pos;
657 switch (granularity) { 651 switch (granularity) {
658 case CharacterGranularity: 652 case CharacterGranularity:
659 if (isRange()) { 653 if (isRange()) {
660 if (directionOfSelection() == LTR) 654 if (directionOfSelection() == LTR)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 break; 757 break;
764 case SentenceGranularity: 758 case SentenceGranularity:
765 case LineGranularity: 759 case LineGranularity:
766 case ParagraphGranularity: 760 case ParagraphGranularity:
767 case SentenceBoundary: 761 case SentenceBoundary:
768 case ParagraphBoundary: 762 case ParagraphBoundary:
769 case DocumentBoundary: 763 case DocumentBoundary:
770 pos = modifyExtendingBackward(granularity); 764 pos = modifyExtendingBackward(granularity);
771 break; 765 break;
772 } 766 }
773 #if ENABLE(USERSELECT_ALL)
774 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR)); 767 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR));
775 #endif
776 return pos; 768 return pos;
777 } 769 }
778 770
779 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity) 771 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity)
780 { 772 {
781 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); 773 VisiblePosition pos(m_selection.extent(), m_selection.affinity());
782 774
783 // Extending a selection backward by word or character from just after a tab le selects 775 // Extending a selection backward by word or character from just after a tab le selects
784 // the table. This "makes sense" from the user perspective, esp. when delet ing. 776 // the table. This "makes sense" from the user perspective, esp. when delet ing.
785 // It was done here instead of in VisiblePosition because we want VPs to ite rate 777 // It was done here instead of in VisiblePosition because we want VPs to ite rate
(...skipping 24 matching lines...) Expand all
810 pos = startOfParagraph(startForPlatform()); 802 pos = startOfParagraph(startForPlatform());
811 break; 803 break;
812 case DocumentBoundary: 804 case DocumentBoundary:
813 pos = startForPlatform(); 805 pos = startForPlatform();
814 if (isEditablePosition(pos.deepEquivalent())) 806 if (isEditablePosition(pos.deepEquivalent()))
815 pos = startOfEditableContent(pos); 807 pos = startOfEditableContent(pos);
816 else 808 else
817 pos = startOfDocument(pos); 809 pos = startOfDocument(pos);
818 break; 810 break;
819 } 811 }
820 #if ENABLE(USERSELECT_ALL)
821 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR)); 812 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR));
822 #endif
823 return pos; 813 return pos;
824 } 814 }
825 815
826 VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity) 816 VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity)
827 { 817 {
828 VisiblePosition pos; 818 VisiblePosition pos;
829 switch (granularity) { 819 switch (granularity) {
830 case CharacterGranularity: 820 case CharacterGranularity:
831 if (isRange()) 821 if (isRange())
832 if (directionOfSelection() == LTR) 822 if (directionOfSelection() == LTR)
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 sel.showTreeForThis(); 1930 sel.showTreeForThis();
1941 } 1931 }
1942 1932
1943 void showTree(const WebCore::FrameSelection* sel) 1933 void showTree(const WebCore::FrameSelection* sel)
1944 { 1934 {
1945 if (sel) 1935 if (sel)
1946 sel->showTreeForThis(); 1936 sel->showTreeForThis();
1947 } 1937 }
1948 1938
1949 #endif 1939 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698