@@ -21,9 +21,7 @@ class nsDynamicAtom;
2121// This class encompasses both static and dynamic atoms.
2222//
2323// - In places where static and dynamic atoms can be used, use RefPtr<nsAtom>.
24- // This is by far the most common case. (The exception to this is the HTML5
25- // parser, which does its own weird thing, and uses non-refcounted dynamic
26- // atoms.)
24+ // This is by far the most common case.
2725//
2826// - In places where only static atoms can appear, use nsStaticAtom* to avoid
2927// unnecessary refcounting. This is a moderately common case.
@@ -75,6 +73,13 @@ class nsAtom
7573 //
7674 uint32_t hash () const { return mHash ; }
7775
76+ // This function returns true if ToLowercaseASCII would return the string
77+ // unchanged.
78+ bool IsAsciiLowercase () const
79+ {
80+ return mIsAsciiLowercase ;
81+ }
82+
7883 // We can't use NS_INLINE_DECL_THREADSAFE_REFCOUNTING because the refcounting
7984 // of this type is special.
8085 MozExternalRefCountType AddRef ();
@@ -84,25 +89,29 @@ class nsAtom
8489
8590protected:
8691 // Used by nsStaticAtom.
87- constexpr nsAtom (uint32_t aLength, uint32_t aHash)
92+ constexpr nsAtom (uint32_t aLength, uint32_t aHash, bool aIsAsciiLowercase )
8893 : mLength(aLength)
8994 , mIsStatic(true )
95+ , mIsAsciiLowercase(aIsAsciiLowercase)
9096 , mHash(aHash)
9197 {}
9298
9399 // Used by nsDynamicAtom.
94- nsAtom (const nsAString& aString, uint32_t aHash)
100+ nsAtom (const nsAString& aString,
101+ uint32_t aHash,
102+ bool aIsAsciiLowercase)
95103 : mLength (aString.Length())
96104 , mIsStatic (false )
105+ , mIsAsciiLowercase (aIsAsciiLowercase)
97106 , mHash (aHash)
98107 {
99108 }
100109
101110 ~nsAtom () = default ;
102111
103112 const uint32_t mLength :30 ;
104- // NOTE: There's one free bit here.
105113 const uint32_t mIsStatic :1 ;
114+ const uint32_t mIsAsciiLowercase :1 ;
106115 const uint32_t mHash ;
107116};
108117
@@ -123,8 +132,8 @@ class nsStaticAtom : public nsAtom
123132 // Atom.py and assert in nsAtomTable::RegisterStaticAtoms that the two
124133 // hashes match.
125134 constexpr nsStaticAtom (uint32_t aLength, uint32_t aHash,
126- uint32_t aStringOffset)
127- : nsAtom(aLength, aHash)
135+ uint32_t aStringOffset, bool aIsAsciiLowercase )
136+ : nsAtom(aLength, aHash, aIsAsciiLowercase )
128137 , mStringOffset(aStringOffset)
129138 {}
130139
@@ -167,14 +176,10 @@ class nsDynamicAtom : public nsAtom
167176
168177 // These shouldn't be used directly, even by friend classes. The
169178 // Create()/Destroy() methods use them.
170- static nsDynamicAtom* CreateInner (const nsAString& aString, uint32_t aHash);
171- nsDynamicAtom (const nsAString& aString, uint32_t aHash);
179+ nsDynamicAtom (const nsAString& aString, uint32_t aHash, bool aIsAsciiLowercase);
172180 ~nsDynamicAtom () {}
173181
174- // Creation/destruction is done by friend classes. The first Create() is for
175- // dynamic normal atoms, the second is for dynamic HTML5 atoms.
176182 static nsDynamicAtom* Create (const nsAString& aString, uint32_t aHash);
177- static nsDynamicAtom* Create (const nsAString& aString);
178183 static void Destroy (nsDynamicAtom* aAtom);
179184
180185 mozilla::ThreadSafeAutoRefCnt mRefCnt ;
0 commit comments