Closed Bug 1561395 Opened 5 years ago Closed 5 years ago

Improve drawSnapshot API

Categories

(Core :: Graphics, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: rhunt, Assigned: rhunt)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

  • Expose it off of WindowGlobalParent so we can snapshot the whole browser window or just a specific remote iframe
  • Allow specifying 'capture the whole viewport' instead of an explicit rect

Here's some sample code you can put in your browser console to test this out:

img = await docShell.browsingContext.currentWindowGlobal.drawSnapshot(null, 1, 'white');
canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
uri = canvas.toDataURL()

I would've liked to split this patch up into cleaner parts, but the logic is pretty tangled up. I hope it's still simple enough to be reviewed. At the least, no code is actively using or testing this so it's a low risk change.

Pushed by rhunt@eqrion.net:
https://hg.mozilla.org/integration/autoland/rev/09fcee21b246
Move drawSnapshot API to WindowGlobalParent and allow specifying the whole viewport as a rect. r=mattwoodrow,nika
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
No longer depends on: 1569974
Regressions: 1569974
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: