StyleSheetInfo.h (2602B)
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_StyleSheetInfo_h 8 #define mozilla_StyleSheetInfo_h 9 10 #include "mozilla/CORSMode.h" 11 #include "mozilla/css/SheetParsingMode.h" 12 #include "mozilla/dom/SRIMetadata.h" 13 #include "nsIReferrerInfo.h" 14 15 class nsIPrincipal; 16 class nsIURI; 17 18 namespace mozilla { 19 class StyleSheet; 20 struct StyleStylesheetContents; 21 struct URLExtraData; 22 23 /** 24 * Struct for data common to CSSStyleSheetInner and ServoStyleSheet. 25 */ 26 struct StyleSheetInfo final { 27 using ReferrerPolicy = dom::ReferrerPolicy; 28 29 StyleSheetInfo(CORSMode aCORSMode, const dom::SRIMetadata& aIntegrity, 30 css::SheetParsingMode aParsingMode); 31 32 // FIXME(emilio): aCopy should be const. 33 StyleSheetInfo(StyleSheetInfo& aCopy, StyleSheet* aPrimarySheet); 34 35 ~StyleSheetInfo(); 36 37 StyleSheetInfo* CloneFor(StyleSheet* aPrimarySheet); 38 39 void AddSheet(StyleSheet* aSheet); 40 void RemoveSheet(StyleSheet* aSheet); 41 42 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; 43 44 const CORSMode mCORSMode; 45 dom::SRIMetadata mIntegrity; 46 // https://drafts.csswg.org/cssom/#concept-css-style-sheet-origin-clean-flag 47 bool mOriginClean = true; 48 49 // Pointer to the list of child sheets. This is all fundamentally broken, 50 // because each of the child sheets has a unique parent... We can only hope 51 // (and currently this is the case) that any time page JS can get its hands on 52 // a child sheet that means we've already ensured unique infos throughout its 53 // parent chain and things are good. 54 nsTArray<RefPtr<StyleSheet>> mChildren; 55 56 // If a SourceMap or X-SourceMap response header is seen, this is 57 // the value. If both are seen, SourceMap is preferred. If neither 58 // is seen, this will be an empty string. 59 nsCString mSourceMapURL; 60 61 RefPtr<const StyleStylesheetContents> mContents; 62 63 // HACK: This must be the after any member rust accesses in order to not cause 64 // issues on i686-android. Bindgen generates an opaque blob of [u64; N] for 65 // types it doesn't understand like AutoTArray, but turns out u64 is not 66 // 8-byte aligned on this arch (wtf), which would cause other members rust 67 // cares about to be misaligned. 68 AutoTArray<StyleSheet*, 8> mSheets; 69 70 #ifdef DEBUG 71 bool mPrincipalSet = false; 72 #endif 73 }; 74 75 } // namespace mozilla 76 77 #endif // mozilla_StyleSheetInfo_h