| 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 05ce23eed63f5161958e044fa99fd3829756dc3c..bc91cb681588601449ebc6995d6b16ef35b95113 100644
|
| --- a/third_party/WebKit/Source/core/editing/Editor.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/Editor.cpp
|
| @@ -98,24 +98,31 @@ using namespace Unicode;
|
|
|
| namespace {
|
|
|
| -void dispatchInputEvent(Element* target, InputEvent::InputType inputType, const String& data, InputEvent::EventIsComposing isComposing)
|
| +void dispatchInputEvent(Element* target, InputEvent::InputType inputType, const String& data, InputEvent::EventIsComposing isComposing, const Document* originalDocument = nullptr)
|
| {
|
| if (!RuntimeEnabledFeatures::inputEventEnabled())
|
| return;
|
| - if (!target)
|
| + if (!target || !target->isConnected())
|
| return;
|
| - // TODO(chongz): Pass appreciate |ranges| after it's defined on spec.
|
| - // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype
|
| + if (originalDocument)
|
| + DCHECK(originalDocument == target->ownerDocument());
|
| 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)
|
| - dispatchInputEvent(endRoot, inputType, data, isComposing);
|
| + const Document* endRootOriginalDocument = endRoot ? endRoot->ownerDocument() : nullptr;
|
| + 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, endRootOriginalDocument);
|
| + return;
|
| + }
|
| +
|
| + dispatchInputEvent(startRoot, inputType, data, isComposing);
|
| + if (endRoot != startRoot)
|
| + dispatchInputEvent(endRoot, inputType, data, isComposing, endRootOriginalDocument);
|
| }
|
|
|
| InputEvent::EventIsComposing isComposingFromCommand(const CompositeEditCommand* command)
|
| @@ -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)
|
|
|