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