<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Need ability to specify alternate image for AutoFill button in input fields"
   href="https://bugs.webkit.org/show_bug.cgi?id=153116#c21">Comment # 21</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Need ability to specify alternate image for AutoFill button in input fields"
   href="https://bugs.webkit.org/show_bug.cgi?id=153116">bug 153116</a>
              from <span class="vcard"><a class="email" href="mailto:zacharyli323&#64;gmail.com" title="Zach Li &lt;zacharyli323&#64;gmail.com&gt;"> <span class="fn">Zach Li</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=153116#c20">comment #20</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=269831&amp;action=diff" name="attach_269831" title="Patch v3">attachment 269831</a> <a href="attachment.cgi?id=269831&amp;action=edit" title="Patch v3">[details]</a></span>
&gt; Patch v3
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=269831&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=269831&amp;action=review</a>
&gt; 
&gt; Code is OK. Still one significant problem with it (no way to remove the
&gt; auto-fill button), and a number of questionable points of style.
&gt; 
&gt; &gt; Source/WebCore/html/HTMLTextFormControlElement.h:37
&gt; &gt; +enum class AutoFillButtonType : uint8_t { Uninitialized, Credentials, Contacts };
&gt; 
&gt; I think that the first value is None, not Uninitialized. It means no
&gt; auto-fill button at all, not “uninitialized”.</span >

I didn't think Uninitialized was a good word choice, but I couldn't think of something better. I will use None.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/html/TextFieldInputType.cpp:643
&gt; &gt; +    AtomicString pseudoClassName = autoFillButtonTypeToAutoFillButtonPseudoClassName(autoFillButtonType);
&gt; &gt; +    m_autoFillButton-&gt;setPseudo(pseudoClassName);
&gt; 
&gt; Would read better without a local variable as a single line.</span >

Will combine these two lines.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/html/TextFieldInputType.cpp:654
&gt; &gt; +            createAutoFillButton(element().autoFillButtonType());
&gt; 
&gt; Missing code to remove the auto-fill button if the type changes from
&gt; contacts or credentials to none.</span >

If the type changes from contacts or credentials to none, the button will not be displayed with the code, which is our existing approach when we set show AutoFill button to false:

m_autoFillButton-&gt;setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);

This works and I don't think we have to actually remove the AutoFill button.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/html/TextFieldInputType.cpp:657
&gt; &gt; +        AtomicString pseudoContactsAutoFillClassName = AtomicString(&quot;-webkit-contacts-auto-fill-button&quot;, AtomicString::ConstructFromLiteral);
&gt; &gt; +        AtomicString pseudoCredentialsAutoFillClassName = AtomicString(&quot;-webkit-credentials-auto-fill-button&quot;, AtomicString::ConstructFromLiteral);
&gt; 
&gt; This is a unnecessarily slow way to write the code. You can just write
&gt; attribute == &quot;-webkit-contacts-auto-fill-button&quot;; no need to do all the
&gt; extra work to create an atomic string.</span >

I see. I will just compare the string with the `attribute`.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/html/TextFieldInputType.cpp:658
&gt; &gt; +        AtomicString attribute = m_autoFillButton-&gt;getAttribute(pseudoAttr);
&gt; 
&gt; Wrong type here. It should be auto&amp;, or const AtomicString&amp; to avoid
&gt; unnecessary work.</span >

Will change to const AtomicString&amp;.

<span class="quote">&gt; 
&gt; Wrong function called here. It should be fastGetAttribute.</span >

Will use fastGetAttribute.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/html/TextFieldInputType.cpp:659
&gt; &gt; +        bool shouldUpdateAutoFillButtonType = ((attribute == pseudoContactsAutoFillClassName &amp;&amp; element().autoFillButtonType() != AutoFillButtonType::Contacts) || (attribute == pseudoCredentialsAutoFillClassName &amp;&amp; element().autoFillButtonType() != AutoFillButtonType::Credentials));
&gt; 
&gt; This is really hard to read. I think a helper function would make it easier
&gt; to read. But I also don’t understand why we wouldn’t just call setPseudo
&gt; unconditionally. Are we trying to optimize something?</span >

I don't want to call setPseudo when the button type was not changed, or is this an unnecessary optimization?

Thanks for your review!</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>