<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:darin@apple.com" title="Darin Adler <darin@apple.com>"> <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@apple.com" title="Darin Adler <darin@apple.com>"> <span class="fn">Darin Adler</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=262822&action=diff" name="attach_262822" title="Patch">attachment 262822</a> <a href="attachment.cgi?id=262822&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=262822&action=review">https://bugs.webkit.org/attachment.cgi?id=262822&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">> Source/WebCore/platform/SearchPopupMenu.h:36
> +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">> Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:52
> +static RetainPtr<NSMutableDictionary>readSearchFieldRecentSearchesPlist()</span >
Missing space here before the word "read".
<span class="quote">> Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:56
> + if (![[recentSearchesPlist classForCoder] isSubclassOfClass:[NSMutableDictionary class]])
> + 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">> Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:96
> + NSMutableDictionary *itemsDictionary = [recentSearchesPlist objectForKey:itemsKey];
> + if ([[itemsDictionary classForCoder] isSubclassOfClass:[NSMutableDictionary class]])
> + [itemsDictionary setObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:items.get(), searchesKey, nil] forKey:name];
> + else
> + [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">> Source/WebCore/platform/cocoa/SearchPopupMenuCocoa.mm:137
> + searchItems.append({ String { searchString }, toSystemClockTime(date) });</span >
No space after String before the "{" as I mentioned in my last review.
<span class="quote">> Source/WebCore/platform/win/SearchPopupMenuWin.cpp:95
> + searchItems.append({ String { item }, std::chrono::system_clock::time_point::min() });</span >
No space after String before the "{" 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>