[globals] self.UI.inspectorView

[email protected]

Bug: 1058320
Change-Id: If282650f584d4db45c0a6260e102f044791f759d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2379692
Reviewed-by: Simon Zünd <[email protected]>
Commit-Queue: Tim van der Lippe <[email protected]>
diff --git a/front_end/console/ConsolePanel.js b/front_end/console/ConsolePanel.js
index cf8affd..b1cccf4 100644
--- a/front_end/console/ConsolePanel.js
+++ b/front_end/console/ConsolePanel.js
@@ -62,7 +62,7 @@
     super.wasShown();
     const wrapper = WrapperView._instance;
     if (wrapper && wrapper.isShowing()) {
-      self.UI.inspectorView.setDrawerMinimized(true);
+      UI.InspectorView.InspectorView.instance().setDrawerMinimized(true);
     }
     this._view.show(this.element);
     ConsolePanel._updateContextFlavor();
@@ -75,7 +75,7 @@
     super.willHide();
     // The minimized drawer has 0 height, and showing Console inside may set
     // Console's scrollTop to 0. Unminimize before calling show to avoid this.
-    self.UI.inspectorView.setDrawerMinimized(false);
+    UI.InspectorView.InspectorView.instance().setDrawerMinimized(false);
     if (WrapperView._instance) {
       WrapperView._instance._showViewInWrapper();
     }
@@ -111,7 +111,7 @@
     if (!ConsolePanel.instance().isShowing()) {
       this._showViewInWrapper();
     } else {
-      self.UI.inspectorView.setDrawerMinimized(true);
+      UI.InspectorView.InspectorView.instance().setDrawerMinimized(true);
     }
     ConsolePanel._updateContextFlavor();
   }
@@ -120,7 +120,7 @@
    * @override
    */
   willHide() {
-    self.UI.inspectorView.setDrawerMinimized(false);
+    UI.InspectorView.InspectorView.instance().setDrawerMinimized(false);
     ConsolePanel._updateContextFlavor();
   }
 
diff --git a/front_end/console_counters/WarningErrorCounter.js b/front_end/console_counters/WarningErrorCounter.js
index 493e16a..af6105c 100644
--- a/front_end/console_counters/WarningErrorCounter.js
+++ b/front_end/console_counters/WarningErrorCounter.js
@@ -181,7 +181,7 @@
     }
     this._counter.title = this._titles;
     UI.ARIAUtils.setAccessibleName(this._counter, this._titles);
-    self.UI.inspectorView.toolbarItemResized();
+    UI.InspectorView.InspectorView.instance().toolbarItemResized();
     this._updatingForTest = false;
     this._updatedForTest();
     return Promise.resolve();
diff --git a/front_end/elements/ElementsPanel.js b/front_end/elements/ElementsPanel.js
index 2b917f3..bcbbba9 100644
--- a/front_end/elements/ElementsPanel.js
+++ b/front_end/elements/ElementsPanel.js
@@ -961,7 +961,8 @@
 
     const position = Common.Settings.Settings.instance().moduleSetting('sidebarPosition').get();
     let splitMode = _splitMode.Horizontal;
