| Index: third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js b/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
|
| index 5ebebac6e57692222da1d821b85ce007058903c6..9a89222a4ca40a939047a8af0d3103a0df505feb 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
|
| @@ -27,45 +27,46 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| /**
|
| - * @constructor
|
| - * @extends {WebInspector.VBox}
|
| * @implements {WebInspector.ViewLocationResolver}
|
| + * @unrestricted
|
| */
|
| -WebInspector.InspectorView = function()
|
| -{
|
| - WebInspector.VBox.call(this);
|
| +WebInspector.InspectorView = class extends WebInspector.VBox {
|
| + constructor() {
|
| + super();
|
| WebInspector.Dialog.setModalHostView(this);
|
| this.setMinimumSize(240, 72);
|
|
|
| // DevTools sidebar is a vertical split of panels tabbed pane and a drawer.
|
| - this._drawerSplitWidget = new WebInspector.SplitWidget(false, true, "Inspector.drawerSplitViewState", 200, 200);
|
| + this._drawerSplitWidget = new WebInspector.SplitWidget(false, true, 'Inspector.drawerSplitViewState', 200, 200);
|
| this._drawerSplitWidget.hideSidebar();
|
| this._drawerSplitWidget.hideDefaultResizer();
|
| this._drawerSplitWidget.enableShowModeSaving();
|
| this._drawerSplitWidget.show(this.element);
|
|
|
| // Create drawer tabbed pane.
|
| - this._drawerTabbedLocation = WebInspector.viewManager.createTabbedLocation(this._showDrawer.bind(this, false), "drawer-view", true);
|
| + this._drawerTabbedLocation =
|
| + WebInspector.viewManager.createTabbedLocation(this._showDrawer.bind(this, false), 'drawer-view', true);
|
| this._drawerTabbedLocation.enableMoreTabsButton();
|
| this._drawerTabbedPane = this._drawerTabbedLocation.tabbedPane();
|
| this._drawerTabbedPane.setMinimumSize(0, 27);
|
| - var closeDrawerButton = new WebInspector.ToolbarButton(WebInspector.UIString("Close drawer"), "delete-toolbar-item");
|
| - closeDrawerButton.addEventListener("click", this._closeDrawer.bind(this));
|
| + var closeDrawerButton =
|
| + new WebInspector.ToolbarButton(WebInspector.UIString('Close drawer'), 'delete-toolbar-item');
|
| + closeDrawerButton.addEventListener('click', this._closeDrawer.bind(this));
|
| this._drawerTabbedPane.rightToolbar().appendToolbarItem(closeDrawerButton);
|
| this._drawerSplitWidget.installResizer(this._drawerTabbedPane.headerElement());
|
| this._drawerSplitWidget.setSidebarWidget(this._drawerTabbedPane);
|
|
|
| // Create main area tabbed pane.
|
| - this._tabbedLocation = WebInspector.viewManager.createTabbedLocation(InspectorFrontendHost.bringToFront.bind(InspectorFrontendHost), "panel", true, true);
|
| + this._tabbedLocation = WebInspector.viewManager.createTabbedLocation(
|
| + InspectorFrontendHost.bringToFront.bind(InspectorFrontendHost), 'panel', true, true);
|
| this._tabbedPane = this._tabbedLocation.tabbedPane();
|
| - this._tabbedPane.registerRequiredCSS("ui/inspectorViewTabbedPane.css");
|
| + this._tabbedPane.registerRequiredCSS('ui/inspectorViewTabbedPane.css');
|
| this._tabbedPane.setTabSlider(true);
|
| this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected, this._tabSelected, this);
|
|
|
| if (InspectorFrontendHost.isUnderTest())
|
| - this._tabbedPane.setAutoSelectFirstItemOnShow(false);
|
| + this._tabbedPane.setAutoSelectFirstItemOnShow(false);
|
| this._drawerSplitWidget.setMainWidget(this._tabbedPane);
|
|
|
| this._keyDownBound = this._keyDown.bind(this);
|
| @@ -75,270 +76,248 @@ WebInspector.InspectorView = function()
|
| * @this {WebInspector.InspectorView}
|
| * @param {!WebInspector.Event} event
|
| */
|
| - function showPanel(event)
|
| - {
|
| - var panelName = /** @type {string} */ (event.data);
|
| - this.showPanel(panelName);
|
| + function showPanel(event) {
|
| + var panelName = /** @type {string} */ (event.data);
|
| + this.showPanel(panelName);
|
| }
|
| -};
|
| + }
|
|
|
| -/**
|
| - * @return {!WebInspector.InspectorView}
|
| - */
|
| -WebInspector.InspectorView.instance = function()
|
| -{
|
| + /**
|
| + * @return {!WebInspector.InspectorView}
|
| + */
|
| + static instance() {
|
| return /** @type {!WebInspector.InspectorView} */ (self.runtime.sharedInstance(WebInspector.InspectorView));
|
| -};
|
| -
|
| -WebInspector.InspectorView.prototype = {
|
| - wasShown: function()
|
| - {
|
| - this.element.ownerDocument.addEventListener("keydown", this._keyDownBound, false);
|
| - },
|
| -
|
| - willHide: function()
|
| - {
|
| - this.element.ownerDocument.removeEventListener("keydown", this._keyDownBound, false);
|
| - },
|
| -
|
| - /**
|
| - * @override
|
| - * @param {string} locationName
|
| - * @return {?WebInspector.ViewLocation}
|
| - */
|
| - resolveLocation: function(locationName)
|
| - {
|
| - return this._drawerTabbedLocation;
|
| - },
|
| -
|
| - createToolbars: function()
|
| - {
|
| - this._tabbedPane.leftToolbar().appendLocationItems("main-toolbar-left");
|
| - this._tabbedPane.rightToolbar().appendLocationItems("main-toolbar-right");
|
| - },
|
| -
|
| - /**
|
| - * @param {!WebInspector.View} view
|
| - */
|
| - addPanel: function(view)
|
| - {
|
| - this._tabbedLocation.appendView(view);
|
| - },
|
| -
|
| - /**
|
| - * @param {string} panelName
|
| - * @return {boolean}
|
| - */
|
| - hasPanel: function(panelName)
|
| - {
|
| - return this._tabbedPane.hasTab(panelName);
|
| - },
|
| -
|
| - /**
|
| - * @param {string} panelName
|
| - * @return {!Promise.<!WebInspector.Panel>}
|
| - */
|
| - panel: function(panelName)
|
| - {
|
| - return /** @type {!Promise.<!WebInspector.Panel>} */ (WebInspector.viewManager.view(panelName).widget());
|
| - },
|
| -
|
| - /**
|
| - * @param {boolean} allTargetsSuspended
|
| - */
|
| - onSuspendStateChanged: function(allTargetsSuspended)
|
| - {
|
| - this._currentPanelLocked = allTargetsSuspended;
|
| - this._tabbedPane.setCurrentTabLocked(this._currentPanelLocked);
|
| - this._tabbedPane.leftToolbar().setEnabled(!this._currentPanelLocked);
|
| - this._tabbedPane.rightToolbar().setEnabled(!this._currentPanelLocked);
|
| - },
|
| -
|
| - /**
|
| - * @param {string} panelName
|
| - * @return {boolean}
|
| - */
|
| - canSelectPanel: function(panelName)
|
| - {
|
| - return !this._currentPanelLocked || this._tabbedPane.selectedTabId === panelName;
|
| - },
|
| -
|
| - /**
|
| - * @param {string} panelName
|
| - * @return {!Promise.<?WebInspector.Panel>}
|
| - */
|
| - showPanel: function(panelName)
|
| - {
|
| - return WebInspector.viewManager.showView(panelName);
|
| - },
|
| -
|
| - /**
|
| - * @param {string} panelName
|
| - * @param {string} iconType
|
| - * @param {string=} iconTooltip
|
| - */
|
| - setPanelIcon: function(panelName, iconType, iconTooltip)
|
| - {
|
| - this._tabbedPane.setTabIcon(panelName, iconType, iconTooltip);
|
| - },
|
| -
|
| - /**
|
| - * @return {!WebInspector.Panel}
|
| - */
|
| - currentPanelDeprecated: function()
|
| - {
|
| - return /** @type {!WebInspector.Panel} */ (WebInspector.viewManager.materializedWidget(this._tabbedPane.selectedTabId || ""));
|
| - },
|
| -
|
| - /**
|
| - * @param {boolean} focus
|
| - */
|
| - _showDrawer: function(focus)
|
| - {
|
| - if (this._drawerTabbedPane.isShowing())
|
| - return;
|
| - this._drawerSplitWidget.showBoth();
|
| - if (focus)
|
| - this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._drawerTabbedPane);
|
| - else
|
| - this._focusRestorer = null;
|
| - },
|
| -
|
| - /**
|
| - * @return {boolean}
|
| - */
|
| - drawerVisible: function()
|
| - {
|
| - return this._drawerTabbedPane.isShowing();
|
| - },
|
| -
|
| - _closeDrawer: function()
|
| - {
|
| - if (!this._drawerTabbedPane.isShowing())
|
| - return;
|
| - if (this._focusRestorer)
|
| - this._focusRestorer.restore();
|
| - this._drawerSplitWidget.hideSidebar(true);
|
| - },
|
| -
|
| - /**
|
| - * @param {boolean} minimized
|
| - */
|
| - setDrawerMinimized: function(minimized)
|
| - {
|
| - this._drawerSplitWidget.setSidebarMinimized(minimized);
|
| - this._drawerSplitWidget.setResizable(!minimized);
|
| - },
|
| -
|
| - /**
|
| - * @return {boolean}
|
| - */
|
| - isDrawerMinimized: function()
|
| - {
|
| - return this._drawerSplitWidget.isSidebarMinimized();
|
| - },
|
| -
|
| - _keyDown: function(event)
|
| - {
|
| - if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event))
|
| - return;
|
| -
|
| - var keyboardEvent = /** @type {!KeyboardEvent} */ (event);
|
| - // Ctrl/Cmd + 1-9 should show corresponding panel.
|
| - var panelShortcutEnabled = WebInspector.moduleSetting("shortcutPanelSwitch").get();
|
| - if (panelShortcutEnabled && !event.shiftKey && !event.altKey) {
|
| - var panelIndex = -1;
|
| - if (event.keyCode > 0x30 && event.keyCode < 0x3A)
|
| - panelIndex = event.keyCode - 0x31;
|
| - else if (event.keyCode > 0x60 && event.keyCode < 0x6A && keyboardEvent.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD)
|
| - panelIndex = event.keyCode - 0x61;
|
| - if (panelIndex !== -1) {
|
| - var panelName = this._tabbedPane.allTabs()[panelIndex];
|
| - if (panelName) {
|
| - if (!WebInspector.Dialog.hasInstance() && !this._currentPanelLocked)
|
| - this.showPanel(panelName);
|
| - event.consume(true);
|
| - }
|
| - }
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + */
|
| + wasShown() {
|
| + this.element.ownerDocument.addEventListener('keydown', this._keyDownBound, false);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + */
|
| + willHide() {
|
| + this.element.ownerDocument.removeEventListener('keydown', this._keyDownBound, false);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {string} locationName
|
| + * @return {?WebInspector.ViewLocation}
|
| + */
|
| + resolveLocation(locationName) {
|
| + return this._drawerTabbedLocation;
|
| + }
|
| +
|
| + createToolbars() {
|
| + this._tabbedPane.leftToolbar().appendLocationItems('main-toolbar-left');
|
| + this._tabbedPane.rightToolbar().appendLocationItems('main-toolbar-right');
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.View} view
|
| + */
|
| + addPanel(view) {
|
| + this._tabbedLocation.appendView(view);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} panelName
|
| + * @return {boolean}
|
| + */
|
| + hasPanel(panelName) {
|
| + return this._tabbedPane.hasTab(panelName);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} panelName
|
| + * @return {!Promise.<!WebInspector.Panel>}
|
| + */
|
| + panel(panelName) {
|
| + return /** @type {!Promise.<!WebInspector.Panel>} */ (WebInspector.viewManager.view(panelName).widget());
|
| + }
|
| +
|
| + /**
|
| + * @param {boolean} allTargetsSuspended
|
| + */
|
| + onSuspendStateChanged(allTargetsSuspended) {
|
| + this._currentPanelLocked = allTargetsSuspended;
|
| + this._tabbedPane.setCurrentTabLocked(this._currentPanelLocked);
|
| + this._tabbedPane.leftToolbar().setEnabled(!this._currentPanelLocked);
|
| + this._tabbedPane.rightToolbar().setEnabled(!this._currentPanelLocked);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} panelName
|
| + * @return {boolean}
|
| + */
|
| + canSelectPanel(panelName) {
|
| + return !this._currentPanelLocked || this._tabbedPane.selectedTabId === panelName;
|
| + }
|
| +
|
| + /**
|
| + * @param {string} panelName
|
| + * @return {!Promise.<?WebInspector.Panel>}
|
| + */
|
| + showPanel(panelName) {
|
| + return WebInspector.viewManager.showView(panelName);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} panelName
|
| + * @param {string} iconType
|
| + * @param {string=} iconTooltip
|
| + */
|
| + setPanelIcon(panelName, iconType, iconTooltip) {
|
| + this._tabbedPane.setTabIcon(panelName, iconType, iconTooltip);
|
| + }
|
| +
|
| + /**
|
| + * @return {!WebInspector.Panel}
|
| + */
|
| + currentPanelDeprecated() {
|
| + return /** @type {!WebInspector.Panel} */ (
|
| + WebInspector.viewManager.materializedWidget(this._tabbedPane.selectedTabId || ''));
|
| + }
|
| +
|
| + /**
|
| + * @param {boolean} focus
|
| + */
|
| + _showDrawer(focus) {
|
| + if (this._drawerTabbedPane.isShowing())
|
| + return;
|
| + this._drawerSplitWidget.showBoth();
|
| + if (focus)
|
| + this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._drawerTabbedPane);
|
| + else
|
| + this._focusRestorer = null;
|
| + }
|
| +
|
| + /**
|
| + * @return {boolean}
|
| + */
|
| + drawerVisible() {
|
| + return this._drawerTabbedPane.isShowing();
|
| + }
|
| +
|
| + _closeDrawer() {
|
| + if (!this._drawerTabbedPane.isShowing())
|
| + return;
|
| + if (this._focusRestorer)
|
| + this._focusRestorer.restore();
|
| + this._drawerSplitWidget.hideSidebar(true);
|
| + }
|
| +
|
| + /**
|
| + * @param {boolean} minimized
|
| + */
|
| + setDrawerMinimized(minimized) {
|
| + this._drawerSplitWidget.setSidebarMinimized(minimized);
|
| + this._drawerSplitWidget.setResizable(!minimized);
|
| + }
|
| +
|
| + /**
|
| + * @return {boolean}
|
| + */
|
| + isDrawerMinimized() {
|
| + return this._drawerSplitWidget.isSidebarMinimized();
|
| + }
|
| +
|
| + _keyDown(event) {
|
| + if (!WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event))
|
| + return;
|
| +
|
| + var keyboardEvent = /** @type {!KeyboardEvent} */ (event);
|
| + // Ctrl/Cmd + 1-9 should show corresponding panel.
|
| + var panelShortcutEnabled = WebInspector.moduleSetting('shortcutPanelSwitch').get();
|
| + if (panelShortcutEnabled && !event.shiftKey && !event.altKey) {
|
| + var panelIndex = -1;
|
| + if (event.keyCode > 0x30 && event.keyCode < 0x3A)
|
| + panelIndex = event.keyCode - 0x31;
|
| + else if (
|
| + event.keyCode > 0x60 && event.keyCode < 0x6A &&
|
| + keyboardEvent.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD)
|
| + panelIndex = event.keyCode - 0x61;
|
| + if (panelIndex !== -1) {
|
| + var panelName = this._tabbedPane.allTabs()[panelIndex];
|
| + if (panelName) {
|
| + if (!WebInspector.Dialog.hasInstance() && !this._currentPanelLocked)
|
| + this.showPanel(panelName);
|
| + event.consume(true);
|
| }
|
| - },
|
| -
|
| - onResize: function()
|
| - {
|
| - WebInspector.Dialog.modalHostRepositioned();
|
| - },
|
| -
|
| - /**
|
| - * @return {!Element}
|
| - */
|
| - topResizerElement: function()
|
| - {
|
| - return this._tabbedPane.headerElement();
|
| - },
|
| -
|
| - toolbarItemResized: function()
|
| - {
|
| - this._tabbedPane.headerResized();
|
| - },
|
| -
|
| - /**
|
| - * @param {!WebInspector.Event} event
|
| - */
|
| - _tabSelected: function(event)
|
| - {
|
| - var tabId = /** @type {string} */(event.data["tabId"]);
|
| - WebInspector.userMetrics.panelShown(tabId);
|
| - },
|
| -
|
| - /**
|
| - * @param {!WebInspector.SplitWidget} splitWidget
|
| - */
|
| - setOwnerSplit: function(splitWidget)
|
| - {
|
| - this._ownerSplitWidget = splitWidget;
|
| - },
|
| -
|
| - minimize: function()
|
| - {
|
| - if (this._ownerSplitWidget)
|
| - this._ownerSplitWidget.setSidebarMinimized(true);
|
| - },
|
| -
|
| - restore: function()
|
| - {
|
| - if (this._ownerSplitWidget)
|
| - this._ownerSplitWidget.setSidebarMinimized(false);
|
| - },
|
| -
|
| - __proto__: WebInspector.VBox.prototype
|
| + }
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + */
|
| + onResize() {
|
| + WebInspector.Dialog.modalHostRepositioned();
|
| + }
|
| +
|
| + /**
|
| + * @return {!Element}
|
| + */
|
| + topResizerElement() {
|
| + return this._tabbedPane.headerElement();
|
| + }
|
| +
|
| + toolbarItemResized() {
|
| + this._tabbedPane.headerResized();
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.Event} event
|
| + */
|
| + _tabSelected(event) {
|
| + var tabId = /** @type {string} */ (event.data['tabId']);
|
| + WebInspector.userMetrics.panelShown(tabId);
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.SplitWidget} splitWidget
|
| + */
|
| + setOwnerSplit(splitWidget) {
|
| + this._ownerSplitWidget = splitWidget;
|
| + }
|
| +
|
| + minimize() {
|
| + if (this._ownerSplitWidget)
|
| + this._ownerSplitWidget.setSidebarMinimized(true);
|
| + }
|
| +
|
| + restore() {
|
| + if (this._ownerSplitWidget)
|
| + this._ownerSplitWidget.setSidebarMinimized(false);
|
| + }
|
| };
|
|
|
| +
|
| /**
|
| * @type {!WebInspector.InspectorView}
|
| */
|
| WebInspector.inspectorView;
|
|
|
| /**
|
| - * @constructor
|
| * @implements {WebInspector.ActionDelegate}
|
| + * @unrestricted
|
| */
|
| -WebInspector.InspectorView.DrawerToggleActionDelegate = function()
|
| -{
|
| -};
|
| -
|
| -WebInspector.InspectorView.DrawerToggleActionDelegate.prototype = {
|
| - /**
|
| - * @override
|
| - * @param {!WebInspector.Context} context
|
| - * @param {string} actionId
|
| - * @return {boolean}
|
| - */
|
| - handleAction: function(context, actionId)
|
| - {
|
| - if (WebInspector.inspectorView.drawerVisible())
|
| - WebInspector.inspectorView._closeDrawer();
|
| - else
|
| - WebInspector.inspectorView._showDrawer(true);
|
| - return true;
|
| - }
|
| +WebInspector.InspectorView.DrawerToggleActionDelegate = class {
|
| + /**
|
| + * @override
|
| + * @param {!WebInspector.Context} context
|
| + * @param {string} actionId
|
| + * @return {boolean}
|
| + */
|
| + handleAction(context, actionId) {
|
| + if (WebInspector.inspectorView.drawerVisible())
|
| + WebInspector.inspectorView._closeDrawer();
|
| + else
|
| + WebInspector.inspectorView._showDrawer(true);
|
| + return true;
|
| + }
|
| };
|
|
|