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

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

Issue 21694005: Spell check whole content of an editable element when it gets focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: style & spurious comment removal. 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/html/HTMLInputElement.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 ed04fdbd82b534fa325a303580e490b50fd336af..e193df2cb2559bc8c12910c198017996c4470d7f 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -1017,6 +1017,13 @@ bool Editor::isContinuousSpellCheckingEnabled() const
void Editor::toggleContinuousSpellChecking()
{
client().toggleContinuousSpellChecking();
+ if (isContinuousSpellCheckingEnabled())
+ return;
+ for (Frame* frame = m_frame->page()->mainFrame(); frame && frame->document(); frame = frame->tree()->traverseNext()) {
+ for (Node* node = frame->document()->rootNode(); node; node = NodeTraversal::next(node)) {
+ node->setAlreadySpellChecked(false);
+ }
+ }
}
bool Editor::isGrammarCheckingEnabled()
@@ -1059,8 +1066,35 @@ void Editor::redo()
client().redo();
}
-void Editor::didBeginEditing()
+void Editor::elementDidBeginEditing(Element* element)
+{
+ if (isContinuousSpellCheckingEnabled() && unifiedTextCheckerEnabled()) {
+ bool isTextField = false;
+ HTMLTextFormControlElement* enclosingHTMLTextFormControlElement = 0;
+ if (!isHTMLTextFormControlElement(element))
+ enclosingHTMLTextFormControlElement = enclosingTextFormControl(firstPositionInNode(element));
+ element = enclosingHTMLTextFormControlElement ? enclosingHTMLTextFormControlElement : element;
+ Element* parent = element;
+ if (isHTMLTextFormControlElement(element)) {
+ HTMLTextFormControlElement* textControl = toHTMLTextFormControlElement(element);
+ parent = textControl;
+ element = textControl->innerTextElement();
+ isTextField = textControl->hasTagName(inputTag) && toHTMLInputElement(textControl)->isTextField();
+ }
+
+ if (isTextField || !parent->isAlreadySpellChecked()) {
+ // We always recheck textfields because markers are removed from them on blur.
+ VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(element);
+ markMisspellingsAndBadGrammar(selection);
+ if (!isTextField)
+ parent->setAlreadySpellChecked(true);
+ }
+ }
+}
+
+void Editor::didBeginEditing(Element* rootEditableElement)
{
+ elementDidBeginEditing(rootEditableElement);
client().didBeginEditing();
}
@@ -1867,14 +1901,9 @@ void Editor::computeAndSetTypingStyle(StylePropertySet* style, EditAction editin
m_frame->selection()->setTypingStyle(typingStyle);
}
-
-void Editor::textFieldDidBeginEditing(Element* e)
+void Editor::textAreaOrTextFieldDidBeginEditing(Element* e)
{
- if (isContinuousSpellCheckingEnabled()) {
- Element* element = toHTMLTextFormControlElement(e)->innerTextElement();
- VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(element);
- markMisspellingsAndBadGrammar(selection);
- }
+ elementDidBeginEditing(e);
}
void Editor::textFieldDidEndEditing(Element* e)
« no previous file with comments | « Source/core/editing/Editor.h ('k') | Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698