| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 bool Editor::deleteSelectionAfterDraggingWithEvents( | 641 bool Editor::deleteSelectionAfterDraggingWithEvents( |
| 642 Element* dragSource, | 642 Element* dragSource, |
| 643 DeleteMode deleteMode, | 643 DeleteMode deleteMode, |
| 644 const Position& referenceMovePosition) { | 644 const Position& referenceMovePosition) { |
| 645 if (!dragSource || !dragSource->isConnected()) | 645 if (!dragSource || !dragSource->isConnected()) |
| 646 return true; | 646 return true; |
| 647 | 647 |
| 648 // Dispatch 'beforeinput'. | 648 // Dispatch 'beforeinput'. |
| 649 const bool shouldDelete = dispatchBeforeInputEditorCommand( | 649 const bool shouldDelete = dispatchBeforeInputEditorCommand( |
| 650 dragSource, InputEvent::InputType::DeleteByDrag, | 650 dragSource, InputEvent::InputType::DeleteByDrag, |
| 651 nullptr) == DispatchEventResult::NotCanceled; | 651 targetRangesForInputEvent(*dragSource)) == |
| 652 DispatchEventResult::NotCanceled; |
| 652 | 653 |
| 653 // 'beforeinput' event handler may destroy frame, return false to cancel | 654 // 'beforeinput' event handler may destroy frame, return false to cancel |
| 654 // remaining actions; | 655 // remaining actions; |
| 655 if (m_frame->document()->frame() != m_frame) | 656 if (m_frame->document()->frame() != m_frame) |
| 656 return false; | 657 return false; |
| 657 | 658 |
| 658 if (shouldDelete && dragSource->isConnected()) { | 659 if (shouldDelete && dragSource->isConnected()) { |
| 659 deleteSelectionWithSmartDelete( | 660 deleteSelectionWithSmartDelete( |
| 660 deleteMode, InputEvent::InputType::DeleteByDrag, referenceMovePosition); | 661 deleteMode, InputEvent::InputType::DeleteByDrag, referenceMovePosition); |
| 661 } | 662 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 673 if (!dropTarget || !dropTarget->isConnected()) | 674 if (!dropTarget || !dropTarget->isConnected()) |
| 674 return true; | 675 return true; |
| 675 | 676 |
| 676 // Dispatch 'beforeinput'. | 677 // Dispatch 'beforeinput'. |
| 677 DataTransfer* dataTransfer = | 678 DataTransfer* dataTransfer = |
| 678 DataTransfer::create(DataTransfer::DragAndDrop, DataTransferReadable, | 679 DataTransfer::create(DataTransfer::DragAndDrop, DataTransferReadable, |
| 679 dragData->platformData()); | 680 dragData->platformData()); |
| 680 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()); | 681 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()); |
| 681 const bool shouldInsert = | 682 const bool shouldInsert = |
| 682 dispatchBeforeInputDataTransfer( | 683 dispatchBeforeInputDataTransfer( |
| 683 dropTarget, InputEvent::InputType::InsertFromDrop, dataTransfer, | 684 dropTarget, InputEvent::InputType::InsertFromDrop, dataTransfer) == |
| 684 nullptr) == DispatchEventResult::NotCanceled; | 685 DispatchEventResult::NotCanceled; |
| 685 | 686 |
| 686 // 'beforeinput' event handler may destroy frame, return false to cancel | 687 // 'beforeinput' event handler may destroy frame, return false to cancel |
| 687 // remaining actions; | 688 // remaining actions; |
| 688 if (m_frame->document()->frame() != m_frame) | 689 if (m_frame->document()->frame() != m_frame) |
| 689 return false; | 690 return false; |
| 690 | 691 |
| 691 if (shouldInsert && dropTarget->isConnected()) | 692 if (shouldInsert && dropTarget->isConnected()) |
| 692 replaceSelectionAfterDragging(fragment, insertMode, dragSourceType); | 693 replaceSelectionAfterDragging(fragment, insertMode, dragSourceType); |
| 693 | 694 |
| 694 return true; | 695 return true; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 Pasteboard::generalPasteboard()->writePlainText( | 1076 Pasteboard::generalPasteboard()->writePlainText( |
| 1076 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace | 1077 plainText, canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace |
| 1077 : Pasteboard::CannotSmartReplace); | 1078 : Pasteboard::CannotSmartReplace); |
| 1078 } else { | 1079 } else { |
| 1079 writeSelectionToPasteboard(); | 1080 writeSelectionToPasteboard(); |
| 1080 } | 1081 } |
| 1081 | 1082 |
| 1082 if (source == CommandFromMenuOrKeyBinding) { | 1083 if (source == CommandFromMenuOrKeyBinding) { |
| 1083 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), | 1084 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), |
| 1084 InputEvent::InputType::DeleteByCut, | 1085 InputEvent::InputType::DeleteByCut, |
| 1085 nullptr, nullptr) != | 1086 nullptr) != |
| 1086 DispatchEventResult::NotCanceled) | 1087 DispatchEventResult::NotCanceled) |
| 1087 return; | 1088 return; |
| 1088 // 'beforeinput' event handler may destroy target frame. | 1089 // 'beforeinput' event handler may destroy target frame. |
| 1089 if (m_frame->document()->frame() != m_frame) | 1090 if (m_frame->document()->frame() != m_frame) |
| 1090 return; | 1091 return; |
| 1091 } | 1092 } |
| 1092 deleteSelectionWithSmartDelete( | 1093 deleteSelectionWithSmartDelete( |
| 1093 canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple, | 1094 canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple, |
| 1094 InputEvent::InputType::DeleteByCut); | 1095 InputEvent::InputType::DeleteByCut); |
| 1095 } | 1096 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 ? AllMimeTypes | 1138 ? AllMimeTypes |
| 1138 : PlainTextOnly; | 1139 : PlainTextOnly; |
| 1139 | 1140 |
| 1140 if (source == CommandFromMenuOrKeyBinding) { | 1141 if (source == CommandFromMenuOrKeyBinding) { |
| 1141 DataTransfer* dataTransfer = | 1142 DataTransfer* dataTransfer = |
| 1142 DataTransfer::create(DataTransfer::CopyAndPaste, DataTransferReadable, | 1143 DataTransfer::create(DataTransfer::CopyAndPaste, DataTransferReadable, |
| 1143 DataObject::createFromPasteboard(pasteMode)); | 1144 DataObject::createFromPasteboard(pasteMode)); |
| 1144 | 1145 |
| 1145 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), | 1146 if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), |
| 1146 InputEvent::InputType::InsertFromPaste, | 1147 InputEvent::InputType::InsertFromPaste, |
| 1147 dataTransfer, nullptr) != | 1148 dataTransfer) != |
| 1148 DispatchEventResult::NotCanceled) | 1149 DispatchEventResult::NotCanceled) |
| 1149 return; | 1150 return; |
| 1150 // 'beforeinput' event handler may destroy target frame. | 1151 // 'beforeinput' event handler may destroy target frame. |
| 1151 if (m_frame->document()->frame() != m_frame) | 1152 if (m_frame->document()->frame() != m_frame) |
| 1152 return; | 1153 return; |
| 1153 } | 1154 } |
| 1154 | 1155 |
| 1155 if (pasteMode == AllMimeTypes) | 1156 if (pasteMode == AllMimeTypes) |
| 1156 pasteWithPasteboard(Pasteboard::generalPasteboard()); | 1157 pasteWithPasteboard(Pasteboard::generalPasteboard()); |
| 1157 else | 1158 else |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 | 1702 |
| 1702 DEFINE_TRACE(Editor) { | 1703 DEFINE_TRACE(Editor) { |
| 1703 visitor->trace(m_frame); | 1704 visitor->trace(m_frame); |
| 1704 visitor->trace(m_lastEditCommand); | 1705 visitor->trace(m_lastEditCommand); |
| 1705 visitor->trace(m_undoStack); | 1706 visitor->trace(m_undoStack); |
| 1706 visitor->trace(m_mark); | 1707 visitor->trace(m_mark); |
| 1707 visitor->trace(m_typingStyle); | 1708 visitor->trace(m_typingStyle); |
| 1708 } | 1709 } |
| 1709 | 1710 |
| 1710 } // namespace blink | 1711 } // namespace blink |
| OLD | NEW |