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
Родитель b0949e6412
Коммит 581157178e
2 изменённых файлов: 32 добавлений и 4 удалений

Просмотреть файл

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

Просмотреть файл

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