[webkit-dev] "ReflectOnly" IDL equivalent

Maciej Stachowiak mjs at apple.com
Sat Jun 10 15:41:14 PDT 2017



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

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
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20170610/ab222b2e/attachment.html>


More information about the webkit-dev mailing list