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 nsXBLPrototypeResources_h__
8 : #define nsXBLPrototypeResources_h__
9 :
10 : #include "mozilla/StyleSheet.h"
11 : #include "nsICSSLoaderObserver.h"
12 :
13 : class nsCSSRuleProcessor;
14 : class nsIAtom;
15 : class nsIContent;
16 : class nsXBLPrototypeBinding;
17 : class nsXBLResourceLoader;
18 :
19 : namespace mozilla {
20 : class CSSStyleSheet;
21 : class ServoStyleSet;
22 : } // namespace mozilla
23 :
24 : // *********************************************************************/
25 : // The XBLPrototypeResources class
26 :
27 : class nsXBLPrototypeResources
28 : {
29 : public:
30 : explicit nsXBLPrototypeResources(nsXBLPrototypeBinding* aBinding);
31 : ~nsXBLPrototypeResources();
32 :
33 : bool LoadResources(nsIContent* aBoundElement);
34 : void AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
35 : void AddResourceListener(nsIContent* aElement);
36 : nsresult FlushSkinSheets();
37 :
38 : nsresult Write(nsIObjectOutputStream* aStream);
39 :
40 : void Traverse(nsCycleCollectionTraversalCallback &cb);
41 : void Unlink();
42 :
43 : void ClearLoader();
44 :
45 : void AppendStyleSheet(mozilla::StyleSheet* aSheet);
46 : void RemoveStyleSheet(mozilla::StyleSheet* aSheet);
47 : void InsertStyleSheetAt(size_t aIndex, mozilla::StyleSheet* aSheet);
48 : mozilla::StyleSheet* StyleSheetAt(size_t aIndex) const;
49 : size_t SheetCount() const;
50 : bool HasStyleSheets() const;
51 : void AppendStyleSheetsTo(nsTArray<mozilla::StyleSheet*>& aResult) const;
52 :
53 : /**
54 : * Recreates mRuleProcessor to represent the current list of style sheets
55 : * stored in mStyleSheetList. (Named GatherRuleProcessor to parallel
56 : * nsStyleSet::GatherRuleProcessors.)
57 : */
58 : void GatherRuleProcessor();
59 :
60 4032 : nsCSSRuleProcessor* GetRuleProcessor() const { return mRuleProcessor; }
61 :
62 : // Updates the ServoStyleSet object that holds the result of cascading the
63 : // sheets in mStyleSheetList. Equivalent to GatherRuleProcessor(), but for
64 : // the Servo style backend.
65 : void ComputeServoStyleSet(nsPresContext* aPresContext);
66 :
67 0 : const mozilla::ServoStyleSet* GetServoStyleSet() const { return mServoStyleSet.get(); }
68 :
69 : private:
70 : // A loader object. Exists only long enough to load resources, and then it dies.
71 : RefPtr<nsXBLResourceLoader> mLoader;
72 :
73 : // A list of loaded stylesheets for this binding.
74 : nsTArray<RefPtr<mozilla::StyleSheet>> mStyleSheetList;
75 :
76 : // The list of stylesheets converted to a rule processor.
77 : RefPtr<nsCSSRuleProcessor> mRuleProcessor;
78 :
79 : // The result of cascading the XBL style sheets like mRuleProcessor, but
80 : // for the Servo style backend.
81 : // XXX: We might want to design a better representation for the result of
82 : // cascading the XBL style sheets, like a collection of SelectorMaps.
83 : mozilla::UniquePtr<mozilla::ServoStyleSet> mServoStyleSet;
84 : };
85 :
86 : #endif
|