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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/TypingCommand.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
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/TypingCommand.h ('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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // Breaking the blockquote would also break apart the table, which is uneces sary when inserting a newline 379 // Breaking the blockquote would also break apart the table, which is uneces sary when inserting a newline
380 if (enclosingNodeOfType(endingSelection().start(), &isTableStructureNode)) { 380 if (enclosingNodeOfType(endingSelection().start(), &isTableStructureNode)) {
381 insertParagraphSeparator(); 381 insertParagraphSeparator();
382 return; 382 return;
383 } 383 }
384 384
385 applyCommandToComposite(BreakBlockquoteCommand::create(document())); 385 applyCommandToComposite(BreakBlockquoteCommand::create(document()));
386 typingAddedToOpenCommand(InsertParagraphSeparatorInQuotedContent); 386 typingAddedToOpenCommand(InsertParagraphSeparatorInQuotedContent);
387 } 387 }
388 388
389 bool TypingCommand::makeEditableRootEmpty() 389 bool TypingCommand::makeEditableRootEmpty(EditingState* editingState)
390 { 390 {
391 Element* root = endingSelection().rootEditableElement(); 391 Element* root = endingSelection().rootEditableElement();
392 if (!root || !root->hasChildren()) 392 if (!root || !root->hasChildren())
393 return false; 393 return false;
394 394
395 if (root->firstChild() == root->lastChild()) { 395 if (root->firstChild() == root->lastChild()) {
396 if (isHTMLBRElement(root->firstChild())) { 396 if (isHTMLBRElement(root->firstChild())) {
397 // If there is a single child and it could be a placeholder, leave i t alone. 397 // If there is a single child and it could be a placeholder, leave i t alone.
398 if (root->layoutObject() && root->layoutObject()->isLayoutBlockFlow( )) 398 if (root->layoutObject() && root->layoutObject()->isLayoutBlockFlow( ))
399 return false; 399 return false;
400 } 400 }
401 } 401 }
402 402
403 while (Node* child = root->firstChild()) 403 while (Node* child = root->firstChild()) {
404 removeNode(child); 404 removeNode(child, editingState);
405 if (editingState->isAborted())
406 return false;
407 }
405 408
406 addBlockPlaceholderIfNeeded(root); 409 addBlockPlaceholderIfNeeded(root);
407 setEndingSelection(VisibleSelection(firstPositionInNode(root), TextAffinity: :Downstream, endingSelection().isDirectional())); 410 setEndingSelection(VisibleSelection(firstPositionInNode(root), TextAffinity: :Downstream, endingSelection().isDirectional()));
408 411
409 return true; 412 return true;
410 } 413 }
411 414
412 void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing, EditingState* editingState) 415 void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing, EditingState* editingState)
413 { 416 {
414 LocalFrame* frame = document().frame(); 417 LocalFrame* frame = document().frame();
415 if (!frame) 418 if (!frame)
416 return; 419 return;
417 420
418 frame->spellChecker().updateMarkersForWordsAffectedByEditing(false); 421 frame->spellChecker().updateMarkersForWordsAffectedByEditing(false);
419 422
420 VisibleSelection selectionToDelete; 423 VisibleSelection selectionToDelete;
421 VisibleSelection selectionAfterUndo; 424 VisibleSelection selectionAfterUndo;
422 425
423 switch (endingSelection().selectionType()) { 426 switch (endingSelection().selectionType()) {
424 case RangeSelection: 427 case RangeSelection:
425 selectionToDelete = endingSelection(); 428 selectionToDelete = endingSelection();
426 selectionAfterUndo = selectionToDelete; 429 selectionAfterUndo = selectionToDelete;
427 break; 430 break;
428 case CaretSelection: { 431 case CaretSelection: {
429 // After breaking out of an empty mail blockquote, we still want continu e with the deletion 432 // After breaking out of an empty mail blockquote, we still want continu e with the deletion
430 // so actual content will get deleted, and not just the quote style. 433 // so actual content will get deleted, and not just the quote style.
431 if (breakOutOfEmptyMailBlockquotedParagraph()) 434 bool breakOutResult = breakOutOfEmptyMailBlockquotedParagraph(editingSta te);
435 if (editingState->isAborted())
436 return;
437 if (breakOutResult)
432 typingAddedToOpenCommand(DeleteKey); 438 typingAddedToOpenCommand(DeleteKey);
433 439
434 m_smartDelete = false; 440 m_smartDelete = false;
435 441
436 OwnPtrWillBeRawPtr<FrameSelection> selection = FrameSelection::create(); 442 OwnPtrWillBeRawPtr<FrameSelection> selection = FrameSelection::create();
437 selection->setSelection(endingSelection()); 443 selection->setSelection(endingSelection());
438 selection->modify(FrameSelection::AlterationExtend, DirectionBackward, g ranularity); 444 selection->modify(FrameSelection::AlterationExtend, DirectionBackward, g ranularity);
439 if (killRing && selection->isCaret() && granularity != CharacterGranular ity) 445 if (killRing && selection->isCaret() && granularity != CharacterGranular ity)
440 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar d, CharacterGranularity); 446 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar d, CharacterGranularity);
441 447
442 VisiblePosition visibleStart(endingSelection().visibleStart()); 448 VisiblePosition visibleStart(endingSelection().visibleStart());
443 if (previousPositionOf(visibleStart, CannotCrossEditingBoundary).isNull( )) { 449 if (previousPositionOf(visibleStart, CannotCrossEditingBoundary).isNull( )) {
444 // When the caret is at the start of the editable area in an empty l ist item, break out of the list item. 450 // When the caret is at the start of the editable area in an empty l ist item, break out of the list item.
445 if (breakOutOfEmptyListItem()) { 451 bool breakOutOfEmptyListItemResult = breakOutOfEmptyListItem(editing State);
452 if (editingState->isAborted())
453 return;
454 if (breakOutOfEmptyListItemResult) {
446 typingAddedToOpenCommand(DeleteKey); 455 typingAddedToOpenCommand(DeleteKey);
447 return; 456 return;
448 } 457 }
449 // When there are no visible positions in the editing root, delete i ts entire contents. 458 // When there are no visible positions in the editing root, delete i ts entire contents.
450 if (nextPositionOf(visibleStart, CannotCrossEditingBoundary).isNull( ) && makeEditableRootEmpty()) { 459 if (nextPositionOf(visibleStart, CannotCrossEditingBoundary).isNull( ) && makeEditableRootEmpty(editingState)) {
451 typingAddedToOpenCommand(DeleteKey); 460 typingAddedToOpenCommand(DeleteKey);
452 return; 461 return;
453 } 462 }
463 if (editingState->isAborted())
464 return;
454 } 465 }
455 466
456 // If we have a caret selection at the beginning of a cell, we have noth ing to do. 467 // If we have a caret selection at the beginning of a cell, we have noth ing to do.
457 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale nt(), &isTableCell); 468 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale nt(), &isTableCell);
458 if (enclosingTableCell && visibleStart.deepEquivalent() == createVisible Position(firstPositionInNode(enclosingTableCell)).deepEquivalent()) 469 if (enclosingTableCell && visibleStart.deepEquivalent() == createVisible Position(firstPositionInNode(enclosingTableCell)).deepEquivalent())
459 return; 470 return;
460 471
461 // If the caret is at the start of a paragraph after a table, move conte nt into the last table cell. 472 // If the caret is at the start of a paragraph after a table, move conte nt into the last table cell.
462 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(previo usPositionOf(visibleStart, CannotCrossEditingBoundary))) { 473 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(previo usPositionOf(visibleStart, CannotCrossEditingBoundary))) {
463 // Unless the caret is just before a table. We don't want to move a table into the last table cell. 474 // Unless the caret is just before a table. We don't want to move a table into the last table cell.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 ASSERT_NOT_REACHED(); 641 ASSERT_NOT_REACHED();
631 m_preservesTypingStyle = false; 642 m_preservesTypingStyle = false;
632 } 643 }
633 644
634 bool TypingCommand::isTypingCommand() const 645 bool TypingCommand::isTypingCommand() const
635 { 646 {
636 return true; 647 return true;
637 } 648 }
638 649
639 } // namespace blink 650 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/TypingCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698