Re: [mediacapture-region] Why expose produceCropTarget at MediaDevices level? (#11)

> * (Window/MessagePort-from-Window object, element ID string): does not work in full generality, but is nice and simple and reuses existing primitives

Thanks @domenic, this is my winner. Avoids a new API & gets the id from iframe B to iframe A, which is all we need. KISS

```js
// a.com/main.html
const channel = new MessageChannel();
iframeA.contentWindow.postMessage(channel.port1, '*', [channel.port1]);
iframeB.contentWindow.postMessage(channel.port2, '*', [channel.port2]);

// b.com/iframeB.html
const element = document.getElementById("foo");
const {data: port} = await new Promise(r => window.onmessage = r);
port.postMessage(element.id);

// a.com/iframeA.html
const {data: port} = await new Promise(r => window.onmessage = r);
port.onmessage = async e => await track.cropTo(e.data.id, {source: e.source});
```
postMessage here is a means to an end, so solving full generality feels like scope-creep.

> Another thing to consider is that the ID can refer to one element at a given point in time and to another one later on. This might make dynamic cropping easier ...

@youennf a live id feels like feature creep. Having `await cropTo(id)` resolve to a specific element seems POLA.

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/mediacapture-region/issues/11#issuecomment-1119135439 using your GitHub account


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

Received on Thursday, 5 May 2022 23:26:07 UTC