nsXBLDocumentInfo.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsXBLDocumentInfo_h__
  6. #define nsXBLDocumentInfo_h__
  7. #include "mozilla/Attributes.h"
  8. #include "nsCOMPtr.h"
  9. #include "nsAutoPtr.h"
  10. #include "nsWeakReference.h"
  11. #include "nsIDocument.h"
  12. #include "nsCycleCollectionParticipant.h"
  13. class nsXBLPrototypeBinding;
  14. class nsXBLDocumentInfo final : public nsSupportsWeakReference
  15. {
  16. public:
  17. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  18. explicit nsXBLDocumentInfo(nsIDocument* aDocument);
  19. already_AddRefed<nsIDocument> GetDocument()
  20. { nsCOMPtr<nsIDocument> copy = mDocument; return copy.forget(); }
  21. bool GetScriptAccess() const { return mScriptAccess; }
  22. nsIURI* DocumentURI() { return mDocument->GetDocumentURI(); }
  23. nsXBLPrototypeBinding* GetPrototypeBinding(const nsACString& aRef);
  24. nsresult SetPrototypeBinding(const nsACString& aRef,
  25. nsXBLPrototypeBinding* aBinding);
  26. // This removes the binding without deleting it
  27. void RemovePrototypeBinding(const nsACString& aRef);
  28. nsresult WritePrototypeBindings();
  29. void SetFirstPrototypeBinding(nsXBLPrototypeBinding* aBinding);
  30. void FlushSkinStylesheets();
  31. bool IsChrome() { return mIsChrome; }
  32. void MarkInCCGeneration(uint32_t aGeneration);
  33. static nsresult ReadPrototypeBindings(nsIURI* aURI, nsXBLDocumentInfo** aDocInfo);
  34. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsXBLDocumentInfo)
  35. private:
  36. virtual ~nsXBLDocumentInfo();
  37. nsCOMPtr<nsIDocument> mDocument;
  38. bool mScriptAccess;
  39. bool mIsChrome;
  40. // the binding table owns each nsXBLPrototypeBinding
  41. nsAutoPtr<nsClassHashtable<nsCStringHashKey, nsXBLPrototypeBinding>> mBindingTable;
  42. // non-owning pointer to the first binding in the table
  43. nsXBLPrototypeBinding* mFirstBinding;
  44. };
  45. #ifdef DEBUG
  46. void AssertInCompilationScope();
  47. #else
  48. inline void AssertInCompilationScope() {}
  49. #endif
  50. #endif