2017-10-27 20:33:53 +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: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
/* loading of CSS style sheets using the network APIs */
|
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
#ifndef mozilla_css_Loader_h
|
|
|
|
#define mozilla_css_Loader_h
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2020-05-19 06:59:23 +03:00
|
|
|
#include <tuple>
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/CORSMode.h"
|
2020-05-21 06:07:16 +03:00
|
|
|
#include "mozilla/dom/LinkStyle.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
|
|
|
#include "mozilla/UniquePtr.h"
|
2010-03-03 00:00:53 +03:00
|
|
|
#include "nsCompatibility.h"
|
2014-07-02 02:37:09 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-05-09 19:23:14 +04:00
|
|
|
#include "nsStringFwd.h"
|
2010-03-03 00:00:53 +03:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsTObserverArray.h"
|
2020-06-12 22:31:32 +03:00
|
|
|
#include "nsURIHashKey.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
class nsICSSLoaderObserver;
|
2016-09-08 04:59:40 +03:00
|
|
|
class nsIConsoleReportCollector;
|
2010-03-03 00:00:53 +03:00
|
|
|
class nsIContent;
|
2020-05-29 16:48:11 +03:00
|
|
|
class nsIPrincipal;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
namespace mozilla {
|
2020-05-29 16:48:11 +03:00
|
|
|
|
2020-06-23 20:18:47 +03:00
|
|
|
class PreloadHashKey;
|
2020-06-12 22:31:32 +03:00
|
|
|
class SharedStyleSheetCache;
|
|
|
|
class SheetLoadDataHashKey;
|
2020-05-29 16:48:11 +03:00
|
|
|
class StyleSheet;
|
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
namespace dom {
|
2017-03-13 12:00:57 +03:00
|
|
|
class DocGroup;
|
2013-01-09 03:25:47 +04:00
|
|
|
class Element;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
// The load data for a <link> or @import style-sheet.
|
|
|
|
//
|
|
|
|
// This must contain all the state that affects CSS parsing.
|
|
|
|
class SheetLoadDataHashKey : public PLDHashEntryHdr {
|
|
|
|
public:
|
|
|
|
enum class IsPreload : uint8_t {
|
|
|
|
No,
|
|
|
|
// This is a speculative load initiated by a <link rel=stylesheet> tag
|
|
|
|
// scanned by the parser, or @import rules found in a <style> tag.
|
|
|
|
FromParser,
|
|
|
|
// This is a speculative load as well, but initiated by
|
|
|
|
// <link rel="preload" as="style">
|
|
|
|
FromLink,
|
|
|
|
};
|
|
|
|
|
|
|
|
using KeyType = const SheetLoadDataHashKey&;
|
|
|
|
using KeyTypePointer = const SheetLoadDataHashKey*;
|
|
|
|
|
|
|
|
explicit SheetLoadDataHashKey(const SheetLoadDataHashKey* aKey)
|
|
|
|
: mURI(aKey->mURI),
|
|
|
|
mPrincipal(aKey->mPrincipal),
|
|
|
|
mLoaderPrincipal(aKey->mLoaderPrincipal),
|
2020-06-24 09:47:38 +03:00
|
|
|
mPartitionPrincipal(aKey->mPartitionPrincipal),
|
2020-06-12 22:31:32 +03:00
|
|
|
mEncodingGuess(aKey->mEncodingGuess),
|
|
|
|
mCORSMode(aKey->mCORSMode),
|
|
|
|
mParsingMode(aKey->mParsingMode),
|
|
|
|
mCompatMode(aKey->mCompatMode),
|
|
|
|
mSRIMetadata(aKey->mSRIMetadata),
|
|
|
|
mIsLinkPreload(aKey->mIsLinkPreload) {
|
|
|
|
MOZ_COUNT_CTOR(SheetLoadDataHashKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
SheetLoadDataHashKey(nsIURI* aURI, nsIPrincipal* aPrincipal,
|
|
|
|
nsIPrincipal* aLoaderPrincipal,
|
2020-06-24 09:47:38 +03:00
|
|
|
nsIPrincipal* aPartitionPrincipal,
|
2020-06-12 22:31:32 +03:00
|
|
|
NotNull<const Encoding*> aEncodingGuess,
|
|
|
|
CORSMode aCORSMode, css::SheetParsingMode aParsingMode,
|
|
|
|
nsCompatibility aCompatMode,
|
|
|
|
const dom::SRIMetadata& aSRIMetadata,
|
|
|
|
IsPreload aIsPreload)
|
|
|
|
: mURI(aURI),
|
|
|
|
mPrincipal(aPrincipal),
|
|
|
|
mLoaderPrincipal(aLoaderPrincipal),
|
2020-06-24 09:47:38 +03:00
|
|
|
mPartitionPrincipal(aPartitionPrincipal),
|
2020-06-12 22:31:32 +03:00
|
|
|
mEncodingGuess(aEncodingGuess),
|
|
|
|
mCORSMode(aCORSMode),
|
|
|
|
mParsingMode(aParsingMode),
|
|
|
|
mCompatMode(aCompatMode),
|
|
|
|
mSRIMetadata(aSRIMetadata),
|
|
|
|
mIsLinkPreload(aIsPreload == IsPreload::FromLink) {
|
|
|
|
MOZ_ASSERT(aURI);
|
|
|
|
MOZ_ASSERT(aPrincipal);
|
|
|
|
MOZ_ASSERT(aLoaderPrincipal);
|
|
|
|
MOZ_COUNT_CTOR(SheetLoadDataHashKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
SheetLoadDataHashKey(SheetLoadDataHashKey&& toMove)
|
|
|
|
: mURI(std::move(toMove.mURI)),
|
|
|
|
mPrincipal(std::move(toMove.mPrincipal)),
|
|
|
|
mLoaderPrincipal(std::move(toMove.mLoaderPrincipal)),
|
2020-06-24 09:47:38 +03:00
|
|
|
mPartitionPrincipal(std::move(toMove.mPartitionPrincipal)),
|
2020-06-12 22:31:32 +03:00
|
|
|
mEncodingGuess(std::move(toMove.mEncodingGuess)),
|
|
|
|
mCORSMode(std::move(toMove.mCORSMode)),
|
|
|
|
mParsingMode(std::move(toMove.mParsingMode)),
|
|
|
|
mCompatMode(std::move(toMove.mCompatMode)),
|
|
|
|
mSRIMetadata(std::move(toMove.mSRIMetadata)),
|
|
|
|
mIsLinkPreload(std::move(toMove.mIsLinkPreload)) {
|
|
|
|
MOZ_COUNT_CTOR(SheetLoadDataHashKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit SheetLoadDataHashKey(const css::SheetLoadData&);
|
|
|
|
|
|
|
|
MOZ_COUNTED_DTOR(SheetLoadDataHashKey)
|
|
|
|
|
|
|
|
const SheetLoadDataHashKey& GetKey() const { return *this; }
|
|
|
|
const SheetLoadDataHashKey* GetKeyPointer() const { return this; }
|
|
|
|
|
|
|
|
bool KeyEquals(const SheetLoadDataHashKey* aKey) const {
|
|
|
|
return KeyEquals(*aKey);
|
|
|
|
}
|
|
|
|
|
2020-06-22 13:48:44 +03:00
|
|
|
bool KeyEquals(const SheetLoadDataHashKey&) const;
|
2020-06-12 22:31:32 +03:00
|
|
|
|
|
|
|
static const SheetLoadDataHashKey* KeyToPointer(
|
|
|
|
const SheetLoadDataHashKey& aKey) {
|
|
|
|
return &aKey;
|
|
|
|
}
|
|
|
|
static PLDHashNumber HashKey(const SheetLoadDataHashKey* aKey) {
|
|
|
|
return nsURIHashKey::HashKey(aKey->mURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIURI* URI() const { return mURI; }
|
|
|
|
|
|
|
|
nsIPrincipal* Principal() const { return mPrincipal; }
|
|
|
|
|
|
|
|
nsIPrincipal* LoaderPrincipal() const { return mLoaderPrincipal; }
|
|
|
|
|
|
|
|
css::SheetParsingMode ParsingMode() const { return mParsingMode; }
|
|
|
|
|
|
|
|
enum { ALLOW_MEMMOVE = true };
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const nsCOMPtr<nsIURI> mURI;
|
|
|
|
const nsCOMPtr<nsIPrincipal> mPrincipal;
|
|
|
|
const nsCOMPtr<nsIPrincipal> mLoaderPrincipal;
|
2020-06-24 09:47:38 +03:00
|
|
|
const nsCOMPtr<nsIPrincipal> mPartitionPrincipal;
|
2020-06-12 22:31:32 +03:00
|
|
|
// The encoding guess is the encoding the sheet would get if the request
|
|
|
|
// didn't have any encoding information like @charset or a Content-Encoding
|
|
|
|
// header.
|
|
|
|
const NotNull<const Encoding*> mEncodingGuess;
|
|
|
|
const CORSMode mCORSMode;
|
|
|
|
const css::SheetParsingMode mParsingMode;
|
|
|
|
const nsCompatibility mCompatMode;
|
|
|
|
dom::SRIMetadata mSRIMetadata;
|
|
|
|
const bool mIsLinkPreload;
|
|
|
|
};
|
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
namespace css {
|
|
|
|
|
|
|
|
class SheetLoadData;
|
2011-03-17 20:41:52 +03:00
|
|
|
class ImportRule;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2015-09-18 08:27:00 +03:00
|
|
|
/*********************
|
|
|
|
* Style sheet reuse *
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
class MOZ_RAII LoaderReusableStyleSheets {
|
|
|
|
public:
|
2020-03-17 12:38:32 +03:00
|
|
|
LoaderReusableStyleSheets() = default;
|
2015-09-18 08:27:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Look for a reusable sheet (see AddReusableSheet) matching the
|
|
|
|
* given URL. If found, set aResult, remove the reused sheet from
|
|
|
|
* the internal list, and return true. If not found, return false;
|
|
|
|
* in this case, aResult is not modified.
|
|
|
|
*
|
|
|
|
* @param aURL the url to match
|
|
|
|
* @param aResult [out] the style sheet which can be reused
|
|
|
|
*/
|
2017-05-15 10:55:08 +03:00
|
|
|
bool FindReusableStyleSheet(nsIURI* aURL, RefPtr<StyleSheet>& aResult);
|
2015-09-18 08:27:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate that a certain style sheet is available for reuse if its
|
|
|
|
* URI matches the URI of an @import. Sheets should be added in the
|
|
|
|
* opposite order in which they are intended to be reused.
|
|
|
|
*
|
|
|
|
* @param aSheet the sheet which can be reused
|
|
|
|
*/
|
2017-05-15 10:55:08 +03:00
|
|
|
void AddReusableSheet(StyleSheet* aSheet) {
|
2015-09-18 08:27:00 +03:00
|
|
|
mReusableSheets.AppendElement(aSheet);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
LoaderReusableStyleSheets(const LoaderReusableStyleSheets&) = delete;
|
|
|
|
LoaderReusableStyleSheets& operator=(const LoaderReusableStyleSheets&) =
|
|
|
|
delete;
|
|
|
|
|
|
|
|
// The sheets that can be reused.
|
2017-05-15 10:55:08 +03:00
|
|
|
nsTArray<RefPtr<StyleSheet>> mReusableSheets;
|
2015-09-18 08:27:00 +03:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Loader final {
|
2019-11-30 14:57:10 +03:00
|
|
|
using ReferrerPolicy = dom::ReferrerPolicy;
|
2014-11-18 16:46:47 +03:00
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
public:
|
2020-05-21 06:07:16 +03:00
|
|
|
using Completed = dom::LinkStyle::Completed;
|
|
|
|
using HasAlternateRel = dom::LinkStyle::HasAlternateRel;
|
|
|
|
using IsAlternate = dom::LinkStyle::IsAlternate;
|
|
|
|
using IsInline = dom::LinkStyle::IsInline;
|
|
|
|
using IsExplicitlyEnabled = dom::LinkStyle::IsExplicitlyEnabled;
|
|
|
|
using MediaMatched = dom::LinkStyle::MediaMatched;
|
|
|
|
using LoadSheetResult = dom::LinkStyle::Update;
|
|
|
|
using SheetInfo = dom::LinkStyle::SheetInfo;
|
2018-04-24 15:12:54 +03:00
|
|
|
|
2018-03-28 18:33:01 +03:00
|
|
|
Loader();
|
2017-03-13 12:00:57 +03:00
|
|
|
// aDocGroup is used for dispatching SheetLoadData in PostLoadEvent(). It
|
|
|
|
// can be null if you want to use this constructor, and there's no
|
|
|
|
// document when the Loader is constructed.
|
2019-11-30 14:57:10 +03:00
|
|
|
explicit Loader(dom::DocGroup*);
|
|
|
|
explicit Loader(dom::Document*);
|
2014-03-21 05:16:20 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2010-03-03 00:00:53 +03:00
|
|
|
~Loader();
|
|
|
|
|
2014-03-21 05:16:20 +04:00
|
|
|
public:
|
2014-07-02 02:37:09 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Loader)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(Loader)
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
void DropDocumentReference(); // notification that doc is going away
|
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
void DeregisterFromSheetCache();
|
|
|
|
void RegisterInSheetCache();
|
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
void SetCompatibilityMode(nsCompatibility aCompatMode) {
|
|
|
|
mCompatMode = aCompatMode;
|
|
|
|
}
|
|
|
|
nsCompatibility GetCompatibilityMode() { return mCompatMode; }
|
2018-05-06 15:59:34 +03:00
|
|
|
|
|
|
|
// TODO(emilio): Is the complexity of this method and carrying the titles
|
|
|
|
// around worth it? The alternate sheets will load anyhow eventually...
|
|
|
|
void DocumentStyleSheetSetChanged();
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
// XXXbz sort out what the deal is with events! When should they fire?
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load an inline style sheet. If a successful result is returned and
|
2018-04-24 15:56:02 +03:00
|
|
|
* result.WillNotify() is true, then aObserver is guaranteed to be notified
|
2010-03-03 00:00:53 +03:00
|
|
|
* asynchronously once the sheet is marked complete. If an error is
|
2018-04-24 15:56:02 +03:00
|
|
|
* returned, or if result.WillNotify() is false, aObserver will not be
|
|
|
|
* notified. In addition to parsing the sheet, this method will insert it
|
|
|
|
* into the stylesheet list of this CSSLoader's document.
|
2010-03-03 00:00:53 +03:00
|
|
|
* @param aObserver the observer to notify when the load completes.
|
|
|
|
* May be null.
|
2018-05-08 07:11:56 +03:00
|
|
|
* @param aBuffer the stylesheet data
|
|
|
|
* @param aLineNumber the line number at which the stylesheet data started.
|
2010-03-03 00:00:53 +03:00
|
|
|
*/
|
2018-04-24 15:56:02 +03:00
|
|
|
Result<LoadSheetResult, nsresult> LoadInlineStyle(
|
|
|
|
const SheetInfo&, const nsAString& aBuffer, uint32_t aLineNumber,
|
|
|
|
nsICSSLoaderObserver* aObserver);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a linked (document) stylesheet. If a successful result is returned,
|
|
|
|
* aObserver is guaranteed to be notified asynchronously once the sheet is
|
2018-04-24 15:56:02 +03:00
|
|
|
* loaded and marked complete, i.e., result.WillNotify() will always return
|
|
|
|
* true. If an error is returned, aObserver will not be notified. In
|
|
|
|
* addition to loading the sheet, this method will insert it into the
|
|
|
|
* stylesheet list of this CSSLoader's document.
|
2010-03-03 00:00:53 +03:00
|
|
|
* @param aObserver the observer to notify when the load completes.
|
|
|
|
* May be null.
|
|
|
|
*/
|
2018-04-24 15:56:02 +03:00
|
|
|
Result<LoadSheetResult, nsresult> LoadStyleLink(
|
2018-05-08 07:11:56 +03:00
|
|
|
const SheetInfo&, nsICSSLoaderObserver* aObserver);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a child (@import-ed) style sheet. In addition to loading the sheet,
|
|
|
|
* this method will insert it into the child sheet list of aParentSheet. If
|
|
|
|
* there is no sheet currently being parsed and the child sheet is not
|
|
|
|
* complete when this method returns, then when the child sheet becomes
|
|
|
|
* complete aParentSheet will be QIed to nsICSSLoaderObserver and
|
|
|
|
* asynchronously notified, just like for LoadStyleLink. Note that if the
|
|
|
|
* child sheet is already complete when this method returns, no
|
|
|
|
* nsICSSLoaderObserver notification will be sent.
|
|
|
|
*
|
|
|
|
* @param aParentSheet the parent of this child sheet
|
2018-02-28 11:09:00 +03:00
|
|
|
* @param aParentData the SheetLoadData corresponding to the load of the
|
2019-08-16 13:56:09 +03:00
|
|
|
* parent sheet. May be null for @import rules inserted via
|
|
|
|
* CSSOM.
|
2010-03-03 00:00:53 +03:00
|
|
|
* @param aURL the URL of the child sheet
|
|
|
|
* @param aMedia the already-parsed media list for the child sheet
|
2015-09-18 08:27:00 +03:00
|
|
|
* @param aSavedSheets any saved style sheets which could be reused
|
|
|
|
* for this load
|
2010-03-03 00:00:53 +03:00
|
|
|
*/
|
2019-08-16 13:56:09 +03:00
|
|
|
nsresult LoadChildSheet(StyleSheet& aParentSheet, SheetLoadData* aParentData,
|
2017-04-10 05:38:42 +03:00
|
|
|
nsIURI* aURL, dom::MediaList* aMedia,
|
2015-09-18 08:27:00 +03:00
|
|
|
LoaderReusableStyleSheets* aSavedSheets);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2020-06-12 22:06:12 +03:00
|
|
|
/**
|
|
|
|
* Called when we hit the internal memory cache with a complete stylesheet.
|
|
|
|
*/
|
2020-06-13 05:03:08 +03:00
|
|
|
void DidHitCompleteSheetCache(const SheetLoadDataHashKey&,
|
|
|
|
const StyleUseCounters* aCounters);
|
2020-06-12 22:05:56 +03:00
|
|
|
|
2019-08-16 13:56:05 +03:00
|
|
|
enum class UseSystemPrincipal { No, Yes };
|
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
/**
|
|
|
|
* Synchronously load and return the stylesheet at aURL. Any child sheets
|
|
|
|
* will also be loaded synchronously. Note that synchronous loads over some
|
|
|
|
* protocols may involve spinning up a new event loop, so use of this method
|
|
|
|
* does NOT guarantee not receiving any events before the sheet loads. This
|
|
|
|
* method can be used to load sheets not associated with a document.
|
|
|
|
*
|
|
|
|
* @param aURL the URL of the sheet to load
|
2015-10-14 00:43:16 +03:00
|
|
|
* @param aParsingMode the mode in which to parse the sheet
|
|
|
|
* (see comments at enum SheetParsingMode, above).
|
2010-03-03 00:00:53 +03:00
|
|
|
* @param aUseSystemPrincipal if true, give the resulting sheet the system
|
|
|
|
* principal no matter where it's being loaded from.
|
|
|
|
*
|
|
|
|
* NOTE: At the moment, this method assumes the sheet will be UTF-8, but
|
|
|
|
* ideally it would allow arbitrary encodings. Callers should NOT depend on
|
|
|
|
* non-UTF8 sheets being treated as UTF-8 by this method.
|
|
|
|
*
|
|
|
|
* NOTE: A successful return from this method doesn't indicate anything about
|
|
|
|
* whether the data could be parsed as CSS and doesn't indicate anything
|
|
|
|
* about the status of child sheets of the returned sheet.
|
|
|
|
*/
|
2019-08-16 13:56:03 +03:00
|
|
|
Result<RefPtr<StyleSheet>, nsresult> LoadSheetSync(
|
|
|
|
nsIURI*, SheetParsingMode = eAuthorSheetFeatures,
|
2019-08-16 13:56:05 +03:00
|
|
|
UseSystemPrincipal = UseSystemPrincipal::No);
|
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
using IsPreload = SheetLoadDataHashKey::IsPreload;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2017-03-20 05:33:49 +03:00
|
|
|
/**
|
|
|
|
* Asynchronously load the stylesheet at aURL. If a successful result is
|
|
|
|
* returned, aObserver is guaranteed to be notified asynchronously once the
|
|
|
|
* sheet is loaded and marked complete. This method can be used to load
|
|
|
|
* sheets not associated with a document.
|
|
|
|
*
|
|
|
|
* @param aURL the URL of the sheet to load
|
|
|
|
* @param aParsingMode the mode in which to parse the sheet
|
|
|
|
* (see comments at enum SheetParsingMode, above).
|
|
|
|
* @param aUseSystemPrincipal if true, give the resulting sheet the system
|
|
|
|
* principal no matter where it's being loaded from.
|
2019-07-16 14:43:56 +03:00
|
|
|
* @param aReferrerInfo referrer information of the sheet.
|
2017-03-20 05:33:49 +03:00
|
|
|
* @param aObserver the observer to notify when the load completes.
|
|
|
|
* Must not be null.
|
2019-08-16 13:56:03 +03:00
|
|
|
* @return the sheet to load. Note that the sheet may well not be loaded by
|
|
|
|
* the time this method returns.
|
2017-03-20 05:33:49 +03:00
|
|
|
*
|
|
|
|
* NOTE: At the moment, this method assumes the sheet will be UTF-8, but
|
|
|
|
* ideally it would allow arbitrary encodings. Callers should NOT depend on
|
|
|
|
* non-UTF8 sheets being treated as UTF-8 by this method.
|
|
|
|
*/
|
2019-08-16 13:56:03 +03:00
|
|
|
Result<RefPtr<StyleSheet>, nsresult> LoadSheet(
|
2020-05-25 12:42:01 +03:00
|
|
|
nsIURI* aURI, IsPreload, const Encoding* aPreloadEncoding,
|
|
|
|
nsIReferrerInfo* aReferrerInfo, nsICSSLoaderObserver* aObserver,
|
|
|
|
CORSMode = CORS_NONE, const nsAString& aIntegrity = EmptyString());
|
2017-03-20 05:33:49 +03:00
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
/**
|
2019-08-16 13:56:03 +03:00
|
|
|
* As above, but without caring for a couple things.
|
2010-03-03 00:00:53 +03:00
|
|
|
*/
|
2019-08-16 13:56:03 +03:00
|
|
|
Result<RefPtr<StyleSheet>, nsresult> LoadSheet(nsIURI*, SheetParsingMode,
|
2019-08-16 13:56:05 +03:00
|
|
|
UseSystemPrincipal,
|
2019-08-16 13:56:03 +03:00
|
|
|
nsICSSLoaderObserver*);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop loading all sheets. All nsICSSLoaderObservers involved will be
|
|
|
|
* notified with NS_BINDING_ABORTED as the status, possibly synchronously.
|
|
|
|
*/
|
2018-06-22 15:23:28 +03:00
|
|
|
void Stop();
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
/**
|
2010-04-03 15:36:19 +04:00
|
|
|
* nsresult Loader::StopLoadingSheet(nsIURI* aURL), which notifies the
|
2011-05-06 19:45:36 +04:00
|
|
|
* nsICSSLoaderObserver with NS_BINDING_ABORTED, was removed in Bug 556446.
|
2010-04-03 15:36:19 +04:00
|
|
|
* It can be found in revision 2c44a32052ad.
|
2010-03-03 00:00:53 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the loader is enabled or not.
|
|
|
|
* When disabled, processing of new styles is disabled and an attempt
|
|
|
|
* to do so will fail with a return code of
|
|
|
|
* NS_ERROR_NOT_AVAILABLE. Note that this DOES NOT disable
|
|
|
|
* currently loading styles or already processed styles.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetEnabled() { return mEnabled; }
|
|
|
|
void SetEnabled(bool aEnabled) { mEnabled = aEnabled; }
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
uint32_t ParsedSheetCount() const { return mParsedSheetCount; }
|
|
|
|
|
2010-12-20 19:21:59 +03:00
|
|
|
/**
|
|
|
|
* Get the document we live for. May return null.
|
|
|
|
*/
|
2019-11-30 14:57:10 +03:00
|
|
|
dom::Document* GetDocument() const { return mDocument; }
|
2010-12-20 19:21:59 +03:00
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
/**
|
|
|
|
* Return true if this loader has pending loads (ones that would send
|
|
|
|
* notifications to an nsICSSLoaderObserver attached to this loader).
|
|
|
|
* If called from inside nsICSSLoaderObserver::StyleSheetLoaded, this will
|
2011-10-17 18:59:28 +04:00
|
|
|
* return false if and only if that is the last StyleSheetLoaded
|
2010-03-03 00:00:53 +03:00
|
|
|
* notification the CSSLoader knows it's going to send. In other words, if
|
|
|
|
* two sheets load at once (via load coalescing, e.g.), HasPendingLoads()
|
2011-10-17 18:59:28 +04:00
|
|
|
* will return true during notification for the first one, and false
|
2010-03-03 00:00:53 +03:00
|
|
|
* during notification for the second one.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasPendingLoads();
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an observer to this loader. The observer will be notified
|
|
|
|
* for all loads that would have notified their own observers (even
|
|
|
|
* if those loads don't have observers attached to them).
|
|
|
|
* Load-specific observers will be notified before generic
|
|
|
|
* observers. The loader holds a reference to the observer.
|
|
|
|
*
|
|
|
|
* aObserver must not be null.
|
|
|
|
*/
|
2018-10-14 19:12:23 +03:00
|
|
|
void AddObserver(nsICSSLoaderObserver* aObserver);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an observer added via AddObserver.
|
|
|
|
*/
|
|
|
|
void RemoveObserver(nsICSSLoaderObserver* aObserver);
|
|
|
|
|
|
|
|
// These interfaces are public only for the benefit of static functions
|
|
|
|
// within nsCSSLoader.cpp.
|
|
|
|
|
2018-04-24 15:56:02 +03:00
|
|
|
// IsAlternateSheet can change our currently selected style set if none is
|
|
|
|
// selected and aHasAlternateRel is false.
|
2018-04-24 15:12:54 +03:00
|
|
|
IsAlternate IsAlternateSheet(const nsAString& aTitle, bool aHasAlternateRel);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2018-06-22 15:23:28 +03:00
|
|
|
typedef nsTArray<RefPtr<SheetLoadData>> LoadDataArray;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2012-10-18 01:01:56 +04:00
|
|
|
// Measure our size.
|
2019-11-30 14:57:10 +03:00
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
2012-10-18 01:01:56 +04:00
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
enum class SheetState : uint8_t {
|
|
|
|
NeedsParser = 0,
|
|
|
|
Pending,
|
|
|
|
Loading,
|
|
|
|
Complete
|
|
|
|
};
|
|
|
|
|
2020-06-08 12:11:26 +03:00
|
|
|
// The loader principal is the document's node principal, if this loader is
|
|
|
|
// owned by a document, or the system principal otherwise.
|
|
|
|
nsIPrincipal* LoaderPrincipal() const;
|
|
|
|
|
2020-06-24 09:47:38 +03:00
|
|
|
// The partitioned principal is the document's partitioned principal, if this
|
|
|
|
// loader is owned by a document, or the system principal otherwise.
|
|
|
|
nsIPrincipal* PartitionedPrincipal() const;
|
|
|
|
|
2020-06-12 22:06:04 +03:00
|
|
|
bool ShouldBypassCache() const;
|
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
private:
|
2020-06-12 22:31:32 +03:00
|
|
|
friend class mozilla::SharedStyleSheetCache;
|
2010-03-03 00:00:53 +03:00
|
|
|
friend class SheetLoadData;
|
2017-08-29 16:01:42 +03:00
|
|
|
friend class StreamLoader;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2018-02-14 00:25:04 +03:00
|
|
|
// Helpers to conditionally block onload if mDocument is non-null.
|
2020-06-23 11:27:54 +03:00
|
|
|
void IncrementOngoingLoadCount() {
|
|
|
|
if (!mOngoingLoadCount++) {
|
|
|
|
BlockOnload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DecrementOngoingLoadCount() {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mOngoingLoadCount);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mOngoingLoadCount > mPendingLoadCount);
|
|
|
|
if (!--mOngoingLoadCount) {
|
|
|
|
UnblockOnload(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-14 00:25:04 +03:00
|
|
|
void BlockOnload();
|
|
|
|
void UnblockOnload(bool aFireSync);
|
|
|
|
|
2018-02-28 03:57:09 +03:00
|
|
|
// Helper to select the correct dispatch target for asynchronous events for
|
|
|
|
// this loader.
|
|
|
|
already_AddRefed<nsISerialEventTarget> DispatchTarget();
|
|
|
|
|
Bug 1407056: Part 1 - Provide more consistent principal/origin URL to content policies. r=bz,ckerschb
We're currently fairly vague and inconsistent about the values we provide to
content policy implementations for requestOrigin and requestPrincipal. In some
cases they're the triggering principal, sometimes the loading principal,
sometimes the channel principal.
Our existing content policy implementations which require or expect a loading
principal currently retrieve it from the context node. Since no current
callers require the principal to be the loading principal, and some already
expect it to be the triggering principal (which there's currently no other way
to retrieve), I chose to pass the triggering principal whenever possible, but
use the loading principal to determine the origin URL.
As a follow-up, I'd like to change the nsIContentPolicy interface to
explicitly receive loading and triggering principals, or possibly just
LoadInfo instances, rather than poorly-defined request
origin/principal/context args. But since that may cause trouble for
comm-central, I'd rather not do it as part of this bug.
MozReview-Commit-ID: LqD9GxdzMte
--HG--
extra : rebase_source : 41ce439912ae7b895e0a3b0e660fa6ba571eb50f
2017-10-13 01:43:55 +03:00
|
|
|
nsresult CheckContentPolicy(nsIPrincipal* aLoadingPrincipal,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2018-05-08 07:08:51 +03:00
|
|
|
nsIURI* aTargetURI, nsINode* aRequestingNode,
|
2020-01-13 14:47:25 +03:00
|
|
|
const nsAString& aNonce, IsPreload);
|
2016-02-03 07:35:30 +03:00
|
|
|
|
2020-05-19 06:59:23 +03:00
|
|
|
std::tuple<RefPtr<StyleSheet>, SheetState> CreateSheet(
|
2020-06-12 22:31:32 +03:00
|
|
|
const SheetInfo& aInfo, css::SheetParsingMode aParsingMode,
|
|
|
|
bool aSyncLoad, IsPreload aIsPreload) {
|
|
|
|
nsIPrincipal* triggeringPrincipal = aInfo.mTriggeringPrincipal
|
|
|
|
? aInfo.mTriggeringPrincipal.get()
|
|
|
|
: LoaderPrincipal();
|
|
|
|
return CreateSheet(aInfo.mURI, aInfo.mContent, triggeringPrincipal,
|
2020-06-18 17:06:20 +03:00
|
|
|
aParsingMode, aInfo.mCORSMode,
|
2020-06-12 22:31:32 +03:00
|
|
|
/* aPreloadOrParentDataEncoding = */ nullptr,
|
2020-05-21 03:06:25 +03:00
|
|
|
aInfo.mIntegrity, aSyncLoad, aIsPreload);
|
2018-05-06 17:10:09 +03:00
|
|
|
}
|
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
// For inline style, the aURI param is null, but the aLinkingContent
|
|
|
|
// must be non-null then. The loader principal must never be null
|
|
|
|
// if aURI is not null.
|
2020-05-19 06:59:23 +03:00
|
|
|
std::tuple<RefPtr<StyleSheet>, SheetState> CreateSheet(
|
2020-05-31 20:11:57 +03:00
|
|
|
nsIURI* aURI, nsIContent* aLinkingContent,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal, css::SheetParsingMode, CORSMode,
|
2020-06-12 22:31:32 +03:00
|
|
|
const Encoding* aPreloadOrParentDataEncoding, const nsAString& aIntegrity,
|
2020-05-31 20:11:57 +03:00
|
|
|
bool aSyncLoad, IsPreload aIsPreload);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2017-04-10 05:38:42 +03:00
|
|
|
// Pass in either a media string or the MediaList from the CSSParser. Don't
|
|
|
|
// pass both.
|
|
|
|
//
|
2019-08-16 13:56:18 +03:00
|
|
|
// This method will set the sheet's enabled state based on IsAlternate and co.
|
|
|
|
MediaMatched PrepareSheet(StyleSheet&, const nsAString& aTitle,
|
2019-04-19 16:31:05 +03:00
|
|
|
const nsAString& aMediaString, dom::MediaList*,
|
|
|
|
IsAlternate, IsExplicitlyEnabled);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2018-06-22 13:53:18 +03:00
|
|
|
// Inserts a style sheet in a document or a ShadowRoot.
|
|
|
|
void InsertSheetInTree(StyleSheet& aSheet, nsIContent* aLinkingContent);
|
2018-06-22 15:23:09 +03:00
|
|
|
// Inserts a style sheet into a parent style sheet.
|
|
|
|
void InsertChildSheet(StyleSheet& aSheet, StyleSheet& aParentSheet);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2019-08-16 13:56:03 +03:00
|
|
|
Result<RefPtr<StyleSheet>, nsresult> InternalLoadNonDocumentSheet(
|
2019-08-16 13:56:05 +03:00
|
|
|
nsIURI* aURL, IsPreload, SheetParsingMode aParsingMode,
|
2020-05-25 12:42:01 +03:00
|
|
|
UseSystemPrincipal, const Encoding* aPreloadEncoding,
|
|
|
|
nsIReferrerInfo* aReferrerInfo, nsICSSLoaderObserver* aObserver,
|
|
|
|
CORSMode aCORSMode, const nsAString& aIntegrity);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
RefPtr<StyleSheet> LookupInlineSheetInCache(const nsAString&);
|
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
// Post a load event for aObserver to be notified about aSheet. The
|
|
|
|
// notification will be sent with status NS_OK unless the load event is
|
|
|
|
// canceled at some point (in which case it will be sent with
|
2020-05-21 00:16:04 +03:00
|
|
|
// NS_BINDING_ABORTED).
|
|
|
|
nsresult PostLoadEvent(RefPtr<SheetLoadData>);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
// Start the loads of all the sheets in mPendingDatas
|
2018-04-24 20:17:33 +03:00
|
|
|
void StartDeferredLoads();
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2019-08-16 13:56:09 +03:00
|
|
|
void HandleLoadEvent(SheetLoadData&);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2019-08-16 13:56:09 +03:00
|
|
|
// Note: LoadSheet is responsible for setting the sheet to complete on
|
|
|
|
// failure.
|
2020-06-23 11:27:54 +03:00
|
|
|
enum class PendingLoad { No, Yes };
|
|
|
|
nsresult LoadSheet(SheetLoadData&, SheetState, PendingLoad = PendingLoad::No);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2018-06-22 15:40:52 +03:00
|
|
|
enum class AllowAsyncParse {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Parse the stylesheet in the load data.
|
|
|
|
//
|
|
|
|
// Returns whether the parse finished. It may not finish e.g. if the sheet had
|
|
|
|
// an @import.
|
|
|
|
//
|
|
|
|
// If this function returns Completed::Yes, then ParseSheet also called
|
|
|
|
// SheetComplete on aLoadData.
|
2019-08-16 13:56:09 +03:00
|
|
|
Completed ParseSheet(const nsACString&, SheetLoadData&, AllowAsyncParse);
|
2018-02-13 20:12:58 +03:00
|
|
|
|
2019-08-16 13:56:09 +03:00
|
|
|
// The load of the sheet in the load data is done, one way or another.
|
|
|
|
// Do final cleanup.
|
2020-06-12 22:31:32 +03:00
|
|
|
void SheetComplete(SheetLoadData&, nsresult);
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
// Notify observers on an individual data. This is different from
|
|
|
|
// SheetComplete for loads that are shared.
|
|
|
|
void NotifyObservers(SheetLoadData&, nsresult);
|
2018-03-06 22:45:27 +03:00
|
|
|
|
|
|
|
// Mark the given SheetLoadData, as well as any of its siblings, parents, etc
|
|
|
|
// transitively, as failed. The idea is to mark as failed any load that was
|
|
|
|
// directly or indirectly @importing the sheet this SheetLoadData represents.
|
2020-06-12 22:31:32 +03:00
|
|
|
//
|
|
|
|
// if aOnlyForLoader is non-null, then only loads for a given loader will be
|
|
|
|
// marked as failing. This is useful to only cancel loads associated to a
|
|
|
|
// given loader, in case they were marked as canceled.
|
|
|
|
static void MarkLoadTreeFailed(SheetLoadData&,
|
|
|
|
Loader* aOnlyForLoader = nullptr);
|
2020-06-11 14:42:46 +03:00
|
|
|
|
2020-06-23 20:18:47 +03:00
|
|
|
// A shorthand to mark a possible link preload as used to supress "unused"
|
|
|
|
// warning in the console.
|
|
|
|
void MaybeNotifyPreloadUsed(SheetLoadData&);
|
|
|
|
|
2020-06-12 22:31:32 +03:00
|
|
|
nsRefPtrHashtable<nsStringHashKey, StyleSheet> mInlineSheets;
|
|
|
|
|
|
|
|
// A set with all the different loads we've done in a given document, for the
|
|
|
|
// purpose of not posting duplicate performance entries for them.
|
|
|
|
nsTHashtable<const SheetLoadDataHashKey> mLoadsPerformed;
|
|
|
|
|
|
|
|
RefPtr<SharedStyleSheetCache> mSheets;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
// The array of posted stylesheet loaded events (SheetLoadDatas) we have.
|
|
|
|
// Note that these are rare.
|
2018-06-22 15:23:28 +03:00
|
|
|
LoadDataArray mPostedEvents;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
|
|
|
// Our array of "global" observers
|
|
|
|
nsTObserverArray<nsCOMPtr<nsICSSLoaderObserver>> mObservers;
|
|
|
|
|
2015-06-16 15:10:00 +03:00
|
|
|
// This reference is nulled by the Document in it's destructor through
|
|
|
|
// DropDocumentReference().
|
2019-11-30 14:57:10 +03:00
|
|
|
dom::Document* MOZ_NON_OWNING_REF mDocument; // the document we live for
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2017-03-13 12:00:57 +03:00
|
|
|
// For dispatching events via DocGroup::Dispatch() when mDocument is nullptr.
|
2019-11-30 14:57:10 +03:00
|
|
|
RefPtr<dom::DocGroup> mDocGroup;
|
2010-03-03 00:00:53 +03:00
|
|
|
|
2020-06-12 02:40:38 +03:00
|
|
|
nsCompatibility mCompatMode;
|
2020-06-11 14:42:46 +03:00
|
|
|
|
2020-06-12 02:40:38 +03:00
|
|
|
nsCOMPtr<nsIConsoleReportCollector> mReporter;
|
2020-06-11 14:42:46 +03:00
|
|
|
|
2020-06-23 05:54:58 +03:00
|
|
|
// Number of datas for asynchronous sheet loads still waiting to be notified.
|
|
|
|
// This includes pending stylesheets whose load hasn't started yet but which
|
|
|
|
// we need to, but not inline or constructable stylesheets, though the
|
|
|
|
// constructable stylesheets bit may change, see bug 1642227.
|
2020-06-12 22:31:32 +03:00
|
|
|
uint32_t mOngoingLoadCount = 0;
|
|
|
|
|
|
|
|
// The number of sheets that have been deferred / are in a pending state.
|
|
|
|
uint32_t mPendingLoadCount = 0;
|
|
|
|
|
|
|
|
// The number of stylesheets that we have parsed, for testing purposes.
|
|
|
|
uint32_t mParsedSheetCount = 0;
|
|
|
|
|
|
|
|
bool mEnabled = true;
|
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
#ifdef DEBUG
|
2019-08-13 08:12:28 +03:00
|
|
|
// Whether we're in a necko callback atm.
|
|
|
|
bool mSyncCallback = false;
|
2010-03-03 00:00:53 +03:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace css
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
#endif /* mozilla_css_Loader_h */
|