Bug 1049130 - UITour: Fixing highlight placed in the wrong place at first time. r=Gijs

MozReview-Commit-ID: LVTbjeaizRD

--HG--
extra : rebase_source : 535286c1de72d42c24432b2e2073ab13dc808b87
This commit is contained in:
Rex Lee 2017-07-27 14:35:22 +08:00
parent 8145881eb8
commit 14a7e31cc1
2 changed files with 4 additions and 7 deletions

View File

@ -1140,16 +1140,11 @@ this.UITour = {
/* The "overlap" position anchors from the top-left but we want to centre highlights at their /* The "overlap" position anchors from the top-left but we want to centre highlights at their
minimum size. */ minimum size. */
let highlightWindow = aChromeWindow; 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 highlightStyle = highlightWindow.getComputedStyle(highlighter);
let highlightHeightWithMin = Math.max(highlightHeight, parseFloat(highlightStyle.minHeight)); let highlightHeightWithMin = Math.max(highlightHeight, parseFloat(highlightStyle.minHeight));
let highlightWidthWithMin = Math.max(highlightWidth, parseFloat(highlightStyle.minWidth)); let highlightWidthWithMin = Math.max(highlightWidth, parseFloat(highlightStyle.minWidth));
let offsetX = paddingTopPx let offsetX = -(Math.max(0, highlightWidthWithMin - targetRect.width) / 2);
- (Math.max(0, highlightWidthWithMin - targetRect.width) / 2); let offsetY = -(Math.max(0, highlightHeightWithMin - targetRect.height) / 2);
let offsetY = paddingLeftPx
- (Math.max(0, highlightHeightWithMin - targetRect.height) / 2);
this._addAnnotationPanelMutationObserver(highlighter.parentElement); this._addAnnotationPanelMutationObserver(highlighter.parentElement);
highlighter.parentElement.openPopup(highlightAnchor, "overlap", offsetX, offsetY); highlighter.parentElement.openPopup(highlightAnchor, "overlap", offsetX, offsetY);
} }

View File

@ -14,6 +14,8 @@
/* This is a buffer to compensate for the movement in the "wobble" effect, /* This is a buffer to compensate for the movement in the "wobble" effect,
and for the box-shadow of #UITourHighlight. */ and for the box-shadow of #UITourHighlight. */
padding: 4px; padding: 4px;
/* Compensate the displacement caused by padding. */
margin: -4px;
} }
#UITourHighlight { #UITourHighlight {