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/. */
7 #ifndef mozilla_StyleSheetInfo_h
8 #define mozilla_StyleSheetInfo_h
10 #include "mozilla/css/SheetParsingMode.h"
11 #include "mozilla/dom/SRIMetadata.h"
12 #include "mozilla/CORSMode.h"
14 #include "nsIReferrerInfo.h"
21 struct StyleUseCounters
;
22 struct StyleStylesheetContents
;
26 * Struct for data common to CSSStyleSheetInner and ServoStyleSheet.
28 struct StyleSheetInfo final
{
29 using ReferrerPolicy
= dom::ReferrerPolicy
;
31 StyleSheetInfo(CORSMode aCORSMode
, const dom::SRIMetadata
& aIntegrity
,
32 css::SheetParsingMode aParsingMode
);
34 // FIXME(emilio): aCopy should be const.
35 StyleSheetInfo(StyleSheetInfo
& aCopy
, StyleSheet
* aPrimarySheet
);
39 StyleSheetInfo
* CloneFor(StyleSheet
* aPrimarySheet
);
41 void AddSheet(StyleSheet
* aSheet
);
42 void RemoveSheet(StyleSheet
* aSheet
);
44 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const;
46 // FIXME(emilio): most of this struct should be const, then we can remove the
47 // duplication with the UrlExtraData member and such.
48 nsCOMPtr
<nsIURI
> mSheetURI
; // for error reports, etc.
49 nsCOMPtr
<nsIURI
> mOriginalSheetURI
; // for GetHref. Can be null.
50 nsCOMPtr
<nsIURI
> mBaseURI
; // for resolving relative URIs
51 nsCOMPtr
<nsIPrincipal
> mPrincipal
;
52 const CORSMode mCORSMode
;
53 // The ReferrerInfo of a stylesheet is used for its child sheets and loads
54 // come from this stylesheet, so it is stored here.
55 nsCOMPtr
<nsIReferrerInfo
> mReferrerInfo
;
56 dom::SRIMetadata mIntegrity
;
58 // Pointer to the list of child sheets. This is all fundamentally broken,
59 // because each of the child sheets has a unique parent... We can only hope
60 // (and currently this is the case) that any time page JS can get its hands on
61 // a child sheet that means we've already ensured unique infos throughout its
62 // parent chain and things are good.
63 nsTArray
<RefPtr
<StyleSheet
>> mChildren
;
65 AutoTArray
<StyleSheet
*, 8> mSheets
;
67 // If a SourceMap or X-SourceMap response header is seen, this is
68 // the value. If both are seen, SourceMap is preferred. If neither
69 // is seen, this will be an empty string.
70 nsCString mSourceMapURL
;
72 RefPtr
<const StyleStylesheetContents
> mContents
;
74 UniquePtr
<StyleUseCounters
> mUseCounters
;
76 // XXX We already have mSheetURI, mBaseURI, and mPrincipal.
78 // Can we somehow replace them with URLExtraData directly? The issue
79 // is currently URLExtraData is immutable, but URIs in StyleSheetInfo
80 // seems to be mutable, so we probably cannot set them altogether.
81 // Also, this is mostly a duplicate reference of the same url data
82 // inside RawServoStyleSheet. We may want to just use that instead.
83 RefPtr
<URLExtraData
> mURLData
;
86 bool mPrincipalSet
= false;
90 } // namespace mozilla
92 #endif // mozilla_StyleSheetInfo_h