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