Bug 1468953: Use node bounds in viewport instead of offsets from offsetParent. r?jdescottes draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Tue, 26 Jun 2018 10:51:40 +0900
changeset 810526 da3e8ec03d633301d64861fba095fb89a1b1db4d
parent 810379 6e8e861540e6d8c85c73ab7b2afa1f027fb3750c
child 810529 ace6a059941b93ef35a15ae2fcccbb0a84abb341
push id114018
push userbmo:dakatsuka@mozilla.com
push dateTue, 26 Jun 2018 01:54:42 +0000
reviewersjdescottes
bugs1468953
milestone63.0a1
Bug 1468953: Use node bounds in viewport instead of offsets from offsetParent. r?jdescottes MozReview-Commit-ID: nqMLetevCZ
devtools/client/shared/components/splitter/SplitBox.js
--- a/devtools/client/shared/components/splitter/SplitBox.js
+++ b/devtools/client/shared/components/splitter/SplitBox.js
@@ -161,42 +161,43 @@ class SplitBox extends Component {
 
   /**
    * Adjust size of the controlled panel. Depending on the current
    * orientation we either remember the width or height of
    * the splitter box.
    */
   onMove(x, y) {
     const node = ReactDOM.findDOMNode(this);
+    const nodeBounds = node.getBoundingClientRect();
 
     let size;
     let { endPanelControl, vert } = this.state;
 
     if (vert) {
       // Use the document owning the SplitBox to detect rtl. The global document might be
       // the one bound to the toolbox shared BrowserRequire, which is irrelevant here.
       const doc = node.ownerDocument;
 
       // Switch the control flag in case of RTL. Note that RTL
       // has impact on vertical splitter only.
       if (doc.dir === "rtl") {
         endPanelControl = !endPanelControl;
       }
 
       size = endPanelControl ?
-        (node.offsetLeft + node.offsetWidth) - x :
-        x - node.offsetLeft;
+        (nodeBounds.left + nodeBounds.width) - x :
+        x - nodeBounds.left;
 
       this.setState({
         width: size
       });
     } else {
       size = endPanelControl ?
-        (node.offsetTop + node.offsetHeight) - y :
-        y - node.offsetTop;
+        (nodeBounds.top + nodeBounds.height) - y :
+        y - nodeBounds.top;
 
       this.setState({
         height: size
       });
     }
   }
 
   // Rendering