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 2954891283900e17fad5cad4257946cc1f26294c..8133490428652cae100563e86a578ff26f696c56 100644 |
--- a/third_party/WebKit/Source/core/editing/Editor.cpp |
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp |
@@ -86,6 +86,7 @@ |
#include "core/page/Page.h" |
#include "core/svg/SVGImageElement.h" |
#include "platform/KillRing.h" |
+#include "platform/clipboard/ClipboardMimeTypes.h" |
#include "platform/weborigin/KURL.h" |
#include "wtf/PtrUtil.h" |
#include "wtf/text/CharacterNames.h" |
@@ -104,12 +105,10 @@ void dispatchInputEvent(Element* target, |
InputEvent::EventIsComposing isComposing) { |
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 |
InputEvent* inputEvent = |
- InputEvent::createInput(inputType, data, isComposing, nullptr); |
+ InputEvent::createInput(inputType, data, isComposing); |
target->dispatchScopedEvent(inputEvent); |
} |
@@ -125,15 +124,6 @@ void dispatchInputEventEditableContentChanged( |
dispatchInputEvent(endRoot, inputType, data, isComposing); |
} |
-InputEvent::EventIsComposing isComposingFromCommand( |
- const CompositeEditCommand* command) { |
- if (command->isTypingCommand() && |
- toTypingCommand(command)->compositionType() != |
- TypingCommand::TextCompositionNone) |
- return InputEvent::EventIsComposing::IsComposing; |
- return InputEvent::EventIsComposing::NotComposing; |
-} |
- |
} // anonymous namespace |
Editor::RevealSelectionScope::RevealSelectionScope(Editor* editor) |
@@ -623,63 +613,6 @@ void Editor::replaceSelectionAfterDragging(DocumentFragment* fragment, |
->apply(EditCommandSource::kMenuOrKeyBinding); |
} |
-bool Editor::deleteSelectionAfterDraggingWithEvents( |
- Element* dragSource, |
- DeleteMode deleteMode, |
- const Position& referenceMovePosition) { |
- if (!dragSource || !dragSource->isConnected()) |
- return true; |
- |
- // Dispatch 'beforeinput'. |
- const bool shouldDelete = dispatchBeforeInputEditorCommand( |
- dragSource, InputEvent::InputType::DeleteByDrag, |
- nullptr) == DispatchEventResult::NotCanceled; |
- |
- // 'beforeinput' event handler may destroy frame, return false to cancel |
- // remaining actions; |
- if (m_frame->document()->frame() != m_frame) |
- return false; |
- |
- if (shouldDelete && dragSource->isConnected()) { |
- deleteSelectionWithSmartDelete( |
- EditCommandSource::kMenuOrKeyBinding, deleteMode, |
- InputEvent::InputType::DeleteByDrag, referenceMovePosition); |
- } |
- |
- return true; |
-} |
- |
-bool Editor::replaceSelectionAfterDraggingWithEvents( |
- Element* dropTarget, |
- DragData* dragData, |
- DocumentFragment* fragment, |
- Range* dropCaretRange, |
- InsertMode insertMode, |
- DragSourceType dragSourceType) { |
- if (!dropTarget || !dropTarget->isConnected()) |
- return true; |
- |
- // Dispatch 'beforeinput'. |
- DataTransfer* dataTransfer = |
- DataTransfer::create(DataTransfer::DragAndDrop, DataTransferReadable, |
- dragData->platformData()); |
- dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()); |
- const bool shouldInsert = |
- dispatchBeforeInputDataTransfer( |
- dropTarget, InputEvent::InputType::InsertFromDrop, dataTransfer, |
- nullptr) == DispatchEventResult::NotCanceled; |
- |
- // 'beforeinput' event handler may destroy frame, return false to cancel |
- // remaining actions; |
- if (m_frame->document()->frame() != m_frame) |
- return false; |
- |
- if (shouldInsert && dropTarget->isConnected()) |
- replaceSelectionAfterDragging(fragment, insertMode, dragSourceType); |
- |
- return true; |
-} |
- |
EphemeralRange Editor::selectedRange() { |
return frame().selection().selection().toNormalizedEphemeralRange(); |
} |
@@ -1069,16 +1002,6 @@ void Editor::cut(EditCommandSource source) { |
writeSelectionToPasteboard(); |
} |
- if (source == EditCommandSource::kMenuOrKeyBinding) { |
- if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), |
- InputEvent::InputType::DeleteByCut, |
- nullptr, nullptr) != |
- DispatchEventResult::NotCanceled) |
- return; |
- // 'beforeinput' event handler may destroy target frame. |
- if (m_frame->document()->frame() != m_frame) |
- return; |
- } |
deleteSelectionWithSmartDelete( |
source, canSmartCopyOrDelete() ? DeleteMode::Smart : DeleteMode::Simple, |
InputEvent::InputType::DeleteByCut); |
@@ -1113,7 +1036,9 @@ void Editor::copy() { |
} |
} |
-void Editor::paste(EditCommandSource source) { |
+// TODO(chongz): Pass |EditCommandSource| to |TextEvent| and don't fire |
+// 'beforeinput' for JS triggered paste. |
chongz
2016/12/20 04:48:58
See comments in "inputevent-execcommand.html".
|
+void Editor::paste(EditCommandSource) { |
DCHECK(frame().document()); |
if (tryDHTMLPaste(AllMimeTypes)) |
return; // DHTML did the whole operation |
@@ -1127,21 +1052,6 @@ void Editor::paste(EditCommandSource source) { |
? AllMimeTypes |
: PlainTextOnly; |
- if (source == EditCommandSource::kMenuOrKeyBinding) { |
- DataTransfer* dataTransfer = |
- DataTransfer::create(DataTransfer::CopyAndPaste, DataTransferReadable, |
- DataObject::createFromPasteboard(pasteMode)); |
- |
- if (dispatchBeforeInputDataTransfer(findEventTargetFromSelection(), |
- InputEvent::InputType::InsertFromPaste, |
- dataTransfer, nullptr) != |
- DispatchEventResult::NotCanceled) |
- return; |
- // 'beforeinput' event handler may destroy target frame. |
- if (m_frame->document()->frame() != m_frame) |
- return; |
- } |
- |
if (pasteMode == AllMimeTypes) |
pasteWithPasteboard(Pasteboard::generalPasteboard()); |
else |
@@ -1296,7 +1206,7 @@ void Editor::setBaseWritingDirection(WritingDirection direction) { |
void Editor::revealSelectionAfterEditingOperation( |
const ScrollAlignment& alignment, |
RevealExtentOption revealExtentOption) { |
- if (m_preventRevealSelection) |
+ if (m_preventRevealSelection || !m_frame->selection().isAvailable()) |
return; |
frame().selection().revealSelection(alignment, revealExtentOption); |
} |