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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js

Issue 2911363002: DevTools: Split SoftDropdown out of ConsoleContextSelector (Closed)
Patch Set: Created 3 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
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 * @implements {SDK.SDKModelObserver<!SDK.RuntimeModel>} 5 * @implements {SDK.SDKModelObserver<!SDK.RuntimeModel>}
6 * @implements {UI.ListDelegate<!SDK.ExecutionContext>} 6 * @implements {UI.SoftDropDown.Delegate<!SDK.ExecutionContext>}
7 */ 7 */
8 Console.ConsoleContextSelector = class { 8 Console.ConsoleContextSelector = class {
9 constructor() { 9 constructor() {
10 this._toolbarItem = new UI.ToolbarItem(createElementWithClass('button', 'con sole-context')); 10 /** @type {!UI.SoftDropDown<!SDK.ExecutionContext>} */
11 var shadowRoot = 11 this._dropDown = new UI.SoftDropDown(this);
12 UI.createShadowRootWithCoreStyles(this._toolbarItem.element, 'console/co nsoleContextSelectorButton.css'); 12 this._toolbarItem = new UI.ToolbarItem(this._dropDown.element);
13 this._titleElement = shadowRoot.createChild('span', 'title');
14 13
15 /** @type {!Map<!SDK.ExecutionContext, !ProductRegistry.BadgePool>} */ 14 /** @type {!Map<!SDK.ExecutionContext, !ProductRegistry.BadgePool>} */
16 this._badgePoolForExecutionContext = new Map(); 15 this._badgePoolForExecutionContext = new Map();
17 16
18 this._toolbarItem.element.classList.add('toolbar-has-dropdown'); 17 this._toolbarItem.element.classList.add('toolbar-has-dropdown');
19 this._toolbarItem.element.tabIndex = 0;
20 this._glassPane = new UI.GlassPane();
21 this._glassPane.setMarginBehavior(UI.GlassPane.MarginBehavior.NoMargin);
22 this._glassPane.setAnchorBehavior(UI.GlassPane.AnchorBehavior.PreferBottom);
23 this._glassPane.setOutsideClickCallback(this._hide.bind(this));
24 this._glassPane.setPointerEventsBehavior(UI.GlassPane.PointerEventsBehavior. BlockedByGlassPane);
25 this._list = new UI.ListControl(this, UI.ListMode.EqualHeightItems);
26 this._list.element.classList.add('context-list');
27 this._list.element.tabIndex = -1;
28 this._rowHeight = 36;
29 UI.createShadowRootWithCoreStyles(this._glassPane.contentElement, 'console/c onsoleContextSelector.css')
30 .appendChild(this._list.element);
31
32 this._listWasShowing200msAgo = false;
33 this._toolbarItem.element.addEventListener('mousedown', event => {
34 if (this._listWasShowing200msAgo)
35 this._hide(event);
36 else
37 this._show(event);
38 }, false);
39 this._toolbarItem.element.addEventListener('keydown', this._onKeyDown.bind(t his), false);
40 this._toolbarItem.element.addEventListener('focusout', this._hide.bind(this) , false);
41 this._list.element.addEventListener('mousedown', event => {
42 event.consume(true);
43 }, false);
44 this._list.element.addEventListener('mouseup', event => {
45 if (event.target === this._list.element)
46 return;
47
48 if (!this._listWasShowing200msAgo)
49 return;
50 this._updateSelectedContext();
51 this._hide(event);
52 }, false);
53
54 var dropdownArrowIcon = UI.Icon.create('smallicon-triangle-down');
55 shadowRoot.appendChild(dropdownArrowIcon);
56 18
57 SDK.targetManager.addModelListener( 19 SDK.targetManager.addModelListener(
58 SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextCreated, this. _onExecutionContextCreated, this); 20 SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextCreated, this. _onExecutionContextCreated, this);
59 SDK.targetManager.addModelListener( 21 SDK.targetManager.addModelListener(
60 SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextChanged, this. _onExecutionContextChanged, this); 22 SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextChanged, this. _onExecutionContextChanged, this);
61 SDK.targetManager.addModelListener( 23 SDK.targetManager.addModelListener(
62 SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextDestroyed, thi s._onExecutionContextDestroyed, this); 24 SDK.RuntimeModel, SDK.RuntimeModel.Events.ExecutionContextDestroyed, thi s._onExecutionContextDestroyed, this);
63 SDK.targetManager.addModelListener( 25 SDK.targetManager.addModelListener(
64 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this ._frameNavigated, this); 26 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this ._frameNavigated, this);
65 27
66 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChangedExternally, this); 28 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChangedExternally, this);
67 UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame, this._callFr ameSelectedInUI, this); 29 UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame, this._callFr ameSelectedInUI, this);
68 SDK.targetManager.observeModels(SDK.RuntimeModel, this); 30 SDK.targetManager.observeModels(SDK.RuntimeModel, this);
69 SDK.targetManager.addModelListener( 31 SDK.targetManager.addModelListener(
70 SDK.DebuggerModel, SDK.DebuggerModel.Events.CallFrameSelected, this._cal lFrameSelectedInModel, this); 32 SDK.DebuggerModel, SDK.DebuggerModel.Events.CallFrameSelected, this._cal lFrameSelectedInModel, this);
71 } 33 }
72 34
73 /** 35 /**
74 * @return {!UI.ToolbarItem} 36 * @return {!UI.ToolbarItem}
75 */ 37 */
76 toolbarItem() { 38 toolbarItem() {
77 return this._toolbarItem; 39 return this._toolbarItem;
78 } 40 }
79 41
80 /** 42 /**
81 * @param {!Event} event 43 * @override
44 * @param {?SDK.ExecutionContext} item
82 */ 45 */
83 _show(event) { 46 itemHighlighted(item) {
84 if (this._glassPane.isShowing())
85 return;
86 this._glassPane.setContentAnchorBox(this._toolbarItem.element.boxInWindow()) ;
87 this._glassPane.show(/** @type {!Document} **/ (this._toolbarItem.element.ow nerDocument));
88 this._updateGlasspaneSize();
89 var selectedContext = UI.context.flavor(SDK.ExecutionContext);
90 if (selectedContext) {
91 this._list.selectItem(selectedContext);
92 this._list.scrollItemIntoView(selectedContext, true);
93 }
94 this._toolbarItem.element.focus();
95 event.consume(true);
96 setTimeout(() => this._listWasShowing200msAgo = true, 200);
97 }
98
99 _updateGlasspaneSize() {
100 var maxHeight = this._rowHeight * (Math.min(this._list.length(), 9));
101 this._glassPane.setMaxContentSize(new UI.Size(315, maxHeight));
102 this._list.viewportResized();
103 }
104
105 /**
106 * @param {!Event} event
107 */
108 _hide(event) {
109 setTimeout(() => this._listWasShowing200msAgo = false, 200);
110 this._glassPane.hide();
111 SDK.OverlayModel.hideDOMNodeHighlight(); 47 SDK.OverlayModel.hideDOMNodeHighlight();
112 event.consume(true); 48 if (item && item.frameId) {
113 } 49 var resourceTreeModel = item.target().model(SDK.ResourceTreeModel);
114 50 if (resourceTreeModel)
115 /** 51 resourceTreeModel.domModel().overlayModel().highlightFrame(item.frameId) ;
caseq 2017/05/30 23:40:07 why not directly get OverlayModel for target?
einbinder 2017/05/31 21:14:26 I didn't realize you could just do that.
116 * @param {!Event} event
117 */
118 _onKeyDown(event) {
119 var handled = false;
120 switch (event.key) {
121 case 'ArrowUp':
122 handled = this._list.selectPreviousItem(false, false);
123 break;
124 case 'ArrowDown':
125 handled = this._list.selectNextItem(false, false);
126 break;
127 case 'ArrowRight':
128 var currentExecutionContext = this._list.selectedItem();
129 if (!currentExecutionContext)
130 break;
131 var nextExecutionContext = this._list.itemAtIndex(this._list.selectedInd ex() + 1);
132 if (nextExecutionContext && this._depthFor(currentExecutionContext) < th is._depthFor(nextExecutionContext))
133 handled = this._list.selectNextItem(false, false);
134 break;
135 case 'ArrowLeft':
136 var currentExecutionContext = this._list.selectedItem();
137 if (!currentExecutionContext)
138 break;
139 var depth = this._depthFor(currentExecutionContext);
140 for (var i = this._list.selectedIndex() - 1; i >= 0; i--) {
141 if (this._depthFor(this._list.itemAtIndex(i)) < depth) {
142 handled = true;
143 this._list.selectItem(this._list.itemAtIndex(i), false);
144 break;
145 }
146 }
147 break;
148 case 'PageUp':
149 handled = this._list.selectItemPreviousPage(false);
150 break;
151 case 'PageDown':
152 handled = this._list.selectItemNextPage(false);
153 break;
154 case 'Home':
155 for (var i = 0; i < this._list.length(); i++) {
156 if (this.isItemSelectable(this._list.itemAtIndex(i))) {
157 this._list.selectItem(this._list.itemAtIndex(i));
158 handled = true;
159 break;
160 }
161 }
162 break;
163 case 'End':
164 for (var i = this._list.length() - 1; i >= 0; i--) {
165 if (this.isItemSelectable(this._list.itemAtIndex(i))) {
166 this._list.selectItem(this._list.itemAtIndex(i));
167 handled = true;
168 break;
169 }
170 }
171 break;
172 case 'Escape':
173 this._hide(event);
174 break;
175 case 'Tab':
176 if (!this._glassPane.isShowing())
177 break;
178 this._updateSelectedContext();
179 this._hide(event);
180 break;
181 case 'Enter':
182 if (!this._glassPane.isShowing()) {
183 this._show(event);
184 break;
185 }
186 this._updateSelectedContext();
187 this._hide(event);
188 break;
189 case ' ':
190 this._show(event);
191 break;
192 default:
193 if (event.key.length === 1) {
194 var selectedIndex = this._list.selectedIndex();
195 var letter = event.key.toUpperCase();
196 for (var i = 0; i < this._list.length(); i++) {
197 var context = this._list.itemAtIndex((selectedIndex + i + 1) % this. _list.length());
198 if (this._titleFor(context).toUpperCase().startsWith(letter)) {
199 this._list.selectItem(context);
200 break;
201 }
202 }
203 handled = true;
204 }
205 break;
206 }
207
208 if (handled) {
209 event.consume(true);
210 this._updateSelectedContext();
211 } 52 }
212 } 53 }
213 54
214 /** 55 /**
56 * @override
215 * @param {!SDK.ExecutionContext} executionContext 57 * @param {!SDK.ExecutionContext} executionContext
216 * @return {string} 58 * @return {string}
217 */ 59 */
218 _titleFor(executionContext) { 60 titleFor(executionContext) {
219 var target = executionContext.target(); 61 var target = executionContext.target();
220 var label = executionContext.label() ? target.decorateLabel(executionContext .label()) : ''; 62 var label = executionContext.label() ? target.decorateLabel(executionContext .label()) : '';
221 if (executionContext.frameId) { 63 if (executionContext.frameId) {
222 var resourceTreeModel = target.model(SDK.ResourceTreeModel); 64 var resourceTreeModel = target.model(SDK.ResourceTreeModel);
223 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId); 65 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId);
224 if (frame) 66 if (frame)
225 label = label || frame.displayName(); 67 label = label || frame.displayName();
226 } 68 }
227 label = label || executionContext.origin; 69 label = label || executionContext.origin;
228 70
229 return label; 71 return label;
230 } 72 }
231 73
232 /** 74 /**
75 * @override
233 * @param {!SDK.ExecutionContext} executionContext 76 * @param {!SDK.ExecutionContext} executionContext
234 * @return {number} 77 * @return {number}
235 */ 78 */
236 _depthFor(executionContext) { 79 depthFor(executionContext) {
237 var target = executionContext.target(); 80 var target = executionContext.target();
238 var depth = 0; 81 var depth = 0;
239 if (!executionContext.isDefault) 82 if (!executionContext.isDefault)
240 depth++; 83 depth++;
241 if (executionContext.frameId) { 84 if (executionContext.frameId) {
242 var resourceTreeModel = target.model(SDK.ResourceTreeModel); 85 var resourceTreeModel = target.model(SDK.ResourceTreeModel);
243 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId); 86 var frame = resourceTreeModel && resourceTreeModel.frameForId(executionCon text.frameId);
244 while (frame && frame.parentFrame) { 87 while (frame && frame.parentFrame) {
245 depth++; 88 depth++;
246 frame = frame.parentFrame; 89 frame = frame.parentFrame;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 133
291 /** 134 /**
292 * @param {!SDK.ExecutionContext} executionContext 135 * @param {!SDK.ExecutionContext} executionContext
293 */ 136 */
294 _executionContextCreated(executionContext) { 137 _executionContextCreated(executionContext) {
295 // FIXME(413886): We never want to show execution context for the main threa d of shadow page in service/shared worker frontend. 138 // FIXME(413886): We never want to show execution context for the main threa d of shadow page in service/shared worker frontend.
296 // This check could be removed once we do not send this context to frontend. 139 // This check could be removed once we do not send this context to frontend.
297 if (!executionContext.target().hasJSCapability()) 140 if (!executionContext.target().hasJSCapability())
298 return; 141 return;
299 142
300 this._list.insertItemWithComparator(executionContext, executionContext.runti meModel.executionContextComparator()); 143 this._dropDown.insertItemWithComparator(
144 executionContext, executionContext.runtimeModel.executionContextComparat or());
301 145
302 if (executionContext === UI.context.flavor(SDK.ExecutionContext)) 146 if (executionContext === UI.context.flavor(SDK.ExecutionContext))
303 this._updateSelectionTitle(); 147 this._dropDown.selectItem(executionContext);
304 } 148 }
305 149
306 /** 150 /**
307 * @param {!Common.Event} event 151 * @param {!Common.Event} event
308 */ 152 */
309 _onExecutionContextCreated(event) { 153 _onExecutionContextCreated(event) {
310 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data); 154 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data);
311 this._executionContextCreated(executionContext); 155 this._executionContextCreated(executionContext);
312 this._updateSelectionTitle();
313 this._updateGlasspaneSize();
314 } 156 }
315 157
316 /** 158 /**
317 * @param {!Common.Event} event 159 * @param {!Common.Event} event
318 */ 160 */
319 _onExecutionContextChanged(event) { 161 _onExecutionContextChanged(event) {
320 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data); 162 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data);
321 if (this._list.indexOfItem(executionContext) === -1)
322 return;
323 this._executionContextDestroyed(executionContext); 163 this._executionContextDestroyed(executionContext);
324 this._executionContextCreated(executionContext); 164 this._executionContextCreated(executionContext);
325 this._updateSelectionTitle();
326 } 165 }
327 166
328 /** 167 /**
329 * @param {!SDK.ExecutionContext} executionContext 168 * @param {!SDK.ExecutionContext} executionContext
330 */ 169 */
331 _executionContextDestroyed(executionContext) { 170 _executionContextDestroyed(executionContext) {
332 if (this._list.indexOfItem(executionContext) === -1)
333 return;
334 this._disposeExecutionContextBadge(executionContext); 171 this._disposeExecutionContextBadge(executionContext);
335 this._list.removeItem(executionContext); 172 this._dropDown.removeItem(executionContext);
336 this._updateGlasspaneSize();
337 } 173 }
338 174
339 /** 175 /**
340 * @param {!Common.Event} event 176 * @param {!Common.Event} event
341 */ 177 */
342 _onExecutionContextDestroyed(event) { 178 _onExecutionContextDestroyed(event) {
343 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data); 179 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data);
344 this._executionContextDestroyed(executionContext); 180 this._executionContextDestroyed(executionContext);
345 this._updateSelectionTitle();
346 } 181 }
347 182
348 /** 183 /**
349 * @param {!Common.Event} event 184 * @param {!Common.Event} event
350 */ 185 */
351 _executionContextChangedExternally(event) { 186 _executionContextChangedExternally(event) {
352 var executionContext = /** @type {?SDK.ExecutionContext} */ (event.data); 187 var executionContext = /** @type {?SDK.ExecutionContext} */ (event.data);
353 if (!executionContext || this._list.indexOfItem(executionContext) === -1) 188 this._dropDown.selectItem(executionContext);
354 return;
355 this._list.selectItem(executionContext);
356 this._updateSelectedContext();
357 }
358
359 _updateSelectionTitle() {
360 var executionContext = UI.context.flavor(SDK.ExecutionContext);
361 if (executionContext)
362 this._titleElement.textContent = this._titleFor(executionContext);
363 else
364 this._titleElement.textContent = '';
365 this._toolbarItem.element.classList.toggle(
366 'warning', !this._isTopContext(executionContext) && this._hasTopContext( ));
367 } 189 }
368 190
369 /** 191 /**
370 * @param {?SDK.ExecutionContext} executionContext 192 * @param {?SDK.ExecutionContext} executionContext
371 * @return {boolean} 193 * @return {boolean}
372 */ 194 */
373 _isTopContext(executionContext) { 195 _isTopContext(executionContext) {
374 if (!executionContext || !executionContext.isDefault) 196 if (!executionContext || !executionContext.isDefault)
375 return false; 197 return false;
376 var resourceTreeModel = executionContext.target().model(SDK.ResourceTreeMode l); 198 var resourceTreeModel = executionContext.target().model(SDK.ResourceTreeMode l);
377 var frame = executionContext.frameId && resourceTreeModel && resourceTreeMod el.frameForId(executionContext.frameId); 199 var frame = executionContext.frameId && resourceTreeModel && resourceTreeMod el.frameForId(executionContext.frameId);
378 if (!frame) 200 if (!frame)
379 return false; 201 return false;
380 return frame.isMainFrame(); 202 return frame.isMainFrame();
381 } 203 }
382 204
383 /** 205 /**
384 * @return {boolean} 206 * @return {boolean}
385 */ 207 */
386 _hasTopContext() { 208 _hasTopContext() {
387 for (var i = 0; i < this._list.length(); i++) { 209 var mainTarget = SDK.targetManager.mainTarget();
388 if (this._isTopContext(this._list.itemAtIndex(i))) 210 if (!mainTarget)
389 return true; 211 return false;
390 } 212 var resourceTreeModel = mainTarget.model(SDK.ResourceTreeModel);
391 return false; 213 if (!resourceTreeModel)
214 return false;
215 return !!resourceTreeModel.mainFrame;
392 } 216 }
393 217
394 /** 218 /**
395 * @override 219 * @override
396 * @param {!SDK.RuntimeModel} runtimeModel 220 * @param {!SDK.RuntimeModel} runtimeModel
397 */ 221 */
398 modelAdded(runtimeModel) { 222 modelAdded(runtimeModel) {
399 runtimeModel.executionContexts().forEach(this._executionContextCreated, this ); 223 runtimeModel.executionContexts().forEach(this._executionContextCreated, this );
400 } 224 }
401 225
402 /** 226 /**
403 * @override 227 * @override
404 * @param {!SDK.RuntimeModel} runtimeModel 228 * @param {!SDK.RuntimeModel} runtimeModel
405 */ 229 */
406 modelRemoved(runtimeModel) { 230 modelRemoved(runtimeModel) {
407 for (var i = 0; i < this._list.length(); i++) { 231 for (var executionContext of runtimeModel.executionContexts())
408 if (this._list.itemAtIndex(i).runtimeModel === runtimeModel) 232 this._executionContextDestroyed(executionContext);
409 this._executionContextDestroyed(this._list.itemAtIndex(i));
410 }
411 } 233 }
412 234
413 /** 235 /**
414 * @override 236 * @override
415 * @param {!SDK.ExecutionContext} item 237 * @param {!SDK.ExecutionContext} item
416 * @return {!Element} 238 * @return {!Element}
417 */ 239 */
418 createElementForItem(item) { 240 elementForItem(item) {
419 var element = createElementWithClass('div', 'context'); 241 var element = createElementWithClass('div', 'context');
420 element.style.paddingLeft = (8 + this._depthFor(item) * 15) + 'px';
421 // var titleArea = element.createChild('div', 'title-area');
422 var title = element.createChild('div', 'title'); 242 var title = element.createChild('div', 'title');
423 title.createTextChild(this._titleFor(item).trimEnd(100)); 243 title.createTextChild(this.titleFor(item).trimEnd(100));
424 var subTitle = element.createChild('div', 'subtitle'); 244 var subTitle = element.createChild('div', 'subtitle');
425 var badgeElement = this._badgeFor(item); 245 var badgeElement = this._badgeFor(item);
426 if (badgeElement) { 246 if (badgeElement) {
427 badgeElement.classList.add('badge'); 247 badgeElement.classList.add('badge');
428 subTitle.appendChild(badgeElement); 248 subTitle.appendChild(badgeElement);
429 } 249 }
430 subTitle.createTextChild(this._subtitleFor(item)); 250 subTitle.createTextChild(this._subtitleFor(item));
431 element.addEventListener('mousemove', e => {
432 if ((e.movementX || e.movementY) && this.isItemSelectable(item))
433 this._list.selectItem(item, false, /* Don't scroll */ true);
434 });
435 element.classList.toggle('disabled', !this.isItemSelectable(item));
436 return element; 251 return element;
437 } 252 }
438 253
439 /** 254 /**
440 * @param {!SDK.ExecutionContext} executionContext 255 * @param {!SDK.ExecutionContext} executionContext
441 * @return {string} 256 * @return {string}
442 */ 257 */
443 _subtitleFor(executionContext) { 258 _subtitleFor(executionContext) {
444 var target = executionContext.target(); 259 var target = executionContext.target();
445 if (executionContext.frameId) { 260 if (executionContext.frameId) {
(...skipping 13 matching lines...) Expand all
459 if (callFrame) 274 if (callFrame)
460 return new Common.ParsedURL(callFrame.url).domain(); 275 return new Common.ParsedURL(callFrame.url).domain();
461 return Common.UIString('IFrame'); 276 return Common.UIString('IFrame');
462 } 277 }
463 return ''; 278 return '';
464 } 279 }
465 280
466 /** 281 /**
467 * @override 282 * @override
468 * @param {!SDK.ExecutionContext} item 283 * @param {!SDK.ExecutionContext} item
469 * @return {number}
470 */
471 heightForItem(item) {
472 return this._rowHeight;
473 }
474
475 /**
476 * @override
477 * @param {!SDK.ExecutionContext} item
478 * @return {boolean} 284 * @return {boolean}
479 */ 285 */
480 isItemSelectable(item) { 286 isItemSelectable(item) {
481 var callFrame = item.debuggerModel.selectedCallFrame(); 287 var callFrame = item.debuggerModel.selectedCallFrame();
482 var callFrameContext = callFrame && callFrame.script.executionContext(); 288 var callFrameContext = callFrame && callFrame.script.executionContext();
483 return !callFrameContext || item === callFrameContext; 289 return !callFrameContext || item === callFrameContext;
484 } 290 }
485 291
486 /** 292 /**
487 * @override 293 * @override
488 * @param {?SDK.ExecutionContext} from 294 * @param {?SDK.ExecutionContext} item
489 * @param {?SDK.ExecutionContext} to
490 * @param {?Element} fromElement
491 * @param {?Element} toElement
492 */ 295 */
493 selectedItemChanged(from, to, fromElement, toElement) { 296 itemSelected(item) {
494 if (fromElement) 297 this._toolbarItem.element.classList.toggle('warning', !this._isTopContext(it em) && this._hasTopContext());
495 fromElement.classList.remove('selected'); 298 UI.context.setFlavor(SDK.ExecutionContext, item);
496 if (toElement)
497 toElement.classList.add('selected');
498 SDK.OverlayModel.hideDOMNodeHighlight();
499 if (to && to.frameId) {
500 var resourceTreeModel = to.target().model(SDK.ResourceTreeModel);
501 if (resourceTreeModel)
502 resourceTreeModel.domModel().overlayModel().highlightFrame(to.frameId);
503 }
504 }
505
506 _updateSelectedContext() {
507 var context = this._list.selectedItem();
508 UI.context.setFlavor(SDK.ExecutionContext, context);
509 this._updateSelectionTitle();
510 } 299 }
511 300
512 _callFrameSelectedInUI() { 301 _callFrameSelectedInUI() {
513 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); 302 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame);
514 var callFrameContext = callFrame && callFrame.script.executionContext(); 303 var callFrameContext = callFrame && callFrame.script.executionContext();
515 if (callFrameContext) 304 if (callFrameContext)
516 UI.context.setFlavor(SDK.ExecutionContext, callFrameContext); 305 UI.context.setFlavor(SDK.ExecutionContext, callFrameContext);
517 } 306 }
518 307
519 /** 308 /**
520 * @param {!Common.Event} event 309 * @param {!Common.Event} event
521 */ 310 */
522 _callFrameSelectedInModel(event) { 311 _callFrameSelectedInModel(event) {
523 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.data); 312 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.data);
524 for (var i = 0; i < this._list.length(); i++) { 313 for (var executionContext of debuggerModel.runtimeModel().executionContexts( )) {
525 if (this._list.itemAtIndex(i).debuggerModel === debuggerModel) { 314 if (executionContext.debuggerModel === debuggerModel) {
526 this._disposeExecutionContextBadge(this._list.itemAtIndex(i)); 315 this._disposeExecutionContextBadge(executionContext);
527 this._list.refreshItemsInRange(i, i + 1); 316 this._dropDown.refreshItem(executionContext);
528 } 317 }
529 } 318 }
530 } 319 }
531 320
532 /** 321 /**
533 * @param {!Common.Event} event 322 * @param {!Common.Event} event
534 */ 323 */
535 _frameNavigated(event) { 324 _frameNavigated(event) {
536 var frameId = event.data.id; 325 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data);
537 for (var i = 0; i < this._list.length(); i++) { 326 var runtimeModel = frame.resourceTreeModel().target().model(SDK.RuntimeModel );
538 if (frameId === this._list.itemAtIndex(i).frameId) { 327 if (!runtimeModel)
539 this._disposeExecutionContextBadge(this._list.itemAtIndex(i)); 328 return;
540 this._list.refreshItemsInRange(i, i + 1); 329 for (var executionContext of runtimeModel.executionContexts()) {
330 if (frame.id === executionContext.frameId) {
331 this._disposeExecutionContextBadge(executionContext);
332 this._dropDown.refreshItem(executionContext);
541 } 333 }
542 } 334 }
543 } 335 }
544 }; 336 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698