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

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

Issue 21235009: Make sure the last selection gets spell checked when focusing different frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 4 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 | « Source/core/editing/Editor.h ('k') | Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/Editor.cpp
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index 1534ca33e87d9600444538ffdb51ad963552972d..ba273482d6d01b29d5ab6f93e69a04238c084f39 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -2291,15 +2291,7 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, Fra
&& oldSelection.start().deprecatedNode()
&& oldSelection.start().anchorNode()->inDocument()
&& !isSelectionInTextField(oldSelection)) {
- VisiblePosition oldStart(oldSelection.visibleStart());
- VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, LeftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary));
- if (oldAdjacentWords != newAdjacentWords) {
- if (isContinuousGrammarCheckingEnabled) {
- VisibleSelection oldSelectedSentence = VisibleSelection(startOfSentence(oldStart), endOfSentence(oldStart));
- markMisspellingsAndBadGrammar(oldAdjacentWords, oldSelectedSentence != newSelectedSentence, oldSelectedSentence);
- } else
- markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWords);
- }
+ spellCheckOldSelection(oldSelection, newAdjacentWords, newSelectedSentence);
}
if (!textChecker() || textChecker()->shouldEraseMarkersAfterChangeSelection(TextCheckingTypeSpelling)) {
@@ -2323,6 +2315,34 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, Fra
notifyComponentsOnChangedSelection(oldSelection, options);
}
+void Editor::spellCheckAfterBlur()
+{
+ if (!m_frame->selection()->selection().isContentEditable())
+ return;
+
+ if (isSelectionInTextField(m_frame->selection()->selection())) {
+ // textFieldDidEndEditing() and textFieldDidBeginEditing() handle this.
+ return;
+ }
+
+ VisibleSelection empty;
+ spellCheckOldSelection(m_frame->selection()->selection(), empty, empty);
+}
+
+void Editor::spellCheckOldSelection(const VisibleSelection& oldSelection, const VisibleSelection& newAdjacentWords, const VisibleSelection& newSelectedSentence)
+{
+ VisiblePosition oldStart(oldSelection.visibleStart());
+ VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, LeftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary));
+ if (oldAdjacentWords != newAdjacentWords) {
+ if (isContinuousSpellCheckingEnabled() && isGrammarCheckingEnabled()) {
+ VisibleSelection selectedSentence = VisibleSelection(startOfSentence(oldStart), endOfSentence(oldStart));
+ markMisspellingsAndBadGrammar(oldAdjacentWords, selectedSentence != newSelectedSentence, selectedSentence);
+ } else {
+ markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWords);
+ }
+ }
+}
+
static Node* findFirstMarkable(Node* node)
{
while (node) {
« no previous file with comments | « Source/core/editing/Editor.h ('k') | Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698