Bug 1306800 - Remove support for app theming; r=myk,baku
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 30 Sep 2016 22:34:19 -0400
changeset 360731 9d674f5dbc8e1c6d160f844701a0771316a8d833
parent 360730 144625d6fafa6bd2870f9d886245e878e591b2e1
child 360732 67300cfca7338c03a71e713f1b7103367fad4b29
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk, baku
bugs1306800
milestone52.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 1306800 - Remove support for app theming; r=myk,baku
b2g/app/b2g.js
b2g/chrome/content/settings.js
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/PContent.ipdl
image/imgLoader.cpp
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -871,21 +871,16 @@ pref("gfx.canvas.max-size-for-skia-gl", 
 pref("gfx.gralloc.fence-with-readpixels", true);
 
 // enable screen mirroring to external display
 pref("gfx.screen-mirroring.enabled", true);
 
 // The url of the page used to display network error details.
 pref("b2g.neterror.url", "net_error.html");
 
-// The origin used for the shared themes uri space.
-pref("b2g.theme.origin", "app://theme.gaiamobile.org");
-pref("dom.mozApps.themable", true);
-pref("dom.mozApps.selected_theme", "default_theme.gaiamobile.org");
-
 // Enable PAC generator for B2G.
 pref("network.proxy.pac_generator", true);
 
 // List of app origins to apply browsing traffic proxy setting, separated by
 // comma.  Specify '*' in the list to apply to all apps.
 pref("network.proxy.browsing.app_origins", "app://system.gaiamobile.org");
 
 // Enable Web Speech synthesis API
--- a/b2g/chrome/content/settings.js
+++ b/b2g/chrome/content/settings.js
@@ -476,56 +476,16 @@ setUpdateTrackingId();
         window.navigator.mozSettings.createLock().set(setting);
       } catch (e) {
         console.log('Unable to read pref layers.low-precision-opacity: ' + e);
       }
     }
   });
 })();
 
