Bug 970625 - Add dpi-option to screenshot command. r=jryans
authorJohan K. Jensen <jj@johanjensen.dk>
Thu, 27 Aug 2015 04:17:00 -0400
changeset 260038 bfc9825d4ac7a37755f65a422f323f2574c31583
parent 260037 1d2f59732f03e6538e56e8e65242c4a5b83ac4db
child 260039 130e4fd8fc76f62b8f2db58e3513ac4fafdfcb27
push id29298
push userryanvm@gmail.com
push dateMon, 31 Aug 2015 02:09:10 +0000
treeherdermozilla-central@f2518b8a7b97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs970625
milestone43.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 970625 - Add dpi-option to screenshot command. r=jryans
toolkit/devtools/gcli/commands/screenshot.js
toolkit/locales/en-US/chrome/global/devtools/gclicommands.properties
--- a/toolkit/devtools/gcli/commands/screenshot.js
+++ b/toolkit/devtools/gcli/commands/screenshot.js
@@ -62,16 +62,23 @@ const standardParams = {
     {
       name: "delay",
       type: { name: "number", min: 0 },
       defaultValue: 0,
       description: l10n.lookup("screenshotDelayDesc"),
       manual: l10n.lookup("screenshotDelayManual")
     },
     {
+      name: "dpi",
+      type: { name: "number", min: 0, allowFloat: true },
+      defaultValue: 0,
+      description: l10n.lookup("screenshotDPIDesc"),
+      manual: l10n.lookup("screenshotDPIManual")
+    },
+    {
       name: "fullpage",
       type: "boolean",
       description: l10n.lookup("screenshotFullPageDesc"),
       manual: l10n.lookup("screenshotFullPageManual")
     },
     {
       name: "selector",
       type: "node",
@@ -282,17 +289,17 @@ function createScreenshotData(document, 
   const scrollbarHeight = {};
   const scrollbarWidth = {};
   winUtils.getScrollbarSize(false, scrollbarWidth, scrollbarHeight);
   width -= scrollbarWidth.value;
   height -= scrollbarHeight.value;
 
   const canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
   const ctx = canvas.getContext("2d");
-  const ratio = window.devicePixelRatio;
+  const ratio = args.dpi ? args.dpi : window.devicePixelRatio;
   canvas.width = width * ratio;
   canvas.height = height * ratio;
   ctx.scale(ratio, ratio);
   ctx.drawWindow(window, left, top, width, height, "#fff");
   const data = canvas.toDataURL("image/png", "");
 
   // See comment above on bug 961832
   if (args.fullpage) {
--- a/toolkit/locales/en-US/chrome/global/devtools/gclicommands.properties
+++ b/toolkit/locales/en-US/chrome/global/devtools/gclicommands.properties
@@ -91,16 +91,26 @@ screenshotAdvancedOptions=Advanced Optio
 # a dialog when the user is using this command.
 screenshotDelayDesc=Delay (seconds)
 
 # LOCALIZATION NOTE (screenshotDelayManual) A fuller description of the
 # 'delay' parameter to the 'screenshot' command, displayed when the user
 # asks for help on what it does.
 screenshotDelayManual=The time to wait (in seconds) before the screenshot is taken
 
+# LOCALIZATION NOTE (screenshotDPIDesc) A very short string to describe
+# the 'dpi' parameter to the 'screenshot' command, which is displayed in
+# a dialog when the user is using this command.
+screenshotDPIDesc=Dots per inch
+
+# LOCALIZATION NOTE (screenshotDPIManual) A fuller description of the
+# 'dpi' parameter to the 'screenshot' command, displayed when the user
+# asks for help on what it does.
+screenshotDPIManual=The number of dots per inch in the screenshot
+
 # LOCALIZATION NOTE (screenshotFullscreenDesc) A very short string to describe
 # the 'fullscreen' parameter to the 'screenshot' command, which is displayed in
 # a dialog when the user is using this command.
 screenshotFullPageDesc=Entire webpage? (true/false)
 
 # LOCALIZATION NOTE (screenshotFullscreenManual) A fuller description of the
 # 'fullscreen' parameter to the 'screenshot' command, displayed when the user
 # asks for help on what it does.