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

Side by Side Diff: Source/devtools/front_end/components/ExecutionContextModel.js

Issue 1165393003: [DevTools] Update execution context title in select on frame navigation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TargetManager.Observer} 7 * @implements {WebInspector.TargetManager.Observer}
8 * @param {!Element} selectElement 8 * @param {!Element} selectElement
9 */ 9 */
10 WebInspector.ExecutionContextModel = function(selectElement) 10 WebInspector.ExecutionContextModel = function(selectElement)
11 { 11 {
12 this._selectElement = selectElement; 12 this._selectElement = selectElement;
13 /** 13 /**
14 * @type {!Map.<!WebInspector.ExecutionContext, !Element>} 14 * @type {!Map.<!WebInspector.ExecutionContext, !Element>}
15 */ 15 */
16 this._optionByExecutionContext = new Map(); 16 this._optionByExecutionContext = new Map();
17 17
18 WebInspector.targetManager.observeTargets(this); 18 WebInspector.targetManager.observeTargets(this);
19 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn spector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCre ated, this); 19 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn spector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCre ated, this);
20 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn spector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextD estroyed, this); 20 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn spector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextD estroyed, this);
21 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._onFrameNavigated , this);
21 22
22 this._selectElement.addEventListener("change", this._executionContextChanged .bind(this), false); 23 this._selectElement.addEventListener("change", this._executionContextChanged .bind(this), false);
23 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChangedExternally, this); 24 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChangedExternally, this);
24 } 25 }
25 26
26 WebInspector.ExecutionContextModel.prototype = { 27 WebInspector.ExecutionContextModel.prototype = {
27 /** 28 /**
28 * @param {!WebInspector.ExecutionContext} executionContext 29 * @param {!WebInspector.ExecutionContext} executionContext
29 * @return {string} 30 * @return {string}
30 */ 31 */
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 */ 104 */
104 _onExecutionContextDestroyed: function(event) 105 _onExecutionContextDestroyed: function(event)
105 { 106 {
106 var executionContext = /** @type {!WebInspector.ExecutionContext} */ (ev ent.data); 107 var executionContext = /** @type {!WebInspector.ExecutionContext} */ (ev ent.data);
107 this._executionContextDestroyed(executionContext); 108 this._executionContextDestroyed(executionContext);
108 }, 109 },
109 110
110 /** 111 /**
111 * @param {!WebInspector.Event} event 112 * @param {!WebInspector.Event} event
112 */ 113 */
114 _onFrameNavigated: function(event)
115 {
116 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data);
117 var executionContexts = this._optionByExecutionContext.keysArray();
118 for (var i = 0; i < executionContexts.length; ++i) {
119 var context = executionContexts[i];
120 if (context.frameId === frame.id)
121 this._optionByExecutionContext.get(context).text = this._titleFo r(context);
122 }
123 },
124
125 /**
126 * @param {!WebInspector.Event} event
127 */
113 _executionContextChangedExternally: function(event) 128 _executionContextChangedExternally: function(event)
114 { 129 {
115 var executionContext = /** @type {?WebInspector.ExecutionContext} */ (e vent.data); 130 var executionContext = /** @type {?WebInspector.ExecutionContext} */ (e vent.data);
116 if (!executionContext) 131 if (!executionContext)
117 return; 132 return;
118 133
119 var options = this._selectElement.options; 134 var options = this._selectElement.options;
120 for (var i = 0; i < options.length; ++i) { 135 for (var i = 0; i < options.length; ++i) {
121 if (options[i].__executionContext === executionContext) 136 if (options[i].__executionContext === executionContext)
122 this._select(options[i]); 137 this._select(options[i]);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 /** 178 /**
164 * @return {?Element} 179 * @return {?Element}
165 */ 180 */
166 _selectedOption: function() 181 _selectedOption: function()
167 { 182 {
168 if (this._selectElement.selectedIndex >= 0) 183 if (this._selectElement.selectedIndex >= 0)
169 return this._selectElement[this._selectElement.selectedIndex]; 184 return this._selectElement[this._selectElement.selectedIndex];
170 return null; 185 return null;
171 } 186 }
172 } 187 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698