Bug 1278204 - Fix HiDPI issue by detecting devicePixelRatio. r=lochang
--- 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);