"ReflectOnly" IDL equivalent

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

"ReflectOnly" IDL equivalent

Yoav Weiss
I'm working on the link preload feature and as part of that want to align it to the spec from an IDL perspective.
The `as` attribute is defined as an "enumerated attribute", which reflects only a finite set of known values. That is important for feature detection purposes, so that developers can know which `as` values are supported by the implementation.

In Blink this is done using `ReflectOnly` (pending CL), and I'm wondering what is the WebKit equivalent to implement attributes that are limited to known values.

Thanks! :)
Yoav

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "ReflectOnly" IDL equivalent

Chris Dumez
Hi,

No, I do not believe WebKit supports ReflectOnly and this is not standard IDL either.

The way to do it in WebKit would be to use a regular DOMString attribute, as in the specification and implement this logic in the c++ getter for this attribute. See HTMLElement::dir() for an example.

We could also consider adding support for something like ReflectOnly in our bindings generator considering that this seems to be used quite a bit in the HTML specification and it would decrease code complexity a little.
I’d actually be in favor of that.

--
 Chris Dumez




On Jun 1, 2017, at 10:57 PM, Yoav Weiss <[hidden email]> wrote:

I'm working on the link preload feature and as part of that want to align it to the spec from an IDL perspective.
The `as` attribute is defined as an "enumerated attribute", which reflects only a finite set of known values. That is important for feature detection purposes, so that developers can know which `as` values are supported by the implementation.

In Blink this is done using `ReflectOnly` (pending CL), and I'm wondering what is the WebKit equivalent to implement attributes that are limited to known values.

Thanks! :)
Yoav
_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev


_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "ReflectOnly" IDL equivalent

Ryosuke Niwa-2
On Fri, Jun 2, 2017 at 9:18 AM, Chris Dumez <[hidden email]> wrote:

> Hi,
>
> No, I do not believe WebKit supports ReflectOnly and this is not standard
> IDL either.
>
> The way to do it in WebKit would be to use a regular DOMString attribute, as
> in the specification and implement this logic in the c++ getter for this
> attribute. See HTMLElement::dir() for an example.
>
> We could also consider adding support for something like ReflectOnly in our
> bindings generator considering that this seems to be used quite a bit in the
> HTML specification and it would decrease code complexity a little.
> I’d actually be in favor of that.

I'd suggest other names like "ReflectEnum" or even "Reflect<EnumType>"
where EnumType is the name of enum that defines the list of values.

"ReflectOnly" doesn't tell us on what "only" applies. If I didn't know
the context, it sounds like something that does less work than regular
"Reflect".

- R. Niwa
_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "ReflectOnly" IDL equivalent

Sam Weinig-2


> On Jun 2, 2017, at 11:32 AM, Ryosuke Niwa <[hidden email]> wrote:
>
> On Fri, Jun 2, 2017 at 9:18 AM, Chris Dumez <[hidden email]> wrote:
>> Hi,
>>
>> No, I do not believe WebKit supports ReflectOnly and this is not standard
>> IDL either.
>>
>> The way to do it in WebKit would be to use a regular DOMString attribute, as
>> in the specification and implement this logic in the c++ getter for this
>> attribute. See HTMLElement::dir() for an example.
>>
>> We could also consider adding support for something like ReflectOnly in our
>> bindings generator considering that this seems to be used quite a bit in the
>> HTML specification and it would decrease code complexity a little.
>> I’d actually be in favor of that.
>
> I'd suggest other names like "ReflectEnum" or even "Reflect<EnumType>"
> where EnumType is the name of enum that defines the list of values.
>
> "ReflectOnly" doesn't tell us on what "only" applies. If I didn't know
> the context, it sounds like something that does less work than regular
> "Reflect”.


I don’t see a good reason to complicate the bindings until this becomes more common place.  For now, I would just implement HTMLLinkElement::as() to behave as you want and leave the IDL unannotated, and we can revisit it at a later time.

- Sam
_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "ReflectOnly" IDL equivalent

Yoav Weiss
Apologies for not updating this thread sooner.
I already went ahead and implemented `as()` to reflect what's needed, and was planning to refactor that and add a "ReflectEnum" binding at a later patch.
If that's not needed, I can just leave it as is.

On Fri, Jun 9, 2017 at 8:47 PM Sam Weinig <[hidden email]> wrote:


> On Jun 2, 2017, at 11:32 AM, Ryosuke Niwa <[hidden email]> wrote:
>
> On Fri, Jun 2, 2017 at 9:18 AM, Chris Dumez <[hidden email]> wrote:
>> Hi,
>>
>> No, I do not believe WebKit supports ReflectOnly and this is not standard
>> IDL either.
>>
>> The way to do it in WebKit would be to use a regular DOMString attribute, as
>> in the specification and implement this logic in the c++ getter for this
>> attribute. See HTMLElement::dir() for an example.
>>
>> We could also consider adding support for something like ReflectOnly in our
>> bindings generator considering that this seems to be used quite a bit in the
>> HTML specification and it would decrease code complexity a little.
>> I’d actually be in favor of that.
>
> I'd suggest other names like "ReflectEnum" or even "Reflect<EnumType>"
> where EnumType is the name of enum that defines the list of values.
>
> "ReflectOnly" doesn't tell us on what "only" applies. If I didn't know
> the context, it sounds like something that does less work than regular
> "Reflect”.


I don’t see a good reason to complicate the bindings until this becomes more common place.  For now, I would just implement HTMLLinkElement::as() to behave as you want and leave the IDL unannotated, and we can revisit it at a later time.

