Bug 1444031 - Rename Is{Static,Dynamic,HTML5}Atom. r=froydnj
By removing the "Atom" suffix, which is redundant.
MozReview-Commit-ID: 4MCX9Icfjrw
--- a/dom/base/nsPlainTextSerializer.cpp
+++ b/dom/base/nsPlainTextSerializer.cpp
@@ -1834,17 +1834,17 @@ nsPlainTextSerializer::IsCurrentNodeConv
nsAtom*
nsPlainTextSerializer::GetIdForContent(nsIContent* aContent)
{
if (!aContent->IsHTMLElement()) {
return nullptr;
}
nsAtom* localName = aContent->NodeInfo()->NameAtom();
- return localName->IsStaticAtom() ? localName : nullptr;
+ return localName->IsStatic() ? localName : nullptr;
}
bool
nsPlainTextSerializer::IsInPre()
{
return !mPreformatStack.empty() && mPreformatStack.top();
}
--- a/dom/bindings/DOMString.h
+++ b/dom/bindings/DOMString.h
@@ -212,17 +212,17 @@ public:
void SetKnownLiveAtom(nsAtom* aAtom, NullHandling aNullHandling)
{
MOZ_ASSERT(mString.isNothing(), "We already have a string?");
MOZ_ASSERT(mState == State::Empty, "We're already set to a value");
MOZ_ASSERT(!mStringBuffer, "Setting stringbuffer twice?");
MOZ_ASSERT(aAtom || aNullHandling != eNullNotExpected);
if (aNullHandling == eNullNotExpected || aAtom) {
- if (aAtom->IsStaticAtom()) {
+ if (aAtom->IsStatic()) {
// Static atoms are backed by literals.
SetLiteralInternal(aAtom->GetUTF16String(), aAtom->GetLength());
} else {
// Dynamic atoms always have a string buffer and never have 0 length,
// because nsGkAtoms::_empty is a static atom.
SetKnownLiveStringBuffer(aAtom->GetStringBuffer(), aAtom->GetLength());
}
} else if (aNullHandling == eTreatNullAsNull) {
--- a/parser/html/nsHtml5AtomTable.h
+++ b/parser/html/nsHtml5AtomTable.h
@@ -36,17 +36,17 @@ class nsHtml5AtomEntry : public nsString
* Each instance of nsHtml5Parser has a single instance of nsHtml5AtomTable,
* and each instance of nsHtml5StreamParser has a single instance of
* nsHtml5AtomTable. Dynamic atoms obtained from an nsHtml5AtomTable are valid
* for == comparison with each other or with atoms declared in nsHtml5Atoms
* within the nsHtml5Tokenizer and the nsHtml5TreeBuilder instances owned by
* the same nsHtml5Parser/nsHtml5StreamParser instance that owns the
* nsHtml5AtomTable instance.
*
- * Dynamic atoms (atoms whose IsStaticAtom() returns false) obtained from
+ * Dynamic atoms (atoms whose IsStatic() returns false) obtained from
* nsHtml5AtomTable must be re-obtained from another atom table when there's a
* need to migrate atoms from an nsHtml5Parser to its nsHtml5StreamParser
* (re-obtain from the other nsHtml5AtomTable), from an nsHtml5Parser to its
* owner nsHtml5Parser (re-obtain from the other nsHtml5AtomTable) or from the
* parser to the DOM (re-obtain from the application-wide atom table). To
* re-obtain an atom from another atom table, obtain a string from the atom
* using ToString(nsAString&) and look up an atom in the other table using that
* string.
--- a/parser/html/nsHtml5AttributeEntry.h
+++ b/parser/html/nsHtml5AttributeEntry.h
@@ -63,17 +63,17 @@ public:
nsHtml5AttributeEntry clone(*this);
// Increment refcount for value
clone.mValue = this->mValue.Clone();
if (aInterner) {
// Now if we have an interner, we'll need to rewrite non-static atoms.
// Only the local names may be non-static, in which case all three
// are the same.
nsAtom* local = GetLocal(0);
- if (!local->IsStaticAtom()) {
+ if (!local->IsStatic()) {
nsAutoString str;
local->ToString(str);
local = aInterner->GetAtom(str);
clone.mLocals[0] = local;
clone.mLocals[1] = local;
clone.mLocals[2] = local;
}
}
--- a/parser/html/nsHtml5Portability.cpp
+++ b/parser/html/nsHtml5Portability.cpp
@@ -82,17 +82,17 @@ nsHtml5Portability::newCharArrayFromStri
return arr;
}
nsAtom*
nsHtml5Portability::newLocalFromLocal(nsAtom* local, nsHtml5AtomTable* interner)
{
NS_PRECONDITION(local, "Atom was null.");
NS_PRECONDITION(interner, "Atom table was null");
- if (!local->IsStaticAtom()) {
+ if (!local->IsStatic()) {
nsAutoString str;
local->ToString(str);
local = interner->GetAtom(str);
}
return local;
}
bool
--- a/parser/html/nsHtml5TreeOperation.h
+++ b/parser/html/nsHtml5TreeOperation.h
@@ -107,17 +107,17 @@ class nsHtml5TreeOperation final {
* reobtains dynamic atoms from the Gecko-global atom table.
*
* @param aAtom a potentially parser-scoped atom
* @return an nsAtom that's pointer comparable on the main thread with
* other not-parser atoms.
*/
static inline already_AddRefed<nsAtom> Reget(nsAtom* aAtom)
{
- if (!aAtom || aAtom->IsStaticAtom()) {
+ if (!aAtom || aAtom->IsStatic()) {
return dont_AddRef(aAtom);
}
nsAutoString str;
aAtom->ToString(str);
return NS_AtomizeMainThread(str);
}
static nsresult AppendTextToTextNode(const char16_t* aBuffer,
--- a/xpcom/ds/nsAtom.h
+++ b/xpcom/ds/nsAtom.h
@@ -35,44 +35,44 @@ public:
bool Equals(const nsAString& aString) const
{
return Equals(aString.BeginReading(), aString.Length());
}
AtomKind Kind() const { return static_cast<AtomKind>(mKind); }
- bool IsDynamicAtom() const { return Kind() == AtomKind::DynamicAtom; }
- bool IsHTML5Atom() const { return Kind() == AtomKind::HTML5Atom; }
- bool IsStaticAtom() const { return Kind() == AtomKind::StaticAtom; }
+ bool IsDynamic() const { return Kind() == AtomKind::DynamicAtom; }
+ bool IsHTML5() const { return Kind() == AtomKind::HTML5Atom; }
+ bool IsStatic() const { return Kind() == AtomKind::StaticAtom; }
char16ptr_t GetUTF16String() const { return mString; }
uint32_t GetLength() const { return mLength; }
void ToString(nsAString& aString) const;
void ToUTF8String(nsACString& aString) const;
// This is not valid for static atoms. The caller must *not* mutate the
// string buffer, otherwise all hell will break loose.
nsStringBuffer* GetStringBuffer() const
{
// See the comment on |mString|'s declaration.
- MOZ_ASSERT(IsDynamicAtom() || IsHTML5Atom());
+ MOZ_ASSERT(IsDynamic() || IsHTML5());
return nsStringBuffer::FromData(const_cast<char16_t*>(mString));
}
// A hashcode that is better distributed than the actual atom pointer, for
// use in situations that need a well-distributed hashcode. It's called hash()
// rather than Hash() so we can use mozilla::BloomFilter<N, nsAtom>, because
// BloomFilter requires elements to implement a function called hash().
//
uint32_t hash() const
{
- MOZ_ASSERT(!IsHTML5Atom());
+ MOZ_ASSERT(!IsHTML5());
return mHash;
}
// We can't use NS_INLINE_DECL_THREADSAFE_REFCOUNTING because the refcounting
// of this type is special.
MozExternalRefCountType AddRef();
MozExternalRefCountType Release();
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -70,17 +70,17 @@ class nsDynamicAtom : public nsAtom
public:
// We can't use NS_INLINE_DECL_THREADSAFE_REFCOUNTING because the refcounting
// of this type is special.
MozExternalRefCountType AddRef();
MozExternalRefCountType Release();
static nsDynamicAtom* As(nsAtom* aAtom)
{
- MOZ_ASSERT(aAtom->IsDynamicAtom());
+ MOZ_ASSERT(aAtom->IsDynamic());
return static_cast<nsDynamicAtom*>(aAtom);
}
private:
friend class nsAtomTable;
friend class nsAtomSubTable;
// Construction is done by |friend|s.
@@ -124,17 +124,17 @@ FromStringBuffer(const nsAString& aStrin
nsAtom::nsAtom(AtomKind aKind, const nsAString& aString, uint32_t aHash)
: mLength(aString.Length())
, mKind(static_cast<uint32_t>(aKind))
, mHash(aHash)
, mString(FromStringBuffer(aString))
{
MOZ_ASSERT(aKind == AtomKind::DynamicAtom || aKind == AtomKind::HTML5Atom);
- MOZ_ASSERT_IF(!IsHTML5Atom(), mHash == HashString(mString, mLength));
+ MOZ_ASSERT_IF(!IsHTML5(), mHash == HashString(mString, mLength));
MOZ_ASSERT(mString[mLength] == char16_t(0), "null terminated");
MOZ_ASSERT(Equals(aString), "correct data");
}
// This constructor is for static atoms.
nsAtom::nsAtom(const char16_t* aString, uint32_t aLength, uint32_t aHash)
: mLength(aLength)
@@ -145,51 +145,51 @@ nsAtom::nsAtom(const char16_t* aString,
MOZ_ASSERT(mHash == HashString(mString, mLength));
MOZ_ASSERT(mString[mLength] == char16_t(0), "null terminated");
MOZ_ASSERT(NS_strlen(mString) == mLength, "correct storage");
}
nsAtom::~nsAtom()
{
- if (!IsStaticAtom()) {
- MOZ_ASSERT(IsDynamicAtom() || IsHTML5Atom());
+ if (!IsStatic()) {
+ MOZ_ASSERT(IsDynamic() || IsHTML5());
GetStringBuffer()->Release();
}
}
void
nsAtom::ToString(nsAString& aString) const
{
// See the comment on |mString|'s declaration.
- if (IsStaticAtom()) {
+ if (IsStatic()) {
// AssignLiteral() lets us assign without copying. This isn't a string
// literal, but it's a static atom and thus has an unbounded lifetime,
// which is what's important.
aString.AssignLiteral(mString, mLength);
} else {
GetStringBuffer()->ToString(mLength, aString);
}
}
void
nsAtom::ToUTF8String(nsACString& aBuf) const
{
- MOZ_ASSERT(!IsHTML5Atom(), "Called ToUTF8String() on an HTML5 atom");
+ MOZ_ASSERT(!IsHTML5(), "Called ToUTF8String() on an HTML5 atom");
CopyUTF16toUTF8(nsDependentString(mString, mLength), aBuf);
}
void
nsAtom::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf, AtomsSizes& aSizes)
const
{
- MOZ_ASSERT(!IsHTML5Atom(),
+ MOZ_ASSERT(!IsHTML5(),
"Called AddSizeOfIncludingThis() on an HTML5 atom");
size_t thisSize = aMallocSizeOf(this);
- if (IsStaticAtom()) {
+ if (IsStatic()) {
// String buffers pointed to by static atoms are in static memory, and so
// are not measured here.
aSizes.mStaticAtomObjects += thisSize;
} else {
aSizes.mDynamicAtomObjects += thisSize;
aSizes.mDynamicUnsharedBuffers +=
GetStringBuffer()->SizeOfIncludingThisIfUnshared(aMallocSizeOf);
}
@@ -355,17 +355,17 @@ AtomTableMatchKey(const PLDHashEntryHdr*
return he->mAtom->Equals(k->mUTF16String, k->mLength);
}
void
nsAtomTable::AtomTableClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
{
auto entry = static_cast<AtomTableEntry*>(aEntry);
nsAtom* atom = entry->mAtom;
- if (atom->IsStaticAtom()) {
+ if (atom->IsStatic()) {
// This case -- when the entry being cleared holds a static atom -- only
// occurs when gAtomTable is destroyed, whereupon all static atoms within it
// must be explicitly deleted.
delete atom;
}
}
static void
@@ -499,23 +499,23 @@ nsAtomSubTable::GCLocked(GCKind aKind)
MOZ_ASSERT(NS_IsMainThread());
mLock.AssertCurrentThreadOwns();
int32_t removedCount = 0; // A non-atomic temporary for cheaper increments.
nsAutoCString nonZeroRefcountAtoms;
uint32_t nonZeroRefcountAtomsCount = 0;
for (auto i = mTable.Iter(); !i.Done(); i.Next()) {
auto entry = static_cast<AtomTableEntry*>(i.Get());
- if (entry->mAtom->IsStaticAtom()) {
+ if (entry->mAtom->IsStatic()) {
continue;
}
nsAtom* atom = entry->mAtom;
- MOZ_ASSERT(!atom->IsHTML5Atom());
- if (atom->IsDynamicAtom() && nsDynamicAtom::As(atom)->mRefCnt == 0) {
+ MOZ_ASSERT(!atom->IsHTML5());
+ if (atom->IsDynamic() && nsDynamicAtom::As(atom)->mRefCnt == 0) {
i.Remove();
delete atom;
++removedCount;
}
#ifdef NS_FREE_PERMANENT_DATA
else if (aKind == GCKind::Shutdown && PR_GetEnv("XPCOM_MEM_BLOAT_LOG")) {
// Only report leaking atoms in leak-checking builds in a run where we
// are checking for leaks, during shutdown. If something is anomalous,
@@ -583,27 +583,27 @@ nsDynamicAtom::Release()
}
return count;
}
MozExternalRefCountType
nsAtom::AddRef()
{
- MOZ_ASSERT(!IsHTML5Atom(), "Attempt to AddRef an HTML5 atom");
+ MOZ_ASSERT(!IsHTML5(), "Attempt to AddRef an HTML5 atom");
- return IsStaticAtom() ? 2 : nsDynamicAtom::As(this)->AddRef();
+ return IsStatic() ? 2 : nsDynamicAtom::As(this)->AddRef();
}
MozExternalRefCountType
nsAtom::Release()
{
- MOZ_ASSERT(!IsHTML5Atom(), "Attempt to Release an HTML5 atom");
+ MOZ_ASSERT(!IsHTML5(), "Attempt to Release an HTML5 atom");
- return IsStaticAtom() ? 1 : nsDynamicAtom::As(this)->Release();
+ return IsStatic() ? 1 : nsDynamicAtom::As(this)->Release();
}
//----------------------------------------------------------------------
// Have the static atoms been inserted into the table?
static bool gStaticAtomsDone = false;
class DefaultAtoms
@@ -692,17 +692,17 @@ nsAtomTable::RegisterStaticAtoms(const n
MutexAutoLock lock(table.mLock);
AtomTableEntry* he = table.Add(key);
nsStaticAtom* atom;
if (he->mAtom) {
// Disallow creating a dynamic atom, and then later, while the dynamic
// atom is still alive, registering that same atom as a static atom. It
// causes subtle bugs, and we're programming in C++ here, not Smalltalk.
- if (!he->mAtom->IsStaticAtom()) {
+ if (!he->mAtom->IsStatic()) {
nsAutoCString name;
he->mAtom->ToUTF8String(name);
MOZ_CRASH_UNSAFE_PRINTF(
"Static atom registration for %s should be pushed back", name.get());
}
atom = static_cast<nsStaticAtom*>(he->mAtom);
} else {
atom = new nsStaticAtom(string, stringLen, hash);
@@ -861,17 +861,17 @@ NS_GetStaticAtom(const nsAString& aUTF16
nsStaticAtom*
nsAtomTable::GetStaticAtom(const nsAString& aUTF16String)
{
uint32_t hash;
AtomTableKey key(aUTF16String.Data(), aUTF16String.Length(), &hash);
nsAtomSubTable& table = SelectSubTable(key);
MutexAutoLock lock(table.mLock);
AtomTableEntry* he = table.Search(key);
- return he && he->mAtom->IsStaticAtom()
+ return he && he->mAtom->IsStatic()
? static_cast<nsStaticAtom*>(he->mAtom)
: nullptr;
}
void
NS_SetStaticAtomsDone()
{
MOZ_ASSERT(NS_IsMainThread());