Bug 1407843 part 1 - Introduce a global-level AtomArray type alias. r?froydnj
MozReview-Commit-ID: DbGkWxkPfX7
--- a/dom/base/nsAttrValue.h
+++ b/dom/base/nsAttrValue.h
@@ -20,16 +20,17 @@
#include "nsColor.h"
#include "nsCaseTreatment.h"
#include "nsMargin.h"
#include "nsCOMPtr.h"
#include "nsStringFwd.h"
#include "SVGAttrValueWrapper.h"
#include "nsTArrayForwardDeclare.h"
#include "nsAtom.h"
+#include "mozilla/AtomArray.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/EnumTypeTraits.h"
// Undefine LoadImage to prevent naming conflict with Windows.
#undef LoadImage
class nsIDocument;
@@ -79,18 +80,16 @@ public:
if (aBuf)
aBuf->ToString(aBuf->StorageSize()/sizeof(char16_t) - 1, *this);
}
};
class nsAttrValue {
friend struct MiscContainer;
public:
- typedef nsTArray< RefPtr<nsAtom> > AtomArray;
-
// This has to be the same as in ValueBaseType
enum ValueType {
eString = 0x00, // 00
// 01 this value indicates a 'misc' struct
eAtom = 0x02, // 10
eInteger = 0x03, // 0011
eColor = 0x07, // 0111
eEnum = 0x0B, // 1011 This should eventually die
@@ -195,17 +194,17 @@ public:
// to retrieve the datatype that this nsAttrValue has.
inline bool IsEmptyString() const;
const nsCheapString GetStringValue() const;
inline nsAtom* GetAtomValue() const;
inline int32_t GetIntegerValue() const;
bool GetColorValue(nscolor& aColor) const;
inline int16_t GetEnumValue() const;
inline float GetPercentValue() const;
- inline AtomArray* GetAtomArrayValue() const;
+ inline mozilla::AtomArray* GetAtomArrayValue() const;
inline mozilla::DeclarationBlock* GetCSSDeclarationValue() const;
inline mozilla::css::URLValue* GetURLValue() const;
inline mozilla::css::ImageValue* GetImageValue() const;
inline double GetDoubleValue() const;
bool GetIntMarginValue(nsIntMargin& aMargin) const;
/**
* Returns the string corresponding to the stored enum value.
--- a/dom/base/nsAttrValueInlines.h
+++ b/dom/base/nsAttrValueInlines.h
@@ -29,17 +29,17 @@ struct MiscContainer final
union {
int32_t mInteger;
nscolor mColor;
uint32_t mEnumValue;
int32_t mPercent;
mozilla::DeclarationBlock* mCSSDeclaration;
mozilla::css::URLValue* mURL;
mozilla::css::ImageValue* mImage;
- nsAttrValue::AtomArray* mAtomArray;
+ mozilla::AtomArray* mAtomArray;
nsIntMargin* mIntMargin;
const nsSVGAngle* mSVGAngle;
const nsSVGIntegerPair* mSVGIntegerPair;
const nsSVGLength2* mSVGLength;
const mozilla::SVGLengthList* mSVGLengthList;
const mozilla::SVGNumberList* mSVGNumberList;
const nsSVGNumberPair* mSVGNumberPair;
const mozilla::SVGPathData* mSVGPathData;
@@ -134,17 +134,17 @@ nsAttrValue::GetPercentValue() const
{
NS_PRECONDITION(Type() == ePercent, "wrong type");
return ((BaseType() == eIntegerBase)
? GetIntInternal()
: GetMiscContainer()->mValue.mPercent)
/ 100.0f;
}
-inline nsAttrValue::AtomArray*
+inline mozilla::AtomArray*
nsAttrValue::GetAtomArrayValue() const
{
NS_PRECONDITION(Type() == eAtomArray, "wrong type");
return GetMiscContainer()->mValue.mAtomArray;
}
inline mozilla::DeclarationBlock*
nsAttrValue::GetCSSDeclarationValue() const
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6751,17 +6751,17 @@ nsContentUtils::StripNullChars(const nsA
while (start != end) {
if (*start != '\0')
aOutStr.Append(*start);
++start;
}
}
struct ClassMatchingInfo {
- nsAttrValue::AtomArray mClasses;
+ AtomArray mClasses;
nsCaseTreatment mCaseTreatment;
};
// static
bool
nsContentUtils::MatchClassNames(Element* aElement, int32_t aNamespaceID,
nsAtom* aAtom, void* aData)
{
--- a/dom/base/nsDOMTokenList.cpp
+++ b/dom/base/nsDOMTokenList.cpp
@@ -57,32 +57,31 @@ nsDOMTokenList::GetParsedAttr()
void
nsDOMTokenList::RemoveDuplicates(const nsAttrValue* aAttr)
{
if (!aAttr || aAttr->Type() != nsAttrValue::eAtomArray) {
return;
}
BloomFilter<8, nsAtom> filter;
- nsAttrValue::AtomArray* array = aAttr->GetAtomArrayValue();
+ AtomArray* array = aAttr->GetAtomArrayValue();
for (uint32_t i = 0; i < array->Length(); i++) {
nsAtom* atom = array->ElementAt(i);
if (filter.mightContain(atom)) {
// Start again, with a hashtable
RemoveDuplicatesInternal(array, i);
return;
} else {
filter.add(atom);
}
}
}
void
-nsDOMTokenList::RemoveDuplicatesInternal(nsAttrValue::AtomArray* aArray,
- uint32_t aStart)
+nsDOMTokenList::RemoveDuplicatesInternal(AtomArray* aArray, uint32_t aStart)
{
nsDataHashtable<nsPtrHashKey<nsAtom>, bool> tokens;
for (uint32_t i = 0; i < aArray->Length(); i++) {
nsAtom* atom = aArray->ElementAt(i);
// No need to check the hashtable below aStart
if (i >= aStart && tokens.Get(atom)) {
aArray->RemoveElementAt(i);
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -1,16 +1,17 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsTreeBodyFrame_h
#define nsTreeBodyFrame_h
+#include "mozilla/AtomArray.h"
#include "mozilla/Attributes.h"
#include "nsLeafBoxFrame.h"
#include "nsITreeView.h"
#include "nsICSSPseudoComparator.h"
#include "nsIScrollbarMediator.h"
#include "nsITimer.h"
#include "nsIReflowCallback.h"
@@ -594,17 +595,17 @@ protected: // Data Members
// A hashtable that maps from URLs to image request/listener pairs. The URL
// is provided by the view or by the style context. The style context
// represents a resolved :-moz-tree-cell-image (or twisty) pseudo-element.
// It maps directly to an imgIRequest.
nsDataHashtable<nsStringHashKey, nsTreeImageCacheEntry> mImageCache;
// A scratch array used when looking up cached style contexts.
- AtomArray mScratchArray;
+ mozilla::AtomArray mScratchArray;
// The index of the first visible row and the # of rows visible onscreen.
// The tree only examines onscreen rows, starting from
// this index and going up to index+pageLength.
int32_t mTopRowIndex;
int32_t mPageLength;
// The horizontal scroll position
--- a/layout/xul/tree/nsTreeStyleCache.h
+++ b/layout/xul/tree/nsTreeStyleCache.h
@@ -1,26 +1,24 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsTreeStyleCache_h__
#define nsTreeStyleCache_h__
+#include "mozilla/AtomArray.h"
#include "mozilla/Attributes.h"
#include "nsAutoPtr.h"
-#include "nsAtom.h"
#include "nsCOMArray.h"
#include "nsICSSPseudoComparator.h"
#include "nsRefPtrHashtable.h"
#include "nsStyleContext.h"
-typedef nsTArray<RefPtr<nsAtom>> AtomArray;
-
class nsTreeStyleCache
{
public:
nsTreeStyleCache()
: mNextState(0)
{
}
@@ -36,17 +34,17 @@ public:
mNextState = 0;
}
nsStyleContext* GetStyleContext(nsICSSPseudoComparator* aComparator,
nsPresContext* aPresContext,
nsIContent* aContent,
nsStyleContext* aContext,
nsICSSAnonBoxPseudo* aPseudoElement,
- const AtomArray & aInputWord);
+ const mozilla::AtomArray& aInputWord);
protected:
typedef uint32_t DFAState;
class Transition final
{
public:
Transition(DFAState aState, nsAtom* aSymbol);
--- a/layout/xul/tree/nsTreeUtils.h
+++ b/layout/xul/tree/nsTreeUtils.h
@@ -1,32 +1,34 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsTreeUtils_h__
#define nsTreeUtils_h__
+#include "mozilla/AtomArray.h"
#include "nsError.h"
#include "nsString.h"
#include "nsTreeStyleCache.h"
class nsAtom;
class nsIContent;
class nsTreeUtils
{
public:
/**
* Parse a whitespace separated list of properties into an array
* of atoms.
*/
static nsresult
- TokenizeProperties(const nsAString& aProperties, AtomArray & aPropertiesArray);
+ TokenizeProperties(const nsAString& aProperties,
+ mozilla::AtomArray& aPropertiesArray);
static nsIContent*
GetImmediateChild(nsIContent* aContainer, nsAtom* aTag);
static nsIContent*
GetDescendantChild(nsIContent* aContainer, nsAtom* aTag);
static nsresult
new file mode 100644
--- /dev/null
+++ b/xpcom/ds/AtomArray.h
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_AtomArray_h
+#define mozilla_AtomArray_h
+
+#include "mozilla/RefPtr.h"
+#include "nsTArray.h"
+
+class nsAtom;
+
+namespace mozilla {
+typedef nsTArray<RefPtr<nsAtom>> AtomArray;
+}
+
+#endif // mozilla_AtomArray_h
--- a/xpcom/ds/moz.build
+++ b/xpcom/ds/moz.build
@@ -75,16 +75,17 @@ EXPORTS += [
'nsWhitespaceTokenizer.h',
'PLDHashTable.h',
]
EXPORTS.mozilla += [
'ArenaAllocator.h',
'ArenaAllocatorExtensions.h',
'ArrayIterator.h',
+ 'AtomArray.h',
'Dafsa.h',
'IncrementalTokenizer.h',
'Observer.h',
'StickyTimeDuration.h',
'Tokenizer.h',
]
UNIFIED_SOURCES += [