Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/layers/LayersPanel.js

Issue 2307253003: DevTools: enable layers pane outside of experiements. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 /**
32 * @constructor
33 * @extends {WebInspector.PanelWithSidebar}
34 * @implements {WebInspector.TargetManager.Observer}
35 */
36 WebInspector.LayersPanel = function()
37 {
38 WebInspector.PanelWithSidebar.call(this, "layers", 225);
39 this.registerRequiredCSS("timeline/timelinePanel.css");
40
41 /** @type {?WebInspector.LayerTreeModel} */
42 this._model = null;
43
44 WebInspector.targetManager.observeTargets(this);
45 this._layerViewHost = new WebInspector.LayerViewHost();
46 this._layerTreeOutline = new WebInspector.LayerTreeOutline(this._layerViewHo st);
47 this.panelSidebarElement().appendChild(this._layerTreeOutline.element);
48 this.setDefaultFocusedElement(this._layerTreeOutline.element);
49
50 this._rightSplitWidget = new WebInspector.SplitWidget(false, true, "layerDet ailsSplitViewState");
51 this.splitWidget().setMainWidget(this._rightSplitWidget);
52
53 this._layers3DView = new WebInspector.Layers3DView(this._layerViewHost);
54 this._rightSplitWidget.setMainWidget(this._layers3DView);
55 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.LayerSn apshotRequested, this._onSnapshotRequested, this);
56
57 this._tabbedPane = new WebInspector.TabbedPane();
58 this._rightSplitWidget.setSidebarWidget(this._tabbedPane);
59
60 this._layerDetailsView = new WebInspector.LayerDetailsView(this._layerViewHo st);
61 this._tabbedPane.appendTab(WebInspector.LayersPanel.DetailsViewTabs.Details, WebInspector.UIString("Details"), this._layerDetailsView);
62
63 this._paintProfilerView = new WebInspector.LayerPaintProfilerView(this._laye rs3DView.showImageForLayer.bind(this._layers3DView));
64 this._tabbedPane.appendTab(WebInspector.LayersPanel.DetailsViewTabs.Profiler , WebInspector.UIString("Profiler"), this._paintProfilerView);
65 }
66
67 WebInspector.LayersPanel.DetailsViewTabs = {
68 Details: "details",
69 Profiler: "profiler"
70 };
71
72 WebInspector.LayersPanel.prototype = {
73 focus: function()
74 {
75 this._layerTreeOutline.focus();
76 },
77
78 wasShown: function()
79 {
80 WebInspector.Panel.prototype.wasShown.call(this);
81 if (this._model)
82 this._model.enable();
83 this._layerTreeOutline.focus();
84 },
85
86 willHide: function()
87 {
88 if (this._model)
89 this._model.disable();
90 WebInspector.Panel.prototype.willHide.call(this);
91 },
92
93 /**
94 * @override
95 * @param {!WebInspector.Target} target
96 */
97 targetAdded: function(target)
98 {
99 if (this._model)
100 return;
101 this._model = WebInspector.LayerTreeModel.fromTarget(target);
102 if (!this._model)
103 return;
104 this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerTre eChanged, this._onLayerTreeUpdated, this);
105 this._model.addEventListener(WebInspector.LayerTreeModel.Events.LayerPai nted, this._onLayerPainted, this);
106 if (this.isShowing())
107 this._model.enable();
108 },
109
110 /**
111 * @override
112 * @param {!WebInspector.Target} target
113 */
114 targetRemoved: function(target)
115 {
116 if (!this._model || this._model.target() !== target)
117 return;
118 this._model.removeEventListener(WebInspector.LayerTreeModel.Events.Layer TreeChanged, this._onLayerTreeUpdated, this);
119 this._model.removeEventListener(WebInspector.LayerTreeModel.Events.Layer Painted, this._onLayerPainted, this);
120 this._model.disable();
121 this._model = null;
122 },
123
124 /**
125 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree
126 */
127 _showLayerTree: function(deferredLayerTree)
128 {
129 deferredLayerTree.resolve(this._layerViewHost.setLayerTree.bind(this._la yerViewHost));
130 },
131
132 _onLayerTreeUpdated: function()
133 {
134 if (this._model)
135 this._layerViewHost.setLayerTree(this._model.layerTree());
136 },
137
138 /**
139 * @param {!WebInspector.Event} event
140 */
141 _onLayerPainted: function(event)
142 {
143 if (!this._model)
144 return;
145 this._layers3DView.setLayerTree(this._model.layerTree());
146 if (this._layerViewHost.selection() && this._layerViewHost.selection().l ayer() === event.data)
147 this._layerDetailsView.update();
148 },
149
150 /**
151 * @param {!WebInspector.Event} event
152 */
153 _onSnapshotRequested: function(event)
154 {
155 var layer = /** @type {!WebInspector.Layer} */ (event.data);
156 this._tabbedPane.selectTab(WebInspector.LayersPanel.DetailsViewTabs.Prof iler);
157 this._paintProfilerView.profileLayer(layer);
158 },
159
160 __proto__: WebInspector.PanelWithSidebar.prototype
161 }
162
163 /**
164 * @constructor
165 * @implements {WebInspector.Revealer}
166 */
167 WebInspector.LayersPanel.LayerTreeRevealer = function()
168 {
169 }
170
171 WebInspector.LayersPanel.LayerTreeRevealer.prototype = {
172 /**
173 * @override
174 * @param {!Object} snapshotData
175 * @return {!Promise}
176 */
177 reveal: function(snapshotData)
178 {
179 if (!(snapshotData instanceof WebInspector.DeferredLayerTree))
180 return Promise.reject(new Error("Internal error: not a WebInspector. DeferredLayerTree"));
181 var panel = /** @type {!WebInspector.LayersPanel} */ (self.runtime.share dInstance(WebInspector.LayersPanel));
182 WebInspector.inspectorView.setCurrentPanel(panel);
183 panel._showLayerTree(/** @type {!WebInspector.DeferredLayerTree} */ (sna pshotData));
184 return Promise.resolve();
185 }
186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698