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

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: Created 4 years 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 const DeleteMode deleteMode = 599 const DeleteMode deleteMode =
600 innerFrame->editor().smartInsertDeleteEnabled() ? DeleteMode::Smart 600 innerFrame->editor().smartInsertDeleteEnabled() ? DeleteMode::Smart
601 : DeleteMode::Simple; 601 : DeleteMode::Simple;
602 const InsertMode insertMode = 602 const InsertMode insertMode =
603 (deleteMode == DeleteMode::Smart && 603 (deleteMode == DeleteMode::Smart &&
604 innerFrame->selection().granularity() == WordGranularity && 604 innerFrame->selection().granularity() == WordGranularity &&
605 dragData->canSmartReplace()) 605 dragData->canSmartReplace())
606 ? InsertMode::Smart 606 ? InsertMode::Smart
607 : InsertMode::Simple; 607 : InsertMode::Simple;
608 608
609 if (!innerFrame->editor().deleteSelectionAfterDraggingWithEvents( 609 innerFrame->editor().deleteSelectionWithSmartDelete(
610 innerFrame->editor().findEventTargetFromSelection(), deleteMode, 610 deleteMode, InputEvent::InputType::DeleteByDrag, dragCaret.base());
611 dragCaret.base())) 611
612 // 'beforeinput' event handler may disconnect drop target.
613 if (!element->isConnected())
612 return false; 614 return false;
613 615
614 innerFrame->selection().setSelection( 616 innerFrame->selection().setSelection(
615 SelectionInDOMTree::Builder() 617 SelectionInDOMTree::Builder()
616 .setBaseAndExtent(EphemeralRange(range)) 618 .setBaseAndExtent(EphemeralRange(range))
617 .build()); 619 .build());
618 if (innerFrame->selection().isAvailable()) { 620 if (innerFrame->selection().isAvailable()) {
619 DCHECK(m_documentUnderMouse); 621 DCHECK(m_documentUnderMouse);
620 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 622 innerFrame->editor().replaceSelectionAfterDragging(fragment, insertMode,
621 element, dragData, fragment, range, insertMode, dragSourceType)) 623 dragSourceType);
622 return false;
623 } 624 }
624 } else { 625 } else {
625 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 626 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
626 DCHECK(m_documentUnderMouse); 627 DCHECK(m_documentUnderMouse);
627 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 628 innerFrame->editor().replaceSelectionAfterDragging(
628 element, dragData, fragment, range, 629 fragment, dragData->canSmartReplace() ? InsertMode::Smart
629 dragData->canSmartReplace() ? InsertMode::Smart 630 : InsertMode::Simple,
630 : InsertMode::Simple, 631 dragSourceType);
631 dragSourceType))
632 return false;
633 } 632 }
634 } 633 }
635 } else { 634 } else {
636 String text = dragData->asPlainText(); 635 String text = dragData->asPlainText();
637 if (text.isEmpty()) 636 if (text.isEmpty())
638 return false; 637 return false;
639 638
640 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 639 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
641 DCHECK(m_documentUnderMouse); 640 DCHECK(m_documentUnderMouse);
642 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 641 innerFrame->editor().replaceSelectionAfterDragging(
643 element, dragData, 642 createFragmentFromText(EphemeralRange(range), text),
644 createFragmentFromText(EphemeralRange(range), text), range, 643 InsertMode::Simple, DragSourceType::PlainTextSource);
645 InsertMode::Simple, DragSourceType::PlainTextSource))
646 return false;
647 } 644 }
648 } 645 }
649 646
650 if (rootEditableElement) { 647 if (rootEditableElement) {
651 if (LocalFrame* frame = rootEditableElement->document().frame()) { 648 if (LocalFrame* frame = rootEditableElement->document().frame()) {
652 frame->eventHandler().updateDragStateAfterEditDragIfNeeded( 649 frame->eventHandler().updateDragStateAfterEditDragIfNeeded(
653 rootEditableElement); 650 rootEditableElement);
654 } 651 }
655 } 652 }
656 653
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 } 1229 }
1233 1230
1234 DEFINE_TRACE(DragController) { 1231 DEFINE_TRACE(DragController) {
1235 visitor->trace(m_page); 1232 visitor->trace(m_page);
1236 visitor->trace(m_documentUnderMouse); 1233 visitor->trace(m_documentUnderMouse);
1237 visitor->trace(m_dragInitiator); 1234 visitor->trace(m_dragInitiator);
1238 visitor->trace(m_fileInputElementUnderMouse); 1235 visitor->trace(m_fileInputElementUnderMouse);
1239 } 1236 }
1240 1237
1241 } // namespace blink 1238 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698