Re: [mediacapture-screen-share] capture screenshot of DOM (#145)

I also notice that firefox has it 🙂 

It would be annoying to have to prompt if all content is under your control or have CORS support or isn't a taintet canvas element
Otherwise i would be okey with what html2canvas is doing (render those part as a white or transparent placeholder)

When i came to think about it... Expanding [createImageBitmap](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap) to accept eg `document` or any `HTMLElement` could be a grate placement for this functionality if done correctly?
- don't have to come up with new api's
- if only `document` became allowed and not any `HTMLElement`, than you can easily just use `node.getBoundingClientRect()` to clip the area you need.
- you can decide for yourself what image format and quality you want
- it can be transfered to workers/iframes more easily with postMessage
- it can handle alpha (transparent background/iframes)?
- it's already promise based 👍 
  - so we could expand the option to include tainted images in which case it will ask the user for permission (preferable with a preview of the image that have already been taken, but that's up to browser to implement)

```js
const imageBitmapPromise = createImageBitmap(document.body, {
  // setting this to true would cause tainted canvas, cross origin images,
  // backgrounds and iframes to be included and not painted as white or
  // transparent placeholders, but it can also cause a prompt to appear.
  includeTainted: true
})
```

---

durning development and end-to-end testing to see how responsive things are in mobile/desktop would also be a good usecase for this

-- 
GitHub Notification of comment by jimmywarting
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/145#issuecomment-672768831 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 12 August 2020 09:40:16 UTC