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

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

Issue 2747943005: [InputEvent] Support 'insertTranspose' (Closed)
Patch Set: Created 3 years, 9 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 6bb6bebb520c939e83b55528f62a4e64bed94715..f1e1a4f03625f798be6e68baebb3e14a97eb0dd1 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -1416,11 +1416,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(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
+ // 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) {

Powered by Google App Engine
This is Rietveld 408576698