Bug 1546329 - Remove dead skins code. r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com//D28459
This commit is contained in:
Emilio Cobos Álvarez 2019-04-24 13:18:50 +02:00
Родитель 3bec30d25f
Коммит 2b46634961
20 изменённых файлов: 22 добавлений и 420 удалений

Просмотреть файл

@ -27,7 +27,6 @@ add_task(async function() {
// behaviour when opening a new window, even if windows have been
// opened in previous tests.
Services.obs.notifyObservers(null, "startupcache-invalidate");
Services.obs.notifyObservers(null, "chrome-flush-skin-caches");
Services.obs.notifyObservers(null, "chrome-flush-caches");
let win = window.openDialog(AppConstants.BROWSER_CHROME_URL, "_blank",

Просмотреть файл

@ -41,7 +41,6 @@ nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
using mozilla::PresShell;
using mozilla::StyleSheet;
using mozilla::dom::Document;
using mozilla::dom::IsChromeURI;
using mozilla::dom::Location;
////////////////////////////////////////////////////////////////////////////////
@ -273,116 +272,6 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURI, nsIURI** aResult) {
////////////////////////////////////////////////////////////////////////
// theme stuff
static void FlushSkinBindingsForWindow(nsPIDOMWindowOuter* aWindow) {
// Get the document.
RefPtr<Document> document = aWindow->GetDoc();
if (!document) return;
// Annihilate all XBL bindings.
document->FlushSkinBindings();
}
// XXXbsmedberg: move this to nsIWindowMediator
NS_IMETHODIMP nsChromeRegistry::RefreshSkins() {
nsCOMPtr<nsIWindowMediator> windowMediator(
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
if (!windowMediator) return NS_OK;
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
bool more;
windowEnumerator->HasMoreElements(&more);
while (more) {
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsPIDOMWindowOuter> domWindow = do_QueryInterface(protoWindow);
if (domWindow) FlushSkinBindingsForWindow(domWindow);
}
windowEnumerator->HasMoreElements(&more);
}
FlushSkinCaches();
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
windowEnumerator->HasMoreElements(&more);
while (more) {
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsPIDOMWindowOuter> domWindow = do_QueryInterface(protoWindow);
if (domWindow) RefreshWindow(domWindow);
}
windowEnumerator->HasMoreElements(&more);
}
return NS_OK;
}
void nsChromeRegistry::FlushSkinCaches() {
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
obsSvc->NotifyObservers(static_cast<nsIChromeRegistry*>(this),
NS_CHROME_FLUSH_SKINS_TOPIC, nullptr);
}
// XXXbsmedberg: move this to windowmediator
nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow) {
// Deal with our subframes first.
nsDOMWindowList* frames = aWindow->GetFrames();
uint32_t length = frames->GetLength();
for (uint32_t j = 0; j < length; j++) {
nsCOMPtr<nsPIDOMWindowOuter> piWindow = frames->IndexedGetter(j);
RefreshWindow(piWindow);
}
// Get the document.
RefPtr<Document> document = aWindow->GetDoc();
if (!document) return NS_OK;
size_t count = document->SheetCount();
// Build an array of style sheets we need to reload.
nsTArray<RefPtr<StyleSheet>> oldSheets(count);
nsTArray<RefPtr<StyleSheet>> newSheets(count);
// Iterate over the style sheets.
for (size_t i = 0; i < count; i++) {
// Get the style sheet
oldSheets.AppendElement(document->SheetAt(i));
}
// Iterate over our old sheets and kick off a sync load of the new
// sheet if and only if it's a non-inline sheet with a chrome URL.
//
// FIXME(emilio): What about user sheets? Also, does this do anything useful
// anymore?
for (StyleSheet* sheet : oldSheets) {
MOZ_ASSERT(sheet,
"SheetAt shouldn't return nullptr for "
"in-range sheet indexes");
nsIURI* uri = sheet->GetSheetURI();
if (!sheet->IsInline() && IsChromeURI(uri)) {
// Reload the sheet.
// XXX what about chrome sheets that have a title or are disabled? This
// only works by sheer dumb luck.
if (RefPtr<StyleSheet> newSheet = document->LoadChromeSheetSync(uri)) {
newSheets.AppendElement(newSheet);
}
} else {
// Just use the same sheet.
newSheets.AppendElement(sheet);
}
}
// Now notify the document that multiple sheets have been added and removed.
document->UpdateStyleSheets(oldSheets, newSheets);
return NS_OK;
}
void nsChromeRegistry::FlushAllCaches() {
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();

Просмотреть файл

@ -42,7 +42,6 @@ class nsChromeRegistry : public nsIToolkitChromeRegistry,
NS_DECL_ISUPPORTS
// nsIXULChromeRegistry methods:
NS_IMETHOD RefreshSkins() override;
NS_IMETHOD AllowScriptsForPackage(nsIURI* url, bool* _retval) override;
NS_IMETHOD AllowContentToAccess(nsIURI* url, bool* _retval) override;
NS_IMETHOD CanLoadURLRemotely(nsIURI* url, bool* _retval) override;

Просмотреть файл

@ -37,8 +37,8 @@
#include "nsIScriptError.h"
#include "nsIXULRuntime.h"
#define SELECTED_SKIN_PREF "general.skins.selectedSkin"
#define PACKAGE_OVERRIDE_BRANCH "chrome.override_package."
#define SKIN NS_LITERAL_CSTRING("classic/1.0")
using namespace mozilla;
using mozilla::dom::ContentParent;
@ -94,33 +94,10 @@ nsresult nsChromeRegistryChrome::Init() {
nsresult rv = nsChromeRegistry::Init();
if (NS_FAILED(rv)) return rv;
mSelectedSkin = NS_LITERAL_CSTRING("classic/1.0");
bool safeMode = false;
nsCOMPtr<nsIXULRuntime> xulrun(do_GetService(XULAPPINFO_SERVICE_CONTRACTID));
if (xulrun) xulrun->GetInSafeMode(&safeMode);
nsCOMPtr<nsIPrefService> prefserv(do_GetService(NS_PREFSERVICE_CONTRACTID));
nsCOMPtr<nsIPrefBranch> prefs;
if (prefserv) {
if (safeMode) {
prefserv->GetDefaultBranch(nullptr, getter_AddRefs(prefs));
} else {
prefs = do_QueryInterface(prefserv);
}
}
if (!prefs) {
NS_WARNING("Could not get pref service!");
} else {
nsAutoCString provider;
rv = prefs->GetCharPref(SELECTED_SKIN_PREF, provider);
if (NS_SUCCEEDED(rv)) mSelectedSkin = provider;
rv = prefs->AddObserver(SELECTED_SKIN_PREF, this, true);
}
nsCOMPtr<nsIObserverService> obsService =
mozilla::services::GetObserverService();
if (obsService) {
@ -131,27 +108,6 @@ nsresult nsChromeRegistryChrome::Init() {
return NS_OK;
}
NS_IMETHODIMP
nsChromeRegistryChrome::CheckForOSAccessibility() {
int32_t useAccessibilityTheme =
LookAndFeel::GetInt(LookAndFeel::eIntID_UseAccessibilityTheme, 0);
if (useAccessibilityTheme) {
/* Set the skin to classic and remove pref observers */
if (!mSelectedSkin.EqualsLiteral("classic/1.0")) {
mSelectedSkin.AssignLiteral("classic/1.0");
RefreshSkins();
}
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
prefs->RemoveObserver(SELECTED_SKIN_PREF, this);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeRegistryChrome::GetLocalesForPackage(
const nsACString& aPackage, nsIUTF8StringEnumerator** aResult) {
@ -240,26 +196,7 @@ nsChromeRegistryChrome::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* someData) {
nsresult rv = NS_OK;
if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
nsCOMPtr<nsIPrefBranch> prefs(do_QueryInterface(aSubject));
NS_ASSERTION(prefs, "Bad observer call!");
NS_ConvertUTF16toUTF8 pref(someData);
if (pref.EqualsLiteral(SELECTED_SKIN_PREF)) {
nsAutoCString provider;
rv = prefs->GetCharPref(pref.get(), provider);
if (NS_FAILED(rv)) {
NS_ERROR("Couldn't get new skin pref!");
return rv;
}
mSelectedSkin = provider;
RefreshSkins();
} else {
NS_ERROR("Unexpected pref!");
}
} else if (!strcmp("profile-initial-state", aTopic)) {
if (!strcmp("profile-initial-state", aTopic)) {
mProfileLoaded = true;
} else if (!strcmp("intl:app-locales-changed", aTopic)) {
if (mProfileLoaded) {
@ -308,7 +245,7 @@ void nsChromeRegistryChrome::SendRegisteredChrome(
for (auto iter = mPackagesHash.Iter(); !iter.Done(); iter.Next()) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(iter.Key(), iter.UserData(), &chromePackage,
mSelectedSkin);
SKIN);
packages.AppendElement(chromePackage);
}
@ -402,7 +339,7 @@ nsIURI* nsChromeRegistryChrome::GetBaseURIFromPackage(
LocaleService::GetInstance()->GetAppLocaleAsLangTag(appLocale);
return entry->locales.GetBase(appLocale, nsProviderArray::LOCALE);
} else if (aProvider.EqualsLiteral("skin")) {
return entry->skins.GetBase(mSelectedSkin, nsProviderArray::ANY);
return entry->skins.GetBase(SKIN, nsProviderArray::ANY);
} else if (aProvider.EqualsLiteral("content")) {
return entry->baseURI;
}
@ -554,8 +491,7 @@ void nsChromeRegistryChrome::ManifestContent(ManifestProcessingContext& cx,
if (mDynamicRegistration) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(packageName, entry, &chromePackage,
mSelectedSkin);
ChromePackageFromPackageEntry(packageName, entry, &chromePackage, SKIN);
SendManifestEntry(chromePackage);
}
}
@ -591,8 +527,7 @@ void nsChromeRegistryChrome::ManifestLocale(ManifestProcessingContext& cx,
if (mDynamicRegistration) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(packageName, entry, &chromePackage,
mSelectedSkin);
ChromePackageFromPackageEntry(packageName, entry, &chromePackage, SKIN);
SendManifestEntry(chromePackage);
}
@ -638,8 +573,7 @@ void nsChromeRegistryChrome::ManifestSkin(ManifestProcessingContext& cx,
if (mDynamicRegistration) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(packageName, entry, &chromePackage,
mSelectedSkin);
ChromePackageFromPackageEntry(packageName, entry, &chromePackage, SKIN);
SendManifestEntry(chromePackage);
}
}

Просмотреть файл

@ -29,7 +29,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry {
nsresult Init() override;
NS_IMETHOD CheckForNewChrome() override;
NS_IMETHOD CheckForOSAccessibility() override;
NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
nsIUTF8StringEnumerator** aResult) override;
NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;
@ -104,8 +103,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry {
bool mProfileLoaded;
bool mDynamicRegistration;
nsCString mSelectedSkin;
// Hash of package names ("global") to PackageEntry objects
nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;

Просмотреть файл

@ -159,11 +159,6 @@ nsChromeRegistryContent::GetLocalesForPackage(
CONTENT_NOT_IMPLEMENTED();
}
NS_IMETHODIMP
nsChromeRegistryContent::CheckForOSAccessibility() {
CONTENT_NOT_IMPLEMENTED();
}
NS_IMETHODIMP
nsChromeRegistryContent::CheckForNewChrome() { CONTENT_NOT_IMPLEMENTED(); }

Просмотреть файл

@ -26,7 +26,6 @@ class nsChromeRegistryContent : public nsChromeRegistry {
NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
nsIUTF8StringEnumerator** aResult) override;
NS_IMETHOD CheckForNewChrome() override;
NS_IMETHOD CheckForOSAccessibility() override;
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) override;
NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;

Просмотреть файл

@ -54,9 +54,6 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
// (or may be overridden by intl.uidirection pref)
boolean isLocaleRTL(in ACString package);
/* Should be called when skins change. Reloads only stylesheets. */
void refreshSkins();
/**
* Installable skin XBL is not always granted the same privileges as other
* chrome. This asks the chrome registry whether scripts are allowed to be
@ -99,11 +96,4 @@ interface nsIXULChromeRegistry : nsIChromeRegistry
#define NS_CHROME_FLUSH_TOPIC \
"chrome-flush-caches"
/**
* Chrome registry will notify various caches that skin files need flushing.
* If "chrome-flush-caches" is notified, this topic will *not* be notified.
*/
#define NS_CHROME_FLUSH_SKINS_TOPIC \
"chrome-flush-skin-caches"
%}

Просмотреть файл

@ -11,16 +11,6 @@ interface nsIUTF8StringEnumerator;
[scriptable, uuid(8727651c-9530-45a0-b81e-0e0690c30c50)]
interface nsIToolkitChromeRegistry : nsIXULChromeRegistry
{
/**
* If the OS has a "high-visibility" or "disabled-friendly" theme set,
* we want to force mozilla into the classic theme, which (for the most part
* obeys the system color/font settings. We cannot do this at initialization,
* because it depends on the toolkit (GTK2) being initialized, which is
* not the case in some embedding situations. Embedders have to manually
* call this method during the startup process.
*/
void checkForOSAccessibility();
/**
* Get a list of locales available for the specified package.
*/

Просмотреть файл

@ -2409,12 +2409,14 @@ void Document::RemoveContentEditableStyleSheets() {
auto* cache = nsLayoutStylesheetCache::Singleton();
bool changed = false;
if (mDesignModeSheetAdded) {
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent, cache->DesignModeSheet());
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent,
cache->DesignModeSheet());
mDesignModeSheetAdded = false;
changed = true;
}
if (mContentEditableSheetAdded) {
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent, cache->ContentEditableSheet());
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent,
cache->ContentEditableSheet());
mContentEditableSheetAdded = false;
changed = true;
}
@ -2426,20 +2428,24 @@ void Document::RemoveContentEditableStyleSheets() {
void Document::AddContentEditableStyleSheetsToStyleSet(bool aDesignMode) {
MOZ_ASSERT(IsHTMLOrXHTML());
MOZ_DIAGNOSTIC_ASSERT(mStyleSetFilled, "Caller should ensure we're being rendered");
MOZ_DIAGNOSTIC_ASSERT(mStyleSetFilled,
"Caller should ensure we're being rendered");
auto* cache = nsLayoutStylesheetCache::Singleton();
bool changed = false;
if (!mContentEditableSheetAdded) {
mStyleSet->AppendStyleSheet(StyleOrigin::UserAgent, cache->ContentEditableSheet());
mStyleSet->AppendStyleSheet(StyleOrigin::UserAgent,
cache->ContentEditableSheet());
mContentEditableSheetAdded = true;
changed = true;
}
if (mDesignModeSheetAdded != aDesignMode) {
if (mDesignModeSheetAdded) {
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent, cache->DesignModeSheet());
mStyleSet->RemoveStyleSheet(StyleOrigin::UserAgent,
cache->DesignModeSheet());
} else {
mStyleSet->AppendStyleSheet(StyleOrigin::UserAgent, cache->DesignModeSheet());
mStyleSet->AppendStyleSheet(StyleOrigin::UserAgent,
cache->DesignModeSheet());
}
mDesignModeSheetAdded = !mDesignModeSheetAdded;
changed = true;
@ -4343,36 +4349,6 @@ void Document::RemoveStyleSheet(StyleSheet* aSheet) {
sheet->ClearAssociatedDocumentOrShadowRoot();
}
void Document::UpdateStyleSheets(nsTArray<RefPtr<StyleSheet>>& aOldSheets,
nsTArray<RefPtr<StyleSheet>>& aNewSheets) {
// XXX Need to set the sheet on the ownernode, if any
MOZ_ASSERT(aOldSheets.Length() == aNewSheets.Length(),
"The lists must be the same length!");
int32_t count = aOldSheets.Length();
RefPtr<StyleSheet> oldSheet;
int32_t i;
for (i = 0; i < count; ++i) {
oldSheet = aOldSheets[i];
// First remove the old sheet.
NS_ASSERTION(oldSheet, "None of the old sheets should be null");
int32_t oldIndex = mStyleSheets.IndexOf(oldSheet);
RemoveStyleSheet(oldSheet); // This does the right notifications
// Now put the new one in its place. If it's null, just ignore it.
StyleSheet* newSheet = aNewSheets[i];
if (newSheet) {
DocumentOrShadowRoot::InsertSheetAt(oldIndex, *newSheet);
if (newSheet->IsApplicable()) {
AddStyleSheetToStyleSets(newSheet);
}
NotifyStyleSheetAdded(newSheet, true);
}
}
}
void Document::InsertSheetAt(size_t aIndex, StyleSheet& aSheet) {
DocumentOrShadowRoot::InsertSheetAt(aIndex, aSheet);
@ -6281,8 +6257,6 @@ already_AddRefed<MediaQueryList> Document::MatchMedia(
return result.forget();
}
void Document::FlushSkinBindings() { BindingManager()->FlushSkinBindings(); }
void Document::SetMayStartLayout(bool aMayStartLayout) {
mMayStartLayout = aMayStartLayout;
if (MayStartLayout()) {

Просмотреть файл

@ -1660,17 +1660,6 @@ class Document : public nsINode,
void InsertSheetAt(size_t aIndex, StyleSheet&);
/**
* Replace the stylesheets in aOldSheets with the stylesheets in
* aNewSheets. The two lists must have equal length, and the sheet
* at positon J in the first list will be replaced by the sheet at
* position J in the second list. Some sheets in the second list
* may be null; if so the corresponding sheets in the first list
* will simply be removed.
*/
void UpdateStyleSheets(nsTArray<RefPtr<StyleSheet>>& aOldSheets,
nsTArray<RefPtr<StyleSheet>>& aNewSheets);
/**
* Add a stylesheet to the document
*
@ -2415,10 +2404,6 @@ class Document : public nsINode,
nsAtom* aAttrName,
const nsAString& aAttrValue) const;
/**
* See FlushSkinBindings on nsBindingManager
*/
void FlushSkinBindings();
/**
* To batch DOMSubtreeModified, document needs to be informed when

Просмотреть файл

@ -454,27 +454,6 @@ void nsBindingManager::RemoveLoadingDocListener(nsIURI* aURL) {
}
}
void nsBindingManager::FlushSkinBindings() {
if (!mBoundContentSet) {
return;
}
for (auto iter = mBoundContentSet->Iter(); !iter.Done(); iter.Next()) {
nsXBLBinding* binding = iter.Get()->GetKey()->GetXBLBinding();
if (binding->MarkedForDeath()) {
continue;
}
nsAutoCString path;
binding->PrototypeBinding()->DocURI()->GetPathQueryRef(path);
if (!strncmp(path.get(), "/skin", 5)) {
binding->MarkForDeath();
}
}
}
// Used below to protect from recurring in QI calls through XPConnect.
struct AntiRecursionData {
nsIContent* element;

Просмотреть файл

@ -111,8 +111,6 @@ class nsBindingManager final : public nsStubMutationObserver {
nsIStreamListener* GetLoadingDocListener(nsIURI* aURL);
void RemoveLoadingDocListener(nsIURI* aURL);
void FlushSkinBindings();
nsresult GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,
void** aResult);

Просмотреть файл

@ -90,7 +90,6 @@ nsXULPrototypeCache* nsXULPrototypeCache::GetInstance() {
mozilla::services::GetObserverService();
if (obsSvc) {
nsXULPrototypeCache* p = sInstance;
obsSvc->AddObserver(p, "chrome-flush-skin-caches", false);
obsSvc->AddObserver(p, "chrome-flush-caches", false);
obsSvc->AddObserver(p, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
obsSvc->AddObserver(p, "startupcache-invalidate", false);
@ -104,10 +103,8 @@ nsXULPrototypeCache* nsXULPrototypeCache::GetInstance() {
NS_IMETHODIMP
nsXULPrototypeCache::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
if (!strcmp(aTopic, "chrome-flush-skin-caches")) {
FlushSkinFiles();
} else if (!strcmp(aTopic, "chrome-flush-caches") ||
!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
if (!strcmp(aTopic, "chrome-flush-caches") ||
!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
Flush();
} else if (!strcmp(aTopic, "startupcache-invalidate")) {
AbortCaching();
@ -211,26 +208,6 @@ nsresult nsXULPrototypeCache::PutXBLDocumentInfo(
return NS_OK;
}
void nsXULPrototypeCache::FlushSkinFiles() {
// Flush out skin XBL files from the cache.
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
nsAutoCString str;
iter.Key()->GetPathQueryRef(str);
if (strncmp(str.get(), "/skin", 5) == 0) {
iter.Remove();
}
}
// Now flush out our skin stylesheets from the cache.
for (auto iter = mStyleSheetTable.Iter(); !iter.Done(); iter.Next()) {
nsAutoCString str;
iter.Data()->GetSheetURI()->GetPathQueryRef(str);
if (strncmp(str.get(), "/skin", 5) == 0) {
iter.Remove();
}
}
}
void nsXULPrototypeCache::FlushScripts() { mScriptTable.Clear(); }
void nsXULPrototypeCache::Flush() {

Просмотреть файл

@ -114,8 +114,6 @@ class nsXULPrototypeCache : public nsIObserver {
static nsXULPrototypeCache* sInstance;
void FlushSkinFiles();
using StyleSheetTable = nsRefPtrHashtable<nsURIHashKey, mozilla::StyleSheet>;
using XBLDocTable = nsRefPtrHashtable<nsURIHashKey, nsXBLDocumentInfo>;

Просмотреть файл

@ -1269,7 +1269,6 @@ nsresult imgLoader::InitCache() {
}
os->AddObserver(this, "memory-pressure", false);
os->AddObserver(this, "chrome-flush-skin-caches", false);
os->AddObserver(this, "chrome-flush-caches", false);
os->AddObserver(this, "last-pb-context-exited", false);
os->AddObserver(this, "profile-before-change", false);
@ -1307,8 +1306,7 @@ imgLoader::Observe(nsISupports* aSubject, const char* aTopic,
} else if (strcmp(aTopic, "memory-pressure") == 0) {
MinimizeCaches();
} else if (strcmp(aTopic, "chrome-flush-skin-caches") == 0 ||
strcmp(aTopic, "chrome-flush-caches") == 0) {
} else if (strcmp(aTopic, "chrome-flush-caches") == 0) {
MinimizeCaches();
ClearChromeImageCache();
} else if (strcmp(aTopic, "last-pb-context-exited") == 0) {

Просмотреть файл

@ -997,9 +997,6 @@ void PresShell::Init(Document* aDocument, nsPresContext* aPresContext,
{
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
#ifdef MOZ_XUL
os->AddObserver(this, "chrome-flush-skin-caches", false);
#endif
os->AddObserver(this, "memory-pressure", false);
os->AddObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC, false);
if (XRE_IsParentProcess() && !sProcessInteractable) {
@ -1224,9 +1221,6 @@ void PresShell::Destroy() {
{
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
#ifdef MOZ_XUL
os->RemoveObserver(this, "chrome-flush-skin-caches");
#endif
os->RemoveObserver(this, "memory-pressure");
os->RemoveObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC);
if (XRE_IsParentProcess()) {
@ -9411,63 +9405,6 @@ void PresShell::WindowSizeMoveDone() {
}
}
#ifdef MOZ_XUL
/*
* It's better to add stuff to the |DidSetComputedStyle| method of the
* relevant frames than adding it here. These methods should (ideally,
* anyway) go away.
*/
// Return value says whether to walk children.
typedef bool (*frameWalkerFn)(nsIFrame* aFrame);
static bool ReResolveMenusAndTrees(nsIFrame* aFrame) {
// Trees have a special style cache that needs to be flushed when
// the theme changes.
nsTreeBodyFrame* treeBody = do_QueryFrame(aFrame);
if (treeBody) treeBody->ClearStyleAndImageCaches();
// We deliberately don't re-resolve style on a menu's popup
// sub-content, since doing so slows menus to a crawl. That means we
// have to special-case them on a skin switch, and ensure that the
// popup frames just get destroyed completely.
nsMenuFrame* menu = do_QueryFrame(aFrame);
if (menu) menu->CloseMenu(true);
return true;
}
static bool ReframeImageBoxes(nsIFrame* aFrame) {
if (aFrame->IsImageBoxFrame()) {
aFrame->PresContext()->RestyleManager()->PostRestyleEvent(
aFrame->GetContent()->AsElement(), RestyleHint{0},
nsChangeHint_ReconstructFrame);
return false; // don't walk descendants
}
return true; // walk descendants
}
static void WalkFramesThroughPlaceholders(nsPresContext* aPresContext,
nsIFrame* aFrame,
frameWalkerFn aFunc) {
bool walkChildren = (*aFunc)(aFrame);
if (!walkChildren) return;
nsIFrame::ChildListIterator lists(aFrame);
for (; !lists.IsDone(); lists.Next()) {
nsFrameList::Enumerator childFrames(lists.CurrentList());
for (; !childFrames.AtEnd(); childFrames.Next()) {
nsIFrame* child = childFrames.get();
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
// only do frames that are in flow, and recur through the
// out-of-flows of placeholders.
WalkFramesThroughPlaceholders(
aPresContext, nsPlaceholderFrame::GetRealFrameFor(child), aFunc);
}
}
}
}
#endif
NS_IMETHODIMP
PresShell::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
@ -9476,24 +9413,6 @@ PresShell::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
#ifdef MOZ_XUL
if (!nsCRT::strcmp(aTopic, "chrome-flush-skin-caches")) {
// Need to null-check because "chrome-flush-skin-caches" can happen
// at interesting times during startup.
if (nsIFrame* rootFrame = mFrameConstructor->GetRootFrame()) {
NS_ASSERTION(mViewManager, "View manager must exist");
WalkFramesThroughPlaceholders(mPresContext, rootFrame,
ReResolveMenusAndTrees);
// Because "chrome:" URL equality is messy, reframe image box
// frames (hack!).
WalkFramesThroughPlaceholders(mPresContext, rootFrame, ReframeImageBoxes);
}
return NS_OK;
}
#endif
if (!nsCRT::strcmp(aTopic, "memory-pressure")) {
if (!AssumeAllFramesVisible() && mPresContext->IsRootContentDocument()) {
DoUpdateApproximateFrameVisibility(/* aRemoveOnly = */ true);

Просмотреть файл

@ -112,10 +112,6 @@ nsresult nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
mUserChromeSheet = nullptr;
} else if (!strcmp(aTopic, "profile-do-change")) {
InitFromProfile();
} else if (strcmp(aTopic, "chrome-flush-skin-caches") == 0 ||
strcmp(aTopic, "chrome-flush-caches") == 0) {
mScrollbarsSheet = nullptr;
mFormsSheet = nullptr;
} else {
MOZ_ASSERT_UNREACHABLE("Unexpected observer topic.");
}
@ -229,8 +225,6 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache() : mUsedSharedMemory(0) {
if (obsSvc) {
obsSvc->AddObserver(this, "profile-before-change", false);
obsSvc->AddObserver(this, "profile-do-change", false);
obsSvc->AddObserver(this, "chrome-flush-skin-caches", false);
obsSvc->AddObserver(this, "chrome-flush-caches", false);
}
// Load user style sheets.

Просмотреть файл

@ -103,12 +103,9 @@ function createManifestTemporarily(tempDir, manifestText) {
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
autoRegister(tempfile);
gChromeReg.refreshSkins();
return function() {
tempfile.fileSize = 0; // truncate the manifest
gChromeReg.checkForNewChrome();
gChromeReg.refreshSkins();
Services.prefs.clearUserPref(XUL_CACHE_PREF);
};
}
@ -124,12 +121,9 @@ function registerManifestTemporarily(manifestURI) {
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
autoRegister(tempfile);
gChromeReg.refreshSkins();
return function() {
tempfile.fileSize = 0; // truncate the manifest
gChromeReg.checkForNewChrome();
gChromeReg.refreshSkins();
Services.prefs.clearUserPref(XUL_CACHE_PREF);
};
}

Просмотреть файл

@ -1331,12 +1331,6 @@ nsresult ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native) {
NS_IF_ADDREF(gNativeAppSupport = native);
// Inform the chrome registry about OS accessibility
nsCOMPtr<nsIToolkitChromeRegistry> cr =
mozilla::services::GetToolkitChromeRegistryService();
if (cr) cr->CheckForOSAccessibility();
nsCOMPtr<nsIWindowCreator> creator(components::AppStartup::Service());
if (!creator) return NS_ERROR_UNEXPECTED;