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

Side by Side Diff: Source/core/editing/commands/InsertTextCommand.cpp

Issue 1305963003: Introduce {next,previous}PositionOf() as replacement of {next,previous}() member functions in Positi (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-22T00:12:04 Rebase Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 Apple Computer, 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 startPosition = positionBeforeStartNode; 179 startPosition = positionBeforeStartNode;
180 if (!isVisuallyEquivalentCandidate(startPosition)) 180 if (!isVisuallyEquivalentCandidate(startPosition))
181 startPosition = startPosition.downstream(); 181 startPosition = startPosition.downstream();
182 182
183 startPosition = positionAvoidingSpecialElementBoundary(startPosition); 183 startPosition = positionAvoidingSpecialElementBoundary(startPosition);
184 184
185 Position endPosition; 185 Position endPosition;
186 186
187 if (m_text == "\t") { 187 if (m_text == "\t") {
188 endPosition = insertTab(startPosition); 188 endPosition = insertTab(startPosition);
189 startPosition = endPosition.previous(); 189 // TODO(yosin) We should use |PositionMoveType::Character| for
190 // |previousPositionOf()|.
191 startPosition = previousPositionOf(endPosition, PositionMoveType::Charac ter);
190 if (placeholder.isNotNull()) 192 if (placeholder.isNotNull())
191 removePlaceholderAt(placeholder); 193 removePlaceholderAt(placeholder);
192 } else { 194 } else {
193 // Make sure the document is set up to receive m_text 195 // Make sure the document is set up to receive m_text
194 startPosition = positionInsideTextNode(startPosition); 196 startPosition = positionInsideTextNode(startPosition);
195 ASSERT(startPosition.isOffsetInAnchor()); 197 ASSERT(startPosition.isOffsetInAnchor());
196 ASSERT(startPosition.computeContainerNode()); 198 ASSERT(startPosition.computeContainerNode());
197 ASSERT(startPosition.computeContainerNode()->isTextNode()); 199 ASSERT(startPosition.computeContainerNode()->isTextNode());
198 if (placeholder.isNotNull()) 200 if (placeholder.isNotNull())
199 removePlaceholderAt(placeholder); 201 removePlaceholderAt(placeholder);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 splitTextNode(textNode, offset); 266 splitTextNode(textNode, offset);
265 insertNodeBefore(spanElement, textNode.release()); 267 insertNodeBefore(spanElement, textNode.release());
266 } 268 }
267 } 269 }
268 270
269 // return the position following the new tab 271 // return the position following the new tab
270 return lastPositionInNode(spanElement.get()); 272 return lastPositionInNode(spanElement.get());
271 } 273 }
272 274
273 } 275 }
OLDNEW
« no previous file with comments | « Source/core/editing/commands/BreakBlockquoteCommand.cpp ('k') | Source/core/editing/commands/TypingCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698