<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#c7">Comment # 7</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#c4">comment #4</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=269073&amp;action=diff" name="attach_269073" title="Patch v1">attachment 269073</a> <a href="attachment.cgi?id=269073&amp;action=edit" title="Patch v1">[details]</a></span>
&gt; Patch v1
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=269073&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=269073&amp;action=review</a>
&gt; 
&gt; This patch A WebKit2 Owner will need to review this patch since it affects
&gt; WebKit2.
&gt; 
&gt; &gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:1
&gt; &gt; +&lt;p&gt;This tests that the Address Book AutoFill button renders. It can only be tested in the test tool.&lt;/p&gt;
&gt; 
&gt; Please add &lt;!DOCTYPE html&gt; to the top of this file.</span >

I was using the change in <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Allow adding a button in input elements for auto fill related functionality"
   href="show_bug.cgi?id=142564">https://bugs.webkit.org/show_bug.cgi?id=142564</a> as a reference, but I could add &lt;!DOCTYPE html&gt;.

<span class="quote">&gt; 
&gt; &gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:6
&gt; &gt; +&lt;div id='container'&gt;
&gt; &gt; +    &lt;input type='text'&gt;
&gt; &gt; +    &lt;input type='text' name='first_name'&gt;
&gt; &gt; +    &lt;input type='text' name='last_name'&gt;
&gt; &gt; +&lt;/div&gt;
&gt; 
&gt; We seem to use single quoted literals throughout this markup and double
&gt; quoted literals below. I suggest we use double quoted literals. Regardless,
&gt; we should pick one quoting style and stick with it throughout this file.</span >

Ditto. I will stick with double quote and make it consistent in existing AutoFill tests.

<span class="quote">&gt; 
&gt; &gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:8
&gt; &gt; +
&gt; 
&gt; Please remove this empty line as I do not feel it improves the readability
&gt; of this file.</span >

Sure.

