From 8ac9830be02f8b224ed2418e4edf68df1df6017b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 7 Mar 2018 15:17:34 +1100 Subject: [PATCH] Bug 1444031 - Rename Is{Static,Dynamic,HTML5}Atom. r=froydnj By removing the "Atom" suffix, which is redundant. MozReview-Commit-ID: 4MCX9Icfjrw --HG-- extra : rebase_source : c3c759a508a8938b59d36dbb20448d2964b98c91 --- dom/base/nsPlainTextSerializer.cpp | 2 +- dom/bindings/DOMString.h | 2 +- parser/html/nsHtml5AtomTable.h | 2 +- parser/html/nsHtml5AttributeEntry.h | 2 +- parser/html/nsHtml5Portability.cpp | 2 +- parser/html/nsHtml5TreeOperation.h | 2 +- xpcom/ds/nsAtom.h | 10 ++++---- xpcom/ds/nsAtomTable.cpp | 36 ++++++++++++++--------------- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dom/base/nsPlainTextSerializer.cpp b/dom/base/nsPlainTextSerializer.cpp index b76731c6505b..2c1de3a157fa 100644 --- a/dom/base/nsPlainTextSerializer.cpp +++ b/dom/base/nsPlainTextSerializer.cpp @@ -1839,7 +1839,7 @@ nsPlainTextSerializer::GetIdForContent(nsIContent* aContent) } nsAtom* localName = aContent->NodeInfo()->NameAtom(); - return localName->IsStaticAtom() ? localName : nullptr; + return localName->IsStatic() ? localName : nullptr; } bool diff --git a/dom/bindings/DOMString.h b/dom/bindings/DOMString.h index 2294843afdac..5fd4fadbbc90 100644 --- a/dom/bindings/DOMString.h +++ b/dom/bindings/DOMString.h @@ -217,7 +217,7 @@ public: 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 { diff --git a/parser/html/nsHtml5AtomTable.h b/parser/html/nsHtml5AtomTable.h index 9940186b886a..4029fc5485dd 100644 --- a/parser/html/nsHtml5AtomTable.h +++ b/parser/html/nsHtml5AtomTable.h @@ -41,7 +41,7 @@ class nsHtml5AtomEntry : public nsStringHashKey * 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 diff --git a/parser/html/nsHtml5AttributeEntry.h b/parser/html/nsHtml5AttributeEntry.h index 7d6f693214a0..8caab72b5112 100644 --- a/parser/html/nsHtml5AttributeEntry.h +++ b/parser/html/nsHtml5AttributeEntry.h @@ -68,7 +68,7 @@ public: // 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); diff --git a/parser/html/nsHtml5Portability.cpp b/parser/html/nsHtml5Portability.cpp index b4161bfbe1bf..09db5850ed7e 100644 --- a/parser/html/nsHtml5Portability.cpp +++ b/parser/html/nsHtml5Portability.cpp @@ -87,7 +87,7 @@ 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); diff --git a/parser/html/nsHtml5TreeOperation.h b/parser/html/nsHtml5TreeOperation.h index 0e44e57276be..25367c2ff650 100644 --- a/parser/html/nsHtml5TreeOperation.h +++ b/parser/html/nsHtml5TreeOperation.h @@ -112,7 +112,7 @@ class nsHtml5TreeOperation final { */ static inline already_AddRefed Reget(nsAtom* aAtom) { - if (!aAtom || aAtom->IsStaticAtom()) { + if (!aAtom || aAtom->IsStatic()) { return dont_AddRef(aAtom); } nsAutoString str; diff --git a/xpcom/ds/nsAtom.h b/xpcom/ds/nsAtom.h index d450b89d5a61..df5364829cfb 100644 --- a/xpcom/ds/nsAtom.h +++ b/xpcom/ds/nsAtom.h @@ -40,9 +40,9 @@ public: AtomKind Kind() const { return static_cast(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; } @@ -56,7 +56,7 @@ public: nsStringBuffer* GetStringBuffer() const { // See the comment on |mString|'s declaration. - MOZ_ASSERT(IsDynamicAtom() || IsHTML5Atom()); + MOZ_ASSERT(IsDynamic() || IsHTML5()); return nsStringBuffer::FromData(const_cast(mString)); } @@ -67,7 +67,7 @@ public: // uint32_t hash() const { - MOZ_ASSERT(!IsHTML5Atom()); + MOZ_ASSERT(!IsHTML5()); return mHash; } diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index a174ea9c4720..5f4b3b9f8830 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -75,7 +75,7 @@ public: static nsDynamicAtom* As(nsAtom* aAtom) { - MOZ_ASSERT(aAtom->IsDynamicAtom()); + MOZ_ASSERT(aAtom->IsDynamic()); return static_cast(aAtom); } @@ -129,7 +129,7 @@ nsAtom::nsAtom(AtomKind aKind, const nsAString& aString, uint32_t aHash) { 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"); @@ -150,8 +150,8 @@ nsAtom::nsAtom(const char16_t* aString, uint32_t aLength, uint32_t aHash) nsAtom::~nsAtom() { - if (!IsStaticAtom()) { - MOZ_ASSERT(IsDynamicAtom() || IsHTML5Atom()); + if (!IsStatic()) { + MOZ_ASSERT(IsDynamic() || IsHTML5()); GetStringBuffer()->Release(); } } @@ -160,7 +160,7 @@ 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. @@ -173,7 +173,7 @@ nsAtom::ToString(nsAString& aString) const 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); } @@ -181,10 +181,10 @@ 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; @@ -360,7 +360,7 @@ nsAtomTable::AtomTableClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry) { auto entry = static_cast(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. @@ -504,13 +504,13 @@ nsAtomSubTable::GCLocked(GCKind aKind) uint32_t nonZeroRefcountAtomsCount = 0; for (auto i = mTable.Iter(); !i.Done(); i.Next()) { auto entry = static_cast(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; @@ -588,17 +588,17 @@ nsDynamicAtom::Release() 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(); } //---------------------------------------------------------------------- @@ -697,7 +697,7 @@ nsAtomTable::RegisterStaticAtoms(const nsStaticAtomSetup* aSetup, // 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( @@ -866,7 +866,7 @@ nsAtomTable::GetStaticAtom(const nsAString& aUTF16String) 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(he->mAtom) : nullptr; }