OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** |
| 5 * @implements {WebInspector.App} |
| 6 * @unrestricted |
| 7 */ |
| 8 WebInspector.AdvancedApp = class { |
| 9 constructor() { |
| 10 WebInspector.dockController.addEventListener( |
| 11 WebInspector.DockController.Events.BeforeDockSideChanged, this._openTool
boxWindow, this); |
| 12 } |
4 | 13 |
5 /** | 14 /** |
6 * @constructor | 15 * @return {!WebInspector.AdvancedApp} |
7 * @implements {WebInspector.App} | 16 */ |
8 */ | 17 static _instance() { |
9 WebInspector.AdvancedApp = function() | 18 if (!WebInspector.AdvancedApp._appInstance) |
10 { | 19 WebInspector.AdvancedApp._appInstance = new WebInspector.AdvancedApp(); |
11 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._openToolboxWindow, this); | 20 return WebInspector.AdvancedApp._appInstance; |
12 }; | 21 } |
13 | 22 |
14 WebInspector.AdvancedApp.prototype = { | 23 /** |
15 /** | 24 * @override |
16 * @override | 25 * @param {!Document} document |
17 * @param {!Document} document | 26 */ |
18 */ | 27 presentUI(document) { |
19 presentUI: function(document) | 28 var rootView = new WebInspector.RootView(); |
20 { | |
21 var rootView = new WebInspector.RootView(); | |
22 | 29 |
23 this._rootSplitWidget = new WebInspector.SplitWidget(false, true, "Inspe
ctorView.splitViewState", 555, 300, true); | 30 this._rootSplitWidget = new WebInspector.SplitWidget(false, true, 'Inspector
View.splitViewState', 555, 300, true); |
24 this._rootSplitWidget.show(rootView.element); | 31 this._rootSplitWidget.show(rootView.element); |
25 | 32 |
26 this._rootSplitWidget.setSidebarWidget(WebInspector.inspectorView); | 33 this._rootSplitWidget.setSidebarWidget(WebInspector.inspectorView); |
27 WebInspector.inspectorView.setOwnerSplit(this._rootSplitWidget); | 34 WebInspector.inspectorView.setOwnerSplit(this._rootSplitWidget); |
28 | 35 |
29 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlacehold
er(); | 36 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlaceholder()
; |
30 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPa
gePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this), this); | 37 this._inspectedPagePlaceholder.addEventListener( |
31 this._deviceModeView = new WebInspector.DeviceModeWrapper(this._inspecte
dPagePlaceholder); | 38 WebInspector.InspectedPagePlaceholder.Events.Update, this._onSetInspecte
dPageBounds.bind(this), this); |
| 39 this._deviceModeView = new WebInspector.DeviceModeWrapper(this._inspectedPag
ePlaceholder); |
32 | 40 |
33 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.BeforeDockSideChanged, this._onBeforeDockSideChange, this); | 41 WebInspector.dockController.addEventListener( |
34 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.DockSideChanged, this._onDockSideChange, this); | 42 WebInspector.DockController.Events.BeforeDockSideChanged, this._onBefore
DockSideChange, this); |
35 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.AfterDockSideChanged, this._onAfterDockSideChange, this); | 43 WebInspector.dockController.addEventListener( |
36 this._onDockSideChange(); | 44 WebInspector.DockController.Events.DockSideChanged, this._onDockSideChan
ge, this); |
| 45 WebInspector.dockController.addEventListener( |
| 46 WebInspector.DockController.Events.AfterDockSideChanged, this._onAfterDo
ckSideChange, this); |
| 47 this._onDockSideChange(); |
37 | 48 |
38 console.timeStamp("AdvancedApp.attachToBody"); | 49 console.timeStamp('AdvancedApp.attachToBody'); |
39 rootView.attachToDocument(document); | 50 rootView.attachToDocument(document); |
40 this._inspectedPagePlaceholder.update(); | 51 this._inspectedPagePlaceholder.update(); |
41 }, | 52 } |
42 | 53 |
43 /** | 54 /** |
44 * @param {!WebInspector.Event} event | 55 * @param {!WebInspector.Event} event |
45 */ | 56 */ |
46 _openToolboxWindow: function(event) | 57 _openToolboxWindow(event) { |
47 { | 58 if (/** @type {string} */ (event.data.to) !== WebInspector.DockController.St
ate.Undocked) |
48 if (/** @type {string} */ (event.data.to) !== WebInspector.DockControlle
r.State.Undocked) | 59 return; |
49 return; | |
50 | 60 |
51 if (this._toolboxWindow) | 61 if (this._toolboxWindow) |
52 return; | 62 return; |
53 | 63 |
54 var url = window.location.href.replace("inspector.html", "toolbox.html")
; | 64 var url = window.location.href.replace('inspector.html', 'toolbox.html'); |
55 this._toolboxWindow = window.open(url, undefined); | 65 this._toolboxWindow = window.open(url, undefined); |
56 }, | 66 } |
57 | 67 |
58 /** | 68 /** |
59 * @param {!Document} toolboxDocument | 69 * @param {!Document} toolboxDocument |
60 */ | 70 */ |
61 toolboxLoaded: function(toolboxDocument) | 71 toolboxLoaded(toolboxDocument) { |
62 { | 72 WebInspector.initializeUIUtils(toolboxDocument, WebInspector.settings.create
Setting('uiTheme', 'default')); |
63 WebInspector.initializeUIUtils(toolboxDocument, WebInspector.settings.cr
eateSetting("uiTheme", "default")); | 73 WebInspector.installComponentRootStyles(/** @type {!Element} */ (toolboxDocu
ment.body)); |
64 WebInspector.installComponentRootStyles(/** @type {!Element} */ (toolbox
Document.body)); | 74 WebInspector.ContextMenu.installHandler(toolboxDocument); |
65 WebInspector.ContextMenu.installHandler(toolboxDocument); | 75 WebInspector.Tooltip.installHandler(toolboxDocument); |
66 WebInspector.Tooltip.installHandler(toolboxDocument); | |
67 | 76 |
68 this._toolboxRootView = new WebInspector.RootView(); | 77 this._toolboxRootView = new WebInspector.RootView(); |
69 this._toolboxRootView.attachToDocument(toolboxDocument); | 78 this._toolboxRootView.attachToDocument(toolboxDocument); |
70 | 79 |
71 this._updateDeviceModeView(); | 80 this._updateDeviceModeView(); |
72 }, | 81 } |
73 | 82 |
74 _updateDeviceModeView: function() | 83 _updateDeviceModeView() { |
75 { | 84 if (this._isDocked()) |
76 if (this._isDocked()) | 85 this._rootSplitWidget.setMainWidget(this._deviceModeView); |
77 this._rootSplitWidget.setMainWidget(this._deviceModeView); | 86 else if (this._toolboxRootView) |
78 else if (this._toolboxRootView) | 87 this._deviceModeView.show(this._toolboxRootView.element); |
79 this._deviceModeView.show(this._toolboxRootView.element); | 88 } |
80 }, | |
81 | 89 |
82 /** | 90 /** |
83 * @param {!WebInspector.Event} event | 91 * @param {!WebInspector.Event} event |
84 */ | 92 */ |
85 _onBeforeDockSideChange: function(event) | 93 _onBeforeDockSideChange(event) { |
86 { | 94 if (/** @type {string} */ (event.data.to) === WebInspector.DockController.St
ate.Undocked && this._toolboxRootView) { |
87 if (/** @type {string} */ (event.data.to) === WebInspector.DockControlle
r.State.Undocked && this._toolboxRootView) { | 95 // Hide inspectorView and force layout to mimic the undocked state. |
88 // Hide inspectorView and force layout to mimic the undocked state. | 96 this._rootSplitWidget.hideSidebar(); |
89 this._rootSplitWidget.hideSidebar(); | 97 this._inspectedPagePlaceholder.update(); |
90 this._inspectedPagePlaceholder.update(); | 98 } |
91 } | |
92 | 99 |
93 this._changingDockSide = true; | 100 this._changingDockSide = true; |
94 }, | 101 } |
95 | 102 |
96 /** | 103 /** |
97 * @param {!WebInspector.Event=} event | 104 * @param {!WebInspector.Event=} event |
98 */ | 105 */ |
99 _onDockSideChange: function(event) | 106 _onDockSideChange(event) { |
100 { | 107 this._updateDeviceModeView(); |
101 this._updateDeviceModeView(); | |
102 | 108 |
103 var toDockSide = event ? /** @type {string} */ (event.data.to) : WebInsp
ector.dockController.dockSide(); | 109 var toDockSide = event ? /** @type {string} */ (event.data.to) : WebInspecto
r.dockController.dockSide(); |
104 if (toDockSide === WebInspector.DockController.State.Undocked) { | 110 if (toDockSide === WebInspector.DockController.State.Undocked) { |
105 this._updateForUndocked(); | 111 this._updateForUndocked(); |
106 } else if (this._toolboxRootView && event && /** @type {string} */ (even
t.data.from) === WebInspector.DockController.State.Undocked) { | 112 } else if ( |
107 // Don't update yet for smooth transition. | 113 this._toolboxRootView && event && |
108 this._rootSplitWidget.hideSidebar(); | 114 /** @type {string} */ (event.data.from) === WebInspector.DockController.
State.Undocked) { |
109 } else { | 115 // Don't update yet for smooth transition. |
110 this._updateForDocked(toDockSide); | 116 this._rootSplitWidget.hideSidebar(); |
111 } | 117 } else { |
112 }, | 118 this._updateForDocked(toDockSide); |
| 119 } |
| 120 } |
113 | 121 |
114 /** | 122 /** |
115 * @param {!WebInspector.Event} event | 123 * @param {!WebInspector.Event} event |
116 */ | 124 */ |
117 _onAfterDockSideChange: function(event) | 125 _onAfterDockSideChange(event) { |
118 { | 126 // We may get here on the first dock side change while loading without Befor
eDockSideChange. |
119 // We may get here on the first dock side change while loading without B
eforeDockSideChange. | 127 if (!this._changingDockSide) |
120 if (!this._changingDockSide) | 128 return; |
121 return; | 129 if (/** @type {string} */ (event.data.from) === WebInspector.DockController.
State.Undocked) { |
122 if (/** @type {string} */ (event.data.from) === WebInspector.DockControl
ler.State.Undocked) { | 130 // Restore docked layout in case of smooth transition. |
123 // Restore docked layout in case of smooth transition. | 131 this._updateForDocked(/** @type {string} */ (event.data.to)); |
124 this._updateForDocked(/** @type {string} */ (event.data.to)); | 132 } |
125 } | 133 this._changingDockSide = false; |
126 this._changingDockSide = false; | 134 this._inspectedPagePlaceholder.update(); |
127 this._inspectedPagePlaceholder.update(); | 135 } |
128 }, | |
129 | 136 |
130 /** | 137 /** |
131 * @param {string} dockSide | 138 * @param {string} dockSide |
132 */ | 139 */ |
133 _updateForDocked: function(dockSide) | 140 _updateForDocked(dockSide) { |
134 { | 141 this._rootSplitWidget.setVertical(dockSide === WebInspector.DockController.S
tate.DockedToRight); |
135 this._rootSplitWidget.setVertical(dockSide === WebInspector.DockControll
er.State.DockedToRight); | 142 this._rootSplitWidget.setSecondIsSidebar( |
136 this._rootSplitWidget.setSecondIsSidebar(dockSide === WebInspector.DockC
ontroller.State.DockedToRight || dockSide === WebInspector.DockController.State.
DockedToBottom); | 143 dockSide === WebInspector.DockController.State.DockedToRight || |
137 this._rootSplitWidget.toggleResizer(this._rootSplitWidget.resizerElement
(), true); | 144 dockSide === WebInspector.DockController.State.DockedToBottom); |
138 this._rootSplitWidget.toggleResizer(WebInspector.inspectorView.topResize
rElement(), dockSide === WebInspector.DockController.State.DockedToBottom); | 145 this._rootSplitWidget.toggleResizer(this._rootSplitWidget.resizerElement(),
true); |
139 this._rootSplitWidget.showBoth(); | 146 this._rootSplitWidget.toggleResizer( |
140 }, | 147 WebInspector.inspectorView.topResizerElement(), dockSide === WebInspecto
r.DockController.State.DockedToBottom); |
| 148 this._rootSplitWidget.showBoth(); |
| 149 } |
141 | 150 |
142 _updateForUndocked: function() | 151 _updateForUndocked() { |
143 { | 152 this._rootSplitWidget.toggleResizer(this._rootSplitWidget.resizerElement(),
false); |
144 this._rootSplitWidget.toggleResizer(this._rootSplitWidget.resizerElement
(), false); | 153 this._rootSplitWidget.toggleResizer(WebInspector.inspectorView.topResizerEle
ment(), false); |
145 this._rootSplitWidget.toggleResizer(WebInspector.inspectorView.topResize
rElement(), false); | 154 this._rootSplitWidget.hideMain(); |
146 this._rootSplitWidget.hideMain(); | 155 } |
147 }, | |
148 | 156 |
149 _isDocked: function() | 157 _isDocked() { |
150 { | 158 return WebInspector.dockController.dockSide() !== WebInspector.DockControlle
r.State.Undocked; |
151 return WebInspector.dockController.dockSide() !== WebInspector.DockContr
oller.State.Undocked; | 159 } |
152 }, | |
153 | 160 |
154 /** | 161 /** |
155 * @param {!WebInspector.Event} event | 162 * @param {!WebInspector.Event} event |
156 */ | 163 */ |
157 _onSetInspectedPageBounds: function(event) | 164 _onSetInspectedPageBounds(event) { |
158 { | 165 if (this._changingDockSide) |
159 if (this._changingDockSide) | 166 return; |
160 return; | 167 var window = this._inspectedPagePlaceholder.element.window(); |
161 var window = this._inspectedPagePlaceholder.element.window(); | 168 if (!window.innerWidth || !window.innerHeight) |
162 if (!window.innerWidth || !window.innerHeight) | 169 return; |
163 return; | 170 if (!this._inspectedPagePlaceholder.isShowing()) |
164 if (!this._inspectedPagePlaceholder.isShowing()) | 171 return; |
165 return; | 172 var bounds = /** @type {{x: number, y: number, width: number, height: number
}} */ (event.data); |
166 var bounds = /** @type {{x: number, y: number, width: number, height: nu
mber}} */ (event.data); | 173 console.timeStamp('AdvancedApp.setInspectedPageBounds'); |
167 console.timeStamp("AdvancedApp.setInspectedPageBounds"); | 174 InspectorFrontendHost.setInspectedPageBounds(bounds); |
168 InspectorFrontendHost.setInspectedPageBounds(bounds); | 175 } |
169 } | |
170 }; | 176 }; |
171 | 177 |
172 /** @type {!WebInspector.AdvancedApp} */ | 178 /** @type {!WebInspector.AdvancedApp} */ |
173 WebInspector.AdvancedApp._appInstance; | 179 WebInspector.AdvancedApp._appInstance; |
174 | 180 |
175 /** | |
176 * @return {!WebInspector.AdvancedApp} | |
177 */ | |
178 WebInspector.AdvancedApp._instance = function() | |
179 { | |
180 if (!WebInspector.AdvancedApp._appInstance) | |
181 WebInspector.AdvancedApp._appInstance = new WebInspector.AdvancedApp(); | |
182 return WebInspector.AdvancedApp._appInstance; | |
183 }; | |
184 | 181 |
185 /** | 182 /** |
186 * @constructor | |
187 * @implements {WebInspector.AppProvider} | 183 * @implements {WebInspector.AppProvider} |
| 184 * @unrestricted |
188 */ | 185 */ |
189 WebInspector.AdvancedAppProvider = function() | 186 WebInspector.AdvancedAppProvider = class { |
190 { | 187 /** |
| 188 * @override |
| 189 * @return {!WebInspector.App} |
| 190 */ |
| 191 createApp() { |
| 192 return WebInspector.AdvancedApp._instance(); |
| 193 } |
191 }; | 194 }; |
192 | |
193 WebInspector.AdvancedAppProvider.prototype = { | |
194 /** | |
195 * @override | |
196 * @return {!WebInspector.App} | |
197 */ | |
198 createApp: function() | |
199 { | |
200 return WebInspector.AdvancedApp._instance(); | |
201 } | |
202 }; | |
OLD | NEW |