<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:dbates&#64;webkit.org" title="Daniel Bates &lt;dbates&#64;webkit.org&gt;"> <span class="fn">Daniel Bates</span></a>
</span> changed
              <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>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #269073 Flags</td>
           <td>review?
           </td>
           <td>review-
           </td>
         </tr></table>
      <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#c4">Comment # 4</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:dbates&#64;webkit.org" title="Daniel Bates &lt;dbates&#64;webkit.org&gt;"> <span class="fn">Daniel Bates</span></a>
</span></b>
        <pre>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>
Patch v1

View in context: <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>

This patch A WebKit2 Owner will need to review this patch since it affects WebKit2.

<span class="quote">&gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:1
&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;</span >

Please add &lt;!DOCTYPE html&gt; to the top of this file.

<span class="quote">&gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:6
&gt; +&lt;div id='container'&gt;
&gt; +    &lt;input type='text'&gt;
&gt; +    &lt;input type='text' name='first_name'&gt;
&gt; +    &lt;input type='text' name='last_name'&gt;
&gt; +&lt;/div&gt;</span >

We seem to use single quoted literals throughout this markup and double quoted literals below. I suggest we use double quoted literals. Regardless, we should pick one quoting style and stick with it throughout this file.

<span class="quote">&gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:8
&gt; +</span >

Please remove this empty line as I do not feel it improves the readability of this file.

<span class="quote">&gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:16
&gt; +    document.querySelector(&quot;#container&quot;).appendChild(dynamicInput);</span >

This is OK as-is. I would have written this as:

document.getElementById(&quot;container&quot;).appendChild(dynamicInput);

<span class="quote">&gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:20
&gt; +    document.querySelector(&quot;#container&quot;).appendChild(dynamicInput2);</span >

This is OK as-is. I would have written this as:

document.getElementById(&quot;container&quot;).appendChild(dynamicInput2);

<span class="quote">&gt; LayoutTests/fast/forms/auto-fill-button/input-address-book-auto-fill-button.html:26
&gt; +    dynamicInput3.setAttribute(&quot;name&quot;, &quot;phone_number&quot;);</span >

This is OK as-is. I would have written this as:

document.getElementById(&quot;container&quot;).appendChild(dynamicInput3);

<span class="quote">&gt; Source/WebCore/ChangeLog:11
&gt; +        Test: fast/forms/auto-fill-button/input-address-book-auto-fill-button.html
&gt; +
&gt; +        Add a new AutoFill button that can be shown in &lt;input&gt; elements.</span >

Swap the order of these such that the description (line 11) is before the line that mentions the added test (line 9) to conform to the format of a ChangeLog entry. An example of this formatting can be seen on page &lt;<a href="https://webkit.org/contributing-code/#changelog-files">https://webkit.org/contributing-code/#changelog-files</a>&gt;.

<span class="quote">&gt; Source/WebCore/ChangeLog:32
&gt; +        (WebCore::InputType::updateAutoFillButton): Add a new parameter to specify what the type</span >

Nit: I suggest removing the word &quot;what&quot; to make this sentence read well. Alternatively, add the word &quot;is&quot; to the end of this sentence.

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

Ditto.

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

Nit: This sentence does not read well.

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

Nit: I suggest removing the word &quot;what&quot; to make this sentence read well. Alternatively, add the word &quot;is&quot; to the end of this sentence.

<span class="quote">&gt; Source/WebCore/html/HTMLTextFormControlElement.h:37
&gt; +enum AutoFillButtonType { AutoFillButtonTypeCredentials, AutoFillButtonTypeAddressBook };</span >

Please make this an enum class whose width is uint32_t (to match the width of the enum WKAutoFillButtonType defined in WKBundleNodeHandlePrivate.h). Among the benefits of using an enum class we can remove the prefix AutoFillButtonType from the names of the enumerators since they are scoped. So, we can rename the enumerators to Credentials (maybe a better name would be Password - singular) and AddressBook, respectively.

On another note, can we move this definition to HTMLInputElement.h?

<span class="quote">&gt; Source/WebCore/html/TextFieldInputType.cpp:627
&gt; +    ASSERT(autoFillButtonType == AutoFillButtonTypeCredentials || autoFillButtonType == AutoFillButtonTypeAddressBook);
&gt; +    if (autoFillButtonType != AutoFillButtonTypeCredentials &amp;&amp; autoFillButtonType != AutoFillButtonTypeAddressBook)
&gt; +        return;
&gt;  
&gt;      m_autoFillButton = AutoFillButtonElement::create(element().document(), *this);
&gt; -    m_autoFillButton-&gt;setPseudo(AtomicString(&quot;-webkit-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));
&gt; +    if (autoFillButtonType == AutoFillButtonTypeCredentials)
&gt; +        m_autoFillButton-&gt;setPseudo(AtomicString(&quot;-webkit-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));
&gt; +    else if (autoFillButtonType == AutoFillButtonTypeAddressBook)
&gt; +        m_autoFillButton-&gt;setPseudo(AtomicString(&quot;-webkit-address-book-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));</span >

We should take advantage of AutoFillButtonType being a enum/enum class and use a switch statement without a default case to cause a compile time error (instead of using a runtime assertion) when a new button type is added without updating this code:

m_autoFillButton = AutoFillButtonElement::create(element().document(), *this);
AtomicString pseudoClassName;
switch (autoFillButtonType) {
case AddressBook:
    pseudoClassName = AtomicString(&quot;-webkit-address-book-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));
    break;
case Password:
    pseudoClassName  = AtomicString(&quot;-webkit-auto-fill-button&quot;, AtomicString::ConstructFromLiteral));
    break;
}
m_autoFillButton-&gt;setPseudo(pseudoClassName);

