RESOLVED FIXED 188174
[WinCairo] Search terms are not saved for <input type="search">
https://bugs.webkit.org/show_bug.cgi?id=188174
Summary [WinCairo] Search terms are not saved for <input type="search">
Stephan Szabo
Reported 2018-07-30 10:33:45 PDT
Search type inputs are not saving the recent search terms.
Attachments
Patch (3.38 KB, patch)
2018-07-30 13:28 PDT, Stephan Szabo
no flags
Patch (4.14 KB, patch)
2018-07-31 10:48 PDT, Stephan Szabo
no flags
Archive of layout-test-results from ews205 for win-future (13.09 MB, application/zip)
2018-07-31 16:40 PDT, EWS Watchlist
no flags
Patch (4.40 KB, patch)
2018-08-06 14:19 PDT, Stephan Szabo
achristensen: review-
Save search inputs to filesystem (7.88 KB, patch)
2018-10-11 15:29 PDT, Stephan Szabo
Hironori.Fujii: review-
Save windows search inputs to sqlite db (17.14 KB, patch)
2018-10-17 13:06 PDT, Stephan Szabo
no flags
Save windows search inputs to sqlite db fixed newline (375 bytes, patch)
2018-10-17 13:11 PDT, Stephan Szabo
no flags
Save windows search inputs to sqlite db fixed newline (17.11 KB, patch)
2018-10-17 13:13 PDT, Stephan Szabo
no flags
Save windows search inputs to sqlite db (17.14 KB, patch)
2018-10-17 15:00 PDT, Stephan Szabo
Hironori.Fujii: review-
Save windows search inputs to sqlite db (17.34 KB, patch)
2018-10-18 14:45 PDT, Stephan Szabo
Hironori.Fujii: review-
Save windows search inputs to sqlite db (20.79 KB, patch)
2018-10-19 11:35 PDT, Stephan Szabo
no flags
Stephan Szabo
Comment 1 2018-07-30 13:28:00 PDT
Alex Christensen
Comment 2 2018-07-30 13:29:56 PDT
Comment on attachment 346093 [details] Patch Is there a way we could do this without using CF?
Stephan Szabo
Comment 3 2018-07-30 13:39:48 PDT
We should be able to save them elsewhere rather than CF, will update.
Stephan Szabo
Comment 4 2018-07-31 10:48:08 PDT
Stephan Szabo
Comment 5 2018-07-31 10:48:56 PDT
Updated to save search terms to registry rather than using CF.
EWS Watchlist
Comment 6 2018-07-31 16:39:48 PDT
Comment on attachment 346178 [details] Patch Attachment 346178 [details] did not pass win-ews (win): Output: https://webkit-queues.webkit.org/results/8715524 New failing tests: imported/blink/transitions/unprefixed-transform.html legacy-animation-engine/imported/blink/transitions/unprefixed-transform.html
EWS Watchlist
Comment 7 2018-07-31 16:40:01 PDT
Created attachment 346220 [details] Archive of layout-test-results from ews205 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews205 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Fujii Hironori
Comment 8 2018-08-05 20:32:21 PDT
WK1 and WK2 of Cocoa port shares saveRecentSearches. Unfortunately, WK1 of Windows port is using CF. https://github.com/WebKit/webkit/blob/7ba360682b81ec26924a602eaabc6f038e0140f1/Source/WebCore/platform/win/SearchPopupMenuWin.cpp#L58
Fujii Hironori
Comment 9 2018-08-05 20:59:06 PDT
Comment on attachment 346178 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=346178&action=review > Source/WebKit/UIProcess/win/WebPageProxyWin.cpp:62 > + if (size) { You don't need "if (size)" because the following 'for' skips if size is zero. > Source/WebKit/UIProcess/win/WebPageProxyWin.cpp:65 > + if (::RegSetValueEx(key, std::to_wstring(i).c_str(), 0, REG_SZ, reinterpret_cast<const BYTE*>(searchItems[i].string.characters16()), searchItems[i].string.length() * sizeof(UChar)) != ERROR_SUCCESS) According to the spec, you should include the size of the terminating null character. You should use stringToNullTerminatedWChar. https://docs.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regsetvalueexw > cbData > The size of the information pointed to by the lpData parameter, in bytes. If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of the terminating null character or characters. > Source/WebKit/UIProcess/win/WebPageProxyWin.cpp:80 > + if (::RegCreateKeyEx(HKEY_CURRENT_USER, keyName.characters16(), 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &key, nullptr) != ERROR_SUCCESS) You should use stringToNullTerminatedWChar. > Source/WebKit/UIProcess/win/WebPageProxyWin.cpp:101 > + auto buff = std::make_unique<BYTE[]>(size); WTF has makeUniqueArray which is using fastMalloc. > Source/WebKit/UIProcess/win/WebPageProxyWin.cpp:104 > + Why do you want to remove the comment? I think it should be preserved to explain WallTime::infinity. // We are choosing not to use or store search times on Windows at this time, so for now it's OK to use a "distant past" time as a placeholder.
Stephan Szabo
Comment 10 2018-08-06 14:19:30 PDT
Alex Christensen
Comment 11 2018-08-06 16:08:08 PDT
Comment on attachment 346656 [details] Patch I think in the Windows registry is a bad place to save recent searches. It makes it hard to clear. Shouldn't we just put it in a file on disk somewhere?
Fujii Hironori
Comment 12 2018-08-06 18:38:52 PDT
I think WK1 and WK2 of WinCairo port should share the implementation of saveRecentSearches as well as Cocoa port does.
Stephan Szabo
Comment 13 2018-08-07 10:01:54 PDT
(In reply to Alex Christensen from comment #11) > Comment on attachment 346656 [details] > Patch > > I think in the Windows registry is a bad place to save recent searches. It > makes it hard to clear. Shouldn't we just put it in a file on disk > somewhere? I wasn't entirely sure that sticking a file in the user's local application data would be better, but it seems like there's already data there for indexeddb and localstorage so that seems fine.
Stephan Szabo
Comment 14 2018-08-07 10:02:24 PDT
(In reply to Fujii Hironori from comment #12) > I think WK1 and WK2 of WinCairo port should share the implementation of > saveRecentSearches as well as Cocoa port does. Should we do that as part of this, or make the new non-CF implementation and then update WK1 separately?
Alex Christensen
Comment 15 2018-08-07 10:20:49 PDT
Comment on attachment 346656 [details] Patch application data directory is much better for this sort of thing than the registry. Implementations ought to be shared, and ideally wouldn't use CF.
Stephan Szabo
Comment 16 2018-10-11 15:29:07 PDT
Created attachment 352094 [details] Save search inputs to filesystem Sorry about the long delay, had internal items then vacation. Switching to using filesystem for the storage and replacing the SearchPopupMenuWin implementation as well. Need to see if this is happy for win.
Fujii Hironori
Comment 17 2018-10-14 19:31:35 PDT
Comment on attachment 352094 [details] Save search inputs to filesystem View in context: https://bugs.webkit.org/attachment.cgi?id=352094&action=review > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:25 > +#include <WebCore/UserAgent.h> Do you need to include <WebCore/UserAgent.h> in this file? > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:58 > + file.append(name); Can `name` contain '/', '\', or '..'? How much is the maximum length? How do you think the idea using single SQLite database, for example 'search.db' instead of many files? > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:72 > +void saveRecentSearches(const String& name, const Vector<WebCore::RecentSearch>& searchItems) I think you shouldn't use 'WebCore::' in WebCore. > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:91 > + auto nullTerminatedSearchItem = WTF::stringToNullTerminatedWChar(searchItems[i].string); Remove 'WTF::' because there is using statement. https://github.com/WebKit/webkit/blob/2fde85661b4bf2a3ad6344694401d91e9220e99e/Source/WTF/wtf/text/win/WCharStringExtras.h#L68
Stephan Szabo
Comment 18 2018-10-17 13:06:58 PDT
Created attachment 352625 [details] Save windows search inputs to sqlite db
EWS Watchlist
Comment 19 2018-10-17 13:09:02 PDT
Attachment 352625 [details] did not pass style-queue: ERROR: Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:301: Could not find a newline character at the end of the file. [whitespace/ending_newline] [5] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Stephan Szabo
Comment 20 2018-10-17 13:11:46 PDT
Created attachment 352626 [details] Save windows search inputs to sqlite db fixed newline
Stephan Szabo
Comment 21 2018-10-17 13:13:40 PDT
Created attachment 352627 [details] Save windows search inputs to sqlite db fixed newline
Stephan Szabo
Comment 22 2018-10-17 15:00:56 PDT
Created attachment 352647 [details] Save windows search inputs to sqlite db A version that saves to a sqlite db. I'd initially thought it might be overkill vs plain file, but it actually wasn't too bad.
Fujii Hironori
Comment 23 2018-10-17 21:00:32 PDT
Comment on attachment 352647 [details] Save windows search inputs to sqlite db View in context: https://bugs.webkit.org/attachment.cgi?id=352647&action=review > Source/WebCore/PlatformWin.cmake:105 > + platform/win/SearchPopupMenuWinDB.cpp This is almost platform independent. Remove 'Win'. It is OK for me to put this file in this platform/win/ dir until other ports reuse this. > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:25 > +#include <WebCore/FileSystem.h> Do you use <WebCore/FileSystem.h> in this file? > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:27 > +#include <wtf/text/win/WCharStringExtras.h> Do you use <wtf/text/win/WCharStringExtras.h> in this file? > Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:35 > +static const String createSearchTableSQL { String ctor calls fastMalloc. Do not define String global variables. Use WTF::ASCIILiteral instead. > static constexpr auto createSearchTableSQL = "..."_s; > Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:38 > + " ind INTEGER NOT NULL," ind -> index https://webkit.org/code-style-guidelines/#names-full-words > Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:58 > + static SearchPopupMenuDB inst; inst -> instance https://webkit.org/code-style-guidelines/#names-full-words > Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:81 > + SQLiteTransaction xact(m_database, false); xact -> transaction https://webkit.org/code-style-guidelines/#names-full-words > Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:82 > + auto rem = getPreparedStatement(removeSearchTermsForNameSQL); https://webkit.org/code-style-guidelines/#names-full-words > Source/WebCore/platform/win/SearchPopupMenuWinDB.h:43 > + static WEBCORE_EXPORT SearchPopupMenuDB &instance(); instance -> singleton https://webkit.org/code-style-guidelines/#singleton-static-member > Source/WebCore/platform/win/SearchPopupMenuWinDB.h:63 > + HashMap<String, std::unique_ptr<SQLiteStatement>> m_statements; Do you really need this HashMap? https://trac.webkit.org/wiki/InvestigatingLeaksAndBloat > m_loadSearchTermsForNameStatement = createPreparedStatement(loadSearchTermsForNameSQL);
Fujii Hironori
Comment 24 2018-10-17 21:03:53 PDT
Comment on attachment 352647 [details] Save windows search inputs to sqlite db View in context: https://bugs.webkit.org/attachment.cgi?id=352647&action=review > Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:119 > + // We are choosing not to use or store search times on Windows at thistime, so for now it's OK to use a "distant past" time as a placeholder. thistime -> this time
Stephan Szabo
Comment 25 2018-10-18 09:49:14 PDT
(In reply to Fujii Hironori from comment #23) > Comment on attachment 352647 [details] > Save windows search inputs to sqlite db > > View in context: > https://bugs.webkit.org/attachment.cgi?id=352647&action=review Just updating for most of these, but a few comments. > > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:25 > > +#include <WebCore/FileSystem.h> > > Do you use <WebCore/FileSystem.h> in this file? Yes, I'm using pathByAppendingComponent and localUserSpecificStorageDirectory to generate the database file location. > > Source/WebCore/platform/win/SearchPopupMenuWinDB.cpp:38 > > + " ind INTEGER NOT NULL," > > ind -> index > https://webkit.org/code-style-guidelines/#names-full-words Index is a reserved word in SQL, so we cannot name a column index (we could use "index" with the double quotes, but that becomes a bit of a mess). I'll change the name to position or something like that. > > Source/WebCore/platform/win/SearchPopupMenuWinDB.h:63 > > + HashMap<String, std::unique_ptr<SQLiteStatement>> m_statements; > > Do you really need this HashMap? > https://trac.webkit.org/wiki/InvestigatingLeaksAndBloat Since there's only a few specific statements, we can probably do without it as you mention. If this somehow ended up with a ton of statements it might be a problem, but that seems unlikely.
Stephan Szabo
Comment 26 2018-10-18 09:56:32 PDT
(In reply to Stephan Szabo from comment #25) > (In reply to Fujii Hironori from comment #23) > > Comment on attachment 352647 [details] > > Save windows search inputs to sqlite db > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=352647&action=review > > Just updating for most of these, but a few comments. > > > > Source/WebCore/platform/win/SearchPopupMenuWin.cpp:25 > > > +#include <WebCore/FileSystem.h> > > > > Do you use <WebCore/FileSystem.h> in this file? > > Yes, I'm using pathByAppendingComponent and > localUserSpecificStorageDirectory to generate the database file location. Sorry, looked back now and had misremembered that I moved the file location out to the DB cpp as well. Will kill that too.
Stephan Szabo
Comment 27 2018-10-18 14:45:39 PDT
Created attachment 352735 [details] Save windows search inputs to sqlite db Removed extra includes Renamed the db file source to remove win Switched to explicit statements rather than hashmap Updated variable names Switched ind -> position in sql database Fixed missing space in comment
Fujii Hironori
Comment 28 2018-10-18 18:16:54 PDT
Comment on attachment 352735 [details] Save windows search inputs to sqlite db View in context: https://bugs.webkit.org/attachment.cgi?id=352735&action=review Look good to me. Please add ChangeLog entry. I need to review it, too, to mark r+. > Source/WebCore/platform/win/SearchPopupMenuDB.cpp:89 > + for (const auto &search : searches) { Nit: auto& https://webkit.org/code-style-guidelines/#pointers-cpp
Fujii Hironori
Comment 29 2018-10-18 18:18:40 PDT
Comment on attachment 352735 [details] Save windows search inputs to sqlite db View in context: https://bugs.webkit.org/attachment.cgi?id=352735&action=review > Source/WebCore/platform/win/SearchPopupMenuDB.h:43 > + static WEBCORE_EXPORT SearchPopupMenuDB &singleton(); Nit: SearchPopupMenuDB& https://webkit.org/code-style-guidelines/#pointers-cpp
Stephan Szabo
Comment 30 2018-10-19 11:35:33 PDT
Created attachment 352810 [details] Save windows search inputs to sqlite db
WebKit Commit Bot
Comment 31 2018-10-19 17:03:28 PDT
Comment on attachment 352810 [details] Save windows search inputs to sqlite db Clearing flags on attachment: 352810 Committed r237308: <https://trac.webkit.org/changeset/237308>
WebKit Commit Bot
Comment 32 2018-10-19 17:03:30 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 33 2018-10-19 17:04:37 PDT
Note You need to log in before you can comment on or make changes to this bug.