Bug 1345119 - Part 2: Server side for retrieving offset parent of DOM node. r=pbro
authorStanford Lockhart <lockhart@cs.dal.ca>
Fri, 17 Mar 2017 23:05:27 -0300
changeset 349663 03e81669e18c
parent 349662 e84425b5ccef
child 349664 130016ad0425
push id31556
push userphilringnalda@gmail.com
push dateSun, 26 Mar 2017 01:40:08 +0000
treeherdermozilla-central@f5e214144799 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1345119
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1345119 - Part 2: Server side for retrieving offset parent of DOM node. r=pbro MozReview-Commit-ID: I51NHlxv6Mp
devtools/server/actors/inspector.js
devtools/shared/specs/inspector.js
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -2642,16 +2642,32 @@ var WalkerActor = protocol.ActorClassWit
    */
   getLayoutInspector: function () {
     if (!this.layoutActor) {
       this.layoutActor = new LayoutActor(this.conn, this.tabActor, this);
     }
 
     return this.layoutActor;
   },
+
+  /**
+   * Get the offset parent of the node
+   * If the offset parent is statically positioned, there is no offset parent
+   * and null is returned.
+   * Returns the DOMNode for the offset parent if it exists
+   */
+  getOffsetParent: function (domnode) {
+    let offsetParent = domnode.rawNode.offsetParent;
+
+    if (!offsetParent || CssLogic.getComputedStyle(offsetParent).position === "static") {
+      return null;
+    }
+
+    return this._ref(offsetParent);
+  },
 });
 
 /**
  * Server side of the inspector actor, which is used to create
  * inspector-related actors, including the walker.
  */
 exports.InspectorActor = protocol.ActorClassWithSpec(inspectorSpec, {
   initialize: function (conn, tabActor) {
--- a/devtools/shared/specs/inspector.js
+++ b/devtools/shared/specs/inspector.js
@@ -369,17 +369,25 @@ const walkerSpec = generateActorSpec({
         node: RetVal("nullable:disconnectedNode")
       }
     },
     getLayoutInspector: {
       request: {},
       response: {
         actor: RetVal("layout")
       }
-    }
+    },
+    getOffsetParent: {
+      request: {
+        node: Arg(0, "domnode")
+      },
+      response: {
+        node: RetVal("nullable:domnode")
+      }
+    },
   }
 });
 
 exports.walkerSpec = walkerSpec;
 
 const inspectorSpec = generateActorSpec({
   typeName: "inspector",