2016-02-26 04:51:01 +03:00
|
|
|
/* -*- 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"
|
2016-08-02 23:17:06 +03:00
|
|
|
#include "mozilla/dom/CSSStyleSheetBinding.h"
|
2018-04-30 18:50:03 +03:00
|
|
|
#include "mozilla/dom/SRIMetadata.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/net/ReferrerPolicy.h"
|
|
|
|
#include "mozilla/CORSMode.h"
|
2018-04-30 18:50:03 +03:00
|
|
|
#include "mozilla/MozPromise.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "mozilla/ServoBindingTypes.h"
|
2016-10-13 15:45:03 +03:00
|
|
|
#include "mozilla/ServoUtils.h"
|
2018-04-30 18:50:03 +03:00
|
|
|
#include "mozilla/StyleSheetInfo.h"
|
|
|
|
#include "mozilla/URLExtraData.h"
|
2017-04-03 12:55:06 +03:00
|
|
|
#include "nsICSSLoaderObserver.h"
|
2016-10-14 14:25:38 +03:00
|
|
|
#include "nsWrapperCache.h"
|
2018-04-30 18:50:03 +03:00
|
|
|
#include "nsCompatibility.h"
|
|
|
|
#include "nsStringFwd.h"
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2016-03-01 23:39:29 +03:00
|
|
|
class nsIDocument;
|
2016-02-26 04:51:01 +03:00
|
|
|
class nsINode;
|
2016-10-14 14:25:38 +03:00
|
|
|
class nsIPrincipal;
|
2016-02-26 04:51:01 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
class ServoCSSRuleList;
|
2018-03-29 14:15:46 +03:00
|
|
|
class ServoStyleSet;
|
2018-04-30 18:50:03 +03:00
|
|
|
|
|
|
|
typedef MozPromise</* Dummy */ bool,
|
|
|
|
/* Dummy */ bool,
|
|
|
|
/* IsExclusive = */ true> StyleSheetParsePromise;
|
|
|
|
|
|
|
|
namespace css {
|
|
|
|
class GroupRule;
|
|
|
|
class Loader;
|
|
|
|
class LoaderReusableStyleSheets;
|
|
|
|
class Rule;
|
|
|
|
class SheetLoadData;
|
|
|
|
}
|
2016-09-26 15:03:25 +03:00
|
|
|
|
|
|
|
namespace dom {
|
2017-05-30 04:10:25 +03:00
|
|
|
class CSSImportRule;
|
2016-10-14 14:25:38 +03:00
|
|
|
class CSSRuleList;
|
2016-11-09 09:28:24 +03:00
|
|
|
class MediaList;
|
2018-03-17 00:56:05 +03:00
|
|
|
class ShadowRoot;
|
2016-09-26 15:03:25 +03:00
|
|
|
class SRIMetadata;
|
|
|
|
} // namespace dom
|
2016-03-02 01:38:13 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
class StyleSheet final : public nsICSSLoaderObserver
|
|
|
|
, public nsWrapperCache
|
2016-02-26 04:51:01 +03:00
|
|
|
{
|
|
|
|
StyleSheet(const StyleSheet& aCopy,
|
2017-05-31 14:12:33 +03:00
|
|
|
StyleSheet* aParentToUse,
|
2017-05-30 04:10:25 +03:00
|
|
|
dom::CSSImportRule* aOwnerRuleToUse,
|
2016-03-01 23:39:29 +03:00
|
|
|
nsIDocument* aDocumentToUse,
|
2016-02-26 04:51:01 +03:00
|
|
|
nsINode* aOwningNodeToUse);
|
2018-04-30 18:50:03 +03:00
|
|
|
|
2017-01-06 10:05:24 +03:00
|
|
|
virtual ~StyleSheet();
|
2016-02-26 04:51:01 +03:00
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
public:
|
2018-04-30 18:50:03 +03:00
|
|
|
StyleSheet(css::SheetParsingMode aParsingMode,
|
|
|
|
CORSMode aCORSMode,
|
|
|
|
net::ReferrerPolicy aReferrerPolicy,
|
|
|
|
const dom::SRIMetadata& aIntegrity);
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2018-01-11 11:17:57 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StyleSheet)
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
already_AddRefed<StyleSheet> CreateEmptyChildSheet(
|
|
|
|
already_AddRefed<dom::MediaList> aMediaList) const;
|
|
|
|
|
|
|
|
bool HasRules() const;
|
|
|
|
|
|
|
|
// Parses a stylesheet. The aLoadData argument corresponds to the
|
|
|
|
// SheetLoadData for this stylesheet. It may be null in some cases.
|
|
|
|
RefPtr<StyleSheetParsePromise>
|
|
|
|
ParseSheet(css::Loader* aLoader,
|
|
|
|
const nsACString& aBytes,
|
|
|
|
css::SheetLoadData* aLoadData);
|
|
|
|
|
|
|
|
// Common code that needs to be called after servo finishes parsing. This is
|
|
|
|
// shared between the parallel and sequential paths.
|
|
|
|
void FinishAsyncParse(already_AddRefed<RawServoStyleSheetContents> aSheetContents);
|
|
|
|
|
|
|
|
// Similar to the above, but guarantees that parsing will be performed
|
|
|
|
// synchronously.
|
|
|
|
void
|
|
|
|
ParseSheetSync(css::Loader* aLoader,
|
|
|
|
const nsACString& aBytes,
|
|
|
|
css::SheetLoadData* aLoadData,
|
|
|
|
uint32_t aLineNumber,
|
|
|
|
css::LoaderReusableStyleSheets* aReusableSheets = nullptr);
|
|
|
|
|
|
|
|
nsresult ReparseSheet(const nsAString& aInput);
|
|
|
|
|
|
|
|
const RawServoStyleSheetContents* RawContents() const {
|
|
|
|
return Inner()->mContents;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetContentsForImport(const RawServoStyleSheetContents* aContents) {
|
|
|
|
MOZ_ASSERT(!Inner()->mContents);
|
|
|
|
Inner()->mContents = aContents;
|
|
|
|
}
|
|
|
|
|
|
|
|
URLExtraData* URLData() const { return Inner()->mURLData; }
|
|
|
|
|
|
|
|
// nsICSSLoaderObserver interface
|
|
|
|
NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate,
|
|
|
|
nsresult aStatus) final;
|
|
|
|
|
|
|
|
// Internal GetCssRules methods which do not have security check and
|
|
|
|
// completeness check.
|
|
|
|
ServoCSSRuleList* GetCssRulesInternal();
|
|
|
|
|
|
|
|
// Returns the stylesheet's Servo origin as an OriginFlags value.
|
|
|
|
OriginFlags GetOrigin();
|
|
|
|
|
2017-05-24 05:28:58 +03:00
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
};
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
void SetOwningNode(nsINode* aOwningNode)
|
|
|
|
{
|
|
|
|
mOwningNode = aOwningNode;
|
|
|
|
}
|
|
|
|
|
2017-06-29 20:09:56 +03:00
|
|
|
css::SheetParsingMode ParsingMode() const { return mParsingMode; }
|
2016-08-02 23:17:06 +03:00
|
|
|
mozilla::dom::CSSStyleSheetParsingMode ParsingModeDOM();
|
|
|
|
|
2016-03-02 02:10:45 +03:00
|
|
|
/**
|
|
|
|
* Whether the sheet is complete.
|
|
|
|
*/
|
|
|
|
bool IsComplete() const;
|
|
|
|
void SetComplete();
|
|
|
|
|
2017-01-06 10:05:24 +03:00
|
|
|
/**
|
|
|
|
* 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
|
2018-01-11 11:17:57 +03:00
|
|
|
* you, see SetDisabled().
|
2017-01-06 10:05:24 +03:00
|
|
|
*/
|
|
|
|
void SetEnabled(bool aEnabled);
|
|
|
|
|
2016-09-26 15:03:25 +03:00
|
|
|
// Whether the sheet is for an inline <style> element.
|
|
|
|
inline bool IsInline() const;
|
|
|
|
|
|
|
|
inline nsIURI* GetSheetURI() const;
|
|
|
|
/* Get the URI this sheet was originally loaded from, if any. Can
|
|
|
|
return null */
|
|
|
|
inline nsIURI* GetOriginalURI() const;
|
|
|
|
inline nsIURI* GetBaseURI() const;
|
|
|
|
/**
|
|
|
|
* SetURIs must be called on all sheets before parsing into them.
|
|
|
|
* SetURIs may only be called while the sheet is 1) incomplete and 2)
|
|
|
|
* has no rules in it
|
|
|
|
*/
|
|
|
|
inline void SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI,
|
|
|
|
nsIURI* aBaseURI);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the sheet is applicable. A sheet that is not applicable
|
|
|
|
* should never be inserted into a style set. A sheet may not be
|
|
|
|
* applicable for a variety of reasons including being disabled and
|
|
|
|
* being incomplete.
|
|
|
|
*/
|
|
|
|
inline bool IsApplicable() const;
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
already_AddRefed<StyleSheet> Clone(StyleSheet* aCloneParent,
|
|
|
|
dom::CSSImportRule* aCloneOwnerRule,
|
|
|
|
nsIDocument* aCloneDocument,
|
|
|
|
nsINode* aCloneOwningNode) const;
|
2017-02-16 00:33:17 +03:00
|
|
|
|
2018-02-16 13:34:12 +03:00
|
|
|
bool HasForcedUniqueInner() const
|
|
|
|
{
|
|
|
|
return mDirtyFlags & FORCED_UNIQUE_INNER;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasModifiedRules() const
|
|
|
|
{
|
|
|
|
return mDirtyFlags & MODIFIED_RULES;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearModifiedRules()
|
|
|
|
{
|
|
|
|
mDirtyFlags &= ~MODIFIED_RULES;
|
|
|
|
}
|
2017-02-13 21:27:46 +03:00
|
|
|
|
2017-10-12 10:56:02 +03:00
|
|
|
inline bool HasUniqueInner() const;
|
2017-05-16 02:30:10 +03:00
|
|
|
void EnsureUniqueInner();
|
2018-04-14 19:05:44 +03:00
|
|
|
inline void AssertHasUniqueInner() const;
|
2017-05-16 02:19:17 +03:00
|
|
|
|
2017-05-16 03:11:08 +03:00
|
|
|
// Append all of this sheet's child sheets to aArray.
|
|
|
|
void AppendAllChildSheets(nsTArray<StyleSheet*>& aArray);
|
|
|
|
|
2016-09-26 15:03:25 +03:00
|
|
|
// style sheet owner info
|
2017-06-14 07:26:48 +03:00
|
|
|
enum DocumentAssociationMode : uint8_t {
|
2017-01-20 07:49:44 +03:00
|
|
|
// OwnedByDocument means mDocument owns us (possibly via a chain of other
|
|
|
|
// stylesheets).
|
|
|
|
OwnedByDocument,
|
|
|
|
// NotOwnedByDocument means we're owned by something that might have a
|
|
|
|
// different lifetime than mDocument.
|
|
|
|
NotOwnedByDocument
|
|
|
|
};
|
|
|
|
nsIDocument* GetAssociatedDocument() const { return mDocument; }
|
|
|
|
bool IsOwnedByDocument() const {
|
|
|
|
return mDocumentAssociationMode == OwnedByDocument;
|
|
|
|
}
|
|
|
|
// aDocument must not be null.
|
2017-01-25 00:12:40 +03:00
|
|
|
void SetAssociatedDocument(nsIDocument* aDocument,
|
|
|
|
DocumentAssociationMode aMode);
|
|
|
|
void ClearAssociatedDocument();
|
2016-09-26 15:03:25 +03:00
|
|
|
nsINode* GetOwnerNode() const { return mOwningNode; }
|
2017-01-25 00:09:33 +03:00
|
|
|
inline StyleSheet* GetParentSheet() const { return mParent; }
|
2016-09-26 15:03:25 +03:00
|
|
|
|
2017-05-30 04:10:25 +03:00
|
|
|
void SetOwnerRule(dom::CSSImportRule* aOwnerRule) {
|
|
|
|
mOwnerRule = aOwnerRule; /* Not ref counted */
|
|
|
|
}
|
|
|
|
dom::CSSImportRule* GetOwnerRule() const { return mOwnerRule; }
|
|
|
|
|
2017-05-30 04:10:25 +03:00
|
|
|
void PrependStyleSheet(StyleSheet* aSheet);
|
2016-09-26 15:03:25 +03:00
|
|
|
|
2018-04-30 19:11:41 +03:00
|
|
|
// Prepend a stylesheet to the child list without calling WillDirty.
|
2017-06-29 20:09:56 +03:00
|
|
|
void PrependStyleSheetSilently(StyleSheet* aSheet);
|
|
|
|
|
2017-01-24 02:52:56 +03:00
|
|
|
StyleSheet* GetFirstChild() const;
|
2017-05-30 04:10:25 +03:00
|
|
|
StyleSheet* GetMostRecentlyAddedChildSheet() const {
|
|
|
|
// New child sheet can only be prepended into the linked list of
|
|
|
|
// child sheets, so the most recently added one is always the first.
|
|
|
|
return GetFirstChild();
|
|
|
|
}
|
2017-01-24 02:52:56 +03:00
|
|
|
|
2016-09-26 15:03:25 +03:00
|
|
|
// Principal() never returns a null pointer.
|
|
|
|
inline nsIPrincipal* Principal() const;
|
|
|
|
/**
|
|
|
|
* SetPrincipal should be called on all sheets before parsing into them.
|
|
|
|
* This can only be called once with a non-null principal. Calling this with
|
|
|
|
* a null pointer is allowed and is treated as a no-op.
|
|
|
|
*/
|
|
|
|
inline void SetPrincipal(nsIPrincipal* aPrincipal);
|
|
|
|
|
2017-01-06 10:05:24 +03:00
|
|
|
void SetTitle(const nsAString& aTitle) { mTitle = aTitle; }
|
2016-11-09 09:28:24 +03:00
|
|
|
void SetMedia(dom::MediaList* aMedia);
|
2017-01-06 10:05:24 +03:00
|
|
|
|
2016-09-26 15:03:25 +03:00
|
|
|
// Get this style sheet's CORS mode
|
|
|
|
inline CORSMode GetCORSMode() const;
|
|
|
|
// Get this style sheet's Referrer Policy
|
|
|
|
inline net::ReferrerPolicy GetReferrerPolicy() const;
|
|
|
|
// Get this style sheet's integrity metadata
|
|
|
|
inline void GetIntegrity(dom::SRIMetadata& aResult) const;
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
2016-09-26 15:03:25 +03:00
|
|
|
#ifdef DEBUG
|
2018-04-30 18:50:03 +03:00
|
|
|
void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
|
2016-09-26 15:03:25 +03:00
|
|
|
#endif
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
// WebIDL StyleSheet API
|
2018-01-11 11:17:57 +03:00
|
|
|
void GetType(nsAString& aType);
|
|
|
|
void GetHref(nsAString& aHref, ErrorResult& aRv);
|
2016-10-14 14:25:38 +03:00
|
|
|
// GetOwnerNode is defined above.
|
2016-10-14 14:25:38 +03:00
|
|
|
inline StyleSheet* GetParentStyleSheet() const;
|
2018-01-11 11:17:57 +03:00
|
|
|
void GetTitle(nsAString& aTitle);
|
2016-11-09 09:28:24 +03:00
|
|
|
dom::MediaList* Media();
|
2016-10-14 14:25:38 +03:00
|
|
|
bool Disabled() const { return mDisabled; }
|
2018-01-11 11:17:57 +03:00
|
|
|
void SetDisabled(bool aDisabled);
|
2017-06-29 02:51:46 +03:00
|
|
|
void GetSourceMapURL(nsAString& aTitle);
|
|
|
|
void SetSourceMapURL(const nsAString& aSourceMapURL);
|
2017-08-09 22:33:24 +03:00
|
|
|
void SetSourceMapURLFromComment(const nsAString& aSourceMapURLFromComment);
|
2017-09-14 23:59:32 +03:00
|
|
|
void GetSourceURL(nsAString& aSourceURL);
|
|
|
|
void SetSourceURL(const nsAString& aSourceURL);
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
// WebIDL CSSStyleSheet API
|
2017-05-30 04:10:25 +03:00
|
|
|
// Can't be inline because we can't include ImportRule here. And can't be
|
|
|
|
// called GetOwnerRule because that would be ambiguous with the ImportRule
|
|
|
|
// version.
|
|
|
|
css::Rule* GetDOMOwnerRule() const;
|
2018-04-30 18:50:03 +03:00
|
|
|
dom::CSSRuleList* GetCssRules(nsIPrincipal& aSubjectPrincipal, ErrorResult&);
|
2016-10-14 14:25:38 +03:00
|
|
|
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
void DeleteRule(uint32_t aIndex,
|
|
|
|
nsIPrincipal& aSubjectPrincipal,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
// WebIDL miscellaneous bits
|
|
|
|
inline dom::ParentObject GetParentObject() const;
|
2018-04-30 18:50:03 +03:00
|
|
|
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2018-04-30 19:11:41 +03:00
|
|
|
// Changes to sheets should be after a WillDirty call.
|
2017-05-16 02:19:17 +03:00
|
|
|
void WillDirty();
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2017-11-28 03:50:45 +03:00
|
|
|
// Called when a rule changes from CSSOM.
|
|
|
|
//
|
|
|
|
// FIXME(emilio): This shouldn't allow null, but MediaList doesn't know about
|
|
|
|
// it's owning media rule, plus it's used for the stylesheet media itself.
|
|
|
|
void RuleChanged(css::Rule*);
|
|
|
|
|
2018-03-29 14:15:46 +03:00
|
|
|
void AddStyleSet(ServoStyleSet* aStyleSet);
|
|
|
|
void DropStyleSet(ServoStyleSet* aStyleSet);
|
2017-05-16 02:27:15 +03:00
|
|
|
|
2017-03-08 10:04:15 +03:00
|
|
|
nsresult DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex);
|
|
|
|
nsresult InsertRuleIntoGroup(const nsAString& aRule,
|
|
|
|
css::GroupRule* aGroup, uint32_t aIndex);
|
|
|
|
|
2017-07-11 00:52:00 +03:00
|
|
|
// Find the ID of the owner inner window.
|
|
|
|
uint64_t FindOwningWindowInnerID() const;
|
|
|
|
|
2017-05-30 04:10:25 +03:00
|
|
|
template<typename Func>
|
|
|
|
void EnumerateChildSheets(Func aCallback) {
|
|
|
|
for (StyleSheet* child = GetFirstChild(); child; child = child->mNext) {
|
|
|
|
aCallback(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-26 15:03:25 +03:00
|
|
|
private:
|
2018-03-17 00:56:05 +03:00
|
|
|
dom::ShadowRoot* GetContainingShadow() const;
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
StyleSheetInfo* Inner() { return mInner; }
|
|
|
|
const StyleSheetInfo* Inner() const { return mInner; }
|
|
|
|
|
2016-09-26 15:03:25 +03:00
|
|
|
// Get a handle to the various stylesheet bits which live on the 'inner' for
|
|
|
|
// gecko stylesheets and live on the StyleSheet for Servo stylesheets.
|
|
|
|
inline StyleSheetInfo& SheetInfo();
|
|
|
|
inline const StyleSheetInfo& SheetInfo() const;
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
// Check if the rules are available for read and write.
|
|
|
|
// It does the security check as well as whether the rules have been
|
|
|
|
// completely loaded. aRv will have an exception set if this function
|
|
|
|
// returns false.
|
2018-04-30 18:50:03 +03:00
|
|
|
bool AreRulesAvailable(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv);
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
protected:
|
2018-04-30 18:50:03 +03:00
|
|
|
// Internal methods which do not have security check and completeness check.
|
|
|
|
uint32_t InsertRuleInternal(const nsAString& aRule,
|
|
|
|
uint32_t aIndex,
|
|
|
|
ErrorResult&);
|
|
|
|
void DeleteRuleInternal(uint32_t aIndex, ErrorResult&);
|
|
|
|
nsresult InsertRuleIntoGroupInternal(const nsAString& aRule,
|
|
|
|
css::GroupRule* aGroup,
|
|
|
|
uint32_t aIndex);
|
|
|
|
|
|
|
|
// Common tail routine for the synchronous and asynchronous parsing paths.
|
|
|
|
void FinishParse();
|
|
|
|
|
|
|
|
// Take the recently cloned sheets from the `@import` rules, and reparent them
|
|
|
|
// correctly to `aPrimarySheet`.
|
|
|
|
void BuildChildListAfterInnerClone();
|
|
|
|
|
|
|
|
void DropRuleList();
|
|
|
|
|
2017-11-28 03:50:45 +03:00
|
|
|
// Called when a rule is removed from the sheet from CSSOM.
|
|
|
|
void RuleAdded(css::Rule&);
|
|
|
|
|
|
|
|
// Called when a rule is added to the sheet from CSSOM.
|
|
|
|
void RuleRemoved(css::Rule&);
|
|
|
|
|
2018-03-17 00:56:05 +03:00
|
|
|
void ApplicableStateChanged(bool aApplicable);
|
|
|
|
|
2017-03-07 03:27:32 +03:00
|
|
|
struct ChildSheetListBuilder {
|
|
|
|
RefPtr<StyleSheet>* sheetSlot;
|
|
|
|
StyleSheet* parent;
|
|
|
|
|
|
|
|
void SetParentLinks(StyleSheet* aSheet);
|
|
|
|
|
|
|
|
static void ReparentChildList(StyleSheet* aPrimarySheet,
|
|
|
|
StyleSheet* aFirstChild);
|
|
|
|
};
|
|
|
|
|
2017-01-24 03:37:59 +03:00
|
|
|
void UnparentChildren();
|
|
|
|
|
2017-06-19 03:15:49 +03:00
|
|
|
void LastRelease();
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
// Return success if the subject principal subsumes the principal of our
|
|
|
|
// inner, error otherwise. This will also succeed if the subject has
|
|
|
|
// UniversalXPConnect or if access is allowed by CORS. In the latter case,
|
|
|
|
// it will set the principal of the inner to the subject principal.
|
|
|
|
void SubjectSubsumesInnerPrincipal(nsIPrincipal& aSubjectPrincipal,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2017-01-06 10:05:24 +03:00
|
|
|
// Drop our reference to mMedia
|
|
|
|
void DropMedia();
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
// Unlink our inner, if needed, for cycle collection.
|
|
|
|
void UnlinkInner();
|
2017-02-16 03:19:33 +03:00
|
|
|
// Traverse our inner, if needed, for cycle collection
|
2018-04-30 18:50:03 +03:00
|
|
|
void TraverseInner(nsCycleCollectionTraversalCallback &);
|
2017-02-16 03:19:33 +03:00
|
|
|
|
2017-05-30 04:10:25 +03:00
|
|
|
// Return whether the given @import rule has pending child sheet.
|
|
|
|
static bool RuleHasPendingChildSheet(css::Rule* aRule);
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
StyleSheet* mParent; // weak ref
|
2017-01-25 00:09:33 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
nsString mTitle;
|
|
|
|
nsIDocument* mDocument; // weak ref; parents maintain this for their children
|
|
|
|
nsINode* mOwningNode; // weak ref
|
|
|
|
dom::CSSImportRule* mOwnerRule; // weak ref
|
2016-08-02 23:12:27 +03:00
|
|
|
|
2016-11-09 09:28:24 +03:00
|
|
|
RefPtr<dom::MediaList> mMedia;
|
2017-01-06 10:05:24 +03:00
|
|
|
|
2017-01-24 02:36:09 +03:00
|
|
|
RefPtr<StyleSheet> mNext;
|
|
|
|
|
2016-08-02 23:12:27 +03:00
|
|
|
// mParsingMode controls access to nonstandard style constructs that
|
|
|
|
// are not safe for use on the public Web but necessary in UA sheets
|
|
|
|
// and/or useful in user sheets.
|
2016-02-26 04:51:01 +03:00
|
|
|
css::SheetParsingMode mParsingMode;
|
2016-08-02 23:12:27 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
bool mDisabled;
|
2017-01-20 07:49:44 +03:00
|
|
|
|
2018-01-04 01:25:56 +03:00
|
|
|
enum dirtyFlagAttributes {
|
|
|
|
FORCED_UNIQUE_INNER = 0x1,
|
2018-01-04 02:02:43 +03:00
|
|
|
MODIFIED_RULES = 0x2,
|
2018-01-04 01:25:56 +03:00
|
|
|
};
|
|
|
|
uint8_t mDirtyFlags; // has been modified
|
2017-06-14 07:26:48 +03:00
|
|
|
|
2017-01-20 07:49:44 +03:00
|
|
|
// mDocumentAssociationMode determines whether mDocument directly owns us (in
|
|
|
|
// the sense that if it's known-live then we're known-live). Always
|
|
|
|
// NotOwnedByDocument when mDocument is null.
|
|
|
|
DocumentAssociationMode mDocumentAssociationMode;
|
2017-01-24 02:36:09 +03:00
|
|
|
|
2017-02-14 20:41:33 +03:00
|
|
|
// Core information we get from parsed sheets, which are shared amongst
|
|
|
|
// StyleSheet clones.
|
2018-04-30 18:50:03 +03:00
|
|
|
//
|
|
|
|
// FIXME(emilio): Should be NonNull.
|
2017-02-14 20:41:33 +03:00
|
|
|
StyleSheetInfo* mInner;
|
|
|
|
|
2018-03-29 14:15:46 +03:00
|
|
|
nsTArray<ServoStyleSet*> mStyleSets;
|
2017-05-16 02:27:15 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
RefPtr<ServoCSSRuleList> mRuleList;
|
2017-01-24 02:36:09 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
MozPromiseHolder<StyleSheetParsePromise> mParsePromise;
|
2017-03-07 03:27:32 +03:00
|
|
|
|
|
|
|
// Make StyleSheetInfo and subclasses into friends so they can use
|
|
|
|
// ChildSheetListBuilder.
|
|
|
|
friend struct mozilla::StyleSheetInfo;
|
2016-02-26 04:51:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_StyleSheet_h
|