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

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

Issue 1317053004: Make VisiblePosition constructor private (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-02T12:44:47 Rebase Created 5 years, 3 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 Position startPosition(endingSelection().start()); 152 Position startPosition(endingSelection().start());
153 153
154 Position placeholder; 154 Position placeholder;
155 // We want to remove preserved newlines and brs that will collapse (and thus become unnecessary) when content 155 // We want to remove preserved newlines and brs that will collapse (and thus become unnecessary) when content
156 // is inserted just before them. 156 // is inserted just before them.
157 // FIXME: We shouldn't really have to do this, but removing placeholders is a workaround for 9661. 157 // FIXME: We shouldn't really have to do this, but removing placeholders is a workaround for 9661.
158 // If the caret is just before a placeholder, downstream will normalize the caret to it. 158 // If the caret is just before a placeholder, downstream will normalize the caret to it.
159 Position downstream(mostForwardCaretPosition(startPosition)); 159 Position downstream(mostForwardCaretPosition(startPosition));
160 if (lineBreakExistsAtPosition(downstream)) { 160 if (lineBreakExistsAtPosition(downstream)) {
161 // FIXME: This doesn't handle placeholders at the end of anonymous block s. 161 // FIXME: This doesn't handle placeholders at the end of anonymous block s.
162 VisiblePosition caret(startPosition); 162 VisiblePosition caret = createVisiblePosition(startPosition);
163 if (isEndOfBlock(caret) && isStartOfParagraph(caret)) 163 if (isEndOfBlock(caret) && isStartOfParagraph(caret))
164 placeholder = downstream; 164 placeholder = downstream;
165 // Don't remove the placeholder yet, otherwise the block we're inserting into would collapse before 165 // Don't remove the placeholder yet, otherwise the block we're inserting into would collapse before
166 // we get a chance to insert into it. We check for a placeholder now, t hough, because doing so requires 166 // we get a chance to insert into it. We check for a placeholder now, t hough, because doing so requires
167 // the creation of a VisiblePosition, and if we did that post-insertion it would force a layout. 167 // the creation of a VisiblePosition, and if we did that post-insertion it would force a layout.
168 } 168 }
169 169
170 // Insert the character at the leftmost candidate. 170 // Insert the character at the leftmost candidate.
171 startPosition = mostBackwardCaretPosition(startPosition); 171 startPosition = mostBackwardCaretPosition(startPosition);
172 172
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (!typingStyle->isEmpty()) 226 if (!typingStyle->isEmpty())
227 applyStyle(typingStyle.get()); 227 applyStyle(typingStyle.get());
228 } 228 }
229 229
230 if (!m_selectInsertedText) 230 if (!m_selectInsertedText)
231 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec tion().affinity(), endingSelection().isDirectional())); 231 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec tion().affinity(), endingSelection().isDirectional()));
232 } 232 }
233 233
234 Position InsertTextCommand::insertTab(const Position& pos) 234 Position InsertTextCommand::insertTab(const Position& pos)
235 { 235 {
236 Position insertPos = VisiblePosition(pos).deepEquivalent(); 236 Position insertPos = createVisiblePosition(pos).deepEquivalent();
237 if (insertPos.isNull()) 237 if (insertPos.isNull())
238 return pos; 238 return pos;
239 239
240 Node* node = insertPos.computeContainerNode(); 240 Node* node = insertPos.computeContainerNode();
241 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0 ; 241 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0 ;
242 242
243 // keep tabs coalesced in tab span 243 // keep tabs coalesced in tab span
244 if (isTabHTMLSpanElementTextNode(node)) { 244 if (isTabHTMLSpanElementTextNode(node)) {
245 RefPtrWillBeRawPtr<Text> textNode = toText(node); 245 RefPtrWillBeRawPtr<Text> textNode = toText(node);
246 insertTextIntoNode(textNode, offset, "\t"); 246 insertTextIntoNode(textNode, offset, "\t");
(...skipping 19 matching lines...) Expand all
266 splitTextNode(textNode, offset); 266 splitTextNode(textNode, offset);
267 insertNodeBefore(spanElement, textNode.release()); 267 insertNodeBefore(spanElement, textNode.release());
268 } 268 }
269 } 269 }
270 270
271 // return the position following the new tab 271 // return the position following the new tab
272 return lastPositionInNode(spanElement.get()); 272 return lastPositionInNode(spanElement.get());
273 } 273 }
274 274
275 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698