Bug 346373: Resync children when parent spellcheck attribute changes.

r=bzbarsky
sr=sicking
This commit is contained in:
pkasting%google.com 2006-08-25 00:15:14 +00:00
parent b0949e6412
commit 581157178e
2 changed files with 32 additions and 4 deletions

View File

@ -1704,10 +1704,7 @@ nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
NS_ENSURE_SUCCESS(rv, rv);
}
else if (aNotify && aName == nsHTMLAtoms::spellcheck) {
nsCOMPtr<nsIEditor> 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<nsIEditor> 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);
}
}
}

View File

@ -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);
};