Bug 1455462 - Part 3. Use zoom value when showing popup menu. r=jdescottes

The openPopupAtScreen() use the zoomed css coordinate value as position value,
devtools's caller of this function use css pixel value without zoom. So position
of popup will missaligned if zooming out/in the devtool panel.

MozReview-Commit-ID: 4vvEssO41bO

--HG--
extra : rebase_source : 6bb8d7288590f3d85bfef362ecda9fc823675d7b
This commit is contained in:
Mantaroh Yoshinaga 2018-05-11 09:08:09 +09:00
parent c91355132f
commit a32ed2ab54
5 changed files with 24 additions and 5 deletions

View File

@ -220,7 +220,7 @@ class ToolboxTabs extends Component {
let screenY = target.ownerDocument.defaultView.mozInnerScreenY;
// Display the popup below the button.
menu.popup(rect.left + screenX, rect.bottom + screenY, toolbox);
menu.popupWithZoom(rect.left + screenX, rect.bottom + screenY, toolbox);
return menu;
},
});

View File

@ -440,5 +440,5 @@ function showMeatballMenu(
const screenY = menuButton.ownerDocument.defaultView.mozInnerScreenY;
// Display the popup below the button.
menu.popup(rect.left + screenX, rect.bottom + screenY, toolbox);
menu.popupWithZoom(rect.left + screenX, rect.bottom + screenY, toolbox);
}

View File

@ -6,6 +6,7 @@
"use strict";
const Services = require("Services");
const EventEmitter = require("devtools/shared/event-emitter");
/**
@ -50,6 +51,24 @@ Menu.prototype.insert = function(pos, menuItem) {
throw Error("Not implemented");
};
/**
* Show the Menu with anchor element's coordinate.
* For example, In the case of zoom in/out the devtool panel, we should multiply
* element's position to zoom value.
* If you know the screen coodinate of display position, you should use Menu.pop().
*
* @param {int} x
* @param {int} y
* @param Toolbox toolbox
*/
Menu.prototype.popupWithZoom = function(x, y, toolbox) {
let zoom = parseFloat(Services.prefs.getCharPref("devtools.toolbox.zoomValue"));
if (!zoom || isNaN(zoom)) {
zoom = 1.0;
}
this.popup(x * zoom, y * zoom, toolbox);
};
/**
* Show the Menu at a specified location on the screen
*

View File

@ -2287,7 +2287,7 @@ Toolbox.prototype = {
let rect = target.getBoundingClientRect();
let screenX = target.ownerDocument.defaultView.mozInnerScreenX;
let screenY = target.ownerDocument.defaultView.mozInnerScreenY;
menu.popup(rect.left + screenX, rect.bottom + screenY, this);
menu.popupWithZoom(rect.left + screenX, rect.bottom + screenY, this);
return menu;
},

View File

@ -239,8 +239,8 @@ class Tabbar extends Component {
let rect = target.getBoundingClientRect();
let screenX = target.ownerDocument.defaultView.mozInnerScreenX;
let screenY = target.ownerDocument.defaultView.mozInnerScreenY;
menu.popup(rect.left + screenX, rect.bottom + screenY,
{ doc: this.props.menuDocument });
menu.popupWithZoom(rect.left + screenX, rect.bottom + screenY,
{ doc: this.props.menuDocument });
return menu;
}