-    if (position === 'right' || (position === 'auto' && self.UI.inspectorView.element.offsetWidth > 680)) {
+    if (position === 'right' ||
+        (position === 'auto' && UI.InspectorView.InspectorView.instance().element.offsetWidth > 680)) {
       splitMode = _splitMode.Vertical;
     }
     if (!this.sidebarPaneView) {
diff --git a/front_end/emulation/AdvancedApp.js b/front_end/emulation/AdvancedApp.js
index 2538502..3deb44e 100644
--- a/front_end/emulation/AdvancedApp.js
+++ b/front_end/emulation/AdvancedApp.js
@@ -46,7 +46,7 @@
     this._rootSplitWidget.show(rootView.element);
     this._rootSplitWidget.setSidebarWidget(self.UI.inspectorView);
     this._rootSplitWidget.setDefaultFocusedChild(self.UI.inspectorView);
-    self.UI.inspectorView.setOwnerSplit(this._rootSplitWidget);
+    UI.InspectorView.InspectorView.instance().setOwnerSplit(this._rootSplitWidget);
 
     this._inspectedPagePlaceholder = instance();
     this._inspectedPagePlaceholder.addEventListener(Events.Update, this._onSetInspectedPageBounds.bind(this), this);
@@ -166,13 +166,14 @@
         dockSide === UI.DockController.State.DockedToRight || dockSide === UI.DockController.State.DockedToBottom);
     this._rootSplitWidget.toggleResizer(this._rootSplitWidget.resizerElement(), true);
     this._rootSplitWidget.toggleResizer(
-        self.UI.inspectorView.topResizerElement(), dockSide === UI.DockController.State.DockedToBottom);
+        UI.InspectorView.InspectorView.instance().topResizerElement(),
+        dockSide === UI.DockController.State.DockedToBottom);
     this._rootSplitWidget.showBoth();
   }
 
   _updateForUndocked() {
     this._rootSplitWidget.toggleResizer(this._rootSplitWidget.resizerElement(), false);
-    this._rootSplitWidget.toggleResizer(self.UI.inspectorView.topResizerElement(), false);
+    this._rootSplitWidget.toggleResizer(UI.InspectorView.InspectorView.instance().topResizerElement(), false);
     this._rootSplitWidget.hideMain();
   }
 
diff --git a/front_end/extensions/ExtensionServer.js b/front_end/extensions/ExtensionServer.js
index f2df338..b1d3617 100644
--- a/front_end/extensions/ExtensionServer.js
+++ b/front_end/extensions/ExtensionServer.js
@@ -337,7 +337,7 @@
     const id = message.id;
     // The ids are generated on the client API side and must be unique, so the check below
     // shouldn't be hit unless someone is bypassing the API.
-    if (id in this._clientObjects || self.UI.inspectorView.hasPanel(id)) {
+    if (id in this._clientObjects || UI.InspectorView.InspectorView.instance().hasPanel(id)) {
       return this._status.E_EXISTS(id);
     }
 
@@ -347,7 +347,7 @@
     const panelView =
         new ExtensionServerPanelView(persistentId, message.title, new ExtensionPanel(this, persistentId, id, page));
     this._clientObjects[id] = panelView;
-    self.UI.inspectorView.addPanel(panelView);
+    UI.InspectorView.InspectorView.instance().addPanel(panelView);
     return this._status.OK();
   }
 
@@ -357,7 +357,7 @@
     if (panelView && panelView instanceof ExtensionServerPanelView) {
       panelViewId = panelView.viewId();
     }
-    self.UI.inspectorView.showPanel(panelViewId);
+    UI.InspectorView.InspectorView.instance().showPanel(panelViewId);
   }
 
   _onCreateToolbarButton(message, port) {
diff --git a/front_end/help/ReleaseNoteView.js b/front_end/help/ReleaseNoteView.js
index 8c33aed..c974f91 100644
--- a/front_end/help/ReleaseNoteView.js
+++ b/front_end/help/ReleaseNoteView.js
@@ -68,7 +68,7 @@
 
     actionContainer.appendChild(UI.UIUtils.createTextButton(ls`Close`, event => {
       event.consume(true);
-      self.UI.inspectorView.closeDrawerTab(releaseNoteViewId, true);
+      UI.InspectorView.InspectorView.instance().closeDrawerTab(releaseNoteViewId, true);
     }, 'close-release-note'));
 
     const imageLink = UI.XLink.XLink.create(releaseNote.link, ' ');
diff --git a/front_end/inspector_main/InspectorMain.js b/front_end/inspector_main/InspectorMain.js
index 336cfb3..a381f18 100644
--- a/front_end/inspector_main/InspectorMain.js
+++ b/front_end/inspector_main/InspectorMain.js
@@ -155,7 +155,7 @@
         icon = UI.Icon.Icon.create('smallicon-warning');
         icon.title = Common.UIString.UIString('JavaScript is disabled');
       }
