[webkit-dev] "ReflectOnly" IDL equivalent

Sam Weinig weinig at apple.com
Sat Jun 10 17:03:02 PDT 2017



> On Jun 10, 2017, at 3:41 PM, Maciej Stachowiak <mjs at apple.com> wrote:
> 
> 
> 
> On Jun 9, 2017, at 10:08 PM, Chris Dumez <cdumez at apple.com <mailto:cdumez at apple.com>> wrote:
> 
>> 
>>> On Jun 9, 2017, at 11:47 AM, Sam Weinig <weinig at apple.com <mailto:weinig at apple.com>> wrote:
>>> 
>>> 
>>> 
>>>> On Jun 2, 2017, at 11:32 AM, Ryosuke Niwa <rniwa at webkit.org <mailto:rniwa at webkit.org>> wrote:
>>>> 
>>>> On Fri, Jun 2, 2017 at 9:18 AM, Chris Dumez <cdumez at apple.com <mailto:cdumez at apple.com>> 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:
>> - https://html.spec.whatwg.org/#dom-dir <https://html.spec.whatwg.org/#dom-dir>
>> - https://html.spec.whatwg.org/#dom-link-as <https://html.spec.whatwg.org/#dom-link-as>
>> - https://html.spec.whatwg.org/#dom-link-referrerpolicy <https://html.spec.whatwg.org/#dom-link-referrerpolicy>
>> - https://html.spec.whatwg.org/#dom-link-updateviacache <https://html.spec.whatwg.org/#dom-link-updateviacache>
>> - https://html.spec.whatwg.org/#dom-a-referrerpolicy <https://html.spec.whatwg.org/#dom-a-referrerpolicy>
>> - https://html.spec.whatwg.org/#dom-img-referrerpolicy <https://html.spec.whatwg.org/#dom-img-referrerpolicy>
>> - https://html.spec.whatwg.org/#dom-iframe-referrerpolicy <https://html.spec.whatwg.org/#dom-iframe-referrerpolicy>
>> - https://html.spec.whatwg.org/#dom-track-kind <https://html.spec.whatwg.org/#dom-track-kind>
>> - https://html.spec.whatwg.org/#dom-media-preload <https://html.spec.whatwg.org/#dom-media-preload>
>> - https://html.spec.whatwg.org/#dom-area-referrerpolicy <https://html.spec.whatwg.org/#dom-area-referrerpolicy>
>> - https://html.spec.whatwg.org/#dom-th-scope <https://html.spec.whatwg.org/#dom-th-scope>
>> - https://html.spec.whatwg.org/#dom-form-autocomplete <https://html.spec.whatwg.org/#dom-form-autocomplete>
>> - https://html.spec.whatwg.org/#dom-input-type <https://html.spec.whatwg.org/#dom-input-type>
>> - https://html.spec.whatwg.org/#dom-input-inputmode <https://html.spec.whatwg.org/#dom-input-inputmode>
>> - https://html.spec.whatwg.org/#dom-button-type <https://html.spec.whatwg.org/#dom-button-type>
>> - https://html.spec.whatwg.org/#dom-textarea-inputmode <https://html.spec.whatwg.org/#dom-textarea-inputmode>
>> - https://html.spec.whatwg.org/#dom-fs-method <https://html.spec.whatwg.org/#dom-fs-method>
>> - https://html.spec.whatwg.org/#dom-fs-enctype <https://html.spec.whatwg.org/#dom-fs-enctype>
>> - https://html.spec.whatwg.org/#dom-fs-formenctype <https://html.spec.whatwg.org/#dom-fs-formenctype>
>> - https://html.spec.whatwg.org/#dom-fs-formmethod <https://html.spec.whatwg.org/#dom-fs-formmethod>
>> 
>> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20170610/ecde32e6/attachment.html>


More information about the webkit-dev mailing list