| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {WebInspector.TargetManager.Observer} | 31 * @implements {SDK.TargetManager.Observer} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.LayersPanel = class extends WebInspector.PanelWithSidebar { | 34 Layers.LayersPanel = class extends UI.PanelWithSidebar { |
| 35 constructor() { | 35 constructor() { |
| 36 super('layers', 225); | 36 super('layers', 225); |
| 37 | 37 |
| 38 /** @type {?WebInspector.LayerTreeModel} */ | 38 /** @type {?Layers.LayerTreeModel} */ |
| 39 this._model = null; | 39 this._model = null; |
| 40 | 40 |
| 41 WebInspector.targetManager.observeTargets(this); | 41 SDK.targetManager.observeTargets(this); |
| 42 this._layerViewHost = new WebInspector.LayerViewHost(); | 42 this._layerViewHost = new LayerViewer.LayerViewHost(); |
| 43 this._layerTreeOutline = new WebInspector.LayerTreeOutline(this._layerViewHo
st); | 43 this._layerTreeOutline = new LayerViewer.LayerTreeOutline(this._layerViewHos
t); |
| 44 this.panelSidebarElement().appendChild(this._layerTreeOutline.element); | 44 this.panelSidebarElement().appendChild(this._layerTreeOutline.element); |
| 45 this.setDefaultFocusedElement(this._layerTreeOutline.element); | 45 this.setDefaultFocusedElement(this._layerTreeOutline.element); |
| 46 | 46 |
| 47 this._rightSplitWidget = new WebInspector.SplitWidget(false, true, 'layerDet
ailsSplitViewState'); | 47 this._rightSplitWidget = new UI.SplitWidget(false, true, 'layerDetailsSplitV
iewState'); |
| 48 this.splitWidget().setMainWidget(this._rightSplitWidget); | 48 this.splitWidget().setMainWidget(this._rightSplitWidget); |
| 49 | 49 |
| 50 this._layers3DView = new WebInspector.Layers3DView(this._layerViewHost); | 50 this._layers3DView = new LayerViewer.Layers3DView(this._layerViewHost); |
| 51 this._rightSplitWidget.setMainWidget(this._layers3DView); | 51 this._rightSplitWidget.setMainWidget(this._layers3DView); |
| 52 this._layers3DView.addEventListener( | 52 this._layers3DView.addEventListener( |
| 53 WebInspector.Layers3DView.Events.PaintProfilerRequested, this._onPaintPr
ofileRequested, this); | 53 LayerViewer.Layers3DView.Events.PaintProfilerRequested, this._onPaintPro
fileRequested, this); |
| 54 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ScaleCh
anged, this._onScaleChanged, this); | 54 this._layers3DView.addEventListener(LayerViewer.Layers3DView.Events.ScaleCha
nged, this._onScaleChanged, this); |
| 55 | 55 |
| 56 this._tabbedPane = new WebInspector.TabbedPane(); | 56 this._tabbedPane = new UI.TabbedPane(); |
| 57 this._rightSplitWidget.setSidebarWidget(this._tabbedPane); | 57 this._rightSplitWidget.setSidebarWidget(this._tabbedPane); |
| 58 | 58 |
| 59 this._layerDetailsView = new WebInspector.LayerDetailsView(this._layerViewHo
st); | 59 this._layerDetailsView = new LayerViewer.LayerDetailsView(this._layerViewHos
t); |
| 60 this._layerDetailsView.addEventListener( | 60 this._layerDetailsView.addEventListener( |
| 61 WebInspector.LayerDetailsView.Events.PaintProfilerRequested, this._onPai
ntProfileRequested, this); | 61 LayerViewer.LayerDetailsView.Events.PaintProfilerRequested, this._onPain
tProfileRequested, this); |
| 62 this._tabbedPane.appendTab( | 62 this._tabbedPane.appendTab( |
| 63 WebInspector.LayersPanel.DetailsViewTabs.Details, WebInspector.UIString(
'Details'), this._layerDetailsView); | 63 Layers.LayersPanel.DetailsViewTabs.Details, Common.UIString('Details'),
this._layerDetailsView); |
| 64 | 64 |
| 65 this._paintProfilerView = new WebInspector.LayerPaintProfilerView(this._show
Image.bind(this)); | 65 this._paintProfilerView = new Layers.LayerPaintProfilerView(this._showImage.
bind(this)); |
| 66 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabClosed,
this._onTabClosed, this); | 66 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._onTa
bClosed, this); |
| 67 this._updateThrottler = new WebInspector.Throttler(100); | 67 this._updateThrottler = new Common.Throttler(100); |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @override | 71 * @override |
| 72 */ | 72 */ |
| 73 focus() { | 73 focus() { |
| 74 this._layerTreeOutline.focus(); | 74 this._layerTreeOutline.focus(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 /** | 77 /** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 88 * @override | 88 * @override |
| 89 */ | 89 */ |
| 90 willHide() { | 90 willHide() { |
| 91 if (this._model) | 91 if (this._model) |
| 92 this._model.disable(); | 92 this._model.disable(); |
| 93 super.willHide(); | 93 super.willHide(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * @override | 97 * @override |
| 98 * @param {!WebInspector.Target} target | 98 * @param {!SDK.Target} target |
| 99 */ | 99 */ |
| 100 targetAdded(target) { | 100 targetAdded(target) { |
| 101 if (this._model) | 101 if (this._model) |
| 102 return; | 102 return; |
| 103 this._model = WebInspector.LayerTreeModel.fromTarget(target); | 103 this._model = Layers.LayerTreeModel.fromTarget(target); |
| 104 if (!this._model) | 104 if (!this._model) |
| 105 return; | 105 return; |
| 106 this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerTreeCha
nged, this._onLayerTreeUpdated, this); | 106 this._model.addEventListener(Layers.LayerTreeModel.Events.LayerTreeChanged,
this._onLayerTreeUpdated, this); |
| 107 this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerPainted
, this._onLayerPainted, this); | 107 this._model.addEventListener(Layers.LayerTreeModel.Events.LayerPainted, this
._onLayerPainted, this); |
| 108 if (this.isShowing()) | 108 if (this.isShowing()) |
| 109 this._model.enable(); | 109 this._model.enable(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * @override | 113 * @override |
| 114 * @param {!WebInspector.Target} target | 114 * @param {!SDK.Target} target |
| 115 */ | 115 */ |
| 116 targetRemoved(target) { | 116 targetRemoved(target) { |
| 117 if (!this._model || this._model.target() !== target) | 117 if (!this._model || this._model.target() !== target) |
| 118 return; | 118 return; |
| 119 this._model.removeEventListener( | 119 this._model.removeEventListener( |
| 120 WebInspector.LayerTreeModel.Events.LayerTreeChanged, this._onLayerTreeUp
dated, this); | 120 Layers.LayerTreeModel.Events.LayerTreeChanged, this._onLayerTreeUpdated,
this); |
| 121 this._model.removeEventListener(WebInspector.LayerTreeModel.Events.LayerPain
ted, this._onLayerPainted, this); | 121 this._model.removeEventListener(Layers.LayerTreeModel.Events.LayerPainted, t
his._onLayerPainted, this); |
| 122 this._model.disable(); | 122 this._model.disable(); |
| 123 this._model = null; | 123 this._model = null; |
| 124 } | 124 } |
| 125 | 125 |
| 126 _onLayerTreeUpdated() { | 126 _onLayerTreeUpdated() { |
| 127 this._updateThrottler.schedule(this._update.bind(this)); | 127 this._updateThrottler.schedule(this._update.bind(this)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * @return {!Promise<*>} | 131 * @return {!Promise<*>} |
| 132 */ | 132 */ |
| 133 _update() { | 133 _update() { |
| 134 if (this._model) | 134 if (this._model) |
| 135 this._layerViewHost.setLayerTree(this._model.layerTree()); | 135 this._layerViewHost.setLayerTree(this._model.layerTree()); |
| 136 return Promise.resolve(); | 136 return Promise.resolve(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * @param {!WebInspector.Event} event | 140 * @param {!Common.Event} event |
| 141 */ | 141 */ |
| 142 _onLayerPainted(event) { | 142 _onLayerPainted(event) { |
| 143 if (!this._model) | 143 if (!this._model) |
| 144 return; | 144 return; |
| 145 var layer = /** @type {!WebInspector.Layer} */ (event.data); | 145 var layer = /** @type {!SDK.Layer} */ (event.data); |
| 146 if (this._layerViewHost.selection() && this._layerViewHost.selection().layer
() === layer) | 146 if (this._layerViewHost.selection() && this._layerViewHost.selection().layer
() === layer) |
| 147 this._layerDetailsView.update(); | 147 this._layerDetailsView.update(); |
| 148 this._layers3DView.updateLayerSnapshot(layer); | 148 this._layers3DView.updateLayerSnapshot(layer); |
| 149 } | 149 } |
| 150 | 150 |
| 151 /** | 151 /** |
| 152 * @param {!WebInspector.Event} event | 152 * @param {!Common.Event} event |
| 153 */ | 153 */ |
| 154 _onPaintProfileRequested(event) { | 154 _onPaintProfileRequested(event) { |
| 155 var selection = /** @type {!WebInspector.LayerView.Selection} */ (event.data
); | 155 var selection = /** @type {!LayerViewer.LayerView.Selection} */ (event.data)
; |
| 156 this._layers3DView.snapshotForSelection(selection).then(snapshotWithRect =>
{ | 156 this._layers3DView.snapshotForSelection(selection).then(snapshotWithRect =>
{ |
| 157 if (!snapshotWithRect) | 157 if (!snapshotWithRect) |
| 158 return; | 158 return; |
| 159 this._layerBeingProfiled = selection.layer(); | 159 this._layerBeingProfiled = selection.layer(); |
| 160 this._tabbedPane.appendTab( | 160 this._tabbedPane.appendTab( |
| 161 WebInspector.LayersPanel.DetailsViewTabs.Profiler, WebInspector.UIStri
ng('Profiler'), this._paintProfilerView, | 161 Layers.LayersPanel.DetailsViewTabs.Profiler, Common.UIString('Profiler
'), this._paintProfilerView, |
| 162 undefined, true, true); | 162 undefined, true, true); |
| 163 this._tabbedPane.selectTab(WebInspector.LayersPanel.DetailsViewTabs.Profil
er); | 163 this._tabbedPane.selectTab(Layers.LayersPanel.DetailsViewTabs.Profiler); |
| 164 this._paintProfilerView.profile(snapshotWithRect.snapshot); | 164 this._paintProfilerView.profile(snapshotWithRect.snapshot); |
| 165 }); | 165 }); |
| 166 } | 166 } |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * @param {!WebInspector.Event} event | 169 * @param {!Common.Event} event |
| 170 */ | 170 */ |
| 171 _onTabClosed(event) { | 171 _onTabClosed(event) { |
| 172 if (event.data.tabId !== WebInspector.LayersPanel.DetailsViewTabs.Profiler |
| !this._layerBeingProfiled) | 172 if (event.data.tabId !== Layers.LayersPanel.DetailsViewTabs.Profiler || !thi
s._layerBeingProfiled) |
| 173 return; | 173 return; |
| 174 this._paintProfilerView.reset(); | 174 this._paintProfilerView.reset(); |
| 175 this._layers3DView.showImageForLayer(this._layerBeingProfiled, undefined); | 175 this._layers3DView.showImageForLayer(this._layerBeingProfiled, undefined); |
| 176 this._layerBeingProfiled = null; | 176 this._layerBeingProfiled = null; |
| 177 } | 177 } |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * @param {string=} imageURL | 180 * @param {string=} imageURL |
| 181 */ | 181 */ |
| 182 _showImage(imageURL) { | 182 _showImage(imageURL) { |
| 183 this._layers3DView.showImageForLayer(this._layerBeingProfiled, imageURL); | 183 this._layers3DView.showImageForLayer(this._layerBeingProfiled, imageURL); |
| 184 } | 184 } |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * @param {!WebInspector.Event} event | 187 * @param {!Common.Event} event |
| 188 */ | 188 */ |
| 189 _onScaleChanged(event) { | 189 _onScaleChanged(event) { |
| 190 this._paintProfilerView.setScale(/** @type {number} */ (event.data)); | 190 this._paintProfilerView.setScale(/** @type {number} */ (event.data)); |
| 191 } | 191 } |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 WebInspector.LayersPanel.DetailsViewTabs = { | 194 Layers.LayersPanel.DetailsViewTabs = { |
| 195 Details: 'details', | 195 Details: 'details', |
| 196 Profiler: 'profiler' | 196 Profiler: 'profiler' |
| 197 }; | 197 }; |
| OLD | NEW |