/* -*- 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/StyleBackendType.h" #include "mozilla/CORSMode.h" #include "mozilla/ServoUtils.h" #include "nsICSSLoaderObserver.h" #include "nsIDOMCSSStyleSheet.h" #include "nsWrapperCache.h" class nsIDocument; class nsINode; class nsIPrincipal; class nsCSSRuleProcessor; namespace mozilla { class CSSStyleSheet; class ServoStyleSheet; class StyleSetHandle; struct StyleSheetInfo; struct CSSStyleSheetInner; namespace dom { class CSSImportRule; class CSSRuleList; class MediaList; class SRIMetadata; } // namespace dom namespace css { class GroupRule; class Rule; } /** * Superclass for data common to CSSStyleSheet and ServoStyleSheet. */ class StyleSheet : public nsIDOMCSSStyleSheet , public nsICSSLoaderObserver , public nsWrapperCache { protected: StyleSheet(StyleBackendType aType, 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_AMBIGUOUS(StyleSheet, nsIDOMCSSStyleSheet) /** * 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 nsIDOMStyleSheet::SetDisabled(). */ void SetEnabled(bool aEnabled); MOZ_DECL_STYLO_METHODS(CSSStyleSheet, ServoStyleSheet) // Whether the sheet is for an inline