Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. | 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * @constructor | 28 * @constructor |
| 29 * @extends {WebInspector.View} | 29 * @extends {WebInspector.View} |
| 30 */ | 30 */ |
| 31 WebInspector.DOMStorageItemsView = function(domStorage, domStorageModel) | 31 WebInspector.DOMStorageItemsView = function(domStorage) |
| 32 { | 32 { |
| 33 WebInspector.View.call(this); | 33 WebInspector.View.call(this); |
| 34 | 34 |
| 35 this.domStorage = domStorage; | 35 this.domStorage = domStorage; |
| 36 this.domStorageModel = domStorageModel; | |
| 37 | 36 |
| 38 this.element.addStyleClass("storage-view"); | 37 this.element.addStyleClass("storage-view"); |
| 39 this.element.addStyleClass("table"); | 38 this.element.addStyleClass("table"); |
| 40 | 39 |
| 41 this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString(" Delete"), "delete-storage-status-bar-item"); | 40 this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString(" Delete"), "delete-storage-status-bar-item"); |
| 42 this.deleteButton.visible = false; | 41 this.deleteButton.visible = false; |
| 43 this.deleteButton.addEventListener("click", this._deleteButtonClicked, this) ; | 42 this.deleteButton.addEventListener("click", this._deleteButtonClicked, this) ; |
| 44 | 43 |
| 45 this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString( "Refresh"), "refresh-storage-status-bar-item"); | 44 this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString( "Refresh"), "refresh-storage-status-bar-item"); |
| 46 this.refreshButton.addEventListener("click", this._refreshButtonClicked, thi s); | 45 this.refreshButton.addEventListener("click", this._refreshButtonClicked, thi s); |
| 47 | 46 |
| 48 this.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DO MStorageItemsCleared, this._domStorageItemsCleared, this); | 47 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emsCleared, this._domStorageItemsCleared, this); |
| 49 this.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DO MStorageItemRemoved, this._domStorageItemRemoved, this); | 48 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emRemoved, this._domStorageItemRemoved, this); |
| 50 this.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DO MStorageItemAdded, this._domStorageItemAdded, this); | 49 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emAdded, this._domStorageItemAdded, this); |
| 51 this.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DO MStorageItemUpdated, this._domStorageItemUpdated, this); | 50 this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageIt emUpdated, this._domStorageItemUpdated, this); |
| 52 } | 51 } |
| 53 | 52 |
| 54 WebInspector.DOMStorageItemsView.prototype = { | 53 WebInspector.DOMStorageItemsView.prototype = { |
| 55 get statusBarItems() | 54 get statusBarItems() |
| 56 { | 55 { |
| 57 return [this.refreshButton.element, this.deleteButton.element]; | 56 return [this.refreshButton.element, this.deleteButton.element]; |
| 58 }, | 57 }, |
| 59 | 58 |
| 60 wasShown: function() | 59 wasShown: function() |
| 61 { | 60 { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 var rootNode = this._dataGrid.rootNode(); | 136 var rootNode = this._dataGrid.rootNode(); |
| 138 var children = rootNode.children; | 137 var children = rootNode.children; |
| 139 | 138 |
| 140 event.consume(true); | 139 event.consume(true); |
| 141 this.deleteButton.visible = true; | 140 this.deleteButton.visible = true; |
| 142 | 141 |
| 143 for (var i = 0; i < children.length; ++i) | 142 for (var i = 0; i < children.length; ++i) |
| 144 if (children[i].data.key === storageData.key) | 143 if (children[i].data.key === storageData.key) |
| 145 return; | 144 return; |
| 146 | 145 |
| 147 var childNode = new WebInspector.DataGridNode({key: storageData.key, val ue: storageData.newValue}, false); | 146 var childNode = new WebInspector.DataGridNode({key: storageData.key, val ue: storageData.value}, false); |
| 148 rootNode.insertChild(childNode, children.length - 1); | 147 rootNode.insertChild(childNode, children.length - 1); |
| 149 }, | 148 }, |
| 150 | 149 |
| 151 /** | 150 /** |
| 152 * @param {WebInspector.Event} event | 151 * @param {WebInspector.Event} event |
| 153 */ | 152 */ |
| 154 _domStorageItemUpdated: function(event) | 153 _domStorageItemUpdated: function(event) |
| 155 { | 154 { |
| 156 if (!this.isShowing() || !this._dataGrid) | 155 if (!this.isShowing() || !this._dataGrid) |
| 157 return; | 156 return; |
| 158 | 157 |
| 159 var storageData = event.data; | 158 var storageData = event.data; |
| 160 var rootNode = this._dataGrid.rootNode(); | 159 var rootNode = this._dataGrid.rootNode(); |
| 161 var children = rootNode.children; | 160 var children = rootNode.children; |
| 162 | 161 |
| 163 event.consume(true); | 162 event.consume(true); |
| 164 | 163 |
| 165 var keyFound = false; | 164 var keyFound = false; |
| 166 for (var i = 0; i < children.length; ++i) { | 165 for (var i = 0; i < children.length; ++i) { |
| 167 var childNode = children[i]; | 166 var childNode = children[i]; |
| 168 if (childNode.data.key === storageData.key) { | 167 if (childNode.data.key === storageData.key) { |
| 169 if (keyFound) { | 168 if (keyFound) { |
| 170 rootNode.removeChild(childNode); | 169 rootNode.removeChild(childNode); |
| 171 return; | 170 return; |
| 172 } | 171 } |
| 173 keyFound = true; | 172 keyFound = true; |
| 174 if (childNode.data.value !== storageData.newValue) { | 173 if (childNode.data.value === storageData.oldValue) { |
|
pfeldman
2013/08/23 12:17:51
This changes semantics. Why?
vivekg__
2013/08/23 13:19:37
Oops, this was a stray local change slipped into t
| |
| 175 childNode.data.value = storageData.newValue; | 174 childNode.data.value = storageData.value; |
| 176 childNode.refresh(); | 175 childNode.refresh(); |
| 177 childNode.select(); | 176 childNode.select(); |
| 178 childNode.reveal(); | 177 childNode.reveal(); |
| 179 } | 178 } |
| 180 this.deleteButton.visible = true; | 179 this.deleteButton.visible = true; |
| 181 } | 180 } |
| 182 } | 181 } |
| 183 }, | 182 }, |
| 184 | 183 |
| 185 _update: function() | 184 _update: function() |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 { | 272 { |
| 274 if (!node || node.isCreationNode) | 273 if (!node || node.isCreationNode) |
| 275 return; | 274 return; |
| 276 | 275 |
| 277 if (this.domStorage) | 276 if (this.domStorage) |
| 278 this.domStorage.removeItem(node.data.key); | 277 this.domStorage.removeItem(node.data.key); |
| 279 }, | 278 }, |
| 280 | 279 |
| 281 __proto__: WebInspector.View.prototype | 280 __proto__: WebInspector.View.prototype |
| 282 } | 281 } |
| OLD | NEW |