Chromium Code Reviews| Index: Source/core/editing/Editor.cpp |
| diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp |
| index ed04fdbd82b534fa325a303580e490b50fd336af..578e5d4313c8a691a3e7ac0c66df29508f7a4545 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()) { |
|
tony
2013/08/22 18:44:34
Nit: If you early return, when enabled, the rest o
|
| + 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) |