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 mozilla_StyleSheetInlines_h
8 : #define mozilla_StyleSheetInlines_h
9 :
10 : #include "mozilla/StyleSheetInfo.h"
11 : #include "mozilla/ServoStyleSheet.h"
12 : #include "mozilla/CSSStyleSheet.h"
13 : #include "nsINode.h"
14 :
15 : namespace mozilla {
16 :
17 566 : MOZ_DEFINE_STYLO_METHODS(StyleSheet, CSSStyleSheet, ServoStyleSheet)
18 :
19 : StyleSheetInfo&
20 239 : StyleSheet::SheetInfo()
21 : {
22 239 : return *mInner;
23 : }
24 :
25 : const StyleSheetInfo&
26 1051 : StyleSheet::SheetInfo() const
27 : {
28 1051 : return *mInner;
29 : }
30 :
31 : bool
32 0 : StyleSheet::IsInline() const
33 : {
34 0 : return !SheetInfo().mOriginalSheetURI;
35 : }
36 :
37 : nsIURI*
38 157 : StyleSheet::GetSheetURI() const
39 : {
40 157 : return SheetInfo().mSheetURI;
41 : }
42 :
43 : nsIURI*
44 0 : StyleSheet::GetOriginalURI() const
45 : {
46 0 : return SheetInfo().mOriginalSheetURI;
47 : }
48 :
49 : nsIURI*
50 58 : StyleSheet::GetBaseURI() const
51 : {
52 58 : return SheetInfo().mBaseURI;
53 : }
54 :
55 : void
56 113 : StyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI,
57 : nsIURI* aBaseURI)
58 : {
59 113 : NS_PRECONDITION(aSheetURI && aBaseURI, "null ptr");
60 113 : StyleSheetInfo& info = SheetInfo();
61 113 : MOZ_ASSERT(!HasRules() && !info.mComplete,
62 : "Can't call SetURIs on sheets that are complete or have rules");
63 113 : info.mSheetURI = aSheetURI;
64 113 : info.mOriginalSheetURI = aOriginalSheetURI;
65 113 : info.mBaseURI = aBaseURI;
66 113 : }
67 :
68 : bool
69 357 : StyleSheet::IsApplicable() const
70 : {
71 357 : return !mDisabled && SheetInfo().mComplete;
72 : }
73 :
74 : bool
75 161 : StyleSheet::HasRules() const
76 : {
77 161 : MOZ_STYLO_FORWARD(HasRules, ())
78 : }
79 :
80 : StyleSheet*
81 0 : StyleSheet::GetParentStyleSheet() const
82 : {
83 0 : return GetParentSheet();
84 : }
85 :
86 : dom::ParentObject
87 0 : StyleSheet::GetParentObject() const
88 : {
89 0 : if (mOwningNode) {
90 0 : return dom::ParentObject(mOwningNode);
91 : }
92 0 : return dom::ParentObject(static_cast<nsIDOMCSSStyleSheet*>(mParent), mParent);
93 : }
94 :
95 : nsIPrincipal*
96 121 : StyleSheet::Principal() const
97 : {
98 121 : return SheetInfo().mPrincipal;
99 : }
100 :
101 : void
102 58 : StyleSheet::SetPrincipal(nsIPrincipal* aPrincipal)
103 : {
104 58 : StyleSheetInfo& info = SheetInfo();
105 58 : NS_PRECONDITION(!info.mPrincipalSet, "Should only set principal once");
106 58 : if (aPrincipal) {
107 58 : info.mPrincipal = aPrincipal;
108 : #ifdef DEBUG
109 58 : info.mPrincipalSet = true;
110 : #endif
111 : }
112 58 : }
113 :
114 : CORSMode
115 40 : StyleSheet::GetCORSMode() const
116 : {
117 40 : return SheetInfo().mCORSMode;
118 : }
119 :
120 : net::ReferrerPolicy
121 35 : StyleSheet::GetReferrerPolicy() const
122 : {
123 35 : return SheetInfo().mReferrerPolicy;
124 : }
125 :
126 : void
127 106 : StyleSheet::GetIntegrity(dom::SRIMetadata& aResult) const
128 : {
129 106 : aResult = SheetInfo().mIntegrity;
130 106 : }
131 :
132 : }
133 :
134 : #endif // mozilla_StyleSheetInlines_h
|