e8592ce9efce7fac62aa5e0ff0ac679001396ceb
[WebKit.git] / Source / WebKit / ChangeLog
1 2019-10-10  youenn fablet  <youenn@apple.com>
2
3         [Mac] Allow SYS___pthread_markcancel call
4         https://bugs.webkit.org/show_bug.cgi?id=202723
5
6         Reviewed by Alex Christensen.
7
8         Allow this pthread call as libwebrtc uses it on the Mac as well.
9
10         * WebProcess/com.apple.WebProcess.sb.in:
11
12 2019-10-09  youenn fablet  <youenn@apple.com>
13
14         A service worker process should not be created when enqueuing a service worker job
15         https://bugs.webkit.org/show_bug.cgi?id=202578
16         <rdar://problem/55979690>
17
18         Reviewed by Chris Dumez.
19
20         Remove the calls to create service worker context connection.
21         They are now done at SWServer level when trying to either run a service worker or install one.
22
23         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
24         (WebKit::WebSWServerConnection::startFetch):
25         (WebKit::WebSWServerConnection::postMessageToServiceWorker):
26         (WebKit::WebSWServerConnection::scheduleJobInServer):
27
28 2019-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
29
30         [Clipboard API] Refactor Pasteboard item reading functions to work on both iOS and macOS
31         https://bugs.webkit.org/show_bug.cgi?id=202647
32
33         Reviewed by Tim Horton.
34
35         Refactor iOS-specific pasteboard functions to be platform-agnostic. See WebCore ChangeLog for more details.
36
37         * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
38         (WebKit::WebPasteboardProxy::allPasteboardItemInfo):
39         (WebKit::WebPasteboardProxy::informationForItemAtIndex):
40         (WebKit::WebPasteboardProxy::getPasteboardItemsCount):
41         (WebKit::WebPasteboardProxy::readStringFromPasteboard):
42         (WebKit::WebPasteboardProxy::readURLFromPasteboard):
43         (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
44         (WebKit::WebPasteboardProxy::writeURLToPasteboard):
45         (WebKit::WebPasteboardProxy::writeWebContentToPasteboard):
46         (WebKit::WebPasteboardProxy::writeImageToPasteboard):
47         (WebKit::WebPasteboardProxy::writeStringToPasteboard):
48         * UIProcess/WebPasteboardProxy.cpp:
49         (WebKit::WebPasteboardProxy::allPasteboardItemInfo):
50         (WebKit::WebPasteboardProxy::informationForItemAtIndex):
51         (WebKit::WebPasteboardProxy::getPasteboardItemsCount):
52         (WebKit::WebPasteboardProxy::readStringFromPasteboard):
53         (WebKit::WebPasteboardProxy::readURLFromPasteboard):
54         (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
55         * UIProcess/WebPasteboardProxy.h:
56         * UIProcess/WebPasteboardProxy.messages.in:
57         * UIProcess/wpe/WebPasteboardProxyWPE.cpp:
58         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
59         (WebKit::WebPlatformStrategies::informationForItemAtIndex):
60         (WebKit::WebPlatformStrategies::readBufferFromPasteboard):
61         (WebKit::WebPlatformStrategies::readURLFromPasteboard):
62         (WebKit::WebPlatformStrategies::readStringFromPasteboard):
63         (WebKit::WebPlatformStrategies::writeToPasteboard):
64         (WebKit::WebPlatformStrategies::updateSupportedTypeIdentifiers):
65         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
66
67 2019-10-09  John Wilander  <wilander@apple.com>
68
69         IsLoggedIn: Add as experimental feature
70         https://bugs.webkit.org/show_bug.cgi?id=202707
71         <rdar://problem/56095064>
72
73         Reviewed by Brent Fulgham and Chris Dumez.
74
75         IsLoggedIn was proposed to the WebAppSec WG at TPAC 2019.
76         So far there is only an explainer posted to the mailing list:
77         https://lists.w3.org/Archives/Public/public-webappsec/2019Sep/0004.html
78
79         * Shared/WebPreferences.yaml:
80
81 2019-10-09  Jiewen Tan  <jiewen_tan@apple.com>
82
83         [WebAuthn] Move the mock testing entrance to Internals
84         https://bugs.webkit.org/show_bug.cgi?id=202560
85         <rdar://problem/55973793>
86
87         Reviewed by Chris Dumez.
88
89         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
90         (WKWebsiteDataStoreSetWebAuthenticationMockConfiguration): Deleted.
91         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
92         * UIProcess/WebAuthentication/AuthenticatorTransportService.cpp:
93         (WebKit::AuthenticatorTransportService::createMock):
94         * UIProcess/WebAuthentication/AuthenticatorTransportService.h:
95         * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp:
96         (WebKit::MockAuthenticatorManager::MockAuthenticatorManager):
97         * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h:
98         * UIProcess/WebAuthentication/Mock/MockHidConnection.cpp:
99         (WebKit::MockHidConnection::send):
100         (WebKit::MockHidConnection::registerDataReceivedCallbackInternal):
101         (WebKit::MockHidConnection::parseRequest):
102         (WebKit::MockHidConnection::feedReports):
103         (WebKit::MockHidConnection::shouldContinueFeedReports):
104         * UIProcess/WebAuthentication/Mock/MockHidConnection.h:
105         * UIProcess/WebAuthentication/Mock/MockHidService.cpp:
106         (WebKit::MockHidService::MockHidService):
107         * UIProcess/WebAuthentication/Mock/MockHidService.h:
108         * UIProcess/WebAuthentication/Mock/MockLocalConnection.h:
109         * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
110         (WebKit::MockLocalConnection::MockLocalConnection):
111         * UIProcess/WebAuthentication/Mock/MockLocalService.h:
112         * UIProcess/WebAuthentication/Mock/MockLocalService.mm:
113         (WebKit::MockLocalService::MockLocalService):
114         * UIProcess/WebAuthentication/Mock/MockNfcService.h:
115         * UIProcess/WebAuthentication/Mock/MockNfcService.mm:
116         (WebKit::MockNfcService::MockNfcService):
117         (WebKit::MockNfcService::platformStartDiscovery):
118         (WebKit::MockNfcService::detectTags const):
119         * UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h: Removed.
120         * UIProcess/WebPageProxy.cpp:
121         (WebKit::WebPageProxy::setMockWebAuthenticationConfiguration):
122         * UIProcess/WebPageProxy.h:
123         * UIProcess/WebPageProxy.messages.in:
124         * UIProcess/WebsiteData/WebsiteDataStore.h:
125         * WebKit.xcodeproj/project.pbxproj:
126         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
127         (WebKit::WebChromeClient::setMockWebAuthenticationConfiguration):
128         * WebProcess/WebCoreSupport/WebChromeClient.h:
129
130 2019-10-09  Simon Fraser  <simon.fraser@apple.com>
131
132         Rename WheelEventTestTrigger and improve naming in related code
133         https://bugs.webkit.org/show_bug.cgi?id=202772
134
135         Reviewed by Tim Horton.
136
137         Change the "test trigger" terminology to "monitor wheel events"; after all, tests
138         call monitorWheelEvents() and callAfterScrollingCompletes(), and this is not triggering
139         a test.
140
141         * UIProcess/API/C/WKPage.cpp:
142         (WKPageClearWheelEventTestMonitor):
143         (WKPageClearWheelEventTestTrigger): Deleted.
144         * UIProcess/API/C/WKPage.h:
145         * UIProcess/WebPageProxy.cpp:
146         (WebKit::WebPageProxy::clearWheelEventTestMonitor):
147         (WebKit::WebPageProxy::clearWheelEventTestTrigger): Deleted.
148         * UIProcess/WebPageProxy.h:
149         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
150         (WKBundlePageStartMonitoringScrollOperations):
151         (WKBundlePageRegisterScrollOperationCompletionCallback):
152         * WebProcess/Plugins/PDF/PDFPlugin.mm:
153         (WebKit::PDFPlugin::createScrollbar):
154         * WebProcess/WebPage/EventDispatcher.cpp:
155         * WebProcess/WebPage/WebPage.cpp:
156         (WebKit::WebPage::clearWheelEventTestMonitor):
157         (WebKit::WebPage::clearWheelEventTestTrigger): Deleted.
158         * WebProcess/WebPage/WebPage.h:
159         * WebProcess/WebPage/WebPage.messages.in:
160
161 2019-10-09  Andy Estes  <aestes@apple.com>
162
163         [Cocoa] IPC::decode should gracefully handle a nil allowed class
164         https://bugs.webkit.org/show_bug.cgi?id=202753
165
166         Reviewed by Geoffrey Garen.
167
168         If IPC::decode is called with a nil allowed class, an NSInvalidArgumentException will be
169         thrown when trying to create an NSArray literal with a nil value. Depending on who calls
170         IPC::decode, this exception might or might not be caught, leading to dropped messages or
171         crashes.
172
173         One case of this happening is tracked by rdar://problem/55839467. In this case, the nil
174         allowed class was due to a build misconfiguration, and the exception caused the UI process
175         to not respond to a synchronous IPC message, hanging the WebContent process.
176
177         rdar://problem/55839467 was resolved by fixing the build misconfiguration, but this patch
178         improves IPC::decode so that a nil allowed class results in a message decoding failure
179         rather than a maybe-caught NSException.
180
181         * Shared/Cocoa/ArgumentCodersCocoa.h:
182         (IPC::decode):
183
184 2019-10-09  youenn fablet  <youenn@apple.com>
185
186         Remove testRunner.setWebRTCUnifiedPlanEnabled
187         https://bugs.webkit.org/show_bug.cgi?id=202700
188
189         Reviewed by Eric Carlson.
190
191         * WebProcess/InjectedBundle/InjectedBundle.cpp:
192         (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
193
194 2019-10-09  Carlos Garcia Campos  <cgarcia@igalia.com>
195
196         REGRESSION(r250597): [GTK][WPE] 2.27.1 shows HTML content as text/plain in custom protocols when passing a charset in content type
197         https://bugs.webkit.org/show_bug.cgi?id=202633
198
199         Reviewed by Žan Doberšek.
200
201         This is a regression of the switch to use the new custom protocols implementation. Before r250597, we extracted
202         the mime type and charset from content type in the network process, but we are now sending the response directly
203         from the UI process, so we need to do that when building our response. Rename the mime_type parameter as
204         content_type to avoid confusion, since it's documented as the content type.
205
206         * UIProcess/API/glib/WebKitURISchemeRequest.cpp:
207         (webkitURISchemeRequestReadCallback):
208         (webkit_uri_scheme_request_finish):
209         * UIProcess/API/gtk/WebKitURISchemeRequest.h:
210         * UIProcess/API/wpe/WebKitURISchemeRequest.h:
211
212 2019-10-09  Carlos Garcia Campos  <cgarcia@igalia.com>
213
214         [GTK][WPE] about:gpu should also show the client EGL extensions
215         https://bugs.webkit.org/show_bug.cgi?id=202690
216
217         Reviewed by Carlos Alberto Lopez Perez.
218
219         We are showing the extensions supported by the display.
220
221         * UIProcess/API/glib/WebKitProtocolHandler.cpp:
222         (WebKit::WebKitProtocolHandler::handleGPU):
223
224 2019-10-09  Carlos Garcia Campos  <cgarcia@igalia.com>
225
226         CustomProtocols: convert log messages in WebURLSchemeTaskProxy to RELEASE_LOG
227         https://bugs.webkit.org/show_bug.cgi?id=202686
228
229         Reviewed by Alex Christensen.
230
231         Instead of using WTFLogAlways, since those messages are confusing on stdout.
232
233         * WebProcess/WebPage/WebURLSchemeTaskProxy.cpp:
234         (WebKit::WebURLSchemeTaskProxy::didPerformRedirection):
235         (WebKit::WebURLSchemeTaskProxy::didReceiveResponse):
236         (WebKit::WebURLSchemeTaskProxy::didReceiveData):
237
238 2019-10-09  Carlos Garcia Campos  <cgarcia@igalia.com>
239
240         [WPE][GTK] WebKitSecurityManager should consider webkit:// to be a local URI scheme
241         https://bugs.webkit.org/show_bug.cgi?id=202638
242
243         Reviewed by Michael Catanzaro.
244
245         * UIProcess/API/glib/WebKitProtocolHandler.cpp:
246         (WebKit::WebKitProtocolHandler::WebKitProtocolHandler):
247
248 2019-10-08  Antti Koivisto  <antti@apple.com>
249
250         [CSS Shadow Parts] Enable by default
251         https://bugs.webkit.org/show_bug.cgi?id=202644
252
253         Reviewed by Ryosuke Niwa.
254
255         * Shared/WebPreferences.yaml:
256
257         Flip the switch.
258
259 2019-10-08  Andy Estes  <aestes@apple.com>
260
261         [iOS] Add a fast path that avoids hit testing during context menu interactions on elements
262         https://bugs.webkit.org/show_bug.cgi?id=202510
263         <rdar://problem/55939313>
264
265         Reviewed by Tim Horton.
266
267         When computing position information for an element, we can store sufficient context
268         information in InteractionInformationAtPosition such that the same element could be
269         retrieved again without hit testing. The existing TextInputContext can already store an
270         element's page identifier, document identifier, and element identifier, which is sufficient
271         context for such a task.
272
273         This patch renames TextInputContext to ElementContext and uses it when populating new
274         InteractionInformationAtPosition structs in elementPositionInformation(). When a context
275         menu interaction occurs, WebPage::startInteractionWithElementContextOrPosition() uses this
276         context to look up the interaction element by its identifier triplet, falling back to hit
277         testing if this lookup fails.
278
279         * Scripts/webkit/messages.py:
280         * Shared/DocumentEditingContext.h:
281         * Shared/DocumentEditingContext.mm:
282         (IPC::ArgumentCoder<WebKit::DocumentEditingContextRequest>::decode):
283         * Shared/ElementContext.cpp: Renamed from Source/WebKit/Shared/TextInputContext.cpp.
284         (IPC::ArgumentCoder<WebKit::ElementContext>::encode):
285         (IPC::ArgumentCoder<WebKit::ElementContext>::decode):
286         * Shared/ElementContext.h: Renamed from Source/WebKit/Shared/TextInputContext.h.
287         (WebKit::operator==):
288         * Shared/ios/InteractionInformationAtPosition.h:
289         * Shared/ios/InteractionInformationAtPosition.mm:
290         (WebKit::InteractionInformationAtPosition::encode const):
291         (WebKit::InteractionInformationAtPosition::decode):
292         * Sources.txt:
293         * UIProcess/API/Cocoa/WKWebView.mm:
294         (-[WKWebView _requestTextInputContextsInRect:completionHandler:]):
295         * UIProcess/API/Cocoa/_WKTextInputContext.mm:
296         (-[_WKTextInputContext _initWithTextInputContext:]):
297         (-[_WKTextInputContext _textInputContext]):
298         * UIProcess/API/Cocoa/_WKTextInputContextInternal.h:
299         * UIProcess/WebPageProxy.cpp:
300         (WebKit::WebPageProxy::textInputContextsInRect):
301         (WebKit::WebPageProxy::focusTextInputContext):
302         * UIProcess/WebPageProxy.h:
303         * UIProcess/ios/WKContentViewInteraction.mm:
304         (-[WKContentView actionSheetAssistant:willStartInteractionWithElement:]):
305         (-[WKContentView assignLegacyDataForContextMenuInteraction]):
306         (-[WKContentView continueContextMenuInteraction:]):
307         (-[WKContentView continueContextMenuInteractionWithDataDetectors:]):
308         (-[WKContentView _presentedViewControllerForPreviewItemController:]):
309         * UIProcess/ios/WebPageProxyIOS.mm:
310         (WebKit::WebPageProxy::startInteractionWithPositionInformation):
311         (WebKit::WebPageProxy::startInteractionWithElementAtPosition): Deleted.
312         * WebKit.xcodeproj/project.pbxproj:
313         * WebProcess/WebPage/WebPage.cpp:
314         (WebKit::WebPage::textInputContextsInRect):
315         (WebKit::WebPage::focusTextInputContext):
316         (WebKit::WebPage::elementForContext const):
317         (WebKit::WebPage::contextForElement const):
318         (WebKit::WebPage::elementForTextInputContext): Deleted.
319         * WebProcess/WebPage/WebPage.h:
320         * WebProcess/WebPage/WebPage.messages.in:
321         * WebProcess/WebPage/ios/WebPageIOS.mm:
322         (WebKit::elementPositionInformation):
323         (WebKit::WebPage::startInteractionWithElementContextOrPosition):
324         (WebKit::WebPage::requestDocumentEditingContext):
325         (WebKit::WebPage::startInteractionWithElementAtPosition): Deleted.
326
327 2019-10-08  Adrian Perez de Castro  <aperez@igalia.com>
328
329         Unreviewed. Update OptionsWPE.cmake and NEWS for the 2.27.1 release
330
331         * wpe/NEWS: Add release notes for 2.27.1
332
333 2019-10-08  Kate Cheney  <katherine_cheney@apple.com>
334
335         Implement Telemetry and Dumping Routines for SQLite backend (195088)
336         https://bugs.webkit.org/show_bug.cgi?id=195088
337         <rdar://problem/54213407>
338
339         Reviewed by John Wilander.
340
341         Implemented database telemetry calculating for ITP. Mimicked
342         ResourceLoadStatisticsMemoryStore telemetry logging behavior using
343         SQLite Queries as opposed to vector sorting/manipulation. Once fully
344         integrated, this will simplify analysis of ITP data by transitioning
345         ITP data storage from a plist to a SQLite database.
346
347         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
348         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
349         Added SQL queries to be initialized in the constructor. These queries
350         are needed to mimic the telemetry calculations done in
351         ResourceLoadStatisticsMemoryStore.
352         
353         (WebKit::resetStatement):
354         To reduce code duplication, this function holds common code to reset
355         a SQL query.
356
357         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements):
358         Added SQL queries needed for telemetry calculations to be prepared.
359         
360         (WebKit::joinSubStatisticsForSorting):
361         This function returns the query string for sorting resources that is
362         shared by many queries.
363
364         (WebKit::ResourceLoadStatisticsDatabaseStore::getMedianOfPrevalentResourcesWithUserInteraction const):
365         Implemented a function to take the median days since user interaction
366         from all prevalent resources in the database with user interaction
367         (sorted by max count of subframes, subresources and unique redirects under
368         the top frame domain).
369
370         (WebKit::ResourceLoadStatisticsDatabaseStore::getNumberOfPrevalentResources const):
371         Executes a SQL query to get the number of prevalent resources to log as
372         telemetry.
373
374         (WebKit::ResourceLoadStatisticsDatabaseStore::getNumberOfPrevalentResourcesWithUI const):
375         Executes a SQL query to get the number of prevalent resources with user
376         interaction to log as telemetry.
377
378         (WebKit::ResourceLoadStatisticsDatabaseStore::getTopPrevelentResourceDaysSinceUI const):
379         Prepares and executes a SQL query to get the days since user
380         interaction from the top prevalent resource to be recorded as
381         telemetry data.
382
383         (WebKit::ResourceLoadStatisticsDatabaseStore::getMedianStatisticOfPrevalentResourceWithoutUserInteraction const):
384         Implemented a function which takes a statistic and returns the value
385         of that statistic for the median prevalent resource without user
386         interaction to be recorded as telemetry data.
387
388         (WebKit::ResourceLoadStatisticsDatabaseStore::getNumberOfPrevalentResourcesInTopResources const):
389         Returns the count of prevalent resources in the top x resources
390         sorted by sum of substatistics again to be logged as telemetry.
391
392         (WebKit::ResourceLoadStatisticsDatabaseStore::calculateTelemetryData const):
393         Function which executes all functions which populate the struct with
394         telemetry data. This struct will then be passed to
395         WebResourceLoadStatisticsTelemetry to be logged.
396
397         (WebKit::ResourceLoadStatisticsDatabaseStore::calculateAndSubmitTelemetry const):
398         Initializes the telemetry struct and calls the function to populate
399         it, then passes it to the WebResourceLoadStatisticsTelemetry object
400         to be recorded.
401
402         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
403         Describe PrevalentResourceDatabaseTelemetry Struct to be passed and
404         logged as telemetry data.
405
406         * NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp:
407         (WebKit::databaseSubmitTopLists):
408         Logging telemetry data by looping through 2D array of statistics for
409         the top 1, 3, 10, 50, and 100 prevalent resources sorted by the sum
410         of substatistics under the top frame domain. This matches the logging
411         already done in ResourceLoadStatisticsMemoryStore.
412
413         (WebKit::WebResourceLoadStatisticsTelemetry::submitTelemetry):
414         Submits data to the webPageProxy logs and plists.
415
416         * NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.h:
417         Added new submitTopList function to accomodate database telemetry
418         logging.
419         
420         * NetworkProcess/NetworkSession.cpp:
421         (WebKit::NetworkSession::notifyPageStatisticsTelemetryFinished):
422         * NetworkProcess/NetworkSession.h:
423         * UIProcess/Network/NetworkProcessProxy.cpp:
424         (WebKit::NetworkProcessProxy::notifyResourceLoadStatisticsTelemetryFinished):
425         * UIProcess/Network/NetworkProcessProxy.h:
426         * UIProcess/Network/NetworkProcessProxy.messages.in:
427         Updated the current testing for telemetry which only tested 3
428         statistics. With this patch it now tests 10 statistics.
429
430 2019-10-08  Adrian Perez de Castro  <aperez@igalia.com>
431
432         [GTK][WPE] Fix non-unified builds after r250486
433         https://bugs.webkit.org/show_bug.cgi?id=202636
434
435         Reviewed by Youenn Fablet.
436
437         * NetworkProcess/NetworkConnectionToWebProcess.cpp: Add missing inclusion of the
438         Logging.h header.
439
440 2019-10-08  Brady Eidson  <beidson@apple.com>
441
442         Service Worker Fetch events should time out.
443         https://bugs.webkit.org/show_bug.cgi?id=202188
444
445         Reviewed by Alex Christensen.
446
447         When we start a fetch task in the server, we also start a timeout on that fetch task.
448         
449         "Time out" means the fetch task must continue to make progress at the given frequency (once every 60 seconds by default)
450
451         If any given fetch task times out in a service worker instance, that instance loses the right to handle fetches.
452         
453         * NetworkProcess/NetworkProcess.cpp:
454         (WebKit::NetworkProcess::setServiceWorkerFetchTimeoutForTesting):
455         (WebKit::NetworkProcess::resetServiceWorkerFetchTimeoutForTesting):
456         * NetworkProcess/NetworkProcess.h:
457         (WebKit::NetworkProcess::serviceWorkerFetchTimeout const):
458         * NetworkProcess/NetworkProcess.messages.in:
459
460         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
461         (WebKit::ServiceWorkerFetchTask::ServiceWorkerFetchTask):
462         (WebKit::ServiceWorkerFetchTask::didReceiveRedirectResponse): 
463         (WebKit::ServiceWorkerFetchTask::didReceiveResponse): 
464         (WebKit::ServiceWorkerFetchTask::didReceiveData): 
465         (WebKit::ServiceWorkerFetchTask::didReceiveFormData): 
466         (WebKit::ServiceWorkerFetchTask::didFinish): 
467         (WebKit::ServiceWorkerFetchTask::didFail): 
468         (WebKit::ServiceWorkerFetchTask::didNotHandle): 
469         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h:
470         (WebKit::ServiceWorkerFetchTask::create):
471         (WebKit::ServiceWorkerFetchTask::serviceWorkerIdentifier const):
472         (WebKit::ServiceWorkerFetchTask::wasHandled const):
473         (WebKit::ServiceWorkerFetchTask::ServiceWorkerFetchTask): Deleted.
474
475         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
476         (WebKit::WebSWServerConnection::startFetch):
477         * NetworkProcess/ServiceWorker/WebSWServerConnection.h:
478
479         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
480         (WebKit::WebSWServerToContextConnection::startFetch):
481         (WebKit::WebSWServerToContextConnection::fetchTaskTimedOut):
482         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
483
484         * UIProcess/API/C/WKContext.cpp:
485         (WKContextSetServiceWorkerFetchTimeoutForTesting):
486         (WKContextResetServiceWorkerFetchTimeoutForTesting):
487         * UIProcess/API/C/WKContext.h:
488
489         * UIProcess/WebProcessPool.cpp:
490         (WebKit::WebProcessPool::setServiceWorkerTimeoutForTesting):
491         (WebKit::WebProcessPool::resetServiceWorkerTimeoutForTesting):
492         * UIProcess/WebProcessPool.h:
493
494 2019-10-08  Ross Kirsling  <ross.kirsling@sony.com>
495
496         Unreviewed. Restabilize non-unified build.
497
498         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
499
500 2019-10-08  Dean Jackson  <dino@apple.com>
501
502         Sort Internal and Experimental features by human readable name
503         https://bugs.webkit.org/show_bug.cgi?id=202667
504
505         Reviewed by Zalan Bujtas.
506
507         Sort the statically generated vectors of internal and
508         experimental features by their human readable name, rather than
509         the feature key, so that looking at them in the Settings app
510         doesn't make people who like alphabetical order angry.
511
512         * Scripts/GeneratePreferences.rb: Add an extra sort call to the list generation.
513
514 2019-10-08  Wenson Hsieh  <wenson_hsieh@apple.com>
515
516         [Clipboard API] Introduce bindings for the async Clipboard API
517         https://bugs.webkit.org/show_bug.cgi?id=202622
518         <rdar://problem/56038126>
519
520         Reviewed by Ryosuke Niwa.
521
522         Adds a new experimental feature flag. See WebCore ChangeLog for more details.
523
524         * Shared/WebPreferences.yaml:
525
526 2019-10-08  Alexander Mikhaylenko  <alexm@gnome.org>
527
528         [GTK] Navigation gesture improvements
529         https://bugs.webkit.org/show_bug.cgi?id=202645
530
531         Reviewed by Carlos Garcia Campos.
532
533         Measure velocity threshold in pixels per second rather than distance (range [0-1])
534         per second. The value is the same as it was on touchpads, since a fixed distance is
535         used, but is now consistent on touchscreens, regardless of the webview width.
536
537         Add a threshold for cancelling gesture when the page is more than halfway
538         through, so that it's symmetric with the first half.
539
540         Align the moving page to pixel grid on hidpi devices correctly. Just
541         rounding the position doesn't work correctly, since the cairo context is
542         pre-scaled. Multiplying by scale factor, rounding and then dividing by
543         scale factor fixes this.
544
545         * UIProcess/ViewGestureController.h:
546         * UIProcess/gtk/ViewGestureControllerGtk.cpp:
547         (WebKit::ViewGestureController::SwipeProgressTracker::reset):
548         (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
549         (WebKit::ViewGestureController::SwipeProgressTracker::shouldCancel):
550         (WebKit::ViewGestureController::draw):
551
552 2019-10-08  Carlos Garcia Campos  <cgarcia@igalia.com>
553
554         Unreviewed. Remove unused WebKitSoupRequestGeneric after r250597
555
556         * NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h:
557
558 2019-10-08  Adrian Perez de Castro  <aperez@igalia.com>
559
560         [WPE][GTK] Build fails with ENABLE_WEBDRIVER=OFF
561         https://bugs.webkit.org/show_bug.cgi?id=202658
562
563         Reviewed by Carlos Garcia Campos.
564
565         * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp: Add missing
566         ENABLE(WEBDRIVER_MOUSE_INTERACTIONS) and ENABLE(WEBDRIVER_KEYBOARD_INTERACTIONS)
567         preprocessor guards.
568         * UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp: Ditto.
569
570 2019-10-07  Ryosuke Niwa  <rniwa@webkit.org>
571
572         Add IDL for requestIdleCallback
573         https://bugs.webkit.org/show_bug.cgi?id=202653
574
575         Reviewed by Geoffrey Garen.
576
577         * Shared/WebPreferences.yaml:
578
579 2019-10-07  Kate Cheney  <katherine_cheney@apple.com>
580
581         Domain relationships in the ITP Database should be inserted in a single query and ignore repeat insert attempts. (202604)
582         https://bugs.webkit.org/show_bug.cgi?id=202604
583         <rdar://problem/55995831>
584
585         Reviewed by Chris Dumez. 
586         
587         This patch addresses two clean-ups for the ITP SQLite Database Store.
588         First, by using INSERT OR IGNORE as opposed to INSERT, it eliminates
589         the need to check if a relationship already exists in the database
590         before inserting it. Second, instead of looping through domain lists
591         and inserting each relationship as a separate query, this patch now
592         converts lists to a string which SQLite can use to insert multiple
593         rows into a database using a single query.
594
595         Some Exists queries could not be deleted because they were being
596         used for testing.
597
598         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
599         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
600         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements):
601         Removed old insert queries and replaced them with queries able to
602         insert string-lists of domains in a single query. Also reorganized
603         the queries by functionality to make them easier to find and edit.
604
605         (WebKit::ResourceLoadStatisticsDatabaseStore::createUniqueIndices):
606         (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
607         In order to properly take advantage of the INSERT OR IGNORE
608         functionality, unique indices must be established so the SQLite table
609         is aware of what patterns to look for when ignoring a new insert.
610
611         (WebKit::ResourceLoadStatisticsDatabaseStore::ensureAndmakeDomainList):
612         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationshipList):
613         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
614         Looping through the domain list is no longer needed with the new query
615         changes. Additionally, ensuring a domain is in the Observed Domains
616         table of the database must be done before utilizing any inserting of 
617         relationships because the relationship queries rely on fetching the
618         topFrame domainID from the ObservedDomains table.
619
620         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
621         (WebKit::ResourceLoadStatisticsDatabaseStore::logFrameNavigation):
622         (WebKit::ResourceLoadStatisticsDatabaseStore::logCrossSiteLoadWithLinkDecoration):
623         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubframeUnderTopFrameDomain):
624         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUnderTopFrameDomain):
625         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUniqueRedirectTo):
626         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUniqueRedirectFrom):
627         (WebKit::ResourceLoadStatisticsDatabaseStore::setTopFrameUniqueRedirectTo):
628         (WebKit::ResourceLoadStatisticsDatabaseStore::setTopFrameUniqueRedirectFrom):
629         With the ensure check being done once in the ensureAndmakeDomainList
630         function, these functions no longer have to make that check before
631         inserting.
632         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
633
634         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
635         (WebKit::WebResourceLoadStatisticsStore::mergeStatisticForTesting):
636         (WebKit::WebResourceLoadStatisticsStore::isRelationshipOnlyInDatabaseOnce):
637         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
638         Changes in WeResourceLoadStatisticsStore were for testing only. This
639         patch updated the merge statistic testing to also test this change by
640         having a topFrameDomain list with more than one domain.
641
642         * NetworkProcess/NetworkProcess.cpp:
643         (WebKit::NetworkProcess::mergeStatisticForTesting):
644         (WebKit::NetworkProcess::isRelationshipOnlyInDatabaseOnce):
645         * NetworkProcess/NetworkProcess.h:
646         * NetworkProcess/NetworkProcess.messages.in:
647         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
648         (WKWebsiteDataStoreSetStatisticsMergeStatistic):
649         (WKWebsiteDataStoreIsStatisticsOnlyInDatabaseOnce):
650         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
651         * UIProcess/Network/NetworkProcessProxy.cpp:
652         (WebKit::NetworkProcessProxy::mergeStatisticForTesting):
653         (WebKit::NetworkProcessProxy::isRelationshipOnlyInDatabaseOnce):
654         * UIProcess/Network/NetworkProcessProxy.h:
655         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
656         (WebKit::WebsiteDataStore::mergeStatisticForTesting):
657         (WebKit::WebsiteDataStore::isRelationshipOnlyInDatabaseOnce):
658         * UIProcess/WebsiteData/WebsiteDataStore.h:
659         Added a new function for testing that there are no repeat inserts
660         into the database. Updated mergeStatistics to test the list-insert
661         functionality.
662
663 2019-10-07  Yusuke Suzuki  <ysuzuki@apple.com>
664
665         [JSC] Change signature of HostFunction to (JSGlobalObject*, CallFrame*)
666         https://bugs.webkit.org/show_bug.cgi?id=202569
667
668         Reviewed by Saam Barati.
669
670         * WebProcess/Plugins/Netscape/JSNPMethod.cpp:
671         (WebKit::callMethod):
672         * WebProcess/Plugins/Netscape/JSNPObject.cpp:
673         (WebKit::callNPJSObject):
674         (WebKit::constructWithConstructor):
675         * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h:
676
677 2019-10-07  Megan Gardner  <megan_gardner@apple.com>
678
679         Switch to WKShareSheet for WKPDFView
680         https://bugs.webkit.org/show_bug.cgi?id=202338
681
682         Reviewed by Tim Horton.
683
684         Switch to WKShareSheet from the share sheet in UIWKSelectionAssistant, since this is the only instance
685         of UIWKSelectionAssistant any more. This will keep all our share sheet code together, and allow
686         us to eliminate this class that will be completely unused with this change.
687
688         * Platform/spi/ios/UIKitSPI.h:
689         * UIProcess/ios/WKPDFView.h:
690         * UIProcess/ios/WKPDFView.mm:
691         (-[WKPDFView dealloc]):
692         (-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]):
693         (-[WKPDFView shareSheetDidDismiss:]):
694
695 2019-10-07  Per Arne Vollan  <pvollan@apple.com>
696
697         [macOS] Layering violation in AuxiliaryProcessProxy::didFinishLaunching
698         https://bugs.webkit.org/show_bug.cgi?id=201617
699
700         Reviewed by Brent Fulgham.
701
702         The commit <https://trac.webkit.org/changeset/249649> introduced a layering violation in AuxiliaryProcessProxy::didFinishLaunching
703         where we inspect the pending message queue looking for a local file load message which needs the PID to create a sandbox extension
704         for the WebContent process. The layering violation can be fixed by creating a virtual method in AuxiliaryProcessProxy and override
705         the method in the WebProcessProxy to do the work needed to replace the message with a load request message containing a sandbox
706         extension created using the PID of the WebContent process. No new tests have been created, since this is covered by existing tests.
707
708         * UIProcess/AuxiliaryProcessProxy.cpp:
709         (WebKit::AuxiliaryProcessProxy::didFinishLaunching):
710         * UIProcess/AuxiliaryProcessProxy.h:
711         (WebKit::AuxiliaryProcessProxy::shouldSendPendingMessage):
712         * UIProcess/WebProcessProxy.cpp:
713         (WebKit::WebProcessProxy::shouldSendPendingMessage):
714         * UIProcess/WebProcessProxy.h:
715
716 2019-10-07  Dean Jackson  <dino@apple.com>
717
718         Provide options for DTTZ to happen in more situations
719         https://bugs.webkit.org/show_bug.cgi?id=202634
720         <rdar://problem/55732762>
721
722         Reviewed by Antoine Quint.
723
724         Add two options that can be enabled to trigger double tap zooming 
725         in more places.
726
727         Firstly, an option to keep listening for a double-tap-to-zoom if the
728         first tap found a click handler on the body or document element. The
729         tap will still be dispatched. This is probably the most common case
730         for disabling a DTTZ.
731
732         Secondly, an option to always keep listening for a double-tap-to-zoom,
733         even if there was a clickable (non-root) element under the first tap.
734
735         * Shared/WebPreferences.yaml: Add ZoomOnDoubleTapWhenRoot and AlwaysZoomOnDoubleTap.
736         * UIProcess/PageClient.h: The message from the WebProcess now tells the UIProcess if
737         the tapped element was a root-level (document or body).
738         * UIProcess/WebPageProxy.h:
739         * UIProcess/WebPageProxy.messages.in:
740         * UIProcess/ios/PageClientImplIOS.h:
741         * UIProcess/ios/PageClientImplIOS.mm:
742         (WebKit::PageClientImpl::handleSmartMagnificationInformationForPotentialTap):
743         * UIProcess/ios/WKContentViewInteraction.h:
744         * UIProcess/ios/WKContentViewInteraction.mm:
745         (-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
746         (-[WKContentView _handleSmartMagnificationInformationForPotentialTap:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:nodeIsRootLevel:]):
747         Handle the two new options.
748
749         * UIProcess/ios/WebPageProxyIOS.mm:
750         (WebKit::WebPageProxy::handleSmartMagnificationInformationForPotentialTap):
751         * WebProcess/WebPage/ios/WebPageIOS.mm:
752         (WebKit::WebPage::potentialTapAtPosition): Check if the tap was on a root-level element.
753
754 2019-10-07  Matt Mokary  <mmokary@apple.com>
755
756         foundStringMatchIndex in FindController::findString gets reset on page scroll
757         https://bugs.webkit.org/show_bug.cgi?id=201773
758         <rdar://problem/55351892>
759
760         Reviewed by Tim Horton.
761
762         Decouple hiding of the find indicator from resetting match index, and only reset match index when there is not
763         an active match.
764
765         * WebProcess/WebPage/FindController.cpp:
766         (WebKit::FindController::updateFindUIAfterPageScroll):
767         (WebKit::FindController::hideFindUI):
768         (WebKit::FindController::hideFindIndicator):
769         (WebKit::FindController::resetMatchIndex):
770         * WebProcess/WebPage/FindController.h:
771         * WebProcess/WebPage/ios/FindControllerIOS.mm:
772         (WebKit::FindController::hideFindIndicator):
773         (WebKit::FindController::resetMatchIndex):
774
775 2019-10-07  youenn fablet  <youenn@apple.com>
776
777         WebPageProxy::updatePlayingMediaDidChange should protect from a null m_userMediaPermissionRequestManager
778         https://bugs.webkit.org/show_bug.cgi?id=202628
779         <rdar://problem/55935091>
780
781         Reviewed by Eric Carlson.
782
783         On process swap on navigation or process crash, m_userMediaPermissionRequestManager is made null.
784         At the same time, the media state is set back to not playing.
785         Future calls of updatePlayingMediaDidChange should not have any capture state change until getUserMedia/getDisplayMedia
786         is called, which would create m_userMediaPermissionRequestManager.
787         But this assumption is not always true given that the media state is computed as process-wide in MediaStreamTrack::captureState on iOS.
788         The above behavior is fixed as part of https://bugs.webkit.org/show_bug.cgi?id=202627.
789         Since the call to updatePlayingMediaDidChange is triggered straight from IPC, it should not be trusted and a null check should be added.
790
791         * UIProcess/WebPageProxy.cpp:
792         (WebKit::WebPageProxy::updatePlayingMediaDidChange):
793
794 2019-10-04  Dean Jackson  <dino@apple.com>
795
796         Use a better name than allowFastClicksEverywhere
797         https://bugs.webkit.org/show_bug.cgi?id=202607
798         <rdar://problem/55997133>
799
800         Reviewed by Tim Horton.
801
802         This preference name is quite confusing. Change it to
803         PreferFasterClickOverDoubleTap.
804
805         * Shared/WebPreferences.yaml:
806         * Shared/WebPreferencesDefaultValues.h:
807         * UIProcess/WebPageProxy.h:
808         (WebKit::WebPageProxy::preferFasterClickOverDoubleTap const):
809         (WebKit::WebPageProxy::allowsFastClicksEverywhere const): Deleted.
810         * UIProcess/ios/WKContentViewInteraction.mm:
811         (-[WKContentView _handleSmartMagnificationInformationForPotentialTap:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:]):
812         * UIProcess/ios/WebPageProxyIOS.mm:
813         (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
814
815 2019-10-04  Ross Kirsling  <ross.kirsling@sony.com>
816
817         Socket-based RWI should base64-encode backend commands on client, not server
818         https://bugs.webkit.org/show_bug.cgi?id=202605
819
820         Reviewed by Don Olmstead.
821
822         * UIProcess/socket/RemoteInspectorClient.cpp:
823         (WebKit::RemoteInspectorClient::setBackendCommands):
824
825 2019-10-04  Jiewen Tan  <jiewen_tan@apple.com>
826
827         Unreviewed, build fix after r250729
828
829         * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
830         * UIProcess/API/Cocoa/_WKWebAuthenticationPanelInternal.h:
831
832 2019-10-04  Keith Rollin  <krollin@apple.com>
833
834         Fix determination of the top-level resource
835         https://bugs.webkit.org/show_bug.cgi?id=202491
836         <rdar://problem/50780648>
837
838         Reviewed by Youenn Fablet.
839
840         When loading the resources associated with a page, the Networking
841         process needs to know the main resource for the main frame. It uses
842         this information to keep track of page loads and the resources that
843         are loaded in those pages. By keeping track of this information,
844         WebKit can track and report difficult (slow or incomplete) resource
845         loads and their impact on the overall page.
846
847         The initial determination of the top resource only looked at whether
848         the resource was the "main" resource of a frame or not. However, this
849         determination was insufficient, and would confuse the tracking
850         mechanism when sub-frames also had main frames. Therefore, augment the
851         test by also looking to see if the hosting frame is the main frame.
852
853         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
854         (WebKit::NetworkConnectionToWebProcess::startTrackingResourceLoad):
855         * NetworkProcess/NetworkConnectionToWebProcess.h:
856         * NetworkProcess/NetworkResourceLoader.cpp:
857         (WebKit::NetworkResourceLoader::start):
858
859 2019-10-04  Ross Kirsling  <ross.kirsling@sony.com>
860
861         Unreviewed WinCairo build fix for r250717.
862
863         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
864         (WebKit::LayerTreeHost::invalidate): Deleted.
865
866 2019-10-04  Alex Christensen  <achristensen@webkit.org>
867
868         Stop sending list of display-isolated schemes to NetworkProcess
869         https://bugs.webkit.org/show_bug.cgi?id=202557
870
871         Reviewed by Youenn Fablet.
872
873         * NetworkProcess/NetworkProcess.cpp:
874         (WebKit::NetworkProcess::initializeNetworkProcess):
875         (WebKit::NetworkProcess::registerURLSchemeAsDisplayIsolated const): Deleted.
876         * NetworkProcess/NetworkProcess.h:
877         * NetworkProcess/NetworkProcess.messages.in:
878         * NetworkProcess/NetworkProcessCreationParameters.cpp:
879         (WebKit::NetworkProcessCreationParameters::encode const):
880         (WebKit::NetworkProcessCreationParameters::decode):
881         * NetworkProcess/NetworkProcessCreationParameters.h:
882         * UIProcess/WebProcessPool.cpp:
883         (WebKit::WebProcessPool::ensureNetworkProcess):
884         (WebKit::WebProcessPool::registerURLSchemeAsDisplayIsolated):
885
886 2019-10-04  Alex Christensen  <achristensen@webkit.org>
887
888         Rename SchemeRegistry to LegacySchemeRegistry
889         https://bugs.webkit.org/show_bug.cgi?id=202586
890
891         Reviewed by Tim Horton.
892
893         * NetworkProcess/NetworkLoadChecker.cpp:
894         (WebKit::NetworkLoadChecker::doesNotNeedCORSCheck const):
895         * NetworkProcess/NetworkProcess.cpp:
896         (WebKit::NetworkProcess::registerURLSchemeAsSecure const):
897         (WebKit::NetworkProcess::registerURLSchemeAsBypassingContentSecurityPolicy const):
898         (WebKit::NetworkProcess::registerURLSchemeAsLocal const):
899         (WebKit::NetworkProcess::registerURLSchemeAsNoAccess const):
900         (WebKit::NetworkProcess::registerURLSchemeAsDisplayIsolated const):
901         (WebKit::NetworkProcess::registerURLSchemeAsCORSEnabled const):
902         (WebKit::NetworkProcess::registerURLSchemeAsCanDisplayOnlyIfCanRequest const):
903         * Shared/AuxiliaryProcess.cpp:
904         (WebKit::AuxiliaryProcess::registerURLSchemeServiceWorkersCanHandle const):
905         * UIProcess/API/Cocoa/WKWebView.mm:
906         (+[WKWebView handlesURLScheme:]):
907         * UIProcess/API/glib/WebKitSecurityManager.cpp:
908         (registerSecurityPolicyForURIScheme):
909         (checkSecurityPolicyForURIScheme):
910         * WebProcess/Plugins/WebPluginInfoProvider.cpp:
911         (WebKit::WebPluginInfoProvider::webVisiblePluginInfo):
912         * WebProcess/Storage/WebServiceWorkerProvider.cpp:
913         (WebKit::WebServiceWorkerProvider::handleFetch):
914         * WebProcess/WebPage/WebPage.cpp:
915         (WebKit::WebPage::canHandleRequest):
916         * WebProcess/WebProcess.cpp:
917         (WebKit::WebProcess::registerURLSchemeAsEmptyDocument):
918         (WebKit::WebProcess::registerURLSchemeAsSecure const):
919         (WebKit::WebProcess::registerURLSchemeAsBypassingContentSecurityPolicy const):
920         (WebKit::WebProcess::setDomainRelaxationForbiddenForURLScheme const):
921         (WebKit::WebProcess::registerURLSchemeAsLocal const):
922         (WebKit::WebProcess::registerURLSchemeAsNoAccess const):
923         (WebKit::WebProcess::registerURLSchemeAsDisplayIsolated const):
924         (WebKit::WebProcess::registerURLSchemeAsCORSEnabled const):
925         (WebKit::WebProcess::registerURLSchemeAsAlwaysRevalidated const):
926         (WebKit::WebProcess::registerURLSchemeAsCachePartitioned const):
927         (WebKit::WebProcess::registerURLSchemeAsCanDisplayOnlyIfCanRequest const):
928         * WebProcess/WebStorage/StorageAreaImpl.cpp:
929
930 2019-10-04  Jiewen Tan  <jiewen_tan@apple.com>
931
932         [WebAuthn] Implement _WKWebAuthenticationPanel SPI
933         https://bugs.webkit.org/show_bug.cgi?id=202559
934         <rdar://problem/55932094>
935
936         Reviewed by Brent Fulgham.
937
938         This patch implements _WKWebAuthenticationPanel SPI. Here is the structure:
939         1) API::WebAuthenticationPanel is the APIObject of _WKWebAuthenticationPanel. It is owned by AuthenticatorManager.
940         The lifetime of _WKWebAuthenticationPanel on the other hand is managed by clients. This binding is the surface
941         where clients could interact with WebKit's WebAuthentication implementation.
942         2) API::WebAuthenticationPanelClient is a base class representing _WKWebAuthenticationPanelDelegate. Its subclass
943         WebKit::WebAuthenticationPanelClient implements bridges to _WKWebAuthenticationPanelDelegate methods. It is owned by
944         API::WebAuthenticationPanel. A weak pointer of WebKit::WebAuthenticationPanelClient is kept in _WKWebAuthenticationPanel
945         to get the _WKWebAuthenticationPanelDelegate set by clients or nil otherwise. This binding is the surface where WebKit
946         interacts with clients.
947         3) WebAuthenticationPanelFlags is the mirror of enums within _WKWebAuthenticationPanel.
948
949         Implementation wise, this patch implements:
950         1) -[WKUIDelegatePrivate webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:], this is bridged from
951         the regular UIDelegate route. Noted, WKFrameInfo is nil for now, a follow up on Bug 202563 will take care of it. This
952         will be called from AuthenticatorManager::runPanel() which gates the start of discovery on the callback. For clients
953         that don't implement the delegate, the callback will always be called with _WKWebAuthenticationPanelResultUnavailable
954         to allow WebKit run on non-UI mode. A specific C API hack is added to always return _WKWebAuthenticationPanelResultPresented
955         in WebKitTestRunner for layout tests.
956         2) -[_WKWebAuthenticationPanelDelegate panel:updateWebAuthenticationPanel:] will be implemented in Bug 200932.
957         3) -[_WKWebAuthenticationPanelDelegate panel:dismissWebAuthenticationPanelWithResult:], this is bridged from
958         API::WebAuthenticationPanel/API::WebAuthenticationPanelClient. This will be called whenever AuthenticatorManager::m_pendingCompletionHandler
959         is invoked. Depending on the respond, _WKWebAuthenticationResult will be returned accordingly. To facilitate that,
960         invokePendingCompletionHandler is crafted to bundle those two operations.
961         4) -[_WKWebAuthenticationPanel cancel] will be implemented in Bug 191523.
962
963         Besides the above, this patch also silents the NFC action sheet.
964
965         * Platform/spi/Cocoa/NearFieldSPI.h:
966         * Shared/API/APIObject.h:
967         * Shared/Cocoa/APIObject.mm:
968         (API::Object::newObject):
969         * Sources.txt:
970         * SourcesCocoa.txt:
971         * UIProcess/API/APIUIClient.h:
972         (API::UIClient::runWebAuthenticationPanel):
973         * UIProcess/API/APIWebAuthenticationPanel.cpp: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm.
974         (API::WebAuthenticationPanel::create):
975         (API::WebAuthenticationPanel::WebAuthenticationPanel):
976         (API::WebAuthenticationPanel::setClient):
977         * UIProcess/API/APIWebAuthenticationPanel.h: Copied from Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h.
978         * UIProcess/API/APIWebAuthenticationPanelClient.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanelInternal.h.
979         (API::WebAuthenticationPanelClient::dismissPanel const):
980         * UIProcess/API/C/WKPage.cpp:
981         (WKPageSetPageUIClient):
982         * UIProcess/API/C/WKPageUIClient.h:
983         * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
984         (-[_WKWebAuthenticationPanel dealloc]):
985         (-[_WKWebAuthenticationPanel relyingPartyID]):
986         (-[_WKWebAuthenticationPanel delegate]):
987         (-[_WKWebAuthenticationPanel setDelegate:]):
988         (-[_WKWebAuthenticationPanel _apiObject]):
989         (-[_WKWebAuthenticationPanel _initWithRelayingPartyID:]): Deleted.
990         * UIProcess/API/Cocoa/_WKWebAuthenticationPanelInternal.h:
991         * UIProcess/Cocoa/UIDelegate.h:
992         * UIProcess/Cocoa/UIDelegate.mm:
993         (WebKit::UIDelegate::setDelegate):
994         (WebKit::webAuthenticationPanelResult):
995         (WebKit::UIDelegate::UIClient::runWebAuthenticationPanel):
996         * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
997         (WebKit::WebCore::isFeatureEnabled):
998         (WebKit::WebCore::getRpId):
999         (WebKit::AuthenticatorManager::handleRequest):
1000         (WebKit::AuthenticatorManager::respondReceived):
1001         (WebKit::AuthenticatorManager::startDiscovery):
1002         (WebKit::AuthenticatorManager::initTimeOutTimer):
1003         (WebKit::AuthenticatorManager::timeOutTimerFired):
1004         (WebKit::AuthenticatorManager::runPanel):
1005         (WebKit::AuthenticatorManager::startRequest):
1006         (WebKit::AuthenticatorManager::invokePendingCompletionHandler):
1007         (WebKit::AuthenticatorManagerInternal::collectTransports): Deleted.
1008         (WebKit::AuthenticatorManagerInternal::processGoogleLegacyAppIdSupportExtension): Deleted.
1009         * UIProcess/WebAuthentication/AuthenticatorManager.h:
1010         (WebKit::AuthenticatorManager::pendingCompletionHandler): Deleted.
1011         * UIProcess/WebAuthentication/Cocoa/NfcConnection.mm:
1012         (WebKit::NfcConnection::NfcConnection):
1013         * UIProcess/WebAuthentication/Cocoa/NfcService.mm:
1014         (WebKit::NfcService::platformStartDiscovery):
1015         * UIProcess/WebAuthentication/Cocoa/WebAuthenticationPanelClient.h: Copied from Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h.
1016         * UIProcess/WebAuthentication/Cocoa/WebAuthenticationPanelClient.mm: Copied from Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp.
1017         (WebKit::WebAuthenticationPanelClient::WebAuthenticationPanelClient):
1018         (WebKit::wkWebAuthenticationResult):
1019         (WebKit::WebAuthenticationPanelClient::dismissPanel const):
1020         * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp:
1021         (WebKit::MockAuthenticatorManager::respondReceivedInternal):
1022         * UIProcess/WebAuthentication/WebAuthenticationPanelFlags.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanelInternal.h.
1023         * UIProcess/WebAuthentication/WebAuthenticationRequestData.h:
1024         * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
1025         (WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
1026         (WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
1027         * WebKit.xcodeproj/project.pbxproj:
1028
1029 2019-10-04  Alex Christensen  <achristensen@webkit.org>
1030
1031         Move WKProcessPool._registerURLSchemeServiceWorkersCanHandle to _WKWebsiteDataStoreConfiguration
1032         https://bugs.webkit.org/show_bug.cgi?id=202553
1033
1034         Reviewed by Youenn Fablet.
1035
1036         It was only used for testing, and all the tests that use it still pass with the new SPI.
1037
1038         * NetworkProcess/NetworkProcess.cpp:
1039         (WebKit::NetworkProcess::initializeNetworkProcess):
1040         (WebKit::NetworkProcess::addWebsiteDataStore):
1041         (WebKit::NetworkProcess::swServerForSession):
1042         (WebKit::NetworkProcess::addServiceWorkerSession):
1043         * NetworkProcess/NetworkProcess.h:
1044         * Shared/AuxiliaryProcess.cpp:
1045         (WebKit::AuxiliaryProcess::registerURLSchemeServiceWorkersCanHandle const): Deleted.
1046         * Shared/AuxiliaryProcess.h:
1047         * Shared/AuxiliaryProcess.messages.in:
1048         * Shared/WebsiteDataStoreParameters.cpp:
1049         (WebKit::WebsiteDataStoreParameters::encode const):
1050         (WebKit::WebsiteDataStoreParameters::decode):
1051         * Shared/WebsiteDataStoreParameters.h:
1052         * UIProcess/API/Cocoa/WKProcessPool.mm:
1053         (-[WKProcessPool _registerURLSchemeServiceWorkersCanHandle:]): Deleted.
1054         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
1055         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
1056         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
1057         (-[_WKWebsiteDataStoreConfiguration registerURLSchemeServiceWorkersCanHandleForTesting:]):
1058         * UIProcess/WebProcessPool.cpp:
1059         (WebKit::WebProcessPool::ensureNetworkProcess):
1060         (WebKit::WebProcessPool::initializeNewWebProcess):
1061         (WebKit::WebProcessPool::registerURLSchemeServiceWorkersCanHandle): Deleted.
1062         * UIProcess/WebProcessPool.h:
1063         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1064         (WebKit::WebsiteDataStore::parameters):
1065         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
1066         (WebKit::WebsiteDataStoreConfiguration::copy):
1067         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
1068         (WebKit::WebsiteDataStoreConfiguration::serviceWorkerRegisteredSchemes const):
1069         (WebKit::WebsiteDataStoreConfiguration::registerServiceWorkerScheme):
1070         * WebProcess/WebProcess.cpp:
1071         (WebKit::WebProcess::initializeWebProcess):
1072
1073 2019-10-04  youenn fablet  <youenn@apple.com>
1074
1075         Allow to suspend RTCPeerConnection when not connected
1076         https://bugs.webkit.org/show_bug.cgi?id=202403
1077
1078         Reviewed by Chris Dumez.
1079
1080         Implement suspend/resume of sockets by doing the following:
1081         - For UDP sockets, we simulate as if being sent data is queued when being suspended.
1082         the webrtc backend will then stop sending packets until the queue is emptied.
1083         At resume time, we do as if the queue is emptied and packets sent (even though packets are not sent).
1084         For incoming traffic, we ignore it when being suspended.
1085         - For TCP sockets, we close them at suspend time. We then notify at resume time that an error happeneded
1086         for these sockets to the webrtc backend. We cannot simulate packet dropping like in the UDP case.
1087
1088         To manage resume/suspend, each socket now has a isSuspended state and a socket group.
1089         The socket group is per peer connection.
1090         A peer connection will notify the factory that it is suspended/resumed.
1091         The factory will iterate through all sockets and will suspend/resume each socket of the socket group.
1092
1093         * WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
1094         (WebKit::RTCSocketFactory::RTCSocketFactory):
1095         (WebKit::RTCSocketFactory::CreateUdpSocket):
1096         (WebKit::RTCSocketFactory::CreateServerTcpSocket):
1097         (WebKit::RTCSocketFactory::CreateClientTcpSocket):
1098         (WebKit::RTCSocketFactory::CreateAsyncResolver):
1099         (WebKit::RTCSocketFactory::suspend):
1100         (WebKit::RTCSocketFactory::resume):
1101         (WebKit::LibWebRTCProvider::createSocketFactory):
1102         * WebProcess/Network/webrtc/LibWebRTCProvider.h:
1103         * WebProcess/Network/webrtc/LibWebRTCSocket.cpp:
1104         (WebKit::LibWebRTCSocket::LibWebRTCSocket):
1105         (WebKit::LibWebRTCSocket::~LibWebRTCSocket):
1106         (WebKit::LibWebRTCSocket::signalReadPacket):
1107         (WebKit::LibWebRTCSocket::signalSentPacket):
1108         (WebKit::LibWebRTCSocket::SendTo):
1109         (WebKit::LibWebRTCSocket::Close):
1110         (WebKit::LibWebRTCSocket::SetOption):
1111         (WebKit::LibWebRTCSocket::resume):
1112         (WebKit::LibWebRTCSocket::suspend):
1113         * WebProcess/Network/webrtc/LibWebRTCSocket.h:
1114         * WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
1115         (WebKit::LibWebRTCSocketFactory::createServerTcpSocket):
1116         (WebKit::LibWebRTCSocketFactory::createUdpSocket):
1117         (WebKit::LibWebRTCSocketFactory::createClientTcpSocket):
1118         (WebKit::LibWebRTCSocketFactory::createNewConnectionSocket):
1119         (WebKit::LibWebRTCSocketFactory::addSocket):
1120         (WebKit::LibWebRTCSocketFactory::removeSocket):
1121         (WebKit::LibWebRTCSocketFactory::forSocketInGroup):
1122         * WebProcess/Network/webrtc/LibWebRTCSocketFactory.h:
1123
1124 2019-10-04  Alex Christensen  <achristensen@webkit.org>
1125
1126         Simplify sandbox enabling macros
1127         https://bugs.webkit.org/show_bug.cgi?id=202536
1128
1129         Reviewed by Brent Fulgham.
1130
1131         ENABLE_WEB_PROCESS_SANDBOX was always on for Cocoa platforms and only used in WebProcessCocoa.mm, so it did nothing.
1132         ENABLE_MANUAL_SANDBOXING was on for sdk=macosx* which I made more explicit in the code by using PLATFORM(MAC) || PLATFORM(MAACCATALYST)
1133         ENABLE_MANUAL_NETWORK_SANDBOXING was always off and hiding dead code we do not intend to use because iOS sandboxes are always on and never manual.
1134
1135         * Configurations/FeatureDefines.xcconfig:
1136         * NetworkProcess/ios/NetworkProcessIOS.mm:
1137         (WebKit::NetworkProcess::initializeSandbox):
1138         * Shared/ios/AuxiliaryProcessIOS.mm:
1139         (WebKit::AuxiliaryProcess::initializeSandbox):
1140         * WebProcess/cocoa/WebProcessCocoa.mm:
1141         (WebKit::WebProcess::initializeSandbox):
1142
1143 2019-10-04  Carlos Garcia Campos  <cgarcia@igalia.com>
1144
1145         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.27.1 release
1146
1147         * gtk/NEWS: Add release notes for 2.27.1.
1148
1149 2019-10-04  Carlos Garcia Campos  <cgarcia@igalia.com>
1150
1151         [GTK] Crash in WebChromeClient::createDisplayRefreshMonitor
1152         https://bugs.webkit.org/show_bug.cgi?id=202551
1153
1154         Reviewed by Žan Doberšek.
1155
1156         The crash happens when the drawing area is destroyed due to a page close. The layer tree host is invalidated
1157         causing a layer flush that ends up trying to create a display refresh monitor, which requires the drawing
1158         area. We need to null-check the drawing area in WebChromeClient::createDisplayRefreshMonitor() but we should
1159         also ensure that layer flush is not performed after layer tree host is destroyed.
1160
1161         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
1162         (WebKit::WebChromeClient::createDisplayRefreshMonitor const): Null-check drawing area before using it.
1163         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
1164         (WebKit::CompositingCoordinator::CompositingCoordinator): Receive a WebPage instead of a WebCore::Page and
1165         create the root layer here.
1166         (WebKit::CompositingCoordinator::~CompositingCoordinator): Do not purge backing stores again, invalidate should
1167         always be called right before the object is destroyed.
1168         (WebKit::CompositingCoordinator::flushPendingLayerChanges): Get WebCore::Page from WebPage.
1169         (WebKit::CompositingCoordinator::timestamp const): Ditto.
1170         (WebKit::CompositingCoordinator::syncDisplayState): Ditto.
1171         (WebKit::CompositingCoordinator::notifyFlushRequired): Do not continue if m_rootLayer is nullptr.
1172         (WebKit::CompositingCoordinator::deviceScaleFactor const): Get WebCore::Page from WebPage.
1173         (WebKit::CompositingCoordinator::pageScaleFactor const): Ditto.
1174         (WebKit::CompositingCoordinator::createGraphicsLayer): Call attachLayer() instead of duplicating the code.
1175         (WebKit::CompositingCoordinator::setVisibleContentsRect): Get WebCore::Page from WebPage.
1176         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
1177         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
1178         (WebKit::DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost): Do not call LayerTreeHost::invalidate()
1179         that has been removed.
1180         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
1181         (WebKit::LayerTreeHost::LayerTreeHost): Construct the coordinator after the sceneIntegration.
1182         (WebKit::LayerTreeHost::~LayerTreeHost): Invalidate everything here now. We don't really need invalidate()
1183         method since LayerTreeHost is not refcounted and we always called invalidate right before deleting the object.
1184         (WebKit::LayerTreeHost::layerFlushTimerFired): This can't happen on invalid state anymore.
1185         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
1186
1187 2019-10-04  Carlos Garcia Campos  <cgarcia@igalia.com>
1188
1189         [GTK][WPE] REGRESSION(r250673): connection to network process is broken after r250673
1190         https://bugs.webkit.org/show_bug.cgi?id=202575
1191
1192         Reviewed by Carlos Alberto Lopez Perez.
1193
1194         The file descriptor is now closed when the IPC::Attachment is destroyed in NetworkProcessConnectionInfo
1195         destructor. In case of unix domain sockets we need to transfer the ownership of the fd to
1196         NetworkProcessConnection, but NetworkProcessConnectionInfo is ow keeping the ownership.
1197
1198         * WebProcess/Network/NetworkProcessConnectionInfo.h:
1199         (WebKit::NetworkProcessConnectionInfo::releaseIdentifier): Use IPC::Attachment::releaseFileDescriptor() in case
1200         of unix domain sockets.
1201         * WebProcess/WebProcess.cpp:
1202         (WebKit::WebProcess::ensureNetworkProcessConnection): Use NetworkProcessConnectionInfo::releaseIdentifier() when
1203         passing the identifier to NetworkProcessConnection.
1204
1205 2019-10-04  Carlos Garcia Campos  <cgarcia@igalia.com>
1206
1207         Unreviewed. Fix GTK distcheck
1208
1209         * webkitglib-symbols.map: Remove symbols that are no longer in lib.
1210
1211 2019-10-03  Carlos Garcia Campos  <cgarcia@igalia.com>
1212
1213         [GTK] WebAutomation: make setWindowRect synchronous
1214         https://bugs.webkit.org/show_bug.cgi?id=202530
1215
1216         Reviewed by Carlos Alberto Lopez Perez.
1217
1218         Move/resize window is asynchronous in GTK, but automation expects it to be synchronous so that get window rect
1219         after setting it always returns the value set. Use a nested run loop to wait for the configure events after the
1220         move/resize.
1221
1222         * UIProcess/API/glib/WebKitUIClient.cpp:
1223         (UIClient::windowConfigureEventCallback):
1224         (UIClient::setWindowFrameTimerFired):
1225
1226 2019-10-03  Carlos Garcia Campos  <cgarcia@igalia.com>
1227
1228         Unreviewed. Address review comments after r250646.
1229
1230         I forgot to include the documentation improvements suggested.
1231
1232         * UIProcess/API/glib/WebKitWebContext.cpp:
1233         (webkit_web_context_class_init):
1234
1235 2019-10-03  Christopher Reid  <chris.reid@sony.com>
1236
1237         [WinCairo] Remote inspector client target list is racy
1238         https://bugs.webkit.org/show_bug.cgi?id=202169
1239
1240         Reviewed by Ross Kirsling.
1241
1242         Original patch by Basuke Suzuki.
1243
1244         Use LoaderClient to defer javascript target update calls to until after the page finished load.
1245
1246         * UIProcess/socket/RemoteInspectorProtocolHandler.cpp:
1247         * UIProcess/socket/RemoteInspectorProtocolHandler.h:
1248
1249 2019-10-03  Ross Kirsling  <ross.kirsling@sony.com>
1250
1251         Socket RWI client should acquire backend commands from server
1252         https://bugs.webkit.org/show_bug.cgi?id=202421
1253
1254         Reviewed by Devin Rousso.
1255
1256         * UIProcess/socket/RemoteInspectorClient.cpp:
1257         (WebKit::RemoteInspectorClient::dispatchMap):
1258         (WebKit::RemoteInspectorClient::setBackendCommands):
1259         * UIProcess/socket/RemoteInspectorClient.h:
1260         Receive "BackendCommands" message from server (which is already base64-encoded) and hand it over to RWIProxy.
1261
1262         * UIProcess/win/WebProcessPoolWin.cpp:
1263         (WebKit::backendCommandsPath):
1264         (WebKit::initializeRemoteInspectorServer):
1265         On Windows, initialize server with the path to InspectorBackendCommands.js from the CFBundle.
1266
1267 2019-10-03  Alex Christensen  <achristensen@webkit.org>
1268
1269         Replace _WKProcessPoolConfiguration.suppressesConnectionTerminationOnSystemChange with SPI on _WKWebsiteDataStoreConfiguration
1270         https://bugs.webkit.org/show_bug.cgi?id=202544
1271
1272         Reviewed by Tim Horton.
1273
1274         The _WKProcessPoolConfiguration SPI was originally introduced in rdar://problem/40650244
1275         Keep both working during the transition period, but we need it to not be on the process pool.
1276
1277         * NetworkProcess/NetworkSessionCreationParameters.cpp:
1278         (WebKit::NetworkSessionCreationParameters::encode const):
1279         (WebKit::NetworkSessionCreationParameters::decode):
1280         * NetworkProcess/NetworkSessionCreationParameters.h:
1281         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
1282         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
1283         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
1284         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
1285         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
1286         (-[_WKWebsiteDataStoreConfiguration suppressesConnectionTerminationOnSystemChange]):
1287         (-[_WKWebsiteDataStoreConfiguration setSuppressesConnectionTerminationOnSystemChange:]):
1288         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1289         (WebKit::WebsiteDataStore::parameters):
1290         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
1291         (WebKit::WebsiteDataStoreConfiguration::copy):
1292         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
1293         (WebKit::WebsiteDataStoreConfiguration::suppressesConnectionTerminationOnSystemChange const):
1294         (WebKit::WebsiteDataStoreConfiguration::setSuppressesConnectionTerminationOnSystemChange):
1295
1296 2019-10-03  Per Arne Vollan  <pvollan@apple.com>
1297
1298         REGRESSION(249649): Unable to open local files in MiniBrowser on macOS
1299         https://bugs.webkit.org/show_bug.cgi?id=201798
1300
1301         Reviewed by Brent Fulgham.
1302
1303         The commit <https://trac.webkit.org/changeset/249649> introduced a MiniBrowser regression on macOS where MiniBrowser
1304         is not able to open local files. The change set r249649 fixed a problem where the WebContent process PID was not ready
1305         to be used when creating a sandbox extension. This happened in the cases where the WebContent process had not finished
1306         launching when the load started. The WebContent process is also creating sandbox extensions for the Networking process
1307         for the files being loaded, and also needs to be passing the audit token of the Networking process when creating these.
1308         This patch implements getting the audit token for the Networking process when the WebProcess is sending a message to
1309         the UI process to establish the Networking process connection. The audit token is stored in the NetworkProcessConnection
1310         object, and passed to the NetworkLoadParameters object when the load is started. Finally, when encoding the Network
1311         resources load parameters, the audit token is used to create an extension for the Networking process.
1312
1313         API test: WKWebView.LoadFileWithLoadRequest
1314
1315         * NetworkProcess/NetworkLoadParameters.h:
1316         * NetworkProcess/NetworkResourceLoadParameters.cpp:
1317         (WebKit::NetworkResourceLoadParameters::encode const):
1318         * Platform/IPC/ArgumentCoders.cpp:
1319         (IPC::ArgumentCoder<audit_token_t>::encode):
1320         (IPC::ArgumentCoder<audit_token_t>::decode):
1321         * Platform/IPC/ArgumentCoders.h:
1322         * Shared/Cocoa/SandboxExtensionCocoa.mm:
1323         (WebKit::SandboxExtensionImpl::create):
1324         (WebKit::SandboxExtensionImpl::sandboxExtensionForType):
1325         (WebKit::SandboxExtensionImpl::SandboxExtensionImpl):
1326         (WebKit::SandboxExtension::createHandleForMachLookupByPid):
1327         (WebKit::SandboxExtension::createHandleForReadByPid):
1328         (WebKit::SandboxExtension::createHandleForReadByAuditToken):
1329         * Shared/SandboxExtension.h:
1330         * UIProcess/Network/NetworkProcessProxy.cpp:
1331         (WebKit::NetworkProcessProxy::openNetworkProcessConnection):
1332         * UIProcess/WebProcessProxy.messages.in:
1333         * WebKit.xcodeproj/project.pbxproj:
1334         * WebProcess/Network/NetworkProcessConnection.h:
1335         (WebKit::NetworkProcessConnection::setNetworkProcessAuditToken):
1336         (WebKit::NetworkProcessConnection::networkProcessAuditToken const):
1337         * WebProcess/Network/NetworkProcessConnectionInfo.h: Added.
1338         (WebKit::NetworkProcessConnectionInfo::identifier):
1339         (WebKit::NetworkProcessConnectionInfo::encode const):
1340         (WebKit::NetworkProcessConnectionInfo::decode):
1341         * WebProcess/Network/WebLoaderStrategy.cpp:
1342         (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
1343         (WebKit::WebLoaderStrategy::loadResourceSynchronously):
1344         (WebKit::WebLoaderStrategy::startPingLoad):
1345         (WebKit::WebLoaderStrategy::preconnectTo):
1346         * WebProcess/WebProcess.cpp:
1347         (WebKit::getNetworkProcessConnection):
1348         (WebKit::WebProcess::ensureNetworkProcessConnection):
1349
1350 2019-10-03  Konstantin Tokarev  <annulen@yandex.ru>
1351
1352         CMake-built WebKit.framework should launch XPC services successfully
1353         https://bugs.webkit.org/show_bug.cgi?id=202490
1354
1355         Reviewed by Carlos Alberto Lopez Perez.
1356
1357         target_link_options() requires CMake 3.10, however we can avoid
1358         raising required CMake version by moving it to PlatformMac.cmake,
1359         also avoid introduction of new CMake variable.
1360
1361         * CMakeLists.txt:
1362         * PlatformMac.cmake:
1363
1364 2019-10-03  Jiewen Tan  <jiewen_tan@apple.com>
1365
1366         Support googleLegacyAppidSupport extension
1367         https://bugs.webkit.org/show_bug.cgi?id=202427
1368         <rdar://problem/55887473>
1369
1370         Reviewed by Brent Fulgham.
1371
1372         * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
1373         (WebKit::AuthenticatorManagerInternal::collectTransports):
1374         (WebKit::AuthenticatorManagerInternal::processGoogleLegacyAppIdSupportExtension):
1375         (WebKit::AuthenticatorManager::handleRequest):
1376         * UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp:
1377         (WebKit::CtapAuthenticator::makeCredential):
1378         (WebKit::CtapAuthenticator::processGoogleLegacyAppIdSupportExtension):
1379         * UIProcess/WebAuthentication/fido/CtapAuthenticator.h:
1380         * UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp:
1381         (WebKit::U2fAuthenticator::continueRegisterCommandAfterResponseReceived):
1382
1383 2019-10-03  Jiewen Tan  <jiewen_tan@apple.com>
1384
1385         [WebAuthn] Implement dummy _WKWebAuthenticationPanel SPI
1386         https://bugs.webkit.org/show_bug.cgi?id=202507
1387         <rdar://problem/55918793>
1388
1389         Reviewed by Brent Fulgham.
1390
1391         This patch implements dummy _WKWebAuthenticationPanel SPI to unblock Safari.
1392
1393         Here are the illustrations for each SPI:
1394         1) -[WKUIDelegatePrivate webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:] is used at the beginning of
1395         any WebAuthn ceremonies. A WKFrameInfo is provided for more info of the initiating frame so clients could decide either show
1396         the RP ID or the origin of the frame which may or may not be the RP ID. A callback of _WKWebAuthenticationPanelResult is
1397         provided such that clients could inform WebKit to continue the ceremony or not. Case like rate limiting of a modular dialog
1398         could result in _WKWebAuthenticationPanelResultDidNotPresent. Then WebKit will abort the operation.
1399         _WKWebAuthenticationPanelResultUnavailable tells WebKit the client has no UI implemented and therefore WebKit will operate
1400         in a non UI mode which basically will only enable HID authenticators, and is the current behavior of macOS Safari.
1401         2) -[_WKWebAuthenticationPanelDelegate panel:updateWebAuthenticationPanel:] is primarily to instruct users to do some
1402         actionable thing to recover from some error state. However, it could be used for pure info as well. For
1403         _WKWebAuthenticationPanelInfoMultipleNFCTagPresents, users can be instructed to only hold one NFC tag to the scanner. For
1404         _WKWebAuthenticationPanelInfoNoCredentialsFound, users can potentially switch to another security key that could hit a match.
1405         3) -[_WKWebAuthenticationPanelDelegate panel:dismissWebAuthenticationPanelWithResult:] is to dismiss UI.
1406         _WKWebAuthenticationResult is provided such that client could show different animations as a hint to the user. The reasons for
1407         failure could either be timeout or InvalidStateError which will be reported to the page as well. InvalidStateError signals a
1408         credential matching an entry of the exclude list (excludeCredentials) is found on the authenticator.
1409         4) -[_WKWebAuthenticationPanel cancel] is the way clients tell WebKit a user cancel.
1410
1411         * SourcesCocoa.txt:
1412         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
1413         * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h: Added.
1414         * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm: Added.
1415         (-[_WKWebAuthenticationPanel _initWithRelayingPartyID:]):
1416         (-[_WKWebAuthenticationPanel relyingPartyID]):
1417         (-[_WKWebAuthenticationPanel cancel]):
1418         * UIProcess/API/Cocoa/_WKWebAuthenticationPanelInternal.h: Added.
1419         * WebKit.xcodeproj/project.pbxproj:
1420
1421 2019-10-03  Zan Dobersek  <zdobersek@igalia.com>
1422
1423         [GTK][WPE] Enable async scrolling
1424         https://bugs.webkit.org/show_bug.cgi?id=202449
1425
1426         Reviewed by Carlos Garcia Campos.
1427
1428         For WPE, explicitly enable the threaded scrolling preference on the
1429         WebPreferences object. For GTK, the same preference is enabled in
1430         parallel with the forced-compositing preference, as the async scrolling
1431         feature depends on always-on AC mode.
1432
1433         To help with quick evaluation of potential issues around async scrolling
1434         the feature can still be disabled via the WEBKIT_DISABLE_ASYNC_SCROLLING
1435         environment variable, though this only works in DEVELOPER_MODE builds.
1436
1437         * Shared/WebPreferencesDefaultValues.h: Default-enable async frame and
1438         overflow scrolling on Nicosia-using ports.
1439         * UIProcess/API/glib/WebKitSettings.cpp:
1440         (webkit_settings_set_hardware_acceleration_policy):
1441         * UIProcess/API/wpe/WPEView.cpp:
1442         (WKWPE::m_backend):
1443         * UIProcess/gtk/WebPreferencesGtk.cpp:
1444         (WebKit::WebPreferences::platformInitializeStore):
1445         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
1446         (WebKit::DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics):
1447         (WebKit::DrawingAreaCoordinatedGraphics::updatePreferences):
1448         (WebKit::DrawingAreaCoordinatedGraphics::supportsAsyncScrolling):
1449         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h:
1450
1451 2019-10-03  Zan Dobersek  <zdobersek@igalia.com>
1452
1453         [Nicosia] Enable runtime checks and triggers for async non-main-frame scrolling
1454         https://bugs.webkit.org/show_bug.cgi?id=202509
1455
1456         Reviewed by Carlos Garcia Campos.
1457
1458         * WebProcess/WebCoreSupport/WebChromeClient.h:
1459         Allow the non-main-frame compositing trigger for the Nicosia-using ports
1460         as well. This will enable non-main-frame compositing if the related
1461         setting is also enabled.
1462
1463 2019-10-03  Alexander Mikhaylenko  <alexm@gnome.org>
1464
1465         [GTK] Don't hardcode swipe navigation gesture style
1466         https://bugs.webkit.org/show_bug.cgi?id=202447
1467
1468         Reviewed by Carlos Garcia Campos.
1469
1470         Use GTK foreign drawing to draw swipe gesture dimming and shadow instead of
1471         hardcoded opacity and gradient values.
1472
1473         Have separate elements for dimming and shadow. Additionally, add border
1474         and outline. Dimming layer opacity always matches progress, shadow opacity
1475         is 1 except when the page is almost completely retracted. Border and outline
1476         opacity is always 1. Outline is drawn above the top page. For determining
1477         shadow, border and outline width, 'min-width' property is used.
1478
1479         Each element also has .right or .left style class depending on text direction.
1480
1481         Creating patterns is relatively expensive, so do it once a gesture
1482         starts and clear them once it ends. Style changes are currently not
1483         handled, since it's unlikely anything would change while the gesture
1484         is done. Dimming layer is created with the same width as webview and is
1485         clipped when drawing.
1486
1487         Translate existing dimming and shadow into css as is, add subtle border and
1488         outline. Since it's controlled via css, downstreams can override the style.
1489
1490         Set WebKitWebView css name to 'webkitwebview', and only apply styles for
1491         elements directly preceded by it, otherwise the selectors are too generic.
1492
1493         * PlatformGTK.cmake: Add gtk.css to gresource bundle.
1494         * Resources/gtk/gtk-theme.css: Added.
1495         (webkitwebview > dimming):
1496         (webkitwebview > shadow):
1497         (webkitwebview > shadow.right):
1498         (webkitwebview > shadow.left):
1499         (webkitwebview > border):
1500         (webkitwebview > outline):
1501         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
1502         (webkit_web_view_base_class_init): Set css name to 'webkitwebview'.
1503         * UIProcess/ViewGestureController.h:
1504         * UIProcess/gtk/ViewGestureControllerGtk.cpp:
1505         (WebKit::ViewGestureController::createStyleContext):
1506         (WebKit::createElementPattern):
1507         (WebKit::elementWidth):
1508         (WebKit::ViewGestureController::beginSwipeGesture): Create helper patterns.
1509         (WebKit::ViewGestureController::draw): Rework drawing to use the patterns.
1510         (WebKit::ViewGestureController::removeSwipeSnapshot): Clear the patterns.
1511
1512 2019-10-03  Carlos Garcia Campos  <cgarcia@igalia.com>
1513
1514         [GTK] Make PSON optional
1515         https://bugs.webkit.org/show_bug.cgi?id=200967
1516
1517         Reviewed by Michael Catanzaro.
1518
1519         It's not possible to enable PSON by default and keep backwards compatibility, applications might need to use new
1520         API to monitor the page ID changes in the Web view. So, this patch adds a construct only property to
1521         WebKitWebContext to enable PSON.
1522
1523         * UIProcess/API/glib/WebKitWebContext.cpp:
1524         (webkitWebContextGetProperty):
1525         (webkitWebContextSetProperty):
1526         (webkitWebContextConstructed):
1527         (webkit_web_context_class_init):
1528
1529 2019-10-03  Carlos Garcia Campos  <cgarcia@igalia.com>
1530
1531         [GTK][WPE] Add WebKitWebView:page-id property
1532         https://bugs.webkit.org/show_bug.cgi?id=201642
1533
1534         Reviewed by Michael Catanzaro.
1535
1536         The page ID of a WebKitWebView can now change, so we need a way to get notified when it changes.
1537
1538         * UIProcess/API/glib/WebKitWebView.cpp:
1539         (webkitWebViewGetProperty): Add getter for page-id.
1540         (webkit_web_view_class_init): Add page-id property
1541         (webkitWebViewDidChangePageID): Emit notify::page-id.
1542         * UIProcess/API/glib/WebKitWebViewPrivate.h:
1543         * UIProcess/API/gtk/PageClientImpl.cpp:
1544         (WebKit::PageClientImpl::didChangeWebPageID const): Call webkitWebViewDidChangePageID().
1545         * UIProcess/API/gtk/PageClientImpl.h:
1546         * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
1547         * UIProcess/API/wpe/APIViewClient.h:
1548         (API::ViewClient::didChangePageID): Added virtual method.
1549         * UIProcess/API/wpe/PageClientImpl.cpp:
1550         (WebKit::PageClientImpl::didChangeWebPageID const): Call WKWPE::View::didChangePageID().
1551         * UIProcess/API/wpe/PageClientImpl.h:
1552         * UIProcess/API/wpe/WPEView.cpp:
1553         (WKWPE::View::didChangePageID): Call API::ViewClient::didChangePageID().
1554         * UIProcess/API/wpe/WPEView.h:
1555         * UIProcess/PageClient.h:
1556         (WebKit::PageClient::didChangeWebPageID const): Added virtual method.
1557         * UIProcess/WebPageProxy.cpp:
1558         (WebKit::WebPageProxy::swapToWebProcess): Call PageClient::didChangeWebPageID().
1559
1560 2019-10-02  Andy Estes  <aestes@apple.com>
1561
1562         [iOS] When hit testing for a context menu interaction, do not consider whether the element is contenteditable
1563         https://bugs.webkit.org/show_bug.cgi?id=202498
1564         <rdar://problem/54723131>
1565
1566         Reviewed by Tim Horton.
1567
1568         * WebProcess/WebPage/ios/WebPageIOS.mm:
1569         (WebKit::WebPage::startInteractionWithElementAtPosition): Changed to call
1570         WebCore::Frame::nodeRespondingToInteraction.
1571
1572 2019-10-02  Myles C. Maxfield  <mmaxfield@apple.com>
1573
1574         REGRESSION (r245672): <select> dropdown with text-rendering: optimizeLegibility freezes Safari
1575         https://bugs.webkit.org/show_bug.cgi?id=202198
1576
1577         Reviewed by Tim Horton.
1578
1579         NSFont has a bug where passing "auto" to kCTFontOpticalSizeAttribute
1580         causes an exception to be thrown. We don't catch the exception, so we
1581         pop up back to the runloop, which confuses the UI process.
1582
1583         The solution is twofold: 1) Workaround the bug by passing the font size
1584         to kCTFontOpticalSizeAttribute instead, and 2) catch any exceptions that
1585         this part of the code might throw.
1586
1587         * UIProcess/mac/WebPopupMenuProxyMac.mm:
1588         (WebKit::WebPopupMenuProxyMac::showPopupMenu):
1589
1590 2019-10-02  Alex Christensen  <achristensen@webkit.org>
1591
1592         [CMake] Don't link WebKit.framework with SecItemShim
1593         ​https://bugs.webkit.org/show_bug.cgi?id=202490
1594
1595         * PlatformMac.cmake:
1596         Otherwise everything that uses the Security framework crashes immediately.
1597         We only need it in the NetworkProcess.
1598
1599 2019-10-02  Alex Christensen  <achristensen@webkit.org>
1600
1601         CMake-built WebKit.framework should launch XPC services successfully
1602         https://bugs.webkit.org/show_bug.cgi?id=202490
1603
1604         Rubber-stamped by Tim Horton.
1605
1606         * CMakeLists.txt:
1607         * PlatformMac.cmake:
1608
1609 2019-10-02  Kate Cheney  <katherine_cheney@apple.com>
1610
1611         Updated resource load statistics are never merged into the SQLite Database backend (202372).
1612         https://bugs.webkit.org/show_bug.cgi?id=202372
1613         <rdar://problem/55854542>
1614
1615         Reviewed by Brent Fulgham. 
1616
1617         This patch has a lot of changes to the test infrastructure to be able 
1618         to test the mergeStatistics function. Merging functionality mimics
1619         that of the ResourceLoadStatisticsMemoryStore and the merge() function in
1620         ResourceLoadStatistics.cpp.
1621
1622         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
1623         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
1624         Added new SQLite queries that are needed to merge new statistics.
1625
1626         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements):
1627         Added new prepare statements for new SQLite queries.
1628
1629         (WebKit::ResourceLoadStatisticsDatabaseStore::insertObservedDomain):
1630         Updated to use domainID() instead of confirmDomainDoesNotExist which 
1631         was deleted. Changed the insert bind parameters
1632         to utilize new enum of Observed Domain table indices which will help
1633         reduce errors in the future if the database schema changes.
1634
1635         (WebKit::ResourceLoadStatisticsDatabaseStore::relationshipExists const):
1636         Changed {public} to {private} in logging statement to avoid leaking
1637         sensitive information when logging the query error.
1638
1639         (WebKit::ResourceLoadStatisticsDatabaseStore::confirmDomainDoesNotExist const): Deleted.
1640         This function essentially does the exact same thing as domainID and
1641         we can reduce code duplication by deleting it and transitioning all
1642         other functions to use domainID instead.
1643
1644         (WebKit::ResourceLoadStatisticsDatabaseStore::domainID const):
1645         Changed {public} to {private} in logging statement to avoid leaking
1646         sensitive information when logging the query error.
1647         
1648         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
1649         In order to reuse this code for the merge statistics function, I added
1650         a check before each insert call to ensure the relationship does not
1651         already exist in the database. This was not needed before because it
1652         was only called on an empty database.
1653
1654         (WebKit::ResourceLoadStatisticsDatabaseStore::merge):
1655         (WebKit::ResourceLoadStatisticsDatabaseStore::mergeStatistic):
1656         (WebKit::ResourceLoadStatisticsDatabaseStore::mergeStatistics):
1657         Merges new statistic.
1658
1659         (WebKit::ResourceLoadStatisticsDatabaseStore::incrementRecordsDeletedCountForDomains):
1660         (WebKit::ResourceLoadStatisticsDatabaseStore::recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain):
1661         (WebKit::ResourceLoadStatisticsDatabaseStore::markAsPrevalentIfHasRedirectedToPrevalent):
1662         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
1663         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener):
1664         (WebKit::ResourceLoadStatisticsDatabaseStore::grandfatherDataForDomains):
1665         (WebKit::ResourceLoadStatisticsDatabaseStore::ensurePrevalentResourcesForDebugMode):
1666         (WebKit::ResourceLoadStatisticsDatabaseStore::setUserInteraction):
1667         (WebKit::ResourceLoadStatisticsDatabaseStore::clearUserInteraction):
1668         (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction):
1669         (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource):
1670         (WebKit::ResourceLoadStatisticsDatabaseStore::setDomainsAsPrevalent):
1671         (WebKit::ResourceLoadStatisticsDatabaseStore::predicateValueForDomain const):
1672         (WebKit::ResourceLoadStatisticsDatabaseStore::clearPrevalentResource):
1673         Changed {public} to {private} in logging statement to avoid leaking
1674         sensitive information when logging the query error.
1675
1676         (WebKit::ResourceLoadStatisticsDatabaseStore::setGrandfathered):
1677         Fix a bug uncovered by the new test cases.
1678         
1679         (WebKit::ResourceLoadStatisticsDatabaseStore::ensureResourceStatisticsForRegistrableDomain):
1680         (WebKit::ResourceLoadStatisticsDatabaseStore::clearDatabaseContents):
1681         (WebKit::ResourceLoadStatisticsDatabaseStore::cookieTreatmentForOrigin const):
1682         (WebKit::ResourceLoadStatisticsDatabaseStore::clearExpiredUserInteractions):
1683         (WebKit::ResourceLoadStatisticsDatabaseStore::clearGrandfathering):
1684         (WebKit::ResourceLoadStatisticsDatabaseStore::pruneStatisticsIfNeeded):
1685         (WebKit::ResourceLoadStatisticsDatabaseStore::updateLastSeen):
1686         Changed {public} to {private} in logging statement to avoid leaking
1687         sensitive information when logging the query error.
1688         
1689         (WebKit::ResourceLoadStatisticsDatabaseStore::updateDataRecordsRemoved):
1690         A new function that utilizes a query needed for the merging of two
1691         statistics.
1692         
1693         (WebKit::ResourceLoadStatisticsDatabaseStore::confirmDomainDoesNotExist const): Deleted.
1694         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
1695         
1696         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
1697         (WebKit::ResourceLoadStatisticsMemoryStore::mergeStatistics):
1698         (WebKit::ResourceLoadStatisticsMemoryStore::wasAccessedAsFirstPartyDueToUserInteraction const): Deleted.
1699         Removed the check for updating times accessed due to first party 
1700         interaction, which is data no longer needed in updated ITP. 
1701
1702         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
1703         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
1704         Added the mergeStatistics function (previously only in the memory
1705         store) to the parent class now that it is used by both stores.
1706         
1707         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1708         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
1709         This function now calls mergeStatistics on the database store if
1710         enabled.
1711
1712         (WebKit::WebResourceLoadStatisticsStore::mergeStatisticForTesting):
1713         This function builds a vector from the sample data to test the
1714         mergeStatistics() function of the database store.
1715
1716         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
1717         * NetworkProcess/NetworkProcess.cpp:
1718         (WebKit::NetworkProcess::mergeStatisticForTesting):
1719         * NetworkProcess/NetworkProcess.h:
1720         * NetworkProcess/NetworkProcess.messages.in:
1721         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
1722         (WKWebsiteDataStoreSetStatisticsMergeStatistic):
1723         Fixed bug where isGrandfathered function in WKWebsiteDataStoreRef
1724         was calling hasHadUserInteraction by mistake.
1725
1726         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
1727         * UIProcess/Network/NetworkProcessProxy.cpp:
1728         (WebKit::NetworkProcessProxy::mergeStatisticForTesting):
1729         * UIProcess/Network/NetworkProcessProxy.h:
1730         This code is for testing the mergeStatistics() function.
1731
1732         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1733         (WebKit::WebsiteDataStore::isGrandfathered):
1734         (WebKit::WebsiteDataStore::mergeStatisticForTesting):
1735         * UIProcess/WebsiteData/WebsiteDataStore.h:
1736         Added this function which contacts the networkProcess to retrieve the
1737         grandfathered value for a domain. This was not included before because
1738         of a bug in WKWebsiteDataStoreRef.
1739
1740 2019-10-02  Dean Jackson  <dino@apple.com>
1741
1742         Provide originating website URL to AR QuickLook
1743         https://bugs.webkit.org/show_bug.cgi?id=202451
1744
1745         Reviewed by Antoine Quint.
1746
1747         Declare the setAdditionalParameters method and
1748         call it with the originating page URL if available.
1749
1750         * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
1751
1752 2019-10-02  Keith Rollin  <krollin@apple.com>
1753
1754         Properly mark canceled resources in NetworkActivityTracker
1755         https://bugs.webkit.org/show_bug.cgi?id=202440
1756         <rdar://problem/55843651>
1757
1758         Reviewed by Brent Fulgham.
1759
1760         The nw_activity facility tracking resource loads did not originally
1761         have support for reporting resources that were canceled. It now has
1762         that support (since late MacOS 14-aligned SDKs), so add support for it
1763         in NetworkActivityTracker and use it in places where we were
1764         previously reporting the status of canceled resources as "None".
1765
1766         * NetworkProcess/NetworkActivityTracker.h:
1767         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
1768         (WebKit::NetworkConnectionToWebProcess::stopAllNetworkActivityTracking):
1769         (WebKit::NetworkConnectionToWebProcess::stopAllNetworkActivityTrackingForPage):
1770         * NetworkProcess/NetworkResourceLoader.cpp:
1771         (WebKit::NetworkResourceLoader::cleanup):
1772         * NetworkProcess/cocoa/NetworkActivityTrackerCocoa.mm:
1773         (WebKit::NetworkActivityTracker::complete):
1774
1775 2019-10-02  Zan Dobersek  <zdobersek@igalia.com>
1776
1777         Unreviewed build fix for non-Mac ports after r250600.
1778
1779         * UIProcess/WebProcessPool.cpp:
1780         Make the CoreGraphicsSPI.h header include exclusive to the Mac port.
1781
1782 2019-10-02  Antoine Quint  <graouts@apple.com>
1783
1784         Unreviewed build fix for macOS, broken by r250595.
1785
1786         * UIProcess/WebProcessPool.cpp:
1787
1788 2019-10-02  youenn fablet  <youenn@apple.com>
1789
1790         Use strongly typed identifiers for webrtc sockets
1791         https://bugs.webkit.org/show_bug.cgi?id=202400
1792
1793         Reviewed by Chris Dumez.
1794
1795         Refactoring to use LibWebRTCSocketIdentifier instead of uint64_t.
1796
1797         * NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
1798         (WebKit::LibWebRTCSocketClient::LibWebRTCSocketClient):
1799         * NetworkProcess/webrtc/LibWebRTCSocketClient.h:
1800         * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
1801         (WebKit::NetworkRTCProvider::createSocket):
1802         (WebKit::NetworkRTCProvider::createUDPSocket):
1803         (WebKit::NetworkRTCProvider::createServerTCPSocket):
1804         (WebKit::NetworkRTCProvider::createClientTCPSocket):
1805         (WebKit::NetworkRTCProvider::wrapNewTCPConnection):
1806         (WebKit::NetworkRTCProvider::addSocket):
1807         (WebKit::NetworkRTCProvider::takeSocket):
1808         (WebKit::NetworkRTCProvider::newConnection):
1809         (WebKit::NetworkRTCProvider::didReceiveNetworkRTCSocketMessage):
1810         (WebKit::NetworkRTCProvider::closeListeningSockets):
1811         (WebKit::NetworkRTCProvider::callSocket):
1812         * NetworkProcess/webrtc/NetworkRTCProvider.h:
1813         * NetworkProcess/webrtc/NetworkRTCProvider.messages.in:
1814         * NetworkProcess/webrtc/NetworkRTCSocket.cpp:
1815         (WebKit::NetworkRTCSocket::NetworkRTCSocket):
1816         * NetworkProcess/webrtc/NetworkRTCSocket.h:
1817         * Scripts/webkit/messages.py:
1818         * WebProcess/Network/NetworkProcessConnection.cpp:
1819         (WebKit::NetworkProcessConnection::didReceiveMessage):
1820         * WebProcess/Network/webrtc/LibWebRTCNetwork.h:
1821         (WebKit::LibWebRTCNetwork::socket):
1822         * WebProcess/Network/webrtc/LibWebRTCSocket.cpp:
1823         (WebKit::LibWebRTCSocket::LibWebRTCSocket):
1824         * WebProcess/Network/webrtc/LibWebRTCSocket.h:
1825         * WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
1826         (WebKit::LibWebRTCSocketFactory::createServerTcpSocket):
1827         (WebKit::LibWebRTCSocketFactory::createUdpSocket):
1828         (WebKit::LibWebRTCSocketFactory::createClientTcpSocket):
1829         (WebKit::LibWebRTCSocketFactory::createNewConnectionSocket):
1830         * WebProcess/Network/webrtc/LibWebRTCSocketFactory.h:
1831         (WebKit::LibWebRTCSocketFactory::socket):
1832         (WebKit::LibWebRTCSocketFactory::resolver):
1833         (WebKit::LibWebRTCSocketFactory::takeResolver):
1834         (WebKit::LibWebRTCSocketFactory::disableNonLocalhostConnections):
1835         * WebProcess/Network/webrtc/WebRTCSocket.cpp:
1836         (WebKit::WebRTCSocket::signalOnNetworkThread):
1837         (WebKit::WebRTCSocket::WebRTCSocket):
1838         (WebKit::WebRTCSocket::signalSentPacket):
1839         (WebKit::WebRTCSocket::signalConnect):
1840         (WebKit::WebRTCSocket::signalClose):
1841         (WebKit::WebRTCSocket::signalNewConnection):
1842         * WebProcess/Network/webrtc/WebRTCSocket.h:
1843         * WebProcess/Network/webrtc/WebRTCSocket.messages.in:
1844
1845 2019-10-02  Carlos Garcia Campos  <cgarcia@igalia.com>
1846
1847         [GTK][WPE] Stop using legacy custom protocol implementation
1848         https://bugs.webkit.org/show_bug.cgi?id=202407
1849
1850         Reviewed by Žan Doberšek.
1851
1852         Use the new approach, which is simpler and doesn't require to go to the network process to load custom
1853         protocols.
1854
1855         * NetworkProcess/CustomProtocols/soup/LegacyCustomProtocolManagerSoup.cpp: Removed.
1856         * NetworkProcess/NetworkProcess.cpp:
1857         (WebKit::m_messagePortChannelRegistry):
1858         * NetworkProcess/soup/WebKitSoupRequestInputStream.cpp: Removed.
1859         * NetworkProcess/soup/WebKitSoupRequestInputStream.h: Removed.
1860         * PlatformGTK.cmake:
1861         * PlatformWPE.cmake:
1862         * SourcesGTK.txt:
1863         * SourcesWPE.txt:
1864         * UIProcess/API/glib/WebKitCustomProtocolManagerClient.cpp: Removed.
1865         * UIProcess/API/glib/WebKitCustomProtocolManagerClient.h: Removed.
1866         * UIProcess/API/glib/WebKitURISchemeRequest.cpp:
1867         (webkitURISchemeRequestCreate):
1868         (webkit_uri_scheme_request_get_scheme):
1869         (webkit_uri_scheme_request_get_uri):
1870         (webkit_uri_scheme_request_get_path):
1871         (webkit_uri_scheme_request_get_web_view):
1872         (webkitURISchemeRequestReadCallback):
1873         (webkit_uri_scheme_request_finish_error):
1874         * UIProcess/API/glib/WebKitURISchemeRequestPrivate.h:
1875         * UIProcess/API/glib/WebKitWebContext.cpp:
1876         (webkitWebContextConstructed):
1877         (webkitWebContextDispose):
1878         (webkit_web_context_register_uri_scheme):
1879         (webkitWebContextCreatePageForWebView):
1880         * UIProcess/API/glib/WebKitWebContextPrivate.h:
1881         * UIProcess/WebURLSchemeTask.h:
1882         (WebKit::WebURLSchemeTask::request const):
1883         * UIProcess/soup/WebProcessPoolSoup.cpp:
1884
1885 2019-10-02  Zan Dobersek  <zdobersek@igalia.com>
1886
1887         [Nicosia] Enable async scrolling at build-time for Nicosia-using ports
1888         https://bugs.webkit.org/show_bug.cgi?id=202397
1889
1890         Reviewed by Carlos Garcia Campos.
1891
1892         * Shared/WebEvent.h:
1893         Enable WebWheelEvent phasing for WPE, as required by the
1894         ASYNC_SCROLLING code.
1895
1896 2019-10-01  Tim Horton  <timothy_horton@apple.com>
1897
1898         Clean up some includes to make the build a bit faster
1899         https://bugs.webkit.org/show_bug.cgi?id=202444
1900
1901         Reviewed by Geoff Garen.
1902
1903         * UIProcess/API/Cocoa/_WKThumbnailView.mm:
1904
1905 2019-10-01  Alex Christensen  <achristensen@webkit.org>
1906
1907         Progress towards a functioning CMake build on Mac
1908         https://bugs.webkit.org/show_bug.cgi?id=202443
1909
1910         Rubber-stamped by Tim Horton.
1911
1912         * CMakeLists.txt:
1913         * PlatformMac.cmake:
1914
1915 2019-10-01  John Wilander  <wilander@apple.com>
1916
1917         Storage Access API: document.hasStorageAccess() should return true when the cookie policy allows access
1918         https://bugs.webkit.org/show_bug.cgi?id=202435
1919         <rdar://problem/55718526>
1920
1921         Reviewed by Brent Fulgham.
1922
1923         WebKit's Storage Access API implementation has so far only looked at whether ITP is
1924         blocking cookie access or not. However, the default cookie policy is still in
1925         effect underneath ITP. document.hasStorageAccess() should return true if the
1926         third-party:
1927         a) is not classified by ITP, and
1928         b) has cookies which implies it can use cookies as third-party according to the
1929         default cookie policy.
1930
1931         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
1932         (WebKit::ResourceLoadStatisticsMemoryStore::hasStorageAccess):
1933         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1934         (WebKit::WebResourceLoadStatisticsStore::hasCookies):
1935         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
1936         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
1937         (WebKit::NetworkConnectionToWebProcess::hasStorageAccess):
1938         * NetworkProcess/NetworkProcess.cpp:
1939         (WebKit::NetworkProcess::registrableDomainsWithWebsiteData):
1940
1941 2019-10-01  Antti Koivisto  <antti@apple.com>
1942
1943         [CSS Shadow Parts] Parse 'part' attribute
1944         https://bugs.webkit.org/show_bug.cgi?id=202409
1945
1946         Reviewed by Ryosuke Niwa.
1947
1948         * Shared/WebPreferences.yaml:
1949
1950         Add experimental feature, default to disabled for now.
1951
1952 2019-10-01  Alex Christensen  <achristensen@webkit.org>
1953
1954         Progress towards successful CMake build on Mac
1955         https://bugs.webkit.org/show_bug.cgi?id=202426
1956
1957         Rubber-stamped by Tim Horton.
1958
1959         * Platform/cocoa/PaymentAuthorizationPresenter.h:
1960         * Platform/cocoa/PaymentAuthorizationPresenter.mm:
1961         * Platform/cocoa/PaymentAuthorizationViewController.h:
1962         * Platform/cocoa/PaymentAuthorizationViewController.mm:
1963         * Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
1964         * PlatformMac.cmake:
1965         * Shared/SandboxExtension.h:
1966         (WebKit::SandboxExtension::createHandleForReadByPid):
1967         * SourcesCocoa.txt:
1968         * UIProcess/API/Cocoa/WKWebView.mm:
1969         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1970         (-[WKWebsiteDataStore _hasRegisteredServiceWorker]):
1971         * UIProcess/API/mac/WKView.mm:
1972         * UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
1973         * UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm:
1974         * UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm:
1975         * UIProcess/Cocoa/WKShareSheet.mm:
1976         (-[WKShareSheet delegate]):
1977         (-[WKShareSheet setDelegate:]):
1978         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1979         * UIProcess/Cocoa/WebViewImpl.h:
1980         * WebKit.xcodeproj/project.pbxproj:
1981         * WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp:
1982         * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h:
1983         * WebProcess/WebPage/Cocoa/WebRemoteObjectRegistry.cpp:
1984
1985 2019-10-01  Tim Horton  <timothy_horton@apple.com>
1986
1987         Clean up some includes to make the build a bit faster
1988         https://bugs.webkit.org/show_bug.cgi?id=202417
1989
1990         Reviewed by Jer Noble.
1991
1992         * WebProcess/Plugins/Netscape/NetscapePlugin.h:
1993         * WebProcess/Plugins/Plugin.h:
1994         Fix the build.
1995
1996 2019-10-01  Alex Christensen  <achristensen@webkit.org>
1997
1998         Fix GTK build after r250558
1999         https://bugs.webkit.org/show_bug.cgi?id=202390
2000
2001         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp:
2002         (webkit_dom_dom_window_confirm):
2003
2004 2019-10-01  Alex Christensen  <achristensen@webkit.org>
2005
2006         Fix an internal build.
2007
2008         Ignore some deprecation warnings.  We'll adopt new SPI soon.
2009
2010         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
2011         (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):
2012
2013 2019-10-01  youenn fablet  <youenn@apple.com>
2014
2015         Remove races condition when validating capture sandbox extension revocation
2016         https://bugs.webkit.org/show_bug.cgi?id=202133
2017         <rdar://problem/55660905>
2018
2019         Reviewed by Eric Carlson.
2020
2021         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
2022         (WebKit::UserMediaPermissionRequestManagerProxy::~UserMediaPermissionRequestManagerProxy):
2023         Explicitly ask the page to stop capture.
2024         This will make sure capture is stopped when revoking sandbox extensions.
2025
2026 2019-09-30  Alex Christensen  <achristensen@webkit.org>
2027
2028         Resurrect Mac CMake build
2029         https://bugs.webkit.org/show_bug.cgi?id=202384
2030
2031         Rubber-stamped by Tim Horton.
2032
2033         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
2034         * PlatformMac.cmake:
2035         * Shared/API/Cocoa/_WKRemoteObjectRegistry.mm:
2036         * UIProcess/API/Cocoa/WKWebView.mm:
2037         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
2038         * WebKit2Prefix.h:
2039
2040 2019-09-30  Christopher Reid  <chris.reid@sony.com>
2041
2042         [WinCairo] Move Remote Inspector Server initialization out of WebView
2043         https://bugs.webkit.org/show_bug.cgi?id=202369
2044
2045         Reviewed by Ross Kirsling.
2046         
2047         Move Remote Inspector Server initialization to Windows WebProcessPool initialization.
2048
2049         * UIProcess/win/WebProcessPoolWin.cpp:
2050         * UIProcess/win/WebView.cpp:
2051
2052 2019-09-30  Alex Christensen  <achristensen@webkit.org>
2053
2054         Move DownloadMonitor test speed multiplier from WebProcessPool to WebsiteDataStoreConfiguration
2055         https://bugs.webkit.org/show_bug.cgi?id=202339
2056
2057         Reviewed by Youenn Fablet.
2058
2059         This was only used for some unit tests, which still are accelerated so they pass in the same amount of time as before.
2060         I need this value to not be process-global in the NetworkProcess.
2061
2062         * NetworkProcess/Downloads/Download.cpp:
2063         (WebKit::Download::Download):
2064         * NetworkProcess/Downloads/Download.h:
2065         (WebKit::Download::Download):
2066         (WebKit::Download::testSpeedMultiplier const):
2067         * NetworkProcess/Downloads/DownloadManager.cpp:
2068         (WebKit::DownloadManager::resumeDownload):
2069         * NetworkProcess/Downloads/DownloadManager.h:
2070         * NetworkProcess/Downloads/DownloadMonitor.cpp:
2071         (WebKit::DownloadMonitor::applicationDidEnterBackground):
2072         (WebKit::DownloadMonitor::testSpeedMultiplier const):
2073         (WebKit::DownloadMonitor::timerFired):
2074         (WebKit::DownloadMonitor::speedMultiplier const): Deleted.
2075         * NetworkProcess/Downloads/DownloadMonitor.h:
2076         * NetworkProcess/NetworkDataTaskBlob.cpp:
2077         (WebKit::NetworkDataTaskBlob::download):
2078         * NetworkProcess/NetworkProcess.cpp:
2079         (WebKit::NetworkProcess::initializeNetworkProcess):
2080         * NetworkProcess/NetworkProcess.h:
2081         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2082         (WebKit::NetworkProcessCreationParameters::encode const):
2083         (WebKit::NetworkProcessCreationParameters::decode):
2084         * NetworkProcess/NetworkProcessCreationParameters.h:
2085         * NetworkProcess/NetworkSession.cpp:
2086         (WebKit::NetworkSession::NetworkSession):
2087         * NetworkProcess/NetworkSession.h:
2088         (WebKit::NetworkSession::testSpeedMultiplier const):
2089         * NetworkProcess/NetworkSessionCreationParameters.cpp:
2090         (WebKit::NetworkSessionCreationParameters::encode const):
2091         (WebKit::NetworkSessionCreationParameters::decode):
2092         * NetworkProcess/NetworkSessionCreationParameters.h:
2093         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
2094         (-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]):
2095         * UIProcess/API/APIProcessPoolConfiguration.cpp:
2096         (API::ProcessPoolConfiguration::copy):
2097         * UIProcess/API/APIProcessPoolConfiguration.h:
2098         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
2099         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
2100         (-[_WKProcessPoolConfiguration downloadMonitorSpeedMultiplierForTesting]): Deleted.
2101         (-[_WKProcessPoolConfiguration setDownloadMonitorSpeedMultiplierForTesting:]): Deleted.
2102         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
2103         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
2104         (-[_WKWebsiteDataStoreConfiguration testSpeedMultiplier]):
2105         (-[_WKWebsiteDataStoreConfiguration setTestSpeedMultiplier:]):
2106         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2107         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
2108         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
2109         (WebKit::WebsiteDataStore::parameters):
2110         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
2111         (WebKit::WebsiteDataStoreConfiguration::copy):
2112         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
2113         (WebKit::WebsiteDataStoreConfiguration::testSpeedMultiplier const):
2114         (WebKit::WebsiteDataStoreConfiguration::setTestSpeedMultiplier):
2115
2116 2019-09-30  Carlos Garcia Campos  <cgarcia@igalia.com>
2117
2118         [GTK] IconDatabase is not thread-safe
2119         https://bugs.webkit.org/show_bug.cgi?id=201303
2120
2121         Reviewed by Žan Doberšek.
2122
2123         Rewrite the IconDatabase implementation. Now that we are the only users of this code, we can simply it a lot and
2124         design it specifically for our API, which implementation has been simplified a lot too. There's no change in
2125         the database schema nor in behavior from the API point of view.
2126
2127         * UIProcess/API/glib/IconDatabase.cpp:
2128         (WebKit::IconDatabase::IconDatabase):
2129         (WebKit::IconDatabase::~IconDatabase):
2130         (WebKit::IconDatabase::createTablesIfNeeded):
2131         (WebKit::IconDatabase::populatePageURLToIconURLMap):
2132         (WebKit::IconDatabase::clearStatements):
2133         (WebKit::IconDatabase::pruneTimerFired):
2134         (WebKit::IconDatabase::startPruneTimer):
2135         (WebKit::IconDatabase::clearLoadedIconsTimerFired):
2136         (WebKit::IconDatabase::startClearLoadedIconsTimer):
2137         (WebKit::IconDatabase::iconIDForIconURL):
2138         (WebKit::IconDatabase::setIconIDForPageURL):
2139         (WebKit::IconDatabase::iconData):
2140         (WebKit::IconDatabase::addIcon):
2141         (WebKit::IconDatabase::updateIconTimestamp):
2142         (WebKit::IconDatabase::deleteIcon):
2143         (WebKit::IconDatabase::checkIconURLAndSetPageURLIfNeeded):
2144         (WebKit::IconDatabase::loadIconForPageURL):
2145         (WebKit::IconDatabase::iconURLForPageURL):
2146         (WebKit::IconDatabase::setIconForPageURL):
2147         (WebKit::IconDatabase::clear):
2148         * UIProcess/API/glib/IconDatabase.h:
2149         (WebKit::IconDatabase::create):
2150         * UIProcess/API/glib/WebKitFaviconDatabase.cpp:
2151         (webkitFaviconDatabaseCreate):
2152         (webkitFaviconDatabaseIsOpen):
2153         (webkitFaviconDatabaseOpen):
2154         (webkitFaviconDatabaseClose):
2155         (webkitFaviconDatabaseGetLoadDecisionForIcon):
2156         (webkitFaviconDatabaseSetIconForPageURL):
2157         (webkitFaviconDatabaseGetFaviconInternal):
2158         (webkit_favicon_database_get_favicon):
2159         (webkit_favicon_database_get_favicon_finish):
2160         (webkit_favicon_database_get_favicon_uri):
2161         (webkit_favicon_database_clear):
2162         * UIProcess/API/glib/WebKitFaviconDatabasePrivate.h:
2163         * UIProcess/API/glib/WebKitWebContext.cpp:
2164         (webkitWebContextDispose):
2165         (webkit_web_context_set_favicon_database_directory):
2166         (webkitWebContextCreatePageForWebView):
2167         (webkitWebContextWebViewDestroyed):
2168         * UIProcess/API/glib/WebKitWebView.cpp:
2169         (webkitWebViewRequestFavicon):
2170         (webkitWebViewGetLoadDecisionForIcon):
2171         (webkitWebViewSetIcon):
2172
2173 2019-09-30  Carlos Garcia Campos  <cgarcia@igalia.com>
2174
2175         [GTK][WPE] Add about:gpu
2176         https://bugs.webkit.org/show_bug.cgi?id=202305
2177
2178         Reviewed by Žan Doberšek.
2179
2180         A builtin protocol handler to show information about hardware acceleration. This is useful information we need
2181         from people reporting issues in accelerated compositing mode.
2182
2183         * SourcesGTK.txt:
2184         * SourcesWPE.txt:
2185         * UIProcess/API/glib/WebKitProtocolHandler.cpp: Added.
2186         (WebKit::WebKitProtocolHandler::WebKitProtocolHandler):
2187         (WebKit::WebKitProtocolHandler::handleRequest):
2188         (WebKit::webkitPortName):
2189         (WebKit::hardwareAccelerationPolicy):
2190         (WebKit::webGLEnabled):
2191         (WebKit::openGLAPI):
2192         (WebKit::nativeInterface):
2193         (WebKit::WebKitProtocolHandler::handleGPU):
2194         * UIProcess/API/glib/WebKitProtocolHandler.h: Added.
2195         * UIProcess/API/glib/WebKitWebContext.cpp:
2196         (webkitWebContextConstructed):
2197
2198 2019-09-30  Commit Queue  <commit-queue@webkit.org>
2199
2200         Unreviewed, rolling out r250291.
2201         https://bugs.webkit.org/show_bug.cgi?id=202359
2202
2203         it is failing
2204         TestWebKitAPI.ProcessSwap.GetUserMediaCaptureState (Requested
2205         by youenn on #webkit).
2206
2207         Reverted changeset:
2208
2209         "Delay capture sandbox extension revocation to after the page
2210         close message is sent"
2211         https://bugs.webkit.org/show_bug.cgi?id=202133
2212         https://trac.webkit.org/changeset/250291
2213
2214 2019-09-29  Zan Dobersek  <zdobersek@igalia.com>
2215
2216         ScrollingTreeScrollingNode: use LayerRepresentation for scroll container, scrolled contents layers
2217         https://bugs.webkit.org/show_bug.cgi?id=202256
2218         <rdar://problem/55772092>
2219
2220         Reviewed by Simon Fraser.
2221
2222         * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
2223         (WebKit::RemoteScrollingCoordinatorProxy::establishLayerTreeScrollingRelations):
2224         Use static casts to retrieve the CALayer pointers from the
2225         LayerRepresentation objects due to the explicit operators.
2226
2227 2019-09-29  Zan Dobersek  <zdobersek@igalia.com>
2228
2229         Tighten up LayerRepresentation operators
2230         https://bugs.webkit.org/show_bug.cgi?id=202344
2231
2232         Reviewed by Simon Fraser.
2233
2234         With LayerRepresentation operators now being explicit, we require
2235         to manually specify conversion to CALayer pointers or
2236         GraphicsLayer::PlatformLayerID values.
2237
2238         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
2239         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
2240         * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
2241         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
2242         * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
2243         (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::commitStateBeforeChildren):
2244         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
2245         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::commitStateBeforeChildren):
2246         * UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp:
2247         (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::commitStateBeforeChildren):
2248         * UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp:
2249         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::commitStateBeforeChildren):
2250
2251 2019-09-27  Adrian Perez de Castro  <aperez@igalia.com>
2252
2253         [GTK][WPE] Fixes for non-unified builds after r249714
2254         https://bugs.webkit.org/show_bug.cgi?id=202304
2255
2256         Reviewed by Youenn Fablet.
2257
2258         * NetworkProcess/NetworkLoadChecker.h: Add missing inclusion of the pal/SessionID.h header.
2259         * NetworkProcess/NetworkResourceLoadMap.cpp: Add missing inclusion of the
2260         NetworkResourceLoader.h header.
2261         * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp:
2262         (WKWebsiteDataStoreConfigurationCreate): Add missing namespace to usage of the
2263         WebKit::IsPersistent::Yes value.
2264         * UIProcess/WebPageProxy.cpp: Add missing inclusion of the LegacyGlobalSettings.h header.
2265
2266 2019-09-27  Tim Horton  <timothy_horton@apple.com>
2267
2268         Adopt new UIWebGeolocationPolicyDecider SPI to pass a view instead of a window
2269         https://bugs.webkit.org/show_bug.cgi?id=202329
2270         <rdar://problem/25963823>
2271
2272         Reviewed by Wenson Hsieh.
2273
2274         * Platform/spi/ios/UIKitSPI.h:
2275         * UIProcess/ios/WKGeolocationProviderIOS.mm:
2276         (-[WKGeolocationProviderIOS geolocationAuthorizationGranted]):
2277         * UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm:
2278         (WebKit::decidePolicyForGeolocationRequestFromOrigin):
2279         Switch to newer SPI that takes a UIView instead of a UIWindow, so that
2280         UIWebGeolocationPolicyDecider can find the correct presenting view controller.
2281
2282 2019-09-27  Zalan Bujtas  <zalan@apple.com>
2283
2284         [iPadOS] Can’t use RalphLauren.com on iPad because hover menus don’t stay up
2285         https://bugs.webkit.org/show_bug.cgi?id=202331
2286         <rdar://problem/55629493>
2287
2288         Reviewed by Tim Horton.
2289
2290         * WebProcess/WebPage/ios/WebPageIOS.mm:
2291         (WebKit::WebPage::handleSyntheticClick):
2292         (WebKit::nodeTriggersFastPath): Deleted.
2293
2294 2019-09-27  Alex Christensen  <achristensen@webkit.org>
2295
2296         Move shouldUseTestingNetworkSession from NetworkProcessCreationParameters to NetworkSessionCreationParameters
2297         https://bugs.webkit.org/show_bug.cgi?id=202327
2298
2299         Reviewed by Tim Horton.
2300
2301         * NetworkProcess/NetworkProcess.cpp:
2302         (WebKit::NetworkProcess::initializeNetworkProcess):
2303         (WebKit::NetworkProcess::ensureSession):
2304         * NetworkProcess/NetworkProcess.h:
2305         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2306         (WebKit::NetworkProcessCreationParameters::encode const):
2307         (WebKit::NetworkProcessCreationParameters::decode):
2308         * NetworkProcess/NetworkProcessCreationParameters.h:
2309         * NetworkProcess/NetworkSession.cpp:
2310         (WebKit::NetworkSession::NetworkSession):
2311         * NetworkProcess/NetworkSessionCreationParameters.cpp:
2312         (WebKit::NetworkSessionCreationParameters::encode const):
2313         (WebKit::NetworkSessionCreationParameters::decode):
2314         * NetworkProcess/NetworkSessionCreationParameters.h:
2315         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
2316         (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
2317         * NetworkProcess/curl/RemoteNetworkingContextCurl.cpp:
2318         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
2319         * NetworkProcess/mac/RemoteNetworkingContext.mm:
2320         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
2321         * NetworkProcess/soup/RemoteNetworkingContextSoup.cpp:
2322         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
2323         * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp:
2324         (WKWebsiteDataStoreConfigurationSetPerOriginStorageQuota):
2325         (WKWebsiteDataStoreConfigurationSetNetworkCacheSpeculativeValidationEnabled):
2326         (WKWebsiteDataStoreConfigurationGetTestingSessionEnabled):
2327         (WKWebsiteDataStoreConfigurationSetTestingSessionEnabled):
2328         * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.h:
2329         * UIProcess/WebProcessPool.cpp:
2330         (WebKit::WebProcessPool::ensureNetworkProcess):
2331         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
2332         (WebKit::WebsiteDataStore::parameters):
2333         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
2334         (WebKit::WebsiteDataStoreConfiguration::copy):
2335         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
2336         (WebKit::WebsiteDataStoreConfiguration::testingSessionEnabled const):
2337         (WebKit::WebsiteDataStoreConfiguration::setTestingSessionEnabled):
2338
2339 2019-09-27  Alex Christensen  <achristensen@webkit.org>
2340
2341         Move legacy custom protocol registration from process pool to NetworkProcessProxy
2342         https://bugs.webkit.org/show_bug.cgi?id=202315
2343
2344         Reviewed by Tim Horton.
2345
2346         Legacy custom protocol registration is a global thing, which is why it's legacy and we're trying to get rid of it.
2347         In the meantime, we don't want it to be in the set of things the NetworkProcess depends on the WebProcessPool for, which should be an empty set.
2348
2349         * UIProcess/WebProcessPool.cpp:
2350         (WebKit::WebProcessPool::ensureNetworkProcess):
2351         (WebKit::WebProcessPool::registerGlobalURLSchemeAsHavingCustomProtocolHandlers):
2352         (WebKit::WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers):
2353         (WebKit::WebProcessPool::registerSchemeForCustomProtocol): Deleted.
2354         (WebKit::WebProcessPool::unregisterSchemeForCustomProtocol): Deleted.
2355         * UIProcess/WebProcessPool.h:
2356
2357 2019-09-27  Alex Christensen  <achristensen@webkit.org>
2358
2359         Layout Test http/tests/cache-storage/cache-records-persistency.https.html is failing
2360         https://bugs.webkit.org/show_bug.cgi?id=202323
2361
2362         Reviewed by Tim Horton.
2363
2364         This reverts most of r250351.
2365         It turns out NetworkProcessProxy::addSession has some side effects in the UIProcess that are useful for NetworkProcess resumption after crashes.  Let's keep that.
2366
2367         * NetworkProcess/NetworkProcess.cpp:
2368         (WebKit::NetworkProcess::initializeNetworkProcess):
2369         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2370         (WebKit::NetworkProcessCreationParameters::encode const):
2371         (WebKit::NetworkProcessCreationParameters::decode):
2372         * NetworkProcess/NetworkProcessCreationParameters.h:
2373         * UIProcess/WebProcessPool.cpp:
2374         (WebKit::WebProcessPool::ensureNetworkProcess):
2375
2376 2019-09-27  Jer Noble  <jer.noble@apple.com>
2377
2378         Unreviewed build-fix: wrap the AssertionServicesSPI.h in an IOS_FAMILY check.
2379
2380         * WebProcess/cocoa/WebProcessCocoa.mm:
2381
2382 2019-09-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
2383
2384         [iOS]: When inserting a photo and then inserting auto-corrected text, the photo is removed
2385         https://bugs.webkit.org/show_bug.cgi?id=202294
2386
2387         Reviewed by Wenson Hsieh.
2388
2389         WebPage::applyAutocorrectionInternal() calls wordRangeFromPosition() to
2390         calculate the range of the word to be replaced with the auto-corrected
2391         word. But if the text of the range does not match the original text,
2392         applyAutocorrectionInternal() tries to correct the range by moving it
2393         forward such that the length of the text range matches the length of the
2394         original text.
2395
2396         Another case, which should correct the range also, is: the range does not
2397         have a text but it is not collapsed. In this case, we should set the range
2398         back to the selection range so non-text nodes is removed.
2399
2400         * WebProcess/WebPage/ios/WebPageIOS.mm:
2401         (WebKit::WebPage::applyAutocorrectionInternal):
2402
2403 2019-09-27  John Wilander  <wilander@apple.com>
2404
2405         Storage Access API: document.hasStorageAccess() should return false by default
2406         https://bugs.webkit.org/show_bug.cgi?id=202281
2407         <rdar://problem/55718526>
2408
2409         Reviewed by Alex Christensen.
2410
2411         document.hasStorageAccess() should return false by default so that it only
2412         returns true if the context has asked for and been granted storage access.
2413
2414         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
2415         (WebKit::ResourceLoadStatisticsDatabaseStore::hasStorageAccess):
2416         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
2417         (WebKit::ResourceLoadStatisticsMemoryStore::hasStorageAccess):
2418
2419 2019-09-27  Jer Noble  <jer.noble@apple.com>
2420
2421         [iOS] Lock screen controls can fail to play web content
2422         https://bugs.webkit.org/show_bug.cgi?id=202279
2423
2424         Reviewed by Chris Dumez.
2425
2426         When playback is paused from the lock screen via Now Playing controls, the WebProcess,
2427         UIProcess, and Network Process will all be suspended. MediaRemote will take an assertion
2428         and wake up the WebProcess when a remote control command to "play" is sent via the Now
2429         Playing controls. However, if a synchronous message to the (suspended) Network or UIProcess
2430         is issued before the notification that the process was unexpectedly unsuspended can be
2431         issued (which will subsequently unsuspend the UIProcess and Network process), we can get
2432         into a deadlocked state where the main thread is blocked on the sync message to a suspended
2433         process.
2434
2435         To work around this problem, move all the processing from ProcessTaskStateObserver to a
2436         WorkQueue / background thread. This requires making the ProcessTaskStateObserver thread-safe,
2437         though its only current client is a Singleton (the WebProcess class), and so the risk of
2438         thread safety issues is currently minimal. Regardless, access to the Client pointer must be
2439         guarded by a Lock, and the Client itself must become ref-counted, so that the
2440         ProcessTaskStateObserver can ref its Client (the WebProcess) during callback processing.
2441
2442         Unfortunately, sendWithAsyncReply() is not thread safe, nor is ProcessAssertion, so instead
2443         just use send() and set a 5-second timeout before expiring the assertion, and just use
2444         BKSProcessStateAssertion directly.
2445
2446         * Shared/Cocoa/ProcessTaskStateObserver.h:
2447         (WebKit::ProcessTaskStateObserver::Client::ref):
2448         (WebKit::ProcessTaskStateObserver::Client::deref):
2449         (WebKit::ProcessTaskStateObserver::setClient): Deleted.
2450         (WebKit::ProcessTaskStateObserver::client): Deleted.
2451         * Shared/Cocoa/ProcessTaskStateObserver.mm:
2452         (-[WKProcessTaskStateObserverDelegate process:taskStateDidChange:]):
2453         (WebKit::ProcessTaskStateObserver::create):
2454         (WebKit::ProcessTaskStateObserver::ProcessTaskStateObserver):
2455         (WebKit::ProcessTaskStateObserver::~ProcessTaskStateObserver):
2456         (WebKit::ProcessTaskStateObserver::invalidate):
2457         (WebKit::ProcessTaskStateObserver::client):
2458         (WebKit::ProcessTaskStateObserver::setTaskState):
2459         * WebProcess/WebProcess.cpp:
2460         (WebKit::m_taskStateObserver):
2461         * WebProcess/WebProcess.h:
2462         * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
2463         (WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended):
2464         * UIProcess/WebProcessProxy.h:
2465         * UIProcess/WebProcessProxy.messages.in:
2466         * WebProcess/cocoa/WebProcessCocoa.mm:
2467         (WebKit::WebProcess::processTaskStateDidChange):
2468
2469 2019-09-27  Alex Christensen  <achristensen@webkit.org>
2470
2471         Move service worker process termination delay disabling from process pool to website data store
2472         https://bugs.webkit.org/show_bug.cgi?id=202308
2473
2474         Reviewed by Chris Dumez.
2475
2476         It's only there for a test, which still works quickly.
2477
2478         * NetworkProcess/NetworkProcess.cpp:
2479         (WebKit::NetworkProcess::initializeNetworkProcess):
2480         (WebKit::NetworkProcess::addWebsiteDataStore):
2481         (WebKit::NetworkProcess::destroySession):
2482         (WebKit::NetworkProcess::fetchWebsiteData):
2483         (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains):
2484         (WebKit::NetworkProcess::registrableDomainsWithWebsiteData):
2485         (WebKit::NetworkProcess::swServerForSession):
2486         (WebKit::NetworkProcess::addServiceWorkerSession):
2487         (WebKit::NetworkProcess::disableServiceWorkerProcessTerminationDelay): Deleted.
2488         * NetworkProcess/NetworkProcess.h:
2489         * NetworkProcess/NetworkProcess.messages.in:
2490         * Shared/WebsiteDataStoreParameters.cpp:
2491         (WebKit::WebsiteDataStoreParameters::encode const):
2492         (WebKit::WebsiteDataStoreParameters::decode):
2493         * Shared/WebsiteDataStoreParameters.h:
2494         * UIProcess/API/Cocoa/WKProcessPool.mm:
2495         (-[WKProcessPool _disableServiceWorkerProcessTerminationDelay]): Deleted.
2496         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
2497         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
2498         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
2499         (-[_WKWebsiteDataStoreConfiguration serviceWorkerProcessTerminationDelayEnabled]):
2500         (-[_WKWebsiteDataStoreConfiguration setServiceWorkerProcessTerminationDelayEnabled:]):
2501         * UIProcess/WebProcessPool.cpp:
2502         (WebKit::WebProcessPool::ensureNetworkProcess):
2503         (WebKit::WebProcessPool::disableServiceWorkerProcessTerminationDelay): Deleted.
2504         * UIProcess/WebProcessPool.h:
2505         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
2506         (WebKit::WebsiteDataStore::parameters):
2507         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
2508         (WebKit::WebsiteDataStoreConfiguration::copy):
2509         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
2510         (WebKit::WebsiteDataStoreConfiguration::serviceWorkerProcessTerminationDelayEnabled const):
2511         (WebKit::WebsiteDataStoreConfiguration::setServiceWorkerProcessTerminationDelayEnabled):
2512
2513 2019-09-27  Alex Christensen  <achristensen@webkit.org>
2514
2515         Enable and disable ResourceLoadStatistics only by session
2516         https://bugs.webkit.org/show_bug.cgi?id=202298
2517
2518         Reviewed by Chris Dumez.
2519
2520         This is needed to keep per-session things per-session and per-process-pool things per-process-pool.
2521         This was a strange case where we would take the current session's value and apply it globally.
2522         This has no change in behavior because it is globally enabled and disabled by API clients anyways.
2523
2524         * NetworkProcess/NetworkProcess.cpp:
2525         (WebKit::NetworkProcess::setResourceLoadStatisticsEnabled):
2526         * NetworkProcess/NetworkProcess.h:
2527         * NetworkProcess/NetworkProcess.messages.in:
2528         * UIProcess/API/Cocoa/WKWebView.mm:
2529         (-[WKWebView _initializeWithConfiguration:]):
2530         * UIProcess/WebProcessPool.cpp:
2531         (WebKit::WebProcessPool::setResourceLoadStatisticsEnabled): Deleted.
2532         * UIProcess/WebProcessPool.h:
2533         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2534         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
2535
2536 2019-09-27  Alex Christensen  <achristensen@webkit.org>
2537
2538         Remove unused WebProcessPool::setCanHandleHTTPSServerTrustEvaluation
2539         https://bugs.webkit.org/show_bug.cgi?id=202285
2540
2541         Reviewed by Youenn Fablet.
2542
2543         The SPI to set this was deprecated in r250377 with a replacement that was adopted in rdar://problem/55731135
2544         I removed a layout test using the old SPI and replaced it with a more precise API test verifying the behavior of the new SPI
2545         before and after the introduction of NSURLSession's _strictTrustEvaluate:queue:completionHandler:
2546
2547         * NetworkProcess/NetworkProcess.cpp:
2548         (WebKit::NetworkProcess::initializeNetworkProcess):
2549         (WebKit::NetworkProcess::setCanHandleHTTPSServerTrustEvaluation): Deleted.
2550         * NetworkProcess/NetworkProcess.h:
2551         (WebKit::NetworkProcess::canHandleHTTPSServerTrustEvaluation const): Deleted.
2552         * NetworkProcess/NetworkProcess.messages.in:
2553         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2554         (WebKit::NetworkProcessCreationParameters::encode const):
2555         (WebKit::NetworkProcessCreationParameters::decode):
2556         * NetworkProcess/NetworkProcessCreationParameters.h:
2557         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
2558         (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
2559         (canNSURLSessionTrustEvaluate): Deleted.
2560         * UIProcess/API/C/WKContext.cpp:
2561         (WKContextSetCanHandleHTTPSServerTrustEvaluation):
2562         * UIProcess/API/Cocoa/WKProcessPool.mm:
2563         (-[WKProcessPool _setCanHandleHTTPSServerTrustEvaluation:]):
2564         * UIProcess/WebProcessPool.cpp:
2565         (WebKit::WebProcessPool::ensureNetworkProcess):
2566         (WebKit::WebProcessPool::setCanHandleHTTPSServerTrustEvaluation): Deleted.
2567         * UIProcess/WebProcessPool.h:
2568
2569 2019-09-27  Alex Christensen  <achristensen@webkit.org>
2570
2571         Remove unused APIProcessPoolConfiguration::diskCacheSpeculativeValidationEnabled
2572         https://bugs.webkit.org/show_bug.cgi?id=202290
2573
2574         Reviewed by Carlos Garcia Campos.
2575
2576         The SPI to set this was deprecated in r250377 with a replacement that was adopted in rdar://problem/55731135
2577
2578         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2579         (WebKit::NetworkProcessCreationParameters::encode const):
2580         (WebKit::NetworkProcessCreationParameters::decode):
2581         * NetworkProcess/NetworkProcessCreationParameters.h:
2582         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
2583         (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
2584         * UIProcess/API/APIProcessPoolConfiguration.cpp:
2585         (API::ProcessPoolConfiguration::copy):
2586         * UIProcess/API/APIProcessPoolConfiguration.h:
2587         * UIProcess/API/C/WKContext.cpp:
2588         (WKContextSetDiskCacheSpeculativeValidationEnabled):
2589         * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp:
2590         (WKWebsiteDataStoreConfigurationGetNetworkCacheSpeculativeValidationEnabled):
2591         (WKWebsiteDataStoreConfigurationSetNetworkCacheSpeculativeValidationEnabled):
2592         * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.h:
2593         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
2594         (-[_WKProcessPoolConfiguration diskCacheSpeculativeValidationEnabled]):
2595         (-[_WKProcessPoolConfiguration setDiskCacheSpeculativeValidationEnabled:]):
2596         * UIProcess/WebProcessPool.cpp:
2597         (WebKit::WebProcessPool::ensureNetworkProcess):
2598
2599 2019-09-27  Zan Dobersek  <zdobersek@igalia.com>
2600
2601         [CoordinatedGraphics] support bounds origin
2602         https://bugs.webkit.org/show_bug.cgi?id=198998
2603
2604         Reviewed by Carlos Garcia Campos.
2605
2606         * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
2607         (WebKit::CoordinatedGraphicsScene::updateSceneState):
2608         Apply bounds origin value to the TextureMapperLayer object.
2609
2610 2019-09-27  Youenn Fablet  <youenn@apple.com>
2611
2612         Make IsNSURLSessionWebSocketEnabled an experimental flag
2613         https://bugs.webkit.org/show_bug.cgi?id=202135
2614         <rdar://problem/55694721>
2615
2616         Reviewed by Geoff Garen.
2617
2618         Add C API to switch off this feature in WTR.
2619
2620         * Shared/WebPreferences.yaml:
2621         * UIProcess/API/C/WKPreferences.cpp:
2622         (WKPreferencesSetIsNSURLSessionWebSocketEnabled):
2623         (WKPreferencesGetIsNSURLSessionWebSocketEnabled):
2624         * UIProcess/API/C/WKPreferencesRefPrivate.h:
2625
2626 2019-09-27  Jiewen Tan  <jiewen_tan@apple.com>
2627
2628         SubFrameSOAuthorizationSession should ensure messages are posted in the right order to the parent frame
2629         https://bugs.webkit.org/show_bug.cgi?id=202061
2630         <rdar://problem/55485666>
2631
2632         Reviewed by Youenn Fablet.
2633
2634         This patch ensures messages that signal the process of SOAuthorization interception are posted in
2635         the right order to the parent frame. Before this patch, there are chances that SOAuthorizationDidCancel
2636         could be posted to the parent before SOAuthorizationDidStart. There are few causes that lead to
2637         this race condition:
2638         1) SubFrameSOAuthorizationSession::beforeStart posts SOAuthorizationDidStart in the next runloop. So
2639         extension could have the chance to invoke SubFrameSOAuthorizationSession::fallBackToWebPathInternal
2640         before SOAuthorizationDidStart is posted.
2641         2) Even if the order is right in the UI process, it is not guaranteed that Web process will strictly
2642         follow the order as the loading process is async.
2643
2644         To fix the issue:
2645         1) SubFrameSOAuthorizationSession::beforeStart now posts SOAuthorizationDidStart in the same runloop.
2646         2) Observer is introduced in FrameLoadState such that SubFrameSOAuthorizationSession could know if
2647         the loading is finished. With this new capacity, SubFrameSOAuthorizationSession can ensure it only
2648         posts next message when the previous message has been posted.
2649
2650         Implementation wise, a deque to queue requests is provided to maintain order.
2651         1) When new request is added to the deque, SubFrameSOAuthorizationSession will only load the request
2652         if it is the only element in the deque. Otherwise, it does nothing.
2653         2) When SubFrameSOAuthorizationSession receives didFinishLoad, it pops the head of the queue and loads
2654         the next request in the queue if any.
2655         The above design should guarantee all requests are loaded in sequence.
2656
2657         * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h:
2658         * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:
2659         (WebKit::SubFrameSOAuthorizationSession::SubFrameSOAuthorizationSession):
2660         (WebKit::SubFrameSOAuthorizationSession::~SubFrameSOAuthorizationSession):
2661         (WebKit::SubFrameSOAuthorizationSession::fallBackToWebPathInternal):
2662         (WebKit::SubFrameSOAuthorizationSession::completeInternal):
2663         (WebKit::SubFrameSOAuthorizationSession::beforeStart):
2664         (WebKit::SubFrameSOAuthorizationSession::didFinishLoad):
2665         (WebKit::SubFrameSOAuthorizationSession::appendRequestToLoad):
2666         (WebKit::SubFrameSOAuthorizationSession::loadRequestToFrame):
2667         (WebKit::SubFrameSOAuthorizationSession::loadDataToFrame): Deleted.
2668         (WebKit::SubFrameSOAuthorizationSession::postDidCancelMessageToParent): Deleted.
2669         * UIProcess/FrameLoadState.cpp:
2670         (WebKit::FrameLoadState::addObserver):
2671         (WebKit::FrameLoadState::removeObserver):
2672         (WebKit::FrameLoadState::didFinishLoad):
2673         * UIProcess/FrameLoadState.h:
2674
2675 2019-09-26  Kate Cheney  <katherine_cheney@apple.com>
2676
2677         Resource Load Statistics: Downgrade all third-party referrer headers
2678         https://bugs.webkit.org/show_bug.cgi?id=201353
2679         <rdar://problem/54895650>
2680         
2681         Majority of this patch was written by John Wilander <wilander@apple.com>.
2682
2683         Reviewed by Brent Fulgham. 
2684
2685         When tracking protections are enabled, we should downgrade all third-party
2686         referrers to their origins. Note that this downgrade will be specific to
2687         Cocoa so other ports will have to adopt as they see fit.
2688
2689         Cocoa already does this downgrade in ephemeral sessions (shipping).
2690
2691         The majority of these changes are test infrastructure. The functional
2692         change is in WebKit::NetworkDataTaskCocoa and WebKit::NetworkSession.
2693
2694         * NetworkProcess/NetworkProcess.cpp:
2695         (WebKit::NetworkProcess::setShouldDowngradeReferrerForTesting):
2696         * NetworkProcess/NetworkProcess.h:
2697         * NetworkProcess/NetworkProcess.messages.in:
2698         * NetworkProcess/NetworkSession.cpp:
2699         (WebKit::NetworkSession::isResourceLoadStatisticsEnabled const):
2700         (WebKit::NetworkSession::setShouldDowngradeReferrerForTesting):
2701         (WebKit::NetworkSession::shouldDowngradeReferrer const):
2702         * NetworkProcess/NetworkSession.h:
2703         * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
2704         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
2705         (WebKit::NetworkDataTaskCocoa::isThirdPartyRequest const):
2706         (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
2707         (WebKit::NetworkDataTaskCocoa::restrictRequestReferrerToOriginIfNeeded):
2708         (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
2709         (WebKit::NetworkDataTaskCocoa::isThirdPartyRequest): Deleted.
2710         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
2711         (WKWebsiteDataStoreSetResourceLoadStatisticsShouldDowngradeReferrerForTesting):
2712         (WKWebsiteDataStoreStatisticsResetToConsistentState):
2713         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
2714         * UIProcess/Network/NetworkProcessProxy.cpp:
2715         (WebKit::NetworkProcessProxy::setShouldDowngradeReferrerForTesting):
2716         * UIProcess/Network/NetworkProcessProxy.h:
2717         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2718         (WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldDowngradeReferrerForTesting):
2719         * UIProcess/WebsiteData/WebsiteDataStore.h:
2720
2721 2019-09-26  Eric Carlson  <eric.carlson@apple.com>
2722
2723         REGRESSION (iOS 13): Trying to record just audio using HTML Media Capture crashes Safari
2724         https://bugs.webkit.org/show_bug.cgi?id=202039
2725         <rdar://problem/55566628>
2726
2727         Reviewed by Jer Noble.
2728
2729         * UIProcess/ios/forms/WKFileUploadPanel.mm:
2730         (-[WKFileUploadPanel _mediaTypesForPickerSourceType:]): UIImagePickerController doesn't 
2731         support audio-only recording, so show the video recorder for "audio/*".
2732
2733 2019-09-26  Tim Horton  <timothy_horton@apple.com>
2734
2735         Add some logging to help diagnose blank or stuck WKWebViews
2736         https://bugs.webkit.org/show_bug.cgi?id=202297
2737         <rdar://problem/55763610>
2738
2739         Reviewed by Wenson Hsieh.
2740
2741         Our current logging is insufficient to rule out some of the potential
2742         causes of stuck/blank WKWebViews in <rdar://problem/53399054>. Add
2743         some new logging, and improve some existing logging, to aid in diagnosis.
2744
2745         * UIProcess/API/Cocoa/WKWebView.mm:
2746         (-[WKWebView _willInvokeUIScrollViewDelegateCallback]):
2747         (-[WKWebView _didInvokeUIScrollViewDelegateCallback]):
2748         Rename _delayUpdateVisibleContentRects to be more specific that it
2749         was due to us being underneath a UIScrollView delegate callback.
2750
2751         (-[WKWebView _processWillSwapOrDidExit]):
2752         (-[WKWebView _didCommitLayerTree:]):
2753         Add a log when we receive an incoming commit while visible content rect
2754         updates are being deferred. Also, include the current transaction ID
2755         and the transaction ID that _needsResetViewState... is waiting for, to
2756         help rule out a class of potential problems.
2757
2758         Add a log when we receive an incoming commit more than 5 seconds after
2759         a visible content rect update.
2760
2761         (-[WKWebView _updateVisibleContentRects]):
2762         Keep track of when we defer visual content rect updates for any reason,
2763         and log the first time we do an update after deferring them. This will make
2764         it MUCH easier at-a-glance to tell if one of the "bailing" messages
2765         represents a long-term state (a problem), or is expected.
2766
2767         Keep track of how long it's been since we sent a visible content rect update
2768         and didn't get a commit back from the Web Content process; if it's been
2769         more than 5 seconds, start logging.
2770
2771         (-[WKWebView _cancelAnimatedResize]):
2772         (-[WKWebView _didCompleteAnimatedResize]):
2773         (-[WKWebView _beginAnimatedResizeWithUpdates:]):
2774         (-[WKWebView _endAnimatedResize]):
2775         (-[WKWebView _resizeWhileHidingContentWithUpdates:]):
2776         Turn animated resize logging into release logging. It is a common culprit
2777         for many kinds of bugs, while also not being high volume, so this is well worth it.
2778         
2779         * WebProcess/WebPage/WebPage.cpp:
2780         (WebKit::WebPage::freezeLayerTree):
2781         (WebKit::WebPage::unfreezeLayerTree):
2782         Show the current value of m_layerTreeFreezeReasons in addition to the old value and delta,
2783         so you don't have to manually compute the current value when reading logs.
2784
2785 2019-09-26  Dean Jackson  <dino@apple.com>
2786
2787         ContextMenu on a link in an email no longer shows web preview
2788         https://bugs.webkit.org/show_bug.cgi?id=201120
2789         <rdar://54353617>
2790
2791         Reviewed by Wenson Hsieh.
2792
2793         Only go down the image path if we are not also a link.
2794
2795         * UIProcess/ios/WKContentViewInteraction.mm:
2796         (-[WKContentView continueContextMenuInteraction:]):
2797
2798 2019-09-26  Chris Dumez  <cdumez@apple.com>
2799
2800         Stop using testRunner.overridePreference() to turn on Page Cache
2801         https://bugs.webkit.org/show_bug.cgi?id=202274
2802
2803         Reviewed by Alex Christensen.
2804
2805         * WebProcess/InjectedBundle/InjectedBundle.cpp:
2806         (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
2807
2808 2019-09-26  Andy Estes  <aestes@apple.com>
2809
2810         Crash under WebPage::beginPrinting when m_printContext becomes null due to synchronous layout
2811         https://bugs.webkit.org/show_bug.cgi?id=202171
2812         <rdar://problem/49731211>
2813
2814         Reviewed by Tim Horton.
2815
2816         Speculatively fix a null pointer dereference crash in WebPage::beginPrinting.
2817
2818         WebPage::beginPrinting creates a PrintContext, stores it in m_printContext, then calls
2819         PrintContext::begin which forces a synchronous, paginated layout. If a post-layout task
2820         executes script, that might result in the WebPage being closed and m_printContext being set
2821         to nullptr.
2822
2823         Guard against this in WebPage::beginPrinting by adding a null check before calling
2824         PrintContext::computePageRects.
2825
2826         * WebProcess/WebPage/WebPage.cpp:
2827         (WebKit::WebPage::beginPrinting):
2828
2829 2019-09-26  Kate Cheney  <katherine_cheney@apple.com>
2830
2831         Enable LayoutTests using ResourceLoadStatistics SQLite backend (195420)
2832         https://bugs.webkit.org/show_bug.cgi?id=195420
2833         <rdar://problem/54213551>
2834
2835         Reviewed by Brent Fulgham.
2836
2837         Changed all RELEASE_LOG_ERROR() calls involving domain strings to
2838         RELEASE_LOG_ERROR_IF_ALLOWED() to prevent leaking information about
2839         the domain strings only if sessionID.isAlwaysOnLoggingAllowed().
2840
2841         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
2842         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
2843         Added autovacuuming to the constructor to avoid manually calling
2844         runVacuumCommand(). Changed constructor to take in sessionID so it
2845         can use RELEASE_LOG_ERROR_IF_ALLOWED which requires the sessionID.
2846
2847         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements):
2848         Added 2 statements that were not being prepared.
2849
2850         (WebKit::ResourceLoadStatisticsDatabaseStore::relationshipExists const):
2851         Corrected incorrect capitalization. Added check for nullopt in case
2852         domainID is for a domain not in the database yet.
2853
2854         (WebKit::ResourceLoadStatisticsDatabaseStore::domainID const):
2855         Changed return value to Optional<unsigned>. Some tests were directly
2856         checking for subframes under top frame domains on domains that had
2857         not been inserted yet. Now, domainID() won't crash but will return
2858         a nullopt value which can be checked to know that the tests failed.
2859
2860         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
2861         Added a check to assure domainID exists and updated the domainID
2862         interactions to work as Optionals.
2863
2864         (WebKit::ResourceLoadStatisticsDatabaseStore::populateFromMemoryStore):
2865         Moved the prepareStatements() call after the vacuum command in the case
2866         where the database is empty. Otherwise called it before returning.
2867
2868         (WebKit::ResourceLoadStatisticsDatabaseStore::recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain):
2869         Added a space to the SQL commands to correct the syntax.
2870
2871         (WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources):
2872         Corrected a bug in the SQL command for querying
2873         subframeUnderTopFrameDomain. The old query was asking for subresource.
2874
2875         (WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources):
2876         Spelling fix.
2877
2878         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
2879         Changed string concatenation to binding.
2880
2881         (WebKit::ResourceLoadStatisticsDatabaseStore::grandfatherDataForDomains):
2882         The grandfathering.html test was failing because domains were being
2883         "set" to grandfathered in the database before being inserted. This fix
2884         ensures all domains before setting the grandfathering flag.
2885
2886         (WebKit::ResourceLoadStatisticsDatabaseStore::logFrameNavigation):
2887         Multiple tests were failing because the query to insert the relationship
2888         for the source domain relies on the target domain being in the
2889         ObservedDomains table. This patch ensures all domains are added before
2890         performing the query.
2891
2892         (WebKit::ResourceLoadStatisticsDatabaseStore::setUserInteraction):
2893         Added a != SQLITE_OK check to make sure an error is logged if the
2894         statement fails to bind.
2895
2896         (WebKit::ResourceLoadStatisticsDatabaseStore::clearUserInteraction):
2897         Changed string concatenation to binding.
2898
2899         (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction):   
2900         The SQL statement was being bound to a value and not being reset. This
2901         patch resets the statement after binding. Additionally, the step()
2902         function was being compared to SQLITE_DONE instead of SQLITE_ROW,
2903         causing an error if the query returned results. The
2904         ASSERT_NOT_REACHED() was causing null searches to crash instead of
2905         returning false (i.e. if a domain is not in the database it should
2906         return that it has no user interaction instead of crashing).
2907
2908         (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource): 
2909         Updated domainID call to act as an Optional. 
2910         
2911         (WebKit::ResourceLoadStatisticsDatabaseStore::predicateValueForDomain const):
2912         The SQL statement was being bound to a value and not being reset. This
2913         patch resets the statement after binding. SQLITE_DONE changed to
2914         SQLITE_ROW to return non-empty query results. ASSERT_NOT_REACHED()
2915         removed for the same reasons as above. 
2916
2917         (WebKit::ResourceLoadStatisticsDatabaseStore::ensureResourceStatisticsForRegistrableDomain):
2918         Fixed the release log statement which was logging the wrong function 
2919         name.
2920
2921         (WebKit::ResourceLoadStatisticsDatabaseStore::clearDatabaseContents): 
2922         Clears the database and rebuilds the tables on a clear command to
2923         match the functionality in the Memory Store.
2924
2925         (WebKit::ResourceLoadStatisticsDatabaseStore::clear):                   
2926         Call the clearDatabaseContents function to match the functionality 
2927         in the Memory Store. 
2928
2929         (WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt const):
2930         Updated domainID call to act as an Optional. 
2931
2932         (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUnexpiredRecentUserInteraction):
2933         Tests were failing because shouldRemoveAllWebsiteDataFor() was not 
2934         checking for expired user interaction. Matched functionality in the
2935         Memory Store.
2936
2937         (WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllWebsiteDataFor):
2938         Tests were failing because shouldRemoveAllWebsiteDataFor() was not 
2939         checking for expired user interaction. Matched functionality in the
2940         Memory Store. 
2941
2942         (WebKit::ResourceLoadStatisticsDatabaseStore::registrableDomainsToRemoveWebsiteDataFor):
2943         Spelling fix. 
2944
2945         (WebKit::ResourceLoadStatisticsDatabaseStore::pruneStatisticsIfNeeded): 
2946         Last seen should be sorted in ascending order because you want to 
2947         prune the older statistics first, which will have a lower lastSeen
2948         field (secondsSinceEpoch() will be lower for older values).
2949
2950         (WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllWebsiteDataFor const): Deleted.
2951         Deleted const specifier because the function needs to clear the
2952         database. 
2953
2954         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:      
2955         Declared new functions. Updated spelling error (registerable --> 
2956         registrable). Updated constructor to take sessionID. 
2957
2958         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 
2959         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
2960         ITP database flag now is stored in the NetworkProcess.
2961         * NetworkProcess/NetworkProcess.cpp: 
2962
2963         (WebKit::NetworkProcess::initializeNetworkProcess): 
2964         Set the ITP database flag which is now stored in the Network Process. 
2965
2966         (WebKit::NetworkProcess::setUseITPDatabase): 
2967         * NetworkProcess/NetworkProcess.h:
2968         (WebKit::NetworkProcess::isITPDatabaseEnabled const):
2969         * NetworkProcess/NetworkProcess.messages.in:
2970         Passed the setUseITPDatabase flag to the initialization function 
2971         of the statistics store to enable the database backend.
2972
2973         * NetworkProcess/NetworkSession.cpp:
2974         (WebKit::NetworkSession::NetworkSession):
2975         SandboxExtension::consumePermanently was not getting called on the 
2976         WebKitTestRunner resourceLoadStatistics path. This was preventing
2977         the database file from opening. 
2978
2979         (WebKit::NetworkSession::recreateResourceLoadStatisticStore):
2980         Destroy old WebResourceLoadStatisticsStore and create a new one using
2981         the ITP database.
2982
2983         * NetworkProcess/NetworkSession.h:
2984         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
2985         (WKWebsiteDataStoreSetUseITPDatabase):
2986         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
2987         * UIProcess/Network/NetworkProcessProxy.cpp:
2988         (WebKit::NetworkProcessProxy::setUseITPDatabase):
2989         * UIProcess/Network/NetworkProcessProxy.h:
2990         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2991         (WebKit::WebsiteDataStore::setUseITPDatabase):
2992         * UIProcess/WebsiteData/WebsiteDataStore.h:
2993         Passed the setUseITPDatabase flag to the initialization function
2994         of the statistics store to enable the database backend. 
2995
2996 2019-09-26  Wenson Hsieh  <wenson_hsieh@apple.com>
2997
2998         [iOS 13] Tapping on a non-editable text selection should toggle callout bar visibility instead of clearing selection
2999         https://bugs.webkit.org/show_bug.cgi?id=202254
3000         <rdar://problem/54410263>
3001
3002         Reviewed by Megan Gardner.
3003
3004         In iOS 13, tapping a text selection should toggle callout bar visibility (i.e. "selection commands" in UIKit).
3005         This currently does not work for non-editable text, since the synthetic click gesture simultaneously fires
3006         alongside the text interaction assistant's non-editable tap gesture, which dispatches a click to the page which
3007         then clears the selection.
3008
3009         To remedy this and match platform behavior, we avoid recognizing clicks that occur over the text selection, but
3010         only in the case where the bounding rect of the text selection doesn't cover a large portion of the visible
3011         content rect of the web view. This ensures that the user doesn't get stuck in a state where it's impossible to
3012         dismiss a very large text selection (e.g. after selecting all the content on the page).
3013
3014         Tests:  editing/selection/ios/clear-selection-after-tap-in-large-selected-non-editable-text.html
3015                 editing/selection/ios/toggle-callout-bar-after-tap-in-selected-non-editable-text.html
3016
3017         * UIProcess/ios/WKContentViewInteraction.mm:
3018         (-[WKContentView _shouldToggleSelectionCommandsAfterTapAt:]):
3019
3020         Check the last known selection rects (on _lastSelectionDrawingInfo) to see if the tapped point lies within at
3021         least one of the selection rects.
3022
3023         (-[WKContentView gestureRecognizerShouldBegin:]):
3024
3025 2019-09-26  Patrick Griffis  <pgriffis@igalia.com>
3026
3027         [GTK] Fix logic of dark theme detection
3028         https://bugs.webkit.org/show_bug.cgi?id=202276
3029
3030         - If GTK_THEME is set it has a higher priority to GtkSettings.
3031         - GTK_THEME may be a -dark theme or :dark variant, handle both.
3032
3033         Reviewed by Michael Catanzaro.
3034
3035         * UIProcess/API/gtk/PageClientImpl.cpp:
3036         (WebKit::PageClientImpl::effectiveAppearanceIsDark const):
3037
3038 2019-09-25  Alex Christensen  <achristensen@webkit.org>
3039
3040         Add replacement SPI on _WKWebsiteDataStoreConfiguration for enabling speculative cache validation and IPC-free server trust evaluation
3041         https://bugs.webkit.org/show_bug.cgi?id=202251
3042
3043         Reviewed by Tim Horton.
3044
3045         These are two performance optimizations that are currently per-ProcessPool that need to be per-WebsiteDataStore.
3046         This makes replacement SPI and deprecates the old SPI.  I'm going to adopt the new SPI then remove the old SPI.
3047
3048         * NetworkProcess/NetworkSession.cpp:
3049         (WebKit::NetworkSession::NetworkSession):
3050         * NetworkProcess/NetworkSessionCreationParameters.cpp:
3051         (WebKit::NetworkSessionCreationParameters::encode const):
3052         (WebKit::NetworkSessionCreationParameters::decode):
3053         * NetworkProcess/NetworkSessionCreationParameters.h:
3054         * NetworkProcess/cocoa/NetworkSessionCocoa.h:
3055         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
3056         (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
3057         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
3058         * UIProcess/API/C/WKContextPrivate.h:
3059         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
3060         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
3061         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
3062         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
3063         (-[_WKWebsiteDataStoreConfiguration networkCacheSpeculativeValidationEnabled]):
3064         (-[_WKWebsiteDataStoreConfiguration setNetworkCacheSpeculativeValidationEnabled:]):
3065         (-[_WKWebsiteDataStoreConfiguration fastServerTrustEvaluationEnabled]):
3066         (-[_WKWebsiteDataStoreConfiguration setFastServerTrustEvaluationEnabled:]):
3067         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
3068         (WebKit::WebsiteDataStore::parameters):
3069         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
3070         (WebKit::WebsiteDataStoreConfiguration::copy):
3071         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
3072         (WebKit::WebsiteDataStoreConfiguration::fastServerTrustEvaluationEnabled const):
3073         (WebKit::WebsiteDataStoreConfiguration::setFastServerTrustEvaluationEnabled):
3074         (WebKit::WebsiteDataStoreConfiguration::networkCacheSpeculativeValidationEnabled const):
3075         (WebKit::WebsiteDataStoreConfiguration::setNetworkCacheSpeculativeValidationEnabled):
3076
3077 2019-09-25  Wenson Hsieh  <wenson_hsieh@apple.com>
3078
3079         Fix failing layout tests after trac.webkit.org/r250183
3080         https://bugs.webkit.org/show_bug.cgi?id=202053
3081         <rdar://problem/54542190>
3082
3083         Reviewed by Tim Horton.
3084
3085         Followup to r250183: move the implementation of -gestureRecognizer:shouldReceiveTouch: out of
3086         ENABLE(TOUCH_EVENTS) and into ENABLE(POINTER_EVENTS) instead. This logic is necessary in order for scrolling
3087         via pan gestures to work on iOS, in the case where ENABLE(POINTER_EVENTS) is on but ENABLE(TOUCH_EVENTS) is off.
3088         This is because the new swipe gesture recognizers added in r250183 will otherwise always take priority over the
3089         scroll view's pan gestures.
3090
3091         Fixes the following layout tests:
3092         - fast/scrolling/ios/reconcile-layer-position-recursive.html
3093         - fast/scrolling/ios/click-events-during-momentum-scroll-in-main-frame.html
3094         - fast/scrolling/ios/click-events-after-long-press-during-momentum-scroll-in-main-frame.html
3095
3096         * UIProcess/ios/WKContentViewInteraction.mm:
3097
3098 2019-09-25  Megan Gardner  <megan_gardner@apple.com>
3099
3100         Update selections after scrolling for iframes and hide selections while iframes and overflow scrolls are scrolling.
3101         https://bugs.webkit.org/show_bug.cgi?id=202125
3102
3103         Reviewed by Tim Horton.
3104
3105         Add additional calls into UIKit differentiate between main frame scrolling and overflow/iframe scrolling.
3106         Add piping for iframe specific scrolling.
3107
3108         * Platform/spi/ios/UIKitSPI.h:
3109         * UIProcess/ios/WKContentViewInteraction.mm:
3110         (-[WKContentView _willStartScrollingOrZooming]):
3111         (-[WKContentView _didEndScrollingOrZooming]):
3112         * WebProcess/WebCoreSupport/WebEditorClient.cpp:
3113         (WebKit::WebEditorClient::subFrameScrollPositionChanged):
3114         * WebProcess/WebCoreSupport/WebEditorClient.h:
3115         * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
3116         (WebKit::WebEditorClient::subFrameScrollPositionChanged):
3117
3118 2019-09-25  Wenson Hsieh  <wenson_hsieh@apple.com>
3119
3120         Page temporarily jumps to an excessively small viewport scale while loading usatoday.com
3121         https://bugs.webkit.org/show_bug.cgi?id=202224
3122         <rdar://problem/52906640>
3123
3124         Reviewed by Tim Horton.
3125
3126         Tweaks the content-aware shrink-to-fit algorithm to bail in the case where the content width is extremely large,
3127         such that it bails instead of attempting to fit the entire content of the page. See WebCore ChangeLog for more
3128         details.
3129
3130         * WebProcess/WebPage/ios/WebPageIOS.mm:
3131         (WebKit::WebPage::immediatelyShrinkToFitContent):
3132
3133 2019-09-25  Alex Christensen  <achristensen@webkit.org>
3134
3135         Don't fall back to default session if session can't be found for cookie operations
3136         https://bugs.webkit.org/show_bug.cgi?id=202222
3137
3138         Reviewed by Geoff Garen.
3139
3140         Apparently, during teardown of private browsing sessions, there is sometimes a race condition and cookies from a torn-down session are requested.
3141         In this case, just fail like we do all other operations in this file.  Otherwise, it's a breach of privacy.
3142
3143         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
3144         (WebKit::NetworkConnectionToWebProcess::storageSession):
3145         (WebKit::NetworkConnectionToWebProcess::cookiesForDOM):
3146         (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM):
3147         (WebKit::NetworkConnectionToWebProcess::cookiesEnabled):
3148         (WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue):
3149         (WebKit::NetworkConnectionToWebProcess::getRawCookies):
3150         (WebKit::NetworkConnectionToWebProcess::deleteCookie):
3151         * NetworkProcess/NetworkConnectionToWebProcess.h:
3152
3153 2019-09-25  Alex Christensen  <achristensen@webkit.org>
3154
3155         Remove duplicate WebsiteDataStoreConfiguration copying code
3156         https://bugs.webkit.org/show_bug.cgi?id=202215
3157
3158         Reviewed by Tim Horton.
3159
3160         WKWebsiteDataStore's _initWithConfiguration was duplicating the functionality of WebsiteDataStoreConfiguration::copy.
3161         The former should just call the latter.
3162         This move has the side effect of making _WKWebsiteDataStoreConfiguration's paths readable, which I think is desirable so I added a unit test verifying it is so.
3163
3164         * UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp:
3165         (WKWebsiteDataStoreConfigurationCreate):
3166         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
3167         (-[WKWebsiteDataStore _initWithConfiguration:]):
3168         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
3169         (-[_WKWebsiteDataStoreConfiguration init]):
3170         (-[_WKWebsiteDataStoreConfiguration initNonPersistentConfiguration]):
3171         * UIProcess/WebProcessPool.cpp:
3172         (WebKit::WebProcessPool::mayHaveRegisteredServiceWorkers):
3173         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3174         (WebKit::WebsiteDataStore::createNonPersistent):
3175         (WebKit::WebsiteDataStore::defaultDataStore):
3176         (WebKit::WebsiteDataStore::defaultDataStoreConfiguration): Deleted.
3177         * UIProcess/WebsiteData/WebsiteDataStore.h:
3178         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
3179         (WebKit::WebsiteDataStoreConfiguration::WebsiteDataStoreConfiguration):
3180         (WebKit::WebsiteDataStoreConfiguration::copy):
3181         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
3182         (WebKit::WebsiteDataStoreConfiguration::create):
3183         (WebKit::WebsiteDataStoreConfiguration::isPersistent const):
3184         (WebKit::WebsiteDataStoreConfiguration::setPersistent): Deleted.
3185
3186 2019-09-25  Alex Christensen  <achristensen@webkit.org>
3187
3188         Replace WebsiteDataStoreParameters::privateSessionParameters with re-initializing all sessions immediately upon NetworkProcess resumption
3189         https://bugs.webkit.org/show_bug.cgi?id=202211
3190
3191         Reviewed by Tim Horton.
3192
3193         Re-adding an ephemeral session after a NetworkProcess crash based on guessing that all its parameters are empty was added in r227590 with a test.
3194         That test passes even when that re-adding code is removed because we re-add all sessions with parameters from the UIProcess when we restart a NetworkProcess.
3195         I move the addition of non-default sessions to the initialization message instead of messages after the initialization message to remove race conditions that
3196         might cause loads to happen before the NetworkProcess has received its second message from the UIProcess.  I also add a unit test to verify that session
3197         resumption also works with non-default persistent WebsiteDataStores.
3198
3199         * NetworkProcess/NetworkProcess.cpp:
3200         (WebKit::NetworkProcess::initializeNetworkProcess):
3201         * NetworkProcess/NetworkProcessCreationParameters.cpp:
3202         (WebKit::NetworkProcessCreationParameters::encode const):
3203         (WebKit::NetworkProcessCreationParameters::decode):
3204         * NetworkProcess/NetworkProcessCreationParameters.h:
3205         * NetworkProcess/NetworkResourceLoader.cpp:
3206         (WebKit::NetworkResourceLoader::startNetworkLoad):
3207         * NetworkProcess/NetworkSessionCreationParameters.cpp:
3208         (WebKit::NetworkSessionCreationParameters::privateSessionParameters): Deleted.
3209         * NetworkProcess/NetworkSessionCreationParameters.h:
3210         * Shared/WebsiteDataStoreParameters.cpp:
3211         (WebKit::WebsiteDataStoreParameters::privateSessionParameters): Deleted.
3212         * Shared/WebsiteDataStoreParameters.h:
3213         (WebKit::WebsiteDataStoreParameters::legacyPrivateSessionParameters): Deleted.
3214         * UIProcess/WebProcessPool.cpp:
3215         (WebKit::WebProcessPool::ensureNetworkProcess):
3216
3217 2019-09-25  Alex Christensen  <achristensen@webkit.org>
3218
3219         Replace _WKProcessPoolConfiguration.CTDataConnectionServiceType with _WKWebsiteDataStoreConfiguration.dataConnectionServiceType
3220         https://bugs.webkit.org/show_bug.cgi?id=202174
3221
3222         Reviewed by Tim Horton.
3223
3224         _WKProcessPoolConfiguration.CTDataConnectionServiceType is used in one place and needs a replacement so we can
3225         start a NetworkProcess without a WKProcessPool.  Since this SPI only does something in the low-level networking code,
3226         I verified that the new SPI sets the String the way the old one does, and the old one keeps working in the interim.
3227
3228         * NetworkProcess/NetworkSessionCreationParameters.cpp:
3229         (WebKit::NetworkSessionCreationParameters::encode const):
3230         (WebKit::NetworkSessionCreationParameters::decode):
3231         * NetworkProcess/NetworkSessionCreationParameters.h:
3232         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
3233         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
3234         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
3235         (-[WKWebsiteDataStore _initWithConfiguration:]):
3236         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
3237         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
3238         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
3239         (-[_WKWebsiteDataStoreConfiguration dataConnectionServiceType]):
3240         (-[_WKWebsiteDataStoreConfiguration setDataConnectionServiceType:]):
3241         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
3242         (WebKit::WebsiteDataStore::parameters):
3243         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
3244         (WebKit::WebsiteDataStoreConfiguration::copy):
3245         * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
3246         (WebKit::WebsiteDataStoreConfiguration::dataConnectionServiceType const):
3247         (WebKit::WebsiteDataStoreConfiguration::setDataConnectionServiceType):
3248
3249 2019-09-25  Commit Queue  <commit-queue@webkit.org>
3250
3251         Unreviewed, rolling out r250336.
3252         https://bugs.webkit.org/show_bug.cgi?id=202210
3253
3254         it is creating failures on iOS bots (Requested by youenn on
3255         #webkit).
3256
3257         Reverted changeset:
3258
3259         "Make IsNSURLSessionWebSocketEnabled an experimental flag"
3260         https://bugs.webkit.org/show_bug.cgi?id=202135
3261         https://trac.webkit.org/changeset/250336
3262
3263 2019-09-25  Youenn Fablet  <youenn@apple.com>
3264
3265         Creation of a service worker connection for a service worker job should be based on the job scope
3266         https://bugs.webkit.org/show_bug.cgi?id=202185
3267
3268         Reviewed by Alex Christensen.
3269
3270         * NetworkProcess/NetworkProcess.cpp:
3271         (WebKit::NetworkProcess::swServerForSession):
3272         Assert that registrable domain is not empty.
3273         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
3274         (WebKit::WebSWServerConnection::scheduleJobInServer):
3275         Use the scope URL instead of the script URL which may be empty in case of an unregister job.
3276
3277 2019-09-25  Wenson Hsieh  <wenson_hsieh@apple.com>
3278
3279         [iPadOS] [DataActivation] Focus moves away after focusing input fields on www.att.com
3280         https://bugs.webkit.org/show_bug.cgi?id=202167
3281         <rdar://problem/55185021>
3282
3283         Reviewed by Tim Horton.
3284
3285         When using the data activation page on www.att.com, one of the sections on the page contains several select
3286         elements; in the case where the user agent:
3287
3288         1. contains the string "iPad", and
3289         2. does not contain the string "Safari"
3290
3291         ...www.att.com's data activation page will opt into a mode where it adds blur event listeners to the select
3292         elements; in this blur event listener, www.att.com proceeds to programmatically focus a non-editable div element
3293         after a 1 second timeout. The reasons for this behavior remain unclear to me, though it's worth noting that the
3294         blur event handler name is "screenReaderFocus", which suggests that this is in place to ensure compatibility
3295         with screen readers.
3296
3297         In iOS 12, dismissing the popover would blur the focused select menu with an animation. Since the animation
3298         would take a slightly less than 1 second, www.att.com's logic would have the effect of moving focus to the div
3299         element shortly after dismissing the select menu. However, after r243808, we no longer attempt to blur the
3300         focused select element when dismissing the popover. This means that the select element is only blurred the next
3301         time the user activates another focused element, such as one of the input fields on the page, or a different
3302         select element. Consequently, the logic to move focus into a div element now occurs only after a different
3303         element has already been focused; this results in focus moving away from newly focused elements after 1 second
3304         in the case where a select element has previously focused.
3305
3306         To mitigate this, restore iOS 12 behavior behind a site- and app-specific quirk. See comments below for more
3307         details.
3308
3309         * Shared/FocusedElementInformation.cpp:
3310         (WebKit::FocusedElementInformation::encode const):
3311         (WebKit::FocusedElementInformation::decode):
3312         * Shared/FocusedElementInformation.h:
3313
3314         Add a new behavioral quirk flag to FocusedElementInformation to determine whether we should use "legacy" select
3315         popover dismissal behavior (i.e. blurring the focused select element when dismissing the select popover, as well
3316         as dismissing the popover with animation).
3317
3318         * Shared/WebPreferences.yaml:
3319
3320         Enable site-specific quirks by default in WKWebView. With regards to this bug, this change allows for
3321         site-specific hacks (namely, legacy select popover dismissal) in DataActivation. However, this also fixes
3322         various known bugs that are otherwise addressed in Safari only, via site-specific quirks.
3323
3324         * UIProcess/API/Cocoa/WKWebView.mm:
3325         (-[WKWebView _initializeWithConfiguration:]):
3326
3327         For apps linked on or before iOS 13 and macOS 10.15, revert the default of value of NeedsSiteSpecificQuirks to
3328         false. This is done here instead of in a default value function in WebPreferencesDefaultValues to prevent the
3329         default values of NeedsSiteSpecificQuirks in the web process and UI process from going out of sync, since the
3330         web process is not necessarily linked against the same SDK as the application.
3331
3332         * UIProcess/Cocoa/VersionChecks.h:
3333
3334         Add a new DYLD version check for the first version of iOS and macOS where site-specific quirks are enabled by
3335         default.
3336
3337         * UIProcess/ios/WKContentViewInteraction.h:
3338         * UIProcess/ios/WKContentViewInteraction.mm:
3339         (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
3340         (-[WKContentView _elementDidBlur]):
3341         (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]):
3342
3343         We only use "legacy" select popover dismissal behavior in the case where the site-specific quirk flag is on, a
3344         select popover is used (i.e. the device is an iPad and a select element is focused), and the application bundle
3345         is "com.apple.DataActivation".
3346
3347         * UIProcess/ios/forms/WKFormSelectPopover.mm:
3348         (-[WKSelectTableViewController shouldDismissWithAnimation]):
3349
3350         Keyed off of _shouldUseLegacySelectPopoverDismissalBehavior.
3351
3352         (-[WKSelectPopover controlEndEditing]):
3353         * WebProcess/WebPage/ios/WebPageIOS.mm:
3354         (WebKit::WebPage::getFocusedElementInformation):
3355
3356 2019-09-25  Jonathan Bedard  <jbedard@apple.com>
3357
3358         Unreviewed, rolling out r250324.
3359
3360         Broke many mac wk2 layout tests
3361
3362         Reverted changeset:
3363
3364         "Enable LayoutTests using ResourceLoadStatistics SQLite
3365         backend (195420)"
3366         https://bugs.webkit.org/show_bug.cgi?id=195420
3367         https://trac.webkit.org/changeset/250324
3368
3369 2019-09-25  Youenn Fablet  <youenn@apple.com>
3370
3371         Make IsNSURLSessionWebSocketEnabled an experimental flag
3372         https://bugs.webkit.org/show_bug.cgi?id=202135
3373
3374         Reviewed by Geoffrey Garen.
3375
3376         * Shared/WebPreferences.yaml:
3377
3378 2019-09-24  Chris Dumez  <cdumez@apple.com>
3379
3380         [iOS] Regression(r249703) frequent 'kill() returned unexpected error' log messages
3381         https://bugs.webkit.org/show_bug.cgi?id=202173
3382
3383         Reviewed by Geoffrey Garen.
3384
3385         The kill(pid, 0) command actually fails with an EPERM error when there is a process
3386         running with the given pid, and this is causing us to log a lot of errors. The good
3387         news is that we merely want to know that there is no process with the given PID and
3388         we correctly get a ESRCH error in this case. I renamed the function from
3389         isRunningProcessPID() to wasTerminated() and only check for ESRCH error now. I no
3390         longer log any error otherwise since this is expected.
3391
3392         Also, for performance reason, I no longer call kill(pid, 0) from inside
3393         AuxiliaryProcessProxy::state() as it gets called a lot. I instead only call it from
3394         AuxiliaryProcessProxy::wasTerminated() and call it from
3395         WebProcessPool::tryTakePrewarmedProcess().
3396
3397         * UIProcess/AuxiliaryProcessProxy.cpp:
3398         (WebKit::AuxiliaryProcessProxy::state const):
3399         (WebKit::AuxiliaryProcessProxy::wasTerminated const):
3400         (WebKit::AuxiliaryProcessProxy::isRunningProcessPID): Deleted.
3401         * UIProcess/AuxiliaryProcessProxy.h:
3402         * UIProcess/WebProcessPool.cpp:
3403         (WebKit::WebProcessPool::tryTakePrewarmedProcess):
3404
3405 2019-09-24  Christopher Reid  <chris.reid@sony.com>
3406
3407         [WinCairo] Start RemoteInspectorServer
3408         https://bugs.webkit.org/show_bug.cgi?id=199938
3409         <rdar://problem/53323048>
3410
3411         Reviewed by Fujii Hironori.
3412
3413         Enable the remote inspector client on WinCairo.
3414         The inspector server will run if the WEBKIT_INSPECTOR_SERVER environment variable is set.
3415         WEBKIT_INSPECTOR_SERVER needs to be set in the form of <ip>:port e.g. WEBKIT_INSPECTOR_SERVER=127.0.0.1:1234.
3416
3417         Updated the protocol handler to update the target list with DOM manipulation.
3418
3419         * UIProcess/socket/RemoteInspectorClient.cpp:
3420         * UIProcess/socket/RemoteInspectorClient.h:
3421         * UIProcess/socket/RemoteInspectorProtocolHandler.cpp:
3422         * UIProcess/socket/RemoteInspectorProtocolHandler.h:
3423         * UIProcess/win/WebView.cpp:
3424
3425 2019-09-24  Kate Cheney  <katherine_cheney@apple.com>
3426
3427         Enable LayoutTests using ResourceLoadStatistics SQLite backend (195420)
3428         https://bugs.webkit.org/show_bug.cgi?id=195420
3429         <rdar://problem/54213551>
3430
3431         Reviewed by Brent Fulgham.
3432
3433         Changed all RELEASE_LOG_ERROR() calls involving domain strings to
3434         RELEASE_LOG_ERROR_IF_ALLOWED() to prevent leaking information about
3435         the domain strings only if sessionID.isAlwaysOnLoggingAllowed().
3436
3437         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
3438         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
3439         Added autovacuuming to the constructor to avoid manually calling
3440         runVacuumCommand(). Changed constructor to take in sessionID so it
3441         can use RELEASE_LOG_ERROR_IF_ALLOWED which requires the sessionID.
3442
3443         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements):
3444         Added 2 statements that were not being prepared.
3445
3446         (WebKit::ResourceLoadStatisticsDatabaseStore::relationshipExists const):
3447         Corrected incorrect capitalization. Added check for nullopt in case
3448         domainID is for a domain not in the database yet.
3449
3450         (WebKit::ResourceLoadStatisticsDatabaseStore::domainID const):
3451         Changed return value to Optional<unsigned>. Some tests were directly
3452         checking for subframes under top frame domains on domains that had
3453         not been inserted yet. Now, domainID() won't crash but will return
3454         a nullopt value which can be checked to know that the tests failed.
3455
3456         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
3457         Added a check to assure domainID exists and updated the domainID
3458         interactions to work as Optionals.
3459
3460         (WebKit::ResourceLoadStatisticsDatabaseStore::populateFromMemoryStore):
3461         Moved the prepareStatements() call after the vacuum command in the case
3462         where the database is empty. Otherwise called it before returning.
3463
3464         (WebKit::ResourceLoadStatisticsDatabaseStore::recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain):
3465         Added a space to the SQL commands to correct the syntax.
3466
3467         (WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources):
3468         Corrected a bug in the SQL command for querying
3469         subframeUnderTopFrameDomain. The old query was asking for subresource.
3470
3471         (WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources):
3472         Spelling fix.
3473
3474         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
3475         Changed string concatenation to binding.
3476
3477         (WebKit::ResourceLoadStatisticsDatabaseStore::grandfatherDataForDomains):
3478         The grandfathering.html test was failing because domains were being
3479         "set" to grandfathered in the database before being inserted. This fix
3480         ensures all domains before setting the grandfathering flag.
3481
3482         (WebKit::ResourceLoadStatisticsDatabaseStore::logFrameNavigation):
3483         Multiple tests were failing because the query to insert the relationship
3484         for the source domain relies on the target domain being in the
3485         ObservedDomains table. This patch ensures all domains are added before
3486         performing the query.
3487
3488         (WebKit::ResourceLoadStatisticsDatabaseStore::setUserInteraction):
3489         Added a != SQLITE_OK check to make sure an error is logged if the
3490         statement fails to bind.
3491
3492         (WebKit::ResourceLoadStatisticsDatabaseStore::clearUserInteraction):
3493         Changed string concatenation to binding.
3494
3495         (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction):   
3496         The SQL statement was being bound to a value and not being reset. This
3497         patch resets the statement after binding. Additionally, the step()
3498         function was being compared to SQLITE_DONE instead of SQLITE_ROW,
3499         causing an error if the query returned results. The
3500         ASSERT_NOT_REACHED() was causing null searches to crash instead of
3501         returning false (i.e. if a domain is not in the database it should
3502         return that it has no user interaction instead of crashing).
3503
3504         (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource): 
3505         Updated domainID call to act as an Optional. 
3506         
3507         (WebKit::ResourceLoadStatisticsDatabaseStore::predicateValueForDomain const):
3508         The SQL statement was being bound to a value and not being reset. This
3509         patch resets the statement after binding. SQLITE_DONE changed to
3510         SQLITE_ROW to return non-empty query results. ASSERT_NOT_REACHED()
3511         removed for the same reasons as above. 
3512
3513         (WebKit::ResourceLoadStatisticsDatabaseStore::ensureResourceStatisticsForRegistrableDomain):
3514         Fixed the release log statement which was logging the wrong function 
3515         name.
3516
3517         (WebKit::ResourceLoadStatisticsDatabaseStore::clearDatabaseContents): 
3518         Clears the database and rebuilds the tables on a clear command to
3519         match the functionality in the Memory Store.
3520
3521         (WebKit::ResourceLoadStatisticsDatabaseStore::clear):                   
3522         Call the clearDatabaseContents function to match the functionality 
3523         in the Memory Store. 
3524
3525         (WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt const):
3526         Updated domainID call to act as an Optional. 
3527
3528         (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUnexpiredRecentUserInteraction):
3529         Tests were failing because shouldRemoveAllWebsiteDataFor() was not 
3530         checking for expired user interaction. Matched functionality in the
3531         Memory Store.
3532
3533         (WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllWebsiteDataFor):
3534         Tests were failing because shouldRemoveAllWebsiteDataFor() was not 
3535         checking for expired user interaction. Matched functionality in the
3536         Memory Store. 
3537
3538         (WebKit::ResourceLoadStatisticsDatabaseStore::registrableDomainsToRemoveWebsiteDataFor):
3539         Spelling fix. 
3540
3541         (WebKit::ResourceLoadStatisticsDatabaseStore::pruneStatisticsIfNeeded): 
3542         Last seen should be sorted in ascending order because you want to 
3543         prune the older statistics first, which will have a lower lastSeen
3544         field (secondsSinceEpoch() will be lower for older values).
3545
3546         (WebKit::ResourceLoadStatisticsDatabaseStore::shouldRemoveAllWebsiteDataFor const): Deleted.
3547         Deleted const specifier because the function needs to clear the
3548         database. 
3549
3550         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:      
3551         Declared new functions. Updated spelling error (registerable --> 
3552         registrable). Updated constructor to take sessionID. 
3553
3554         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 
3555         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
3556         ITP database flag now is stored in the NetworkProcess.
3557         * NetworkProcess/NetworkProcess.cpp: 
3558
3559         (WebKit::NetworkProcess::initializeNetworkProcess): 
3560         Set the ITP database flag which is now stored in the Network Process. 
3561
3562         (WebKit::NetworkProcess::addWebsiteDataStore):
3563         SandboxExtension::consumePermanently was not getting called on the 
3564         WebKitTestRunner resourceLoadStatistics path. This was preventing
3565         the database file from opening. 
3566
3567         (WebKit::NetworkProcess::setUseITPDatabase): 
3568         * NetworkProcess/NetworkProcess.h:
3569         (WebKit::NetworkProcess::isITPDatabaseEnabled const):
3570         * NetworkProcess/NetworkProcess.messages.in:
3571         Passed the setUseITPDatabase flag to the initialization function 
3572         of the statistics store to enable the database backend.
3573
3574         * NetworkProcess/NetworkSession.cpp:
3575         (WebKit::NetworkSession::recreateResourceLoadStatisticStore):
3576         Destroy old WebResourceLoadStatisticsStore and create a new one using
3577         the ITP database.
3578
3579         * NetworkProcess/NetworkSession.h:
3580         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
3581         (WKWebsiteDataStoreSetUseITPDatabase):
3582         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
3583         * UIProcess/Network/NetworkProcessProxy.cpp:
3584         (WebKit::NetworkProcessProxy::setUseITPDatabase):
3585         * UIProcess/Network/NetworkProcessProxy.h:
3586         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3587         (WebKit::WebsiteDataStore::setUseITPDatabase):
3588         * UIProcess/WebsiteData/WebsiteDataStore.h:
3589         Passed the setUseITPDatabase flag to the initialization function
3590         of the statistics store to enable the database backend. 
3591
3592 2019-09-24  Alex Christensen  <achristensen@webkit.org>
3593
3594         Make iOS WebProcessPool directory getters static
3595         https://bugs.webkit.org/show_bug.cgi?id=202157
3596
3597         Reviewed by Tim Horton.
3598
3599         No change in behavior.  This just cuts another dependency the NetworkProcessProxy has on its owning WebProcessPool.
3600
3601         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
3602         (WebKit::WebProcessPool::cookieStorageDirectory):
3603         (WebKit::WebProcessPool::platformResolvePathsForSandboxExtensions):
3604         (WebKit::WebProcessPool::parentBundleDirectory):
3605         (WebKit::WebProcessPool::networkingCachesDirectory):
3606         (WebKit::WebProcessPool::webContentCachesDirectory):
3607         (WebKit::WebProcessPool::containerTemporaryDirectory):
3608         (WebKit::WebProcessPool::cookieStorageDirectory const): Deleted.
3609         (WebKit::WebProcessPool::parentBundleDirectory const): Deleted.
3610         (WebKit::WebProcessPool::networkingCachesDirectory const): Deleted.
3611         (WebKit::WebProcessPool::webContentCachesDirectory const): Deleted.
3612         (WebKit::WebProcessPool::containerTemporaryDirectory const): Deleted.
3613         * UIProcess/WebProcessPool.cpp:
3614         (WebKit::WebProcessPool::ensureNetworkProcess):
3615         * UIProcess/WebProcessPool.h:
3616
3617 2019-09-24  Patrick Griffis  <pgriffis@igalia.com>
3618
3619         [GTK][WPE] Minor code cleanup in BubblewrapLauncher
3620         https://bugs.webkit.org/show_bug.cgi?id=201906
3621
3622         This just cleans up string handling and some
3623         whitespace fixes.
3624
3625         Reviewed by Carlos Garcia Campos.
3626
3627         * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
3628         (WebKit::XDGDBusProxyLauncher::setAddress):
3629         (WebKit::XDGDBusProxyLauncher::launch):
3630         (WebKit::XDGDBusProxyLauncher::makeProxyPath):
3631         (WebKit::XDGDBusProxyLauncher::dbusAddressToPath):
3632
3633 2019-09-24  Zalan Bujtas  <zalan@apple.com>
3634
3635         [iPadOs] The second click event is missing on double tap when dblclick handler is not present
3636         https://bugs.webkit.org/show_bug.cgi?id=202006
3637         <rdar://problem/51706828>
3638
3639         Reviewed by Wenson Hsieh.
3640
3641         While double tapping,
3642         1. the first tap triggers a click event through the normal _singleTapIdentified/_singleTapRecognized codepath.
3643         2. and the second tap should trigger either
3644           a second single click event or
3645           a second single click followed by a dblclick event when dblclick handler is present.
3646         However the second click is dropped on the floor when the node under the cursor does not have a dblclick handler (see handleDoubleTapForDoubleClickAtPoint()) -so we end up sending one click event.
3647
3648         This patch fixes this case by sending the second tap through the normal single tap flow when the dblclick handler is not present.
3649
3650         * Shared/ios/InteractionInformationAtPosition.h:
3651         * Shared/ios/InteractionInformationAtPosition.mm:
3652         (WebKit::InteractionInformationAtPosition::encode const):
3653         (WebKit::InteractionInformationAtPosition::decode):
3654         * UIProcess/ios/WKContentViewInteraction.h:
3655         * UIProcess/ios/WKContentViewInteraction.mm:
3656         (-[WKContentView setupInteraction]):
3657         (-[WKContentView gestureRecognizerShouldBegin:]):
3658         (WebKit::WebPage::positionInformation):
3659         (WebKit::WebPage::requestPositionInformation):
3660
3661 2019-09-24  Alex Christensen  <achristensen@webkit.org>
3662
3663         Move HSTS storage directory to LegacyGlobalSettings
3664         https://bugs.webkit.org/show_bug.cgi?id=202059
3665
3666         Reviewed by Tim Horton.
3667
3668         I continue my lamentation begun in r245075.
3669         Remove the glib setting of it on the WebKitWebContext because they use it on the WebsiteDataStore.  We should do that too when we can.
3670
3671         * UIProcess/API/APIProcessPoolConfiguration.cpp:
3672         (API::ProcessPoolConfiguration::copy):
3673         * UIProcess/API/APIProcessPoolConfiguration.h:
3674         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
3675         (-[_WKProcessPoolConfiguration setHSTSStorageDirectory:]):
3676         (-[_WKProcessPoolConfiguration hstsStorageDirectory]):
3677         * UIProcess/LegacyGlobalSettings.h:
3678         (WebKit::LegacyGlobalSettings::setHSTSStorageDirectory):
3679         (WebKit::LegacyGlobalSettings::hstsStorageDirectory const):
3680         * UIProcess/WebProcessPool.cpp:
3681         (WebKit::WebProcessPool::ensureNetworkProcess):
3682
3683 2019-09-24  Keith Rollin  <krollin@apple.com>
3684
3685         Coalesce or remove PLATFORM(MAC) || PLATFORM(IOS_FAMILY)
3686         https://bugs.webkit.org/show_bug.cgi?id=202119
3687         <rdar://problem/55638792>
3688
3689         Reviewed by Alex Christensen.
3690
3691         After refactoring and other code evolution, some platform checks have
3692         ended up looking like PLATFORM(MAC) || PLATFORM(IOS_FAMILY) (or
3693         vice-versa). These can be converted into the equivalent
3694         PLATFORM(COCOA). Where the instance occurs in a Cocoa-only file, the
3695         check can be removed altogether (along with any "#else" branches).
3696
3697         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
3698         (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):
3699         * WebProcess/WebCoreSupport/WebChromeClient.h:
3700
3701 2019-09-24  Wenson Hsieh  <wenson_hsieh@apple.com>
3702
3703         FocusPreservationTests.ChangingFocusedNodeResetsFocusPreservationState triggers a debug assertion
3704         https://bugs.webkit.org/show_bug.cgi?id=202145
3705         <rdar://problem/51273128>
3706
3707         Reviewed by Tim Horton.
3708
3709         Fixes an assertion in -tableView:cellForRowAtIndexPath: to only require the cell to have a non-zero
3710         width in the case where the table view itself has a non-empty width. When run under TestWebKitAPI,
3711         this assertion currently fires because the view controller used to show the popover isn't actually
3712         presented, so the view controller's view (i.e. the UITableView) ends up being empty. This causes all
3713         of its table view cells to subsequently become empty upon reuse.
3714
3715         * UIProcess/ios/forms/WKFormSelectPopover.mm:
3716         (-[WKSelectTableViewController tableView:cellForRowAtIndexPath:]):
3717
3718 2019-09-24  Alex Christensen  <achristensen@webkit.org>
3719
3720         Require a WebsiteDataStore when creating or resuming downloads
3721         https://bugs.webkit.org/show_bug.cgi?id=202081
3722
3723         Reviewed by Youenn Fablet.
3724
3725         No change in behavior, but I'll have to move Safari to the new SPI.
3726         This makes it so there are no cases where we guess we need to use the default session,
3727         and it allows downloads to function correctly once there is a NetworkProcess singleton.
3728         Removing the unused WebProcessPool& in the callbacks will allow us to eventually have
3729         downloads only associated with a WebsiteDataStore and not a WebProcessPool.
3730
3731         * UIProcess/API/APIDownloadClient.h:
3732         (API::DownloadClient::didStart):
3733         (API::DownloadClient::didReceiveAuthenticationChallenge):
3734         (API::DownloadClient::didReceiveResponse):
3735         (API::DownloadClient::didReceiveData):
3736         (API::DownloadClient::decideDestinationWithSuggestedFilename):
3737         (API::DownloadClient::didCreateDestination):
3738         (API::DownloadClient::didFinish):
3739         (API::DownloadClient::didFail):
3740         (API::DownloadClient::didCancel):
3741         (API::DownloadClient::processDidCrash):
3742         (API::DownloadClient::willSendRequest):
3743         * UIProcess/API/C/WKContext.cpp:
3744         (WKContextSetDownloadClient):
3745         (WKContextDownloadURLRequest):
3746         (WKContextResumeDownload):
3747         * UIProcess/API/C/WKContext.h:
3748         * UIProcess/API/Cocoa/WKProcessPool.mm:
3749         (-[WKProcessPool _setDownloadDelegate:]):
3750         (-[WKProcessPool _downloadURLRequest:originatingWebView:]):
3751         (-[WKProcessPool _resumeDownloadFromData:path:originatingWebView:]):
3752         (-[WKProcessPool _downloadURLRequest:websiteDataStore:originatingWebView:]):
3753         (-[WKProcessPool _resumeDownloadFromData:websiteDataStore:path:originatingWebView:]):
3754         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
3755         * UIProcess/API/glib/WebKitDownloadClient.cpp:
3756         * UIProcess/API/glib/WebKitWebContext.cpp:
3757         (webkitWebContextDispose):
3758         (webkitWebContextStartDownload):
3759         * UIProcess/Cocoa/DownloadClient.h:
3760         * UIProcess/Cocoa/DownloadClient.mm:
3761         (WebKit::DownloadClient::didStart):
3762         (WebKit::DownloadClient::didReceiveResponse):
3763         (WebKit::DownloadClient::didReceiveData):
3764         (WebKit::DownloadClient::didReceiveAuthenticationChallenge):
3765         (WebKit::DownloadClient::didCreateDestination):
3766         (WebKit::DownloadClient::processDidCrash):
3767         (WebKit::DownloadClient::decideDestinationWithSuggestedFilename):
3768         (WebKit::DownloadClient::didFinish):
3769         (WebKit::DownloadClient::didFail):
3770         (WebKit::DownloadClient::didCancel):
3771         (WebKit::DownloadClient::willSendRequest):
3772         * UIProcess/Downloads/DownloadProxy.cpp:
3773         (WebKit::DownloadProxy::create):
3774         (WebKit::DownloadProxy::DownloadProxy):
3775         (WebKit::DownloadProxy::invalidate):
3776         (WebKit::DownloadProxy::processDidClose):
3777         (WebKit::DownloadProxy::didStart):
3778         (WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
3779         (WebKit::DownloadProxy::willSendRequest):
3780         (WebKit::DownloadProxy::didReceiveResponse):
3781         (WebKit::DownloadProxy::didReceiveData):
3782         (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
3783         (WebKit::DownloadProxy::didCreateDestination):
3784         (WebKit::DownloadProxy::didFinish):
3785         (WebKit::DownloadProxy::didFail):
3786         (WebKit::DownloadProxy::didCancel):
3787         * UIProcess/Downloads/DownloadProxy.h:
3788         * UIProcess/Downloads/DownloadProxyMap.cpp:
3789         (WebKit::DownloadProxyMap::createDownloadProxy):
3790         * UIProcess/Downloads/DownloadProxyMap.h:
3791         * UIProcess/Network/NetworkProcessProxy.cpp:
3792         (WebKit::NetworkProcessProxy::createDownloadProxy):
3793         * UIProcess/Network/NetworkProcessProxy.h:
3794         * UIProcess/WebPageProxy.cpp:
3795         (WebKit::WebPageProxy::receivedPolicyDecision):
3796         (WebKit::WebPageProxy::contextMenuItemSelected):
3797         * UIProcess/WebProcessPool.cpp:
3798         (WebKit::WebProcessPool::WebProcessPool):
3799         (WebKit::WebProcessPool::setDownloadClient):
3800         (WebKit::WebProcessPool::download):
3801         (WebKit::WebProcessPool::resumeDownload):
3802         (WebKit::WebProcessPool::createDownloadProxy):
3803         * UIProcess/WebProcessPool.h:
3804
3805 2019-09-24  Youenn Fablet  <youenn@apple.com>
3806
3807         Delay capture sandbox extension revocation to after the page close message is sent
3808         https://bugs.webkit.org/show_bug.cgi?id=202133
3809
3810         Reviewed by Eric Carlson.
3811
3812         This ensures that the sandbox extension is removed once no longer useful
3813         and makes our WebProcess assertions fine.
3814
3815         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
3816         (WebKit::UserMediaPermissionRequestManagerProxy::~UserMediaPermissionRequestManagerProxy):
3817
3818 2019-09-23  Chris Dumez  <cdumez@apple.com>
3819
3820         Drop unnecessary SessionID.h header includes
3821         https://bugs.webkit.org/show_bug.cgi?id=202129
3822
3823         Reviewed by Alex Christensen.
3824
3825         * NetworkProcess/AdClickAttributionManager.h:
3826         * NetworkProcess/IndexedDB/WebIDBConnectionToClient.h:
3827         * NetworkProcess/NetworkLoadParameters.h:
3828         * NetworkProcess/RemoteNetworkingContext.h:
3829         * NetworkProcess/cache/CacheStorageEngine.cpp:
3830         * NetworkProcess/cache/CacheStorageEngine.h:
3831         * NetworkProcess/cache/NetworkCache.h:
3832         * NetworkProcess/webrtc/NetworkRTCProvider.h:
3833         * Shared/ApplePay/WebPaymentCoordinatorProxy.h:
3834         * Shared/Authentication/AuthenticationManager.h:
3835         * Shared/WebCoreArgumentCoders.cpp:
3836         * Shared/WebProcessCreationParameters.h:
3837         * UIProcess/API/APIPageConfiguration.h:
3838         * WebProcess/Cache/WebCacheStorageProvider.h:
3839         * WebProcess/Databases/WebDatabaseProvider.cpp:
3840         * WebProcess/InjectedBundle/InjectedBundle.cpp:
3841         * WebProcess/InjectedBundle/InjectedBundle.h:
3842         * WebProcess/Network/WebSocketChannel.h:
3843         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
3844         * WebProcess/Storage/WebServiceWorkerProvider.cpp:
3845         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
3846         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
3847         * WebProcess/WebCoreSupport/curl/WebFrameNetworkingContext.h:
3848         * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
3849         * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:
3850         * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h:
3851         * WebProcess/WebPage/WebFrame.h:
3852
3853 2019-09-23  Chris Dumez  <cdumez@apple.com>
3854
3855         PlugInClient::didStartFromOrigin() does not need a sessionID
3856         https://bugs.webkit.org/show_bug.cgi?id=202127
3857
3858         Reviewed by Geoffrey Garen.
3859
3860         * WebProcess/WebCoreSupport/WebPlugInClient.cpp:
3861         (WebKit::WebPlugInClient::didStartFromOrigin):
3862         * WebProcess/WebCoreSupport/WebPlugInClient.h:
3863
3864 2019-09-23  Chris Dumez  <cdumez@apple.com>
3865
3866         FrameSpecificStorageAccessIdentifier does not need a sessionID
3867         https://bugs.webkit.org/show_bug.cgi?id=202093
3868
3869         Reviewed by Geoffrey Garen.
3870
3871         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
3872         * WebProcess/WebPage/WebPage.cpp:
3873         (WebKit::WebPage::requestStorageAccess):
3874
3875 2019-09-23  Tim Horton  <timothy_horton@apple.com>
3876
3877         macOS: <datalist> dropdown shadow is cropped, looks nothing like NSComboBox
3878         https://bugs.webkit.org/show_bug.cgi?id=199350
3879
3880         Reviewed by Wenson Hsieh.
3881
3882         Improve the appearance of the macOS <datalist> dropdown, adopting the
3883         roundly-cornered and backdrop-ful appearance of the current NSComboBox style.
3884
3885         Use the proper window shadow instead of our own inside the window, both
3886         so that we match the system and so that it doesn't get clipped.
3887
3888         Allow vertical rubber-banding, because NSComboBox does.
3889
3890         Don't highlight on hover, because NSComboBox doesn't. Do use NSTableView's
3891         selection mechanism instead of rolling our own for highlights driven by
3892         keyboard-based navigation.
3893
3894         Make use of NSTableCellView, since it has some smarts around pixel alignment
3895         that we don't need to duplicate (and things are blurry on 1x displays without).
3896
3897         Also rename some classes to make it a bit more clear what's going on:
3898         WKDataListSuggestionCell -> WKDataListSuggestionView (it's a NSView, not an NSCell)
3899         WKDataListSuggestionsView -> WKDataListSuggestionsController (it's not a view at all)
3900
3901         * Platform/spi/mac/AppKitSPI.h:
3902         * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
3903         (WebKit::WebDataListSuggestionsDropdownMac::show):
3904         (-[WKDataListSuggestionWindow initWithContentRect:styleMask:backing:defer:]):
3905         (-[WKDataListSuggestionWindow canBecomeKeyWindow]):
3906         (-[WKDataListSuggestionWindow hasKeyAppearance]):
3907         (-[WKDataListSuggestionWindow shadowOptions]):
3908         (-[WKDataListSuggestionView initWithFrame:]):
3909         (-[WKDataListSuggestionView setText:]):
3910         (-[WKDataListSuggestionView setBackgroundStyle:]):
3911         (-[WKDataListSuggestionTableRowView drawSelectionInRect:]):
3912         (-[WKDataListSuggestionTableView initWithElementRect:]):
3913         (-[WKDataListSuggestionTableView layout]):
3914         (-[WKDataListSuggestionTableView reload]):
3915         (-[WKDataListSuggestionsController initWithInformation:inView:]):
3916         (-[WKDataListSuggestionsController currentSelectedString]):
3917         (-[WKDataListSuggestionsController updateWithInformation:]):
3918         (-[WKDataListSuggestionsController moveSelectionByDirection:]):
3919         (-[WKDataListSuggestionsController invalidate]):
3920         (-[WKDataListSuggestionsController dropdownRectForElementRect:]):
3921         (-[WKDataListSuggestionsController showSuggestionsDropdown:]):
3922         (-[WKDataListSuggestionsController tableView:rowViewForRow:]):
3923         (-[WKDataListSuggestionsController tableView:viewForTableColumn:row:]):
3924         (-[WKDataListSuggestionCell initWithFrame:]): Deleted.
3925         (-[WKDataListSuggestionCell setText:]): Deleted.
3926         (-[WKDataListSuggestionCell setActive:]): Deleted.
3927         (-[WKDataListSuggestionCell drawRect:]): Deleted.
3928         (-[WKDataListSuggestionCell mouseEntered:]): Deleted.
3929         (-[WKDataListSuggestionCell mouseExited:]): Deleted.
3930         (-[WKDataListSuggestionCell acceptsFirstResponder]): Deleted.
3931         (-[WKDataListSuggestionTable initWithElementRect:]): Deleted.
3932         (-[WKDataListSuggestionTable setVisibleRect:]): Deleted.
3933         (-[WKDataListSuggestionTable currentActiveRow]): Deleted.
3934         (-[WKDataListSuggestionTable setActiveRow:]): Deleted.
3935         (-[WKDataListSuggestionTable reload]): Deleted.
3936         (-[WKDataListSuggestionTable acceptsFirstResponder]): Deleted.
3937         (-[WKDataListSuggestionTable enclosingScrollView]): Deleted.
3938         (-[WKDataListSuggestionTable removeFromSuperviewWithoutNeedingDisplay]): Deleted.
3939         (-[WKDataListSuggestionsView initWithInformation:inView:]): Deleted.
3940         (-[WKDataListSuggestionsView currentSelectedString]): Deleted.
3941         (-[WKDataListSuggestionsView updateWithInformation:]): Deleted.
3942         (-[WKDataListSuggestionsView moveSelectionByDirection:]): Deleted.
3943         (-[WKDataListSuggestionsView invalidate]): Deleted.
3944         (-[WKDataListSuggestionsView dropdownRectForElementRect:]): Deleted.
3945         (-[WKDataListSuggestionsView showSuggestionsDropdown:]): Deleted.
3946         (-[WKDataListSuggestionsView selectedRow:]): Deleted.
3947         (-[WKDataListSuggestionsView numberOfRowsInTableView:]): Deleted.
3948         (-[WKDataListSuggestionsView tableView:heightOfRow:]): Deleted.
3949         (-[WKDataListSuggestionsView tableView:viewForTableColumn:row:]): Deleted.
3950
3951 2019-09-23  Wenson Hsieh  <wenson_hsieh@apple.com>
3952
3953         [iOS] Drop animation when dragging images from Photos to WebKit2 Mail compose is incorrect
3954         https://bugs.webkit.org/show_bug.cgi?id=201674
3955         <rdar://problem/51250952>
3956
3957         Reviewed by Tim Horton.
3958
3959         Our current logic for handling dropped content in editable elements on iOS works like this in the ideal case:
3960
3961         (1)     UIKit asks us for a targeted preview for each UIDragItem. We don't know (and can't determine this
3962                 synchronously without blocking on the web process) so we simply retarget the preview to animate to the
3963                 last known caret location.
3964
3965         (2)     Soonafter, UIKit hands us a drop preview update block, which may be used to retarget the drop preview
3966                 once, as long as the drop animation is less than 90% complete. We stash these update blocks for now.
3967
3968         (3)     -dropInteraction:performDrop: is then called, and we start loading item provider data right away.
3969
3970         (4)     When the data has finished loading, we perform the drop in the web process. After any inserted images
3971                 have finished loading, we take snapshots (of the dropped content as well as surrounding web content
3972                 minus the dropped content), and deliver these images to the UI process via TextIndicatorData.
3973
3974         (5)     Upon receiving the TextIndicatorData sent in (4), we use the image data to create updated targeted drag
3975                 previews, and use these to invoke the preview update blocks we stored earlier in (2). We also obscure
3976                 the entire web view with a snapshot of the view minus any dropped content, such that the updated drop
3977                 previews may animate into place without also showing the final content.
3978
3979         (6)     When the drop animation ends, we remove the unselected content snapshot view added in (5) simultaneously
3980                 as the targeted previews disappear, revealing the actual dropped content on the page. The drop is now
3981                 complete.
3982
3983         However, note that the drag update block we invoke in (5) doesn't work if the drop animation is already more
3984         than 90% complete. Since the lifecycle of the drop animation is distinct from that of item provider loading, if
3985         the delay between (3) and (4) exceeds 90% of the total drop animation time, we'll fail to update the targeted
3986         previews, such that the user only sees the initial drag preview fly on top of the caret and disappear. While we
3987         typically win this race for data dragged from other WebKit apps, we almost always lose when dragging from Photos
3988         and end up with a janky drop animation. This is especially true for any images that aren't locally available,
3989         and need to be fetched from iCloud. An additional problem is that in step (5), we use the same final snapshot to
3990         update the drop preview of every item, since we don't have a snapshot for the fragment corresponding to each
3991         individual dropped item.
3992
3993         To address these issues for Mail in the case where the user drops images with known sizes (i.e. -[NSItemProvider
3994         preferredPresentationSize] is specified), we introduce an alternate codepath for handling dropped images that
3995         performs the drop immediately upon receiving -dropInteraction:performDrop: in the UI process. Since the data has
3996         yet to arrive, we instead handle the drop by inserting placeholder image elements at the drag caret position,
3997         which initially have no source but are sized to fit their expected final image sizes. After doing so, we
3998         snapshot the page (minus the dropped content range, as usual) and deliver this snapshot to the UI process, along
3999         with the rects (in root view coordinates) of each placeholder image that was inserted. In the UI process, we
4000         then take this snapshot and obscure the content view with it, and also use each of the placeholder rects to
4001         provide an updated target for each drag preview, such that the drop previews now animate to their final
4002         locations on the page.
4003
4004         When the data eventually arrives, we handle the drop by detecting the placeholder elements we inserted earlier,
4005         and using the dropped data to update the source attribute and attachment backing for each of these placeholder
4006         elements instead of attempting to insert new content.
4007
4008         Note that this codepath is currently only enabled for SPI clients that set -[WKWebView _editable] to YES, since
4009         it involves us performing the editing&nb