-      self.UI.inspectorView.setPanelIcon('sources', icon);
+      UI.InspectorView.InspectorView.instance().setPanelIcon('sources', icon);
     }
   }
 }
diff --git a/front_end/lighthouse/LighthouseReportRenderer.js b/front_end/lighthouse/LighthouseReportRenderer.js
index c703bbb..57ea445 100644
--- a/front_end/lighthouse/LighthouseReportRenderer.js
+++ b/front_end/lighthouse/LighthouseReportRenderer.js
@@ -45,7 +45,7 @@
 
     async function onViewTraceClick() {
       HostModule.userMetrics.actionTaken(Host.UserMetrics.Action.LighthouseViewTrace);
-      await self.UI.inspectorView.showPanel('timeline');
+      await UI.InspectorView.InspectorView.instance().showPanel('timeline');
       Timeline.TimelinePanel.TimelinePanel.instance().loadFromEvents(defaultPassTrace.traceEvents);
     }
   }
diff --git a/front_end/main/MainImpl.js b/front_end/main/MainImpl.js
index 5d94875..b50658c 100644
--- a/front_end/main/MainImpl.js
+++ b/front_end/main/MainImpl.js
@@ -343,7 +343,7 @@
     Host.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(
         Host.InspectorFrontendHostAPI.Events.RevealSourceLine, this._revealSourceLine, this);
 
-    self.UI.inspectorView.createToolbars();
+    UI.InspectorView.InspectorView.instance().createToolbars();
     Host.InspectorFrontendHost.InspectorFrontendHostInstance.loadCompleted();
 
     const extensions = self.runtime.extensions(Common.QueryParamHandler.QueryParamHandler);
@@ -553,7 +553,7 @@
 
   _onSuspendStateChanged() {
     const suspended = SDK.SDKModel.TargetManager.instance().allTargetsSuspended();
-    self.UI.inspectorView.onSuspendStateChanged(suspended);
+    UI.InspectorView.InspectorView.instance().onSuspendStateChanged(suspended);
   }
 }
 
@@ -603,7 +603,7 @@
   handleAction(context, actionId) {
     let searchableView = UI.SearchableView.SearchableView.fromElement(document.deepActiveElement());
     if (!searchableView) {
-      const currentPanel = self.UI.inspectorView.currentPanelDeprecated();
+      const currentPanel = UI.InspectorView.InspectorView.instance().currentPanelDeprecated();
       if (currentPanel) {
         searchableView = currentPanel.searchableView();
       }
@@ -732,8 +732,8 @@
 
     contextMenu.defaultSection().appendAction(
         'main.toggle-drawer',
-        self.UI.inspectorView.drawerVisible() ? Common.UIString.UIString('Hide console drawer') :
-                                                Common.UIString.UIString('Show console drawer'));
+        UI.InspectorView.InspectorView.instance().drawerVisible() ? Common.UIString.UIString('Hide console drawer') :
+                                                                    Common.UIString.UIString('Show console drawer'));
     contextMenu.appendItemsAtLocation('mainMenu');
     const moreTools = contextMenu.defaultSection().appendSubMenuItem(Common.UIString.UIString('More tools'));
     const extensions = self.runtime.extensions('view', undefined, true);
diff --git a/front_end/main/SimpleApp.js b/front_end/main/SimpleApp.js
index 61f3fab..d9fc37b 100644
--- a/front_end/main/SimpleApp.js
+++ b/front_end/main/SimpleApp.js
@@ -19,7 +19,7 @@
    */
   presentUI(document) {
     const rootView = new UI.RootView.RootView();
-    self.UI.inspectorView.show(rootView.element);
+    UI.InspectorView.InspectorView.instance().show(rootView.element);
     rootView.attachToDocument(document);
     rootView.focus();
   }
diff --git a/front_end/mobile_throttling/NetworkPanelIndicator.js b/front_end/mobile_throttling/NetworkPanelIndicator.js
index 4f76d92..11cc599 100644
--- a/front_end/mobile_throttling/NetworkPanelIndicator.js
+++ b/front_end/mobile_throttling/NetworkPanelIndicator.js
@@ -12,7 +12,7 @@
 export class NetworkPanelIndicator {
   constructor() {
     // TODO: we should not access network from other modules.
-    if (!self.UI.inspectorView.hasPanel('network')) {
+    if (!UI.InspectorView.InspectorView.instance().hasPanel('network')) {
       return;
     }
     const manager = SDK.NetworkManager.MultitargetNetworkManager.instance();
@@ -34,7 +34,7 @@
         icon = UI.Icon.Icon.create('smallicon-warning');
         icon.title = Common.UIString.UIString('Requests may be blocked');
       }
-      self.UI.inspectorView.setPanelIcon('network', icon);
+      UI.InspectorView.InspectorView.instance().setPanelIcon('network', icon);
     }
   }
 }
