diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 6e09bcd1e5e6..c813ccf5143f 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -1704,10 +1704,7 @@ nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, NS_ENSURE_SUCCESS(rv, rv); } else if (aNotify && aName == nsHTMLAtoms::spellcheck) { - nsCOMPtr editor = GetAssociatedEditor(); - if (editor) { - editor->SyncRealTimeSpell(); - } + SyncEditorsOnSubtree(this); } } @@ -4146,3 +4143,28 @@ nsGenericHTMLElement::IsCurrentBodyElement() htmlDocument->GetBody(getter_AddRefs(htmlElement)); return htmlElement == bodyElement; } + +// static +void +nsGenericHTMLElement::SyncEditorsOnSubtree(nsIContent* content) +{ + /* Sync this node */ + nsGenericHTMLElement* element = FromContent(content); + if (element) { + nsCOMPtr editor = element->GetAssociatedEditor(); + if (editor) { + editor->SyncRealTimeSpell(); + } + } + + /* Sync all children */ + PRUint32 childCount = content->GetChildCount(); + for (PRUint32 i = 0; i < childCount; ++i) { + nsIContent* childContent = content->GetChildAt(i); + NS_ASSERTION(childContent, + "DOM mutated unexpectedly while syncing editors!"); + if (childContent) { + SyncEditorsOnSubtree(childContent); + } + } +} diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 4f2ecf2cdf52..77a4589b835e 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -766,6 +766,12 @@ protected: * Returns true if this is the current document's body element */ PRBool IsCurrentBodyElement(); + + /** + * Ensures all editors associated with a subtree are synced, for purposes of + * spellchecking. + */ + static void SyncEditorsOnSubtree(nsIContent* content); };