Bug 1710635 - Adds capture visible view port using Save visible. r=emalysz

Differential Revision: https://phabricator.services.mozilla.com/D116405
This commit is contained in:
Kajal Sah 2021-06-09 17:45:27 +00:00
Родитель 30eaac65f3
Коммит 4cadce4f26
2 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -12,8 +12,8 @@ this.takeshot = (function() {
communication.register(
"screenshotPage",
(sender, selectedPos, isFullPage, devicePixelRatio) => {
return screenshotPage(selectedPos, isFullPage, devicePixelRatio);
(sender, selectedPos, screenshotType, devicePixelRatio) => {
return screenshotPage(selectedPos, screenshotType, devicePixelRatio);
}
);
@ -21,7 +21,7 @@ this.takeshot = (function() {
return getZoomFactor();
});
function screenshotPage(pos, isFullPage, devicePixelRatio) {
function screenshotPage(pos, screenshotType, devicePixelRatio) {
let zoomFactor = getZoomFactor();
pos.width = Math.min(pos.right - pos.left, MAX_CANVAS_DIMENSION);
pos.height = Math.min(pos.bottom - pos.top, MAX_CANVAS_DIMENSION);
@ -29,7 +29,10 @@ this.takeshot = (function() {
// If we are printing the full page or a truncated full page,
// we must pass in this rectangle to preview the entire image
let options = { format: "png" };
if (isFullPage) {
if (
screenshotType === "fullPage" ||
screenshotType === "fullPageTruncated"
) {
let rectangle = {
x: 0,
y: 0,
@ -42,7 +45,7 @@ this.takeshot = (function() {
// performance problems), we set the devicePixelRatio to 1.
devicePixelRatio = 1;
options.scale = 1 / zoomFactor;
} else {
} else if (screenshotType != "visible") {
let rectangle = {
x: pos.left,
y: pos.top,

Просмотреть файл

@ -48,11 +48,10 @@ this.shooter = (function() {
let promise = Promise.resolve(dataUrl);
if (!dataUrl) {
let isFullPage = type === "fullPage" || type == "fullPageTruncated";
promise = callBackground(
"screenshotPage",
selectedPos.toJSON(),
isFullPage,
type,
window.devicePixelRatio
);
}