Bug 1559257 - Removing getSameTypeRootTreeItemIgnoreBrowserBoundaries and getSameTypeParentIgnoreBrowserBoundaries usage; r=ochameau
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 18 Jun 2019 15:59:29 +0000
changeset 479148 bf1bc7abe7b6dd4a0539f494daafaf9434c03b84
parent 479147 d4cb35f250617dfb8e018f77e4bc533426a09515
child 479149 060c1b2671ff179002285a53d437ea1bb546d11a
push id36170
push usercbrindusan@mozilla.com
push dateWed, 19 Jun 2019 03:56:45 +0000
treeherdermozilla-central@5f0f37756053 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1559257
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1559257 - Removing getSameTypeRootTreeItemIgnoreBrowserBoundaries and getSameTypeParentIgnoreBrowserBoundaries usage; r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D34940
devtools/shared/layout/utils.js
--- a/devtools/shared/layout/utils.js
+++ b/devtools/shared/layout/utils.js
@@ -32,98 +32,48 @@ function utilsFor(win) {
   // this weakmap cache path any faster than just calling the getter?
   if (!utilsCache.has(win)) {
     utilsCache.set(win, win.windowUtils);
   }
   return utilsCache.get(win);
 }
 
 /**
- * like win.top, but goes through mozbrowsers and mozapps iframes.
- *
- * @param {DOMWindow} win
- * @return {DOMWindow}
- */
-function getTopWindow(win) {
-  const docShell = win.docShell;
-
-  if (!docShell.isMozBrowser) {
-    return win.top;
-  }
-
-  const topDocShell =
-    docShell.getSameTypeRootTreeItemIgnoreBrowserBoundaries();
-
-  return topDocShell
-          ? topDocShell.contentViewer.DOMDocument.defaultView
-          : null;
-}
-
-exports.getTopWindow = getTopWindow;
-
-/**
  * Returns `true` is the window given is a top level window.
  * like win.top === win, but goes through mozbrowsers and mozapps iframes.
  *
  * @param {DOMWindow} win
  * @return {Boolean}
  */
-const isTopWindow = win => win && getTopWindow(win) === win;
+const isTopWindow = win => win && win.top === win;
 exports.isTopWindow = isTopWindow;
 
 /**
    * Check a window is part of the boundary window given.
    *
    * @param {DOMWindow} boundaryWindow
    * @param {DOMWindow} win
    * @return {Boolean}
    */
 function isWindowIncluded(boundaryWindow, win) {
   if (win === boundaryWindow) {
     return true;
   }
 
-  const parent = getParentWindow(win);
+  const parent = win.parent;
 
   if (!parent || parent === win) {
     return false;
   }
 
   return isWindowIncluded(boundaryWindow, parent);
 }
 exports.isWindowIncluded = isWindowIncluded;
 
 /**
- * like win.parent, but goes through mozbrowsers and mozapps iframes.
- *
- * @param {DOMWindow} win
- * @return {DOMWindow}
- */
-function getParentWindow(win) {
-  if (isTopWindow(win)) {
-    return null;
-  }
-
-  const docShell = win.docShell;
-
-  if (!docShell.isMozBrowser) {
-    return win.parent;
-  }
-
-  const parentDocShell =
-    docShell.getSameTypeParentIgnoreBrowserBoundaries();
-
-  return parentDocShell
-          ? parentDocShell.contentViewer.DOMDocument.defaultView
-          : null;
-}
-
-exports.getParentWindow = getParentWindow;
-
-/**
  * like win.frameElement, but goes through mozbrowsers and mozapps iframes.
  *
  * @param {DOMWindow} win
  *        The window to get the frame for
  * @return {DOMNode}
  *         The element in which the window is embedded.
  */
 const getFrameElement = (win) =>
@@ -145,17 +95,17 @@ exports.getFrameElement = getFrameElemen
 function getFrameOffsets(boundaryWindow, node) {
   let xOffset = 0;
   let yOffset = 0;
 
   let frameWin = getWindowFor(node);
   const scale = getCurrentZoom(node);
 
   if (boundaryWindow === null) {
-    boundaryWindow = getTopWindow(frameWin);
+    boundaryWindow = frameWin.top;
   } else if (typeof boundaryWindow === "undefined") {
     throw new Error("No boundaryWindow given. Use null for the default one.");
   }
 
   while (frameWin !== boundaryWindow) {
     const frameElement = getFrameElement(frameWin);
     if (!frameElement) {
       break;
@@ -166,17 +116,17 @@ function getFrameOffsets(boundaryWindow,
     // offset (borders and padding).
     const frameRect = frameElement.getBoundingClientRect();
 
     const [offsetTop, offsetLeft] = getFrameContentOffset(frameElement);
 
     xOffset += frameRect.left + offsetLeft;
     yOffset += frameRect.top + offsetTop;
 
-    frameWin = getParentWindow(frameWin);
+    frameWin = frameWin.parent;
   }
 
   return [xOffset * scale, yOffset * scale];
 }
 exports.getFrameOffsets = getFrameOffsets;
 
 /**
  * Get box quads adjusted for iframes and zoom level.
@@ -280,17 +230,17 @@ exports.getAdjustedQuads = getAdjustedQu
  * @return {Object}
  *         A rect object with the {top, left, width, height} properties
  */
 function getRect(boundaryWindow, node, contentWindow) {
   let frameWin = node.ownerDocument.defaultView;
   const clientRect = node.getBoundingClientRect();
 
   if (boundaryWindow === null) {
-    boundaryWindow = getTopWindow(frameWin);
+    boundaryWindow = frameWin.top;
   } else if (typeof boundaryWindow === "undefined") {
     throw new Error("No boundaryWindow given. Use null for the default one.");
   }
 
   // Go up in the tree of frames to determine the correct rectangle.
   // clientRect is read-only, we need to be able to change properties.
   const rect = {
     top: clientRect.top + contentWindow.pageYOffset,
@@ -311,17 +261,17 @@ function getRect(boundaryWindow, node, c
     // offset (borders and padding).
     const frameRect = frameElement.getBoundingClientRect();
 
     const [offsetTop, offsetLeft] = getFrameContentOffset(frameElement);
 
     rect.top += frameRect.top + offsetTop;
     rect.left += frameRect.left + offsetLeft;
 
-    frameWin = getParentWindow(frameWin);
+    frameWin = frameWin.parent;
   }
 
   return rect;
 }
 exports.getRect = getRect;
 
 /**
  * Get the 4 bounding points for a node taking iframes into account.