On Tue, 11 Jun 2024 21:58:46 GMT, Jonathan Gibbons <[email protected]> wrote:
>>> If we are ordering the entries, we can use comparable to check that an attr
>>> is greater than the start of the global attr, something like
>>>
>>> ```java
>>> private static boolean isGlobalAttr(Attr value) {
>>> return value.compareTo(Attr.ACCESSKEY) >= 0;
>>> }
>>> ```
>>
>> That would also work, yes. I still avoid relying on the order of enum
>> constants; but it's me.
>
> I suggest one of
>
> 1. Add a `boolean global;` member to the enum, and provide a second
> constructor that allows that boolean member to be set true. For example,
>
> WIDTH,
> STYLE(true),
>
>
> 2. Make the `Set` be static and init it in a static initializer.
> See the `javac` `Source` and `Target` classes for examples of this technique.
Wouldn't the easiest solution be to add a boolean `global`/`isGlobal` field and
getter to `Attr`?
That would give use some more opportunities to simplify the code: We could get
rid of the `GLOBAL_ATTRS` map here *and* avoid putting global attributes in the
the `attr` map of each `HtmlTag` instance by simply adding a shortcut to return
`AttrKind.OK` in `getAttrKind(Name)` if the given attribute is global.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19652#discussion_r1636093592