diff --git a/front_end/mobile_throttling/ThrottlingManager.js b/front_end/mobile_throttling/ThrottlingManager.js
index 05b988f..82ec694 100644
--- a/front_end/mobile_throttling/ThrottlingManager.js
+++ b/front_end/mobile_throttling/ThrottlingManager.js
@@ -219,7 +219,7 @@
     for (const control of this._cpuThrottlingControls) {
       control.setSelectedIndex(index);
     }
-    self.UI.inspectorView.setPanelIcon('timeline', icon);
+    UI.InspectorView.InspectorView.instance().setPanelIcon('timeline', icon);
     this.dispatchEventToListeners(Events.RateChanged, this._cpuThrottlingRate);
   }
 
diff --git a/front_end/network/NetworkPanel.js b/front_end/network/NetworkPanel.js
index 5ff28c7..dc884ba 100644
--- a/front_end/network/NetworkPanel.js
+++ b/front_end/network/NetworkPanel.js
@@ -879,7 +879,7 @@
         return true;
       }
       case 'network.search': {
-        const selection = self.UI.inspectorView.element.window().getSelection();
+        const selection = UI.InspectorView.InspectorView.instance().element.window().getSelection();
         let queryCandidate = '';
         if (selection.rangeCount) {
           queryCandidate = selection.toString().replace(/\r?\n.*/, '');
diff --git a/front_end/profiler/HeapProfileView.js b/front_end/profiler/HeapProfileView.js
index 068d803..c2d507b 100644
--- a/front_end/profiler/HeapProfileView.js
+++ b/front_end/profiler/HeapProfileView.js
@@ -298,7 +298,7 @@
 
     const icon = UI.Icon.Icon.create('smallicon-warning');
     icon.title = ls`Heap profiler is recording`;
-    self.UI.inspectorView.setPanelIcon('heap_profiler', icon);
+    UI.InspectorView.InspectorView.instance().setPanelIcon('heap_profiler', icon);
 
     this._recording = true;
     this._startSampling();
@@ -319,7 +319,7 @@
       recordedProfile.updateStatus('');
       this.setProfileBeingRecorded(null);
     }
-    self.UI.inspectorView.setPanelIcon('heap_profiler', null);
+    UI.InspectorView.InspectorView.instance().setPanelIcon('heap_profiler', null);
     this.dispatchEventToListeners(ProfileEvents.ProfileComplete, recordedProfile);
   }
 
diff --git a/front_end/screencast/ScreencastApp.js b/front_end/screencast/ScreencastApp.js
index 64d098f..0ee38f4 100644
--- a/front_end/screencast/ScreencastApp.js
+++ b/front_end/screencast/ScreencastApp.js
@@ -54,7 +54,7 @@
     this._rootSplitWidget.hideMain();
 
     this._rootSplitWidget.setSidebarWidget(self.UI.inspectorView);
-    self.UI.inspectorView.setOwnerSplit(this._rootSplitWidget);
+    UI.InspectorView.InspectorView.instance().setOwnerSplit(this._rootSplitWidget);
     rootView.attachToDocument(document);
     rootView.focus();
   }
