From a6f0b061ca407183e062b681793a0202ad7a2636 Mon Sep 17 00:00:00 2001 From: Youenn Fablet Date: Wed, 23 Mar 2022 12:07:29 +0100 Subject: [PATCH 1/2] Make CropTarget have an internal slot to keep a reference to its element Refer to getBoundingClientRect as a defintion of the actual crop area. --- index.html | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index e511e1b..2eba9ef 100644 --- a/index.html +++ b/index.html @@ -153,6 +153,21 @@

CropTarget Definition

};
+

+ To create a CropTarget with element as input, run the following steps: +

    +
  1. +

    Let cropTarget be a new object of type {{CropTarget}}.

    +
  2. +
  3. +

    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.

    +
    +
  4. +
+

MediaDevices.produceCropTarget

@@ -168,33 +183,27 @@

MediaDevices.produceCropTarget

- 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.

@@ -234,8 +243,11 @@

BrowserCaptureMediaStreamTrack

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:

    From a788c0e20352f1abc71415d0f5a4b1aa190ccba1 Mon Sep 17 00:00:00 2001 From: youennf Date: Mon, 28 Mar 2022 16:17:20 +0200 Subject: [PATCH 2/2] Update index.html Co-authored-by: Jan-Ivar Bruaroey --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 2eba9ef..1781778 100644 --- a/index.html +++ b/index.html @@ -160,7 +160,8 @@

    CropTarget Definition

    Let cropTarget be a new object of type {{CropTarget}}.

  1. -

    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.