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

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

Issue 1695153002: Editing: Make the |EditingState*| argument of CompositeEditCommand::removeNode mandatory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ; Created 4 years, 10 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, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 RefPtrWillBeRawPtr<Element> child = ancestors[i - 1]->cloneElementWithou tChildren(); 141 RefPtrWillBeRawPtr<Element> child = ancestors[i - 1]->cloneElementWithou tChildren();
142 // It should always be okay to remove id from the cloned elements, since the originals are not deleted. 142 // It should always be okay to remove id from the cloned elements, since the originals are not deleted.
143 child->removeAttribute(idAttr); 143 child->removeAttribute(idAttr);
144 appendNode(child, parent); 144 appendNode(child, parent);
145 parent = child.release(); 145 parent = child.release();
146 } 146 }
147 147
148 return parent.release(); 148 return parent.release();
149 } 149 }
150 150
151 void InsertParagraphSeparatorCommand::doApply(EditingState*) 151 void InsertParagraphSeparatorCommand::doApply(EditingState* editingState)
152 { 152 {
153 if (!endingSelection().isNonOrphanedCaretOrRange()) 153 if (!endingSelection().isNonOrphanedCaretOrRange())
154 return; 154 return;
155 155
156 Position insertionPosition = endingSelection().start(); 156 Position insertionPosition = endingSelection().start();
157 157
158 TextAffinity affinity = endingSelection().affinity(); 158 TextAffinity affinity = endingSelection().affinity();
159 159
160 // Delete the current selection. 160 // Delete the current selection.
161 if (endingSelection().isRange()) { 161 if (endingSelection().isRange()) {
(...skipping 24 matching lines...) Expand all
186 if (!isVisuallyEquivalentCandidate(insertionPosition)) 186 if (!isVisuallyEquivalentCandidate(insertionPosition))
187 insertionPosition = mostForwardCaretPosition(insertionPosition); 187 insertionPosition = mostForwardCaretPosition(insertionPosition);
188 188
189 // Adjust the insertion position after the delete 189 // Adjust the insertion position after the delete
190 insertionPosition = positionAvoidingSpecialElementBoundary(insertionPosition , ASSERT_NO_EDITING_ABORT); 190 insertionPosition = positionAvoidingSpecialElementBoundary(insertionPosition , ASSERT_NO_EDITING_ABORT);
191 VisiblePosition visiblePos = createVisiblePosition(insertionPosition, affini ty); 191 VisiblePosition visiblePos = createVisiblePosition(insertionPosition, affini ty);
192 calculateStyleBeforeInsertion(insertionPosition); 192 calculateStyleBeforeInsertion(insertionPosition);
193 193
194 //--------------------------------------------------------------------- 194 //---------------------------------------------------------------------
195 // Handle special case of typing return on an empty list item 195 // Handle special case of typing return on an empty list item
196 if (breakOutOfEmptyListItem()) 196 if (breakOutOfEmptyListItem(editingState) || editingState->isAborted())
197 return; 197 return;
198 198
199 //--------------------------------------------------------------------- 199 //---------------------------------------------------------------------
200 // Prepare for more general cases. 200 // Prepare for more general cases.
201 201
202 bool isFirstInBlock = isStartOfBlock(visiblePos); 202 bool isFirstInBlock = isStartOfBlock(visiblePos);
203 bool isLastInBlock = isEndOfBlock(visiblePos); 203 bool isLastInBlock = isEndOfBlock(visiblePos);
204 bool nestNewBlock = false; 204 bool nestNewBlock = false;
205 205
206 // Create block to be inserted. 206 // Create block to be inserted.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 ASSERT(splitTo); 403 ASSERT(splitTo);
404 splitTreeToNode(splitTo, startBlock.get()); 404 splitTreeToNode(splitTo, startBlock.get());
405 405
406 for (n = startBlock->firstChild(); n; n = n->nextSibling()) { 406 for (n = startBlock->firstChild(); n; n = n->nextSibling()) {
407 VisiblePosition beforeNodePosition = createVisiblePosition(posit ionBeforeNode(n)); 407 VisiblePosition beforeNodePosition = createVisiblePosition(posit ionBeforeNode(n));
408 if (!beforeNodePosition.isNull() && comparePositions(createVisib lePosition(insertionPosition), beforeNodePosition) <= 0) 408 if (!beforeNodePosition.isNull() && comparePositions(createVisib lePosition(insertionPosition), beforeNodePosition) <= 0)
409 break; 409 break;
410 } 410 }
411 } 411 }
412 412
413 moveRemainingSiblingsToNewParent(n, blockToInsert.get(), blockToInsert); 413 moveRemainingSiblingsToNewParent(n, blockToInsert.get(), blockToInsert, editingState);
414 if (editingState->isAborted())
415 return;
414 } 416 }
415 417
416 // Handle whitespace that occurs after the split 418 // Handle whitespace that occurs after the split
417 if (positionAfterSplit.isNotNull()) { 419 if (positionAfterSplit.isNotNull()) {
418 document().updateLayoutIgnorePendingStylesheets(); 420 document().updateLayoutIgnorePendingStylesheets();
419 // TODO(yosin) |isRenderedCharacter()| should be removed, and we should 421 // TODO(yosin) |isRenderedCharacter()| should be removed, and we should
420 // use |VisiblePosition::characterAfter()|. 422 // use |VisiblePosition::characterAfter()|.
421 if (!isRenderedCharacter(positionAfterSplit)) { 423 if (!isRenderedCharacter(positionAfterSplit)) {
422 // Clear out all whitespace and insert one non-breaking space 424 // Clear out all whitespace and insert one non-breaking space
423 ASSERT(!positionAfterSplit.computeContainerNode()->layoutObject() || positionAfterSplit.computeContainerNode()->layoutObject()->style()->collapseWhi teSpace()); 425 ASSERT(!positionAfterSplit.computeContainerNode()->layoutObject() || positionAfterSplit.computeContainerNode()->layoutObject()->style()->collapseWhi teSpace());
424 deleteInsignificantTextDownstream(positionAfterSplit); 426 deleteInsignificantTextDownstream(positionAfterSplit);
425 if (positionAfterSplit.anchorNode()->isTextNode()) 427 if (positionAfterSplit.anchorNode()->isTextNode())
426 insertTextIntoNode(toText(positionAfterSplit.computeContainerNod e()), 0, nonBreakingSpaceString()); 428 insertTextIntoNode(toText(positionAfterSplit.computeContainerNod e()), 0, nonBreakingSpaceString());
427 } 429 }
428 } 430 }
429 431
430 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get()) , TextAffinity::Downstream, endingSelection().isDirectional())); 432 setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert.get()) , TextAffinity::Downstream, endingSelection().isDirectional()));
431 applyStyleAfterInsertion(startBlock.get()); 433 applyStyleAfterInsertion(startBlock.get());
432 } 434 }
433 435
434 DEFINE_TRACE(InsertParagraphSeparatorCommand) 436 DEFINE_TRACE(InsertParagraphSeparatorCommand)
435 { 437 {
436 visitor->trace(m_style); 438 visitor->trace(m_style);
437 CompositeEditCommand::trace(visitor); 439 CompositeEditCommand::trace(visitor);
438 } 440 }
439 441
440 442
441 } // namespace blink 443 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698