Bug 1447828 part 4 - Remove StyleBackendType uses from Loader. r=emilio
MozReview-Commit-ID: 8DbjibZE3Dw
This commit is contained in:
@@ -4566,8 +4566,7 @@ nsIDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// Loading the sheet sync.
|
||||
RefPtr<css::Loader> loader =
|
||||
new css::Loader(GetStyleBackendType(), GetDocGroup());
|
||||
RefPtr<css::Loader> loader = new css::Loader(GetDocGroup());
|
||||
|
||||
css::SheetParsingMode parsingMode;
|
||||
switch (aType) {
|
||||
|
||||
@@ -2378,7 +2378,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
|
||||
elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets);
|
||||
if (!sheets.IsEmpty() && baseURI) {
|
||||
RefPtr<css::Loader> cssLoader =
|
||||
new css::Loader(backendType, aDocument->GetDocGroup());
|
||||
new css::Loader(aDocument->GetDocGroup());
|
||||
|
||||
char *str = ToNewCString(sheets);
|
||||
char *newStr = str;
|
||||
|
||||
@@ -199,10 +199,9 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI,
|
||||
static nsresult
|
||||
LoadSheet(nsIURI* aURI,
|
||||
css::SheetParsingMode aParsingMode,
|
||||
StyleBackendType aType,
|
||||
RefPtr<StyleSheet>* aResult)
|
||||
{
|
||||
RefPtr<css::Loader> loader = new css::Loader(aType, nullptr);
|
||||
RefPtr<css::Loader> loader = new css::Loader;
|
||||
return loader->LoadSheetSync(aURI, aParsingMode, true, aResult);
|
||||
}
|
||||
|
||||
@@ -233,7 +232,7 @@ nsStyleSheetService::LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
|
||||
|
||||
|
||||
RefPtr<StyleSheet> servoSheet;
|
||||
nsresult rv = LoadSheet(aSheetURI, parsingMode, StyleBackendType::Servo, &servoSheet);
|
||||
nsresult rv = LoadSheet(aSheetURI, parsingMode, &servoSheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
MOZ_ASSERT(servoSheet);
|
||||
mServoSheets[aSheetType].AppendElement(servoSheet);
|
||||
|
||||
@@ -367,12 +367,10 @@ LoaderReusableStyleSheets::FindReusableStyleSheet(nsIURI* aURL,
|
||||
* Loader Implementation *
|
||||
*************************/
|
||||
|
||||
Loader::Loader(StyleBackendType aType, DocGroup* aDocGroup)
|
||||
Loader::Loader()
|
||||
: mDocument(nullptr)
|
||||
, mDocGroup(aDocGroup)
|
||||
, mDatasToNotifyOn(0)
|
||||
, mCompatMode(eCompatibility_FullStandards)
|
||||
, mStyleBackendType(Some(aType))
|
||||
, mEnabled(true)
|
||||
, mReporter(new ConsoleReportCollector())
|
||||
#ifdef DEBUG
|
||||
@@ -381,16 +379,16 @@ Loader::Loader(StyleBackendType aType, DocGroup* aDocGroup)
|
||||
{
|
||||
}
|
||||
|
||||
Loader::Loader(nsIDocument* aDocument)
|
||||
: mDocument(aDocument)
|
||||
, mDatasToNotifyOn(0)
|
||||
, mCompatMode(eCompatibility_FullStandards)
|
||||
, mEnabled(true)
|
||||
, mReporter(new ConsoleReportCollector())
|
||||
#ifdef DEBUG
|
||||
, mSyncCallback(false)
|
||||
#endif
|
||||
Loader::Loader(DocGroup* aDocGroup)
|
||||
: Loader()
|
||||
{
|
||||
mDocGroup = aDocGroup;
|
||||
}
|
||||
|
||||
Loader::Loader(nsIDocument* aDocument)
|
||||
: Loader()
|
||||
{
|
||||
mDocument = aDocument;
|
||||
MOZ_ASSERT(mDocument, "We should get a valid document from the caller!");
|
||||
|
||||
// We can just use the preferred set, since there are no sheets in the
|
||||
@@ -1061,11 +1059,7 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
&sriMetadata);
|
||||
}
|
||||
|
||||
if (GetStyleBackendType() == StyleBackendType::Gecko) {
|
||||
MOZ_CRASH("old style system disabled");
|
||||
} else {
|
||||
*aSheet = new ServoStyleSheet(aParsingMode, aCORSMode, aReferrerPolicy, sriMetadata);
|
||||
}
|
||||
*aSheet = new ServoStyleSheet(aParsingMode, aCORSMode, aReferrerPolicy, sriMetadata);
|
||||
(*aSheet)->SetURIs(sheetURI, originalURI, baseURI);
|
||||
}
|
||||
|
||||
@@ -2603,18 +2597,6 @@ Loader::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
return n;
|
||||
}
|
||||
|
||||
StyleBackendType
|
||||
Loader::GetStyleBackendType() const
|
||||
{
|
||||
MOZ_ASSERT(mStyleBackendType || mDocument,
|
||||
"you must construct a Loader with a document or set a "
|
||||
"StyleBackendType on it before calling GetStyleBackendType");
|
||||
if (mStyleBackendType) {
|
||||
return *mStyleBackendType;
|
||||
}
|
||||
return mDocument->GetStyleBackendType();
|
||||
}
|
||||
|
||||
void
|
||||
Loader::BlockOnload()
|
||||
{
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
|
||||
@@ -192,11 +191,11 @@ class Loader final {
|
||||
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
||||
|
||||
public:
|
||||
Loader();
|
||||
// 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.
|
||||
Loader(StyleBackendType aType, mozilla::dom::DocGroup* aDocGroup);
|
||||
|
||||
explicit Loader(mozilla::dom::DocGroup*);
|
||||
explicit Loader(nsIDocument*);
|
||||
|
||||
private:
|
||||
@@ -607,8 +606,6 @@ private:
|
||||
// directly or indirectly @importing the sheet this SheetLoadData represents.
|
||||
void MarkLoadTreeFailed(SheetLoadData* aLoadData);
|
||||
|
||||
StyleBackendType GetStyleBackendType() const;
|
||||
|
||||
struct Sheets {
|
||||
nsBaseHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey,
|
||||
RefPtr<StyleSheet>,
|
||||
@@ -643,10 +640,6 @@ private:
|
||||
nsCompatibility mCompatMode;
|
||||
nsString mPreferredSheet; // title of preferred sheet
|
||||
|
||||
// Set explicitly when the Loader(StyleBackendType) constructor is used, or
|
||||
// taken from the document when the Loader(nsIDocument*) constructor is used.
|
||||
mozilla::Maybe<StyleBackendType> mStyleBackendType;
|
||||
|
||||
bool mEnabled; // is enabled to load new styles
|
||||
|
||||
nsCOMPtr<nsIConsoleReportCollector> mReporter;
|
||||
|
||||
@@ -58,7 +58,7 @@ PreloadedStyleSheet::GetSheet(StyleBackendType aType, StyleSheet** aResult)
|
||||
aType == StyleBackendType::Gecko ? mGecko : mServo;
|
||||
|
||||
if (!sheet) {
|
||||
RefPtr<css::Loader> loader = new css::Loader(aType, nullptr);
|
||||
RefPtr<css::Loader> loader = new css::Loader;
|
||||
nsresult rv = loader->LoadSheetSync(mURI, mParsingMode, true, &sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
MOZ_ASSERT(sheet);
|
||||
@@ -119,8 +119,7 @@ PreloadedStyleSheet::PreloadAsync(NotNull<dom::Promise*> aPromise)
|
||||
|
||||
RefPtr<StyleSheet>& sheet = mServo;
|
||||
|
||||
RefPtr<css::Loader> loader =
|
||||
new css::Loader(StyleBackendType::Servo, nullptr);
|
||||
RefPtr<css::Loader> loader = new css::Loader;
|
||||
|
||||
RefPtr<StylesheetPreloadObserver> obs =
|
||||
new StylesheetPreloadObserver(aPromise, this);
|
||||
|
||||
@@ -279,7 +279,7 @@ ServoStyleSheet::ReparseSheet(const nsAString& aInput)
|
||||
loader = mDocument->CSSLoader();
|
||||
NS_ASSERTION(loader, "Document with no CSS loader!");
|
||||
} else {
|
||||
loader = new css::Loader(StyleBackendType::Servo, nullptr);
|
||||
loader = new css::Loader;
|
||||
}
|
||||
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, true);
|
||||
|
||||
@@ -803,7 +803,7 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
|
||||
gCSSLoader_Servo;
|
||||
|
||||
if (!loader) {
|
||||
loader = new Loader(mBackendType, nullptr);
|
||||
loader = new Loader;
|
||||
if (!loader) {
|
||||
ErrorLoadingSheet(aURI, "no Loader", eCrash);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user