Bug 946596 - Support high resolution screenshots, r=timdream,dflanagan
authorPeter Chang <pchang@mozilla.com>
Mon, 13 Jan 2014 10:24:36 +0800
changeset 179085 c874d505a1ad7f8c851022165858894c4eb2922e
parent 179084 0ff4998614a4abff85012b5431640c727a4bb99c
child 179086 93d20eba2597f73741593a7614079efe3be7f671
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimdream, dflanagan
bugs946596
milestone29.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 946596 - Support high resolution screenshots, r=timdream,dflanagan
b2g/chrome/content/shell.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -1145,24 +1145,26 @@ window.addEventListener('ContentStart', 
     if (e.detail.type !== 'take-screenshot')
       return;
 
     try {
       var canvas = document.createElementNS('http://www.w3.org/1999/xhtml',
                                             'canvas');
       var width = window.innerWidth;
       var height = window.innerHeight;
-      canvas.setAttribute('width', width);
-      canvas.setAttribute('height', height);
+      var scale = window.devicePixelRatio;
+      canvas.setAttribute('width', width * scale);
+      canvas.setAttribute('height', height * scale);
 
       var context = canvas.getContext('2d');
       var flags =
         context.DRAWWINDOW_DRAW_CARET |
         context.DRAWWINDOW_DRAW_VIEW |
         context.DRAWWINDOW_USE_WIDGET_LAYERS;
+      context.scale(scale, scale);
       context.drawWindow(window, 0, 0, width, height,
                          'rgb(255,255,255)', flags);
 
       // I can't use sendChromeEvent() here because it doesn't wrap
       // the blob in the detail object correctly. So I use __exposedProps__
       // instead to safely send the chrome detail object to content.
       shell.sendEvent(getContentWindow(), 'mozChromeEvent', {
         __exposedProps__: { type: 'r', file: 'r' },