Bug 1566422 - Avoid unnecessary coordinate conversions when showing tooltips, r=emilio

We currently start with screen-relative coordinates, translate them to
widget-relative coordinates, and then translate them back to screen-relative
coordinates when actually showing the tooltip in XULBrowserWindow.showTooltip().
There's no reason for the extra conversions, so we can just send screen-relative
coordinates directly.

Since the widget origin for out-of-process frames is the origin of the frame
itself (instead of the tab, which is the case for in-process frames), the
screen-to-widget conversion was incorrect, and was causing a bug in how the
tooltip was being positioned. Avoiding that conversion altogether also fixes
that bug.

Differential Revision: https://phabricator.services.mozilla.com/D86750
This commit is contained in:
Kashav Madan
2020-08-11 22:01:40 +00:00
parent 460ad5f201
commit a8bf21e011
2 changed files with 4 additions and 31 deletions

View File

@@ -1287,17 +1287,9 @@ void ChromeTooltipListener::sTooltipCallback(nsITimer* aTimer,
if (textFound && (!self->mTooltipShownOnce ||
tooltipText != self->mLastShownTooltipText)) {
LayoutDeviceIntPoint screenDot = widget->WidgetToScreenOffset();
double scaleFactor = 1.0;
if (presShell->GetPresContext()) {
nsDeviceContext* dc = presShell->GetPresContext()->DeviceContext();
scaleFactor = double(AppUnitsPerCSSPixel()) /
dc->AppUnitsPerDevPixelAtUnitFullZoom();
}
// ShowTooltip expects widget-relative position.
self->ShowTooltip(self->mMouseScreenX - screenDot.x / scaleFactor,
self->mMouseScreenY - screenDot.y / scaleFactor,
tooltipText, directionText);
// ShowTooltip expects screen-relative position.
self->ShowTooltip(self->mMouseScreenX, self->mMouseScreenY, tooltipText,
directionText);
self->mLastShownTooltipText = std::move(tooltipText);
self->mLastDocshell = do_GetWeakReference(
self->mPossibleTooltipNode->OwnerDoc()->GetDocShell());