Chromium Code Reviews| 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 e4e310ba992fcf14ebfbcff1c3287c593e68e7e1..3bd00fdbc42d246e8c230f804b132a96565a1f9e 100644 |
| --- a/third_party/WebKit/Source/core/editing/Editor.cpp |
| +++ b/third_party/WebKit/Source/core/editing/Editor.cpp |
| @@ -1028,9 +1028,11 @@ bool Editor::insertText(const String& text, KeyboardEvent* triggeringEvent) { |
| return frame().eventHandler().handleTextInputEvent(text, triggeringEvent); |
| } |
| -bool Editor::insertTextWithoutSendingTextEvent(const String& text, |
| - bool selectInsertedText, |
| - TextEvent* triggeringEvent) { |
| +bool Editor::insertTextWithoutSendingTextEvent( |
| + const String& text, |
| + bool selectInsertedText, |
| + TextEvent* triggeringEvent, |
| + InputEvent::InputType inputType) { |
| if (text.isEmpty()) |
| return false; |
| @@ -1047,7 +1049,8 @@ bool Editor::insertTextWithoutSendingTextEvent(const String& text, |
| selectInsertedText ? TypingCommand::SelectInsertedText : 0, |
| triggeringEvent && triggeringEvent->isComposition() |
| ? TypingCommand::TextCompositionConfirm |
| - : TypingCommand::TextCompositionNone); |
| + : TypingCommand::TextCompositionNone, |
| + false, inputType); |
| // Reveal the current selection |
| if (LocalFrame* editedFrame = selection.start().document()->frame()) { |
| @@ -1405,11 +1408,23 @@ void Editor::transpose() { |
| frame().selection().computeVisibleSelectionInDOMTreeDeprecated()) |
| frame().selection().setSelection(newSelection); |
| + if (dispatchBeforeInputInsertText( |
| + eventTargetNodeForDocument(frame().document()), transposed, |
| + InputEvent::InputType::InsertTranspose) != |
| + DispatchEventResult::NotCanceled) |
| + return; |
| + |
| + // 'beforeinput' event handler may destroy document. |
| + if (m_frame->document()->frame() != m_frame) |
| + return; |
| + |
| + // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
|
yosin_UTC9
2017/03/09 03:49:11
nit: s/xiaochengh/editing-dev/
chongz
2017/03/09 21:31:36
Done.
|
| + // needs to be audited. see http://crbug.com/590369 for more details. |
| + frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| + |
| // Insert the transposed characters. |
| - // TODO(chongz): Once we add |InsertTranspose| in |InputEvent::InputType|, we |
| - // should use it instead of |InsertFromPaste|. |
| replaceSelectionWithText(transposed, false, false, |
| - InputEvent::InputType::InsertFromPaste); |
| + InputEvent::InputType::InsertTranspose); |
| } |
| void Editor::addToKillRing(const EphemeralRange& range) { |