Bug 1207491 - Part 18: Remove use of expression closure from browser/components/tabview/. r=Gijs
authorTooru Fujisawa <arai_a@mac.com>
Wed, 23 Sep 2015 18:36:23 +0900
changeset 297889 6e75188eeab579934e37f268a07d897b67e8ffdc
parent 297888 c0aed1d0eed67b0a3f3ecb11949de7ffb9386e6b
child 297890 22b2b6e2f21f7409ea455f07d45defe9129c5c9c
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1207491
milestone44.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 1207491 - Part 18: Remove use of expression closure from browser/components/tabview/. r=Gijs
browser/components/tabview/favicons.js
browser/components/tabview/groupitems.js
browser/components/tabview/iq.js
browser/components/tabview/modules/utils.jsm
browser/components/tabview/tabview.js
browser/components/tabview/trench.js
--- a/browser/components/tabview/favicons.js
+++ b/browser/components/tabview/favicons.js
@@ -18,17 +18,19 @@ var FavIcons = {
   },
 
   // Lazy getter for pref browser.chrome.favicons.
   get _prefFavicons() {
     delete this._prefFavicons;
     this._prefFavicons = Services.prefs.getBoolPref(this.PREF_CHROME_FAVICONS);
   },
 
-  get defaultFavicon() this._favIconService.defaultFavicon.spec,
+  get defaultFavicon() {
+    return this._favIconService.defaultFavicon.spec;
+  },
 
   init: function FavIcons_init() {
     XPCOMUtils.defineLazyServiceGetter(this, "_favIconService",
       "@mozilla.org/browser/favicon-service;1", "nsIFaviconService");
 
     Services.prefs.addObserver(this.PREF_CHROME_SITE_ICONS, this, false);
     Services.prefs.addObserver(this.PREF_CHROME_FAVICONS, this, false);
   },
