Chromium Code Reviews| 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 { |
| 562 if (!RuntimeEnabledFeatures::userSelectAllEnabled()) | |
|
adamk
2013/08/09 22:28:34
You can avoid this since rootUserSelectAlLForNode(
| |
| 563 return; | |
| 564 | |
| 563 if (Node* rootUserSelectAll = Position::rootUserSelectAllForNode(pos.deepEqu ivalent().anchorNode())) | 565 if (Node* rootUserSelectAll = Position::rootUserSelectAllForNode(pos.deepEqu ivalent().anchorNode())) |
| 564 pos = isForward ? positionAfterNode(rootUserSelectAll).downstream(CanCro ssEditingBoundary) : positionBeforeNode(rootUserSelectAll).upstream(CanCrossEdit ingBoundary); | 566 pos = isForward ? positionAfterNode(rootUserSelectAll).downstream(CanCro ssEditingBoundary) : positionBeforeNode(rootUserSelectAll).upstream(CanCrossEdit ingBoundary); |
| 565 } | 567 } |
| 566 #endif | |
| 567 | 568 |
| 568 VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity ) | 569 VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity ) |
| 569 { | 570 { |
| 570 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 571 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
| 571 | 572 |
| 572 // The difference between modifyExtendingRight and modifyExtendingForward is : | 573 // The difference between modifyExtendingRight and modifyExtendingForward is : |
| 573 // modifyExtendingForward always extends forward logically. | 574 // modifyExtendingForward always extends forward logically. |
| 574 // modifyExtendingRight behaves the same as modifyExtendingForward except fo r extending character or word, | 575 // 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, | 576 // it extends forward logically if the enclosing block is LTR direction, |
| 576 // but it extends backward logically if the enclosing block is RTL direction . | 577 // but it extends backward logically if the enclosing block is RTL direction . |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 596 case SentenceGranularity: | 597 case SentenceGranularity: |
| 597 case LineGranularity: | 598 case LineGranularity: |
| 598 case ParagraphGranularity: | 599 case ParagraphGranularity: |
| 599 case SentenceBoundary: | 600 case SentenceBoundary: |
| 600 case ParagraphBoundary: | 601 case ParagraphBoundary: |
| 601 case DocumentBoundary: | 602 case DocumentBoundary: |
| 602 // FIXME: implement all of the above? | 603 // FIXME: implement all of the above? |
| 603 pos = modifyExtendingForward(granularity); | 604 pos = modifyExtendingForward(granularity); |
| 604 break; | 605 break; |
| 605 } | 606 } |
| 606 #if ENABLE(USERSELECT_ALL) | |
| 607 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); | 607 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); |
| 608 #endif | |
| 609 return pos; | 608 return pos; |
| 610 } | 609 } |
| 611 | 610 |
| 612 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty) | 611 VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari ty) |
| 613 { | 612 { |
| 614 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 613 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
| 615 switch (granularity) { | 614 switch (granularity) { |
| 616 case CharacterGranularity: | 615 case CharacterGranularity: |
| 617 pos = pos.next(CannotCrossEditingBoundary); | 616 pos = pos.next(CannotCrossEditingBoundary); |
| 618 break; | 617 break; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 638 pos = endOfParagraph(endForPlatform()); | 637 pos = endOfParagraph(endForPlatform()); |
| 639 break; | 638 break; |
| 640 case DocumentBoundary: | 639 case DocumentBoundary: |
| 641 pos = endForPlatform(); | 640 pos = endForPlatform(); |
| 642 if (isEditablePosition(pos.deepEquivalent())) | 641 if (isEditablePosition(pos.deepEquivalent())) |
| 643 pos = endOfEditableContent(pos); | 642 pos = endOfEditableContent(pos); |
| 644 else | 643 else |
| 645 pos = endOfDocument(pos); | 644 pos = endOfDocument(pos); |
| 646 break; | 645 break; |
| 647 } | 646 } |
| 648 #if ENABLE(USERSELECT_ALL) | 647 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); |
| 649 adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR); | |
| 650 #endif | |
| 651 return pos; | 648 return pos; |
| 652 } | 649 } |
| 653 | 650 |
| 654 VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity) | 651 VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity) |
| 655 { | 652 { |
| 656 VisiblePosition pos; | 653 VisiblePosition pos; |
| 657 switch (granularity) { | 654 switch (granularity) { |
| 658 case CharacterGranularity: | 655 case CharacterGranularity: |
| 659 if (isRange()) { | 656 if (isRange()) { |
| 660 if (directionOfSelection() == LTR) | 657 if (directionOfSelection() == LTR) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 break; | 760 break; |
| 764 case SentenceGranularity: | 761 case SentenceGranularity: |
| 765 case LineGranularity: | 762 case LineGranularity: |
| 766 case ParagraphGranularity: | 763 case ParagraphGranularity: |
| 767 case SentenceBoundary: | 764 case SentenceBoundary: |
| 768 case ParagraphBoundary: | 765 case ParagraphBoundary: |
| 769 case DocumentBoundary: | 766 case DocumentBoundary: |
| 770 pos = modifyExtendingBackward(granularity); | 767 pos = modifyExtendingBackward(granularity); |
| 771 break; | 768 break; |
| 772 } | 769 } |
| 773 #if ENABLE(USERSELECT_ALL) | |
| 774 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR)); | 770 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR)); |
| 775 #endif | |
| 776 return pos; | 771 return pos; |
| 777 } | 772 } |
| 778 | 773 |
| 779 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity) | 774 VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular ity) |
| 780 { | 775 { |
| 781 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); | 776 VisiblePosition pos(m_selection.extent(), m_selection.affinity()); |
| 782 | 777 |
| 783 // Extending a selection backward by word or character from just after a tab le selects | 778 // 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. | 779 // 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 | 780 // It was done here instead of in VisiblePosition because we want VPs to ite rate |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 810 pos = startOfParagraph(startForPlatform()); | 805 pos = startOfParagraph(startForPlatform()); |
| 811 break; | 806 break; |
| 812 case DocumentBoundary: | 807 case DocumentBoundary: |
| 813 pos = startForPlatform(); | 808 pos = startForPlatform(); |
| 814 if (isEditablePosition(pos.deepEquivalent())) | 809 if (isEditablePosition(pos.deepEquivalent())) |
| 815 pos = startOfEditableContent(pos); | 810 pos = startOfEditableContent(pos); |
| 816 else | 811 else |
| 817 pos = startOfDocument(pos); | 812 pos = startOfDocument(pos); |
| 818 break; | 813 break; |
| 819 } | 814 } |
| 820 #if ENABLE(USERSELECT_ALL) | |
| 821 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR)); | 815 adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR)); |
| 822 #endif | |
| 823 return pos; | 816 return pos; |
| 824 } | 817 } |
| 825 | 818 |
| 826 VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity) | 819 VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity) |
| 827 { | 820 { |
| 828 VisiblePosition pos; | 821 VisiblePosition pos; |
| 829 switch (granularity) { | 822 switch (granularity) { |
| 830 case CharacterGranularity: | 823 case CharacterGranularity: |
| 831 if (isRange()) | 824 if (isRange()) |
| 832 if (directionOfSelection() == LTR) | 825 if (directionOfSelection() == LTR) |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1940 sel.showTreeForThis(); | 1933 sel.showTreeForThis(); |
| 1941 } | 1934 } |
| 1942 | 1935 |
| 1943 void showTree(const WebCore::FrameSelection* sel) | 1936 void showTree(const WebCore::FrameSelection* sel) |
| 1944 { | 1937 { |
| 1945 if (sel) | 1938 if (sel) |
| 1946 sel->showTreeForThis(); | 1939 sel->showTreeForThis(); |
| 1947 } | 1940 } |
| 1948 | 1941 |
| 1949 #endif | 1942 #endif |
| OLD | NEW |