Bug 1475947 - (Part 1) implement getOwnerGlobalDimensions() on Node actor. r=gl
MozReview-Commit-ID: Ij59UBVlCBD
--- a/devtools/server/actors/inspector/node.js
+++ b/devtools/server/actors/inspector/node.js
@@ -667,16 +667,29 @@ const NodeActor = protocol.ActorClassWit
const currentCssColor = new colorUtils.CssColor(currentStyle);
if (!currentCssColor.isTransparent()) {
return currentCssColor.rgba;
}
}
current = current.parentNode;
}
return "rgba(255, 255, 255, 1)";
+ },
+
+ /**
+ * Returns an object with the width and height of the node's owner window.
+ *
+ * @return {Object}
+ */
+ getOwnerGlobalDimensions: function() {
+ const win = this.rawNode.ownerGlobal;
+ return {
+ innerWidth: win.innerWidth,
+ innerHeight: win.innerHeight,
+ };
}
});
/**
* Server side of a node list as returned by querySelectorAll()
*/
const NodeListActor = protocol.ActorClassWithSpec(nodeListSpec, {
typeName: "domnodelist",
--- a/devtools/shared/specs/node.js
+++ b/devtools/shared/specs/node.js
@@ -12,16 +12,23 @@ const {
types.addDictType("imageData", {
// The image data
data: "nullable:longstring",
// The original image dimensions
size: "json"
});
+types.addDictType("windowDimensions", {
+ // The window innerWidth
+ innerWidth: "nullable:number",
+ // The window innerHeight
+ innerHeight: "nullable:number",
+});
+
/**
* Returned from any call that might return a node that isn't connected to root
* by nodes the child has seen, such as querySelector.
*/
types.addDictType("disconnectedNode", {
// The actual node to return
node: "domnode",
@@ -118,12 +125,16 @@ const nodeSpec = generateActorSpec({
response: RetVal("imageData")
},
getClosestBackgroundColor: {
request: {},
response: {
value: RetVal("string")
}
},
+ getOwnerGlobalDimensions: {
+ request: {},
+ response: RetVal("windowDimensions")
+ }
}
});
exports.nodeSpec = nodeSpec;