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
3 // found in the LICENSE file.
7 * @implements {WebInspector.App}
9 WebInspector
.AdvancedApp = function()
11 WebInspector
.dockController
.addEventListener(WebInspector
.DockController
.Events
.BeforeDockSideChanged
, this._openToolboxWindow
, this);
14 WebInspector
.AdvancedApp
.prototype = {
16 * @param {!Document} document
19 presentUI: function(document
)
21 var rootView
= new WebInspector
.RootView();
23 this._rootSplitWidget
= new WebInspector
.SplitWidget(false, true, "InspectorView.splitViewState", 555, 300, true);
24 this._rootSplitWidget
.show(rootView
.element
);
26 this._rootSplitWidget
.setSidebarWidget(WebInspector
.inspectorView
);
28 this._inspectedPagePlaceholder
= new WebInspector
.InspectedPagePlaceholder();
29 this._inspectedPagePlaceholder
.addEventListener(WebInspector
.InspectedPagePlaceholder
.Events
.Update
, this._onSetInspectedPageBounds
.bind(this, false), this);
30 this._responsiveDesignView
= new WebInspector
.ResponsiveDesignView(this._inspectedPagePlaceholder
);
31 this._rootSplitWidget
.setMainWidget(this._responsiveDesignView
);
33 WebInspector
.dockController
.addEventListener(WebInspector
.DockController
.Events
.BeforeDockSideChanged
, this._onBeforeDockSideChange
, this);
34 WebInspector
.dockController
.addEventListener(WebInspector
.DockController
.Events
.DockSideChanged
, this._onDockSideChange
, this);
35 WebInspector
.dockController
.addEventListener(WebInspector
.DockController
.Events
.AfterDockSideChanged
, this._onAfterDockSideChange
, this);
36 this._onDockSideChange();
38 WebInspector
.inspectorView
.showInitialPanel();
39 console
.timeStamp("AdvancedApp.attachToBody");
40 rootView
.attachToDocument(document
);
41 this._inspectedPagePlaceholder
.update();
45 * @param {!WebInspector.Event} event
47 _openToolboxWindow: function(event
)
49 if (/** @type {string} */ (event
.data
.to
) !== WebInspector
.DockController
.State
.Undocked
)
52 if (this._toolboxWindow
)
55 var url
= window
.location
.href
.replace("inspector.html", "toolbox.html");
56 this._toolboxWindow
= window
.open(url
, undefined);
60 * @param {!Document} toolboxDocument
62 toolboxLoaded: function(toolboxDocument
)
64 WebInspector
.initializeUIUtils(toolboxDocument
.defaultView
);
65 WebInspector
.installComponentRootStyles(/** @type {!Element} */ (toolboxDocument
.body
));
66 WebInspector
.ContextMenu
.installHandler(toolboxDocument
);
67 WebInspector
.Tooltip
.installHandler(toolboxDocument
);
69 var rootView
= new WebInspector
.RootView();
70 var inspectedPagePlaceholder
= new WebInspector
.InspectedPagePlaceholder();
71 inspectedPagePlaceholder
.addEventListener(WebInspector
.InspectedPagePlaceholder
.Events
.Update
, this._onSetInspectedPageBounds
.bind(this, true));
72 this._toolboxResponsiveDesignView
= new WebInspector
.ResponsiveDesignView(inspectedPagePlaceholder
);
73 this._toolboxResponsiveDesignView
.show(rootView
.element
);
74 rootView
.attachToDocument(toolboxDocument
);
76 this._updatePageResizer();
80 * @return {!InspectorFrontendHostAPI}
82 inspectorFrontendHost: function()
84 return window
.InspectorFrontendHost
;
87 _updatePageResizer: function()
90 this._responsiveDesignView
.updatePageResizer();
91 else if (this._toolboxResponsiveDesignView
)
92 this._toolboxResponsiveDesignView
.updatePageResizer();
96 * @param {!WebInspector.Event} event
98 _onBeforeDockSideChange: function(event
)
100 if (/** @type {string} */ (event
.data
.to
) === WebInspector
.DockController
.State
.Undocked
&& this._toolboxResponsiveDesignView
) {
101 // Hide inspectorView and force layout to mimic the undocked state.
102 this._rootSplitWidget
.hideSidebar();
103 this._inspectedPagePlaceholder
.update();
106 this._changingDockSide
= true;
110 * @param {!WebInspector.Event=} event
112 _onDockSideChange: function(event
)
114 this._updatePageResizer();
116 var toDockSide
= event
? /** @type {string} */ (event
.data
.to
) : WebInspector
.dockController
.dockSide();
117 if (toDockSide
=== WebInspector
.DockController
.State
.Undocked
) {
118 this._updateForUndocked();
119 } else if (this._toolboxResponsiveDesignView
&& event
&& /** @type {string} */ (event
.data
.from) === WebInspector
.DockController
.State
.Undocked
) {
120 // Don't update yet for smooth transition.
121 this._rootSplitWidget
.hideSidebar();
123 this._updateForDocked(toDockSide
);
128 * @param {!WebInspector.Event} event
130 _onAfterDockSideChange: function(event
)
132 // We may get here on the first dock side change while loading without BeforeDockSideChange.
133 if (!this._changingDockSide
)
135 this._changingDockSide
= false;
136 if (/** @type {string} */ (event
.data
.from) === WebInspector
.DockController
.State
.Undocked
) {
137 // Restore docked layout in case of smooth transition.
138 this._updateForDocked(/** @type {string} */ (event
.data
.to
));
140 this._inspectedPagePlaceholder
.update();
144 * @param {string} dockSide
146 _updateForDocked: function(dockSide
)
148 this._rootSplitWidget
.setVertical(dockSide
=== WebInspector
.DockController
.State
.DockedToRight
);
149 this._rootSplitWidget
.setSecondIsSidebar(dockSide
=== WebInspector
.DockController
.State
.DockedToRight
|| dockSide
=== WebInspector
.DockController
.State
.DockedToBottom
);
150 this._rootSplitWidget
.toggleResizer(this._rootSplitWidget
.resizerElement(), true);
151 this._rootSplitWidget
.toggleResizer(WebInspector
.inspectorView
.topResizerElement(), dockSide
=== WebInspector
.DockController
.State
.DockedToBottom
);
152 this._rootSplitWidget
.showBoth();
155 _updateForUndocked: function()
157 this._rootSplitWidget
.toggleResizer(this._rootSplitWidget
.resizerElement(), false);
158 this._rootSplitWidget
.toggleResizer(WebInspector
.inspectorView
.topResizerElement(), false);
159 this._rootSplitWidget
.hideMain();
162 _isDocked: function()
164 return WebInspector
.dockController
.dockSide() !== WebInspector
.DockController
.State
.Undocked
;
168 * @param {boolean} toolbox
169 * @param {!WebInspector.Event} event
171 _onSetInspectedPageBounds: function(toolbox
, event
)
173 if (this._changingDockSide
|| (this._isDocked() === toolbox
))
175 if (!window
.innerWidth
|| !window
.innerHeight
)
177 var bounds
= /** @type {{x: number, y: number, width: number, height: number}} */ (event
.data
);
178 console
.timeStamp("AdvancedApp.setInspectedPageBounds");
179 InspectorFrontendHost
.setInspectedPageBounds(bounds
);
183 /** @type {!WebInspector.AdvancedApp} */
184 WebInspector
.AdvancedApp
._appInstance
;
187 * @return {!WebInspector.AdvancedApp}
189 WebInspector
.AdvancedApp
._instance = function()
191 if (!WebInspector
.AdvancedApp
._appInstance
)
192 WebInspector
.AdvancedApp
._appInstance
= new WebInspector
.AdvancedApp();
193 return WebInspector
.AdvancedApp
._appInstance
;
198 * @implements {WebInspector.AppProvider}
200 WebInspector
.AdvancedAppProvider = function()
204 WebInspector
.AdvancedAppProvider
.prototype = {
207 * @return {!WebInspector.App}
209 createApp: function()
211 return WebInspector
.AdvancedApp
._instance();