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

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

Issue 2288913002: [InputEvent] Support |deleteByDrag| and |insertFromDrop| (Closed)
Patch Set: Yosin's review 2, check |!isConnected()| Created 4 years, 3 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 477e1de0f71b071d8c669549dc110d78e6a2b5d5..012f8ad4085056924c7b4e1a66de326d9ce00202 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -102,19 +102,23 @@ void dispatchInputEvent(Element* target, InputEvent::InputType inputType, const
{
if (!RuntimeEnabledFeatures::inputEventEnabled())
return;
- if (!target)
+ if (!target || !target->isConnected())
yosin_UTC9 2016/09/08 04:34:40 One more. Could you make |disaptchInputEvent()| to
chongz 2016/09/08 22:37:50 I've added check for |ownerDocument()| but I don't
chongz 2016/09/13 17:17:12 dtapuska@ I'm not sure if I understood the issue c
dtapuska 2016/09/13 17:27:50 Ya this change seems odd to me. The old code use t
yosin_UTC9 2016/09/14 01:57:37 I changed mind, we should verify source and 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 (startRoot)
- dispatchInputEvent(startRoot, inputType, data, isComposing);
- if (endRoot && endRoot != startRoot)
+ if (inputType == InputEvent::InputType::MoveByDragDrop) {
+ // Drag&Drop will be combined into one |MoveSelectionCommand|, we need to split it into |DeleteByDrag| and |InsertFromDrop|.
+ dispatchInputEvent(startRoot, InputEvent::InputType::DeleteByDrag, data, isComposing);
+ dispatchInputEvent(endRoot, InputEvent::InputType::InsertFromDrop, data, isComposing);
+ return;
+ }
+
+ dispatchInputEvent(startRoot, inputType, data, isComposing);
+ if (endRoot != startRoot)
dispatchInputEvent(endRoot, inputType, data, isComposing);
}
@@ -560,7 +564,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