Changeset 208014 in webkit
- Timestamp:
- Oct 27, 2016 3:46:46 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r208012 r208014 1 2016-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support "insertFromDrop" and "deleteByDrag" for the InputEvent spec 4 https://bugs.webkit.org/show_bug.cgi?id=163948 5 <rdar://problem/28921433> 6 7 Reviewed by Darin Adler. 8 9 Adds 3 new layout tests verifying that when dragging and dropping (both from a contenteditable to another 10 contenteditable and from non-editable content into a contenteditable) beforeinput and input events are fired in 11 the right order with the right data and inputTypes, and that undoing/redoing still considers the drag and drop 12 command as a single unit. Also tests that both deleting text by dragging and inserting text by dropping are 13 preventable. 14 15 * fast/events/before-input-events-prevent-drag-and-drop-expected.txt: Added. 16 * fast/events/before-input-events-prevent-drag-and-drop.html: Added. 17 * fast/events/input-events-drag-and-drop-expected.txt: Added. 18 * fast/events/input-events-drag-and-drop.html: Added. 19 * fast/events/input-events-insert-by-drop-expected.txt: Added. 20 * fast/events/input-events-insert-by-drop.html: Added. 21 * platform/ios-simulator/TestExpectations: 22 * platform/mac-wk2/TestExpectations: 23 1 24 2016-10-27 Devin Rousso <dcrousso+webkit@gmail.com> 2 25 -
trunk/LayoutTests/platform/ios-simulator/TestExpectations
r208003 r208014 1206 1206 fast/events/ime-composition-events-001.html [ Failure ] 1207 1207 fast/events/inputText-never-fired-on-keydown-cancel.html [ Failure ] 1208 fast/events/input-events-drag-and-drop.html [ Failure ] 1209 fast/events/input-events-insert-by-drop.html [ Failure ] 1208 1210 fast/events/input-events-fired-when-typing.html [ Failure ] 1209 1211 fast/events/input-events-paste-data.html [ Failure ] … … 1227 1229 fast/events/before-input-events-prevent-recomposition.html [ Failure ] 1228 1230 fast/events/before-input-events-prevent-insert-composition.html [ Failure ] 1231 fast/events/before-input-events-prevent-drag-and-drop.html [ Failure ] 1229 1232 fast/events/key-events-in-input-button.html [ Failure ] 1230 1233 fast/events/keydown-1.html [ Failure ] -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r207574 r208014 174 174 fast/events/remove-target-with-shadow-in-drag.html 175 175 176 fast/events/before-input-events-prevent-drag-and-drop.html [ Failure ] 177 fast/events/input-events-drag-and-drop.html [ Failure ] 178 fast/events/input-events-insert-by-drop.html [ Failure ] 179 176 180 webkit.org/b/81833 fast/events/drag-and-drop-link-into-focused-contenteditable.html [ Failure ] 177 181 -
trunk/Source/WebCore/ChangeLog
r208013 r208014 1 2016-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support "insertFromDrop" and "deleteByDrag" for the InputEvent spec 4 https://bugs.webkit.org/show_bug.cgi?id=163948 5 <rdar://problem/28921433> 6 7 Reviewed by Darin Adler. 8 9 Implements support for "insertFromDrop" and "deleteByDrag" inputTypes. These are fired when dragging and 10 dropping text in editable areas. To do this, we introduce EditActionInsertFromDrop and EditActionDeleteByDrag 11 (renamed from EditActionDrag, which is no longer necessary after this patch). 12 13 When moving text from an editable element to another, we will use a DeleteSelectionCommand to delete the text 14 from the source element and a ReplaceSelectionCommand to insert the text into the destination element. This 15 means that we currently fire two input events on the source and destination elements (i.e. given by the start 16 and end selections) after both child editing commands of the MoveSelectionCommand have been applied. Instead, we 17 need to fire events in this order: 18 19 1. beforeinput ("deleteByDrag") on the source 20 2. Update DOM 21 3. input ("deleteByDrag") on the source 22 23 4. beforeinput ("insertFromDrop") on the destination 24 5. Update DOM 25 6. input ("insertFromDrop") on the destination 26 27 To accomplish this, we allow an edit command to defer dispatching input events to its child commands via 28 CompositeEditCommand::shouldDispatchInputEvents, which the MoveSelectionCommand overrides. Additionally, 29 when applying the MoveSelectionCommand, we now apply() the child DeleteSelectionCommand and 30 ReplaceSelectionCommand instead of using doApply(). This allows these children to separately dispatch input 31 events, and also handle preventDefault() separately. 32 33 Tests: fast/events/before-input-events-prevent-drag-and-drop.html 34 fast/events/input-events-drag-and-drop.html 35 fast/events/input-events-insert-by-drop.html 36 37 * editing/CompositeEditCommand.cpp: 38 (WebCore::CompositeEditCommand::apply): 39 (WebCore::CompositeEditCommand::composition): 40 41 Searches for the top-level command and returns its composition. Also ASSERTs that the m_command of all child 42 commands along the way is null. In places where we used to ASSERT that command.composition() should be null, we 43 now perform the assertion here instead. 44 45 * editing/CompositeEditCommand.h: 46 (WebCore::CompositeEditCommand::shouldDispatchInputEvents): 47 48 This is true by default, which means that if apply() is called for a composite edit command that does not 49 override this to return false, it will try to dispatch input events. In most cases, the parent command will call 50 on the child command to doApply(), bypassing this check. 51 52 (WebCore::CompositeEditCommand::composition): Deleted. 53 * editing/EditAction.h: 54 * editing/EditCommand.cpp: 55 (WebCore::inputTypeNameForEditingAction): 56 (WebCore::EditCommand::isEditingTextAreaOrTextInput): 57 (WebCore::EditCommand::setStartingSelection): 58 (WebCore::EditCommand::setEndingSelection): 59 (WebCore::EditCommand::setParent): 60 * editing/Editor.cpp: 61 (WebCore::Editor::willApplyEditing): 62 (WebCore::Editor::appliedEditing): 63 64 After applying editing, only adjust the current selection and notify clients of selection change if the applied 65 command was a top-level command; otherwise, these actions should wait until all child commands of the top-level 66 command have been applied. In particular, we should not register the applied command as an undo step. 67 68 * editing/MoveSelectionCommand.cpp: 69 (WebCore::MoveSelectionCommand::doApply): 70 (WebCore::MoveSelectionCommand::editingAction): 71 * editing/MoveSelectionCommand.h: 72 * page/DragController.cpp: 73 (WebCore::DragController::concludeEditDrag): 74 75 For the cases where we're not deleting text from the drag source (i.e. we're just applying a 76 ReplaceSelectionCommand) pass in EditActionInsertFromDrop as the EditAction when creating the command. 77 1 78 2016-10-27 Per Arne Vollan <pvollan@apple.com> 2 79 -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r207841 r208014 344 344 case EditActionTypingInsertFinalComposition: 345 345 case EditActionPaste: 346 case EditActionD rag:346 case EditActionDeleteByDrag: 347 347 case EditActionSetWritingDirection: 348 348 case EditActionCut: … … 350 350 case EditActionInsert: 351 351 case EditActionInsertReplacement: 352 case EditActionInsertFromDrop: 352 353 case EditActionDelete: 353 354 case EditActionDictation: … … 403 404 RefPtr<DataTransfer> CompositeEditCommand::inputEventDataTransfer() const 404 405 { 406 return nullptr; 407 } 408 409 EditCommandComposition* CompositeEditCommand::composition() const 410 { 411 for (auto* command = this; command; command = command->parent()) { 412 if (auto composition = command->m_composition) { 413 ASSERT(!command->parent()); 414 return composition.get(); 415 } 416 } 405 417 return nullptr; 406 418 } -
trunk/Source/WebCore/editing/CompositeEditCommand.h
r207841 r208014 106 106 void apply(); 107 107 bool isFirstCommand(EditCommand* command) { return !m_commands.isEmpty() && m_commands.first() == command; } 108 EditCommandComposition* composition() { return m_composition.get(); }108 EditCommandComposition* composition() const; 109 109 EditCommandComposition* ensureComposition(); 110 110 … … 119 119 virtual String inputEventData() const { return { }; } 120 120 virtual bool isBeforeInputEventCancelable() const { return true; } 121 virtual bool shouldDispatchInputEvents() const { return true; } 121 122 Vector<RefPtr<StaticRange>> targetRangesForBindings() const; 122 123 virtual RefPtr<DataTransfer> inputEventDataTransfer() const; -
trunk/Source/WebCore/editing/EditAction.h
r207698 r208014 32 32 EditActionInsert, 33 33 EditActionInsertReplacement, 34 EditActionInsertFromDrop, 34 35 EditActionSetColor, 35 36 EditActionSetBackgroundColor, … … 56 57 EditActionOutline, 57 58 EditActionUnscript, 58 EditActionD rag,59 EditActionDeleteByDrag, 59 60 EditActionCut, 60 61 EditActionBold, -
trunk/Source/WebCore/editing/EditCommand.cpp
r207698 r208014 59 59 case EditActionSetColor: 60 60 return ASCIILiteral("formatForeColor"); 61 case EditActionD rag:61 case EditActionDeleteByDrag: 62 62 return ASCIILiteral("deleteByDrag"); 63 63 case EditActionCut: … … 93 93 case EditActionInsertReplacement: 94 94 return ASCIILiteral("insertReplacementText"); 95 case EditActionInsertFromDrop: 96 return ASCIILiteral("insertFromDrop"); 95 97 case EditActionTypingInsertLineBreak: 96 98 return ASCIILiteral("insertLineBreak"); … … 179 181 { 180 182 for (EditCommand* cmd = this; ; cmd = cmd->m_parent) { 181 if (EditCommandComposition* composition = compositionIfPossible(cmd)) { 182 ASSERT(cmd->isTopLevelCommand()); 183 if (auto* composition = compositionIfPossible(cmd)) 183 184 composition->setStartingSelection(s); 184 }185 185 cmd->m_startingSelection = s; 186 186 if (!cmd->m_parent || cmd->m_parent->isFirstCommand(cmd)) … … 192 192 { 193 193 for (EditCommand* cmd = this; cmd; cmd = cmd->m_parent) { 194 if (EditCommandComposition* composition = compositionIfPossible(cmd)) { 195 ASSERT(cmd->isTopLevelCommand()); 194 if (auto* composition = compositionIfPossible(cmd)) 196 195 composition->setEndingSelection(s); 197 }198 196 cmd->m_endingSelection = s; 199 197 } … … 203 201 { 204 202 ASSERT((parent && !m_parent) || (!parent && m_parent)); 205 ASSERT(!parent || !isCompositeEditCommand() || !toCompositeEditCommand(this)->composition());206 203 m_parent = parent; 207 204 if (parent) { -
trunk/Source/WebCore/editing/Editor.cpp
r207841 r208014 1084 1084 bool Editor::willApplyEditing(CompositeEditCommand& command, Vector<RefPtr<StaticRange>>&& targetRanges) const 1085 1085 { 1086 if (!command.shouldDispatchInputEvents()) 1087 return true; 1088 1086 1089 auto* composition = command.composition(); 1087 1090 if (!composition) … … 1103 1106 notifyTextFromControls(composition->startingRootEditableElement(), composition->endingRootEditableElement()); 1104 1107 1105 // Don't clear the typing style with this selection change. We do those things elsewhere if necessary. 1106 FrameSelection::SetSelectionOptions options = cmd->isDictationCommand() ? FrameSelection::DictationTriggered : 0; 1107 1108 changeSelectionAfterCommand(newSelection, options); 1109 dispatchInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), cmd->inputEventTypeName(), cmd->inputEventData(), cmd->inputEventDataTransfer()); 1110 1111 updateEditorUINowIfScheduled(); 1112 1113 m_alternativeTextController->respondToAppliedEditing(cmd.get()); 1114 1115 if (!cmd->preservesTypingStyle()) 1116 m_frame.selection().clearTypingStyle(); 1117 1118 // Command will be equal to last edit command only in the case of typing 1119 if (m_lastEditCommand.get() == cmd) 1120 ASSERT(cmd->isTypingCommand()); 1121 else { 1122 // Only register a new undo command if the command passed in is 1123 // different from the last command 1124 m_lastEditCommand = cmd; 1125 if (client()) 1126 client()->registerUndoStep(m_lastEditCommand->ensureComposition()); 1127 } 1128 1129 respondToChangedContents(newSelection); 1108 if (cmd->isTopLevelCommand()) { 1109 // Don't clear the typing style with this selection change. We do those things elsewhere if necessary. 1110 FrameSelection::SetSelectionOptions options = cmd->isDictationCommand() ? FrameSelection::DictationTriggered : 0; 1111 1112 changeSelectionAfterCommand(newSelection, options); 1113 } 1114 1115 if (cmd->shouldDispatchInputEvents()) 1116 dispatchInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), cmd->inputEventTypeName(), cmd->inputEventData(), cmd->inputEventDataTransfer()); 1117 1118 if (cmd->isTopLevelCommand()) { 1119 updateEditorUINowIfScheduled(); 1120 1121 m_alternativeTextController->respondToAppliedEditing(cmd.get()); 1122 1123 if (!cmd->preservesTypingStyle()) 1124 m_frame.selection().clearTypingStyle(); 1125 1126 // Command will be equal to last edit command only in the case of typing 1127 if (m_lastEditCommand.get() == cmd) 1128 ASSERT(cmd->isTypingCommand()); 1129 else { 1130 // Only register a new undo command if the command passed in is 1131 // different from the last command 1132 m_lastEditCommand = cmd; 1133 if (client()) 1134 client()->registerUndoStep(m_lastEditCommand->ensureComposition()); 1135 } 1136 respondToChangedContents(newSelection); 1137 } 1130 1138 } 1131 1139 -
trunk/Source/WebCore/editing/MoveSelectionCommand.cpp
r194496 r208014 27 27 #include "MoveSelectionCommand.h" 28 28 29 #include "DeleteSelectionCommand.h" 29 30 #include "DocumentFragment.h" 30 31 #include "ReplaceSelectionCommand.h" … … 61 62 } 62 63 63 deleteSelection(m_smartDelete); 64 { 65 auto deleteSelection = DeleteSelectionCommand::create(document(), m_smartDelete, true, false, true, true, EditActionDeleteByDrag); 66 deleteSelection->setParent(this); 67 deleteSelection->apply(); 68 m_commands.append(WTFMove(deleteSelection)); 69 } 64 70 65 71 // If the node for the destination has been removed as a result of the deletion, … … 73 79 74 80 setEndingSelection(VisibleSelection(pos, endingSelection().affinity(), endingSelection().isDirectional())); 81 setStartingSelection(endingSelection()); 75 82 if (!pos.anchorNode()->inDocument()) { 76 83 // Document was modified out from under us. … … 80 87 if (m_smartInsert) 81 88 options |= ReplaceSelectionCommand::SmartReplace; 82 applyCommandToComposite(ReplaceSelectionCommand::create(document(), WTFMove(m_fragment), options)); 89 90 { 91 auto replaceSelection = ReplaceSelectionCommand::create(document(), WTFMove(m_fragment), options, EditActionInsertFromDrop); 92 replaceSelection->setParent(this); 93 replaceSelection->apply(); 94 m_commands.append(WTFMove(replaceSelection)); 95 } 83 96 } 84 97 85 98 EditAction MoveSelectionCommand::editingAction() const 86 99 { 87 return EditActionD rag;100 return EditActionDeleteByDrag; 88 101 } 89 102 -
trunk/Source/WebCore/editing/MoveSelectionCommand.h
r177733 r208014 45 45 virtual void doApply(); 46 46 virtual EditAction editingAction() const; 47 bool shouldDispatchInputEvents() const final { return false; } 47 48 48 49 RefPtr<DocumentFragment> m_fragment; -
trunk/Source/WebCore/page/DragController.cpp
r204972 r208014 533 533 if (chosePlainText) 534 534 options |= ReplaceSelectionCommand::MatchStyle; 535 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, WTFMove(fragment), options ));535 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, WTFMove(fragment), options, EditActionInsertFromDrop)); 536 536 } 537 537 } … … 544 544 m_client.willPerformDragDestinationAction(DragDestinationActionEdit, dragData); 545 545 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) 546 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText(*range, text), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting ));546 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse, createFragmentFromText(*range, text), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting, EditActionInsertFromDrop)); 547 547 } 548 548 -
trunk/Source/WebKit/mac/ChangeLog
r207990 r208014 1 2016-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support "insertFromDrop" and "deleteByDrag" for the InputEvent spec 4 https://bugs.webkit.org/show_bug.cgi?id=163948 5 <rdar://problem/28921433> 6 7 Reviewed by Darin Adler. 8 9 Add support for new drag and drop-related EditAction enum values. 10 11 * WebCoreSupport/WebEditorClient.mm: 12 (undoNameForEditAction): 13 1 14 2016-10-27 Dan Bernstein <mitz@apple.com> 2 15 -
trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm
r207698 r208014 565 565 case EditActionInsert: return nil; 566 566 case EditActionInsertReplacement: return nil; 567 case EditActionInsertFromDrop: return nil; 567 568 case EditActionSetColor: return UI_STRING_KEY_INTERNAL("Set Color", "Set Color (Undo action name)", "Undo action name"); 568 569 case EditActionSetBackgroundColor: return UI_STRING_KEY_INTERNAL("Set Background Color", "Set Background Color (Undo action name)", "Undo action name"); … … 589 590 case EditActionOutline: return UI_STRING_KEY_INTERNAL("Outline", "Outline (Undo action name)", "Undo action name"); 590 591 case EditActionUnscript: return UI_STRING_KEY_INTERNAL("Unscript", "Unscript (Undo action name)", "Undo action name"); 591 case EditActionD rag: return UI_STRING_KEY_INTERNAL("Drag", "Drag (Undo action name)", "Undo action name");592 case EditActionDeleteByDrag: return UI_STRING_KEY_INTERNAL("Drag", "Drag (Undo action name)", "Undo action name"); 592 593 case EditActionCut: return UI_STRING_KEY_INTERNAL("Cut", "Cut (Undo action name)", "Undo action name"); 593 594 case EditActionPaste: return UI_STRING_KEY_INTERNAL("Paste", "Paste (Undo action name)", "Undo action name"); -
trunk/Source/WebKit/win/ChangeLog
r207928 r208014 1 2016-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support "insertFromDrop" and "deleteByDrag" for the InputEvent spec 4 https://bugs.webkit.org/show_bug.cgi?id=163948 5 <rdar://problem/28921433> 6 7 Reviewed by Darin Adler. 8 9 Add support for new drag and drop-related EditAction enum values. 10 11 * WebCoreSupport/WebEditorClient.cpp: 12 (undoNameForEditAction): 13 1 14 2016-10-26 Brian Burg <bburg@apple.com> 2 15 -
trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp
r206979 r208014 593 593 case EditActionOutline: return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name"); 594 594 case EditActionUnscript: return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name"); 595 case EditActionD rag: return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name");595 case EditActionDeleteByDrag: return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name"); 596 596 case EditActionCut: return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name"); 597 597 case EditActionPaste: return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name"); -
trunk/Source/WebKit2/ChangeLog
r207931 r208014 1 2016-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support "insertFromDrop" and "deleteByDrag" for the InputEvent spec 4 https://bugs.webkit.org/show_bug.cgi?id=163948 5 <rdar://problem/28921433> 6 7 Reviewed by Darin Adler. 8 9 Add support for new drag and drop-related EditAction enum values. 10 11 * UIProcess/WebEditCommandProxy.cpp: 12 (WebKit::WebEditCommandProxy::nameForEditAction): 13 1 14 2016-10-26 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp
r207698 r208014 74 74 switch (editAction) { 75 75 case EditActionUnspecified: 76 return String();77 76 case EditActionInsert: 78 return String();79 77 case EditActionInsertReplacement: 78 case EditActionInsertFromDrop: 80 79 return String(); 81 80 case EditActionSetColor: … … 127 126 case EditActionUnscript: 128 127 return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name"); 129 case EditActionD rag:128 case EditActionDeleteByDrag: 130 129 return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name"); 131 130 case EditActionCut:
Note: See TracChangeset
for help on using the changeset viewer.