Chromium Code Reviews| 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) |