electron / electronjs.org-old

Electron website
https://electronjs.org
MIT License
1.61k stars 651 forks source link

How would an API look like? This would be impossible with `contextIsolation` (you cannot pass an `HTMLElement` around). Your first problem with cropping could be solved by passing `rect` to `capturePage`, e.g. via `getBoundingClientRect` which can be safely obtained in the renderer and serialized. What's left is that you seem to have issues with transparency not being conserved. I assume because you want to capture only a given element without things like the background color of the `body` being rendered as well? Or in the case of `getBoundingClientRect` you wouldn't want elements that overlap it (e.g. position: fixed) to also be captured? #5952

Closed Brandilee1990 closed 2 years ago

Brandilee1990 commented 2 years ago
    How would an API look like? This would be impossible with `contextIsolation` (you cannot pass an `HTMLElement` around). Your first problem with cropping could be solved by passing `rect` to `capturePage`, e.g. via `getBoundingClientRect` which can be safely obtained in the renderer and serialized. What's left is that you seem to have issues with transparency not being conserved. I assume because you want to capture only a given element without things like the background color of the `body` being rendered as well? Or in the case of `getBoundingClientRect` you wouldn't want elements that overlap it (e.g. position: fixed) to also be captured?

Originally posted by @Prinzhorn in https://github.com/electron/electron/issues/35394#issuecomment-1221955160