Index: Source/core/editing/Editor.cpp |
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp |
index ed04fdbd82b534fa325a303580e490b50fd336af..50d59502400c19322801dadd76414cedecc04ffc 100644 |
--- a/Source/core/editing/Editor.cpp |
+++ b/Source/core/editing/Editor.cpp |
@@ -1017,6 +1017,8 @@ bool Editor::isContinuousSpellCheckingEnabled() const |
void Editor::toggleContinuousSpellChecking() |
{ |
client().toggleContinuousSpellChecking(); |
+ if (!isContinuousSpellCheckingEnabled()) |
+ m_editablesSpellCheckedOnFocus.clear(); |
} |
bool Editor::isGrammarCheckingEnabled() |
@@ -1059,12 +1061,45 @@ void Editor::redo() |
client().redo(); |
} |
-void Editor::didBeginEditing() |
+void Editor::elementDidBeginEditing(Element* element) |
+{ |
+ if (isContinuousSpellCheckingEnabled() && unifiedTextCheckerEnabled()) { |
+ // This could be called for textareas, text fields and contenteditables. |
+ // Markers from text fields are cleared on blur so text fields have to be spell cheked on each focus as opposed |
+ // to textareas and contenteditables which should be spell checked on the first focus only. |
+ // This is also why text fields are not put into m_editablesSpellCheckedOnFocus. |
+ // For textareas HTMLTextFormControlElement is put into m_editablesSpellCheckedOnFocus but spell checking |
+ // is performed on its inner text element (the latter also applies to text fields). For contenteditables |
+ // the passed in element is put into m_editablesSpellCheckedOnFocus (it's the root editable element). |
+ 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 || !m_editablesSpellCheckedOnFocus.contains(parent)) { |
+ VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(element); |
+ markMisspellingsAndBadGrammar(selection); |
+ if (!isTextField) |
+ m_editablesSpellCheckedOnFocus.append(parent); |
+ } |
+ } |
+} |
+ |
+void Editor::didBeginEditing(Element* rootEditableElement) |
{ |
+ elementDidBeginEditing(rootEditableElement); |
client().didBeginEditing(); |
} |
-void Editor::didEndEditing() |
+void Editor::didEndEditing(Element*) |
{ |
client().didEndEditing(); |
} |
@@ -1867,14 +1902,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) |