<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>213227</bug_id>
          
          <creation_ts>2020-06-15 20:51:07 -0700</creation_ts>
          <short_desc>[WPT] img.decoding does not reflect the content attribute limited to known values as specified [WPT] form.action does not return document.url when unset (part of https://wpt.live/html/dom/reflection-embedded.html)</short_desc>
          <delta_ts>2024-01-16 13:49:45 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sam Weinig">sam</reporter>
          <assigned_to name="Sam Weinig">sam</assigned_to>
          <cc>cdumez</cc>
    
    <cc>changseok</cc>
    
    <cc>darin</cc>
    
    <cc>esprehn+autocc</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>kondapallykalyan</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1662959</commentid>
    <comment_count>0</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2020-06-15 20:51:07 -0700</bug_when>
    <thetext>WPT: img.decoding does not reflect the content attribute limited to known values as specified [WPT] form.action does not return document.url when unset

Test: https://wpt.live/html/dom/reflection-embedded.html
Spec: https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decoding

From the spec: &quot;The decoding IDL attribute must reflect the decoding content attribute, limited to only known values.&quot; The known values are the set of image decoding hints (https://html.spec.whatwg.org/multipage/images.html#image-decoding-hint): &quot;sync&quot;, &quot;async&quot; and &quot;auto&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1662960</commentid>
    <comment_count>1</comment_count>
      <attachid>401973</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2020-06-15 20:51:41 -0700</bug_when>
    <thetext>Created attachment 401973
WIP</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1662965</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2020-06-15 21:09:17 -0700</bug_when>
    <thetext>While a fix like the one I just attached as a WIP is straightforward, I think it would be preferable to come up with an automatic way to handle the reflection &quot;limited to only known values&quot; (see https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#limited-to-only-known-values) case better, so we can keep as much of the autogenerated Reflect code as we can.

The most straightforward solution would be to add a variant of Reflect that allowed a custom getter (e.g. ReflectWithCustomGetter). Then, at the very least HTMLImageElement::setDecoding would not be something we need implement.



We could potentially add a delegation point that does the limiting / filtering, e.g.

static AtomString HTMLImageElement::decodingContentAttributeLimiter(const AtomString&amp; decodingMode)
{
     // convert to limited values here
}

and have the bindings generator generate use something like the following:

interface HTMLImageElement {
    ...
    [ReflectWithLimits] attribute DOMString decoding;
    ...
}

to generate:

   return HTMLImageElement::decodingContentAttributeLimiter(element.attributeWithoutSynchronization(decodingAttr));




Or, we could try to go all out and encode the limits into the bindings with something like the following in the IDL:

enum ValidDecodingContentAttributeValues { &quot;sync&quot;, &quot;async&quot;, &quot;auto&quot; };

interface HTMLImageElement {
    ...
    [Reflect, LimitTo=ValidDecodingContentAttributeValues, InvalidDefault=&quot;auto&quot;, MissingDefault=&quot;auto&quot;] attribute DOMString decoding;`
    ...
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1662966</commentid>
    <comment_count>3</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2020-06-15 21:10:44 -0700</bug_when>
    <thetext>Darin, as steward of the &quot;Reflect&quot; extended attribute, would be very keen to hear your thoughts on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1662985</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2020-06-15 22:17:55 -0700</bug_when>
    <thetext>Some disorganized thoughts.

One thing I think about is that “reflect” terminology originally came from the specification wording. How do the specifications describe all these cases? What words are used in the specifications?

I like the one based on an enumeration. The original motivation was to cut down on mistakes in repetitive code so generating more seems good.

But the example looks wordy so I’m a little concerned.

I guess there are two ways to think about this. One is “set as a string, but get as an enumeration”. Another is “set the content attribute but get the effective value”. When you think about it the second way, what you want is to implement a getter that shares the logic with whatever code parses the value. It’s not part of the binding exactly. It’s part of the attribute parsing.

One option is that you write the getter but it returns an enum value, not a string. This makes it more likely that the same getter can be used inside the element class implementation.

I think “ReflectWithCustomGetter” is kind of a funny way to put it because “custom getter” is just normal. Maybe “ReflectSetterOnly” is better?

Really looking for a way to avoid handwriting all these parsers for attribute values. That really does point towards the enum style because that’s effectively what an enum does; just normally the string part stays entirely in the binding layer but for attributes the parsing is needed any time the attribute changes.

My goal would be to not write the “parse for expected values” code.

Maybe syntax for defining the content attribute itself, not just the binding?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1663526</commentid>
    <comment_count>5</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2020-06-17 09:21:26 -0700</bug_when>
    <thetext>(In reply to Darin Adler from comment #4)
&gt; Some disorganized thoughts.
&gt; 
&gt; One thing I think about is that “reflect” terminology originally came from
&gt; the specification wording. How do the specifications describe all these
&gt; cases? What words are used in the specifications?

The spec still uses the term &quot;reflect&quot; extensively. For instance, for img.decoding, it writes:

&quot;The decoding IDL attribute must *reflect* the decoding content attribute, *limited to only known values.&quot;  (https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decoding)

with *reflect* linking to the extensive documentation of the reflection process: https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes

&gt; 
&gt; I like the one based on an enumeration. The original motivation was to cut
&gt; down on mistakes in repetitive code so generating more seems good.
&gt; 
&gt; But the example looks wordy so I’m a little concerned.
&gt; 
&gt; I guess there are two ways to think about this. One is “set as a string, but
&gt; get as an enumeration”. Another is “set the content attribute but get the
&gt; effective value”. When you think about it the second way, what you want is
&gt; to implement a getter that shares the logic with whatever code parses the
&gt; value. It’s not part of the binding exactly. It’s part of the attribute
&gt; parsing.
&gt; 
&gt; One option is that you write the getter but it returns an enum value, not a
&gt; string. This makes it more likely that the same getter can be used inside
&gt; the element class implementation.
&gt; 
&gt; I think “ReflectWithCustomGetter” is kind of a funny way to put it because
&gt; “custom getter” is just normal. Maybe “ReflectSetterOnly” is better?
&gt; 
&gt; Really looking for a way to avoid handwriting all these parsers for
&gt; attribute values. That really does point towards the enum style because
&gt; that’s effectively what an enum does; just normally the string part stays
&gt; entirely in the binding layer but for attributes the parsing is needed any
&gt; time the attribute changes.
&gt; 
&gt; My goal would be to not write the “parse for expected values” code.
&gt; 
&gt; Maybe syntax for defining the content attribute itself, not just the binding?

This last point really speaks to me. There is a lot of code in WebCore that we could probably generate if we didn&apos;t think of this as solely a bindings problem. Just as we started generating more CSS code with the introduction of CSSProperties.json, this leads me to think it is at least worth investigating adding Elements.json (or maybe HTMLElement.json as it is likely scoped pretty narrowly, but I am not sure) where we could describe the elements and their attributes and start generating help functions where necessary. What I am envisioning is something like (very rough):

{
    ...
    &quot;img&quot; : {
        &quot;class&quot; : &quot;HTMLImageElement&quot;,
        &quot;content-attributes&quot;: {
             &quot;alt: { ... },
             &quot;src: { ... },
             ...
             &quot;decoding: {
                 &quot;enumerated&quot;: {
                     &quot;values&quot;: [&quot;sync&quot;, &quot;async&quot;, &quot;auto&quot;],
                     &quot;missing&quot;: &quot;auto&quot;,
                     &quot;invalid&quot;: &quot;auto&quot;,
                 },
                 &quot;status&quot;: &quot;supported&quot;,
                 &quot;specification&quot;: {
                     &quot;category&quot;: &quot;html&quot;,
                     &quot;url&quot;: &quot;https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-decoding&quot;
                 }
             }
        }
}

You get the idea. This could then be used to generate things like the HTMLImageElement::decodingMode() function, and be used as input to bindings generation for defining reflection details when needed.

This also has the benefit of allowing us to add something like https://webkit.org/css-status/ (which is generated from CSSProperties.json) for HTMLElements/attributes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005390</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-01-16 13:49:45 -0800</bug_when>
    <thetext>&lt;rdar://problem/121075155&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>401973</attachid>
            <date>2020-06-15 20:51:41 -0700</date>
            <delta_ts>2020-06-15 20:51:41 -0700</delta_ts>
            <desc>WIP</desc>
            <filename>img.diff</filename>
            <type>text/plain</type>
            <size>2447</size>
            <attacher name="Sam Weinig">sam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL2h0bWwvSFRNTEltYWdlRWxlbWVudC5jcHAKPT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PQotLS0gU291cmNlL1dlYkNvcmUvaHRtbC9IVE1MSW1hZ2VFbGVtZW50LmNwcAkocmV2aXNpb24g
MjYzMDQ0KQorKysgU291cmNlL1dlYkNvcmUvaHRtbC9IVE1MSW1hZ2VFbGVtZW50LmNwcAkod29y
a2luZyBjb3B5KQpAQCAtNjc3LDYgKzY3NywyOSBAQCBib29sIEhUTUxJbWFnZUVsZW1lbnQ6OmNv
bXBsZXRlKCkgY29uc3QKICAgICByZXR1cm4gbV9pbWFnZUxvYWRlci0+aW1hZ2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