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