Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Unified Diff: third_party/WebKit/Source/core/editing/Editor.cpp

Issue 2288913002: [InputEvent] Support |deleteByDrag| and |insertFromDrop| (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/Editor.cpp
diff --git a/third_party/WebKit/Source/core/editing/Editor.cpp b/third_party/WebKit/Source/core/editing/Editor.cpp
index 428331d3e5ae2796fbebc10dec8be0ffe18ef462..463af6a2d7102545212a546af54db6ae19331501 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -104,14 +104,21 @@ void dispatchInputEvent(Element* target, InputEvent::InputType inputType, const
return;
if (!target)
return;
- // TODO(chongz): Pass appreciate |ranges| after it's defined on spec.
- // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype
InputEvent* inputEvent = InputEvent::createInput(inputType, data, isComposing, nullptr);
target->dispatchScopedEvent(inputEvent);
}
void dispatchInputEventEditableContentChanged(Element* startRoot, Element* endRoot, InputEvent::InputType inputType, const String& data, InputEvent::EventIsComposing isComposing)
{
+ if (inputType == InputEvent::InputType::MoveByDragDrop) {
chongz 2016/08/30 23:59:21 Do we have any other solution that does not requir
+ // Drag&Drop will be combined into one |MoveSelectionCommand|, we need to split it into |DeleteByDrag| and |InsertFromDrop|.
+ if (startRoot)
+ dispatchInputEvent(startRoot, InputEvent::InputType::DeleteByDrag, data, isComposing);
+ if (endRoot)
+ dispatchInputEvent(endRoot, InputEvent::InputType::InsertFromDrop, data, isComposing);
yosin_UTC9 2016/08/31 01:20:34 Q: Do we dispatch "insertFromDrop" even if "delete
chongz 2016/09/02 18:02:10 Yes. Canceling 'deleteByDrag' only means cancellin
yosin_UTC9 2016/09/05 01:37:50 Your testing doesn't covered to make the case |end
chongz 2016/09/07 17:12:55 Added check in |dispatchInputEvent()|.
+ return;
+ }
+
if (startRoot)
dispatchInputEvent(startRoot, inputType, data, isComposing);
if (endRoot && endRoot != startRoot)
yosin_UTC9 2016/08/31 01:20:34 Do we need to check |endRoot.isConnected()|?
chongz 2016/09/02 18:02:10 It seems to me that if the element was changed, we
yosin_UTC9 2016/09/05 01:37:50 According DOM spec, https://www.w3.org/TR/dom/#dis
chongz 2016/09/07 17:12:55 OK, thanks for the reference!
@@ -560,7 +567,7 @@ void Editor::replaceSelectionAfterDragging(DocumentFragment* fragment, bool smar
if (plainText)
options |= ReplaceSelectionCommand::MatchStyle;
DCHECK(frame().document());
- ReplaceSelectionCommand::create(*frame().document(), fragment, options, InputEvent::InputType::Drag)->apply();
+ ReplaceSelectionCommand::create(*frame().document(), fragment, options, InputEvent::InputType::InsertFromDrop)->apply();
}
void Editor::moveSelectionAfterDragging(DocumentFragment* fragment, const Position& pos, bool smartInsert, bool smartDelete)

Powered by Google App Engine
This is Rietveld 408576698