Bug 1327560 - Always place the current lwtheme at the beginning of the list of recent lightweight themes to prevent it from getting truncated out. r=gijs draft
authorJared Wein <jwein@mozilla.com>
Tue, 03 Jan 2017 17:24:49 -0500
changeset 455524 c09dedaddb3b0097cacd757aec4aecae3d62b59d
parent 455333 cad2ea346d06ec5a3a70eda912513201dff0c21e
child 541019 022e82678d3ede5a77855b5e78eb4454ef39ca91
push id40269
push userbmo:jaws@mozilla.com
push dateWed, 04 Jan 2017 01:19:35 +0000
reviewersgijs
bugs1327560
milestone53.0a1
Bug 1327560 - Always place the current lwtheme at the beginning of the list of recent lightweight themes to prevent it from getting truncated out. r=gijs MozReview-Commit-ID: b3O3MnpmjG
browser/components/customizableui/CustomizeMode.jsm
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1389,19 +1389,26 @@ CustomizeMode.prototype = {
         tbb.addEventListener("blur", resetPreview);
         tbb.addEventListener("mouseout", resetPreview);
 
         return tbb;
       }
 
       let themes = [aDefaultTheme];
       let lwts = LightweightThemeManager.usedThemes;
+      let currentLwt = LightweightThemeManager.currentTheme;
+      let currentLwtIndex = lwts.indexOf(currentLwt);
+      if (currentLwtIndex > -1) {
+        // Make sure that the current lightweight theme
+        // is at the beginning of the array to avoid truncation
+        // in the next step.
+        lwts = lwts.splice(currentLwtIndex, 1).concat(lwts);
+      }
       if (lwts.length > RECENT_LWT_COUNT)
         lwts.length = RECENT_LWT_COUNT;
-      let currentLwt = LightweightThemeManager.currentTheme;
       for (let lwt of lwts) {
         lwt.isActive = !!currentLwt && (lwt.id == currentLwt.id);
         themes.push(lwt);
       }
 
       let footer = doc.getElementById("customization-lwtheme-menu-footer");
       let panel = footer.parentNode;
       let recommendedLabel = doc.getElementById("customization-lwtheme-menu-recommended");