<span class="quote">&gt; Source/WebCore/testing/Internals.cpp:1286
&gt; +    if (autoFillButtonType == &quot;AutoFillButtonTypeCredentials&quot;)
&gt; +        return AutoFillButtonTypeCredentials;
&gt; +    if (autoFillButtonType == &quot;AutoFillButtonTypeAddressBook&quot;)
&gt; +        return AutoFillButtonTypeAddressBook;
&gt; +    ASSERT_NOT_REACHED();
&gt; +    return AutoFillButtonTypeCredentials;</span >

Similarly we should use a switch statement here without a default case. Then we can remove the ASSERT_NOT_REACHED().

<span class="quote">&gt; Source/WebCore/testing/Internals.idl:62
&gt; +    &quot;AutoFillButtonTypeCredentials&quot;,
&gt; +    &quot;AutoFillButtonTypeAddressBook&quot;</span >

Please switch the order of these enumerators such that they are sorted according to the UNIX sort command.

<span class="quote">&gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:39
&gt; +static WebCore::AutoFillButtonType convertToAutoFillButtonType(WKAutoFillButtonType autoFillButtonType)</span >

We tend to name such WebKit to WebCore conversion functions of the form toX where X is the type. So, I would name this function toAutoFillButtonType() and name the argument wkAutoFillButtonType.

<span class="quote">&gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:41
&gt; +    ASSERT(autoFillButtonType == WKAutoFillButtonTypeAddressBook || autoFillButtonType == WKAutoFillButtonTypeCredentials);</span >

I do not see the value in having this ASSERT() given the presence of ASSERT_NOT_REACHED() below (line 47).

<span class="quote">&gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:48
&gt; +    if (autoFillButtonType == WKAutoFillButtonTypeAddressBook)
&gt; +        return WebCore::AutoFillButtonTypeAddressBook;
&gt; +    if (autoFillButtonType == WKAutoFillButtonTypeCredentials)
&gt; +        return WebCore::AutoFillButtonTypeCredentials;
&gt; +    ASSERT_NOT_REACHED();
&gt; +    return WebCore::AutoFillButtonTypeCredentials;</span >

I would write this as:

switch (wkAutoFillButtonType) {
case WKAutoFillButtonTypeAddressBook:
    return WebCore::AutoFillButtonTypeAddressBook;
case WKAutoFillButtonTypeCredentials:
   return WebCore::AutoFillButtonTypeCredentials;
}
ASSERT_NOT_REACHED();
return WebCore::AutoFillButtonTypeCredentials;

<span class="quote">&gt; Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:38
&gt; +enum WKAutoFillButtonType { WKAutoFillButtonTypeCredentials, WKAutoFillButtonTypeAddressBook };</span >

In the C API we seem to prefer using an anonymous enum, a typedef to represent an enumeration, and prefix enumerator values with &quot;kWK&quot;. Renaming WKAutoFillButtonTypeCredentials and WKAutoFillButtonTypeAddressBook to kWKAutoFillButtonTypePassword and kWKAutoFillButtonTypeAddressBook, I would write this declaration as:

enum {
   kWKAutoFillButtonCredentials,
   kWKAutoFillButtonTypeAddressBook
};
typedef uint32_t WKAutoFillButtonType;

<span class="quote">&gt; Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:32
&gt; +#include &lt;WebCore/HTMLTextFormControlElement.h&gt;</span >

We should forward declare AutoFillButtonType here instead of including 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>