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

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

Issue 2374743002: [InputEvent] Support |deleteByDrag|, |insertFromDrop| and fire in sequential order (Closed)
Patch Set: Created 4 years, 2 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) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 // FIXME: We should to move this down into deleteKeyPressed. 342 // FIXME: We should to move this down into deleteKeyPressed.
343 // clear the "start new kill ring sequence" setting, because it was set to t rue 343 // clear the "start new kill ring sequence" setting, because it was set to t rue
344 // when the selection was updated by deleting the range 344 // when the selection was updated by deleting the range
345 if (killRing) 345 if (killRing)
346 setStartNewKillRingSequence(false); 346 setStartNewKillRingSequence(false);
347 347
348 return true; 348 return true;
349 } 349 }
350 350
351 void Editor::deleteSelectionWithSmartDelete(bool smartDelete, InputEvent::InputT ype inputType) 351 void Editor::deleteSelectionWithSmartDelete(bool smartDelete, InputEvent::InputT ype inputType, const Position& referenceMovePosition)
352 { 352 {
353 if (frame().selection().isNone()) 353 if (frame().selection().isNone())
354 return; 354 return;
355 355
356 const bool kMergeBlocksAfterDelete = true; 356 const bool kMergeBlocksAfterDelete = true;
357 const bool kExpandForSpecialElements = false; 357 const bool kExpandForSpecialElements = false;
358 const bool kSanitizeMarkup = true; 358 const bool kSanitizeMarkup = true;
359 DCHECK(frame().document()); 359 DCHECK(frame().document());
360 DeleteSelectionCommand::create(*frame().document(), smartDelete, kMergeBlock sAfterDelete, kExpandForSpecialElements, kSanitizeMarkup, inputType)->apply(); 360 DeleteSelectionCommand::create(*frame().document(), smartDelete, kMergeBlock sAfterDelete, kExpandForSpecialElements, kSanitizeMarkup, inputType, referenceMo vePosition)->apply();
361 } 361 }
362 362
363 void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace) 363 void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace)
364 { 364 {
365 Element* target = findEventTargetFromSelection(); 365 Element* target = findEventTargetFromSelection();
366 if (!target) 366 if (!target)
367 return; 367 return;
368 target->dispatchEvent(TextEvent::createForPlainTextPaste(frame().domWindow() , pastingText, smartReplace)); 368 target->dispatchEvent(TextEvent::createForPlainTextPaste(frame().domWindow() , pastingText, smartReplace));
369 } 369 }
370 370
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 544
545 // TODO(xiaochengh): Merge it with |replaceSelectionWithFragment()|. 545 // TODO(xiaochengh): Merge it with |replaceSelectionWithFragment()|.
546 void Editor::replaceSelectionAfterDragging(DocumentFragment* fragment, bool smar tReplace, bool plainText) 546 void Editor::replaceSelectionAfterDragging(DocumentFragment* fragment, bool smar tReplace, bool plainText)
547 { 547 {
548 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::PreventNesting; 548 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::PreventNesting;
549 if (smartReplace) 549 if (smartReplace)
550 options |= ReplaceSelectionCommand::SmartReplace; 550 options |= ReplaceSelectionCommand::SmartReplace;
551 if (plainText) 551 if (plainText)
552 options |= ReplaceSelectionCommand::MatchStyle; 552 options |= ReplaceSelectionCommand::MatchStyle;
553 DCHECK(frame().document()); 553 DCHECK(frame().document());
554 ReplaceSelectionCommand::create(*frame().document(), fragment, options, Inpu tEvent::InputType::Drag)->apply(); 554 ReplaceSelectionCommand::create(*frame().document(), fragment, options, Inpu tEvent::InputType::InsertFromDrop)->apply();
555 } 555 }
556 556
557 void Editor::moveSelectionAfterDragging(DocumentFragment* fragment, const Positi on& pos, bool smartInsert, bool smartDelete) 557 void Editor::moveSelectionAfterDragging(DocumentFragment* fragment, const Positi on& pos, bool smartInsert, bool smartDelete)
558 { 558 {
559 MoveSelectionCommand::create(fragment, pos, smartInsert, smartDelete)->apply (); 559 MoveSelectionCommand::create(fragment, pos, smartInsert, smartDelete)->apply ();
560 } 560 }
561 561
562 EphemeralRange Editor::selectedRange() 562 EphemeralRange Editor::selectedRange()
563 { 563 {
564 return frame().selection().selection().toNormalizedEphemeralRange(); 564 return frame().selection().selection().toNormalizedEphemeralRange();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 712
713 // Don't clear the typing style with this selection change. We do those thin gs elsewhere if necessary. 713 // Don't clear the typing style with this selection change. We do those thin gs elsewhere if necessary.
714 changeSelectionAfterCommand(newSelection, 0); 714 changeSelectionAfterCommand(newSelection, 0);
715 715
716 if (!cmd->preservesTypingStyle()) 716 if (!cmd->preservesTypingStyle())
717 frame().selection().clearTypingStyle(); 717 frame().selection().clearTypingStyle();
718 718
719 // Command will be equal to last edit command only in the case of typing 719 // Command will be equal to last edit command only in the case of typing
720 if (m_lastEditCommand.get() == cmd) { 720 if (m_lastEditCommand.get() == cmd) {
721 DCHECK(cmd->isTypingCommand()); 721 DCHECK(cmd->isTypingCommand());
722 } else if (m_lastEditCommand && m_lastEditCommand->inputType() == InputEvent ::InputType::DeleteByDrag && cmd->inputType() == InputEvent::InputType::InsertFr omDrop) {
723 m_lastEditCommand->appendCommandToComposite(cmd);
724 m_lastEditCommand = cmd;
chongz 2016/09/28 02:19:26 Has potential issue. These 2 commands might be cre
yosin_UTC9 2016/09/28 04:19:03 How about having DragAndDropCommand, derived from
chongz 2016/09/29 02:36:22 Added command group wrapper |DragAndDropCommand|,
722 } else { 725 } else {
723 // Only register a new undo command if the command passed in is 726 // Only register a new undo command if the command passed in is
724 // different from the last command 727 // different from the last command
725 m_lastEditCommand = cmd; 728 m_lastEditCommand = cmd;
726 m_undoStack->registerUndoStep(m_lastEditCommand->ensureComposition()); 729 m_undoStack->registerUndoStep(m_lastEditCommand->ensureComposition());
727 } 730 }
728 731
729 respondToChangedContents(newSelection); 732 respondToChangedContents(newSelection);
730 } 733 }
731 734
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 1420
1418 DEFINE_TRACE(Editor) 1421 DEFINE_TRACE(Editor)
1419 { 1422 {
1420 visitor->trace(m_frame); 1423 visitor->trace(m_frame);
1421 visitor->trace(m_lastEditCommand); 1424 visitor->trace(m_lastEditCommand);
1422 visitor->trace(m_undoStack); 1425 visitor->trace(m_undoStack);
1423 visitor->trace(m_mark); 1426 visitor->trace(m_mark);
1424 } 1427 }
1425 1428
1426 } // namespace blink 1429 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698