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

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

Issue 218613013: DevTools: Decouple shortcuts from actions, introduce shortcut contexts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased patch 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
« no previous file with comments | « Source/devtools/front_end/Main.js ('k') | Source/devtools/front_end/TabbedPane.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 this._cachedTypeClasses = {}; 53 this._cachedTypeClasses = {};
54 54
55 /** 55 /**
56 * @type {!Object.<string, !WebInspector.ModuleManager.ModuleDescriptor>} 56 * @type {!Object.<string, !WebInspector.ModuleManager.ModuleDescriptor>}
57 */ 57 */
58 this._descriptorsMap = {}; 58 this._descriptorsMap = {};
59 for (var i = 0; i < descriptors.length; ++i) 59 for (var i = 0; i < descriptors.length; ++i)
60 this._descriptorsMap[descriptors[i]["name"]] = descriptors[i]; 60 this._descriptorsMap[descriptors[i]["name"]] = descriptors[i];
61 } 61 }
62 62
63 /**
64 * @param {!WebInspector.ModuleManager.Extension} extension
65 * @param {?function(!Function):boolean} predicate
66 */
67 WebInspector.ModuleManager._checkExtensionApplicability = function(extension, pr edicate)
68 {
69 if (!predicate)
70 return false;
71 var contextTypes = /** @type {!Array.<string>|undefined} */ (extension.descr iptor().contextTypes);
72 if (!contextTypes)
73 return true;
74 for (var i = 0; i < contextTypes.length; ++i) {
75 var contextType = /** @type {!Function} */ (window.eval(contextTypes[i]) );
76 var isMatching = predicate(contextType);
77 if (isMatching)
78 return true;
79 }
80 return false;
81 }
82
83 /**
84 * @param {!WebInspector.ModuleManager.Extension} extension
85 * @param {?Object} context
86 * @return {boolean}
87 */
88 WebInspector.ModuleManager.isExtensionApplicableToContext = function(extension, context)
89 {
90 if (!context)
91 return true;
92 return WebInspector.ModuleManager._checkExtensionApplicability(extension, is InstanceOf);
93
94 /**
95 * @param {!Function} targetType
96 * @return {boolean}
97 */
98 function isInstanceOf(targetType)
99 {
100 return context instanceof targetType;
101 }
102 }
103
104 /**
105 * @param {!WebInspector.ModuleManager.Extension} extension
106 * @param {!Set.<!Function>=} currentContextTypes
107 * @return {boolean}
108 */
109 WebInspector.ModuleManager.isExtensionApplicableToContextTypes = function(extens ion, currentContextTypes)
110 {
111 if (!extension.descriptor().contextTypes)
112 return true;
113
114 return WebInspector.ModuleManager._checkExtensionApplicability(extension, cu rrentContextTypes ? isContextTypeKnown : null);
115
116 /**
117 * @param {!Function} targetType
118 * @return {boolean}
119 */
120 function isContextTypeKnown(targetType)
121 {
122 return currentContextTypes.contains(targetType);
123 }
124 }
125
63 WebInspector.ModuleManager.prototype = { 126 WebInspector.ModuleManager.prototype = {
64 /** 127 /**
65 * @param {!Array.<string>} configuration 128 * @param {!Array.<string>} configuration
66 */ 129 */
67 registerModules: function(configuration) 130 registerModules: function(configuration)
68 { 131 {
69 for (var i = 0; i < configuration.length; ++i) 132 for (var i = 0; i < configuration.length; ++i)
70 this.registerModule(configuration[i]); 133 this.registerModule(configuration[i]);
71 }, 134 },
72 135
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 return null; 394 return null;
332 return this._module._manager.resolve(this._type); 395 return this._module._manager.resolve(this._type);
333 }, 396 },
334 397
335 /** 398 /**
336 * @param {?Object} context 399 * @param {?Object} context
337 * @return {boolean} 400 * @return {boolean}
338 */ 401 */
339 isApplicable: function(context) 402 isApplicable: function(context)
340 { 403 {
341 var contextTypes = /** @type {!Array.<string>|undefined} */ (this._descr iptor.contextTypes); 404 return WebInspector.ModuleManager.isExtensionApplicableToContext(this, c ontext);
342 if (!contextTypes)
343 return true;
344 for (var i = 0; i < contextTypes.length; ++i) {
345 var contextType = /** @type {!Function} */ (window.eval(contextTypes [i]));
346 if (context instanceof contextType)
347 return true;
348 }
349 return false;
350 }, 405 },
351 406
352 /** 407 /**
353 * @return {?Object} 408 * @return {?Object}
354 */ 409 */
355 instance: function() 410 instance: function()
356 { 411 {
357 if (!this._className) 412 if (!this._className)
358 return null; 413 return null;
359 414
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 revealer.reveal(revealable, lineNumber); 460 revealer.reveal(revealable, lineNumber);
406 } 461 }
407 462
408 WebInspector.Revealer.prototype = { 463 WebInspector.Revealer.prototype = {
409 /** 464 /**
410 * @param {!Object} object 465 * @param {!Object} object
411 */ 466 */
412 reveal: function(object) {} 467 reveal: function(object) {}
413 } 468 }
414 469
415 /**
416 * @interface
417 */
418 WebInspector.ActionDelegate = function()
419 {
420 }
421
422 WebInspector.ActionDelegate.prototype = {
423 /**
424 * @param {!Event} event
425 * @return {boolean}
426 */
427 handleAction: function(event) {}
428 }
429
430 WebInspector.moduleManager = new WebInspector.ModuleManager(allDescriptors); 470 WebInspector.moduleManager = new WebInspector.ModuleManager(allDescriptors);
OLDNEW
« no previous file with comments | « Source/devtools/front_end/Main.js ('k') | Source/devtools/front_end/TabbedPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698