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

Side by Side Diff: third_party/WebKit/Source/core/page/DragController.cpp

Issue 2558643003: [InputEvent] Move 'beforeinput' logic into |CompositeEditCommand::willApplyEditing()| (3/3) (Closed)
Patch Set: xiaocheng's review: Isolate |UndoStep| code; Move attribuates to private Created 3 years, 12 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) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Google Inc. 3 * Copyright (C) 2008 Google Inc.
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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 const DeleteMode deleteMode = 594 const DeleteMode deleteMode =
595 innerFrame->editor().smartInsertDeleteEnabled() ? DeleteMode::Smart 595 innerFrame->editor().smartInsertDeleteEnabled() ? DeleteMode::Smart
596 : DeleteMode::Simple; 596 : DeleteMode::Simple;
597 const InsertMode insertMode = 597 const InsertMode insertMode =
598 (deleteMode == DeleteMode::Smart && 598 (deleteMode == DeleteMode::Smart &&
599 innerFrame->selection().granularity() == WordGranularity && 599 innerFrame->selection().granularity() == WordGranularity &&
600 dragData->canSmartReplace()) 600 dragData->canSmartReplace())
601 ? InsertMode::Smart 601 ? InsertMode::Smart
602 : InsertMode::Simple; 602 : InsertMode::Simple;
603 603
604 if (!innerFrame->editor().deleteSelectionAfterDraggingWithEvents( 604 innerFrame->editor().deleteSelectionWithSmartDelete(
chongz 2016/12/20 23:27:53 Removed, drag deletion are covered by |DeleteSelec
605 innerFrame->editor().findEventTargetFromSelection(), deleteMode, 605 EditCommandSource::kMenuOrKeyBinding, deleteMode,
606 dragCaret.base())) 606 InputEvent::InputType::DeleteByDrag, dragCaret.base());
607
608 // 'beforeinput' event handler may destroy drop frame.
Xiaocheng 2016/12/21 02:56:39 Is it just 'beforeinput'? In fact is it a bug tha
chongz 2016/12/21 23:59:24 I've tested 'input' and it won't crash, so I think
609 if (innerFrame->document()->frame() != innerFrame ||
610 !element->isConnected())
607 return false; 611 return false;
608 612
609 innerFrame->selection().setSelection( 613 innerFrame->selection().setSelection(
610 SelectionInDOMTree::Builder() 614 SelectionInDOMTree::Builder()
611 .setBaseAndExtent(EphemeralRange(range)) 615 .setBaseAndExtent(EphemeralRange(range))
612 .build()); 616 .build());
613 if (innerFrame->selection().isAvailable()) { 617 if (innerFrame->selection().isAvailable()) {
614 DCHECK(m_documentUnderMouse); 618 DCHECK(m_documentUnderMouse);
615 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 619 innerFrame->editor().replaceSelectionAfterDragging(fragment, insertMode,
chongz 2016/12/20 23:27:53 Removed, drop replacing are covered by |ReplaceSel
616 element, dragData, fragment, range, insertMode, dragSourceType)) 620 dragSourceType);
617 return false;
618 } 621 }
619 } else { 622 } else {
620 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 623 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
621 DCHECK(m_documentUnderMouse); 624 DCHECK(m_documentUnderMouse);
622 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 625 innerFrame->editor().replaceSelectionAfterDragging(
chongz 2016/12/20 23:27:53 Removed, drop replacing are covered by |ReplaceSel
623 element, dragData, fragment, range, 626 fragment, dragData->canSmartReplace() ? InsertMode::Smart
624 dragData->canSmartReplace() ? InsertMode::Smart 627 : InsertMode::Simple,
625 : InsertMode::Simple, 628 dragSourceType);
626 dragSourceType))
627 return false;
628 } 629 }
629 } 630 }
630 } else { 631 } else {
631 String text = dragData->asPlainText(); 632 String text = dragData->asPlainText();
632 if (text.isEmpty()) 633 if (text.isEmpty())
633 return false; 634 return false;
634 635
635 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 636 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
636 DCHECK(m_documentUnderMouse); 637 DCHECK(m_documentUnderMouse);
637 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 638 innerFrame->editor().replaceSelectionAfterDragging(
chongz 2016/12/20 23:27:53 Removed, drop replacing are covered by |ReplaceSel
638 element, dragData, 639 createFragmentFromText(EphemeralRange(range), text),
639 createFragmentFromText(EphemeralRange(range), text), range, 640 InsertMode::Simple, DragSourceType::PlainTextSource);
640 InsertMode::Simple, DragSourceType::PlainTextSource))
641 return false;
642 } 641 }
643 } 642 }
644 643
Xiaocheng 2016/12/21 02:56:39 We should check whether the frame is destroyed her
chongz 2016/12/21 23:59:24 Done.
645 if (rootEditableElement) { 644 if (rootEditableElement) {
646 if (LocalFrame* frame = rootEditableElement->document().frame()) { 645 if (LocalFrame* frame = rootEditableElement->document().frame()) {
647 frame->eventHandler().updateDragStateAfterEditDragIfNeeded( 646 frame->eventHandler().updateDragStateAfterEditDragIfNeeded(
648 rootEditableElement); 647 rootEditableElement);
649 } 648 }
650 } 649 }
651 650
652 return true; 651 return true;
653 } 652 }
654 653
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 } 1223 }
1225 1224
1226 DEFINE_TRACE(DragController) { 1225 DEFINE_TRACE(DragController) {
1227 visitor->trace(m_page); 1226 visitor->trace(m_page);
1228 visitor->trace(m_documentUnderMouse); 1227 visitor->trace(m_documentUnderMouse);
1229 visitor->trace(m_dragInitiator); 1228 visitor->trace(m_dragInitiator);
1230 visitor->trace(m_fileInputElementUnderMouse); 1229 visitor->trace(m_fileInputElementUnderMouse);
1231 } 1230 }
1232 1231
1233 } // namespace blink 1232 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698