Bug 1550157 - Set a pref if the user profile is using a userChrome.css or userContent.css file. r=emilio
authorMike Conley <mconley@mozilla.com>
Wed, 08 May 2019 20:50:57 +0000
changeset 535004 efc907d677c24b15d2f652e41efa6bca3239fbcc
parent 535003 7e3b4a30cfd741ff493ca9100bf82c4bb30fe31b
child 535005 751aaa1009d37b550c2396081bb4a9d5de8c0238
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1550157
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1550157 - Set a pref if the user profile is using a userChrome.css or userContent.css file. r=emilio This is in preparation to disable (but not remove) support for these customizations by default. We want to avoid scanning for these files on start-up, but also don't want to make our users jump through a pref-flipping hoop to get their customizations back. So we'll detect those files and flip the pref for this release. For the next release, we'll not load those files unless the pref is flipped. Differential Revision: https://phabricator.services.mozilla.com/D30414
layout/style/nsLayoutStylesheetCache.cpp
modules/libpref/init/all.js
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -97,16 +97,19 @@
 //
 // * In practice, mapping at the address we need in the child process this works
 //   nearly all the time.  If we fail to map at the address we need, the child
 //   process falls back to parsing and allocating its own copy of the UA sheets.
 
 using namespace mozilla;
 using namespace mozilla::css;
 
+#define PREF_LEGACY_STYLESHEET_CUSTOMIZATION \
+  "toolkit.legacyUserProfileCustomizations.stylesheets"
+
 NS_IMPL_ISUPPORTS(nsLayoutStylesheetCache, nsIObserver, nsIMemoryReporter)
 
 nsresult nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
                                           const char* aTopic,
                                           const char16_t* aData) {
   if (!strcmp(aTopic, "profile-before-change")) {
     mUserContentSheet = nullptr;
     mUserChromeSheet = nullptr;
@@ -436,16 +439,31 @@ void nsLayoutStylesheetCache::InitFromPr
   chromeFile->Append(NS_LITERAL_STRING("userChrome.css"));
 
   LoadSheetFile(contentFile, &mUserContentSheet, eUserSheetFeatures,
                 eLogToConsole);
   LoadSheetFile(chromeFile, &mUserChromeSheet, eUserSheetFeatures,
                 eLogToConsole);
 
   if (XRE_IsParentProcess()) {
+    if (mUserChromeSheet || mUserContentSheet) {
+      // Bug 1541233 aims to avoid stat'ing or loading userContent.css or
+      // userChrome.css during start-up by default. After that point,
+      // PREF_LEGACY_STYLESHEET_CUSTOMIZATION pref is how users can opt-in
+      // to continuing to use userChrome.css or userContent.css.
+      //
+      // Before bug 1541233 lands though, we'll ship a release which
+      // continues to look for those files on start-up and sets a pref.
+      // That way, in a subsequent release when loading those files is
+      // off by default, those users will still get their userChrome.css
+      // and userContent.css customizations without having to manually
+      // set the pref themselves.
+      Preferences::SetBool(PREF_LEGACY_STYLESHEET_CUSTOMIZATION, true);
+    }
+
     // We're interested specifically in potential chrome customizations,
     // so we only need data points from the parent process
     Telemetry::Accumulate(Telemetry::USER_CHROME_CSS_LOADED,
                           mUserChromeSheet != nullptr);
   }
 }
 
 void nsLayoutStylesheetCache::LoadSheetURL(const char* aURL,
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -6024,8 +6024,15 @@ pref("dom.datatransfer.mozAtAPIs", true)
 #endif
 
 // External.AddSearchProvider is deprecated and it will be removed in the next
 // cycles.
 pref("dom.sidebar.enabled", true);
 
 // Turn on fission frameloader swapping
 pref("fission.rebuild_frameloaders_on_remoteness_change", true);
+
+// Support for legacy customizations that rely on checking the
+// user profile directory for these stylesheets:
+//  * userContent.css
+//  * userChrome.css
+pref("toolkit.legacyUserProfileCustomizations.stylesheets", false);
+