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

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

Issue 1636883003: Perform Spellcheck Requesting before Dispatching Events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 72d484ede33cc09c89e368afb99c31af3d808e2d..3808290a1735efb15ef3b7e585eadfc35606b333 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -510,14 +510,6 @@ void Editor::replaceSelectionWithFragment(PassRefPtrWillBeRawPtr<DocumentFragmen
ASSERT(frame().document());
ReplaceSelectionCommand::create(*frame().document(), fragment, options, EditActionPaste)->apply();
revealSelectionAfterEditingOperation();
-
- if (frame().selection().isInPasswordField() || !spellChecker().isContinuousSpellCheckingEnabled())
- return;
- ASSERT(lastEditCommand()->isReplaceSelectionCommand());
- const EphemeralRange& insertedRange = toReplaceSelectionCommand(lastEditCommand())->insertedRange();
- if (insertedRange.isNull())
- return;
- spellChecker().chunkAndMarkAllMisspellingsAndBadGrammar(frame().selection().rootEditableElement(), insertedRange);
}
void Editor::replaceSelectionWithText(const String& text, bool selectReplacement, bool smartReplace)
@@ -671,11 +663,30 @@ static void dispatchEditableContentChangedEvents(PassRefPtrWillBeRawPtr<Element>
endRoot->dispatchEvent(Event::create(EventTypeNames::webkitEditableContentChanged));
}
+void Editor::requestSpellcheckingAfterApplyingCommand(CompositeEditCommand* cmd)
+{
+ // Note: Request spell checking for and only for |ReplaceSelectionCommand|s
+ // created in |Editor::replaceSelectionWithFragment()|.
+ // TODO(xiaochengh): May also need to do this after dragging crbug.com/298046.
+ if (cmd->editingAction() != EditActionPaste)
+ return;
+ if (frame().selection().isInPasswordField() || !spellChecker().isContinuousSpellCheckingEnabled())
+ return;
+ ASSERT(cmd->isReplaceSelectionCommand());
+ const EphemeralRange& insertedRange = toReplaceSelectionCommand(cmd)->insertedRange();
+ if (insertedRange.isNull())
+ return;
+ spellChecker().chunkAndMarkAllMisspellingsAndBadGrammar(cmd->endingSelection().rootEditableElement(), insertedRange);
+}
+
void Editor::appliedEditing(PassRefPtrWillBeRawPtr<CompositeEditCommand> cmd)
{
EventQueueScope scope;
frame().document()->updateLayout();
+ // Request spell checking after pasting before any further DOM change.
+ requestSpellcheckingAfterApplyingCommand(cmd.get());
+
EditCommandComposition* composition = cmd->composition();
ASSERT(composition);
dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement());
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698