Line data Source code
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 nsXBLResourceLoader_h
8 : #define nsXBLResourceLoader_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsCOMPtr.h"
12 : #include "nsICSSLoaderObserver.h"
13 : #include "nsCOMArray.h"
14 : #include "nsCycleCollectionParticipant.h"
15 :
16 : class nsIContent;
17 : class nsIAtom;
18 : class nsXBLPrototypeResources;
19 : class nsXBLPrototypeBinding;
20 : struct nsXBLResource;
21 : class nsIObjectOutputStream;
22 : class nsIDocument;
23 :
24 : // *********************************************************************/
25 : // The XBLResourceLoader class
26 :
27 : class nsXBLResourceLoader : public nsICSSLoaderObserver
28 : {
29 : public:
30 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 60 : NS_DECL_CYCLE_COLLECTION_CLASS(nsXBLResourceLoader)
32 :
33 : // nsICSSLoaderObserver
34 : NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheet* aSheet,
35 : bool aWasAlternate,
36 : nsresult aStatus) override;
37 :
38 : bool LoadResources(nsIContent* aBoundElement);
39 : void AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
40 : void AddResourceListener(nsIContent* aElement);
41 :
42 : nsXBLResourceLoader(nsXBLPrototypeBinding* aBinding,
43 : nsXBLPrototypeResources* aResources);
44 :
45 : void NotifyBoundElements();
46 :
47 : nsresult Write(nsIObjectOutputStream* aStream);
48 :
49 : // MEMBER VARIABLES
50 : nsXBLPrototypeBinding* mBinding; // A pointer back to our binding.
51 : nsXBLPrototypeResources* mResources; // A pointer back to our resources
52 : // information. May be null if the
53 : // resources have already been
54 : // destroyed.
55 :
56 : nsXBLResource* mResourceList; // The list of resources we need to load.
57 : nsXBLResource* mLastResource;
58 :
59 : bool mLoadingResources;
60 : // We need mInLoadResourcesFunc because we do a mixture of sync and
61 : // async loads.
62 : bool mInLoadResourcesFunc;
63 : int16_t mPendingSheets; // The number of stylesheets that have yet to load.
64 :
65 : // Bound elements that are waiting on the stylesheets and scripts.
66 : nsCOMArray<nsIContent> mBoundElements;
67 :
68 : protected:
69 : virtual ~nsXBLResourceLoader();
70 :
71 : private:
72 : // The bound document is needed in StyleSheetLoaded() for servo style
73 : // backend, which will be set in LoadResources().
74 : nsIDocument* MOZ_NON_OWNING_REF mBoundDocument;
75 : };
76 :
77 : #endif
|