Bug 1278204 - Fix HiDPI issue by detecting devicePixelRatio. r=lochang draft
authorEvelyn Hung <jj.evelyn@gmail.com>
Wed, 15 Mar 2017 17:27:47 +0800
changeset 499120 809d1dfe875c
parent 498697 8dd496fd015a
child 549274 5d5dce5c529e
push id49328
push userbmo:ehung@mozilla.com
push dateWed, 15 Mar 2017 11:31:56 +0000
reviewerslochang
bugs1278204
milestone55.0a1
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();
@@ -5318,30 +5321,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);