Bug 1278204 - Fix HiDPI issue by detecting devicePixelRatio. r=lochang
authorEvelyn Hung <jj.evelyn@gmail.com>
Wed, 15 Mar 2017 17:27:47 +0800
changeset 347902 cb68333457ad
parent 347901 567080bf24b8
child 347903 b11ebd677b70
push id38972
push userehung@mozilla.com
push dateThu, 16 Mar 2017 07:13:51 +0000
treeherderautoland@cb68333457ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslochang
bugs1278204
milestone55.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 1278204 - Fix HiDPI issue by detecting devicePixelRatio. r=lochang
browser/extensions/mortar/host/common/ppapi-runtime.jsm
--- a/browser/extensions/mortar/host/common/ppapi-runtime.jsm
+++ b/browser/extensions/mortar/host/common/ppapi-runtime.jsm
@@ -890,16 +890,19 @@ class Graphics extends PP_Resource {
     super(instance);
     this.canvas = instance.window.document.createElement("canvas");
   }
   destroy() {
     this.canvas.remove();
     super.destroy();
   }
   changeSize(width, height) {
+    let devicePixelRatio = this.instance.window.devicePixelRatio;
+    this.canvas.style.width = (width / devicePixelRatio) + "px";
+    this.canvas.style.height = (height / devicePixelRatio) + "px";
     this.canvas.width = width;
     this.canvas.height = height;
   }
 }
 class Graphics2DPaintOperation {
   constructor(imageData, x, y, dirtyRect=[]) {
     this.imageData = imageData;
     this.imageData.addRef();
@@ -5325,30 +5328,26 @@ dump(`callFromJSON: < ${JSON.stringify(c
       }
       return [PP_Bool.PP_TRUE, { rect: { point, size } }];
     },
 
     /**
      * float_t GetDeviceScale([in] PP_Resource resource);
      */
     PPB_View_GetDeviceScale: function(json) {
-      // FIXME Need to figure out how to get the ratio between device pixels
-      //       and DIPs.
       let view = PP_Resource.lookup(json.resource);
-      return 1; //view.instance.window.devicePixelRatio;
+      return view.instance.window.devicePixelRatio;
     },
 
     /**
      * float_t GetCSSScale([in] PP_Resource resource);
      */
     PPB_View_GetCSSScale: function(json) {
-      // FIXME Need to figure out how to get the ratio between CSS pixels
-      //       and DIPs.
       let view = PP_Resource.lookup(json.resource);
-      return view.instance.window.devicePixelRatio;
+      return 1;
     },
 
     /**
      * PP_Bool GetScrollOffset([in] PP_Resource resource,
      *                         [out] PP_Point offset);
      */
     PPB_View_GetScrollOffset: function(json) {
       let view = PP_Resource.lookup(json.resource);