<span class="quote">&gt; 
&gt; &gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:16
&gt; &gt; +    document.querySelector(&quot;#container&quot;).appendChild(dynamicInput);
&gt; 
&gt; This is OK as-is. I would have written this as:
&gt; 
&gt; document.getElementById(&quot;container&quot;).appendChild(dynamicInput);</span >

Then I leave as-is unless you feel strongly about it.

<span class="quote">&gt; 
&gt; &gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:20
&gt; &gt; +    document.querySelector(&quot;#container&quot;).appendChild(dynamicInput2);
&gt; 
&gt; This is OK as-is. I would have written this as:
&gt; 
&gt; document.getElementById(&quot;container&quot;).appendChild(dynamicInput2);</span >

Ditto.

<span class="quote">&gt; 
&gt; &gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:26
&gt; &gt; +    dynamicInput3.setAttribute(&quot;name&quot;, &quot;phone_number&quot;);
&gt; 
&gt; This is OK as-is. I would have written this as:
&gt; 
&gt; document.getElementById(&quot;container&quot;).appendChild(dynamicInput3);</span >

Ditto.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/ChangeLog:11
&gt; &gt; +        Test: fast/forms/auto-fill-button/input-address-book-auto-fill-button.html
&gt; &gt; +
&gt; &gt; +        Add a new AutoFill button that can be shown in &lt;input&gt; elements.
&gt; 
&gt; Swap the order of these such that the description (line 11) is before the
&gt; line that mentions the added test (line 9) to conform to the format of a
&gt; ChangeLog entry. An example of this formatting can be seen on page
&gt; &lt;<a href="https://webkit.org/contributing-code/#changelog-files">https://webkit.org/contributing-code/#changelog-files</a>&gt;.</span >

Will do.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/ChangeLog:32
&gt; &gt; +        (WebCore::InputType::updateAutoFillButton): Add a new parameter to specify what the type
&gt; 
&gt; Nit: I suggest removing the word &quot;what&quot; to make this sentence read well.
&gt; Alternatively, add the word &quot;is&quot; to the end of this sentence.</span >

Oops, I forgot the &quot;is&quot;, but I will remove the &quot;what&quot;.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/ChangeLog:43
&gt; &gt; +        Add a new parameter to specify what the type of the AutoFill button.
&gt; 
&gt; Ditto.</span >

Ditto.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/ChangeLog:47
&gt; &gt; +        (WebCore::stringToAutoFillButtonType): Convert the string the AutoFill button type enum.
&gt; 
&gt; Nit: This sentence does not read well.</span >

Changed to &quot;Convert the string to AutoFill button type.&quot;

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/ChangeLog:48
&gt; &gt; +        (WebCore::Internals::setShowAutoFillButton): Add a new parameter to specify what the type of the AutoFill button.
&gt; 
&gt; Nit: I suggest removing the word &quot;what&quot; to make this sentence read well.
&gt; Alternatively, add the word &quot;is&quot; to the end of this sentence.</span >

Oops, I forgot the &quot;is&quot;, but I will remove the &quot;what&quot;.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/html/HTMLTextFormControlElement.h:37
&gt; &gt; +enum AutoFillButtonType { AutoFillButtonTypeCredentials, AutoFillButtonTypeAddressBook };
&gt; 
&gt; Please make this an enum class whose width is uint32_t (to match the width
&gt; of the enum WKAutoFillButtonType defined in WKBundleNodeHandlePrivate.h).
&gt; Among the benefits of using an enum class we can remove the prefix
&gt; AutoFillButtonType from the names of the enumerators since they are scoped.
&gt; So, we can rename the enumerators to Credentials (maybe a better name would
&gt; be Password - singular) and AddressBook, respectively.</span >

Do you mean I should do something like:

enum class AutoFillButtonType : uint32_t {
Credentials,
AddressBook
};

The reason why I did not use enum class is that I got compiler error when I used enum class in internals.idl, should I just use enum in internals.idl and use enum class else where?

The word Credentials was picked because it described the AutoFill type more accurately, since not only was password field AutoFilled, but username field as well.

<span class="quote">&gt; 
&gt; On another note, can we move this definition to HTMLInputElement.h?</span >

The reason why I put the enum in HTMLTextFormControlElement.h is that both HTMLInputElement.h and InputType.h already includes HTMLTextFormControlElement.h, but not one another. If I declare the enum in HTMLInputElement.h, I would need to include HTMLInputElement.h in InputType.h from InputType.cpp, do you think this is preferred approach?

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/html/TextFieldInputType.cpp:627
&gt; &gt; +    ASSERT(autoFillButtonType == AutoFillButtonTypeCredentials || autoFillButtonType == AutoFillButtonTypeAddressBook);
&gt; &gt; +    if (autoFillButtonType != AutoFillButtonTypeCredentials &amp;&amp; autoFillButtonType != AutoFillButtonTypeAddressBook)
&gt; &gt; +        return;
&gt; &gt;  
&gt; &gt;      m_autoFillButton = AutoFillButtonElement::create(element().document(), *this);
&gt; &gt; -    m_autoFillButton-&gt;setPseudo(AtomicString(&quot;-webkit-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));
&gt; &gt; +    if (autoFillButtonType == AutoFillButtonTypeCredentials)
&gt; &gt; +        m_autoFillButton-&gt;setPseudo(AtomicString(&quot;-webkit-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));
&gt; &gt; +    else if (autoFillButtonType == AutoFillButtonTypeAddressBook)
&gt; &gt; +        m_autoFillButton-&gt;setPseudo(AtomicString(&quot;-webkit-address-book-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));
&gt; 
&gt; We should take advantage of AutoFillButtonType being a enum/enum class and
&gt; use a switch statement without a default case to cause a compile time error
&gt; (instead of using a runtime assertion) when a new button type is added
&gt; without updating this code:
&gt; 
&gt; m_autoFillButton = AutoFillButtonElement::create(element().document(),
&gt; *this);
&gt; AtomicString pseudoClassName;
&gt; switch (autoFillButtonType) {
&gt; case AddressBook:
&gt;     pseudoClassName = AtomicString(&quot;-webkit-address-book-auto-fill-button&quot;,
&gt; AtomicString::ConstructFromLiteral));
&gt;     break;
&gt; case Password:
&gt;     pseudoClassName  = AtomicString(&quot;-webkit-auto-fill-button&quot;,
&gt; AtomicString::ConstructFromLiteral));
&gt;     break;
&gt; }
&gt; m_autoFillButton-&gt;setPseudo(pseudoClassName);</span >

