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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp

Issue 2952973002: Introduce VisibleSelection::CreateWithoutValidationDeprecated() (Closed)
Patch Set: 2017-06-23T09:54:35 Created 3 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleSelection.cpp ('k') | no next file » | 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) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 selection_to_delete = selection_modifier.Selection(); 802 selection_to_delete = selection_modifier.Selection();
803 803
804 if (granularity == kCharacterGranularity && 804 if (granularity == kCharacterGranularity &&
805 selection_to_delete.End().ComputeContainerNode() == 805 selection_to_delete.End().ComputeContainerNode() ==
806 selection_to_delete.Start().ComputeContainerNode() && 806 selection_to_delete.Start().ComputeContainerNode() &&
807 selection_to_delete.End().ComputeOffsetInContainerNode() - 807 selection_to_delete.End().ComputeOffsetInContainerNode() -
808 selection_to_delete.Start().ComputeOffsetInContainerNode() > 808 selection_to_delete.Start().ComputeOffsetInContainerNode() >
809 1) { 809 1) {
810 // If there are multiple Unicode code points to be deleted, adjust the 810 // If there are multiple Unicode code points to be deleted, adjust the
811 // range to match platform conventions. 811 // range to match platform conventions.
812 selection_to_delete.SetWithoutValidation( 812 selection_to_delete =
813 selection_to_delete.End(), 813 VisibleSelection::CreateWithoutValidationDeprecated(
814 PreviousPositionOf(selection_to_delete.End(), 814 selection_to_delete.End(),
815 PositionMoveType::kBackwardDeletion)); 815 PreviousPositionOf(selection_to_delete.End(),
816 PositionMoveType::kBackwardDeletion),
817 selection_to_delete.Affinity());
816 } 818 }
817 819
818 if (!StartingSelection().IsRange() || 820 if (!StartingSelection().IsRange() ||
819 selection_to_delete.Base() != StartingSelection().Start()) { 821 selection_to_delete.Base() != StartingSelection().Start()) {
820 selection_after_undo = selection_to_delete; 822 selection_after_undo = selection_to_delete;
821 } else { 823 } else {
822 // It's a little tricky to compute what the starting selection would 824 // It's a little tricky to compute what the starting selection would
823 // have been in the original document. We can't let the VisibleSelection 825 // have been in the original document. We can't let the VisibleSelection
824 // class's validation kick in or it'll adjust for us based on the 826 // class's validation kick in or it'll adjust for us based on the
825 // current state of the document and we'll get the wrong result. 827 // current state of the document and we'll get the wrong result.
826 selection_after_undo.SetWithoutValidation(StartingSelection().End(), 828 selection_after_undo =
827 selection_to_delete.Extent()); 829 VisibleSelection::CreateWithoutValidationDeprecated(
830 StartingSelection().End(), selection_to_delete.Extent(),
831 selection_after_undo.Affinity());
828 } 832 }
829 break; 833 break;
830 } 834 }
831 case kNoSelection: 835 case kNoSelection:
832 NOTREACHED(); 836 NOTREACHED();
833 break; 837 break;
834 } 838 }
835 839
836 DCHECK(!selection_to_delete.IsNone()); 840 DCHECK(!selection_to_delete.IsNone());
837 if (selection_to_delete.IsNone()) 841 if (selection_to_delete.IsNone())
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 extra_characters = 952 extra_characters =
949 selection_to_delete.End().ComputeOffsetInContainerNode() - 953 selection_to_delete.End().ComputeOffsetInContainerNode() -
950 selection_to_delete.Start().ComputeOffsetInContainerNode(); 954 selection_to_delete.Start().ComputeOffsetInContainerNode();
951 else 955 else
952 extra_characters = 956 extra_characters =
953 selection_to_delete.End().ComputeOffsetInContainerNode(); 957 selection_to_delete.End().ComputeOffsetInContainerNode();
954 extent = Position( 958 extent = Position(
955 extent.ComputeContainerNode(), 959 extent.ComputeContainerNode(),
956 extent.ComputeOffsetInContainerNode() + extra_characters); 960 extent.ComputeOffsetInContainerNode() + extra_characters);
957 } 961 }
958 selection_after_undo.SetWithoutValidation(StartingSelection().Start(), 962 selection_after_undo =
959 extent); 963 VisibleSelection::CreateWithoutValidationDeprecated(
964 StartingSelection().Start(), extent,
965 selection_after_undo.Affinity());
960 } 966 }
961 break; 967 break;
962 } 968 }
963 case kNoSelection: 969 case kNoSelection:
964 NOTREACHED(); 970 NOTREACHED();
965 break; 971 break;
966 } 972 }
967 973
968 DCHECK(!selection_to_delete.IsNone()); 974 DCHECK(!selection_to_delete.IsNone());
969 if (selection_to_delete.IsNone()) 975 if (selection_to_delete.IsNone())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 } 1015 }
1010 NOTREACHED(); 1016 NOTREACHED();
1011 preserves_typing_style_ = false; 1017 preserves_typing_style_ = false;
1012 } 1018 }
1013 1019
1014 bool TypingCommand::IsTypingCommand() const { 1020 bool TypingCommand::IsTypingCommand() const {
1015 return true; 1021 return true;
1016 } 1022 }
1017 1023
1018 } // namespace blink 1024 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698