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

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: yosin's review, fix nits 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 destroy drop frame.
613 if (innerFrame->document()->frame() != innerFrame ||
614 !element->isConnected())
612 return false; 615 return false;
613 616
614 innerFrame->selection().setSelection( 617 innerFrame->selection().setSelection(
615 SelectionInDOMTree::Builder() 618 SelectionInDOMTree::Builder()
616 .setBaseAndExtent(EphemeralRange(range)) 619 .setBaseAndExtent(EphemeralRange(range))
617 .build()); 620 .build());
618 if (innerFrame->selection().isAvailable()) { 621 if (innerFrame->selection().isAvailable()) {
619 DCHECK(m_documentUnderMouse); 622 DCHECK(m_documentUnderMouse);
620 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 623 innerFrame->editor().replaceSelectionAfterDragging(fragment, insertMode,
621 element, dragData, fragment, range, insertMode, dragSourceType)) 624 dragSourceType);
622 return false;
623 } 625 }
624 } else { 626 } else {
625 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 627 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
626 DCHECK(m_documentUnderMouse); 628 DCHECK(m_documentUnderMouse);
627 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 629 innerFrame->editor().replaceSelectionAfterDragging(
628 element, dragData, fragment, range, 630 fragment, dragData->canSmartReplace() ? InsertMode::Smart
629 dragData->canSmartReplace() ? InsertMode::Smart 631 : InsertMode::Simple,
630 : InsertMode::Simple, 632 dragSourceType);
631 dragSourceType))
632 return false;
633 } 633 }
634 } 634 }
635 } else { 635 } else {
636 String text = dragData->asPlainText(); 636 String text = dragData->asPlainText();
637 if (text.isEmpty()) 637 if (text.isEmpty())
638 return false; 638 return false;
639 639
640 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) { 640 if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) {
641 DCHECK(m_documentUnderMouse); 641 DCHECK(m_documentUnderMouse);
642 if (!innerFrame->editor().replaceSelectionAfterDraggingWithEvents( 642 innerFrame->editor().replaceSelectionAfterDragging(
643 element, dragData, 643 createFragmentFromText(EphemeralRange(range), text),
644 createFragmentFromText(EphemeralRange(range), text), range, 644 InsertMode::Simple, DragSourceType::PlainTextSource);
645 InsertMode::Simple, DragSourceType::PlainTextSource))
646 return false;
647 } 645 }
648 } 646 }
649 647
650 if (rootEditableElement) { 648 if (rootEditableElement) {
651 if (LocalFrame* frame = rootEditableElement->document().frame()) { 649 if (LocalFrame* frame = rootEditableElement->document().frame()) {
652 frame->eventHandler().updateDragStateAfterEditDragIfNeeded( 650 frame->eventHandler().updateDragStateAfterEditDragIfNeeded(
653 rootEditableElement); 651 rootEditableElement);
654 } 652 }
655 } 653 }
656 654
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 } 1230 }
1233 1231
1234 DEFINE_TRACE(DragController) { 1232 DEFINE_TRACE(DragController) {
1235 visitor->trace(m_page); 1233 visitor->trace(m_page);
1236 visitor->trace(m_documentUnderMouse); 1234 visitor->trace(m_documentUnderMouse);
1237 visitor->trace(m_dragInitiator); 1235 visitor->trace(m_dragInitiator);
1238 visitor->trace(m_fileInputElementUnderMouse); 1236 visitor->trace(m_fileInputElementUnderMouse);
1239 } 1237 }
1240 1238
1241 } // namespace blink 1239 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698