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