#457: M1414452 converted to nsAutoTArray from AutoTArray

This commit is contained in:
Cameron Kaiser 2018-01-15 16:15:19 -08:00
parent ec2be8cb3f
commit d04b9da169

View File

@ -436,7 +436,7 @@ class nsTextNodeDirectionalityMap
nsTextNodeDirectionalityMap* map = nsTextNodeDirectionalityMap* map =
reinterpret_cast<nsTextNodeDirectionalityMap * >(aPropertyValue); reinterpret_cast<nsTextNodeDirectionalityMap * >(aPropertyValue);
map->EnsureMapIsClear(textNode); map->EnsureMapIsClear();
delete map; delete map;
} }
@ -565,11 +565,12 @@ private:
return OpRemove; return OpRemove;
} }
static nsCheapSetOperator ClearEntry(nsPtrHashKey<Element>* aEntry, void* aData) static nsCheapSetOperator TakeEntries(nsPtrHashKey<Element>* aEntry, void* aData)
{ {
Element* rootNode = aEntry->GetKey(); // TenFourFox lacks AutoTArray, so convert bug 1414452 to nsAutoTArray.
rootNode->ClearHasDirAutoSet(); nsAutoTArray<Element*, 8>* entries =
rootNode->DeleteProperty(nsGkAtoms::dirAutoSetBy); static_cast<nsAutoTArray<Element*, 8>*>(aData);
entries->AppendElement(aEntry->GetKey());
return OpRemove; return OpRemove;
} }
@ -585,12 +586,18 @@ public:
mElements.EnumerateEntries(ResetNodeDirection, &data); mElements.EnumerateEntries(ResetNodeDirection, &data);
} }
void EnsureMapIsClear(nsINode* aTextNode) void EnsureMapIsClear()
{ {
AutoRestore<Element*> restore(mElementToBeRemoved); AutoRestore<Element*> restore(mElementToBeRemoved);
DebugOnly<uint32_t> clearedEntries = // As above.
mElements.EnumerateEntries(ClearEntry, aTextNode); nsAutoTArray<Element*, 8> entries;
MOZ_ASSERT(clearedEntries == 0, "Map should be empty already"); mElements.EnumerateEntries(TakeEntries, &entries);
uint32_t size = entries.Length();
for(uint32_t i = 0; i < size; i++) {
Element* el = entries.ElementAt(i);
el->ClearHasDirAutoSet();
el->DeleteProperty(nsGkAtoms::dirAutoSetBy);
}
} }
static void RemoveElementFromMap(nsINode* aTextNode, Element* aElement) static void RemoveElementFromMap(nsINode* aTextNode, Element* aElement)
@ -630,7 +637,7 @@ public:
static void EnsureMapIsClearFor(nsINode* aTextNode) static void EnsureMapIsClearFor(nsINode* aTextNode)
{ {
if (aTextNode->HasTextNodeDirectionalityMap()) { if (aTextNode->HasTextNodeDirectionalityMap()) {
GetDirectionalityMap(aTextNode)->EnsureMapIsClear(aTextNode); GetDirectionalityMap(aTextNode)->EnsureMapIsClear();
} }
} }
}; };