| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The Chromium Authors. All rights reserved. | 2 * Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 /** | 6 /** |
| 7 * @interface | 7 * @interface |
| 8 */ | 8 */ |
| 9 WebInspector.LayerView = function() {}; | 9 LayerViewer.LayerView = function() {}; |
| 10 | 10 |
| 11 WebInspector.LayerView.prototype = { | 11 LayerViewer.LayerView.prototype = { |
| 12 /** | 12 /** |
| 13 * @param {?WebInspector.LayerView.Selection} selection | 13 * @param {?LayerViewer.LayerView.Selection} selection |
| 14 */ | 14 */ |
| 15 hoverObject: function(selection) {}, | 15 hoverObject: function(selection) {}, |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * @param {?WebInspector.LayerView.Selection} selection | 18 * @param {?LayerViewer.LayerView.Selection} selection |
| 19 */ | 19 */ |
| 20 selectObject: function(selection) {}, | 20 selectObject: function(selection) {}, |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * @param {?WebInspector.LayerTreeBase} layerTree | 23 * @param {?SDK.LayerTreeBase} layerTree |
| 24 */ | 24 */ |
| 25 setLayerTree: function(layerTree) {} | 25 setLayerTree: function(layerTree) {} |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @unrestricted | 29 * @unrestricted |
| 30 */ | 30 */ |
| 31 WebInspector.LayerView.Selection = class { | 31 LayerViewer.LayerView.Selection = class { |
| 32 /** | 32 /** |
| 33 * @param {!WebInspector.LayerView.Selection.Type} type | 33 * @param {!LayerViewer.LayerView.Selection.Type} type |
| 34 * @param {!WebInspector.Layer} layer | 34 * @param {!SDK.Layer} layer |
| 35 */ | 35 */ |
| 36 constructor(type, layer) { | 36 constructor(type, layer) { |
| 37 this._type = type; | 37 this._type = type; |
| 38 this._layer = layer; | 38 this._layer = layer; |
| 39 } | 39 } |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * @param {?WebInspector.LayerView.Selection} a | 42 * @param {?LayerViewer.LayerView.Selection} a |
| 43 * @param {?WebInspector.LayerView.Selection} b | 43 * @param {?LayerViewer.LayerView.Selection} b |
| 44 * @return {boolean} | 44 * @return {boolean} |
| 45 */ | 45 */ |
| 46 static isEqual(a, b) { | 46 static isEqual(a, b) { |
| 47 return a && b ? a._isEqual(b) : a === b; | 47 return a && b ? a._isEqual(b) : a === b; |
| 48 } | 48 } |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * @return {!WebInspector.LayerView.Selection.Type} | 51 * @return {!LayerViewer.LayerView.Selection.Type} |
| 52 */ | 52 */ |
| 53 type() { | 53 type() { |
| 54 return this._type; | 54 return this._type; |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * @return {!WebInspector.Layer} | 58 * @return {!SDK.Layer} |
| 59 */ | 59 */ |
| 60 layer() { | 60 layer() { |
| 61 return this._layer; | 61 return this._layer; |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @param {!WebInspector.LayerView.Selection} other | 65 * @param {!LayerViewer.LayerView.Selection} other |
| 66 * @return {boolean} | 66 * @return {boolean} |
| 67 */ | 67 */ |
| 68 _isEqual(other) { | 68 _isEqual(other) { |
| 69 return false; | 69 return false; |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @enum {symbol} | 74 * @enum {symbol} |
| 75 */ | 75 */ |
| 76 WebInspector.LayerView.Selection.Type = { | 76 LayerViewer.LayerView.Selection.Type = { |
| 77 Layer: Symbol('Layer'), | 77 Layer: Symbol('Layer'), |
| 78 ScrollRect: Symbol('ScrollRect'), | 78 ScrollRect: Symbol('ScrollRect'), |
| 79 Snapshot: Symbol('Snapshot') | 79 Snapshot: Symbol('Snapshot') |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * @unrestricted | 84 * @unrestricted |
| 85 */ | 85 */ |
| 86 WebInspector.LayerView.LayerSelection = class extends WebInspector.LayerView.Sel
ection { | 86 LayerViewer.LayerView.LayerSelection = class extends LayerViewer.LayerView.Selec
tion { |
| 87 /** | 87 /** |
| 88 * @param {!WebInspector.Layer} layer | 88 * @param {!SDK.Layer} layer |
| 89 */ | 89 */ |
| 90 constructor(layer) { | 90 constructor(layer) { |
| 91 console.assert(layer, 'LayerSelection with empty layer'); | 91 console.assert(layer, 'LayerSelection with empty layer'); |
| 92 super(WebInspector.LayerView.Selection.Type.Layer, layer); | 92 super(LayerViewer.LayerView.Selection.Type.Layer, layer); |
| 93 } | 93 } |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * @override | 96 * @override |
| 97 * @param {!WebInspector.LayerView.Selection} other | 97 * @param {!LayerViewer.LayerView.Selection} other |
| 98 * @return {boolean} | 98 * @return {boolean} |
| 99 */ | 99 */ |
| 100 _isEqual(other) { | 100 _isEqual(other) { |
| 101 return other._type === WebInspector.LayerView.Selection.Type.Layer && other.
layer().id() === this.layer().id(); | 101 return other._type === LayerViewer.LayerView.Selection.Type.Layer && other.l
ayer().id() === this.layer().id(); |
| 102 } | 102 } |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * @unrestricted | 106 * @unrestricted |
| 107 */ | 107 */ |
| 108 WebInspector.LayerView.ScrollRectSelection = class extends WebInspector.LayerVie
w.Selection { | 108 LayerViewer.LayerView.ScrollRectSelection = class extends LayerViewer.LayerView.
Selection { |
| 109 /** | 109 /** |
| 110 * @param {!WebInspector.Layer} layer | 110 * @param {!SDK.Layer} layer |
| 111 * @param {number} scrollRectIndex | 111 * @param {number} scrollRectIndex |
| 112 */ | 112 */ |
| 113 constructor(layer, scrollRectIndex) { | 113 constructor(layer, scrollRectIndex) { |
| 114 super(WebInspector.LayerView.Selection.Type.ScrollRect, layer); | 114 super(LayerViewer.LayerView.Selection.Type.ScrollRect, layer); |
| 115 this.scrollRectIndex = scrollRectIndex; | 115 this.scrollRectIndex = scrollRectIndex; |
| 116 } | 116 } |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * @override | 119 * @override |
| 120 * @param {!WebInspector.LayerView.Selection} other | 120 * @param {!LayerViewer.LayerView.Selection} other |
| 121 * @return {boolean} | 121 * @return {boolean} |
| 122 */ | 122 */ |
| 123 _isEqual(other) { | 123 _isEqual(other) { |
| 124 return other._type === WebInspector.LayerView.Selection.Type.ScrollRect && | 124 return other._type === LayerViewer.LayerView.Selection.Type.ScrollRect && |
| 125 this.layer().id() === other.layer().id() && this.scrollRectIndex === oth
er.scrollRectIndex; | 125 this.layer().id() === other.layer().id() && this.scrollRectIndex === oth
er.scrollRectIndex; |
| 126 } | 126 } |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * @unrestricted | 130 * @unrestricted |
| 131 */ | 131 */ |
| 132 WebInspector.LayerView.SnapshotSelection = class extends WebInspector.LayerView.
Selection { | 132 LayerViewer.LayerView.SnapshotSelection = class extends LayerViewer.LayerView.Se
lection { |
| 133 /** | 133 /** |
| 134 * @param {!WebInspector.Layer} layer | 134 * @param {!SDK.Layer} layer |
| 135 * @param {!WebInspector.SnapshotWithRect} snapshot | 135 * @param {!SDK.SnapshotWithRect} snapshot |
| 136 */ | 136 */ |
| 137 constructor(layer, snapshot) { | 137 constructor(layer, snapshot) { |
| 138 super(WebInspector.LayerView.Selection.Type.Snapshot, layer); | 138 super(LayerViewer.LayerView.Selection.Type.Snapshot, layer); |
| 139 this._snapshot = snapshot; | 139 this._snapshot = snapshot; |
| 140 } | 140 } |
| 141 | 141 |
| 142 /** | 142 /** |
| 143 * @override | 143 * @override |
| 144 * @param {!WebInspector.LayerView.Selection} other | 144 * @param {!LayerViewer.LayerView.Selection} other |
| 145 * @return {boolean} | 145 * @return {boolean} |
| 146 */ | 146 */ |
| 147 _isEqual(other) { | 147 _isEqual(other) { |
| 148 return other._type === WebInspector.LayerView.Selection.Type.Snapshot && thi
s.layer().id() === other.layer().id() && | 148 return other._type === LayerViewer.LayerView.Selection.Type.Snapshot && this
.layer().id() === other.layer().id() && |
| 149 this._snapshot === other._snapshot; | 149 this._snapshot === other._snapshot; |
| 150 } | 150 } |
| 151 | 151 |
| 152 /** | 152 /** |
| 153 * @return {!WebInspector.SnapshotWithRect} | 153 * @return {!SDK.SnapshotWithRect} |
| 154 */ | 154 */ |
| 155 snapshot() { | 155 snapshot() { |
| 156 return this._snapshot; | 156 return this._snapshot; |
| 157 } | 157 } |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * @unrestricted | 161 * @unrestricted |
| 162 */ | 162 */ |
| 163 WebInspector.LayerViewHost = class { | 163 LayerViewer.LayerViewHost = class { |
| 164 constructor() { | 164 constructor() { |
| 165 /** @type {!Array.<!WebInspector.LayerView>} */ | 165 /** @type {!Array.<!LayerViewer.LayerView>} */ |
| 166 this._views = []; | 166 this._views = []; |
| 167 this._selectedObject = null; | 167 this._selectedObject = null; |
| 168 this._hoveredObject = null; | 168 this._hoveredObject = null; |
| 169 this._showInternalLayersSetting = WebInspector.settings.createSetting('layer
sShowInternalLayers', false); | 169 this._showInternalLayersSetting = Common.settings.createSetting('layersShowI
nternalLayers', false); |
| 170 } | 170 } |
| 171 | 171 |
| 172 /** | 172 /** |
| 173 * @param {!WebInspector.LayerView} layerView | 173 * @param {!LayerViewer.LayerView} layerView |
| 174 */ | 174 */ |
| 175 registerView(layerView) { | 175 registerView(layerView) { |
| 176 this._views.push(layerView); | 176 this._views.push(layerView); |
| 177 } | 177 } |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * @param {?WebInspector.LayerTreeBase} layerTree | 180 * @param {?SDK.LayerTreeBase} layerTree |
| 181 */ | 181 */ |
| 182 setLayerTree(layerTree) { | 182 setLayerTree(layerTree) { |
| 183 this._target = layerTree.target(); | 183 this._target = layerTree.target(); |
| 184 var selectedLayer = this._selectedObject && this._selectedObject.layer(); | 184 var selectedLayer = this._selectedObject && this._selectedObject.layer(); |
| 185 if (selectedLayer && (!layerTree || !layerTree.layerById(selectedLayer.id())
)) | 185 if (selectedLayer && (!layerTree || !layerTree.layerById(selectedLayer.id())
)) |
| 186 this.selectObject(null); | 186 this.selectObject(null); |
| 187 var hoveredLayer = this._hoveredObject && this._hoveredObject.layer(); | 187 var hoveredLayer = this._hoveredObject && this._hoveredObject.layer(); |
| 188 if (hoveredLayer && (!layerTree || !layerTree.layerById(hoveredLayer.id()))) | 188 if (hoveredLayer && (!layerTree || !layerTree.layerById(hoveredLayer.id()))) |
| 189 this.hoverObject(null); | 189 this.hoverObject(null); |
| 190 for (var view of this._views) | 190 for (var view of this._views) |
| 191 view.setLayerTree(layerTree); | 191 view.setLayerTree(layerTree); |
| 192 } | 192 } |
| 193 | 193 |
| 194 /** | 194 /** |
| 195 * @param {?WebInspector.LayerView.Selection} selection | 195 * @param {?LayerViewer.LayerView.Selection} selection |
| 196 */ | 196 */ |
| 197 hoverObject(selection) { | 197 hoverObject(selection) { |
| 198 if (WebInspector.LayerView.Selection.isEqual(this._hoveredObject, selection)
) | 198 if (LayerViewer.LayerView.Selection.isEqual(this._hoveredObject, selection)) |
| 199 return; | 199 return; |
| 200 this._hoveredObject = selection; | 200 this._hoveredObject = selection; |
| 201 var layer = selection && selection.layer(); | 201 var layer = selection && selection.layer(); |
| 202 this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null); | 202 this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null); |
| 203 for (var view of this._views) | 203 for (var view of this._views) |
| 204 view.hoverObject(selection); | 204 view.hoverObject(selection); |
| 205 } | 205 } |
| 206 | 206 |
| 207 /** | 207 /** |
| 208 * @param {?WebInspector.LayerView.Selection} selection | 208 * @param {?LayerViewer.LayerView.Selection} selection |
| 209 */ | 209 */ |
| 210 selectObject(selection) { | 210 selectObject(selection) { |
| 211 if (WebInspector.LayerView.Selection.isEqual(this._selectedObject, selection
)) | 211 if (LayerViewer.LayerView.Selection.isEqual(this._selectedObject, selection)
) |
| 212 return; | 212 return; |
| 213 this._selectedObject = selection; | 213 this._selectedObject = selection; |
| 214 for (var view of this._views) | 214 for (var view of this._views) |
| 215 view.selectObject(selection); | 215 view.selectObject(selection); |
| 216 } | 216 } |
| 217 | 217 |
| 218 /** | 218 /** |
| 219 * @return {?WebInspector.LayerView.Selection} | 219 * @return {?LayerViewer.LayerView.Selection} |
| 220 */ | 220 */ |
| 221 selection() { | 221 selection() { |
| 222 return this._selectedObject; | 222 return this._selectedObject; |
| 223 } | 223 } |
| 224 | 224 |
| 225 /** | 225 /** |
| 226 * @param {!WebInspector.ContextMenu} contextMenu | 226 * @param {!UI.ContextMenu} contextMenu |
| 227 * @param {?WebInspector.LayerView.Selection} selection | 227 * @param {?LayerViewer.LayerView.Selection} selection |
| 228 */ | 228 */ |
| 229 showContextMenu(contextMenu, selection) { | 229 showContextMenu(contextMenu, selection) { |
| 230 contextMenu.appendCheckboxItem( | 230 contextMenu.appendCheckboxItem( |
| 231 WebInspector.UIString('Show internal layers'), this._toggleShowInternalL
ayers.bind(this), | 231 Common.UIString('Show internal layers'), this._toggleShowInternalLayers.
bind(this), |
| 232 this._showInternalLayersSetting.get()); | 232 this._showInternalLayersSetting.get()); |
| 233 var node = selection && selection.layer() && selection.layer().nodeForSelfOr
Ancestor(); | 233 var node = selection && selection.layer() && selection.layer().nodeForSelfOr
Ancestor(); |
| 234 if (node) | 234 if (node) |
| 235 contextMenu.appendApplicableItems(node); | 235 contextMenu.appendApplicableItems(node); |
| 236 contextMenu.show(); | 236 contextMenu.show(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * @return {!WebInspector.Setting} | 240 * @return {!Common.Setting} |
| 241 */ | 241 */ |
| 242 showInternalLayersSetting() { | 242 showInternalLayersSetting() { |
| 243 return this._showInternalLayersSetting; | 243 return this._showInternalLayersSetting; |
| 244 } | 244 } |
| 245 | 245 |
| 246 _toggleShowInternalLayers() { | 246 _toggleShowInternalLayers() { |
| 247 this._showInternalLayersSetting.set(!this._showInternalLayersSetting.get()); | 247 this._showInternalLayersSetting.set(!this._showInternalLayersSetting.get()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 /** | 250 /** |
| 251 * @param {?WebInspector.DOMNode} node | 251 * @param {?SDK.DOMNode} node |
| 252 */ | 252 */ |
| 253 _toggleNodeHighlight(node) { | 253 _toggleNodeHighlight(node) { |
| 254 if (node) { | 254 if (node) { |
| 255 node.highlightForTwoSeconds(); | 255 node.highlightForTwoSeconds(); |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 WebInspector.DOMModel.hideDOMNodeHighlight(); | 258 SDK.DOMModel.hideDOMNodeHighlight(); |
| 259 } | 259 } |
| 260 }; | 260 }; |
| OLD | NEW |