Bug 1475947 - (Part 1) implement getOwnerGlobalDimensions() on Node actor. r=gl draft
authorRazvan Caliman <rcaliman@mozilla.com>
Mon, 16 Jul 2018 19:06:06 +0200
changeset 819370 1fcb89fa634d6890f3442dab4003ffe4a86b6002
parent 818682 2ed1506d1dc7db3d70a3feed95f1456bce05bbee
child 819371 6f19b750c758a277814e149374730c39bbf396b2
push id116535
push userbmo:rcaliman@mozilla.com
push dateTue, 17 Jul 2018 18:29:14 +0000
reviewersgl
bugs1475947
milestone63.0a1
Bug 1475947 - (Part 1) implement getOwnerGlobalDimensions() on Node actor. r=gl MozReview-Commit-ID: Ij59UBVlCBD
devtools/server/actors/inspector/node.js
devtools/shared/specs/node.js
--- 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;