Skip to content

Commit

Permalink
Bug 1546329 - Remove dead skins code. r=bzbarsky
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Apr 25, 2019
1 parent 3bec30d commit 2b46634
Show file tree
Hide file tree
Showing 20 changed files with 22 additions and 420 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
111 changes: 0 additions & 111 deletions chrome/nsChromeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion chrome/nsChromeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
80 changes: 7 additions & 73 deletions chrome/nsChromeRegistryChrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
3 changes: 0 additions & 3 deletions chrome/nsChromeRegistryChrome.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 0 additions & 5 deletions chrome/nsChromeRegistryContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@ nsChromeRegistryContent::GetLocalesForPackage(
CONTENT_NOT_IMPLEMENTED();
}

NS_IMETHODIMP
nsChromeRegistryContent::CheckForOSAccessibility() {
CONTENT_NOT_IMPLEMENTED();
}

NS_IMETHODIMP
nsChromeRegistryContent::CheckForNewChrome() { CONTENT_NOT_IMPLEMENTED(); }

Expand Down
1 change: 0 additions & 1 deletion chrome/nsChromeRegistryContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions chrome/nsIChromeRegistry.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

%}
10 changes: 0 additions & 10 deletions chrome/nsIToolkitChromeRegistry.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Loading

0 comments on commit 2b46634

Please sign in to comment.