Bug 1676363 - Remove dependency of nsTArray on nsCycleCollectionChild. r=#xpcom-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D96547

Depends on D96546
This commit is contained in:
Simon Giesecke 2020-11-23 16:09:49 +00:00
Родитель 3c48c1c404
Коммит 8924394252
3 изменённых файлов: 23 добавлений и 6 удалений

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

@ -44,6 +44,12 @@
* allocated using C memory allocation functions.
*/
// XXX(Bug 1677529) Without undefining MALLOC_H, an ASAN build breaks. Maybe
// this is actually the right thing to do, but Bug 1677529 should check that.
#if defined(MALLOC_H) && !defined(XP_DARWIN)
# undef MALLOC_H
#endif
#include "mozilla/mozalloc.h"
#include "mozHunspellAllocator.h"

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

@ -7,6 +7,7 @@
#include <string.h>
#include "nsTArray.h"
#include "nsXPCOM.h"
#include "nsCycleCollectionNoteChild.h"
#include "nsDebug.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/IntegerPrintfMacros.h"
@ -28,3 +29,7 @@ MOZ_NORETURN MOZ_COLD void InvalidArrayIndex_CRASH(size_t aIndex,
"ElementAt(aIndex = %" PRIu64 ", aLength = %" PRIu64 ")",
static_cast<uint64_t>(aIndex), static_cast<uint64_t>(aLength));
}
void ::detail::SetCycleCollectionArrayFlag(uint32_t& aFlags) {
aFlags |= CycleCollectionEdgeNameArrayFlag;
}

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

@ -23,29 +23,26 @@
#include "mozilla/Attributes.h"
#include "mozilla/BinarySearch.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/DbgMacro.h"
#include "mozilla/FunctionTypeTraits.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/NotNull.h"
#include "mozilla/Span.h"
#include "mozilla/TypeTraits.h"
#include "mozilla/fallible.h"
#include "mozilla/mozalloc.h"
#include "nsAlgorithm.h"
#include "nsCycleCollectionNoteChild.h"
#include "nsDebug.h"
#include "nsISupportsImpl.h"
#include "nsISupports.h"
#include "nsQuickSort.h"
#include "nsRegionFwd.h"
#include "nsTArrayForwardDeclare.h"
#include "nscore.h"
namespace JS {
template <class T>
class Heap;
} /* namespace JS */
class nsCycleCollectionTraversalCallback;
class nsRegion;
namespace mozilla::a11y {
@ -105,6 +102,9 @@ class Endpoint;
class JSStructuredCloneData;
template <class T>
class RefPtr;
//
// nsTArray<E> is a resizable array class, like std::vector.
//
@ -2662,11 +2662,17 @@ inline void ImplCycleCollectionUnlink(nsTArray_Impl<E, Alloc>& aField) {
aField.Clear();
}
namespace detail {
// This is defined in the cpp file to avoid including
// nsCycleCollectionNoteChild.h in this header file.
void SetCycleCollectionArrayFlag(uint32_t& aFlags);
} // namespace detail
template <typename E, typename Alloc>
inline void ImplCycleCollectionTraverse(
nsCycleCollectionTraversalCallback& aCallback,
nsTArray_Impl<E, Alloc>& aField, const char* aName, uint32_t aFlags = 0) {
aFlags |= CycleCollectionEdgeNameArrayFlag;
::detail::SetCycleCollectionArrayFlag(aFlags);
size_t length = aField.Length();
for (size_t i = 0; i < length; ++i) {
ImplCycleCollectionTraverse(aCallback, aField[i], aName, aFlags);