diff --git a/devtools/server/actors/inspector.js b/devtools/server/actors/inspector.js index f1aa00513e0a..c9b05920ead0 100644 --- a/devtools/server/actors/inspector.js +++ b/devtools/server/actors/inspector.js @@ -2647,6 +2647,22 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { 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); + }, }); /** diff --git a/devtools/shared/specs/inspector.js b/devtools/shared/specs/inspector.js index 5a087379530e..0cc6d86bb1d1 100644 --- a/devtools/shared/specs/inspector.js +++ b/devtools/shared/specs/inspector.js @@ -374,7 +374,15 @@ const walkerSpec = generateActorSpec({ response: { actor: RetVal("layout") } - } + }, + getOffsetParent: { + request: { + node: Arg(0, "domnode") + }, + response: { + node: RetVal("nullable:domnode") + } + }, } });