--- a/browser/components/tabview/groupitems.js
+++ b/browser/components/tabview/groupitems.js
@@ -1278,17 +1278,17 @@ GroupItem.prototype = Utils.extend(new I
   _freezeItemSize: function GroupItem__freezeItemSize(itemCount) {
     let data = this._frozenItemSizeData;
 
     if (!data.lastItemCount) {
       let self = this;
       data.lastItemCount = itemCount;
 
       // unfreeze item size when tabview is hidden
-      data.onTabViewHidden = function () self._unfreezeItemSize();
+      data.onTabViewHidden = () => self._unfreezeItemSize();
       window.addEventListener('tabviewhidden', data.onTabViewHidden, false);
 
       // we don't need to observe mouse movement when expanded because the
       // tray is closed when we leave it and collapse causes unfreezing
       if (!self.expanded) {
         // unfreeze item size when cursor is moved out of group bounds
         data.onMouseMove = function (e) {
           let cursor = new Point(e.pageX, e.pageY);
@@ -1835,32 +1835,32 @@ GroupItem.prototype = Utils.extend(new I
 
   // ----------
   // Function: reorderTabItemsBasedOnTabOrder
   // Reorders the tabs in a groupItem based on the arrangment of the tabs
   // shown in the tab bar. It does it by sorting the children
   // of the groupItem by the positions of their respective tabs in the
   // tab bar.
   reorderTabItemsBasedOnTabOrder: function GroupItem_reorderTabItemsBasedOnTabOrder() {
-    this._children.sort(function(a,b) a.tab._tPos - b.tab._tPos);
+    this._children.sort((a,b) => a.tab._tPos - b.tab._tPos);
 
     this.arrange({animate: false});
     // this.arrange calls this.save for us
   },
 
   // Function: reorderTabsBasedOnTabItemOrder
   // Reorders the tabs in the tab bar based on the arrangment of the tabs
   // shown in the groupItem.
   reorderTabsBasedOnTabItemOrder: function GroupItem_reorderTabsBasedOnTabItemOrder() {
     let indices;
-    let tabs = this._children.map(function (tabItem) tabItem.tab);
+    let tabs = this._children.map(tabItem => tabItem.tab);
 
     tabs.forEach(function (tab, index) {
       if (!indices)
-        indices = tabs.map(function (tab) tab._tPos);
+        indices = tabs.map(tab => tab._tPos);
 
       let start = index ? indices[index - 1] + 1 : 0;
       let end = index + 1 < indices.length ? indices[index + 1] - 1 : Infinity;
       let targetRange = new Range(start, end);
 
       if (!targetRange.contains(tab._tPos)) {
         gBrowser.moveTabTo(tab, start);
         indices = null;
@@ -2417,17 +2417,17 @@ var GroupItems = {
   // Hides and shows tabs in the tab bar based on the active groupItem
   _updateTabBar: function GroupItems__updateTabBar() {
     if (!window.UI)
       return; // called too soon
 
     Utils.assert(this._activeGroupItem, "There must be something to show in the tab bar!");
 
     let tabItems = this._activeGroupItem._children;
-    gBrowser.showOnlyTheseTabs(tabItems.map(function(item) item.tab));
+    gBrowser.showOnlyTheseTabs(tabItems.map(item => item.tab));
   },
 
   // ----------
   // Function: updateActiveGroupItemAndTabBar
   // Sets active TabItem and GroupItem, and updates tab bar appropriately.
   // Parameters:
   // tabItem - the tab item
   // options - is passed to UI.setActive() directly
--- a/browser/components/tabview/iq.js
+++ b/browser/components/tabview/iq.js
@@ -641,17 +641,19 @@ iQClass.prototype = {
     return this;
   },
 
   // ----------
   // Function: bind
   // Binds the given function to the given event type. Also wraps the function
   // in a try/catch block that does a Utils.log on any errors.
   bind: function iQClass_bind(type, func) {
-    let handler = function(event) func.apply(this, [event]);
+    let handler = function(event) {
+      return func.apply(this, [event]);
+    };
 
     for (let i = 0; this[i] != null; i++) {
       let elem = this[i];
       if (!elem.iQEventData)
         elem.iQEventData = {};
 
       if (!elem.iQEventData[type])
         elem.iQEventData[type] = [];
--- a/browser/components/tabview/modules/utils.jsm
+++ b/browser/components/tabview/modules/utils.jsm
@@ -79,35 +79,43 @@ Rect.prototype = {
   // ----------
   // Function: toString
   // Prints [Rect (left,top,width,height)] for debug use
   toString: function Rect_toString() {
     return "[Rect (" + this.left + "," + this.top + "," +
             this.width + "," + this.height + ")]";
   },
 
-  get right() this.left + this.width,
+  get right() {
+    return this.left + this.width;
+  },
   set right(value) {
     this.width = value - this.left;
   },
 
-  get bottom() this.top + this.height,
+  get bottom() {
+    return this.top + this.height;
+  },
   set bottom(value) {
     this.height = value - this.top;
   },
 
   // ----------
   // Variable: xRange
   // Gives you a new <Range> for the horizontal dimension.
-  get xRange() new Range(this.left, this.right),
+  get xRange() {
+    return new Range(this.left, this.right);
+  },
 
   // ----------
   // Variable: yRange
   // Gives you a new <Range> for the vertical dimension.
-  get yRange() new Range(this.top, this.bottom),
+  get yRange() {
+    return new Range(this.top, this.bottom);
+  },
 
   // ----------
   // Function: intersects
   // Returns true if this rectangle intersects the given <Rect>.
   intersects: function Rect_intersects(rect) {
     return (rect.right > this.left &&
             rect.left < this.right &&
             rect.bottom > this.top &&
@@ -686,17 +694,17 @@ this.Utils = {
     }
     return value;
   },
 
   // ----------
   // Function: merge
   // Merge two array-like objects into the first and return it.
   merge: function Utils_merge(first, second) {
-    Array.forEach(second, function(el) Array.push(first, el));
+    Array.forEach(second, el => Array.push(first, el));
     return first;
   },
 
   // ----------
   // Function: extend
   // Pass several objects in and it will combine them all into the first object and return it.
   extend: function Utils_extend() {
 
--- a/browser/components/tabview/tabview.js
+++ b/browser/components/tabview/tabview.js
@@ -18,18 +18,22 @@ XPCOMUtils.defineLazyGetter(this, "tabvi
   return Services.strings.
     createBundle("chrome://browser/locale/tabview.properties");
 });
 XPCOMUtils.defineLazyGetter(this, "tabbrowserBundle", function() {
   return Services.strings.
     createBundle("chrome://browser/locale/tabbrowser.properties");
 });
 
-function tabviewString(name) tabviewBundle.GetStringFromName('tabview.' + name);
-function tabbrowserString(name) tabbrowserBundle.GetStringFromName(name);
+function tabviewString(name) {
+  return tabviewBundle.GetStringFromName('tabview.' + name);
+}
+function tabbrowserString(name) {
+  return tabbrowserBundle.GetStringFromName(name);
+}
 
 XPCOMUtils.defineLazyGetter(this, "gPrefBranch", function() {
   return Services.prefs.getBranch("browser.panorama.");
 });
 
 XPCOMUtils.defineLazyModuleGetter(this, "gPageThumbnails",
   "resource://gre/modules/PageThumbs.jsm", "PageThumbs");
 
@@ -47,17 +51,17 @@ var AllTabs = {
     move:         "TabMove",
     open:         "TabOpen",
     select:       "TabSelect",
     pinned:       "TabPinned",
     unpinned:     "TabUnpinned"
   },
 
   get tabs() {
-    return Array.filter(gBrowser.tabs, function (tab) Utils.isValidXULTab(tab));
+    return Array.filter(gBrowser.tabs, tab => Utils.isValidXULTab(tab));
   },
 
   register: function AllTabs_register(eventName, callback) {
     gBrowser.tabContainer.addEventListener(this._events[eventName], callback, false);
   },
 
   unregister: function AllTabs_unregister(eventName, callback) {
     gBrowser.tabContainer.removeEventListener(this._events[eventName], callback, false);
--- a/browser/components/tabview/trench.js
+++ b/browser/components/tabview/trench.js
@@ -82,17 +82,19 @@ Trench.prototype = {
     return "[Trench " + this.edge + " " + this.type +
            (this.parentItem ? " (" + this.parentItem + ")" : "") +
            "]";
   },
 
   //----------
   // Variable: radius
   // (integer) radius is how far away we should snap from
-  get radius() this.customRadius || Trenches.defaultRadius,
+  get radius() {
+    return this.customRadius || Trenches.defaultRadius;
+  },
 
   setParentItem: function Trench_setParentItem(item) {
     if (!item.isAnItem) {
       Utils.assert(false, "parentItem must be an Item");
       return false;
     }
     this.parentItem = item;
     return true;