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

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2101263002: [Editing][CodeHealth] Refactor SpellChecker::respondToChangedSelection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 5 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 | « no previous file | 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/spellcheck/SpellChecker.cpp
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
index 07c4c9611ec3ad3495929e7c0048a1b8d5ead985..12cd1930c72d066d8636af8e67e6258ea0fe2636 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -796,37 +796,38 @@ void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio
if (!isSpellCheckingEnabledFor(oldSelection))
return;
- bool closeTyping = options & FrameSelection::CloseTyping;
- bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabled();
- bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled;
- if (isContinuousSpellCheckingEnabled && closeTyping && shouldCheckOldSelection(oldSelection)) {
- VisibleSelection newAdjacentWords;
- bool caretBrowsing = frame().settings() && frame().settings()->caretBrowsingEnabled();
- const VisibleSelection newSelection = frame().selection().selection();
- if (isSelectionInTextFormControl(newSelection)) {
- Position newStart = newSelection.start();
- newAdjacentWords.setWithoutValidation(HTMLTextFormControlElement::startOfWord(newStart), HTMLTextFormControlElement::endOfWord(newStart));
- } else {
- frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
- if (newSelection.isContentEditable() || caretBrowsing) {
- VisiblePosition newStart(newSelection.visibleStart());
- newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary));
- }
- }
-
- // When typing we check spelling elsewhere, so don't redo it here.
- // If this is a change in selection resulting from a delete operation,
- // oldSelection may no longer be in the document.
- // FIXME(http://crbug.com/382809): if oldSelection is on a textarea
- // element, we cause synchronous layout.
- spellCheckOldSelection(oldSelection, newAdjacentWords);
- }
-
// When continuous spell checking is off, existing markers disappear after the selection changes.
- if (!isContinuousSpellCheckingEnabled)
+ if (!isContinuousSpellCheckingEnabled()) {
frame().document()->markers().removeMarkers(DocumentMarker::Spelling);
- if (!isContinuousGrammarCheckingEnabled)
frame().document()->markers().removeMarkers(DocumentMarker::Grammar);
+ return;
+ }
+
+ if (!(options & FrameSelection::CloseTyping))
+ return;
+ if (!shouldCheckOldSelection(oldSelection))
+ return;
+
+ VisibleSelection newAdjacentWords;
+ const VisibleSelection newSelection = frame().selection().selection();
+ if (isSelectionInTextFormControl(newSelection)) {
+ const Position newStart = newSelection.start();
+ newAdjacentWords.setWithoutValidation(HTMLTextFormControlElement::startOfWord(newStart), HTMLTextFormControlElement::endOfWord(newStart));
+ } else {
+ frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
+ const bool caretBrowsing = frame().settings() && frame().settings()->caretBrowsingEnabled();
+ if (newSelection.isContentEditable() || caretBrowsing) {
+ const VisiblePosition newStart(newSelection.visibleStart());
+ newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary));
+ }
+ }
+
+ // When typing we check spelling elsewhere, so don't redo it here.
+ // If this is a change in selection resulting from a delete operation,
+ // oldSelection may no longer be in the document.
+ // FIXME(http://crbug.com/382809): if oldSelection is on a textarea
+ // element, we cause synchronous layout.
+ spellCheckOldSelection(oldSelection, newAdjacentWords);
}
void SpellChecker::removeSpellingMarkers()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698