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

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

Issue 2920733002: Rename VisibleSelection::end() to End() (Closed)
Patch Set: 2017-06-01T18:31:38 Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/commands/InsertIncrementalTextCommand.h" 5 #include "core/editing/commands/InsertIncrementalTextCommand.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/Text.h" 9 #include "core/dom/Text.h"
10 #include "core/editing/EditingUtilities.h" 10 #include "core/editing/EditingUtilities.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const String& text, 130 const String& text,
131 bool select_inserted_text, 131 bool select_inserted_text,
132 RebalanceType rebalance_type) 132 RebalanceType rebalance_type)
133 : InsertTextCommand(document, text, select_inserted_text, rebalance_type) {} 133 : InsertTextCommand(document, text, select_inserted_text, rebalance_type) {}
134 134
135 void InsertIncrementalTextCommand::DoApply(EditingState* editing_state) { 135 void InsertIncrementalTextCommand::DoApply(EditingState* editing_state) {
136 const Element* element = EndingSelection().RootEditableElement(); 136 const Element* element = EndingSelection().RootEditableElement();
137 DCHECK(element); 137 DCHECK(element);
138 138
139 const EphemeralRange selection_range(EndingSelection().Start(), 139 const EphemeralRange selection_range(EndingSelection().Start(),
140 EndingSelection().end()); 140 EndingSelection().End());
141 const String old_text = PlainText(selection_range); 141 const String old_text = PlainText(selection_range);
142 const String& new_text = text_; 142 const String& new_text = text_;
143 143
144 const Position& selection_start = EndingSelection().Start(); 144 const Position& selection_start = EndingSelection().Start();
145 const size_t new_text_length = new_text.length(); 145 const size_t new_text_length = new_text.length();
146 const size_t old_text_length = old_text.length(); 146 const size_t old_text_length = old_text.length();
147 const size_t common_prefix_length = ComputeCommonGraphemeClusterPrefixLength( 147 const size_t common_prefix_length = ComputeCommonGraphemeClusterPrefixLength(
148 selection_start, old_text, new_text); 148 selection_start, old_text, new_text);
149 // We should ignore common prefix when finding common suffix. 149 // We should ignore common prefix when finding common suffix.
150 const size_t common_suffix_length = ComputeCommonGraphemeClusterSuffixLength( 150 const size_t common_suffix_length = ComputeCommonGraphemeClusterSuffixLength(
151 selection_start, old_text.Right(old_text_length - common_prefix_length), 151 selection_start, old_text.Right(old_text_length - common_prefix_length),
152 new_text.Right(new_text_length - common_prefix_length)); 152 new_text.Right(new_text_length - common_prefix_length));
153 DCHECK_GE(old_text_length, common_prefix_length + common_suffix_length); 153 DCHECK_GE(old_text_length, common_prefix_length + common_suffix_length);
154 154
155 text_ = ComputeTextForInsertion(text_, common_prefix_length, 155 text_ = ComputeTextForInsertion(text_, common_prefix_length,
156 common_suffix_length); 156 common_suffix_length);
157 157
158 const int offset = static_cast<int>(common_prefix_length); 158 const int offset = static_cast<int>(common_prefix_length);
159 const int length = static_cast<int>(old_text_length - common_prefix_length - 159 const int length = static_cast<int>(old_text_length - common_prefix_length -
160 common_suffix_length); 160 common_suffix_length);
161 const VisibleSelection& selection_for_insertion = 161 const VisibleSelection& selection_for_insertion =
162 ComputeSelectionForInsertion(selection_range, offset, length, 162 ComputeSelectionForInsertion(selection_range, offset, length,
163 EndingSelection().IsDirectional()); 163 EndingSelection().IsDirectional());
164 164
165 SetEndingSelectionWithoutValidation(selection_for_insertion.Start(), 165 SetEndingSelectionWithoutValidation(selection_for_insertion.Start(),
166 selection_for_insertion.end()); 166 selection_for_insertion.End());
167 167
168 InsertTextCommand::DoApply(editing_state); 168 InsertTextCommand::DoApply(editing_state);
169 } 169 }
170 170
171 } // namespace blink 171 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698