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