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

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

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: yosin@ comment#57 #58 addressed Created 4 years, 1 month 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 29a3833f5c7b20dc68ff6c158e40be24fe07e499..96b5a6583540f6e4ff7a31130bd3d47b32f41e7a 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -212,13 +212,15 @@ bool Editor::handleTextEvent(TextEvent* event) {
m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
if (event->isPaste()) {
- if (event->pastingFragment())
- replaceSelectionWithFragment(event->pastingFragment(), false,
- event->shouldSmartReplace(),
- event->shouldMatchStyle());
- else
+ if (event->pastingFragment()) {
+ replaceSelectionWithFragment(
+ event->pastingFragment(), false, event->shouldSmartReplace(),
+ event->shouldMatchStyle(), InputEvent::InputType::InsertFromPaste);
+ } else {
replaceSelectionWithText(event->data(), false,
- event->shouldSmartReplace());
+ event->shouldSmartReplace(),
+ InputEvent::InputType::InsertFromPaste);
+ }
return true;
}
@@ -559,7 +561,8 @@ bool Editor::canSmartReplaceWithPasteboard(Pasteboard* pasteboard) {
void Editor::replaceSelectionWithFragment(DocumentFragment* fragment,
bool selectReplacement,
bool smartReplace,
- bool matchStyle) {
+ bool matchStyle,
+ InputEvent::InputType inputType) {
DCHECK(!frame().document()->needsLayoutTreeUpdate());
if (frame().selection().isNone() ||
!frame().selection().isContentEditable() || !fragment)
@@ -576,16 +579,18 @@ void Editor::replaceSelectionWithFragment(DocumentFragment* fragment,
options |= ReplaceSelectionCommand::MatchStyle;
DCHECK(frame().document());
ReplaceSelectionCommand::create(*frame().document(), fragment, options,
- InputEvent::InputType::InsertFromPaste)
+ inputType)
->apply();
revealSelectionAfterEditingOperation();
}
void Editor::replaceSelectionWithText(const String& text,
bool selectReplacement,
- bool smartReplace) {
+ bool smartReplace,
+ InputEvent::InputType inputType) {
replaceSelectionWithFragment(createFragmentFromText(selectedRange(), text),
- selectReplacement, smartReplace, true);
+ selectReplacement, smartReplace, true,
+ inputType);
}
// TODO(xiaochengh): Merge it with |replaceSelectionWithFragment()|.
@@ -1299,7 +1304,10 @@ void Editor::transpose() {
frame().selection().setSelection(newSelection);
// Insert the transposed characters.
- replaceSelectionWithText(transposed, false, false);
+ // TODO(chongz): Once we add |InsertTranspose| in |InputEvent::InputType|, we
+ // should use it instead of |InsertFromPaste|.
+ replaceSelectionWithText(transposed, false, false,
+ InputEvent::InputType::InsertFromPaste);
}
void Editor::addToKillRing(const EphemeralRange& range) {

Powered by Google App Engine
This is Rietveld 408576698