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

Unified Diff: Source/web/EditorClientImpl.cpp

Issue 21130005: Trigger spell check/remove markers if spell checker gets enabled/disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Revert paste related changes 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 15e3346cc4c0f4f3e3b633fe3641b3fb01e41818..8268f157865117d86e89c32823995b51638b5a63 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