diff --git a/front_end/sources/SearchSourcesView.js b/front_end/sources/SearchSourcesView.js
index 790fa3d..68cc172 100644
--- a/front_end/sources/SearchSourcesView.js
+++ b/front_end/sources/SearchSourcesView.js
@@ -60,7 +60,7 @@
    * @return {!Promise}
    */
   _showSearch() {
-    const selection = self.UI.inspectorView.element.window().getSelection();
+    const selection = UI.InspectorView.InspectorView.instance().element.window().getSelection();
     let queryCandidate = '';
     if (selection.rangeCount) {
       queryCandidate = selection.toString().replace(/\r?\n.*/, '');
diff --git a/front_end/sources/SourcesPanel.js b/front_end/sources/SourcesPanel.js
index 84a921e..bedc449 100644
--- a/front_end/sources/SourcesPanel.js
+++ b/front_end/sources/SourcesPanel.js
@@ -178,7 +178,7 @@
     panel._sourcesView.leftToolbar().removeToolbarItems();
     panel._sourcesView.rightToolbar().removeToolbarItems();
     panel._sourcesView.bottomToolbar().removeToolbarItems();
-    const isInWrapper = WrapperView.isShowing() && !self.UI.inspectorView.isDrawerMinimized();
+    const isInWrapper = WrapperView.isShowing() && !UI.InspectorView.InspectorView.instance().isDrawerMinimized();
     if (panel._splitWidget.isVertical() || isInWrapper) {
       panel._splitWidget.uninstallResizer(panel._sourcesView.toolbarContainerElement());
     } else {
@@ -264,7 +264,7 @@
     super.wasShown();
     const wrapper = WrapperView._instance;
     if (wrapper && wrapper.isShowing()) {
-      self.UI.inspectorView.setDrawerMinimized(true);
+      UI.InspectorView.InspectorView.instance().setDrawerMinimized(true);
       SourcesPanel.updateResizerAndSidebarButtons(this);
     }
     this.editorView.setMainWidget(this._sourcesView);
@@ -278,7 +278,7 @@
     UI.Context.Context.instance().setFlavor(SourcesPanel, null);
     if (WrapperView.isShowing()) {
       WrapperView._instance._showViewInWrapper();
-      self.UI.inspectorView.setDrawerMinimized(false);
+      UI.InspectorView.InspectorView.instance().setDrawerMinimized(false);
       SourcesPanel.updateResizerAndSidebarButtons(this);
     }
   }
@@ -303,7 +303,7 @@
     if (WrapperView.isShowing()) {
       return true;
     }
-    if (!self.UI.inspectorView.canSelectPanel('sources')) {
+    if (!UI.InspectorView.InspectorView.instance().canSelectPanel('sources')) {
       return false;
     }
     UI.ViewManager.ViewManager.instance().showView('sources');
@@ -938,7 +938,7 @@
     } else if (position === 'bottom') {
       vertically = true;
     } else {
-      vertically = self.UI.inspectorView.element.offsetWidth < 680;
+      vertically = UI.InspectorView.InspectorView.instance().element.offsetWidth < 680;
     }
 
     if (this.sidebarPaneView && vertically === !this._splitWidget.isVertical()) {
@@ -1262,7 +1262,7 @@
     if (!SourcesPanel.instance().isShowing()) {
       this._showViewInWrapper();
     } else {
-      self.UI.inspectorView.setDrawerMinimized(true);
+      UI.InspectorView.InspectorView.instance().setDrawerMinimized(true);
     }
     SourcesPanel.updateResizerAndSidebarButtons(SourcesPanel.instance());
   }
@@ -1271,7 +1271,7 @@
    * @override
    */
   willHide() {
-    self.UI.inspectorView.setDrawerMinimized(false);
+    UI.InspectorView.InspectorView.instance().setDrawerMinimized(false);
     setImmediate(() => SourcesPanel.updateResizerAndSidebarButtons(SourcesPanel.instance()));
   }
 
diff --git a/front_end/ui/Dialog.js b/front_end/ui/Dialog.js
index de61eb6..4d77cbb 100644
--- a/front_end/ui/Dialog.js
+++ b/front_end/ui/Dialog.js
@@ -33,6 +33,7 @@
 
 import * as ARIAUtils from './ARIAUtils.js';
 import {GlassPane, PointerEventsBehavior} from './GlassPane.js';
+import {InspectorView} from './InspectorView.js';
 import {KeyboardShortcut, Keys} from './KeyboardShortcut.js';
 import {SplitWidget} from './SplitWidget.js';  // eslint-disable-line no-unused-vars
 import {WidgetFocusRestorer} from './Widget.js';
@@ -75,7 +76,7 @@
    */
   show(where) {
     const document = /** @type {!Document} */ (
-        where instanceof Document ? where : (where || self.UI.inspectorView.element).ownerDocument);
+        where instanceof Document ? where : (where || InspectorView.instance().element).ownerDocument);
     this._targetDocument = document;
     this._targetDocument.addEventListener('keydown', this._targetDocumentKeyDownHandler, true);
 
@@ -133,7 +134,7 @@
 
     let exclusionSet = /** @type {?Set.<!HTMLElement>} */ (null);
     if (this._tabIndexBehavior === OutsideTabIndexBehavior.PreserveMainViewTabIndex) {
-      exclusionSet = this._getMainWidgetTabIndexElements(self.UI.inspectorView.ownerSplit());
+      exclusionSet = this._getMainWidgetTabIndexElements(InspectorView.instance().ownerSplit());
     }
 
     this._tabIndexMap.clear();
diff --git a/front_end/ui/InspectorView.js b/front_end/ui/InspectorView.js
index 7236c66..9237b3e 100644
--- a/front_end/ui/InspectorView.js
+++ b/front_end/ui/InspectorView.js
@@ -454,19 +454,19 @@
   handleAction(context, actionId) {
     switch (actionId) {
       case 'main.toggle-drawer':
-        if (self.UI.inspectorView.drawerVisible()) {
-          self.UI.inspectorView._closeDrawer();
+        if (InspectorView.instance().drawerVisible()) {
+          InspectorView.instance()._closeDrawer();
         } else {
-          self.UI.inspectorView._showDrawer(true);
+          InspectorView.instance()._showDrawer(true);
         }
         return true;
       case 'main.next-tab':
-        self.UI.inspectorView._tabbedPane.selectNextTab();
-        self.UI.inspectorView._tabbedPane.focus();
+        InspectorView.instance()._tabbedPane.selectNextTab();
+        InspectorView.instance()._tabbedPane.focus();
         return true;
       case 'main.previous-tab':
-        self.UI.inspectorView._tabbedPane.selectPrevTab();
-        self.UI.inspectorView._tabbedPane.focus();
+        InspectorView.instance()._tabbedPane.selectPrevTab();
+        InspectorView.instance()._tabbedPane.focus();
         return true;
     }
     return false;
diff --git a/front_end/ui/SearchableView.js b/front_end/ui/SearchableView.js
index 8997348..a7142df 100644
--- a/front_end/ui/SearchableView.js
+++ b/front_end/ui/SearchableView.js
@@ -35,6 +35,7 @@
 import * as Common from '../common/common.js';
 
 import {HistoryInput} from './HistoryInput.js';
+import {InspectorView} from './InspectorView.js';
 import {Toolbar, ToolbarButton, ToolbarToggle} from './Toolbar.js';
 import {createTextButton} from './UIUtils.js';
 import {VBox} from './Widget.js';
@@ -347,7 +348,7 @@
 
     let queryCandidate;
     if (!this._searchInputElement.hasFocus()) {
-      const selection = self.UI.inspectorView.element.window().getSelection();
+      const selection = InspectorView.instance().element.window().getSelection();
       if (selection.rangeCount) {
         queryCandidate = selection.toString().replace(/\r?\n.*/, '');
       }