/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_StyleSheet_h #define mozilla_StyleSheet_h #include "mozilla/css/SheetParsingMode.h" #include "mozilla/dom/CSSStyleSheetBinding.h" #include "mozilla/net/ReferrerPolicy.h" #include "mozilla/CORSMode.h" #include "mozilla/ServoUtils.h" #include "nsICSSLoaderObserver.h" #include "nsWrapperCache.h" #include "StyleSheetInfo.h" class nsIDocument; class nsINode; class nsIPrincipal; class nsCSSRuleProcessor; namespace mozilla { class CSSStyleSheet; class ServoStyleSet; class ServoStyleSheet; struct StyleSheetInfo; struct CSSStyleSheetInner; namespace dom { class CSSImportRule; class CSSRuleList; class MediaList; class ShadowRoot; class SRIMetadata; } // namespace dom namespace css { class GroupRule; class Rule; } /** * Superclass for data common to CSSStyleSheet and ServoStyleSheet. */ class StyleSheet : public nsICSSLoaderObserver , public nsWrapperCache { protected: explicit StyleSheet(css::SheetParsingMode aParsingMode); StyleSheet(const StyleSheet& aCopy, StyleSheet* aParentToUse, dom::CSSImportRule* aOwnerRuleToUse, nsIDocument* aDocumentToUse, nsINode* aOwningNodeToUse); virtual ~StyleSheet(); public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheet) /** * The different changes that a stylesheet may go through. * * Used by the StyleSets in order to handle more efficiently some kinds of * changes. */ enum class ChangeType { Added, Removed, ApplicableStateChanged, RuleAdded, RuleRemoved, RuleChanged, }; void SetOwningNode(nsINode* aOwningNode) { mOwningNode = aOwningNode; } css::SheetParsingMode ParsingMode() const { return mParsingMode; } mozilla::dom::CSSStyleSheetParsingMode ParsingModeDOM(); /** * Whether the sheet is complete. */ bool IsComplete() const; void SetComplete(); /** * Set the stylesheet to be enabled. This may or may not make it * applicable. Note that this WILL inform the sheet's document of * its new applicable state if the state changes but WILL NOT call * BeginUpdate() or EndUpdate() on the document -- calling those is * the caller's responsibility. This allows use of SetEnabled when * batched updates are desired. If you want updates handled for * you, see SetDisabled(). */ void SetEnabled(bool aEnabled); MOZ_DECL_STYLO_METHODS(CSSStyleSheet, ServoStyleSheet) // Whether the sheet is for an inline