Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/resources/ApplicationPanelSidebar.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/resources/ApplicationPanelSidebar.js b/third_party/WebKit/Source/devtools/front_end/resources/ApplicationPanelSidebar.js |
| index d7a2d2266a37202ba02eb92d2594e26a69cc91b1..dc13456b99fca7377d5527862191c4a29ed0d138 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/resources/ApplicationPanelSidebar.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/resources/ApplicationPanelSidebar.js |
| @@ -103,12 +103,18 @@ Resources.ApplicationPanelSidebar = class extends UI.VBox { |
| /** @type {!Object.<string, boolean>} */ |
| this._domains = {}; |
| + /** @type {!Array<string>} */ |
| + this._storedSelection = []; |
| + |
| this._sidebarTree.contentElement.addEventListener('mousemove', this._onmousemove.bind(this), false); |
| this._sidebarTree.contentElement.addEventListener('mouseleave', this._onmouseleave.bind(this), false); |
| + this._sidebarTree.addEventListener(UI.TreeOutline.Events.ElementAttached, event => this._elementAdded(event)); |
|
dgozman
2017/05/11 23:08:41
this._elementAdded.bind(this)
eostroukhov
2017/05/12 19:36:36
Done. Waiting for "::" operator :)
|
| SDK.targetManager.observeTargets(this); |
| SDK.targetManager.addModelListener( |
| SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this); |
| + SDK.targetManager.addModelListener( |
| + SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.WillReloadPage, this._storeSelection, this); |
| } |
| /** |
| @@ -239,6 +245,36 @@ Resources.ApplicationPanelSidebar = class extends UI.VBox { |
| this.applicationCacheListTreeElement.setExpandable(false); |
| } |
| + _storeSelection() { |
| + this._storedSelection = []; |
| + for (var element = this._sidebarTree.selectedTreeElement; element; element = element.parent) |
| + this._storedSelection.push(element.itemURL); |
| + // "Forget" the selection if the item was not restored in a timely manner. |
| + // This is to prevent selection jumping on slow page loads. |
|
dgozman
2017/05/11 23:08:41
Why not on first user interaction?
eostroukhov
2017/05/12 19:36:36
Done.
|
| + setTimeout(() => this._storedSelection = [], 1000); |
| + } |
| + |
| + /** |
| + * @param {!Common.Event} event |
| + */ |
| + _elementAdded(event) { |
| + if (!this._storedSelection.length) |
| + return; |
| + var element = event.data; |
| + var index = this._storedSelection.indexOf(element.itemURL); |
| + if (index > 0) |
| + element.expand(); |
| + if (index !== 0) |
|
dgozman
2017/05/11 23:08:41
if (index)
eostroukhov
2017/05/12 19:36:36
Done.
(Node.js has opposite convention ;) )
|
| + return; |
| + for (var parent = element.parent; parent; parent = parent.parent) |
| + parent.expand(); |
| + var selected = this._sidebarTree.selectedTreeElement; |
| + if (!selected || this._storedSelection.indexOf(selected.itemURL) < 0) |
| + return; |
| + element.select(); |
| + this._storedSelection = []; |
| + } |
| + |
| _reset() { |
| this._domains = {}; |
| this._resetWebSQL(); |
| @@ -1246,9 +1282,6 @@ Resources.IDBDatabaseTreeElement = class extends Resources.BaseStorageTreeElemen |
| } |
| }; |
| -/** |
| - * @unrestricted |
| - */ |
| Resources.IDBObjectStoreTreeElement = class extends Resources.BaseStorageTreeElement { |
| /** |
| * @param {!Resources.ResourcesPanel} storagePanel |
| @@ -1261,6 +1294,9 @@ Resources.IDBObjectStoreTreeElement = class extends Resources.BaseStorageTreeEle |
| this._model = model; |
| this._databaseId = databaseId; |
| this._idbIndexTreeElements = {}; |
| + this._objectStore = objectStore; |
| + /** @type {?Resources.IDBDataView} */ |
| + this._view = null; |
| var icon = UI.Icon.create('mediumicon-table', 'resource-tree-item'); |
| this.setLeadingIcons([icon]); |
| } |
| @@ -1327,7 +1363,7 @@ Resources.IDBObjectStoreTreeElement = class extends Resources.BaseStorageTreeEle |
| this.expand(); |
| if (this._view) |
| - this._view.update(this._objectStore); |
| + this._view.update(this._objectStore, null); |
| this._updateTooltip(); |
| } |