-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make CropTarget serializable #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,14 @@ <h2>Abstract</h2> | |
a First Public Working Draft. | ||
</section> | ||
<section id="conformance"></section> | ||
<section id="terminology"> | ||
<h2>Terminology</h2> | ||
<p> | ||
The terms | ||
<dfn data-cite="HTML/structured-data.html#serializable-objects">serializable objects</dfn>, | ||
[= serialization steps =], and [= deserialization steps =] are defined in [[!HTML]]. | ||
</p> | ||
</section> | ||
<section id="definitions"> | ||
<h2>Definitions</h2> | ||
<p> | ||
|
@@ -147,12 +155,39 @@ <h3><dfn>CropTarget</dfn> Definition</h3> | |
purpose is to be handed to {{BrowserCaptureMediaStreamTrack/cropTo}} as input. | ||
</p> | ||
<pre class="idl"> | ||
[Exposed = Window] | ||
[Exposed = Window, Serializable] | ||
interface CropTarget { | ||
// Intentionally empty; just an opaque identifier. | ||
}; | ||
</pre> | ||
<dl data-link-for="CropTarget" data-dfn-for="CropTarget"></dl> | ||
|
||
<p id="serializable-croptarget"> | ||
{{CropTarget}} objects are [= serializable objects =] [[!HTML]]. Their [= serialization | ||
steps =], given <var>value</var> and <var>serialized</var>, are: | ||
</p> | ||
<ol> | ||
<li> | ||
Set <var>serialized</var>.[[\Data]] a randomly generated, globally unique {{DOMString}}. | ||
</li> | ||
</ol> | ||
<p> | ||
Their <a>deserialization steps</a>, given <var>serialized</var> and <var>value</var>, are: | ||
</p> | ||
<ol> | ||
<li> | ||
Compare <var>serialized</var>.[[\Data]] against a record of all {{CropTargets}} produced | ||
and serialized thus far in the current top-level [=browsing context=], or in any of its | ||
descendent [=browsing contexts=]. | ||
<ol> | ||
<li> | ||
If <var>serialized</var>.[[\Data]] was obtained by serializing previous | ||
{{CropTarget}}, then set <var>value</var> to an equivalent {{CropTarget}}. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This "equivalent {{CropTarget}}" is not very well defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this comment applies here too; only its second half is relevant, so I'll repeat: |
||
</li> | ||
<li>Otherwise, set <var>value</var> to {{undefined}}.</li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the serialisation steps are done correctly, we should always successfully deserialise, which does not seem to be the case here if we set value to undefined. Introducing a direct element <-> CropTarget link, for instance by having CropTarget having an element reference seems a good approach to tighten things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
</ol> | ||
</li> | ||
</ol> | ||
</section> | ||
<section id="producecroptarget-method"> | ||
<h3>MediaDevices.produceCropTarget</h3> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to accept forStorage here as well, and throw an error (not sure which one, DataCloneError maybe?) if it is
true
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The introduction of these steps should omit mention of the forStorage argument if it is not relevant to the algorithm."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case for forStorage being set to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want this to be able to end up in IDB/pushState/some other things or not, essentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want it to be possible for this to be stringified and sent over a REST call, as I know some Web applications that can cooperate either in a single-tab or multi-tab setting, and they use REST (and REST-like) for as much as they can, since that's already set up and works for them. I think it's a valid use-case and there's no reason to forbid it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean through Fetch? Serializable doesn't help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Serializable forStorage=true does not allow conversion to a string, could you please advise what does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to convert a platform object to a string, you need to define a stringifier for it. That seems like a topic for a new issue though as #21 doesn't cover it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.