-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use PresentationSourceType instead of url='_self' #6
base: main
Are you sure you want to change the base?
Conversation
Mark PTAL |
@@ -156,11 +154,21 @@ partial interface PresentationConnection { | |||
}; | |||
|
|||
dictionary PresentationSource { | |||
readonly USVString url; | |||
required PresentationSourceType type; |
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.
This should be readonly as you shouldn't be able to change the source type on an existing connection.
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.
It turns out that "Dictionaries must not be used as the type of an attribute" (spec), so we can't have PresentationSource be an attribute of PresentationConnection.
So I've added the fields directly to the PresentationConnection interface. We could wrap them into a separate interface but that feels like complication without much benefit right now.
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.
From a WebIDL point of view, I do think there is benefit in declaring the mirroring parameters once in an interface, so those declarations don't have to be repeated.
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 agree that the repetition isn't great.
PresentationConnection and PresentationSource are an interface and a dictionary respectively with basically the same set of fields, to achieve:
- Not requiring the user to call a ctor for creating a PresentationSource
- Working around WebIDL's restriction that a dictionary cannot be an interface attribute
I'm not sure if we can get rid of the duplication while maintaining the above two properties.
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.
Can you check the WebIDL spec to see what our options are here?
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.
Thus far I'm not seeing a cleaner way to do it. Implicit conversion from a JS object can be done with dictionaries but not interfaces. So we'd want PresentationSource to be a dictionary so that websites would be able to pass a JS object in rather than having to call a ctor.
However a dictionary cannot be used as an attribute nor can an interface inherit from a dictionary (or vice versa), so it seems to me that the parameters need to declared once each in a dictionary and an interface.
@@ -156,11 +154,21 @@ partial interface PresentationConnection { | |||
}; | |||
|
|||
dictionary PresentationSource { | |||
readonly USVString url; | |||
required PresentationSourceType type; |
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.
From a WebIDL point of view, I do think there is benefit in declaring the mirroring parameters once in an interface, so those declarations don't have to be repeated.
explainer.md
Outdated
readonly attribute PresentationSourceType type; | ||
|
||
// Used if `type` is "url". | ||
readonly attribute USVString? url; |
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 don't think this can change to optional since it's mandatory in the current spec, as that would risk breaking current script.
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're right, changed. I suppose it can be an empty string rather than null when not used.
@@ -156,11 +154,21 @@ partial interface PresentationConnection { | |||
}; | |||
|
|||
dictionary PresentationSource { | |||
readonly USVString url; | |||
required PresentationSourceType type; |
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.
Can you check the WebIDL spec to see what our options are here?
The only change I made was to |
No description provided.