зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1599161 - Rename nsLayoutStylesheetCache to GlobalStyleSheetCache. r=boris
It's a better name, and will avoid confusion when I add other stylesheet caches outside of the CSS loader. Depends on D54556 Differential Revision: https://phabricator.services.mozilla.com/D54557 --HG-- rename : layout/style/nsLayoutStylesheetCache.cpp => layout/style/GlobalStyleSheetCache.cpp rename : layout/style/nsLayoutStylesheetCache.h => layout/style/GlobalStyleSheetCache.h extra : moz-landing-system : lando
This commit is contained in:
Родитель
3e643f22f1
Коммит
0eb000c3ae
|
@ -65,7 +65,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/GlobalStyleSheetCache.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/css/ImageLoader.h"
|
||||
#include "nsDocShell.h"
|
||||
|
@ -2616,7 +2616,7 @@ void Document::FillStyleSetUserAndUASheets() {
|
|||
// ordering.
|
||||
|
||||
// The document will fill in the document sheets when we create the presshell
|
||||
auto cache = nsLayoutStylesheetCache::Singleton();
|
||||
auto* cache = GlobalStyleSheetCache::Singleton();
|
||||
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
||||
MOZ_ASSERT(sheetService,
|
||||
|
@ -2691,7 +2691,7 @@ void Document::FillStyleSet() {
|
|||
void Document::RemoveContentEditableStyleSheets() {
|
||||
MOZ_ASSERT(IsHTMLOrXHTML());
|
||||
|
||||
auto* cache = nsLayoutStylesheetCache::Singleton();
|
||||
auto* cache = GlobalStyleSheetCache::Singleton();
|
||||
bool changed = false;
|
||||
if (mDesignModeSheetAdded) {
|
||||
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent,
|
||||
|
@ -2716,7 +2716,7 @@ void Document::AddContentEditableStyleSheetsToStyleSet(bool aDesignMode) {
|
|||
MOZ_DIAGNOSTIC_ASSERT(mStyleSetFilled,
|
||||
"Caller should ensure we're being rendered");
|
||||
|
||||
auto* cache = nsLayoutStylesheetCache::Singleton();
|
||||
auto* cache = GlobalStyleSheetCache::Singleton();
|
||||
bool changed = false;
|
||||
if (!mContentEditableSheetAdded) {
|
||||
mStyleSet->AppendStyleSheet(StyleOrigin::UserAgent,
|
||||
|
@ -2779,7 +2779,7 @@ void Document::CompatibilityModeChanged() {
|
|||
if (mQuirkSheetAdded == NeedsQuirksSheet()) {
|
||||
return;
|
||||
}
|
||||
auto cache = nsLayoutStylesheetCache::Singleton();
|
||||
auto* cache = GlobalStyleSheetCache::Singleton();
|
||||
StyleSheet* sheet = cache->QuirkSheet();
|
||||
if (mQuirkSheetAdded) {
|
||||
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent, sheet);
|
||||
|
|
|
@ -105,7 +105,6 @@
|
|||
#include "nsIFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIStructuredCloneContainer.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
#include "SandboxHal.h"
|
||||
#include "nsDebugImpl.h"
|
||||
#include "nsHashPropertyBag.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/GlobalStyleSheetCache.h"
|
||||
#include "nsThreadManager.h"
|
||||
#include "nsAnonymousTemporaryFile.h"
|
||||
#include "nsClipboardProxy.h"
|
||||
|
@ -1330,7 +1330,7 @@ void ContentChild::InitSharedUASheets(const Maybe<SharedMemoryHandle>& aHandle,
|
|||
// Map the shared memory storing the user agent style sheets. Do this as
|
||||
// early as possible to maximize the chance of being able to map at the
|
||||
// address we want.
|
||||
nsLayoutStylesheetCache::SetSharedMemory(*aHandle, aAddress);
|
||||
GlobalStyleSheetCache::SetSharedMemory(*aHandle, aAddress);
|
||||
}
|
||||
|
||||
void ContentChild::InitXPCOM(
|
||||
|
@ -1417,7 +1417,7 @@ void ContentChild::InitXPCOM(
|
|||
|
||||
// The stylesheet cache is not ready yet. Store this URL for future use.
|
||||
nsCOMPtr<nsIURI> ucsURL = DeserializeURI(aXPCOMInit.userContentSheetURL());
|
||||
nsLayoutStylesheetCache::SetUserContentCSSURL(ucsURL);
|
||||
GlobalStyleSheetCache::SetUserContentCSSURL(ucsURL);
|
||||
|
||||
GfxInfoBase::SetFeatureStatus(aXPCOMInit.gfxFeatureStatus());
|
||||
|
||||
|
|
|
@ -224,12 +224,12 @@
|
|||
#include "nsPluginTags.h"
|
||||
#include "nsIBlocklistService.h"
|
||||
#include "nsITrackingDBService.h"
|
||||
#include "mozilla/GlobalStyleSheetCache.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "nsICaptivePortalService.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsIBidiKeyboard.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "MMPrinter.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsIAsyncInputStream.h"
|
||||
|
@ -2488,8 +2488,8 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
|||
|
||||
// Content processes have no permission to access profile directory, so we
|
||||
// send the file URL instead.
|
||||
StyleSheet* ucs = nsLayoutStylesheetCache::Singleton()->GetUserContentSheet();
|
||||
if (ucs) {
|
||||
auto* sheetCache = GlobalStyleSheetCache::Singleton();
|
||||
if (StyleSheet* ucs = sheetCache->GetUserContentSheet()) {
|
||||
SerializeURI(ucs->GetSheetURI(), xpcomInit.userContentSheetURL());
|
||||
} else {
|
||||
SerializeURI(nullptr, xpcomInit.userContentSheetURL());
|
||||
|
@ -2519,12 +2519,11 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
|||
screenManager.CopyScreensToRemote(this);
|
||||
|
||||
// Send the UA sheet shared memory buffer and the address it is mapped at.
|
||||
auto cache = nsLayoutStylesheetCache::Singleton();
|
||||
Maybe<SharedMemoryHandle> sharedUASheetHandle;
|
||||
uintptr_t sharedUASheetAddress = cache->GetSharedMemoryAddress();
|
||||
uintptr_t sharedUASheetAddress = sheetCache->GetSharedMemoryAddress();
|
||||
|
||||
SharedMemoryHandle handle;
|
||||
if (cache->ShareToProcess(OtherPid(), &handle)) {
|
||||
if (sheetCache->ShareToProcess(OtherPid(), &handle)) {
|
||||
sharedUASheetHandle.emplace(handle);
|
||||
} else {
|
||||
sharedUASheetAddress = 0;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "nsGkAtoms.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsITableCellLayout.h" // for MAX_COLSPAN / MAX_ROWSPAN
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "nsCSSValue.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIStyleSheetService.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "DOMSVGNumber.h"
|
||||
#include "DOMSVGPoint.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsISVGSVGFrame.h"
|
||||
#include "nsSVGDisplayableFrame.h"
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsSubDocumentFrame.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/GlobalStyleSheetCache.h"
|
||||
#include "mozilla/layers/InputAPZContext.h"
|
||||
#include "mozilla/layers/FocusTarget.h"
|
||||
#include "mozilla/layers/WebRenderLayerManager.h"
|
||||
|
@ -1452,7 +1452,7 @@ void PresShell::UpdatePreferenceStyles() {
|
|||
}
|
||||
|
||||
PreferenceSheet::EnsureInitialized();
|
||||
auto cache = nsLayoutStylesheetCache::Singleton();
|
||||
auto* cache = GlobalStyleSheetCache::Singleton();
|
||||
|
||||
RefPtr<StyleSheet> newPrefSheet =
|
||||
PreferenceSheet::ShouldUseChromePrefs(*mDocument)
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "nsISelectionListener.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#ifdef ACCESSIBILITY
|
||||
# include "mozilla/a11y/DocAccessible.h"
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "nsFontFaceUtils.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/GlobalStyleSheetCache.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/StaticPrefs_zoom.h"
|
||||
|
@ -532,7 +532,7 @@ void nsPresContext::PreferenceChanged(const char* aPrefName) {
|
|||
//
|
||||
// The first pres context that has its pref changed runnable called will
|
||||
// be the one to cause the reconstruction of the pref style sheet.
|
||||
nsLayoutStylesheetCache::InvalidatePreferenceSheets();
|
||||
GlobalStyleSheetCache::InvalidatePreferenceSheets();
|
||||
PreferenceSheet::Refresh();
|
||||
DispatchPrefChangedRunnableIfNeeded();
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "nsGlobalWindow.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/GlobalStyleSheetCache.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsRepeatService.h"
|
||||
|
@ -376,7 +376,7 @@ void nsLayoutStatics::Shutdown() {
|
|||
|
||||
nsAttrValue::Shutdown();
|
||||
nsContentUtils::Shutdown();
|
||||
nsLayoutStylesheetCache::Shutdown();
|
||||
GlobalStyleSheetCache::Shutdown();
|
||||
|
||||
ShutdownJSEnvironment();
|
||||
nsGlobalWindowInner::ShutDown();
|
||||
|
|
|
@ -83,7 +83,6 @@ static const char kPrintingPromptService[] =
|
|||
#include "nsContentCID.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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/. */
|
||||
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "GlobalStyleSheetCache.h"
|
||||
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
@ -31,11 +31,13 @@
|
|||
|
||||
#include <mozilla/ServoBindings.h>
|
||||
|
||||
// The nsLayoutStylesheetCache is responsible for sharing user agent style sheet
|
||||
namespace mozilla {
|
||||
|
||||
// The GlobalStyleSheetCache is responsible for sharing user agent style sheet
|
||||
// contents across processes using shared memory. Here is a high level view of
|
||||
// how that works:
|
||||
//
|
||||
// * In the parent process, in the nsLayoutStylesheetCache constructor (which is
|
||||
// * In the parent process, in the GlobalStyleSheetCache constructor (which is
|
||||
// called early on in a process' lifetime), we parse all UA style sheets into
|
||||
// Gecko StyleSheet objects.
|
||||
//
|
||||
|
@ -91,7 +93,7 @@
|
|||
// * In the child process, as early as possible (in
|
||||
// ContentChild::InitSharedUASheets), we try to map the shared memory at that
|
||||
// same address, then pass the shared memory buffer to
|
||||
// nsLayoutStylesheetCache::SetSharedMemory. Since we map at the same
|
||||
// GlobalStyleSheetCache::SetSharedMemory. Since we map at the same
|
||||
// address, this means any internal pointers in the UA sheets back into the
|
||||
// shared memory buffer that were written by the parent process are valid in
|
||||
// the child process too.
|
||||
|
@ -106,11 +108,11 @@ using namespace mozilla::css;
|
|||
#define PREF_LEGACY_STYLESHEET_CUSTOMIZATION \
|
||||
"toolkit.legacyUserProfileCustomizations.stylesheets"
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsLayoutStylesheetCache, nsIObserver, nsIMemoryReporter)
|
||||
NS_IMPL_ISUPPORTS(GlobalStyleSheetCache, nsIObserver, nsIMemoryReporter)
|
||||
|
||||
nsresult nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
nsresult GlobalStyleSheetCache::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
if (!strcmp(aTopic, "profile-before-change")) {
|
||||
mUserContentSheet = nullptr;
|
||||
mUserChromeSheet = nullptr;
|
||||
|
@ -123,7 +125,7 @@ nsresult nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
|
|||
}
|
||||
|
||||
#define STYLE_SHEET(identifier_, url_, shared_) \
|
||||
NotNull<StyleSheet*> nsLayoutStylesheetCache::identifier_##Sheet() { \
|
||||
NotNull<StyleSheet*> GlobalStyleSheetCache::identifier_##Sheet() { \
|
||||
if (!m##identifier_##Sheet) { \
|
||||
m##identifier_##Sheet = LoadSheetURL(url_, eAgentSheetFeatures, eCrash); \
|
||||
} \
|
||||
|
@ -132,15 +134,15 @@ nsresult nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
|
|||
#include "mozilla/UserAgentStyleSheetList.h"
|
||||
#undef STYLE_SHEET
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::GetUserContentSheet() {
|
||||
StyleSheet* GlobalStyleSheetCache::GetUserContentSheet() {
|
||||
return mUserContentSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::GetUserChromeSheet() {
|
||||
StyleSheet* GlobalStyleSheetCache::GetUserChromeSheet() {
|
||||
return mUserChromeSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::ChromePreferenceSheet() {
|
||||
StyleSheet* GlobalStyleSheetCache::ChromePreferenceSheet() {
|
||||
if (!mChromePreferenceSheet) {
|
||||
BuildPreferenceSheet(&mChromePreferenceSheet,
|
||||
PreferenceSheet::ChromePrefs());
|
||||
|
@ -149,7 +151,7 @@ StyleSheet* nsLayoutStylesheetCache::ChromePreferenceSheet() {
|
|||
return mChromePreferenceSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::ContentPreferenceSheet() {
|
||||
StyleSheet* GlobalStyleSheetCache::ContentPreferenceSheet() {
|
||||
if (!mContentPreferenceSheet) {
|
||||
BuildPreferenceSheet(&mContentPreferenceSheet,
|
||||
PreferenceSheet::ContentPrefs());
|
||||
|
@ -158,7 +160,7 @@ StyleSheet* nsLayoutStylesheetCache::ContentPreferenceSheet() {
|
|||
return mContentPreferenceSheet;
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::Shutdown() {
|
||||
void GlobalStyleSheetCache::Shutdown() {
|
||||
gCSSLoader = nullptr;
|
||||
NS_WARNING_ASSERTION(!gStyleCache || !gUserContentSheetURL,
|
||||
"Got the URL but never used?");
|
||||
|
@ -171,7 +173,7 @@ void nsLayoutStylesheetCache::Shutdown() {
|
|||
// potential DOM references and such that chrome code may have created.
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::SetUserContentCSSURL(nsIURI* aURI) {
|
||||
void GlobalStyleSheetCache::SetUserContentCSSURL(nsIURI* aURI) {
|
||||
MOZ_ASSERT(XRE_IsContentProcess(), "Only used in content processes.");
|
||||
gUserContentSheetURL = aURI;
|
||||
}
|
||||
|
@ -179,8 +181,8 @@ void nsLayoutStylesheetCache::SetUserContentCSSURL(nsIURI* aURI) {
|
|||
MOZ_DEFINE_MALLOC_SIZE_OF(LayoutStylesheetCacheMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutStylesheetCache::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData, bool aAnonymize) {
|
||||
GlobalStyleSheetCache::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData, bool aAnonymize) {
|
||||
MOZ_COLLECT_REPORT("explicit/layout/style-sheet-cache/unshared", KIND_HEAP,
|
||||
UNITS_BYTES,
|
||||
SizeOfIncludingThis(LayoutStylesheetCacheMallocSizeOf),
|
||||
|
@ -198,7 +200,7 @@ nsLayoutStylesheetCache::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
size_t nsLayoutStylesheetCache::SizeOfIncludingThis(
|
||||
size_t GlobalStyleSheetCache::SizeOfIncludingThis(
|
||||
mozilla::MallocSizeOf aMallocSizeOf) const {
|
||||
size_t n = aMallocSizeOf(this);
|
||||
|
||||
|
@ -220,7 +222,7 @@ size_t nsLayoutStylesheetCache::SizeOfIncludingThis(
|
|||
return n;
|
||||
}
|
||||
|
||||
nsLayoutStylesheetCache::nsLayoutStylesheetCache() {
|
||||
GlobalStyleSheetCache::GlobalStyleSheetCache() {
|
||||
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
|
||||
NS_ASSERTION(obsSvc, "No global observer service?");
|
||||
|
||||
|
@ -259,7 +261,7 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache() {
|
|||
// Use the shared memory handle that was given to us by a SetSharedMemory
|
||||
// call under ContentChild::InitXPCOM.
|
||||
MOZ_ASSERT(sSharedMemory->memory(),
|
||||
"nsLayoutStylesheetCache::SetSharedMemory should have mapped "
|
||||
"GlobalStyleSheetCache::SetSharedMemory should have mapped "
|
||||
"the shared memory");
|
||||
}
|
||||
}
|
||||
|
@ -281,11 +283,11 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache() {
|
|||
if (auto header = static_cast<Header*>(sSharedMemory->memory())) {
|
||||
MOZ_RELEASE_ASSERT(header->mMagic == Header::kMagic);
|
||||
|
||||
#define STYLE_SHEET(identifier_, url_, shared_) \
|
||||
if (shared_) { \
|
||||
LoadSheetFromSharedMemory(url_, &m##identifier_##Sheet, \
|
||||
eAgentSheetFeatures, header, \
|
||||
UserAgentStyleSheetID::identifier_); \
|
||||
#define STYLE_SHEET(identifier_, url_, shared_) \
|
||||
if (shared_) { \
|
||||
LoadSheetFromSharedMemory(url_, &m##identifier_##Sheet, \
|
||||
eAgentSheetFeatures, header, \
|
||||
UserAgentStyleSheetID::identifier_); \
|
||||
}
|
||||
#include "mozilla/UserAgentStyleSheetList.h"
|
||||
#undef STYLE_SHEET
|
||||
|
@ -293,7 +295,7 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache() {
|
|||
}
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::LoadSheetFromSharedMemory(
|
||||
void GlobalStyleSheetCache::LoadSheetFromSharedMemory(
|
||||
const char* aURL, RefPtr<StyleSheet>* aSheet, SheetParsingMode aParsingMode,
|
||||
Header* aHeader, UserAgentStyleSheetID aSheetID) {
|
||||
auto i = size_t(aSheetID);
|
||||
|
@ -317,7 +319,7 @@ void nsLayoutStylesheetCache::LoadSheetFromSharedMemory(
|
|||
*aSheet = sheet.forget();
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::InitSharedSheetsInParent() {
|
||||
void GlobalStyleSheetCache::InitSharedSheetsInParent() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_RELEASE_ASSERT(!sSharedMemory);
|
||||
|
||||
|
@ -426,20 +428,20 @@ void nsLayoutStylesheetCache::InitSharedSheetsInParent() {
|
|||
sSharedMemory = shm.release();
|
||||
}
|
||||
|
||||
nsLayoutStylesheetCache::~nsLayoutStylesheetCache() {
|
||||
GlobalStyleSheetCache::~GlobalStyleSheetCache() {
|
||||
mozilla::UnregisterWeakMemoryReporter(this);
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::InitMemoryReporter() {
|
||||
void GlobalStyleSheetCache::InitMemoryReporter() {
|
||||
mozilla::RegisterWeakMemoryReporter(this);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsLayoutStylesheetCache* nsLayoutStylesheetCache::Singleton() {
|
||||
GlobalStyleSheetCache* GlobalStyleSheetCache::Singleton() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!gStyleCache) {
|
||||
gStyleCache = new nsLayoutStylesheetCache;
|
||||
gStyleCache = new GlobalStyleSheetCache;
|
||||
gStyleCache->InitMemoryReporter();
|
||||
|
||||
// For each pref that controls a CSS feature that a UA style sheet depends
|
||||
|
@ -453,7 +455,7 @@ nsLayoutStylesheetCache* nsLayoutStylesheetCache::Singleton() {
|
|||
return gStyleCache;
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::InitFromProfile() {
|
||||
void GlobalStyleSheetCache::InitFromProfile() {
|
||||
if (!Preferences::GetBool(PREF_LEGACY_STYLESHEET_CUSTOMIZATION)) {
|
||||
return;
|
||||
}
|
||||
|
@ -484,7 +486,7 @@ void nsLayoutStylesheetCache::InitFromProfile() {
|
|||
mUserChromeSheet = LoadSheetFile(chromeFile, eUserSheetFeatures);
|
||||
}
|
||||
|
||||
RefPtr<StyleSheet> nsLayoutStylesheetCache::LoadSheetURL(
|
||||
RefPtr<StyleSheet> GlobalStyleSheetCache::LoadSheetURL(
|
||||
const char* aURL, SheetParsingMode aParsingMode,
|
||||
FailureAction aFailureAction) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -492,7 +494,7 @@ RefPtr<StyleSheet> nsLayoutStylesheetCache::LoadSheetURL(
|
|||
return LoadSheet(uri, aParsingMode, aFailureAction);
|
||||
}
|
||||
|
||||
RefPtr<StyleSheet> nsLayoutStylesheetCache::LoadSheetFile(
|
||||
RefPtr<StyleSheet> GlobalStyleSheetCache::LoadSheetFile(
|
||||
nsIFile* aFile, SheetParsingMode aParsingMode) {
|
||||
bool exists = false;
|
||||
aFile->Exists(&exists);
|
||||
|
@ -521,7 +523,7 @@ static void ErrorLoadingSheet(nsIURI* aURI, const char* aMsg,
|
|||
MOZ_CRASH_UNSAFE(errorMessage.get());
|
||||
}
|
||||
|
||||
RefPtr<StyleSheet> nsLayoutStylesheetCache::LoadSheet(
|
||||
RefPtr<StyleSheet> GlobalStyleSheetCache::LoadSheet(
|
||||
nsIURI* aURI, SheetParsingMode aParsingMode, FailureAction aFailureAction) {
|
||||
if (!aURI) {
|
||||
ErrorLoadingSheet(aURI, "null URI", eCrash);
|
||||
|
@ -555,14 +557,14 @@ RefPtr<StyleSheet> nsLayoutStylesheetCache::LoadSheet(
|
|||
}
|
||||
|
||||
/* static */
|
||||
void nsLayoutStylesheetCache::InvalidatePreferenceSheets() {
|
||||
void GlobalStyleSheetCache::InvalidatePreferenceSheets() {
|
||||
if (gStyleCache) {
|
||||
gStyleCache->mContentPreferenceSheet = nullptr;
|
||||
gStyleCache->mChromePreferenceSheet = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::BuildPreferenceSheet(
|
||||
void GlobalStyleSheetCache::BuildPreferenceSheet(
|
||||
RefPtr<StyleSheet>* aSheet, const PreferenceSheet::Prefs& aPrefs) {
|
||||
*aSheet = new StyleSheet(eAgentSheetFeatures, CORS_NONE, dom::SRIMetadata());
|
||||
|
||||
|
@ -662,11 +664,10 @@ void nsLayoutStylesheetCache::BuildPreferenceSheet(
|
|||
#undef NS_GET_R_G_B
|
||||
}
|
||||
|
||||
/* static */ void nsLayoutStylesheetCache::SetSharedMemory(
|
||||
/* static */ void GlobalStyleSheetCache::SetSharedMemory(
|
||||
const base::SharedMemoryHandle& aHandle, uintptr_t aAddress) {
|
||||
MOZ_ASSERT(!XRE_IsParentProcess());
|
||||
MOZ_ASSERT(!gStyleCache,
|
||||
"Too late, nsLayoutStylesheetCache already created!");
|
||||
MOZ_ASSERT(!gStyleCache, "Too late, GlobalStyleSheetCache already created!");
|
||||
MOZ_ASSERT(!sSharedMemory, "Shouldn't call this more than once");
|
||||
|
||||
auto shm = MakeUnique<base::SharedMemory>();
|
||||
|
@ -683,18 +684,17 @@ void nsLayoutStylesheetCache::BuildPreferenceSheet(
|
|||
}
|
||||
}
|
||||
|
||||
bool nsLayoutStylesheetCache::ShareToProcess(
|
||||
base::ProcessId aProcessId, base::SharedMemoryHandle* aHandle) {
|
||||
bool GlobalStyleSheetCache::ShareToProcess(base::ProcessId aProcessId,
|
||||
base::SharedMemoryHandle* aHandle) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
return sSharedMemory && sSharedMemory->ShareToProcess(aProcessId, aHandle);
|
||||
}
|
||||
|
||||
mozilla::StaticRefPtr<nsLayoutStylesheetCache>
|
||||
nsLayoutStylesheetCache::gStyleCache;
|
||||
StaticRefPtr<GlobalStyleSheetCache> GlobalStyleSheetCache::gStyleCache;
|
||||
StaticRefPtr<css::Loader> GlobalStyleSheetCache::gCSSLoader;
|
||||
StaticRefPtr<nsIURI> GlobalStyleSheetCache::gUserContentSheetURL;
|
||||
|
||||
mozilla::StaticRefPtr<mozilla::css::Loader> nsLayoutStylesheetCache::gCSSLoader;
|
||||
StaticAutoPtr<base::SharedMemory> GlobalStyleSheetCache::sSharedMemory;
|
||||
size_t GlobalStyleSheetCache::sUsedSharedMemory;
|
||||
|
||||
mozilla::StaticRefPtr<nsIURI> nsLayoutStylesheetCache::gUserContentSheetURL;
|
||||
|
||||
StaticAutoPtr<base::SharedMemory> nsLayoutStylesheetCache::sSharedMemory;
|
||||
size_t nsLayoutStylesheetCache::sUsedSharedMemory;
|
||||
} // namespace mozilla
|
|
@ -4,8 +4,8 @@
|
|||
* 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 nsLayoutStylesheetCache_h__
|
||||
#define nsLayoutStylesheetCache_h__
|
||||
#ifndef mozilla_GlobalStyleSheetCache_h__
|
||||
#define mozilla_GlobalStyleSheetCache_h__
|
||||
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserver.h"
|
||||
|
@ -31,16 +31,15 @@ namespace css {
|
|||
enum FailureAction { eCrash = 0, eLogToConsole };
|
||||
|
||||
} // namespace css
|
||||
} // namespace mozilla
|
||||
|
||||
class nsLayoutStylesheetCache final : public nsIObserver,
|
||||
public nsIMemoryReporter {
|
||||
class GlobalStyleSheetCache final : public nsIObserver,
|
||||
public nsIMemoryReporter {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIMEMORYREPORTER
|
||||
|
||||
static nsLayoutStylesheetCache* Singleton();
|
||||
static GlobalStyleSheetCache* Singleton();
|
||||
|
||||
#define STYLE_SHEET(identifier_, url_, shared_) \
|
||||
mozilla::NotNull<mozilla::StyleSheet*> identifier_##Sheet();
|
||||
|
@ -62,7 +61,7 @@ class nsLayoutStylesheetCache final : public nsIObserver,
|
|||
|
||||
// Set the shared memory segment to load the shared UA sheets from.
|
||||
// Called early on in a content process' life from
|
||||
// ContentChild::InitSharedUASheets, before the nsLayoutStylesheetCache
|
||||
// ContentChild::InitSharedUASheets, before the GlobalStyleSheetCache
|
||||
// singleton has been created.
|
||||
static void SetSharedMemory(const base::SharedMemoryHandle& aHandle,
|
||||
uintptr_t aAddress);
|
||||
|
@ -95,8 +94,8 @@ class nsLayoutStylesheetCache final : public nsIObserver,
|
|||
uint8_t mBuffer[1];
|
||||
};
|
||||
|
||||
nsLayoutStylesheetCache();
|
||||
~nsLayoutStylesheetCache();
|
||||
GlobalStyleSheetCache();
|
||||
~GlobalStyleSheetCache();
|
||||
|
||||
void InitFromProfile();
|
||||
void InitSharedSheetsInParent();
|
||||
|
@ -111,12 +110,12 @@ class nsLayoutStylesheetCache final : public nsIObserver,
|
|||
mozilla::css::FailureAction aFailureAction);
|
||||
void LoadSheetFromSharedMemory(const char* aURL,
|
||||
RefPtr<mozilla::StyleSheet>* aSheet,
|
||||
mozilla::css::SheetParsingMode,
|
||||
Header*, mozilla::UserAgentStyleSheetID);
|
||||
mozilla::css::SheetParsingMode, Header*,
|
||||
mozilla::UserAgentStyleSheetID);
|
||||
void BuildPreferenceSheet(RefPtr<mozilla::StyleSheet>* aSheet,
|
||||
const mozilla::PreferenceSheet::Prefs&);
|
||||
|
||||
static mozilla::StaticRefPtr<nsLayoutStylesheetCache> gStyleCache;
|
||||
static mozilla::StaticRefPtr<GlobalStyleSheetCache> gStyleCache;
|
||||
static mozilla::StaticRefPtr<mozilla::css::Loader> gCSSLoader;
|
||||
static mozilla::StaticRefPtr<nsIURI> gUserContentSheetURL;
|
||||
|
||||
|
@ -138,4 +137,6 @@ class nsLayoutStylesheetCache final : public nsIObserver,
|
|||
static size_t sUsedSharedMemory;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -23,7 +23,6 @@
|
|||
#include "mozilla/StyleSheetInlines.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "SheetLoadData.h"
|
||||
#include "nsIReferrerInfo.h"
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsIReferrerInfo.h"
|
||||
|
||||
class nsLayoutStylesheetCache;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct URLExtraData {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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/. */
|
||||
|
||||
/* list of user agent style sheets that nsLayoutStylesheetCache manages */
|
||||
/* list of user agent style sheets that GlobalStyleSheetCache manages */
|
||||
|
||||
/*
|
||||
* STYLE_SHEET(identifier_, url_, shared_)
|
||||
|
|
|
@ -56,7 +56,6 @@ EXPORTS += [
|
|||
'nsDOMCSSDeclaration.h',
|
||||
'nsICSSDeclaration.h',
|
||||
'nsICSSLoaderObserver.h',
|
||||
'nsLayoutStylesheetCache.h',
|
||||
'nsMediaFeatures.h',
|
||||
'nsStyleAutoArray.h',
|
||||
'nsStyleConsts.h',
|
||||
|
@ -81,6 +80,7 @@ EXPORTS.mozilla += [
|
|||
'DeclarationBlock.h',
|
||||
'DocumentStyleRootIterator.h',
|
||||
'GeckoBindings.h',
|
||||
'GlobalStyleSheetCache.h',
|
||||
'ImportScanner.h',
|
||||
'LayerAnimationInfo.h',
|
||||
'MappedDeclarations.h',
|
||||
|
@ -181,6 +181,7 @@ UNIFIED_SOURCES += [
|
|||
'FontFaceSet.cpp',
|
||||
'FontFaceSetIterator.cpp',
|
||||
'GeckoBindings.cpp',
|
||||
'GlobalStyleSheetCache.cpp',
|
||||
'GroupRule.cpp',
|
||||
'ImageLoader.cpp',
|
||||
'ImportScanner.cpp',
|
||||
|
@ -204,7 +205,6 @@ UNIFIED_SOURCES += [
|
|||
'nsHTMLCSSStyleSheet.cpp',
|
||||
'nsHTMLStyleSheet.cpp',
|
||||
'nsICSSDeclaration.cpp',
|
||||
'nsLayoutStylesheetCache.cpp',
|
||||
'nsMediaFeatures.cpp',
|
||||
'nsROCSSPrimitiveValue.cpp',
|
||||
'nsStyleStruct.cpp',
|
||||
|
|
Загрузка…
Ссылка в новой задаче