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

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: 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/core/editing/Editor.cpp
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index a8f90e5047e66bfd74cd8db6aa1178ca50687336..bebfc5df166ca86ac4b4896f82d1deb378a7cb2d 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -96,6 +96,18 @@ bool isSelectionInTextField(const VisibleSelection& selection)
return textControl && textControl->hasTagName(inputTag) && toHTMLInputElement(textControl)->isTextField();
}
+// Spell checks whole contents of a editable element (<input="text"/>, <textarea> or contenteditable)
+// This gets called when any editable element gets focused.
+void elementDidBeginEditing(Element* element)
+{
+ if (Frame* frame = element->document()->frame()) {
+ if (frame->editor()->isContinuousSpellCheckingEnabled()) {
+ VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(element);
+ frame->editor()->markMisspellingsAndBadGrammar(selection);
tony 2013/08/02 17:01:17 Is it really OK to check all of a contentEditable
+ }
+ }
+}
+
} // namespace
// When an event handler has moved the selection outside of a text control
@@ -1061,13 +1073,15 @@ void Editor::redo()
client()->redo();
}
-void Editor::didBeginEditing()
+void Editor::didBeginEditing(Element* rootEditableElement)
{
+ elementDidBeginEditing(rootEditableElement);
+
if (client())
client()->didBeginEditing();
}
-void Editor::didEndEditing()
+void Editor::didEndEditing(Element*)
{
if (client())
client()->didEndEditing();
@@ -2086,14 +2100,14 @@ void Editor::computeAndSetTypingStyle(StylePropertySet* style, EditAction editin
m_frame->selection()->setTypingStyle(typingStyle);
}
+void Editor::textAreaDidBeginEditing(Element* e)
+{
+ elementDidBeginEditing(toHTMLTextFormControlElement(e)->innerTextElement());
+}
void Editor::textFieldDidBeginEditing(Element* e)
{
- if (isContinuousSpellCheckingEnabled()) {
- Element* element = toHTMLTextFormControlElement(e)->innerTextElement();
- VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(element);
- markMisspellingsAndBadGrammar(selection);
- }
+ elementDidBeginEditing(toHTMLTextFormControlElement(e)->innerTextElement());
tony 2013/08/02 17:01:17 textFieldDidBeginEditing and textAreaDidBeginEditi
}
void Editor::textFieldDidEndEditing(Element* e)

Powered by Google App Engine
This is Rietveld 408576698