Bug 1288558 - Part 10: Remove unnecessary signonsTree parameter passing between functions. r=MattN
authorSteve Chung <schung@mozilla.com>
Wed, 07 Sep 2016 18:36:15 -0700
changeset 354426 827f28a6ff64f6930588689ab120a99a84a61131
parent 354425 cc1837731206598c928e31b740cdf8c3fc4ad6f0
child 354427 3430dfafe8fd776eef81c751b6aca596335a5451
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1288558
milestone51.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 1288558 - Part 10: Remove unnecessary signonsTree parameter passing between functions. r=MattN MozReview-Commit-ID: CYWZqUuzaLq
toolkit/components/passwordmgr/content/passwordManager.js
--- a/toolkit/components/passwordmgr/content/passwordManager.js
+++ b/toolkit/components/passwordmgr/content/passwordManager.js
@@ -222,20 +222,20 @@ let signonsTreeView = {
       if (!value) {
         return;
       }
       _editLogin("password");
     }
   },
 };
 
-function SortTree(tree, column, ascending) {
+function SortTree(column, ascending) {
   let table = signonsTreeView._filterSet.length ? signonsTreeView._filterSet : signons;
   // remember which item was selected so we can restore it after the sort
-  let selections = GetTreeSelections(tree);
+  let selections = GetTreeSelections();
   let selectedNumber = selections.length ? table[selections[0]].number : -1;
 
   function compareFunc(a, b) {
     let valA, valB;
     switch (column) {
       case "hostname":
         let realmA = a.httpRealm;
         let realmB = b.httpRealm;
@@ -271,28 +271,28 @@ function SortTree(tree, column, ascendin
 
   // restore the selection
   let selectedRow = -1;
   if (selectedNumber >= 0 && false) {
     for (let s = 0; s < table.length; s++) {
       if (table[s].number == selectedNumber) {
         // update selection
         // note: we need to deselect before reselecting in order to trigger ...Selected()
-        tree.view.selection.select(-1);
-        tree.view.selection.select(s);
+        signonsTree.view.selection.select(-1);
+        signonsTree.view.selection.select(s);
         selectedRow = s;
         break;
       }
     }
   }
 
   // display the results
-  tree.treeBoxObject.invalidate();
+  signonsTree.treeBoxObject.invalidate();
   if (selectedRow >= 0) {
-    tree.treeBoxObject.ensureRowIsVisible(selectedRow);
+    signonsTree.treeBoxObject.ensureRowIsVisible(selectedRow);
   }
 }
 
 function LoadSignons() {
   // loads signons into table
   try {
     signons = Services.logins.getAllLogins();
   } catch (e) {
@@ -316,19 +316,19 @@ function LoadSignons() {
   } else {
     removeAllButton.removeAttribute("disabled");
     togglePasswordsButton.removeAttribute("disabled");
   }
 
   return true;
 }
 
-function GetTreeSelections(tree) {
+function GetTreeSelections() {
   let selections = [];
-  let select = tree.view.selection;
+  let select = signonsTree.view.selection;
   if (select) {
     let count = select.getRangeCount();
     let min = new Object();
     let max = new Object();
     for (let i=0; i<count; i++) {
       select.getRangeAt(i, min, max);
       for (let k=min.value; k<=max.value; k++) {
         if (k != -1) {
@@ -336,17 +336,17 @@ function GetTreeSelections(tree) {
         }
       }
     }
   }
   return selections;
 }
 
 function SignonSelected() {
-  let selections = GetTreeSelections(signonsTree);
+  let selections = GetTreeSelections();
   if (selections.length) {
     removeButton.removeAttribute("disabled");
   } else {
     removeButton.setAttribute("disabled", true);
   }
 }
 
 function DeleteSignon() {
@@ -355,17 +355,17 @@ function DeleteSignon() {
   let tree = signonsTree;
   let view = signonsTreeView;
   let table = filterSet.length ? filterSet : signons;
 
   // Turn off tree selection notifications during the deletion
   tree.view.selection.selectEventsSuppressed = true;
 
   // remove selected items from list (by setting them to null) and place in deleted list
-  let selections = GetTreeSelections(tree);
+  let selections = GetTreeSelections();
   for (let s = selections.length - 1; s >= 0; s--) {
     let i = selections[s];
     deletedSignons.push(table[i]);
     table[i] = null;
   }
 
   // collapse list by removing all the null entries
   for (let j = 0; j < table.length; j++) {
@@ -405,33 +405,32 @@ function DeleteAllSignons() {
                          kSignonBundle.getString("removeAllPasswordsTitle"),
                          kSignonBundle.getString("removeAllPasswordsPrompt"),
                          prompter.STD_YES_NO_BUTTONS + prompter.BUTTON_POS_1_DEFAULT,
                          null, null, null, null, dummy) == 1) // 1 == "No" button
     return;
 
   let filterSet = signonsTreeView._filterSet;
   let syncNeeded = (filterSet.length != 0);
-  let tree = signonsTree;
   let view = signonsTreeView;
   let table = filterSet.length ? filterSet : signons;
 
   // remove all items from table and place in deleted table
   for (let i = 0; i < table.length; i++) {
     deletedSignons.push(table[i]);
   }
   table.length = 0;
 
   // clear out selections
   view.selection.select(-1);
 
   // update the tree view and notify the tree
   view.rowCount = 0;
 
-  let box = tree.treeBoxObject;
+  let box = signonsTree.treeBoxObject;
   box.rowCountChanged(0, -deletedSignons.length);
   box.invalidate();
 
   // disable buttons
   removeButton.setAttribute("disabled", "true");
   removeAllButton.setAttribute("disabled", "true");
   FinalizeSignonDeletions(syncNeeded);
   Services.telemetry.getHistogramById("PWMGR_MANAGE_DELETED_ALL").add(1);
@@ -520,17 +519,17 @@ function SignonColumnSort(column) {
   // clear out the sortDirection attribute on the old column
   lastSortedCol.removeAttribute("sortDirection");
 
   // determine if sort is to be ascending or descending
   lastSignonSortAscending = (column == lastSignonSortColumn) ? !lastSignonSortAscending : true;
 
   // sort
   lastSignonSortColumn = column;
-  SortTree(signonsTree, lastSignonSortColumn, lastSignonSortAscending);
+  SortTree(lastSignonSortColumn, lastSignonSortAscending);
 
   // set the sortDirection attribute to get the styling going
   // first we need to get the right element
   sortedCol.setAttribute("sortDirection", lastSignonSortAscending ?
                                           "ascending" : "descending");
 }
 
 function SignonClearFilter() {