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

Unified Diff: Source/web/EditorClientImpl.cpp

Issue 23332004: Trigger spell check/remove markers if spell checker gets enabled/disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: true=>asynchronous 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/SpellCheckRequester.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/EditorClientImpl.cpp
diff --git a/Source/web/EditorClientImpl.cpp b/Source/web/EditorClientImpl.cpp
index 4ccca503b0ec605b5ee01e9da70c766aec835890..e6e8eb79e786cd9229ba66ab13cb5e4850922bb6 100644
--- a/Source/web/EditorClientImpl.cpp
+++ b/Source/web/EditorClientImpl.cpp
@@ -46,9 +46,12 @@
#include "WebViewClient.h"
#include "WebViewImpl.h"
#include "core/dom/Document.h"
+#include "core/dom/DocumentMarkerController.h"
#include "core/dom/EventNames.h"
#include "core/dom/KeyboardEvent.h"
#include "core/editing/Editor.h"
+#include "core/editing/SpellCheckRequester.h"
+#include "core/editing/TextCheckingHelper.h"
#include "core/editing/UndoStep.h"
#include "core/html/HTMLInputElement.h"
#include "core/page/EventHandler.h"
@@ -138,10 +141,26 @@ bool EditorClientImpl::isContinuousSpellCheckingEnabled()
void EditorClientImpl::toggleContinuousSpellChecking()
{
- if (isContinuousSpellCheckingEnabled())
+ if (isContinuousSpellCheckingEnabled()) {
m_spellCheckThisFieldStatus = SpellCheckForcedOff;
- else
+ if (Page* page = m_webView->page()) {
+ for (Frame* frame = page->mainFrame(); frame && frame->document(); frame = frame->tree()->traverseNext()) {
+ frame->document()->markers()->removeMarkers(DocumentMarker::Spelling | DocumentMarker::Grammar);
+ }
+ }
+ } else {
m_spellCheckThisFieldStatus = SpellCheckForcedOn;
+ if (Frame* frame = m_webView->focusedWebCoreFrame()) {
+ if (unifiedTextCheckerEnabled(frame)) {
+ VisibleSelection frameSelection = frame->selection()->selection();
+ // If a selection is in an editable element spell check its content.
+ if (Element* rootEditableElement = frameSelection.rootEditableElement()) {
+ VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(rootEditableElement);
+ frame->editor()->markMisspellingsAndBadGrammar(selection);
+ }
+ }
+ }
+ }
}
bool EditorClientImpl::isGrammarCheckingEnabled()
« no previous file with comments | « Source/core/editing/SpellCheckRequester.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698