[global] Remaps self.UI.zoomManager

Moves self.UI.zoomManager to an instance() method.

Bug: 1058320
Change-Id: Idff38a3ffbad33465822f9a350ce17f3387ed235
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2107621
Reviewed-by: Tim van der Lippe <[email protected]>
Commit-Queue: Paul Lewis <[email protected]>
diff --git a/front_end/ui/SplitWidget.js b/front_end/ui/SplitWidget.js
index 0356973..8e5340a 100644
--- a/front_end/ui/SplitWidget.js
+++ b/front_end/ui/SplitWidget.js
@@ -35,7 +35,7 @@
 import {Events as ResizerWidgetEvents, SimpleResizerWidget} from './ResizerWidget.js';
 import {ToolbarButton} from './Toolbar.js';
 import {Widget} from './Widget.js';
-import {Events as ZoomManagerEvents} from './ZoomManager.js';
+import {Events as ZoomManagerEvents, ZoomManager} from './ZoomManager.js';
 
 /**
  * @unrestricted
@@ -455,7 +455,7 @@
    * @param {number} size
    */
   setSidebarSize(size) {
-    const sizeDIP = self.UI.zoomManager.cssToDIP(size);
+    const sizeDIP = ZoomManager.instance().cssToDIP(size);
     this._savedSidebarSizeDIP = sizeDIP;
     this._saveSetting();
     this._innerSetSidebarSizeDIP(sizeDIP, false, true);
@@ -466,7 +466,7 @@
    */
   sidebarSize() {
     const sizeDIP = Math.max(0, this._sidebarSizeDIP);
-    return self.UI.zoomManager.dipToCSS(sizeDIP);
+    return ZoomManager.instance().dipToCSS(sizeDIP);
   }
 
   /**
@@ -479,7 +479,7 @@
       this._totalSizeOtherDimensionCSS =
           this._isVertical ? this.contentElement.offsetHeight : this.contentElement.offsetWidth;
     }
-    return self.UI.zoomManager.cssToDIP(this._totalSizeCSS);
+    return ZoomManager.instance().cssToDIP(this._totalSizeCSS);
   }
 
   /**
@@ -518,7 +518,7 @@
     this._removeAllLayoutProperties();
 
     // this._totalSizeDIP is available below since we successfully applied constraints.
-    const roundSizeCSS = Math.round(self.UI.zoomManager.dipToCSS(sizeDIP));
+    const roundSizeCSS = Math.round(ZoomManager.instance().dipToCSS(sizeDIP));
     const sidebarSizeValue = roundSizeCSS + 'px';
     const mainSizeValue = (this._totalSizeCSS - roundSizeCSS) + 'px';
     this._sidebarElement.style.flexBasis = sidebarSizeValue;
@@ -583,8 +583,8 @@
       animatedMarginPropertyName = this._secondIsSidebar ? 'margin-bottom' : 'margin-top';
     }
 
-    const marginFrom = reverse ? '0' : '-' + self.UI.zoomManager.dipToCSS(this._sidebarSizeDIP) + 'px';
-    const marginTo = reverse ? '-' + self.UI.zoomManager.dipToCSS(this._sidebarSizeDIP) + 'px' : '0';
+    const marginFrom = reverse ? '0' : '-' + ZoomManager.instance().dipToCSS(this._sidebarSizeDIP) + 'px';
+    const marginTo = reverse ? '-' + ZoomManager.instance().dipToCSS(this._sidebarSizeDIP) + 'px' : '0';
 
     // This order of things is important.
     // 1. Resize main element early and force layout.
@@ -657,7 +657,7 @@
    */
   _applyConstraints(sidebarSize, userAction) {
     const totalSize = this._totalSizeDIP();
-    const zoomFactor = this._constraintsInDip ? 1 : self.UI.zoomManager.zoomFactor();
+    const zoomFactor = this._constraintsInDip ? 1 : ZoomManager.instance().zoomFactor();
 
     let constraints = this._sidebarWidget ? this._sidebarWidget.constraints() : new Constraints();
     let minSidebarSize = this.isVertical() ? constraints.minimum.width : constraints.minimum.height;
@@ -723,14 +723,14 @@
    */
   wasShown() {
     this._forceUpdateLayout();
-    self.UI.zoomManager.addEventListener(ZoomManagerEvents.ZoomChanged, this._onZoomChanged, this);
+    ZoomManager.instance().addEventListener(ZoomManagerEvents.ZoomChanged, this._onZoomChanged, this);
   }
 
   /**
    * @override
    */
   willHide() {
-    self.UI.zoomManager.removeEventListener(ZoomManagerEvents.ZoomChanged, this._onZoomChanged, this);
+    ZoomManager.instance().removeEventListener(ZoomManagerEvents.ZoomChanged, this._onZoomChanged, this);
   }
 
   /**
@@ -784,7 +784,7 @@
    */
   _onResizeUpdate(event) {
     const offset = event.data.currentPosition - event.data.startPosition;
-    const offsetDIP = self.UI.zoomManager.cssToDIP(offset);
+    const offsetDIP = ZoomManager.instance().cssToDIP(offset);
     const newSizeDIP =
         this._secondIsSidebar ? this._resizeStartSizeDIP - offsetDIP : this._resizeStartSizeDIP + offsetDIP;
     const constrainedSizeDIP = this._applyConstraints(newSizeDIP, true);