| 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 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. |
| 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, |
| 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( |
| 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( |
| 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 |
| 644 // 'beforeinput' event handler may destroy drop frame. |
| 645 if (!innerFrame->document() || innerFrame->document()->frame() != innerFrame) |
| 646 return false; |
| 645 if (rootEditableElement) { | 647 if (rootEditableElement) { |
| 646 if (LocalFrame* frame = rootEditableElement->document().frame()) { | 648 if (LocalFrame* frame = rootEditableElement->document().frame()) { |
| 647 frame->eventHandler().updateDragStateAfterEditDragIfNeeded( | 649 frame->eventHandler().updateDragStateAfterEditDragIfNeeded( |
| 648 rootEditableElement); | 650 rootEditableElement); |
| 649 } | 651 } |
| 650 } | 652 } |
| 651 | 653 |
| 652 return true; | 654 return true; |
| 653 } | 655 } |
| 654 | 656 |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 } | 1226 } |
| 1225 | 1227 |
| 1226 DEFINE_TRACE(DragController) { | 1228 DEFINE_TRACE(DragController) { |
| 1227 visitor->trace(m_page); | 1229 visitor->trace(m_page); |
| 1228 visitor->trace(m_documentUnderMouse); | 1230 visitor->trace(m_documentUnderMouse); |
| 1229 visitor->trace(m_dragInitiator); | 1231 visitor->trace(m_dragInitiator); |
| 1230 visitor->trace(m_fileInputElementUnderMouse); | 1232 visitor->trace(m_fileInputElementUnderMouse); |
| 1231 } | 1233 } |
| 1232 | 1234 |
| 1233 } // namespace blink | 1235 } // namespace blink |
| OLD | NEW |