From a6f0b061ca407183e062b681793a0202ad7a2636 Mon Sep 17 00:00:00 2001
From: Youenn Fablet
+ To create a CropTarget with element as input, run the following steps:
+ Let cropTarget be a new object of type {{CropTarget}}. Create cropTarget.[[\Element]] initialized to element. cropTarget is keeping a weak reference to the element it is representing.
+ In other words, cropTarget will not prevent garbage collection of its element.CropTarget Definition
};
+
+
+
- The first call of {{MediaDevices/produceCropTarget}} on an {{HTMLElement}} of a - supported type, permanently associates that element with a {{CropTarget}}. Subsequent - calls return the same {{CropTarget}}. This {{CropTarget}} may be used as input to + Calling {{MediaDevices/produceCropTarget}} on an {{HTMLElement}} of a + supported type associates that element with a {{CropTarget}}. + This {{CropTarget}} may be used as input to {{BrowserCaptureMediaStreamTrack/cropTo}}. We define a valid CropTarget as one returned by a previous call to {{MediaDevices/produceCropTarget()}} in the current [=browsing context=].
- When {{MediaDevices/produceCropTarget}} is first called on a given element, - the user agent MUST produce a new unique {{CropTarget}} and permanently associate it - with element. The user agent MUST return a {{Promise}} P. The + When {{MediaDevices/produceCropTarget}} is called on a given element, + the user agent [=create a CropTarget|creates a CropTarget=] with element as input. + The user agent MUST return a {{Promise}} P. The user agent MUST resolve P only after it has finished all the necessary internal propagation of state associated with the new {{CropTarget}}, at which point the user agent MUST be ready to receive the new {{CropTarget}} as a valid parameter to {{BrowserCaptureMediaStreamTrack/cropTo}}.
-- Subsequent calls to {{MediaDevices/produceCropTarget}} MUST return a new {{Promise}} - that behaves the same way P does. Specifically, the new {{Promise}} MUST - resolve after P, and MUST resolve to the same {{CropTarget}} as - P. -
When cloning an {{HTMLElement}} on which {{MediaDevices/produceCropTarget}} was - previously called, the clone MUST NOT be associated with any {{CropTarget}}. If + previously called, the clone is not associated with any {{CropTarget}}. If {{MediaDevices/produceCropTarget}} is later called on the clone, a new {{CropTarget}} - MUST be assigned to it. + will be assigned to it.
Calls to this method instruct the user agent to start/stop cropping a [=self-capture - video track=] to the contours of the element referenced by - cropTarget. Whenever {{BrowserCaptureMediaStreamTrack/cropTo}} is invoked, + video track=] to the + bounding client rectangle of cropTarget.[[\Element]]. + Since the track is restricted to the visible viewport of the [=display-surface=], + the captured area will be the intersection of the visible viewport and the element bounding client rectangle. + Whenever {{BrowserCaptureMediaStreamTrack/cropTo}} is invoked, the user agent MUST execute the following algorithm:
Let cropTarget be a new object of type {{CropTarget}}.
Create cropTarget.[[\Element]] initialized to element.
+Let weakRef be a weak reference to element.
+Create cropTarget.[[\Element]] initialized to weakRef.
cropTarget is keeping a weak reference to the element it is representing. In other words, cropTarget will not prevent garbage collection of its element.