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

Commit

Permalink
remove high DPI shot capture for full page
Browse files Browse the repository at this point in the history
  • Loading branch information
Niharika Khanna committed Aug 2, 2017
1 parent b3232a8 commit fde181d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions addon/webextension/selector/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,22 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
supportsDrawWindow = !!ctx.drawWindow;
})();

let screenshotPage = exports.screenshotPage = function(selectedPos) {
let screenshotPage = exports.screenshotPage = function(selectedPos, captureType) {
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 (window.devicePixelRatio !== 1) {
if (captureType == 'fullPage') {
canvas.width = width;
canvas.height = height;
} else {
canvas.width = width * window.devicePixelRatio;
canvas.height = height * window.devicePixelRatio;
}
if (window.devicePixelRatio !== 1 && captureType != 'fullPage') {
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
}
ui.iframe.hide();
Expand Down Expand Up @@ -92,7 +97,7 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
if (buildSettings.captureText) {
captureText = util.captureEnclosedText(selectedPos);
}
let dataUrl = url || screenshotPage(selectedPos);
let dataUrl = url || screenshotPage(selectedPos, captureType);
if (dataUrl) {
shotObject.delAllClips();
shotObject.addClip({
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/selector/uicontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ this.uicontrol = (function() {

stateHandlers.previewing = {
start() {
dataUrl = shooter.screenshotPage(selectedPos);
dataUrl = shooter.screenshotPage(selectedPos, captureType);
ui.iframe.usePreview();
ui.Preview.display(dataUrl);
}
Expand Down

0 comments on commit fde181d

Please sign in to comment.