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_StyleSheetInfo_h
|
|
|
|
#define mozilla_StyleSheetInfo_h
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
#include "mozilla/css/SheetParsingMode.h"
|
2016-02-26 04:51:01 +03:00
|
|
|
#include "mozilla/dom/SRIMetadata.h"
|
|
|
|
#include "mozilla/CORSMode.h"
|
|
|
|
|
2019-07-16 14:43:39 +03:00
|
|
|
#include "nsIReferrerInfo.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
class nsIPrincipal;
|
2020-11-23 19:12:02 +03:00
|
|
|
class nsIURI;
|
2016-02-26 04:51:01 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
2018-04-30 18:50:03 +03:00
|
|
|
class StyleSheet;
|
2023-05-09 14:07:26 +03:00
|
|
|
struct StyleUseCounters;
|
2023-05-11 03:36:24 +03:00
|
|
|
struct StyleStylesheetContents;
|
2018-10-14 03:06:13 +03:00
|
|
|
struct URLExtraData;
|
2016-02-26 04:51:01 +03:00
|
|
|
|
|
|
|
/**
|
2016-09-29 09:11:52 +03:00
|
|
|
* Struct for data common to CSSStyleSheetInner and ServoStyleSheet.
|
2016-02-26 04:51:01 +03:00
|
|
|
*/
|
2018-04-30 18:50:03 +03:00
|
|
|
struct StyleSheetInfo final {
|
2023-05-28 23:43:32 +03:00
|
|
|
using ReferrerPolicy = dom::ReferrerPolicy;
|
2016-02-26 04:51:01 +03:00
|
|
|
|
2019-07-16 14:43:39 +03:00
|
|
|
StyleSheetInfo(CORSMode aCORSMode, const dom::SRIMetadata& aIntegrity,
|
2018-04-30 18:50:03 +03:00
|
|
|
css::SheetParsingMode aParsingMode);
|
2016-02-26 04:51:01 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
// FIXME(emilio): aCopy should be const.
|
|
|
|
StyleSheetInfo(StyleSheetInfo& aCopy, StyleSheet* aPrimarySheet);
|
2017-02-18 02:48:35 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
~StyleSheetInfo();
|
2017-02-18 02:48:35 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
StyleSheetInfo* CloneFor(StyleSheet* aPrimarySheet);
|
2017-02-18 02:48:35 +03:00
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
void AddSheet(StyleSheet* aSheet);
|
|
|
|
void RemoveSheet(StyleSheet* aSheet);
|
|
|
|
|
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
|
|
|
// FIXME(emilio): most of this struct should be const, then we can remove the
|
|
|
|
// duplication with the UrlExtraData member and such.
|
2016-02-26 04:51:01 +03:00
|
|
|
nsCOMPtr<nsIURI> mSheetURI; // for error reports, etc.
|
|
|
|
nsCOMPtr<nsIURI> mOriginalSheetURI; // for GetHref. Can be null.
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI; // for resolving relative URIs
|
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
2023-05-28 23:43:32 +03:00
|
|
|
const CORSMode mCORSMode;
|
2019-07-16 14:43:39 +03:00
|
|
|
// The ReferrerInfo of a stylesheet is used for its child sheets and loads
|
|
|
|
// come from this stylesheet, so it is stored here.
|
|
|
|
nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
|
2016-02-26 04:51:01 +03:00
|
|
|
dom::SRIMetadata mIntegrity;
|
2017-01-24 02:52:56 +03:00
|
|
|
|
2019-12-03 13:49:23 +03:00
|
|
|
// Pointer to the list of child sheets. This is all fundamentally broken,
|
|
|
|
// because each of the child sheets has a unique parent... We can only hope
|
|
|
|
// (and currently this is the case) that any time page JS can get its hands on
|
|
|
|
// a child sheet that means we've already ensured unique infos throughout its
|
|
|
|
// parent chain and things are good.
|
|
|
|
nsTArray<RefPtr<StyleSheet>> mChildren;
|
|
|
|
|
2017-02-18 02:48:35 +03:00
|
|
|
AutoTArray<StyleSheet*, 8> mSheets;
|
|
|
|
|
2017-06-29 02:51:46 +03:00
|
|
|
// If a SourceMap or X-SourceMap response header is seen, this is
|
|
|
|
// the value. If both are seen, SourceMap is preferred. If neither
|
|
|
|
// is seen, this will be an empty string.
|
2023-08-30 12:27:06 +03:00
|
|
|
nsCString mSourceMapURL;
|
2017-06-29 02:51:46 +03:00
|
|
|
|
2023-05-11 03:36:24 +03:00
|
|
|
RefPtr<const StyleStylesheetContents> mContents;
|
2018-04-30 18:50:03 +03:00
|
|
|
|
Bug 1729488 - Refactor shared sheet cache into something more reusable. r=jwatt
This moves the style-specific bits of the shared style sheet cache into
a super-class, and leaves the generic "sub-resource management" bits
inside a base class. In order to implement it you need to provide some
types, mainly:
* Loader, which implements LoaderPrincipal() and allows you to key per
principal. The idea is that this would be the
{CSS,Script,Image}Loader object.
* Key (self explanatory). We might want to introduce a common key to
share the cache partitioning logic.
* Value, which represents the final cached value. This is expected to
be a StyleSheet / Stencil / imgRequestProxy.
* LoadingValue, which must inherit from
SharedSubResourceCacheLoadingValueBase (which contains the linked
list and the state that the cache manages). It also must provide a
ValueForCache() and ExpirationTime() members. For style, this is the
SheetLoadData. For script this will probably be the
ScriptLoadRequest. For images it might be enough with the
imgRequestProxy, but we might need something else, haven't looked
into it too deeply yet.
We move the use counters into the stylesheet since that's both more
similar to how we treat StyleSheetContents and easier (that way we don't
need to add some sort of "extra data" thing to the cache).
Differential Revision: https://phabricator.services.mozilla.com/D124820
2021-10-05 18:15:22 +03:00
|
|
|
UniquePtr<StyleUseCounters> mUseCounters;
|
|
|
|
|
2018-04-30 18:50:03 +03:00
|
|
|
// XXX We already have mSheetURI, mBaseURI, and mPrincipal.
|
|
|
|
//
|
|
|
|
// Can we somehow replace them with URLExtraData directly? The issue
|
|
|
|
// is currently URLExtraData is immutable, but URIs in StyleSheetInfo
|
|
|
|
// seems to be mutable, so we probably cannot set them altogether.
|
|
|
|
// Also, this is mostly a duplicate reference of the same url data
|
|
|
|
// inside RawServoStyleSheet. We may want to just use that instead.
|
|
|
|
RefPtr<URLExtraData> mURLData;
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
#ifdef DEBUG
|
2023-05-28 23:43:32 +03:00
|
|
|
bool mPrincipalSet = false;
|
2016-02-26 04:51:01 +03:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_StyleSheetInfo_h
|