зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1447828 part 7 - Remove StyleBackendType uses from PreloadedStyleSheet. r=emilio
MozReview-Commit-ID: L37tnRAAJbQ --HG-- extra : rebase_source : 1d073c4fadcc8372b5afe55f648bcb1c276f4de2 extra : source : 09e1b57c52fbfe3145b47d80ac098c487970d8b4
This commit is contained in:
Родитель
d81392eca1
Коммит
5c55e4b983
|
@ -3541,7 +3541,7 @@ nsDOMWindowUtils::AddSheet(nsIPreloadedStyleSheet* aSheet, uint32_t aSheetType)
|
||||||
|
|
||||||
StyleSheet* sheet = nullptr;
|
StyleSheet* sheet = nullptr;
|
||||||
auto preloadedSheet = static_cast<PreloadedStyleSheet*>(aSheet);
|
auto preloadedSheet = static_cast<PreloadedStyleSheet*>(aSheet);
|
||||||
nsresult rv = preloadedSheet->GetSheet(doc->GetStyleBackendType(), &sheet);
|
nsresult rv = preloadedSheet->GetSheet(&sheet);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
|
|
@ -45,26 +45,23 @@ NS_INTERFACE_MAP_END
|
||||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(PreloadedStyleSheet)
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(PreloadedStyleSheet)
|
||||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(PreloadedStyleSheet)
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(PreloadedStyleSheet)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION(PreloadedStyleSheet, mGecko, mServo)
|
NS_IMPL_CYCLE_COLLECTION(PreloadedStyleSheet, mSheet)
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
PreloadedStyleSheet::GetSheet(StyleBackendType aType, StyleSheet** aResult)
|
PreloadedStyleSheet::GetSheet(StyleSheet** aResult)
|
||||||
{
|
{
|
||||||
*aResult = nullptr;
|
*aResult = nullptr;
|
||||||
|
|
||||||
MOZ_DIAGNOSTIC_ASSERT(mLoaded);
|
MOZ_DIAGNOSTIC_ASSERT(mLoaded);
|
||||||
|
|
||||||
RefPtr<StyleSheet>& sheet =
|
if (!mSheet) {
|
||||||
aType == StyleBackendType::Gecko ? mGecko : mServo;
|
|
||||||
|
|
||||||
if (!sheet) {
|
|
||||||
RefPtr<css::Loader> loader = new css::Loader;
|
RefPtr<css::Loader> loader = new css::Loader;
|
||||||
nsresult rv = loader->LoadSheetSync(mURI, mParsingMode, true, &sheet);
|
nsresult rv = loader->LoadSheetSync(mURI, mParsingMode, true, &mSheet);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
MOZ_ASSERT(sheet);
|
MOZ_ASSERT(mSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
*aResult = sheet;
|
*aResult = mSheet;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +85,7 @@ PreloadedStyleSheet::Preload()
|
||||||
mLoaded = true;
|
mLoaded = true;
|
||||||
|
|
||||||
StyleSheet* sheet;
|
StyleSheet* sheet;
|
||||||
return GetSheet(StyleBackendType::Servo, &sheet);
|
return GetSheet(&sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(PreloadedStyleSheet::StylesheetPreloadObserver,
|
NS_IMPL_ISUPPORTS(PreloadedStyleSheet::StylesheetPreloadObserver,
|
||||||
|
@ -117,14 +114,12 @@ PreloadedStyleSheet::PreloadAsync(NotNull<dom::Promise*> aPromise)
|
||||||
{
|
{
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mLoaded);
|
MOZ_DIAGNOSTIC_ASSERT(!mLoaded);
|
||||||
|
|
||||||
RefPtr<StyleSheet>& sheet = mServo;
|
|
||||||
|
|
||||||
RefPtr<css::Loader> loader = new css::Loader;
|
RefPtr<css::Loader> loader = new css::Loader;
|
||||||
|
|
||||||
RefPtr<StylesheetPreloadObserver> obs =
|
RefPtr<StylesheetPreloadObserver> obs =
|
||||||
new StylesheetPreloadObserver(aPromise, this);
|
new StylesheetPreloadObserver(aPromise, this);
|
||||||
|
|
||||||
return loader->LoadSheet(mURI, mParsingMode, false, obs, &sheet);
|
return loader->LoadSheet(mURI, mParsingMode, false, obs, &mSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "mozilla/css/SheetParsingMode.h"
|
#include "mozilla/css/SheetParsingMode.h"
|
||||||
#include "mozilla/NotNull.h"
|
#include "mozilla/NotNull.h"
|
||||||
#include "mozilla/Result.h"
|
#include "mozilla/Result.h"
|
||||||
#include "mozilla/StyleBackendType.h"
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsICSSLoaderObserver.h"
|
#include "nsICSSLoaderObserver.h"
|
||||||
|
@ -39,7 +38,7 @@ public:
|
||||||
|
|
||||||
// *aResult is not addrefed, since the PreloadedStyleSheet holds a strong
|
// *aResult is not addrefed, since the PreloadedStyleSheet holds a strong
|
||||||
// reference to the sheet.
|
// reference to the sheet.
|
||||||
nsresult GetSheet(StyleBackendType aType, StyleSheet** aResult);
|
nsresult GetSheet(StyleSheet** aResult);
|
||||||
|
|
||||||
nsresult Preload();
|
nsresult Preload();
|
||||||
nsresult PreloadAsync(NotNull<dom::Promise*> aPromise);
|
nsresult PreloadAsync(NotNull<dom::Promise*> aPromise);
|
||||||
|
@ -73,8 +72,7 @@ private:
|
||||||
RefPtr<PreloadedStyleSheet> mPreloadedSheet;
|
RefPtr<PreloadedStyleSheet> mPreloadedSheet;
|
||||||
};
|
};
|
||||||
|
|
||||||
RefPtr<StyleSheet> mGecko;
|
RefPtr<StyleSheet> mSheet;
|
||||||
RefPtr<StyleSheet> mServo;
|
|
||||||
|
|
||||||
bool mLoaded;
|
bool mLoaded;
|
||||||
nsCOMPtr<nsIURI> mURI;
|
nsCOMPtr<nsIURI> mURI;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче