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

Side by Side Diff: Source/devtools/front_end/utilities.js

Issue 218613013: DevTools: Decouple shortcuts from actions, introduce shortcut contexts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments - take 1 Created 6 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 * @constructor 1107 * @constructor
1108 * @template T 1108 * @template T
1109 */ 1109 */
1110 var Set = function() 1110 var Set = function()
1111 { 1111 {
1112 /** @type {!Object.<string, !T>} */ 1112 /** @type {!Object.<string, !T>} */
1113 this._set = {}; 1113 this._set = {};
1114 this._size = 0; 1114 this._size = 0;
1115 } 1115 }
1116 1116
1117 /**
1118 * @param {!Array.<!T>} array
1119 * @return {!Set.<T>}
1120 * @template T
1121 */
1122 Set.fromArray = function(array)
1123 {
1124 var result = new Set();
1125 array.forEach(function(item) { result.add(item); });
1126 return result;
1127 }
1128
1117 Set.prototype = { 1129 Set.prototype = {
1118 /** 1130 /**
1119 * @param {!T} item 1131 * @param {!T} item
1120 */ 1132 */
1121 add: function(item) 1133 add: function(item)
1122 { 1134 {
1123 var objectIdentifier = item.__identifier; 1135 var objectIdentifier = item.__identifier;
1124 if (!objectIdentifier) { 1136 if (!objectIdentifier) {
1125 objectIdentifier = createObjectIdentifier(); 1137 objectIdentifier = createObjectIdentifier();
1126 item.__identifier = objectIdentifier; 1138 item.__identifier = objectIdentifier;
(...skipping 26 matching lines...) Expand all
1153 var i = 0; 1165 var i = 0;
1154 for (var objectIdentifier in this._set) 1166 for (var objectIdentifier in this._set)
1155 result[i++] = this._set[objectIdentifier]; 1167 result[i++] = this._set[objectIdentifier];
1156 return result; 1168 return result;
1157 }, 1169 },
1158 1170
1159 /** 1171 /**
1160 * @param {!T} item 1172 * @param {!T} item
1161 * @return {boolean} 1173 * @return {boolean}
1162 */ 1174 */
1163 hasItem: function(item) 1175 contains: function(item)
1164 { 1176 {
1165 return !!this._set[item.__identifier]; 1177 return !!this._set[item.__identifier];
1166 }, 1178 },
1167 1179
1168 /** 1180 /**
1169 * @return {number} 1181 * @return {number}
1170 */ 1182 */
1171 size: function() 1183 size: function()
1172 { 1184 {
1173 return this._size; 1185 return this._size;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 * @constructor 1459 * @constructor
1448 */ 1460 */
1449 var StringSet = function() 1461 var StringSet = function()
1450 { 1462 {
1451 /** @type {!StringMap.<boolean>} */ 1463 /** @type {!StringMap.<boolean>} */
1452 this._map = new StringMap(); 1464 this._map = new StringMap();
1453 } 1465 }
1454 1466
1455 /** 1467 /**
1456 * @param {!Array.<string>} array 1468 * @param {!Array.<string>} array
1469 * @return {!StringSet}
1457 */ 1470 */
1458 StringSet.fromArray = function(array) 1471 StringSet.fromArray = function(array)
1459 { 1472 {
1460 var result = new StringSet(); 1473 var result = new StringSet();
1461 array.forEach(function(item) { result.add(item); }); 1474 array.forEach(function(item) { result.add(item); });
1462 return result; 1475 return result;
1463 } 1476 }
1464 1477
1465 StringSet.prototype = { 1478 StringSet.prototype = {
1466 /** 1479 /**
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 this._outgoingCallback(); 1637 this._outgoingCallback();
1625 } 1638 }
1626 } 1639 }
1627 1640
1628 /** 1641 /**
1629 * @param {*} value 1642 * @param {*} value
1630 */ 1643 */
1631 function suppressUnused(value) 1644 function suppressUnused(value)
1632 { 1645 {
1633 } 1646 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698