Bug 1447043 - Calculate top and left selection margin using left and top; r=_6a68 draft
authorBarry Chen <chenba@gmail.com>
Mon, 19 Mar 2018 09:31:57 -0700
changeset 769475 321221141e95ed5d070c6c7849fafb57ab7f0a3c
parent 769320 4f1014eb5039bdfdd7a39fb7785d102df1994a6f
child 769476 d497ef63a71696f6485a02551f0ff89768c4e58f
child 769477 621655cff6a5c3a555d0e47d51a376adb8607b73
push id103141
push userbmo:jhirsch@mozilla.com
push dateMon, 19 Mar 2018 17:32:58 +0000
reviewers_6a68
bugs1447043
milestone61.0a1
Bug 1447043 - Calculate top and left selection margin using left and top; r=_6a68 MozReview-Commit-ID: 88TM8xgATPC
browser/extensions/screenshots/webextension/selector/ui.js
--- a/browser/extensions/screenshots/webextension/selector/ui.js
+++ b/browser/extensions/screenshots/webextension/selector/ui.js
@@ -212,18 +212,18 @@ this.ui = (function() { // eslint-disabl
         // Since this frame has an absolute position relative to the parent
         // document, if the parent document's body has a relative position and
         // left and/or top not at 0, then the left and/or top of the parent
         // document's body is not at (0, 0) of the viewport. That makes the
         // frame shifted relative to the viewport. These margins negates that.
         if (window.getComputedStyle(document.body).position === "relative") {
           const docBoundingRect = document.documentElement.getBoundingClientRect();
           const bodyBoundingRect = document.body.getBoundingClientRect();
-          this.element.style.marginLeft = `-${bodyBoundingRect.right - docBoundingRect.right}px`;
-          this.element.style.marginTop = `-${bodyBoundingRect.bottom - docBoundingRect.bottom}px`;
+          this.element.style.marginLeft = `-${bodyBoundingRect.left - docBoundingRect.left}px`;
+          this.element.style.marginTop = `-${bodyBoundingRect.top - docBoundingRect.top}px`;
         }
       }
       if (force && visible) {
         this.element.style.display = "";
       }
     },
 
     initSizeWatch() {