Bug 1435944 part 1 - Add ToAddRefed() for nsStaticAtom. r?froydnj draft
authorXidorn Quan <me@upsuper.org>
Thu, 08 Feb 2018 13:50:42 +1100
changeset 752372 5f6d9cf4ee9b7734e72e622a27d9c8f9ecb68a5a
parent 752371 16de7c50eb2c3b693f731ab41b69c5019f26a354
child 752373 77b12d27acd84eaf8c56e508ba071b8613a1eaaf
push id98244
push userxquan@mozilla.com
push dateThu, 08 Feb 2018 02:51:45 +0000
reviewersfroydnj
bugs1435944
milestone60.0a1
Bug 1435944 part 1 - Add ToAddRefed() for nsStaticAtom. r?froydnj MozReview-Commit-ID: 80HginrqhOi
xpcom/ds/nsAtom.h
--- a/xpcom/ds/nsAtom.h
+++ b/xpcom/ds/nsAtom.h
@@ -111,16 +111,20 @@ protected:
 class nsStaticAtom : public nsAtom
 {
 public:
   // These are deleted so it's impossible to RefPtr<nsStaticAtom>. Raw
   // nsStaticAtom atoms should be used instead.
   MozExternalRefCountType AddRef() = delete;
   MozExternalRefCountType Release() = delete;
 
+  already_AddRefed<nsAtom> ToAddRefed() {
+    return already_AddRefed<nsAtom>(static_cast<nsAtom*>(this));
+  }
+
 private:
   friend class nsAtomFriend;
 
   // Construction is done entirely by |friend|s.
   nsStaticAtom(const char16_t* aString, uint32_t aLength, uint32_t aHash)
     : nsAtom(aString, aLength, aHash)
   {}
 };