Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components_lazy/CookiesTable.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return totalSize; 186 return totalSize;
187 }, 187 },
188 188
189 /** 189 /**
190 * @param {!Array.<!WebInspector.Cookie>} cookies 190 * @param {!Array.<!WebInspector.Cookie>} cookies
191 */ 191 */
192 _sortCookies: function(cookies) 192 _sortCookies: function(cookies)
193 { 193 {
194 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; 194 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1;
195 195
196 function compareTo(getter, cookie1, cookie2) 196 /**
197 * @param {string} property
198 * @param {!WebInspector.Cookie} cookie1
199 * @param {!WebInspector.Cookie} cookie2
200 */
201 function compareTo(property, cookie1, cookie2)
197 { 202 {
198 return sortDirection * (getter.apply(cookie1) + "").compareTo(getter .apply(cookie2) + ""); 203 return sortDirection * (String(cookie1[property] || cookie1["name"]) ).compareTo(
204 String(cookie2[property] || cookie2["name"]) );
199 } 205 }
200 206
201 function numberCompare(getter, cookie1, cookie2) 207 function numberCompare(getter, cookie1, cookie2)
202 { 208 {
203 return sortDirection * (getter.apply(cookie1) - getter.apply(cookie2 )); 209 return sortDirection * (getter.apply(cookie1) - getter.apply(cookie2 ));
204 } 210 }
205 211
206 function expiresCompare(cookie1, cookie2) 212 function expiresCompare(cookie1, cookie2)
207 { 213 {
208 if (cookie1.session() !== cookie2.session()) 214 if (cookie1.session() !== cookie2.session())
209 return sortDirection * (cookie1.session() ? 1 : -1); 215 return sortDirection * (cookie1.session() ? 1 : -1);
210 216
211 if (cookie1.session()) 217 if (cookie1.session())
212 return 0; 218 return 0;
213 219
214 if (cookie1.maxAge() && cookie2.maxAge()) 220 if (cookie1.maxAge() && cookie2.maxAge())
215 return sortDirection * (cookie1.maxAge() - cookie2.maxAge()); 221 return sortDirection * (cookie1.maxAge() - cookie2.maxAge());
216 if (cookie1.expires() && cookie2.expires()) 222 if (cookie1.expires() && cookie2.expires())
217 return sortDirection * (cookie1.expires() - cookie2.expires()); 223 return sortDirection * (cookie1.expires() - cookie2.expires());
218 return sortDirection * (cookie1.expires() ? 1 : -1); 224 return sortDirection * (cookie1.expires() ? 1 : -1);
219 } 225 }
220 226
221 var comparator; 227 var comparator;
222 switch (this._dataGrid.sortColumnId()) { 228 if (this._dataGrid.sortColumnId() === "expires")
223 case "name": comparator = compareTo.bind(null, WebInspector.Cookie.proto type.name); break; 229 comparator = expiresCompare;
224 case "value": comparator = compareTo.bind(null, WebInspector.Cookie.prot otype.value); break; 230 else
225 case "domain": comparator = compareTo.bind(null, WebInspector.Cookie.pro totype.domain); break; 231 compareTo.bind(null, this._dataGrid.sortColumnId());
dgozman 2016/11/01 00:04:07 comparator =
226 case "path": comparator = compareTo.bind(null, WebInspector.Cookie.proto type.path); break;
227 case "expires": comparator = expiresCompare; break;
228 case "size": comparator = numberCompare.bind(null, WebInspector.Cookie.p rototype.size); break;
dgozman 2016/11/01 00:04:07 numberCompare!
229 case "httpOnly": comparator = compareTo.bind(null, WebInspector.Cookie.p rototype.httpOnly); break;
230 case "secure": comparator = compareTo.bind(null, WebInspector.Cookie.pro totype.secure); break;
231 case "sameSite": comparator = compareTo.bind(null, WebInspector.Cookie.p rototype.sameSite); break;
232 default: compareTo.bind(null, WebInspector.Cookie.prototype.name);
233 }
234 232
235 cookies.sort(comparator); 233 cookies.sort(comparator);
236 }, 234 },
237 235
238 /** 236 /**
239 * @param {!WebInspector.Cookie} cookie 237 * @param {!WebInspector.Cookie} cookie
240 * @return {!WebInspector.DataGridNode} 238 * @return {!WebInspector.DataGridNode}
241 */ 239 */
242 _createGridNode: function(cookie) 240 _createGridNode: function(cookie)
243 { 241 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 }, 279 },
282 280
283 _refresh: function() 281 _refresh: function()
284 { 282 {
285 if (this._refreshCallback) 283 if (this._refreshCallback)
286 this._refreshCallback(); 284 this._refreshCallback();
287 }, 285 },
288 286
289 __proto__: WebInspector.VBox.prototype 287 __proto__: WebInspector.VBox.prototype
290 }; 288 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698