Clear element from nsTextDirectionalityMap when unbinding. Bug 819623, r=peterv

This commit is contained in:
Simon Montagu 2013-01-06 01:45:28 -08:00
Родитель 329e61a8ab
Коммит 24e9a32425
3 изменённых файлов: 21 добавлений и 9 удалений

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

@ -126,6 +126,12 @@ void OnSetDirAttr(mozilla::dom::Element* aElement,
*/
void SetDirOnBind(mozilla::dom::Element* aElement, nsIContent* aParent);
/**
* Called when unbinding an element from the tree, to recompute the
* directionality of the element if it doesn't have autodirection, and to
* clean up any entries in nsTextDirectionalityMap that refer to it.
*/
void ResetDir(mozilla::dom::Element* aElement);
} // end namespace mozilla
#endif /* DirectionalityUtils_h___ */

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

@ -569,13 +569,6 @@ RecomputeDirectionality(Element* aElement, bool aNotify)
{
MOZ_ASSERT(!aElement->HasDirAuto(),
"RecomputeDirectionality called with dir=auto");
if (aElement->HasDirAutoSet()) {
nsINode* setByNode =
static_cast<nsINode*>(aElement->GetProperty(nsGkAtoms::dirAutoSetBy));
if (setByNode) {
nsTextNodeDirectionalityMap::RemoveElementFromMap(setByNode, aElement);
}
}
Directionality dir = eDir_LTR;
@ -926,5 +919,18 @@ SetDirOnBind(mozilla::dom::Element* aElement, nsIContent* aParent)
}
}
void ResetDir(mozilla::dom::Element* aElement)
{
if (aElement->HasDirAutoSet()) {
nsINode* setByNode =
static_cast<nsINode*>(aElement->GetProperty(nsGkAtoms::dirAutoSetBy));
nsTextNodeDirectionalityMap::RemoveElementFromMap(setByNode, aElement);
}
if (!aElement->HasDirAuto()) {
RecomputeDirectionality(aElement, false);
}
}
} // end namespace mozilla

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

@ -1355,8 +1355,8 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
// This has to be here, rather than in nsGenericHTMLElement::UnbindFromTree,
// because it has to happen after unsetting the parent pointer, but before
// recursively unbinding the kids.
if (IsHTML() && !HasDirAuto()) {
RecomputeDirectionality(this, false);
if (IsHTML()) {
ResetDir(this);
}
if (aDeep) {