Bug 1049130 - UITour: Fixing highlight placed in the wrong place at first time. r=gijs
MozReview-Commit-ID: LVTbjeaizRD
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -1135,26 +1135,21 @@ this.UITour = {
// Close a previous highlight so we can relocate the panel.
if (highlighter.parentElement.state == "showing" || highlighter.parentElement.state == "open") {
log.debug("showHighlight: Closing previous highlight first");
highlighter.parentElement.hidePopup();
}
/* The "overlap" position anchors from the top-left but we want to centre highlights at their
minimum size. */
let highlightWindow = aChromeWindow;
- let containerStyle = highlightWindow.getComputedStyle(highlighter.parentElement);
- let paddingTopPx = 0 - parseFloat(containerStyle.paddingTop);
- let paddingLeftPx = 0 - parseFloat(containerStyle.paddingLeft);
let highlightStyle = highlightWindow.getComputedStyle(highlighter);
let highlightHeightWithMin = Math.max(highlightHeight, parseFloat(highlightStyle.minHeight));
let highlightWidthWithMin = Math.max(highlightWidth, parseFloat(highlightStyle.minWidth));
- let offsetX = paddingTopPx
- - (Math.max(0, highlightWidthWithMin - targetRect.width) / 2);
- let offsetY = paddingLeftPx
- - (Math.max(0, highlightHeightWithMin - targetRect.height) / 2);
+ let offsetX = -(Math.max(0, highlightWidthWithMin - targetRect.width) / 2);
+ let offsetY = -(Math.max(0, highlightHeightWithMin - targetRect.height) / 2);
this._addAnnotationPanelMutationObserver(highlighter.parentElement);
highlighter.parentElement.openPopup(highlightAnchor, "overlap", offsetX, offsetY);
}
// Prevent showing a panel at an undefined position.
if (!this.isElementVisible(aTarget.node)) {
log.warn("showHighlight: Not showing a highlight since the target isn't visible", aTarget);
return;
--- a/browser/themes/shared/UITour.inc.css
+++ b/browser/themes/shared/UITour.inc.css
@@ -9,16 +9,18 @@
#UITourHighlightContainer {
-moz-appearance: none;
-moz-window-shadow: none;
border: none;
background-color: transparent;
/* This is a buffer to compensate for the movement in the "wobble" effect,
and for the box-shadow of #UITourHighlight. */
padding: 4px;
+ /* Compensate the displacement caused by padding. */
+ margin: -4px;
}
#UITourHighlight {
background-image: radial-gradient(50% 100%, rgba(0,149,220,0.4) 50%, rgba(0,149,220,0.6) 100%);
border-radius: 40px;
border: 1px solid white;
/* The box-shadow opacity needs to be < 0.5 so it doesn't appear at 100% opacity
on Linux without an X compositor where opacity is either 0 or 1. */