New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 652393 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Oct 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocked on:
issue 652979

Blocking:
issue 585875



Sign in to add a comment

InputEvent: Support 'deleteByDrag' and 'insertFromDrop'

Project Member Reported by chongz@chromium.org, Oct 3 2016

Issue description

The resolution from TPAC 2016 is we want to:
  1. Fire 'deleteByDrag' and 'insertFromDrop' in sequential order
  2. Only requires a single undo
  3. Each 'beforeinput' can be cancelled without affecting the other

Example event order:
  1. 'drop'
  2. 'beforeinput' InputType=|deleteByDrag|
  3. (DOM update for deletion)
  4. 'input' InputType=|deleteByDrag|
  5. 'beforeinput' InputType=|insertFromDrop|
  6. (DOM update for insertion)
  7. 'input' InputType=|insertFromDrop|
  8. 'dragend'

Resolution:
https://github.com/w3c/input-events/issues/24#issuecomment-249153755
 
Project Member

Comment 1 by bugdroid1@chromium.org, Oct 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e

commit 93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e
Author: chongz <chongz@chromium.org>
Date: Tue Oct 04 20:38:00 2016

[InputEvent] Support |deleteByDrag|, |insertFromDrop| and fire in sequential order

Key point of the implementation:
  * We want to apply 2 commands but only push 1 undo entry.

Solution:
  1. Introduce empty wrapper command |DragAndDropCommand| and
     apply first
  2. Apply |DeleteSelectionCommand| for |deleteByDrag|
  3. Apply |ReplaceSelectionCommand| for |insertFromDrop|

The wrapper command in 1. won't create undo entry by itself, but will
act as a catcher and combine the following 2 commands into a single
undo entry.

--- After CL behavior

* Event order: (See [1])
  1. 'drop'
  2. 'beforeinput' InputType=|deleteByDrag|
  3. (DOM update for deletion)
  4. 'input' InputType=|deleteByDrag|
  5. 'beforeinput' InputType=|insertFromDrop|
  6. (DOM update for insertion)
  7. 'input' InputType=|insertFromDrop|
  8. 'dragend'

* Canceling 'beforeinput' will only prevent DOM update for current
  'beforeinput', and won't affect remaining events.
e.g. Cancelling 'deleteByDrag' won't affect 'insertFromDrop'

* |dataTransfer| field:
  1. NULL for |deleteByDrag|
  2. Readonly |dataTransfer| for |insertFromDrop|

* Undo entry:
  1. Creates a single undo entry for Drag&Drop, if no JS-triggered DOM mutation happened in between
  2. Otherwise creates 2 separate undo entries

For more detailed behavior please refer to LayoutTest.

[1] Event order for |deleteByDrag| and |insertFromDrop|:
https://github.com/w3c/input-events/issues/24#issuecomment-249153755

Intent to Implement:
https://groups.google.com/a/chromium.org/forum/#!searchin/blink-dev/InputEvent/blink-dev/RrnitB0OElc/rirueVekCwAJ

BUG= 652393 

Review-Url: https://codereview.chromium.org/2374743002
Cr-Commit-Position: refs/heads/master@{#422915}

[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/LayoutTests/editing/selection/drag-drop-events-expected.txt
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/LayoutTests/fast/events/inputevents/beforeinput-remove-iframe-crash.html
[add] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-drag-drop.html
[add] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/LayoutTests/fast/events/resources/beforeinput-remove-iframe-crash-iframe.html
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/BUILD.gn
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/Editor.cpp
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/Editor.h
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.h
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.h
[add] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/DragAndDropCommand.cpp
[add] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/DragAndDropCommand.h
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/EditCommand.cpp
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/editing/commands/MoveSelectionCommand.cpp
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/events/InputEvent.cpp
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/events/InputEvent.h
[modify] https://crrev.com/93db3c3bb91fb3e02080e16a0bd0b813b3d10a3e/third_party/WebKit/Source/core/page/DragController.cpp

Comment 2 by horo@chromium.org, Oct 5 2016

Blockedon: 652979
Labels: M-55
Status: Fixed (was: Started)

Sign in to add a comment