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

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: Created 7 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
Index: Source/web/EditorClientImpl.cpp
diff --git a/Source/web/EditorClientImpl.cpp b/Source/web/EditorClientImpl.cpp
index 3f0ec5ee5f751dd484bbeb586ed9604344b572e7..b50b8f7d3c706bab796a978570030f33ab4b595e 100644
--- a/Source/web/EditorClientImpl.cpp
+++ b/Source/web/EditorClientImpl.cpp
@@ -46,6 +46,7 @@
#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"
@@ -139,10 +140,24 @@ bool EditorClientImpl::isContinuousSpellCheckingEnabled()
void EditorClientImpl::toggleContinuousSpellChecking()
{
- if (isContinuousSpellCheckingEnabled())
+ if (isContinuousSpellCheckingEnabled()) {
m_spellCheckThisFieldStatus = SpellCheckForcedOff;
- else
+ const Frame* frame = m_webView->focusedWebCoreFrame();
+ if (frame)
abarth-chromium 2013/07/31 00:42:14 No need for "const". There's no meaningful sense
pstanek 2013/08/12 12:21:23 Won't this remove markers in one frame only (it sh
+ frame->document()->markers()->removeMarkers(DocumentMarker::Spelling | DocumentMarker::Grammar);
+ } else {
m_spellCheckThisFieldStatus = SpellCheckForcedOn;
+ const Frame* frame = m_webView->focusedWebCoreFrame();
+ if (frame) {
abarth-chromium 2013/07/31 00:42:14 ditto
+ VisibleSelection frameSelection = frame->selection()->selection();
+ Element* rootEditableElement = frameSelection.rootEditableElement();
+ // If a selection is in an editable element spell check its content.
+ if (rootEditableElement) {
abarth-chromium 2013/07/31 00:42:14 You can also combine this if statement with the pr
+ VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(rootEditableElement);
+ frame->editor()->markMisspellingsAndBadGrammar(selection);
+ }
+ }
+ }
}
bool EditorClientImpl::isGrammarCheckingEnabled()

Powered by Google App Engine
This is Rietveld 408576698