- Sam

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "ReflectOnly" IDL equivalent

Chris Dumez
In reply to this post by Sam Weinig-2

On Jun 9, 2017, at 11:47 AM, Sam Weinig <[hidden email]> wrote:



On Jun 2, 2017, at 11:32 AM, Ryosuke Niwa <[hidden email]> wrote:

On Fri, Jun 2, 2017 at 9:18 AM, Chris Dumez <[hidden email]> wrote:
Hi,

No, I do not believe WebKit supports ReflectOnly and this is not standard
IDL either.

The way to do it in WebKit would be to use a regular DOMString attribute, as
in the specification and implement this logic in the c++ getter for this
attribute. See HTMLElement::dir() for an example.

We could also consider adding support for something like ReflectOnly in our
bindings generator considering that this seems to be used quite a bit in the
HTML specification and it would decrease code complexity a little.
I’d actually be in favor of that.

I'd suggest other names like "ReflectEnum" or even "Reflect<EnumType>"
where EnumType is the name of enum that defines the list of values.

"ReflectOnly" doesn't tell us on what "only" applies. If I didn't know
the context, it sounds like something that does less work than regular
"Reflect”.


I don’t see a good reason to complicate the bindings until this becomes more common place.  For now, I would just implement HTMLLinkElement::as() to behave as you want and leave the IDL unannotated, and we can revisit it at a later time.

As I said, this is already used in quite a few places in the HTML spec:

Having a per-standard implementation in the bindings would likely be better than many potentially non-compliant ones.

--
 Chris Dumez


_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "ReflectOnly" IDL equivalent

Maciej Stachowiak


On Jun 9, 2017, at 10:08 PM, Chris Dumez <[hidden email]> wrote:


On Jun 9, 2017, at 11:47 AM, Sam Weinig <[hidden email]> wrote:



On Jun 2, 2017, at 11:32 AM, Ryosuke Niwa <[hidden email]> wrote:

On Fri, Jun 2, 2017 at 9:18 AM, Chris Dumez <[hidden email]> wrote:
Hi,

No, I do not believe WebKit supports ReflectOnly and this is not standard
IDL either.

The way to do it in WebKit would be to use a regular DOMString attribute, as
in the specification and implement this logic in the c++ getter for this
attribute. See HTMLElement::dir() for an example.

We could also consider adding support for something like ReflectOnly in our
bindings generator considering that this seems to be used quite a bit in the
HTML specification and it would decrease code complexity a little.
I’d actually be in favor of that.

I'd suggest other names like "ReflectEnum" or even "Reflect<EnumType>"
where EnumType is the name of enum that defines the list of values.

"ReflectOnly" doesn't tell us on what "only" applies. If I didn't know
the context, it sounds like something that does less work than regular
"Reflect”.


I don’t see a good reason to complicate the bindings until this becomes more common place.  For now, I would just implement HTMLLinkElement::as() to behave as you want and leave the IDL unannotated, and we can revisit it at a later time.

As I said, this is already used in quite a few places in the HTML spec:

Having a per-standard implementation in the bindings would likely be better than many potentially non-compliant ones.

The HTML spec's name for this concept, "limited to only known values" is really clear and better than "only" or "enum". I wonder if we could make a name based on this, such as

ReflectLimitedToKnownValues
ReflectOnlyKnownValues
ReflectKnownValues
ReflectLimited

(The last of this might be too vague.)


--
 Chris Dumez

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "ReflectOnly" IDL equivalent

Sam Weinig-2


On Jun 10, 2017, at 3:41 PM, Maciej Stachowiak <[hidden email]> wrote:



On Jun 9, 2017, at 10:08 PM, Chris Dumez <[hidden email]> wrote:


On Jun 9, 2017, at 11:47 AM, Sam Weinig <[hidden email]> wrote:



On Jun 2, 2017, at 11:32 AM, Ryosuke Niwa <[hidden email]> wrote:

On Fri, Jun 2, 2017 at 9:18 AM, Chris Dumez <[hidden email]> wrote:
Hi,

No, I do not believe WebKit supports ReflectOnly and this is not standard
IDL either.

The way to do it in WebKit would be to use a regular DOMString attribute, as
in the specification and implement this logic in the c++ getter for this
attribute. See HTMLElement::dir() for an example.

We could also consider adding support for something like ReflectOnly in our
bindings generator considering that this seems to be used quite a bit in the
HTML specification and it would decrease code complexity a little.
I’d actually be in favor of that.

I'd suggest other names like "ReflectEnum" or even "Reflect<EnumType>"
where EnumType is the name of enum that defines the list of values.

"ReflectOnly" doesn't tell us on what "only" applies. If I didn't know
the context, it sounds like something that does less work than regular
"Reflect”.


I don’t see a good reason to complicate the bindings until this becomes more common place.  For now, I would just implement HTMLLinkElement::as() to behave as you want and leave the IDL unannotated, and we can revisit it at a later time.

As I said, this is already used in quite a few places in the HTML spec:

Having a per-standard implementation in the bindings would likely be better than many potentially non-compliant ones.


That is quite an imposing list, I rescind my objection.

The HTML spec's name for this concept, "limited to only known values" is really clear and better than "only" or "enum". I wonder if we could make a name based on this, such as

ReflectLimitedToKnownValues
ReflectOnlyKnownValues
ReflectKnownValues
ReflectLimited

(The last of this might be too vague.)

I’d prefer ReflectLimitedToKnownValues.

- Sam


_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Loading...