AnonymousContent.h (1383B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_AnonymousContent_h 8 #define mozilla_dom_AnonymousContent_h 9 10 #include "mozilla/AlreadyAddRefed.h" 11 #include "nsCycleCollectionParticipant.h" 12 #include "nsISupportsImpl.h" 13 14 namespace mozilla::dom { 15 16 class Element; 17 class Document; 18 class ShadowRoot; 19 20 class AnonymousContent final { 21 public: 22 // Ref counting and cycle collection 23 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnonymousContent) 24 NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AnonymousContent) 25 26 static already_AddRefed<AnonymousContent> Create(Document&); 27 28 Element* Host() const { return mHost.get(); } 29 ShadowRoot* Root() const { return mRoot.get(); } 30 31 bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, 32 JS::MutableHandle<JSObject*> aReflector); 33 34 private: 35 ~AnonymousContent(); 36 37 explicit AnonymousContent(already_AddRefed<Element> aHost, 38 already_AddRefed<ShadowRoot> aRoot); 39 RefPtr<Element> mHost; 40 RefPtr<ShadowRoot> mRoot; 41 }; 42 43 } // namespace mozilla::dom 44 45 #endif // mozilla_dom_AnonymousContent_h