Will do.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/testing/Internals.cpp:1286
&gt; &gt; +    if (autoFillButtonType == &quot;AutoFillButtonTypeCredentials&quot;)
&gt; &gt; +        return AutoFillButtonTypeCredentials;
&gt; &gt; +    if (autoFillButtonType == &quot;AutoFillButtonTypeAddressBook&quot;)
&gt; &gt; +        return AutoFillButtonTypeAddressBook;
&gt; &gt; +    ASSERT_NOT_REACHED();
&gt; &gt; +    return AutoFillButtonTypeCredentials;
&gt; 
&gt; Similarly we should use a switch statement here without a default case. Then
&gt; we can remove the ASSERT_NOT_REACHED().</span >

Will do.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/testing/Internals.idl:62
&gt; &gt; +    &quot;AutoFillButtonTypeCredentials&quot;,
&gt; &gt; +    &quot;AutoFillButtonTypeAddressBook&quot;
&gt; 
&gt; Please switch the order of these enumerators such that they are sorted
&gt; according to the UNIX sort command.</span >

Will do.

<span class="quote">&gt; 
&gt; &gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:39
&gt; &gt; +static WebCore::AutoFillButtonType convertToAutoFillButtonType(WKAutoFillButtonType autoFillButtonType)
&gt; 
&gt; We tend to name such WebKit to WebCore conversion functions of the form toX
&gt; where X is the type. So, I would name this function toAutoFillButtonType()
&gt; and name the argument wkAutoFillButtonType.</span >

Will do.

<span class="quote">&gt; 
&gt; &gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:41
&gt; &gt; +    ASSERT(autoFillButtonType == WKAutoFillButtonTypeAddressBook || autoFillButtonType == WKAutoFillButtonTypeCredentials);
&gt; 
&gt; I do not see the value in having this ASSERT() given the presence of
&gt; ASSERT_NOT_REACHED() below (line 47).</span >

True.

<span class="quote">&gt; 
&gt; &gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:48
&gt; &gt; +    if (autoFillButtonType == WKAutoFillButtonTypeAddressBook)
&gt; &gt; +        return WebCore::AutoFillButtonTypeAddressBook;
&gt; &gt; +    if (autoFillButtonType == WKAutoFillButtonTypeCredentials)
&gt; &gt; +        return WebCore::AutoFillButtonTypeCredentials;
&gt; &gt; +    ASSERT_NOT_REACHED();
&gt; &gt; +    return WebCore::AutoFillButtonTypeCredentials;
&gt; 
&gt; I would write this as:
&gt; 
&gt; switch (wkAutoFillButtonType) {
&gt; case WKAutoFillButtonTypeAddressBook:
&gt;     return WebCore::AutoFillButtonTypeAddressBook;
&gt; case WKAutoFillButtonTypeCredentials:
&gt;    return WebCore::AutoFillButtonTypeCredentials;
&gt; }
&gt; ASSERT_NOT_REACHED();
&gt; return WebCore::AutoFillButtonTypeCredentials;</span >

Looks better. Will change.

<span class="quote">&gt; 
&gt; &gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:38
&gt; &gt; +enum WKAutoFillButtonType { WKAutoFillButtonTypeCredentials, WKAutoFillButtonTypeAddressBook };
&gt; 
&gt; In the C API we seem to prefer using an anonymous enum, a typedef to
&gt; represent an enumeration, and prefix enumerator values with &quot;kWK&quot;. Renaming
&gt; WKAutoFillButtonTypeCredentials and WKAutoFillButtonTypeAddressBook to
&gt; kWKAutoFillButtonTypePassword and kWKAutoFillButtonTypeAddressBook, I would
&gt; write this declaration as:
&gt; 
&gt; enum {
&gt;    kWKAutoFillButtonCredentials,
&gt;    kWKAutoFillButtonTypeAddressBook
&gt; };
&gt; typedef uint32_t WKAutoFillButtonType;</span >

So here we are not using enum class anymore?

<span class="quote">&gt; 
&gt; &gt; Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:32
&gt; &gt; +#include &lt;WebCore/HTMLTextFormControlElement.h&gt;
&gt; 
&gt; We should forward declare AutoFillButtonType here instead of including
&gt; HTMLTextFormControlElement.h.</span >

Forward declaring AutoFillButtonType means I should declare enum AutoFillButtonType before the class declaration so that I don't need to include HTMLTextFormControlElement.h?</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>