Bug 1049130 - UITour: Fixing highlight placed in the wrong place at first time. r=gijs draft
authorRex Lee <rexboy@mozilla.com>
Thu, 27 Jul 2017 14:35:22 +0800
changeset 617178 9f8c8596afc8ec9d9a778190f95ea5602b9a2e2a
parent 614807 f6528783c52507e29d5be409cc8fbf9a394a5ac8
child 639732 c732cb7cb3eeee4751a55bb4a61451011bf4d193
push id70965
push userbmo:rexboy@mozilla.com
push dateFri, 28 Jul 2017 03:14:50 +0000
reviewersgijs
bugs1049130
milestone56.0a1
Bug 1049130 - UITour: Fixing highlight placed in the wrong place at first time. r=gijs MozReview-Commit-ID: LVTbjeaizRD
browser/components/uitour/UITour.jsm
browser/themes/shared/UITour.inc.css
--- 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. */