-// ================ Theme selection ============
-// theme.selected holds the manifest url of the currently used theme.
-SettingsListener.observe("theme.selected",
-                         "app://default_theme.gaiamobile.org/manifest.webapp",
-                         function(value) {
-  if (!value) {
-    return;
-  }
-
-  let newTheme;
-  try {
-    let enabled = Services.prefs.getBoolPref("dom.mozApps.themable");
-    if (!enabled) {
-      return;
-    }
-
-    // Make sure this is a url, and only keep the host part to set the pref.
-    let uri = Services.io.newURI(value, null, null);
-    // We only support overriding in the app:// protocol handler.
-    if (uri.scheme !== "app") {
-      return;
-    }
-    newTheme = uri.host;
-  } catch(e) {
-    return;
-  }
-
-  let currentTheme;
-  try {
-    currentTheme = Services.prefs.getCharPref('dom.mozApps.selected_theme');
-  } catch(e) {};
-
-  if (currentTheme != newTheme) {
-    debug("New theme selected " + value);
-    Services.prefs.setCharPref('dom.mozApps.selected_theme', newTheme);
-    Services.prefs.savePrefFile(null);
-    Services.obs.notifyObservers(null, 'app-theme-changed', newTheme);
-  }
-});
-
 // =================== Proxy server ======================
 (function setupBrowsingProxySettings() {
   function setPAC() {
     let usePAC;
     try {
       usePAC = Services.prefs.getBoolPref('network.proxy.pac_generator');
     } catch (ex) {}
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1392,22 +1392,16 @@ nsDocument::IsAboutPage()
 nsDocument::~nsDocument()
 {
   if (gDocumentLeakPRLog)
     MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
            ("DOCUMENT %p destroyed", this));
 
   NS_ASSERTION(!mIsShowing, "Destroying a currently-showing document");
 
-  // Note: This assert is only non-fatal because mochitest-bc triggers
-  // it... as well as the preceding assert about !mIsShowing.
-  NS_ASSERTION(!mObservingAppThemeChanged,
-               "Document leaked to shutdown, then the observer service dropped "
-               "its ref to us so we were able to go away.");
-
   if (IsTopLevelContentDocument()) {
     //don't report for about: pages
     if (!IsAboutPage()) {
       // Record the page load
       uint32_t pageLoaded = 1;
       Accumulate(Telemetry::MIXED_CONTENT_UNBLOCK_COUNTER, pageLoaded);
       // Record the mixed content status of the docshell in Telemetry
       enum {
@@ -8728,20 +8722,16 @@ nsDocument::OnPageShow(bool aPersisted,
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
     nsIPrincipal *principal = GetPrincipal();
     os->NotifyObservers(static_cast<nsIDocument*>(this),
                         nsContentUtils::IsSystemPrincipal(principal) ?
                           "chrome-page-shown" :
                           "content-page-shown",
                         nullptr);
-    if (!mObservingAppThemeChanged) {
-      os->AddObserver(this, "app-theme-changed", /* ownsWeak */ false);
-      mObservingAppThemeChanged = true;
-    }
   }
 
   DispatchPageTransition(target, NS_LITERAL_STRING("pageshow"), aPersisted);
 }
 
 static bool
 NotifyPageHide(nsIDocument* aDocument, void* aData)
 {
@@ -8824,19 +8814,16 @@ nsDocument::OnPageHide(bool aPersisted,
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
     nsIPrincipal* principal = GetPrincipal();
     os->NotifyObservers(static_cast<nsIDocument*>(this),
                         nsContentUtils::IsSystemPrincipal(principal) ?
                           "chrome-page-hidden" :
                           "content-page-hidden",
                         nullptr);
-
-    os->RemoveObserver(this, "app-theme-changed");
-    mObservingAppThemeChanged = false;
   }
 
   DispatchPageTransition(target, NS_LITERAL_STRING("pagehide"), aPersisted);
 
   mVisible = false;
 
   UpdateVisibilityState();
 
@@ -11841,23 +11828,17 @@ nsIDocument::GetPointerLockElement()
   return pointerLockedElement;
 }
 
 nsresult
 nsDocument::Observe(nsISupports *aSubject,
                     const char *aTopic,
                     const char16_t *aData)
 {
-  if (strcmp("app-theme-changed", aTopic) == 0) {
-    if (!nsContentUtils::IsSystemPrincipal(NodePrincipal()) &&
-        !IsUnstyledDocument()) {
-      // We don't want to style the chrome window, only app ones.
-      OnAppThemeChanged();
-    }
-  } else if (strcmp("service-worker-get-client", aTopic) == 0) {
+  if (strcmp("service-worker-get-client", aTopic) == 0) {
     // No need to generate the ID if it doesn't exist here.  The ID being
     // requested must already be generated in order to passed in as
     // aSubject.
     nsString clientId = GetId();
     if (!clientId.IsEmpty() && clientId.Equals(aData)) {
       nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_QueryInterface(aSubject);
       if (ifptr) {
 #ifdef DEBUG
@@ -11869,57 +11850,16 @@ nsDocument::Observe(nsISupports *aSubjec
         ifptr->SetDataIID(&NS_GET_IID(nsIDocument));
       }
     }
   }
   return NS_OK;
 }
 
 void
-nsDocument::OnAppThemeChanged()
-{
-  // Bail out if there is no theme support set up properly.
-  auto themeOrigin = Preferences::GetString("b2g.theme.origin");
-  if (!themeOrigin || !Preferences::GetBool("dom.mozApps.themable")) {
-    return;
-  }
-
-  for (int32_t i = 0; i < GetNumberOfStyleSheets(); i++) {
-    RefPtr<StyleSheet> sheet = GetStyleSheetAt(i);
-    if (!sheet) {
-      continue;
-    }
-
-    nsINode* owningNode = sheet->GetOwnerNode();
-    if (!owningNode) {
-      continue;
-    }
-    // Get a DOM stylesheet link to check the href against the theme origin.
-    nsIURI* sheetURI = sheet->GetOriginalURI();
-    if (!sheetURI) {
-      continue;
-    }
-    nsAutoString sheetOrigin;
-    nsContentUtils::GetUTFOrigin(sheetURI, sheetOrigin);
-    if (!sheetOrigin.Equals(themeOrigin)) {
-      continue;
-    }
-
-    // Finally getting a Stylesheet link.
-    nsCOMPtr<nsIStyleSheetLinkingElement> link = do_QueryInterface(owningNode);
-    if (!link) {
-      continue;
-    }
-    bool willNotify;
-    bool isAlternate;
-    link->UpdateStyleSheet(nullptr, &willNotify, &isAlternate, true);
-  }
-}
-
-void
 nsDocument::UpdateVisibilityState()
 {
   dom::VisibilityState oldState = mVisibilityState;
   mVisibilityState = GetVisibilityState();
   if (oldState != mVisibilityState) {
     nsContentUtils::DispatchTrustedEvent(this, static_cast<nsIDocument*>(this),
                                          NS_LITERAL_STRING("visibilitychange"),
                                          /* bubbles = */ true,
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -770,22 +770,16 @@ public:
   virtual void SetValueMissingState(const nsAString& aName, bool aValue) override;
 
   // for radio group
   nsRadioGroupStruct* GetRadioGroup(const nsAString& aName) const;
   nsRadioGroupStruct* GetOrCreateRadioGroup(const nsAString& aName);
 
   virtual nsViewportInfo GetViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) override;
 
-  /**
-   * Called when an app-theme-changed observer notification is
-   * received by this document.
-   */
-  void OnAppThemeChanged();
-
   void ReportUseCounters();
 
 private:
   void AddOnDemandBuiltInUASheet(mozilla::StyleSheet* aSheet);
   nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const;
   void SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages);
 
 public:
@@ -1424,22 +1418,16 @@ public:
 
   // ScreenOrientation "pending promise" as described by
   // http://www.w3.org/TR/screen-orientation/
   RefPtr<mozilla::dom::Promise> mOrientationPendingPromise;
 
   uint16_t mCurrentOrientationAngle;
   mozilla::dom::OrientationType mCurrentOrientationType;
 
-  // Whether we're observing the "app-theme-changed" observer service
-  // notification.  We need to keep track of this because we might get multiple
-  // OnPageShow notifications in a row without an OnPageHide in between, if
-  // we're getting document.open()/close() called on us.
-  bool mObservingAppThemeChanged:1;
-
   // Keeps track of whether we have a pending
   // 'style-sheet-applicable-state-changed' notification.
   bool mSSApplicableStateNotificationPending:1;
 
   // Whether we have reported use counters for this document with Telemetry yet.
   // Normally this is only done at document destruction time, but for image
   // documents (SVG documents) that are not guaranteed to be destroyed, we
   // report use counters when the image cache no longer has any imgRequestProxys
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2803,26 +2803,16 @@ ContentChild::DeallocPOfflineCacheUpdate
 {
   OfflineCacheUpdateChild* offlineCacheUpdate =
     static_cast<OfflineCacheUpdateChild*>(actor);
   NS_RELEASE(offlineCacheUpdate);
   return true;
 }
 
 bool
-ContentChild::RecvOnAppThemeChanged()
-{
-  nsCOMPtr<nsIObserverService> os = services::GetObserverService();
-  if (os) {
-    os->NotifyObservers(nullptr, "app-theme-changed", nullptr);
-  }
-  return true;
-}
-
-bool
 ContentChild::RecvStartProfiler(const ProfilerInitParams& params)
 {
   nsTArray<const char*> featureArray;
   for (size_t i = 0; i < params.features().Length(); ++i) {
     featureArray.AppendElement(params.features()[i].get());
   }
 
   nsTArray<const char*> threadNameFilterArray;
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -509,18 +509,16 @@ public:
   void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
 
   void RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
 
   virtual bool RecvNotifyIdleObserver(const uint64_t& aObserver,
                                       const nsCString& aTopic,
                                       const nsString& aData) override;
 
-  virtual bool RecvOnAppThemeChanged() override;
-
   virtual bool RecvAssociatePluginId(const uint32_t& aPluginId,
                                      const base::ProcessId& aProcessId) override;
 
   virtual bool RecvLoadPluginResult(const uint32_t& aPluginId,
                                     const bool& aResult) override;
 
   virtual bool RecvUpdateWindow(const uintptr_t& aChildId) override;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -561,17 +561,16 @@ static const char* sObserverTopics[] = {
 #ifdef MOZ_WIDGET_GONK
   NS_VOLUME_STATE_CHANGED,
   NS_VOLUME_REMOVED,
   "phone-state-changed",
 #endif
 #ifdef ACCESSIBILITY
   "a11y-init-or-shutdown",
 #endif
-  "app-theme-changed",
 #ifdef MOZ_ENABLE_PROFILER_SPS
   "profiler-started",
   "profiler-stopped",
   "profiler-paused",
   "profiler-resumed",
   "profiler-subprocess-gather",
   "profiler-subprocess",
 #endif
@@ -2803,19 +2802,16 @@ ContentParent::Observe(nsISupports* aSub
 #endif
     } else {
       // If possible, shut down accessibility in content process when
       // accessibility gets shutdown in chrome process.
       Unused << SendShutdownA11y();
     }
   }
 #endif
-  else if (!strcmp(aTopic, "app-theme-changed")) {
-    Unused << SendOnAppThemeChanged();
-  }
 #ifdef MOZ_ENABLE_PROFILER_SPS
   else if (!strcmp(aTopic, "profiler-started")) {
     nsCOMPtr<nsIProfilerStartParams> params(do_QueryInterface(aSubject));
     StartProfiler(params);
   }
   else if (!strcmp(aTopic, "profiler-stopped")) {
     mGatherer = nullptr;
     Unused << SendStopProfiler();
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -563,21 +563,16 @@ child:
     async NotifyPhoneStateChange(nsString newState);
 
     /**
      * Notify idle observers in the child
      */
     async NotifyIdleObserver(uint64_t observerId, nsCString topic, nsString str);
 
     /**
-     * Notify windows in the child to apply a new app style.
-     */
-    async OnAppThemeChanged();
-
-    /**
      * Called during plugin initialization to map a plugin id to a child process
      * id.
      */
     async AssociatePluginId(uint32_t aPluginId, ProcessId aProcessId);
 
     /**
      * This call is used by async plugin initialization to notify the
      * PluginModuleContentParent that the PluginModuleChromeParent's async
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -1241,17 +1241,16 @@ nsresult
 imgLoader::InitCache()
 {
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (!os) {
     return NS_ERROR_FAILURE;
   }
 
   os->AddObserver(this, "memory-pressure", false);
-  os->AddObserver(this, "app-theme-changed", 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);
   os->AddObserver(this, "xpcom-shutdown", false);
 
   mCacheTracker = MakeUnique<imgCacheExpirationTracker>();
 
@@ -1284,19 +1283,16 @@ imgLoader::Observe(nsISupports* aSubject
   // We listen for pref change notifications...
   if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
     if (!NS_strcmp(aData, u"image.http.accept")) {
       ReadAcceptHeaderPref();
     }
 
   } else if (strcmp(aTopic, "memory-pressure") == 0) {
     MinimizeCaches();
-  } else if (strcmp(aTopic, "app-theme-changed") == 0) {
-    ClearImageCache();
-    MinimizeCaches();
   } else if (strcmp(aTopic, "chrome-flush-skin-caches") == 0 ||
              strcmp(aTopic, "chrome-flush-caches") == 0) {
     MinimizeCaches();
     ClearChromeImageCache();
   } else if (strcmp(aTopic, "last-pb-context-exited") == 0) {
     if (mRespectPrivacy) {
       ClearImageCache();
       ClearChromeImageCache();