Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Put in a supportsDrawWindow so in the future we can suppress features…
Browse files Browse the repository at this point in the history
… we don't support
  • Loading branch information
ianb committed Feb 21, 2017
1 parent b2c3b5a commit 088b903
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions webextension/selector/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ window.shooter = (function () { // eslint-disable-line no-unused-vars
const RANDOM_STRING_LENGTH = 16;
let backend;
let shot;
let supportsDrawWindow;

exports.deactivate = function () {
uicontrol.deactivate();
};

(function () {
let canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
let ctx = canvas.getContext('2d');
supportsDrawWindow = !! ctx.drawWindow;
})();

function screenshotPage(selectedPos) {
if (! supportsDrawWindow) {
return null;
}
let height = selectedPos.bottom - selectedPos.top;
let width = selectedPos.right - selectedPos.left;
let canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
canvas.width = width * window.devicePixelRatio;
canvas.height = height * window.devicePixelRatio;
let ctx = canvas.getContext('2d');
if (! ctx.drawWindow) {
return null;
}
if (window.devicePixelRatio !== 1) {
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
}
Expand Down

0 comments on commit 088b903

Please sign in to comment.