nsXBLResourceLoader.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 nsXBLResourceLoader_h
  6. #define nsXBLResourceLoader_h
  7. #include "mozilla/Attributes.h"
  8. #include "nsCOMPtr.h"
  9. #include "nsICSSLoaderObserver.h"
  10. #include "nsCOMArray.h"
  11. #include "nsCycleCollectionParticipant.h"
  12. class nsIContent;
  13. class nsIAtom;
  14. class nsXBLPrototypeResources;
  15. class nsXBLPrototypeBinding;
  16. struct nsXBLResource;
  17. class nsIObjectOutputStream;
  18. // *********************************************************************/
  19. // The XBLResourceLoader class
  20. class nsXBLResourceLoader : public nsICSSLoaderObserver
  21. {
  22. public:
  23. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  24. NS_DECL_CYCLE_COLLECTION_CLASS(nsXBLResourceLoader)
  25. // nsICSSLoaderObserver
  26. NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheet* aSheet,
  27. bool aWasAlternate,
  28. nsresult aStatus) override;
  29. void LoadResources(bool* aResult);
  30. void AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
  31. void AddResourceListener(nsIContent* aElement);
  32. nsXBLResourceLoader(nsXBLPrototypeBinding* aBinding,
  33. nsXBLPrototypeResources* aResources);
  34. void NotifyBoundElements();
  35. nsresult Write(nsIObjectOutputStream* aStream);
  36. // MEMBER VARIABLES
  37. nsXBLPrototypeBinding* mBinding; // A pointer back to our binding.
  38. nsXBLPrototypeResources* mResources; // A pointer back to our resources
  39. // information. May be null if the
  40. // resources have already been
  41. // destroyed.
  42. nsXBLResource* mResourceList; // The list of resources we need to load.
  43. nsXBLResource* mLastResource;
  44. bool mLoadingResources;
  45. // We need mInLoadResourcesFunc because we do a mixture of sync and
  46. // async loads.
  47. bool mInLoadResourcesFunc;
  48. int16_t mPendingSheets; // The number of stylesheets that have yet to load.
  49. // Bound elements that are waiting on the stylesheets and scripts.
  50. nsCOMArray<nsIContent> mBoundElements;
  51. protected:
  52. virtual ~nsXBLResourceLoader();
  53. };
  54. #endif