mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-05 00:02:37 +00:00
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:
parent
c91355132f
commit
a32ed2ab54
@ -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;
|
||||
},
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
},
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user