Bug 1342025 - reduce calls to ctrlTab.updatePreview draft
authormilindl <i.milind.luthra@gmail.com>
Sun, 05 Mar 2017 17:10:04 +0530
changeset 493636 9d61cbe1da118885542237e0f458d850f4aa6619
parent 493537 eb23648534779c110f3a1f2baae1849ae4a9c570
child 494602 553fc72bde0ffacc1101d1a4fa8d9dbfbb18b75e
child 495223 af24ddb7443bb2f605c8798e38d5fd3e40c72827
child 495237 7031e664d2e26ba353dbd74d9ee4f5d9cd99182b
child 497189 191d8776453f2e0e2844a38daf134a5add46560b
child 497190 76f4d9e033d1352867d913a1b7e4b0fccab687aa
child 497213 a916d73ab47c38213eaa2c12315042c6ff258e11
child 497214 38daba16295239b979c6dca964780674ed1641a4
child 498442 52d3b965493517c084e2c71a4e29bc3b938a1781
push id47819
push userbmo:i.milind.luthra@gmail.com
push dateSun, 05 Mar 2017 14:41:41 +0000
bugs1342025
milestone54.0a1
Bug 1342025 - reduce calls to ctrlTab.updatePreview Added if condition to do so MozReview-Commit-ID: CzYCZgEtZS5
browser/base/content/browser-ctrlTab.js
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -1,8 +1,9 @@
+
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Tab previews utility, produces thumbnails
  */
 var tabPreviews = {
@@ -468,21 +469,25 @@ var ctrlTab = {
   },
 
   handleEvent: function ctrlTab_handleEvent(event) {
     switch (event.type) {
       case "SSWindowRestored":
         this._initRecentlyUsedTabs();
         break;
       case "TabAttrModified":
-        // tab attribute modified (e.g. label, busy, image, selected)
-        for (let i = this.previews.length - 1; i >= 0; i--) {
-          if (this.previews[i]._tab && this.previews[i]._tab == event.target) {
-            this.updatePreview(this.previews[i], event.target);
-            break;
+        // tab attribute modified (i.e. label, busy, image, selected)
+        // update preview only if tab attribute modified in the list
+        if (event.detail.changed.some(
+          (elem, ind, arr) => ["label", "busy", "image", "selected"].includes(elem))) {
+          for (let i = this.previews.length - 1; i >= 0; i--) {
+            if (this.previews[i]._tab && this.previews[i]._tab == event.target) {
+              this.updatePreview(this.previews[i], event.target);
+              break;
+            }
           }
         }
         break;
       case "TabSelect":
         this.detachTab(event.target);
         this.attachTab(event.target, 0);
         break;
       case "TabOpen":