Commit 1a7b1e1c authored by Julian Descottes's avatar Julian Descottes
Browse files

Bug 1543940 - Apply devtools framework menu changes to Debugger menu; r=jlast

Depends on D29887

Differential Revision: https://phabricator.services.mozilla.com/D28033

--HG--
extra : moz-landing-system : lando
parent 49b74c05
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -15,7 +15,7 @@
        "byName": {},
        "byName": {},
        "byBlocks": {},
        "byBlocks": {},
        "usedIds": {
        "usedIds": {
          "0": 0
          "1": 1
        }
        }
      }
      }
    }
    }
@@ -36,7 +36,7 @@
        "byName": {},
        "byName": {},
        "byBlocks": {},
        "byBlocks": {},
        "usedIds": {
        "usedIds": {
          "0": 0
          "1": 1
        }
        }
      }
      }
    }
    }
@@ -57,7 +57,7 @@
        "byName": {},
        "byName": {},
        "byBlocks": {},
        "byBlocks": {},
        "usedIds": {
        "usedIds": {
          "0": 0
          "1": 1
        }
        }
      }
      }
    }
    }
@@ -78,7 +78,7 @@
        "byName": {},
        "byName": {},
        "byBlocks": {},
        "byBlocks": {},
        "usedIds": {
        "usedIds": {
          "0": 0
          "1": 1
        }
        }
      }
      }
    }
    }
@@ -99,7 +99,7 @@
        "byName": {},
        "byName": {},
        "byBlocks": {},
        "byBlocks": {},
        "usedIds": {
        "usedIds": {
          "0": 0
          "1": 1
        }
        }
      }
      }
    }
    }
@@ -120,7 +120,7 @@
        "byName": {},
        "byName": {},
        "byBlocks": {},
        "byBlocks": {},
        "usedIds": {
        "usedIds": {
          "0": 0
          "1": 1
        }
        }
      }
      }
    }
    }
@@ -141,7 +141,7 @@
        "byName": {},
        "byName": {},
        "byBlocks": {},
        "byBlocks": {},
        "usedIds": {
        "usedIds": {
          "0": 0
          "1": 1
        }
        }
      }
      }
    }
    }
+22 −6
Original line number Original line Diff line number Diff line
@@ -2610,12 +2610,12 @@ function showMenu(evt, items) {
  });
  });


  if (inToolbox()) {
  if (inToolbox()) {
    menu.popup(evt.screenX, evt.screenY, { doc: window.parent.document });
    menu.popup(evt.screenX, evt.screenY, window.parent.document);
    return;
    return;
  }
  }


  menu.on("open", (_, popup) => onShown(menu, popup));
  menu.on("open", (_, popup) => onShown(menu, popup));
  menu.popup(evt.clientX, evt.clientY, { doc: document });
  menu.popup(evt.clientX, evt.clientY, document);
}
}


function createSubMenu(subItems) {
function createSubMenu(subItems) {
@@ -2712,6 +2712,11 @@ function inToolbox() {
  }
  }
}
}


// Copied from m-c DevToolsUtils.
function getTopWindow(win) {
  return win.windowRoot ? win.windowRoot.ownerGlobal : win.top;
}

/**
/**
 * A partial implementation of the Menu API provided by electron:
 * A partial implementation of the Menu API provided by electron:
 * https://github.com/electron/electron/blob/master/docs/api/menu.md.
 * https://github.com/electron/electron/blob/master/docs/api/menu.md.
@@ -2763,11 +2768,16 @@ Menu.prototype.insert = function (pos, menuItem) {
 *
 *
 * @param {int} screenX
 * @param {int} screenX
 * @param {int} screenY
 * @param {int} screenY
 * @param Toolbox toolbox (non standard)
 * @param {Document} doc
 *        Needed so we in which window to inject XUL
 *        The document that should own the context menu.
 */
 */
Menu.prototype.popup = function (screenX, screenY, toolbox) {
Menu.prototype.popup = function (screenX, screenY, doc) {
  let doc = toolbox.doc;
  // The context-menu will be created in the topmost window to preserve keyboard
  // navigation. See Bug 1543940. Keep a reference on the window owning the menu to hide
  // the popup on unload.
  const win = doc.defaultView;
  doc = getTopWindow(doc.defaultView).document;

  let popupset = doc.querySelector("popupset");
  let popupset = doc.querySelector("popupset");
  if (!popupset) {
  if (!popupset) {
    popupset = doc.createXULElement("popupset");
    popupset = doc.createXULElement("popupset");
@@ -2790,9 +2800,15 @@ Menu.prototype.popup = function (screenX, screenY, toolbox) {
  }
  }
  this._createMenuItems(popup);
  this._createMenuItems(popup);


  // The context menu will be created in the topmost chrome window. Hide it manually when
  // the owner document is unloaded.
  const onWindowUnload = () => popup.hidePopup();
  win.addEventListener("unload", onWindowUnload);

  // Remove the menu from the DOM once it's hidden.
  // Remove the menu from the DOM once it's hidden.
  popup.addEventListener("popuphidden", e => {
  popup.addEventListener("popuphidden", e => {
    if (e.target === popup) {
    if (e.target === popup) {
      win.removeEventListener("unload", onWindowUnload);
      popup.remove();
      popup.remove();
      this.emit("close", popup);
      this.emit("close", popup);
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@
    "babel-plugin-transform-imports": "^1.5.0",
    "babel-plugin-transform-imports": "^1.5.0",
    "codemirror": "^5.28.0",
    "codemirror": "^5.28.0",
    "devtools-environment": "^0.0.6",
    "devtools-environment": "^0.0.6",
    "devtools-launchpad": "^0.0.151",
    "devtools-launchpad": "^0.0.152",
    "devtools-linters": "^0.0.4",
    "devtools-linters": "^0.0.4",
    "devtools-reps": "0.23.0",
    "devtools-reps": "0.23.0",
    "devtools-source-map": "0.16.0",
    "devtools-source-map": "0.16.0",
+1 −1
Original line number Original line Diff line number Diff line
@@ -38,7 +38,7 @@
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "devtools-config": "^0.0.16",
    "devtools-config": "^0.0.16",
    "devtools-launchpad": "^0.0.150",
    "devtools-launchpad": "^0.0.152",
    "devtools-license-check": "^0.7.0",
    "devtools-license-check": "^0.7.0",
    "devtools-modules": "~1.1.0",
    "devtools-modules": "~1.1.0",
    "devtools-services": "^0.0.1",
    "devtools-services": "^0.0.1",
+2 −2
Original line number Original line Diff line number Diff line
@@ -1380,13 +1380,13 @@ async function clickGutter(dbg, line) {


function selectContextMenuItem(dbg, selector) {
function selectContextMenuItem(dbg, selector) {
  // the context menu is in the toolbox window
  // the context menu is in the toolbox window
  const doc = dbg.toolbox.win.document;
  const doc = dbg.toolbox.topDoc;


  // there are several context menus, we want the one with the menu-api
  // there are several context menus, we want the one with the menu-api
  const popup = doc.querySelector('menupopup[menu-api="true"]');
  const popup = doc.querySelector('menupopup[menu-api="true"]');


  const item = popup.querySelector(selector);
  const item = popup.querySelector(selector);
  return EventUtils.synthesizeMouseAtCenter(item, {}, dbg.toolbox.win);
  return EventUtils.synthesizeMouseAtCenter(item, {}, dbg.toolbox.topWindow);
}
}


async function typeInPanel(dbg, text) {
async function typeInPanel(dbg, text) {
Loading