зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1295000 - Clean up for-loops in cookies.js. r=Standard8
MozReview-Commit-ID: KO3KTaPXLpS
This commit is contained in:
Родитель
ed5b15045c
Коммит
5e63b538ec
|
@ -129,15 +129,14 @@ var gCookiesWindow = {
|
|||
var rowIndex = 0;
|
||||
var cookieItem = null;
|
||||
if (!this._view._filtered) {
|
||||
for (var i = 0; i < this._hostOrder.length; ++i) { // (var host in this._hosts) {
|
||||
for (let host of this._hostsOrder) { // (var host in this._hosts) {
|
||||
++rowIndex;
|
||||
var hostItem = this._hosts[this._hostOrder[i]]; // var hostItem = this._hosts[host];
|
||||
var hostItem = this._hosts[host];
|
||||
if (this._hostOrder[i] == strippedHost) { // host == strippedHost) {
|
||||
// Host matches, look for the cookie within this Host collection
|
||||
// and update its data
|
||||
for (var j = 0; j < hostItem.cookies.length; ++j) {
|
||||
for (let currCookie of hostItem.cookies) {
|
||||
++rowIndex;
|
||||
var currCookie = hostItem.cookies[j];
|
||||
if (this._cookieEquals(currCookie, changedCookie, strippedHost)) {
|
||||
currCookie.value = changedCookie.value;
|
||||
currCookie.isSecure = changedCookie.isSecure;
|
||||
|
@ -156,8 +155,7 @@ var gCookiesWindow = {
|
|||
// Just walk the filter list to find the item. It doesn't matter that
|
||||
// we don't update the main Host collection when we do this, because
|
||||
// when the filter is reset the Host collection is rebuilt anyway.
|
||||
for (rowIndex = 0; rowIndex < this._view._filterSet.length; ++rowIndex) {
|
||||
currCookie = this._view._filterSet[rowIndex];
|
||||
for (let currCookie of this._view._filterSet) {
|
||||
if (this._cookieEquals(currCookie, changedCookie, strippedHost)) {
|
||||
currCookie.value = changedCookie.value;
|
||||
currCookie.isSecure = changedCookie.isSecure;
|
||||
|
@ -230,8 +228,8 @@ var gCookiesWindow = {
|
|||
count = hostIndex = cacheItem['count'];
|
||||
}
|
||||
|
||||
for (var i = start; i < gCookiesWindow._hostOrder.length; ++i) { // var host in gCookiesWindow._hosts) {
|
||||
var currHost = gCookiesWindow._hosts[gCookiesWindow._hostOrder[i]]; // gCookiesWindow._hosts[host];
|
||||
for (let i = start; i < gCookiesWindow._hostOrder.length; ++i) { // var host in gCookiesWindow._hosts) {
|
||||
let currHost = gCookiesWindow._hosts[gCookiesWindow._hostOrder[i]];// gCookiesWindow._hosts[host];
|
||||
if (!currHost) continue;
|
||||
if (count == aIndex)
|
||||
return currHost;
|
||||
|
@ -245,9 +243,8 @@ var gCookiesWindow = {
|
|||
// We are looking for an entry within this host's children,
|
||||
// enumerate them looking for the index.
|
||||
++count;
|
||||
for (var j = 0; j < currHost.cookies.length; ++j) {
|
||||
for (let cookie of currHost.cookies) {
|
||||
if (count == aIndex) {
|
||||
var cookie = currHost.cookies[j];
|
||||
cookie.parentIndex = hostIndex;
|
||||
return cookie;
|
||||
}
|
||||
|
@ -265,7 +262,7 @@ var gCookiesWindow = {
|
|||
else
|
||||
++count;
|
||||
|
||||
for (var k = cacheStart; k < count; k++)
|
||||
for (let k = cacheStart; k < count; k++)
|
||||
this._cacheItems[k] = cacheEntry;
|
||||
this._cacheValid = count - 1;
|
||||
}
|
||||
|
@ -390,7 +387,7 @@ var gCookiesWindow = {
|
|||
var item = this._getItemAtIndex(aIndex);
|
||||
if (item) {
|
||||
if (item.container) {
|
||||
for (var i = aIndex + 1; i < this.rowCount; ++i) {
|
||||
for (let i = aIndex + 1; i < this.rowCount; ++i) {
|
||||
var subsequent = this._getItemAtIndex(i);
|
||||
if (subsequent.container)
|
||||
return true;
|
||||
|
@ -549,8 +546,8 @@ var gCookiesWindow = {
|
|||
isSecure: aItem.isSecure ? this._bundle.getString("forSecureOnly")
|
||||
: this._bundle.getString("forAnyConnection"),
|
||||
userContext: this._getUserContextString(aItem.originAttributes.userContextId) };
|
||||
for (var i = 0; i < ids.length; ++i) {
|
||||
document.getElementById(ids[i]).disabled = false;
|
||||
for (let id of ids) {
|
||||
document.getElementById(id).disabled = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -558,11 +555,11 @@ var gCookiesWindow = {
|
|||
properties = { name: noneSelected, value: noneSelected, host: noneSelected,
|
||||
path: noneSelected, expires: noneSelected,
|
||||
isSecure: noneSelected, userContext: noneSelected };
|
||||
for (i = 0; i < ids.length; ++i) {
|
||||
document.getElementById(ids[i]).disabled = true;
|
||||
for (let id of ids) {
|
||||
document.getElementById(id).disabled = true;
|
||||
}
|
||||
}
|
||||
for (var property in properties)
|
||||
for (let property in properties)
|
||||
document.getElementById(property).value = properties[property];
|
||||
},
|
||||
|
||||
|
@ -578,10 +575,10 @@ var gCookiesWindow = {
|
|||
|
||||
var rangeCount = seln.getRangeCount();
|
||||
var selectedCookieCount = 0;
|
||||
for (var i = 0; i < rangeCount; ++i) {
|
||||
for (let i = 0; i < rangeCount; ++i) {
|
||||
var min = {}; var max = {};
|
||||
seln.getRangeAt(i, min, max);
|
||||
for (var j = min.value; j <= max.value; ++j) {
|
||||
for (let j = min.value; j <= max.value; ++j) {
|
||||
item = this._view._getItemAtIndex(j);
|
||||
if (!item) continue;
|
||||
if (item.container)
|
||||
|
@ -605,8 +602,7 @@ var gCookiesWindow = {
|
|||
var blockFutureCookies = false;
|
||||
if (psvc.prefHasUserValue("network.cookie.blockFutureCookies"))
|
||||
blockFutureCookies = psvc.getBoolPref("network.cookie.blockFutureCookies");
|
||||
for (var i = 0; i < deleteItems.length; ++i) {
|
||||
var item = deleteItems[i];
|
||||
for (let item of deleteItems) {
|
||||
this._cm.remove(item.host, item.name, item.path,
|
||||
blockFutureCookies, item.originAttributes);
|
||||
}
|
||||
|
@ -711,11 +707,11 @@ var gCookiesWindow = {
|
|||
// Traverse backwards through selections to avoid messing
|
||||
// up the indices when they are deleted.
|
||||
// See bug 388079.
|
||||
for (var i = rangeCount - 1; i >= 0; --i) {
|
||||
for (let i = rangeCount - 1; i >= 0; --i) {
|
||||
var min = {}; var max = {};
|
||||
seln.getRangeAt(i, min, max);
|
||||
nextSelected = min.value;
|
||||
for (var j = min.value; j <= max.value; ++j) {
|
||||
for (let j = min.value; j <= max.value; ++j) {
|
||||
deleteItems.push(this._view._getItemAtIndex(j));
|
||||
if (!this._view.hasNextSibling(-1, max.value))
|
||||
--nextSelected;
|
||||
|
@ -742,7 +738,7 @@ var gCookiesWindow = {
|
|||
if (this._view._filtered) {
|
||||
var rowCount = this._view.rowCount;
|
||||
var deleteItems = [];
|
||||
for (var index = 0; index < rowCount; index++) {
|
||||
for (let index = 0; index < rowCount; index++) {
|
||||
deleteItems.push(this._view._getItemAtIndex(index));
|
||||
}
|
||||
this._view._removeItemAtIndex(0, rowCount);
|
||||
|
@ -783,7 +779,7 @@ var gCookiesWindow = {
|
|||
function sortByProperty(a, b) {
|
||||
return a[aProperty].toLowerCase().localeCompare(b[aProperty].toLowerCase());
|
||||
}
|
||||
for (var host in this._hosts) {
|
||||
for (let host in this._hosts) {
|
||||
var cookies = this._hosts[host].cookies;
|
||||
cookies.sort(sortByProperty);
|
||||
if (!ascending)
|
||||
|
@ -845,14 +841,14 @@ var gCookiesWindow = {
|
|||
}
|
||||
|
||||
// Restore open state
|
||||
for (var i = 0; i < this._openIndices.length; ++i)
|
||||
this._view.toggleOpenState(this._openIndices[i]);
|
||||
for (let openIndex of this._openIndices) {
|
||||
this._view.toggleOpenState(openIndex);
|
||||
}
|
||||
this._openIndices = [];
|
||||
|
||||
// Restore selection
|
||||
this._view.selection.clearSelection();
|
||||
for (i = 0; i < this._lastSelectedRanges.length; ++i) {
|
||||
var range = this._lastSelectedRanges[i];
|
||||
for (let range of this._lastSelectedRanges) {
|
||||
this._view.selection.rangedSelect(range.min, range.max, true);
|
||||
}
|
||||
this._lastSelectedRanges = [];
|
||||
|
@ -870,11 +866,10 @@ var gCookiesWindow = {
|
|||
_filterCookies: function (aFilterValue) {
|
||||
this._view._filterValue = aFilterValue;
|
||||
var cookies = [];
|
||||
for (var i = 0; i < gCookiesWindow._hostOrder.length; ++i) { //var host in gCookiesWindow._hosts) {
|
||||
var currHost = gCookiesWindow._hosts[gCookiesWindow._hostOrder[i]]; // gCookiesWindow._hosts[host];
|
||||
for (let i = 0; i < gCookiesWindow._hostOrder.length; ++i) { //var host in gCookiesWindow._hosts) {
|
||||
let currHost = gCookiesWindow._hosts[gCookiesWindow._hostOrder[i]]; // gCookiesWindow._hosts[host];
|
||||
if (!currHost) continue;
|
||||
for (var j = 0; j < currHost.cookies.length; ++j) {
|
||||
var cookie = currHost.cookies[j];
|
||||
for (let cookie of currHost.cookies) {
|
||||
if (this._cookieMatchesFilter(cookie))
|
||||
cookies.push(cookie);
|
||||
}
|
||||
|
@ -889,7 +884,7 @@ var gCookiesWindow = {
|
|||
var seln = this._view.selection;
|
||||
this._lastSelectedRanges = [];
|
||||
var rangeCount = seln.getRangeCount();
|
||||
for (var i = 0; i < rangeCount; ++i) {
|
||||
for (let i = 0; i < rangeCount; ++i) {
|
||||
var min = {}; var max = {};
|
||||
seln.getRangeAt(i, min, max);
|
||||
this._lastSelectedRanges.push({ min: min.value, max: max.value });
|
||||
|
|
Загрузка…
Ссылка в новой задаче