Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| index a9de02bf5e947efaf159e8bae4360fc90ab5963e..884ed47b8d44f2673b9c89933d767b9e85ef2b98 100644 |
| --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| @@ -27,6 +27,7 @@ |
| #include "core/HTMLElementFactory.h" |
| #include "core/HTMLNames.h" |
| +#include "core/clipboard/DataObject.h" |
| #include "core/dom/Document.h" |
| #include "core/dom/ElementTraversal.h" |
| #include "core/dom/NodeComputedStyle.h" |
| @@ -57,6 +58,7 @@ |
| #include "core/html/HTMLUListElement.h" |
| #include "core/layout/LayoutObject.h" |
| #include "core/layout/LayoutTableCell.h" |
| +#include "platform/clipboard/ClipboardMimeTypes.h" |
| #include "wtf/Assertions.h" |
| #include "wtf/StdLibExtras.h" |
| #include "wtf/text/StringBuilder.h" |
| @@ -2085,9 +2087,24 @@ DispatchEventResult dispatchBeforeInputDataTransfer( |
| return DispatchEventResult::NotCanceled; |
| if (!target) |
| return DispatchEventResult::NotCanceled; |
| - InputEvent* beforeInputEvent = InputEvent::createBeforeInput( |
| - inputType, dataTransfer, InputEvent::EventCancelable::IsCancelable, |
| - InputEvent::EventIsComposing::NotComposing, ranges); |
| + |
| + DCHECK(inputType == InputEvent::InputType::InsertFromPaste || |
| + inputType == InputEvent::InputType::InsertReplacementText); |
|
chongz
2016/10/28 02:12:16
|inputType| could also be |InsertFromDrop|.
yosin_UTC9
2016/10/28 04:06:14
Could you add "<< inputType" for ease of debugging
|
| + |
| + InputEvent* beforeInputEvent; |
| + |
| + if (hasRichlyEditableStyle(*(target->toNode()))) { |
| + beforeInputEvent = InputEvent::createBeforeInput( |
| + inputType, dataTransfer, InputEvent::EventCancelable::IsCancelable, |
| + InputEvent::EventIsComposing::NotComposing, ranges); |
| + } else { |
| + String data = dataTransfer->getData(mimeTypeTextPlain); |
| + // TODO(chongz): Pass appreciate |ranges| after it's defined on spec. |
| + // http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype |
| + beforeInputEvent = InputEvent::createBeforeInput( |
| + inputType, data, InputEvent::EventCancelable::IsCancelable, |
| + InputEvent::EventIsComposing::NotComposing, nullptr); |
| + } |
| return target->dispatchEvent(beforeInputEvent); |
| } |