<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - We should also store the time information for recent searches"
   href="https://bugs.webkit.org/show_bug.cgi?id=148388">bug 148388</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 #262822 Flags</td>
           <td>review?
           </td>
           <td>review-
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - We should also store the time information for recent searches"
   href="https://bugs.webkit.org/show_bug.cgi?id=148388#c37">Comment # 37</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - We should also store the time information for recent searches"
   href="https://bugs.webkit.org/show_bug.cgi?id=148388">bug 148388</a>
              from <span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=262822&amp;action=diff" name="attach_262822" title="Patch">attachment 262822</a> <a href="attachment.cgi?id=262822&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=262822&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=262822&amp;action=review</a>

General looks really good. I’d love to say review+ but there is still a bit of wrong code here.

<span class="quote">&gt; Source/WebCore/platform/SearchPopupMenu.h:36
&gt; +class PopupMenu;</span >

Normally we’d put a forward declaration before something defined in this file, so this would be slightly better above RecentSearch.

<span class="quote">&gt; Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:52
&gt; +static RetainPtr&lt;NSMutableDictionary&gt;readSearchFieldRecentSearchesPlist()</span >

Missing space here before the word &quot;read&quot;.

<span class="quote">&gt; Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:56
&gt; +    if (![[recentSearchesPlist classForCoder] isSubclassOfClass:[NSMutableDictionary class]])
&gt; +        return nil;</span >

I don’t understand what good this check does. Seems like this should just be removed. -[NSMutableDictionary initWithContentsOfFile:] is guaranteed to return a mutable dictionary or nil; no need to double check that the dictionary is mutable.

<span class="quote">&gt; Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:96
&gt; +        NSMutableDictionary *itemsDictionary = [recentSearchesPlist objectForKey:itemsKey];
&gt; +        if ([[itemsDictionary classForCoder] isSubclassOfClass:[NSMutableDictionary class]])
&gt; +            [itemsDictionary setObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:items.get(), searchesKey, nil] forKey:name];
&gt; +        else
&gt; +            [recentSearchesPlist setObject:[NSMutableDictionary dictionary] forKey:itemsKey];</span >

I don’t think this code is correct.

The use of classForCoder seems a peculiar way to check if a dictionary is mutable; the best practice is *not* to check but guarantee it is mutable. Typically by using mutableCopy on a dictionary.

More importantly, if -[NSMutableDictionary initWithContentsOfFile:] does not guarantee it creates all mutable collections, then we’d want to make a mutable copy of an immutable dictionary we find, not throw it away and make a new empty dictionary.

And finally, it looks like else part of the if does this completely wrong. It uses the items array as a key, not a value!

Did we test this? How?

<span class="quote">&gt; Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:137
&gt; +        searchItems.append({ String { searchString }, toSystemClockTime(date) });</span >

No space after String before the &quot;{&quot; as I mentioned in my last review.

<span class="quote">&gt; Source/WebCore/platform/win/SearchPopupMenuWin.cpp:95
&gt; +            searchItems.append({ String { item }, std::chrono::system_clock::time_point::min() });</span >

No space after String before the &quot;{&quot; as I mentioned in my last 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>