[Mac] Ensure Apple Pay is unavailable when PassKit.framework is missing
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2019-03-11  Andy Estes  <aestes@apple.com>
2
3         [Mac] Ensure Apple Pay is unavailable when PassKit.framework is missing
4         https://bugs.webkit.org/show_bug.cgi?id=195583
5         <rdar://problem/48420224>
6
7         Reviewed by Daniel Bates.
8
9         PassKit.framework is optionally soft-linked on Mac because it is missing from the Recovery
10         Partition. We need to check if the framework is available before calling into it.
11
12         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
13         (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
14         (WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard):
15         (WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup):
16         (WebKit::WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks):
17         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
18         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
19
20 2019-03-12  Antti Koivisto  <antti@apple.com>
21
22         Compositing layer that renders two positioned elements should not hit test
23         https://bugs.webkit.org/show_bug.cgi?id=195371
24         <rdar://problem/48649586>
25
26         Reviewed by Simon Fraser.
27
28         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
29         (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
30         * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
31         * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
32         (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
33         (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode const):
34         (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
35
36         Pass event region to UI process.
37
38         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
39         (WebKit::RemoteLayerTreeNode::layerID const):
40         (WebKit::RemoteLayerTreeNode::eventRegion const):
41         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm:
42         (WebKit::RemoteLayerTreeNode::RemoteLayerTreeNode):
43         (WebKit::RemoteLayerTreeNode::~RemoteLayerTreeNode):
44         (WebKit::RemoteLayerTreeNode::setEventRegion):
45
46         Maintain event region in RemoteLayerTreeNodes.
47
48         (WebKit::RemoteLayerTreeNode::initializeLayer):
49         (WebKit::RemoteLayerTreeNode::layerID):
50         (WebKit::RemoteLayerTreeNode::forCALayer):
51
52         Move layerID to RemoteLayerTreeNode and store RemoteLayerTreeNode pointer to CALayers instead.
53         This makes it easy to find the matching RemoteLayerTreeNode from a layer, globally.
54
55         (WebKit::RemoteLayerTreeNode::setLayerID): Deleted.
56         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
57         (WebKit::collectDescendantViewsAtPoint):
58
59         If we have event region, use it for hit testing.
60
61         (-[UIView _web_findDescendantViewAtPoint:withEvent:]):
62         (collectDescendantViewsAtPoint): Deleted.
63         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
64         (WebKit::PlatformCALayerRemote::eventRegion const):
65         (WebKit::PlatformCALayerRemote::setEventRegion):
66         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
67
68 2019-03-12  Carlos Garcia Campos  <cgarcia@igalia.com>
69
70         [WPE][GTK] Load events may occur in unexpected order when JS redirects page before subresource load finishes
71         https://bugs.webkit.org/show_bug.cgi?id=194131
72
73         Reviewed by Michael Catanzaro.
74
75         Ensure we emit the load-failed and load-changed with finished event when there's still an ongoing load when a
76         new provisional load strarts. Previous load fails with cancelled error.
77
78         * UIProcess/API/glib/WebKitWebView.cpp:
79         (webkitWebViewWillStartLoad): Call webkitWebViewLoadFailed() if current page load state is not finished.
80         * UIProcess/API/glib/WebKitWebViewPrivate.h:
81         * UIProcess/API/gtk/PageClientImpl.cpp:
82         (WebKit::PageClientImpl::didStartProvisionalLoadForMainFrame): Call webkitWebViewWillStartLoad().
83         * UIProcess/API/wpe/APIViewClient.h:
84         (API::ViewClient::willStartLoad): Add willStartLoad() to API::ViewClient
85         * UIProcess/API/wpe/PageClientImpl.cpp:
86         (WebKit::PageClientImpl::didStartProvisionalLoadForMainFrame): Call WPEView::willStartLoad().
87         * UIProcess/API/wpe/PageClientImpl.h:
88         * UIProcess/API/wpe/WPEView.cpp:
89         (WKWPE::View::willStartLoad): Call API::ViewClient::willStartLoad().
90         * UIProcess/API/wpe/WPEView.h:
91         * UIProcess/PageLoadState.h:
92         (WebKit::PageLoadState::isProvisional const):
93         (WebKit::PageLoadState::isCommitted const):
94         (WebKit::PageLoadState::isFinished const):
95
96 2019-03-11  Ryan Haddad  <ryanhaddad@apple.com>
97
98         Unreviewed, rolling out r242763.
99
100         Causes layout test crashes on iOS simulator
101
102         Reverted changeset:
103
104         "[Synthetic Click] Dispatch mouseout soon after mouseup"
105         https://bugs.webkit.org/show_bug.cgi?id=195575
106         https://trac.webkit.org/changeset/242763
107
108 2019-03-11  Ross Kirsling  <ross.kirsling@sony.com>
109
110         Add Optional to Forward.h.
111         https://bugs.webkit.org/show_bug.cgi?id=195586
112
113         Reviewed by Darin Adler.
114
115         * Shared/RTCNetwork.cpp:
116         * Shared/RTCNetwork.h:
117         * Shared/RTCPacketOptions.cpp:
118         * Shared/RTCPacketOptions.h:
119         * UIProcess/API/APIWebsitePolicies.h:
120         * UIProcess/WebStorage/LocalStorageDatabaseTracker.h:
121         Remove unnecessary includes from headers.
122
123 2019-03-11  Commit Queue  <commit-queue@webkit.org>
124
125         Unreviewed, rolling out r242745 and r242756.
126         https://bugs.webkit.org/show_bug.cgi?id=195606
127
128         Breaks internal builds (Requested by ryanhaddad on #webkit).
129
130         Reverted changesets:
131
132         "[iOS] Block access to backboardd service"
133         https://bugs.webkit.org/show_bug.cgi?id=195484
134         https://trac.webkit.org/changeset/242745
135
136         "Unreviewed build fix after r242745."
137         https://trac.webkit.org/changeset/242756
138
139 2019-03-11  Fujii Hironori  <Hironori.Fujii@sony.com>
140
141         [CoordinatedGraphics] ASSERTION FAILED: !m_state.isSuspended
142         https://bugs.webkit.org/show_bug.cgi?id=195550
143
144         Reviewed by Carlos Garcia Campos.
145
146         CompositingRunLoop::suspend() locks a mutex and stops the update
147         timer. But, the timer can be fired after the lock was acquired and
148         before the timer is stopped.
149
150         * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
151         (WebKit::CompositingRunLoop::updateTimerFired): Removed the
152         assertion. Return early if m_state.isSuspended.
153
154 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
155
156         [macOS] Remove the Kerberos rules from the WebContent sandbox
157         https://bugs.webkit.org/show_bug.cgi?id=195464
158         <rdar://problem/35369230>
159
160         Reviewed by Brent Fulgham.
161
162         Kerberos auth is done in the UIProcess or NetworkProcess now.
163
164         * WebProcess/com.apple.WebProcess.sb.in:
165
166 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
167
168         [iOS] Add entitlement to enable use of graphics endpoint with limited capabilities
169         https://bugs.webkit.org/show_bug.cgi?id=195582
170         <rdar://problem/36082379>
171
172         Reviewed by Brent Fulgham.
173
174         This is a QuartzCore endpoint with a minimal set of capabilities.
175
176         * Configurations/WebContent-iOS.entitlements:
177
178 2019-03-11  John Wilander  <wilander@apple.com>
179
180         Move NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm functionality into UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
181         https://bugs.webkit.org/show_bug.cgi?id=195117
182         <rdar://problem/48448715>
183
184         Reviewed by Brent Fulgham.
185
186         Reading of user defaults on Cocoa platforms should be done in the UI process and
187         forwarded to Resource Load Statistics in the network process through the
188         WebKit::NetworkSessionCreationParameters struct.
189
190         This patch does away with some old user defaults we don't use anymore. It also
191         changes the developer-facing default name to ITPManualPrevalentResource.
192
193         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
194         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
195             Removed the call to the old registerUserDefaultsIfNeeded().
196         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
197         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
198             Removed the call to the old registerUserDefaultsIfNeeded().
199         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
200             Removed the declaration of the old registerUserDefaultsIfNeeded().
201         * NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm: Removed.
202         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
203             Added an enum class EnableResourceLoadStatisticsDebugMode.
204         * NetworkProcess/NetworkSession.cpp:
205         (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
206         * NetworkProcess/NetworkSession.h:
207         * NetworkProcess/NetworkSessionCreationParameters.cpp:
208         (WebKit::NetworkSessionCreationParameters::encode const):
209         (WebKit::NetworkSessionCreationParameters::decode):
210         * NetworkProcess/NetworkSessionCreationParameters.h:
211            The struct now has two new fields:
212            - enableResourceLoadStatisticsDebugMode
213            - resourceLoadStatisticsManualPrevalentResource
214         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
215         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
216             Forwarding of the parameters.
217         * SourcesCocoa.txt:
218         * UIProcess/WebProcessPool.cpp:
219         (WebKit::WebProcessPool::ensureNetworkProcess):
220             Forwarding of the parameters.
221         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
222         (WebKit::WebsiteDataStore::parameters):
223             This is where user defaults for Resource Load Statistics are now read.
224         * WebKit.xcodeproj/project.pbxproj:
225
226 2019-03-11  Zalan Bujtas  <zalan@apple.com>
227
228         [Synthetic Click] Dispatch mouseout soon after mouseup
229         https://bugs.webkit.org/show_bug.cgi?id=195575
230         <rdar://problem/47093049>
231
232         Reviewed by Simon Fraser.
233
234         * WebProcess/WebPage/ios/WebPageIOS.mm:
235         (WebKit::WebPage::completeSyntheticClick):
236
237 2019-03-11  Tim Horton  <timothy_horton@apple.com>
238
239         API test WebKit.RequestTextInputContext fails on iOS
240         https://bugs.webkit.org/show_bug.cgi?id=195585
241
242         Reviewed by Wenson Hsieh and Simon Fraser.
243
244         * UIProcess/API/Cocoa/WKWebView.mm:
245         (-[WKWebView _convertRectFromRootViewCoordinates:]):
246         (-[WKWebView _convertRectToRootViewCoordinates:]):
247         (-[WKWebView _requestTextInputContextsInRect:completionHandler:]):
248         (-[WKWebView _focusTextInputContext:completionHandler:]):
249         * WebProcess/WebPage/WebPage.cpp:
250         (WebKit::elementRectInRootViewCoordinates):
251         (WebKit::WebPage::textInputContextsInRect):
252         (WebKit::elementRectInWindowCoordinates): Deleted.
253         Text input context SPI should be in terms of WKWebView coordinates,
254         for consistency's sake. This is a bit irritating; WebPage(Proxy) continue
255         to operate in "root view" coordinates, which means different things
256         depending on if delegatesScrolling is true or not. So, WKWebView does
257         the conversion, re-creating objects as needed.
258
259 2019-03-09  Jiewen Tan  <jiewen_tan@apple.com>
260
261         Optimizing loads when creating new pages
262         https://bugs.webkit.org/show_bug.cgi?id=195516
263         <rdar://problem/48738086>
264
265         Reviewed by Darin Adler.
266
267         This patch adds hooks in WebPageProxy::createNewPage to optimize loads, and moves the creationParameters
268         of API::NavigationAction from UI clients to WebPageProxy::createNewPage. Also, we now pass the whole
269         API::NavigationAction to the load optimizer instead of the request within.
270
271         * UIProcess/API/APINavigationAction.h:
272         * UIProcess/API/APIUIClient.h:
273         (API::UIClient::createNewPage):
274         * UIProcess/API/C/WKPage.cpp:
275         (WKPageSetPageUIClient):
276         * UIProcess/API/glib/WebKitUIClient.cpp:
277         * UIProcess/Cocoa/NavigationState.mm:
278         (WebKit::tryOptimizingLoad):
279         (WebKit::tryInterceptNavigation):
280         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
281         * UIProcess/Cocoa/UIDelegate.h:
282         * UIProcess/Cocoa/UIDelegate.mm:
283         (WebKit::UIDelegate::UIClient::createNewPage):
284         * UIProcess/WebPageProxy.cpp:
285         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
286         (WebKit::tryOptimizingLoad):
287         (WebKit::WebPageProxy::createNewPage):
288         * UIProcess/WebPageProxy.h:
289
290 2019-03-11  Dean Jackson  <dino@apple.com>
291
292         [iOS] Implement a faster click detection that intercepts double-tap-to-zoom if possible
293         https://bugs.webkit.org/show_bug.cgi?id=195473
294         <rdar://problem/48718396>
295
296         Reviewed by Wenson Hsieh (with some help from Dan Bates).
297
298         Adds a new algorithm, behind a flag FasterClicksEnabled, that can trigger a click
299         event without waiting to see if a double tap will occur. It does this by examining
300         the amount of zoom that would be triggered if it was a double tap, and if that value
301         doesn't exceed a set threshold, commits to the click event instead.
302
303         This is implemented by having the Web Process respond to the potential click with
304         some geometry information. If the UI Process receives the information before the
305         second tap in a double tap, it can decide to trigger a click.
306
307         * Shared/WebPreferences.yaml: New internal feature so this can be toggled in
308             a UI for testing.
309
310         * SourcesCocoa.txt: Renamed WKSyntheticTapGestureRecognizer.
311         * WebKit.xcodeproj/project.pbxproj: Ditto.
312
313         * UIProcess/ios/WKSyntheticTapGestureRecognizer.h:
314         * UIProcess/ios/WKSyntheticTapGestureRecognizer.m:
315         (-[WKSyntheticTapGestureRecognizer setGestureIdentifiedTarget:action:]):
316         (-[WKSyntheticTapGestureRecognizer setGestureFailedTarget:action:]):
317         (-[WKSyntheticTapGestureRecognizer setResetTarget:action:]):
318         (-[WKSyntheticTapGestureRecognizer setState:]):
319         (-[WKSyntheticTapGestureRecognizer reset]):  Renamed WKSyntheticClickTapGestureRecognizer to
320             WKSyntheticTapGestureRecognizer, changed the signature of the main function to be a bit
321             more clear about what it does, and added a gesture failed target.
322
323         * UIProcess/API/Cocoa/WKWebViewInternal.h:
324         * UIProcess/API/Cocoa/WKWebView.mm:
325         (-[WKWebView _initialScaleFactor]):
326         (-[WKWebView _contentZoomScale]):
327         (-[WKWebView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
328             Exposed the initial content scale, the current scale and added a declaration that
329             was missing from the .h.
330
331         * UIProcess/WebPageProxy.messages.in: Add a new message,
332             HandleSmartMagnificationInformationForPotentialTap, to
333             communicate the geometry of the clicked node to the UI Process.
334
335         * UIProcess/PageClient.h: Pure virtual function for the geometry message response.
336         * UIProcess/WebPageProxy.h: Ditto.
337
338         * UIProcess/ios/PageClientImplIOS.h: Calls into the WKContentView.
339         * UIProcess/ios/PageClientImplIOS.mm:
340         (WebKit::PageClientImpl::handleSmartMagnificationInformationForPotentialTap):
341
342         * UIProcess/ios/SmartMagnificationController.h:
343         * UIProcess/ios/SmartMagnificationController.mm:
344         (WebKit::SmartMagnificationController::calculatePotentialZoomParameters): A new method that
345             asks the WKContentView to work out what the zoom factor will be for a potential double
346             tap at a location.
347         (WebKit::SmartMagnificationController::smartMagnificationTargetRectAndZoomScales): New implementation
348             of this function to avoid multiple out-arguments.
349
350         * UIProcess/ios/WKContentView.h:
351         * UIProcess/ios/WKContentView.mm:
352         (-[WKContentView _initialScaleFactor]):
353         (-[WKContentView _contentZoomScale]):
354         (-[WKContentView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
355             Exposed the initial content scale, the current scale and the target zoom scale. These
356             all just call into the WKWebView implementation.
357
358         * UIProcess/ios/WKContentViewInteraction.h:
359         * UIProcess/ios/WKContentViewInteraction.mm:
360         (-[WKContentView _createAndConfigureDoubleTapGestureRecognizer]): Use a WKSyntheticTapGestureRecognizer instead
361             of a generic one, so we can capture the failure.
362         (-[WKContentView setupInteraction]):
363         (-[WKContentView cleanupInteraction]):
364         (-[WKContentView _handleSmartMagnificationInformationForPotentialTap:origin:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:]):
365             New method that responds to the incoming Web Process message, and decides if any
366             potential zoom would be "significant".
367         (-[WKContentView _singleTapIdentified:]):
368         (-[WKContentView _doubleTapDidFail:]):
369         (-[WKContentView _didCompleteSyntheticClick]):
370         (-[WKContentView _singleTapRecognized:]):
371         (-[WKContentView _doubleTapRecognized:]):
372             Add some release logging.
373         (-[WKContentView _singleTapCommited:]): Deleted.
374
375         * UIProcess/ios/WebPageProxyIOS.mm:
376         (WebKit::WebPageProxy::potentialTapAtPosition):
377         (WebKit::WebPageProxy::handleSmartMagnificationInformationForPotentialTap):
378         * WebProcess/WebPage/ViewGestureGeometryCollector.h:
379         * WebProcess/WebPage/WebPage.h:
380         * WebProcess/WebPage/WebPage.messages.in:
381             Removed an unused parameter from the existing message.
382
383         * WebProcess/WebPage/ios/WebPageIOS.mm:
384         (WebKit::WebPage::potentialTapAtPosition): Calculates the geometry of the element
385         if requested, and sends it to the UIProcess.
386
387 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
388
389         Unreviewed build fix after r242745.
390
391         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
392         (WebKit::WebProcessPool::registerNotificationObservers):
393         (WebKit::WebProcessPool::unregisterNotificationObservers):
394
395 2019-03-11  Chris Dumez  <cdumez@apple.com>
396
397         Assert in WebPageProxy::suspendCurrentPageIfPossible()
398         https://bugs.webkit.org/show_bug.cgi?id=195506
399         <rdar://problem/48733477>
400
401         Reviewed by Alex Christensen.
402
403         The crash was caused by the top-hit preloading logic in MobileSafari which creates a new Web view that is *related*
404         to the previous one, restores the session state onto it and then triggers a load in this new Web view.
405
406         Initially, the 2 Web views use the same process as they are related. However, if the new load's URL is cross-site
407         with regards to the first view's URL, then we decide to process swap in the new view. This process swap makes
408         sense from a security standpoint. However, when we commit the load in the new process and call
409         suspendCurrentPageIfPossible() we end up in an unexpected state because we have a fromItem (due to the session
410         state having been restored on the new view) but we haven't committed any load yet in this new view.
411
412         To address the issue, suspendCurrentPageIfPossible() now returns early and does not attempt to suspend anything
413         if we have not committed any load yet.
414
415         * UIProcess/WebPageProxy.cpp:
416         (WebKit::WebPageProxy::suspendCurrentPageIfPossible):
417         Do not attempt to suspend to current page if we have not committed any provisional load yet.
418
419 2019-03-11  Chris Dumez  <cdumez@apple.com>
420
421         Update device orientation & motion permission native SPI as per latest proposal
422         https://bugs.webkit.org/show_bug.cgi?id=195567
423
424         Reviewed by Youenn Fablet.
425
426         The native SPI is now:
427         +- (void)_webView:(WKWebView *)webView shouldAllowDeviceOrientationAndMotionAccessRequestedByFrame:(WKFrameInfo *)frameInfo decisionHandler:(void (^)(BOOL))decisionHandler;
428
429         * UIProcess/API/APIUIClient.h:
430         (API::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
431         * UIProcess/API/C/WKPage.cpp:
432         (WKPageSetPageUIClient):
433         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
434         * UIProcess/Cocoa/UIDelegate.h:
435         * UIProcess/Cocoa/UIDelegate.mm:
436         (WebKit::UIDelegate::setDelegate):
437         (WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
438         * UIProcess/WebPageProxy.cpp:
439         (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
440         * UIProcess/WebPageProxy.h:
441         * UIProcess/WebPageProxy.messages.in:
442         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
443         (WebKit::WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess):
444         * WebProcess/WebCoreSupport/WebChromeClient.h:
445         * WebProcess/WebPage/WebPage.cpp:
446         (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
447         * WebProcess/WebPage/WebPage.h:
448
449 2019-03-11  Andy Estes  <aestes@apple.com>
450
451         [Apple Pay] Use PKPaymentAuthorizationController to present the Apple Pay UI remotely from the Networking service on iOS
452         https://bugs.webkit.org/show_bug.cgi?id=195530
453         <rdar://problem/48747164>
454
455         Reviewed by Alex Christensen.
456
457         * Configurations/Network-iOS.entitlements: Added the 'com.apple.payment.all-access'
458         entitlement and reordered the others.
459
460         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
461         (WebKit::NetworkConnectionToWebProcess::didReceiveMessage): Forwarded
462         WebPaymentCoordinatorProxy messages to the payment coordinator.
463         (WebKit::NetworkConnectionToWebProcess::didReceiveSyncMessage): Ditto.
464         (WebKit::NetworkConnectionToWebProcess::didClose): Set m_paymentCoordinator to nullptr.
465         * NetworkProcess/NetworkConnectionToWebProcess.h: Inherited from
466         WebPaymentCoordinatorProxy::Client and added a unique_ptr<WebPaymentCoordinatorProxy> member.
467
468         * NetworkProcess/cocoa/NetworkSessionCocoa.h: Declared getters for source application bundle
469         and secondary identifiers, and CTDataConnectionServiceType on iOS.
470         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
471         (WebKit::NetworkSessionCocoa::sourceApplicationBundleIdentifier const): Defined getter.
472         (WebKit::NetworkSessionCocoa::sourceApplicationSecondaryIdentifier const): Ditto.
473         (WebKit::NetworkSessionCocoa::ctDataConnectionServiceType const): Ditto.
474         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): Initialized
475         m_sourceApplicationBundleIdentifier and m_sourceApplicationSecondaryIdentifier with
476         corresponding NetworkSessionCreationParameters.
477
478         * NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm: Added.
479         (WebKit::NetworkConnectionToWebProcess::paymentCoordinator): Added. Returns
480         m_paymentCoordinator after lazily initializing it.
481         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorConnection): Added. Returns the
482         connection to the web process.
483         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorPresentingViewController): Added.
484         Returns nil.
485         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorCTDataConnectionServiceType):
486         Added. Returns the value from the network session identified by sessionID.
487         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationBundleIdentifier):
488         Ditto.
489         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationSecondaryIdentifier):
490         Ditto.
491         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAuthorizationPresenter): Added.
492         Returns a new PaymentAuthorizationController.
493         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAddMessageReceiver): Added empty
494         definition. NetworkConnectionToWebProcess explicitly forwards WebPaymentCoordinatorProxy
495         messages to its payment coordinator, so there's no need to register with a MessageReceiverMap.
496         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorRemoveMessageReceiver): Ditto.
497
498         * Platform/ios/PaymentAuthorizationController.h: Added. Declares a
499         PaymentAuthorizationPresenter subclass based on PKPaymentAuthorizationController.
500         * Platform/ios/PaymentAuthorizationController.mm: Added.
501         (-[WKPaymentAuthorizationControllerDelegate initWithRequest:presenter:]):
502         Initialized WKPaymentAuthorizationDelegate with request and presenter.
503         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationControllerDidFinish:]):
504         Forwarded call to WKPaymentAuthorizationDelegate.
505         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didAuthorizePayment:handler:]):
506         Ditto.
507         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingMethod:handler:]):
508         Ditto.
509         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingContact:handler:]):
510         Ditto.
511         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectPaymentMethod:handler:]):
512         Ditto.
513         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:willFinishWithError:]):
514         Ditto.
515         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didRequestMerchantSession:]):
516         Ditto.
517         (WebKit::PaymentAuthorizationController::PaymentAuthorizationController):
518         Initialized m_controller with a new PKPaymentAuthorizationController and m_delegate with a
519         new WKPaymentAuthorizationControllerDelegate.
520         (WebKit::PaymentAuthorizationController::platformDelegate): Returned m_delegate.
521         (WebKit::PaymentAuthorizationController::dismiss): Dismissed the controller, set its
522         delegates to nil, set m_controller to nil, invalidated the delegate, and set m_delegate to
523         nil.
524         (WebKit::PaymentAuthorizationController::present): Called -presentWithCompletion: on the
525         controller, forwarding the passed-in completion handler.
526         * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: Allowed PassKit to look up
527         the "com.apple.passd.in-app-payment" and "com.apple.passd.library" service endpoints.
528
529         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
530         (WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy): Changed to call
531         paymentCoordinatorAddMessageReceiver.
532         (WebKit::WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy): Changed to call
533         paymentCoordinatorRemoveMessageReceiver.
534         (WebKit::WebPaymentCoordinatorProxy::messageSenderDestinationID const): Deleted.
535         (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard): Passed sessionID to
536         platformCanMakePaymentsWithActiveCard.
537         (WebKit::WebPaymentCoordinatorProxy::showPaymentUI): Stored destinationID and passed
538         sessionID to platformShowPaymentUI.
539         (WebKit::WebPaymentCoordinatorProxy::cancelPaymentSession): Changed to account for new
540         behavior of didCancelPaymentSession.
541         (WebKit::WebPaymentCoordinatorProxy::didCancelPaymentSession): Changed to call hidePaymentUI.
542         (WebKit::WebPaymentCoordinatorProxy::presenterDidFinish): Changed to only call hidePaymentUI
543         when didReachFinalState is true, since didCancelPaymentSession is called otherwise.
544         (WebKit::WebPaymentCoordinatorProxy::didReachFinalState): Cleared m_destinationID.
545         * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Added m_destionationID member.
546         * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Changed
547         CanMakePaymentsWithActiveCard and ShowPaymentUI messages to take destinationID and sessionID
548         arguments.
549
550         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
551         (WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard): Passed
552         sessionID to paymentCoordinatorSourceApplicationSecondaryIdentifier.
553         (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Passed sessionID to various
554         m_client call sites.
555
556         * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
557         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
558         platformPaymentRequest.
559         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
560         before calling dismiss.
561
562         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
563         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
564         platformPaymentRequest.
565         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
566         before calling dismiss.
567
568         * Shared/WebPreferences.yaml: Added ApplePayRemoteUIEnabled as an internal preference.
569
570         * SourcesCocoa.txt: Added NetworkConnectionToWebProcessIOS.mm and
571         PaymentAuthorizationController.mm.
572
573         * UIProcess/AuxiliaryProcessProxy.h:
574         (WebKit::AuxiliaryProcessProxy::messageReceiverMap): Deleted.
575
576         * UIProcess/Cocoa/WebPageProxyCocoa.mm:
577         (WebKit::WebPageProxy::paymentCoordinatorConnection): Moved from WebPageProxy.cpp.
578         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
579         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
580         (WebKit::WebPageProxy::paymentCoordinatorAddMessageReceiver): Ditto.
581         (WebKit::WebPageProxy::paymentCoordinatorRemoveMessageReceiver): Ditto.
582
583         * UIProcess/WebPageProxy.cpp:
584         (WebKit::WebPageProxy::paymentCoordinatorConnection): Moved to WebPageProxyCocoa.mm.
585         (WebKit::WebPageProxy::paymentCoordinatorMessageReceiver): Ditto.
586         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
587         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
588         (WebKit::WebPageProxy::paymentCoordinatorDestinationID): Ditto.
589         * UIProcess/WebPageProxy.h:
590
591         * UIProcess/ios/WebPageProxyIOS.mm:
592         (WebKit::WebPageProxy::paymentCoordinatorCTDataConnectionServiceType): Asserted that
593         sessionID equals the website data store's sessionID.
594
595         * WebKit.xcodeproj/project.pbxproj:
596
597         * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
598         (WebKit::WebPaymentCoordinator::networkProcessConnectionClosed): Added. Cancels the current
599         session if Apple Pay Remote UI is enabled and the network process connection closes.
600         (WebKit::WebPaymentCoordinator::availablePaymentNetworks): Changed to account for
601         WebPaymentCoordinator being an IPC::MessageSender.
602         (WebKit::WebPaymentCoordinator::canMakePayments): Ditto.
603         (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard): Ditto.
604         (WebKit::WebPaymentCoordinator::openPaymentSetup): Ditto.
605         (WebKit::WebPaymentCoordinator::showPaymentUI): Ditto.
606         (WebKit::WebPaymentCoordinator::completeMerchantValidation): Ditto.
607         (WebKit::WebPaymentCoordinator::completeShippingMethodSelection): Ditto.
608         (WebKit::WebPaymentCoordinator::completeShippingContactSelection): Ditto.
609         (WebKit::WebPaymentCoordinator::completePaymentMethodSelection): Ditto.
610         (WebKit::WebPaymentCoordinator::completePaymentSession): Ditto.
611         (WebKit::WebPaymentCoordinator::abortPaymentSession): Ditto.
612         (WebKit::WebPaymentCoordinator::cancelPaymentSession): Ditto.
613         (WebKit::WebPaymentCoordinator::messageSenderConnection const): Added. Returns a connection
614         to the network process if Apple Pay Remote UI is enabled. Otherwise, returned the web
615         process's parent connection.
616         (WebKit::WebPaymentCoordinator::messageSenderDestinationID const): Added. Returns the web
617         page's ID.
618         (WebKit::WebPaymentCoordinator::remoteUIEnabled const): Added. Calls Settings::applePayRemoteUIEnabled.
619         * WebProcess/ApplePay/WebPaymentCoordinator.h: Inherited from IPC::MessageSender.
620
621         * WebProcess/Network/NetworkProcessConnection.cpp:
622         (WebKit::NetworkProcessConnection::didReceiveMessage): Forwarded WebPaymentCoordinator
623         messages to the payment coordinator of the web page matching the decoder's destination ID.
624         (WebKit::NetworkProcessConnection::didReceiveSyncMessage): Ditto for sync messages.
625
626         * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
627         (WebKit::WebPage::paymentCoordinator): Added a payment coordinator getter.
628         * WebProcess/WebPage/WebPage.h: Ditto.
629
630         * WebProcess/WebProcess.cpp:
631         (WebKit::WebProcess::networkProcessConnectionClosed): Called
632         WebPaymentCoordinator::networkProcessConnectionClosed when the network process connection
633         closes.
634
635 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
636
637         [iOS] Block access to backboardd service
638         https://bugs.webkit.org/show_bug.cgi?id=195484
639
640         Reviewed by Brent Fulgham.
641
642         This patch is addressing blocking the backboardd service "com.apple.backboard.hid.services". Getting the
643         backlight level in the WebContent process will initiate a connection with this service. To be able to
644         block the service, the backlight level is queried in the UI process and sent to the WebContent process
645         when the WebContent process is started, and when the backlight level is changed. On the WebContent side,
646         the method getting the backlight level is swizzled to return the value sent from the UI process.
647
648         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
649         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
650         (WebKit::WebProcessPool::displayBrightness):
651         (WebKit::WebProcessPool::backlightLevelDidChangeCallback):
652         (WebKit::WebProcessPool::registerNotificationObservers):
653         (WebKit::WebProcessPool::unregisterNotificationObservers):
654         * UIProcess/WebProcessPool.cpp:
655         (WebKit::WebProcessPool::initializeNewWebProcess):
656         * UIProcess/WebProcessPool.h:
657         * WebProcess/WebProcess.h:
658         * WebProcess/WebProcess.messages.in:
659         * WebProcess/cocoa/WebProcessCocoa.mm:
660         (WebKit::currentBacklightLevel):
661         (WebKit::WebProcess::backlightLevelDidChange):
662
663 2019-03-11  Brent Fulgham  <bfulgham@apple.com>
664
665         Remove obsolete runtime flag for StorageAccess API Prompt
666         https://bugs.webkit.org/show_bug.cgi?id=195564
667         <rdar://problem/37279014>
668
669         Reviewed by Chris Dumez.
670
671         This bug tracks the work of removing the obsolete flag that had been used to optionally
672         prevent display of the StorageAccess API prompt. We have since shipped the final version
673         of this feature with an always-on prompt, and should have removed this runtime flag.
674
675         No test changes because this has no change in behavior. Tests already assume the prompt
676         behavior, and did not test turning the flag off.
677
678         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
679         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
680         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
681         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
682         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
683         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
684         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
685         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
686         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
687         (WebKit::ResourceLoadStatisticsStore::debugModeEnabled const):
688         (WebKit::ResourceLoadStatisticsStore::storageAccessPromptsEnabled const): Deleted.
689         (WebKit::ResourceLoadStatisticsStore::setStorageAccessPromptsEnabled): Deleted.
690         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
691         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted):
692         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
693         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
694         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
695         (WebKit::NetworkConnectionToWebProcess::requestStorageAccess):
696         * NetworkProcess/NetworkConnectionToWebProcess.h:
697         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
698         * NetworkProcess/NetworkProcess.cpp:
699         (WebKit::NetworkProcess::requestStorageAccess):
700         (WebKit::NetworkProcess::requestStorageAccessGranted):
701         * NetworkProcess/NetworkProcess.h:
702         * NetworkProcess/NetworkProcess.messages.in:
703         * Shared/WebPreferences.yaml:
704         * UIProcess/API/C/WKPreferences.cpp:
705         (WKPreferencesSetStorageAccessPromptsEnabled): Deleted.
706         (WKPreferencesGetStorageAccessPromptsEnabled): Deleted.
707         * UIProcess/API/C/WKPreferencesRef.h:
708         * UIProcess/API/Cocoa/WKPreferences.mm:
709         (-[WKPreferences _storageAccessPromptsEnabled]): Deleted.
710         (-[WKPreferences _setStorageAccessPromptsEnabled:]): Deleted.
711         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
712         * UIProcess/Network/NetworkProcessProxy.cpp:
713         (WebKit::NetworkProcessProxy::requestStorageAccess):
714         * UIProcess/Network/NetworkProcessProxy.h:
715         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
716         (WebKit::WebsiteDataStore::requestStorageAccess):
717         * UIProcess/WebsiteData/WebsiteDataStore.h:
718         * WebProcess/WebPage/WebPage.cpp:
719         (WebKit::WebPage::requestStorageAccess):
720
721 2019-03-11  Alex Christensen  <achristensen@webkit.org>
722
723         Add a WKContentRuleList variant that uses copied memory instead of mmap'd shared memory for class A containerized apps
724         https://bugs.webkit.org/show_bug.cgi?id=195511
725         <rdar://problem/44873269>
726
727         Reviewed by Darin Adler.
728
729         * NetworkProcess/NetworkContentRuleListManager.cpp:
730         (WebKit::NetworkContentRuleListManager::addContentRuleLists):
731         * NetworkProcess/NetworkContentRuleListManager.h:
732         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
733         (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting):
734         (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting):
735         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
736         * NetworkProcess/cache/NetworkCacheFileSystem.h:
737         * Shared/WebCompiledContentRuleList.cpp:
738         (WebKit::WebCompiledContentRuleList::usesCopiedMemory const):
739         (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):
740         (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const):
741         (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const):
742         (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const):
743         (WebKit::WebCompiledContentRuleList::actions const):
744         * Shared/WebCompiledContentRuleList.h:
745         * Shared/WebCompiledContentRuleListData.cpp:
746         (WebKit::WebCompiledContentRuleListData::size const):
747         (WebKit::WebCompiledContentRuleListData::dataPointer const):
748         (WebKit::WebCompiledContentRuleListData::encode const):
749         (WebKit::WebCompiledContentRuleListData::decode):
750         * Shared/WebCompiledContentRuleListData.h:
751         (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
752         * UIProcess/API/APIContentRuleList.cpp:
753         (API::ContentRuleList::usesCopiedMemory const):
754         * UIProcess/API/APIContentRuleList.h:
755         * UIProcess/API/APIContentRuleListStore.cpp:
756         (API::getData):
757         (API::decodeContentRuleListMetaData):
758         (API::ContentRuleListStore::readContentsOfFile):
759         (API::MappedOrCopiedData::dataPointer const):
760         (API::openAndMapOrCopyContentRuleList):
761         (API::compiledToFile):
762         (API::createExtension):
763         (API::ContentRuleListStore::lookupContentRuleList):
764         (API::ContentRuleListStore::compileContentRuleList):
765         (API::ContentRuleListStore::getContentRuleListSource):
766         (API::openAndMapContentRuleList): Deleted.
767         * UIProcess/API/APIContentRuleListStore.h:
768         * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm:
769         (API::ContentRuleListStore::readContentsOfFile):
770         * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
771         (+[WKContentRuleListStore _registerPathAsUnsafeToMemoryMapForTesting:]):
772         * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h:
773         * UIProcess/API/Cocoa/_WKUserContentFilter.mm:
774         (-[_WKUserContentFilter usesCopiedMemory]):
775         * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h:
776         * WebProcess/UserContent/WebUserContentController.cpp:
777         (WebKit::WebUserContentController::addContentRuleLists):
778         * WebProcess/UserContent/WebUserContentController.h:
779         * WebProcess/WebPage/WebPage.cpp:
780         (WebKit::m_hostFileDescriptor):
781
782 2019-03-11  Chris Dumez  <cdumez@apple.com>
783
784         Unreviewed, fix assertions in layout tests on iOS Simulator after r242666.
785
786         Log an error but do not crash if we fail to acquire a ProcessAssertion.
787
788         * UIProcess/ios/ProcessAssertionIOS.mm:
789         (WebKit::ProcessAssertion::ProcessAssertion):
790
791 2019-03-11  Chris Dumez  <cdumez@apple.com>
792
793         WebProcessCache should keep track of processes being added
794         https://bugs.webkit.org/show_bug.cgi?id=195538
795
796         Reviewed by Geoffrey Garen.
797
798         WebProcessCache should keep track of processes being added, while they are being
799         checked for responsiveness. This is useful so that:
800         - Requests to clear the cache also clear processes being added
801         - Requests to remove a given process from the cache (either because it crashed
802           or because it is being used for a history navigation) actually remove the
803           process if it is still being checked for responsiveness.
804         - The cached process eviction timer applies to such processes in case something
805           goes wrong with the code and the pending request does not get processed.
806
807         * UIProcess/WebProcessCache.cpp:
808         (WebKit::generateAddRequestIdentifier):
809         (WebKit::WebProcessCache::addProcessIfPossible):
810         (WebKit::WebProcessCache::addProcess):
811         (WebKit::WebProcessCache::clear):
812         (WebKit::WebProcessCache::clearAllProcessesForSession):
813         (WebKit::WebProcessCache::removeProcess):
814         (WebKit::WebProcessCache::CachedProcess::evictionTimerFired):
815         (WebKit::WebProcessCache::evictProcess): Deleted.
816         * UIProcess/WebProcessCache.h:
817         (WebKit::WebProcessCache::size const):
818         * UIProcess/WebProcessPool.cpp:
819         (WebKit::WebProcessPool::processForNavigationInternal):
820         * UIProcess/WebProcessProxy.cpp:
821         (WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
822
823 2019-03-11  Alex Christensen  <achristensen@webkit.org>
824
825         REGRESSION: ( r240978-r240985 ) [ iOS Release ] Layout Test imported/w3c/web-platform-tests/xhr/send-redirect-post-upload.htm is crashing
826         https://bugs.webkit.org/show_bug.cgi?id=194523
827
828         Reviewed by Alexey Proskuryakov.
829
830         Attempt another workaround to prevent crashes.
831
832         * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
833         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
834         (WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
835         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
836         (-[WKNetworkSessionDelegate URLSession:task:needNewBodyStream:]):
837
838 2019-03-11  Ryan Haddad  <ryanhaddad@apple.com>
839
840         Unreviewed, rolling out r242688, r242643, r242624.
841
842         Caused multiple layout test failures and crashes on iOS and macOS.
843
844         Reverted changeset:
845
846         "requestAnimationFrame should execute before the next frame"
847         https://bugs.webkit.org/show_bug.cgi?id=177484
848         https://trac.webkit.org/changeset/242624/webkit
849
850         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
851         (WebKit::DrawingAreaCoordinatedGraphics::scheduleCompositingLayerFlush):
852         (WebKit::DrawingAreaCoordinatedGraphics::updateBackingStoreState):
853         (WebKit::DrawingAreaCoordinatedGraphics::display):
854         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
855         (WebKit::LayerTreeHost::layerFlushTimerFired):
856         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
857         (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
858         * WebProcess/WebPage/WebPage.cpp:
859         (WebKit::WebPage::layoutIfNeeded):
860         (WebKit::WebPage::willDisplayPage):
861         (WebKit::WebPage::renderingUpdate): Deleted.
862         * WebProcess/WebPage/WebPage.h:
863         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
864         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
865
866 2019-03-11  Darin Adler  <darin@apple.com>
867
868         Specify fixed precision explicitly to prepare to change String::number and StringBuilder::appendNumber floating point behavior
869         https://bugs.webkit.org/show_bug.cgi?id=195533
870
871         Reviewed by Brent Fulgham.
872
873         * NetworkProcess/cache/NetworkCache.cpp:
874         (WebKit::NetworkCache::Cache::dumpContentsToFile): Use appendFixedPrecisionNumber.
875         * NetworkProcess/cache/NetworkCacheEntry.cpp:
876         (WebKit::NetworkCache::Entry::asJSON const): Ditto.
877         * Shared/Gamepad/GamepadData.cpp:
878         (WebKit::GamepadData::loggingString const): Ditto.
879         * UIProcess/WebPageProxy.cpp:
880         (WebKit::WebPageProxy::logDiagnosticMessageWithValue): Use numberToStringFixedPrecision.
881
882 2019-03-11  John Wilander  <wilander@apple.com>
883
884         Resource Load Statistics: Make it possible exclude localhost from classification
885         https://bugs.webkit.org/show_bug.cgi?id=195474
886         <rdar://problem/47520577>
887
888         Reviewed by Brent Fulgham.
889
890         This patch allows for localhost to be excluded from classification and
891         treatment as a prevalent resource.
892
893         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
894         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
895         (WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources):
896             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
897         (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource):
898             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
899         (WebKit::ResourceLoadStatisticsDatabaseStore::isPrevalentResource const):
900             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
901         (WebKit::ResourceLoadStatisticsDatabaseStore::isVeryPrevalentResource const):
902             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
903         (WebKit::ResourceLoadStatisticsDatabaseStore::setVeryPrevalentResource):
904             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
905         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
906         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
907         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
908         (WebKit::ResourceLoadStatisticsMemoryStore::classifyPrevalentResources):
909             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
910         (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResource):
911             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
912         (WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentResource const):
913             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
914         (WebKit::ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource const):
915             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
916         (WebKit::ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource):
917             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
918         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
919         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
920         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
921             Now takes a ShouldIncludeLocalhost parameter.
922         (WebKit::ResourceLoadStatisticsStore::shouldSkip const):
923             Convenience function, currently supporting the localhost exclusion.
924         (WebKit::ResourceLoadStatisticsStore::setIsRunningTest):
925             Test infrastructure.
926         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
927         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
928         (WebKit::WebResourceLoadStatisticsStore::setIsRunningTest):
929             Test infrastructure.
930         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
931             Now takes a ShouldIncludeLocalhost parameter.
932         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
933             Defines the new ShouldIncludeLocalhost boolean enum.
934         * NetworkProcess/NetworkProcess.cpp:
935         (WebKit::NetworkProcess::setIsRunningResourceLoadStatisticsTest):
936             Test infrastructure.
937         * NetworkProcess/NetworkProcess.h:
938         * NetworkProcess/NetworkProcess.messages.in:
939         * NetworkProcess/NetworkSession.cpp:
940         (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
941             Forwards the localhost setting to the create function.
942         * NetworkProcess/NetworkSession.h:
943         * NetworkProcess/NetworkSessionCreationParameters.cpp:
944         (WebKit::NetworkSessionCreationParameters::encode const):
945         (WebKit::NetworkSessionCreationParameters::decode):
946         * NetworkProcess/NetworkSessionCreationParameters.h:
947             New parameter called shouldIncludeLocalhostInResourceLoadStatistics.
948         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
949         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
950             Picks up the localhost setting from the parameters.
951         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
952         (WKWebsiteDataStoreSetStatisticsIsRunningTest):
953             Test infrastructure.
954         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
955         * UIProcess/Network/NetworkProcessProxy.cpp:
956         (WebKit::NetworkProcessProxy::setIsRunningResourceLoadStatisticsTest):
957             Test infrastructure.
958         * UIProcess/Network/NetworkProcessProxy.h:
959         * UIProcess/WebProcessPool.cpp:
960         (WebKit::WebProcessPool::ensureNetworkProcess):
961             Picks up the localhost setting from the WebsiteDataStore parameters.
962         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
963         (WebKit::WebsiteDataStore::parameters):
964             Makes sure Safari does not exclude localhost.
965         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
966         (WebKit::WebsiteDataStore::setIsRunningResourceLoadStatisticsTest):
967             Test infrastructure.
968         * UIProcess/WebsiteData/WebsiteDataStore.h:
969
970 2019-03-11  Alex Christensen  <achristensen@webkit.org>
971
972         Unreviewed, rolling out r242698.
973
974         API test crashes on bots.
975
976         Reverted changeset:
977
978         "Add a WKContentRuleList variant that uses copied memory
979         instead of mmap'd shared memory for class A containerized
980         apps"
981         https://bugs.webkit.org/show_bug.cgi?id=195511
982         https://trac.webkit.org/changeset/242698
983
984 2019-03-11  Michael Catanzaro  <mcatanzaro@igalia.com>
985
986         [WPE] Enable web process sandbox
987         https://bugs.webkit.org/show_bug.cgi?id=195169
988
989         Reviewed by Daniel Bates.
990
991         * PlatformWPE.cmake:
992         * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
993         (WebKit::bubblewrapSpawn):
994
995 2019-03-11  Truitt Savell  <tsavell@apple.com>
996
997         Unreviewed, rolling out r242697.
998
999         Broke internal builders.
1000
1001         Reverted changeset:
1002
1003         "Optimizing loads when creating new pages"
1004         https://bugs.webkit.org/show_bug.cgi?id=195516
1005         https://trac.webkit.org/changeset/242697
1006
1007 2019-03-10  Alex Christensen  <achristensen@webkit.org>
1008
1009         Add a WKContentRuleList variant that uses copied memory instead of mmap'd shared memory for class A containerized apps
1010         https://bugs.webkit.org/show_bug.cgi?id=195511
1011         <rdar://problem/44873269>
1012
1013         Reviewed by Darin Adler.
1014
1015         * NetworkProcess/NetworkContentRuleListManager.cpp:
1016         (WebKit::NetworkContentRuleListManager::addContentRuleLists):
1017         * NetworkProcess/NetworkContentRuleListManager.h:
1018         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
1019         (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting):
1020         (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting):
1021         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
1022         * NetworkProcess/cache/NetworkCacheFileSystem.h:
1023         * Shared/WebCompiledContentRuleList.cpp:
1024         (WebKit::WebCompiledContentRuleList::usesCopiedMemory const):
1025         (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):
1026         (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const):
1027         (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const):
1028         (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const):
1029         (WebKit::WebCompiledContentRuleList::actions const):
1030         * Shared/WebCompiledContentRuleList.h:
1031         * Shared/WebCompiledContentRuleListData.cpp:
1032         (WebKit::WebCompiledContentRuleListData::size const):
1033         (WebKit::WebCompiledContentRuleListData::dataPointer const):
1034         (WebKit::WebCompiledContentRuleListData::encode const):
1035         (WebKit::WebCompiledContentRuleListData::decode):
1036         * Shared/WebCompiledContentRuleListData.h:
1037         (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
1038         * UIProcess/API/APIContentRuleList.cpp:
1039         (API::ContentRuleList::usesCopiedMemory const):
1040         * UIProcess/API/APIContentRuleList.h:
1041         * UIProcess/API/APIContentRuleListStore.cpp:
1042         (API::getData):
1043         (API::decodeContentRuleListMetaData):
1044         (API::ContentRuleListStore::readContentsOfFile):
1045         (API::MappedOrCopiedData::dataPointer const):
1046         (API::openAndMapOrCopyContentRuleList):
1047         (API::compiledToFile):
1048         (API::createExtension):
1049         (API::ContentRuleListStore::lookupContentRuleList):
1050         (API::ContentRuleListStore::compileContentRuleList):
1051         (API::ContentRuleListStore::getContentRuleListSource):
1052         (API::openAndMapContentRuleList): Deleted.
1053         * UIProcess/API/APIContentRuleListStore.h:
1054         * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm:
1055         (API::ContentRuleListStore::readContentsOfFile):
1056         * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
1057         (+[WKContentRuleListStore _registerPathAsUnsafeToMemoryMapForTesting:]):
1058         * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h:
1059         * UIProcess/API/Cocoa/_WKUserContentFilter.mm:
1060         (-[_WKUserContentFilter usesCopiedMemory]):
1061         * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h:
1062         * WebProcess/UserContent/WebUserContentController.cpp:
1063         (WebKit::WebUserContentController::addContentRuleLists):
1064         * WebProcess/UserContent/WebUserContentController.h:
1065         * WebProcess/WebPage/WebPage.cpp:
1066         (WebKit::m_hostFileDescriptor):
1067
1068 2019-03-10  Jiewen Tan  <jiewen_tan@apple.com>
1069
1070         Optimizing loads when creating new pages
1071         https://bugs.webkit.org/show_bug.cgi?id=195516
1072         <rdar://problem/48738086>
1073
1074         Reviewed by Darin Adler.
1075
1076         This patch adds hooks in WebPageProxy::createNewPage to optimize loads, and moves the creationParameters
1077         of API::NavigationAction from UI clients to WebPageProxy::createNewPage. Also, we now pass the whole
1078         API::NavigationAction to the load optimizer instead of the request within.
1079
1080         * UIProcess/API/APINavigationAction.h:
1081         * UIProcess/API/APIUIClient.h:
1082         (API::UIClient::createNewPage):
1083         * UIProcess/API/C/WKPage.cpp:
1084         (WKPageSetPageUIClient):
1085         * UIProcess/API/glib/WebKitUIClient.cpp:
1086         * UIProcess/Cocoa/NavigationState.mm:
1087         (WebKit::tryOptimizingLoad):
1088         (WebKit::tryInterceptNavigation):
1089         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
1090         * UIProcess/Cocoa/UIDelegate.h:
1091         * UIProcess/Cocoa/UIDelegate.mm:
1092         (WebKit::UIDelegate::UIClient::createNewPage):
1093         * UIProcess/WebPageProxy.cpp:
1094         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
1095         (WebKit::tryOptimizingLoad):
1096         (WebKit::WebPageProxy::createNewPage):
1097         * UIProcess/WebPageProxy.h:
1098
1099 2019-03-10  Tim Horton  <timothy_horton@apple.com>
1100
1101         Add SPI to retrieve the set of text inputs in a given rect, and later focus one
1102         https://bugs.webkit.org/show_bug.cgi?id=195499
1103
1104         Reviewed by Darin Adler.
1105
1106         * Scripts/webkit/messages.py:
1107         * Shared/TextInputContext.cpp: Added.
1108         (IPC::ArgumentCoder<WebKit::TextInputContext>::encode):
1109         (IPC::ArgumentCoder<WebKit::TextInputContext>::decode):
1110         * Shared/TextInputContext.h: Added.
1111         (WebKit::TextInputContext::operator== const):
1112         Add TextInputContext, which represents a minimal set of information
1113         about a text field.
1114
1115         * Sources.txt:
1116         * SourcesCocoa.txt:
1117         * UIProcess/API/Cocoa/WKWebView.mm:
1118         (-[WKWebView _requestTextInputContextsInRect:completionHandler:]):
1119         (-[WKWebView _focusTextInputContext:completionHandler:]):
1120         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1121         Add SPI that allows clients to asynchronously request text input
1122         contexts for a given rect, and later focus a given context.
1123
1124         * UIProcess/API/Cocoa/_WKTextInputContext.h: Added.
1125         * UIProcess/API/Cocoa/_WKTextInputContext.mm: Added.
1126         (-[_WKTextInputContext _initWithTextInputContext:]):
1127         (-[_WKTextInputContext boundingRect]):
1128         (-[_WKTextInputContext _textInputContext]):
1129         (-[_WKTextInputContext isEqual:]):
1130         (-[_WKTextInputContext hash]):
1131         (-[_WKTextInputContext copyWithZone:]):
1132         * UIProcess/API/Cocoa/_WKTextInputContextInternal.h: Added.
1133         Add an SPI object that exposes a read-only window on a TextInputContext to clients.
1134
1135         * UIProcess/WebPageProxy.cpp:
1136         (WebKit::WebPageProxy::textInputContextsInRect):
1137         (WebKit::WebPageProxy::focusTextInputContext):
1138         * UIProcess/WebPageProxy.h:
1139         Plumbing from WKWebView<->WebPage.
1140
1141         * WebKit.xcodeproj/project.pbxproj:
1142         * WebProcess/WebPage/WebPage.cpp:
1143         (WebKit::elementRectInWindowCoordinates):
1144         (WebKit::isEditableTextInputElement):
1145         (WebKit::WebPage::textInputContextsInRect):
1146         Search the DOM for text input contexts: <input type='text'> (or other
1147         form fields that fall back on text field behavior), <textarea>, and
1148         contenteditable roots. Store the WebPage, Document, and Element identifiers
1149         so that we can find the element again later.
1150
1151         (WebKit::WebPage::focusTextInputContext):
1152         Find the element for a given (web page, document, element) triple and focus it,
1153         if it's still available.
1154
1155         * WebProcess/WebPage/WebPage.h:
1156         * WebProcess/WebPage/WebPage.messages.in:
1157
1158 2019-03-10  Tim Horton  <timothy_horton@apple.com>
1159
1160         iOS: Using ⌥ to scroll horizontally is no different than arrow key
1161         https://bugs.webkit.org/show_bug.cgi?id=195268
1162         <rdar://problem/48326682>
1163
1164         Reviewed by Brent Fulgham.
1165
1166         * UIProcess/ios/WKContentViewInteraction.mm:
1167         (-[WKContentView keyboardScrollViewAnimator:distanceForIncrement:inDirection:]):
1168         (-[WKContentView keyboardScrollViewAnimator:distanceForIncrement:]): Deleted.
1169         * UIProcess/ios/WKKeyboardScrollingAnimator.h:
1170         * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
1171         (-[WKKeyboardScrollingAnimator keyboardScrollForEvent:]):
1172         (-[WKKeyboardScrollViewAnimator setDelegate:]):
1173         (-[WKKeyboardScrollViewAnimator distanceForIncrement:inDirection:]):
1174         (-[WKKeyboardScrollViewAnimator distanceForIncrement:]): Deleted.
1175         Add a direction parameter to -distanceForIncrement:, so the client
1176         can return a different page/document size based on the scrolling axis.
1177         Adopt it both in the default implementation and in WKContentViewInteraction.
1178         Make the option key scroll by page when scrolling horizontally, like it
1179         does when scrolling vertically.
1180
1181 2019-03-10  David Quesada  <david_quesada@apple.com>
1182
1183         ASSERT(m_downloads.isEmpty()) fails in DownloadProxyMap::~DownloadProxyMap()
1184         https://bugs.webkit.org/show_bug.cgi?id=152480
1185
1186         Reviewed by Chris Dumez.
1187
1188         * UIProcess/Downloads/DownloadProxyMap.cpp:
1189         (WebKit::DownloadProxyMap::downloadFinished):
1190             If the DownloadProxy is holding the last reference to the process pool, then
1191             invalidating the proxy will cause the process pool, the network process proxy,
1192             and this DownloadProxyMap to deallocate. Ensure that doesn't happen until this
1193             method has done everything it wants to do to clean up.
1194
1195 2019-03-10  Wenson Hsieh  <wenson_hsieh@apple.com>
1196
1197         Fix some misleading function and variable names in WKContentViewInteraction.mm
1198         https://bugs.webkit.org/show_bug.cgi?id=195536
1199
1200         Reviewed by Tim Horton.
1201
1202         * UIProcess/ios/WKContentViewInteraction.mm:
1203         (shouldDeferZoomingToSelectionWhenRevealingFocusedElement):
1204
1205         Rename shouldZoomToRevealSelectionRect to shouldDeferZoomingToSelectionWhenRevealingFocusedElement; this
1206         function is used to determine whether we should zoom to the selection rect when revealing the focused element,
1207         and therefore affects whether we need to defer zooming until we get selection information.
1208
1209         (rectToRevealWhenZoomingToFocusedElement):
1210         (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
1211
1212         Rename shouldShowKeyboard to shouldShowInputView; this boolean indicates whether we should show not only the
1213         keyboard, but other UI for user input such as date and select pickers.
1214
1215         (-[WKContentView _didReceiveEditorStateUpdateAfterFocus]):
1216         (shouldZoomToRevealSelectionRect): Deleted.
1217
1218 2019-03-10  Simon Fraser  <simon.fraser@apple.com>
1219
1220         ScrollingTree should have the final say on where layers go
1221         https://bugs.webkit.org/show_bug.cgi?id=195507
1222
1223         Reviewed by Antti Koivisto.
1224
1225         * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
1226         (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
1227         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
1228         (WebKit::RemoteScrollingCoordinatorProxy::applyScrollingTreeLayerPositions):
1229         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
1230         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
1231         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
1232
1233 2019-03-09  Darin Adler  <darin@apple.com>
1234
1235         [Cocoa] Code signing fails because services are copied into XPCServices after the framework is signed
1236         https://bugs.webkit.org/show_bug.cgi?id=195523
1237
1238         Reviewed by Dan Bernstein.
1239
1240         * WebKit.xcodeproj/project.pbxproj: Make symbolic links while building the WebKit
1241         framework instead of copying in the services after the framework is built.
1242
1243 2019-03-09  Wenson Hsieh  <wenson_hsieh@apple.com>
1244
1245         REGRESSION (r242551): Sporadic hangs when tapping to change selection on iOS
1246         https://bugs.webkit.org/show_bug.cgi?id=195475
1247         <rdar://problem/48721153>
1248
1249         Reviewed by Chris Dumez.
1250
1251         r242551 refactored synchronous autocorrection context requests to send an async IPC message and then use
1252         waitForAndDispatchImmediately, instead of calling sendSync. However, this exposes a couple of existing issues in
1253         the implementation of waitForAndDispatchImmediately that causes sporadic IPC deadlocks when changing selection.
1254
1255         First, passing in InterruptWaitingIfSyncMessageArrives when synchronously waiting for an IPC message currently
1256         does not fulfill its intended behavior of interrupting waiting when a sync message arrives. This is because sync
1257         IPC messages, by default, may be dispatched while the receiver is waiting for a sync reply. This means that the
1258         logic in Connection::SyncMessageState::processIncomingMessage to dispatch an incoming sync message on the main
1259         thread will attempt to handle the incoming message by enqueueing it on the main thread, and then waking up the
1260         client runloop (i.e. signaling m_waitForSyncReplySemaphore). This works in the case of sendSync since the sync
1261         reply semaphore is used to block the main thread, but in the case of waitForAndDispatchImmediately, a different
1262         m_waitForMessageCondition is used instead, so SyncMessageState::processIncomingMessage will only enqueue the
1263         incoming sync message on the main thread, and not actually invoke it.
1264
1265         To fix this first issue, observe that there is pre-existing logic to enqueue the incoming message and signal
1266         m_waitForMessageCondition in Connection::processIncomingMessage. This codepath is currently not taken because we
1267         end up bailing early in the call to SyncMessageState::processIncomingMessage. Instead, we can move this early
1268         return further down in the function, such that if there is an incoming sync message and we're waiting with the
1269         InterruptWaitingIfSyncMessageArrives option, we will correctly enqueue the incoming message, wake the runloop,
1270         and proceed to handle the incoming message.
1271
1272         The second issue is more subtle; consider the scenario in which we send a sync message A from the web process to
1273         the UI process, and simultaneously, in the UI process, we schedule some work to be done on the main thread.
1274         Let's additionally suppose that this scheduled work will send an IPC message B to the web process and
1275         synchronously wait for a reply (in the case of this particular bug, this is the sync autocorrection context
1276         request). What happens upon receiving sync message A is that the IPC thread in the UI process will schedule A on
1277         the main thread; however, before the scheduled response to A is invoked, we will first invoke previously
1278         scheduled work that attempts to block synchronously until a message B is received. In summary:
1279
1280         1. (Web process)    sends sync IPC message A to UI process.
1281         2. (UI process)     schedules some main runloop task that will block synchronously on IPC message B.
1282         3. (UI process)     receives sync IPC message A and schedules A on the main runloop.
1283         4. (UI process)     carry out the task scheduled in (2) and block on B.
1284
1285         ...and then, the UI process and web process are now deadlocked because the UI process is waiting for B to
1286         arrive, but the web process can't send B because it's waiting for a reply for IPC message A! To fix this second
1287         deadlock, we first make an important observation: when using sendSync, we don't run into this problem because
1288         immediately before sending sync IPC, we will attempt to handle any incoming sync IPC messages that have been
1289         queued up. However, when calling waitForAndDispatchImmediately, we don't have this extra step, so a deadlock may
1290         occur in the manner described above. To fix this, we make waitForAndDispatchImmediately behave more like
1291         sendSync, by handling all incoming sync messages prior to blocking on an IPC response.
1292
1293         Test: editing/selection/ios/change-selection-by-tapping.html
1294
1295         * Platform/IPC/Connection.cpp:
1296         (IPC::Connection::waitForMessage):
1297         (IPC::Connection::processIncomingMessage):
1298
1299 2019-03-09  Andy Estes  <aestes@apple.com>
1300
1301         [Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages
1302         https://bugs.webkit.org/show_bug.cgi?id=195526
1303         <rdar://problem/48745636>
1304
1305         Reviewed by Chris Dumez.
1306
1307         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
1308         (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard):
1309         (WebKit::WebPaymentCoordinatorProxy::openPaymentSetup):
1310         * Shared/ApplePay/WebPaymentCoordinatorProxy.h:
1311         * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in:
1312         * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
1313         (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard):
1314         (WebKit::WebPaymentCoordinator::openPaymentSetup):
1315         (WebKit::generateCanMakePaymentsWithActiveCardReplyID): Deleted.
1316         (WebKit::generateOpenPaymentSetupReplyID): Deleted.
1317         (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCardReply): Deleted.
1318         (WebKit::WebPaymentCoordinator::openPaymentSetupReply): Deleted.
1319         * WebProcess/ApplePay/WebPaymentCoordinator.h:
1320         * WebProcess/ApplePay/WebPaymentCoordinator.messages.in:
1321
1322 2019-03-09  Andy Estes  <aestes@apple.com>
1323
1324         [iOS] Remove unneeded entitlements and sandbox allowances from the Networking service
1325         https://bugs.webkit.org/show_bug.cgi?id=195527
1326
1327         Reviewed by Eric Carlson.
1328
1329         * Configurations/Network-iOS.entitlements:
1330         * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb:
1331
1332 2019-03-09  Chris Dumez  <cdumez@apple.com>
1333
1334         Use modern async IPC with reply for device orientation permission
1335         https://bugs.webkit.org/show_bug.cgi?id=195529
1336
1337         Reviewed by Ryosuke Niwa.
1338
1339         * UIProcess/WebPageProxy.cpp:
1340         (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
1341         * UIProcess/WebPageProxy.h:
1342         * UIProcess/WebPageProxy.messages.in:
1343         * WebProcess/WebPage/WebPage.cpp:
1344         (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
1345         (WebKit::nextDeviceOrientationAndMotionPermissionCallbackID): Deleted.
1346         (WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision): Deleted.
1347         * WebProcess/WebPage/WebPage.h:
1348         * WebProcess/WebPage/WebPage.messages.in:
1349
1350 2019-03-09  Zalan Bujtas  <zalan@apple.com>
1351
1352         [ContentChangeObserver] Start observing for content change between touchEnd and mouseMoved start
1353         https://bugs.webkit.org/show_bug.cgi?id=195510
1354         <rdar://problem/48735695>
1355
1356         Reviewed by Simon Fraser.
1357
1358         * WebProcess/WebPage/ios/WebPageIOS.mm:
1359         (WebKit::WebPage::cancelPotentialTapInFrame):
1360
1361 2019-03-08  Chris Dumez  <cdumez@apple.com>
1362
1363         Enable ProcessAssertions on iOS Simulator
1364         https://bugs.webkit.org/show_bug.cgi?id=195479
1365
1366         Reviewed by Alexey Proskuryakov.
1367
1368         Enable ProcessAssertions on iOS Simulator. We have some layout tests timing out in the
1369         iOS Simulator due to the WebContent process suspending. Turning on ProcessAssertions in
1370         the iOS Simulator seems to make those tests pass.
1371
1372         * UIProcess/ProcessAssertion.cpp:
1373         * UIProcess/ProcessAssertion.h:
1374         * UIProcess/ios/ProcessAssertionIOS.mm:
1375
1376 2019-03-08  Chris Dumez  <cdumez@apple.com>
1377
1378         Add support for Device Orientation / Motion permission API
1379         https://bugs.webkit.org/show_bug.cgi?id=195329
1380         <rdar://problem/47645367>
1381
1382         Reviewed by Geoffrey Garen.
1383
1384         Add support for Device Orientation / Motion permission API:
1385         - https://github.com/w3c/deviceorientation/issues/57
1386
1387         This adds new SPI to WKUIDelegatePrivate, until we can make this API.
1388
1389         * Shared/WebPreferences.yaml:
1390         * UIProcess/API/APIUIClient.h:
1391         (API::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
1392         * UIProcess/API/C/WKPage.cpp:
1393         (WKPageSetPageUIClient):
1394         * UIProcess/API/C/WKPageUIClient.h:
1395         * UIProcess/API/Cocoa/WKUIDelegate.h:
1396         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
1397         * UIProcess/Cocoa/UIDelegate.h:
1398         * UIProcess/Cocoa/UIDelegate.mm:
1399         (WebKit::UIDelegate::setDelegate):
1400         (WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
1401         * UIProcess/WebPageProxy.cpp:
1402         (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
1403         * UIProcess/WebPageProxy.h:
1404         * UIProcess/WebPageProxy.messages.in:
1405         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
1406         (WebKit::WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess):
1407         * WebProcess/WebCoreSupport/WebChromeClient.h:
1408         * WebProcess/WebPage/WebPage.cpp:
1409         (WebKit::nextDeviceOrientationAndMotionPermissionCallbackID):
1410         (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
1411         (WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision):
1412         * WebProcess/WebPage/WebPage.h:
1413         * WebProcess/WebPage/WebPage.messages.in:
1414
1415 2019-03-08  Brady Eidson  <beidson@apple.com>
1416
1417         Have the UIProcess take the UnboundedNetworking assertion when downloads are in progress.
1418         https://bugs.webkit.org/show_bug.cgi?id=195468
1419
1420         Reviewed by Andy Estes.
1421
1422         * UIProcess/Downloads/DownloadProxyMap.cpp:
1423         (WebKit::DownloadProxyMap::DownloadProxyMap):
1424         (WebKit::DownloadProxyMap::createDownloadProxy): If this is the first download, and the process has the entitlement,
1425           take the assertion.
1426         (WebKit::DownloadProxyMap::downloadFinished):
1427         (WebKit::DownloadProxyMap::processDidClose):
1428         * UIProcess/Downloads/DownloadProxyMap.h:
1429
1430 2019-03-08  Chris Dumez  <cdumez@apple.com>
1431
1432         Add assertions to help debug a WebProcessCache crash
1433         https://bugs.webkit.org/show_bug.cgi?id=195469
1434
1435         Reviewed by Brady Eidson.
1436
1437         I suspect the process's registrableDomain in null when evictProcess() gets
1438         called, thus crashing when lookup it up in the HashMap. Confirm this and
1439         how this could happen via assertions.
1440
1441         * UIProcess/WebProcessCache.cpp:
1442         (WebKit::WebProcessCache::evictProcess):
1443         * UIProcess/WebProcessProxy.cpp:
1444         (WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame):
1445
1446 2019-03-08  Brady Eidson  <beidson@apple.com>
1447
1448         Rename AssertionState::Download.
1449         https://bugs.webkit.org/show_bug.cgi?id=195465
1450
1451         Reviewed by Andy Estes.
1452
1453         It's (currently) about uploads and downloads.
1454         Let's call it "UnboundedNetworking"
1455
1456         * NetworkProcess/Downloads/DownloadMap.cpp:
1457         (WebKit::DownloadMap::add):
1458
1459         * UIProcess/ProcessAssertion.h:
1460
1461         * UIProcess/WebProcessProxy.cpp:
1462         (WebKit::WebProcessProxy::didSetAssertionState):
1463
1464         * UIProcess/ios/ProcessAssertionIOS.mm:
1465         (WebKit::flagsForState):
1466         (WebKit::reasonForState):
1467
1468 2019-03-08  Simon Fraser  <simon.fraser@apple.com>
1469
1470         [macOS UI-side compositing] Mouse handling can trigger a crash before we have a scrolling tree root
1471         https://bugs.webkit.org/show_bug.cgi?id=195467
1472
1473         Reviewed by Antti Koivisto.
1474         
1475         When launching MiniBrowser with UI-side compositing enabled in a state where the window
1476         appears under the mouse, we can hit RemoteScrollingTree::handleMouseEvent() for a mouseEnter
1477         event before we have a scrolling tree root node, so add a null check.
1478
1479         * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
1480         (WebKit::RemoteScrollingTree::handleMouseEvent):
1481
1482 2019-03-08  Carlos Garcia Campos  <cgarcia@igalia.com>
1483
1484         REGRESSION(r242624): [GTK] New rAF code path assumes AC mode
1485         https://bugs.webkit.org/show_bug.cgi?id=195459
1486
1487         Reviewed by Žan Doberšek.
1488
1489         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
1490         (WebKit::DrawingAreaCoordinatedGraphics::scheduleCompositingLayerFlush):
1491         The refresh monitor now calls scheduleLayerFlush() but when AC
1492         mode is disabled this method does nothing, so setNeedsDisplay()
1493         needs to be called instead.
1494
1495 2019-03-07  Tim Horton  <timothy_horton@apple.com>
1496
1497         Crash under RemoteLayerTreePropertyApplier::applyProperties
1498         https://bugs.webkit.org/show_bug.cgi?id=195448
1499         <rdar://problem/48588226>
1500
1501         Reviewed by Simon Fraser.
1502
1503         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
1504         (WebKit::RemoteLayerTreeHost::updateLayerTree):
1505         Under some currently-unknown circumstances, the UI process is receiving
1506         commits referring to layers that it does not know about.
1507         One understood case of this was fixed in r241899, but there seem to be
1508         cases remaining that are not understood.
1509         Also, add a release log so that we can identify any downstream effects.
1510
1511 2019-03-07  Zalan Bujtas  <zalan@apple.com>
1512
1513         [ContentChangeObserver] Introduce fixed duration content observation
1514         https://bugs.webkit.org/show_bug.cgi?id=195295
1515         <rdar://problem/48579913>
1516
1517         Reviewed by Simon Fraser.
1518
1519         * WebProcess/WebPage/ios/WebPageIOS.mm:
1520         (WebKit::WebPage::handleSyntheticClick):
1521         (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
1522
1523 2019-03-07  Fujii Hironori  <Hironori.Fujii@sony.com>
1524
1525         [WinCairo][WebKit] Nothing is drawn after Web process crashed
1526         https://bugs.webkit.org/show_bug.cgi?id=195399
1527
1528         Reviewed by Alex Christensen.
1529
1530         PageClientImpl::viewSize returned 0x0 size after Web process
1531         crashed. Restored the original implementation using GetClientRect
1532         (Bug 52175).
1533
1534         * UIProcess/win/PageClientImpl.cpp:
1535         (WebKit::PageClientImpl::viewSize):
1536
1537 2019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
1538
1539         requestAnimationFrame should execute before the next frame
1540         https://bugs.webkit.org/show_bug.cgi?id=177484
1541
1542         Reviewed by Simon Fraser.
1543
1544         Replace the calls to Page::layoutIfNeeded() and willDisplayPage() by
1545         a single call to Page::renderingUpdate(). This new function implements 
1546         "Update the rendering" step of the HTML Event Loop specification
1547         <https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>.
1548
1549         * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
1550         (WebKit::AcceleratedDrawingArea::updateBackingStoreState):
1551         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
1552         (WebKit::LayerTreeHost::layerFlushTimerFired):
1553         * WebProcess/WebPage/DrawingAreaImpl.cpp:
1554         (WebKit::DrawingAreaImpl::display):
1555         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
1556         (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
1557         * WebProcess/WebPage/WebPage.cpp:
1558         (WebKit::WebPage::layoutIfNeeded):
1559         (WebKit::WebPage::renderingUpdate):
1560         (WebKit::WebPage::willDisplayPage): Deleted.
1561         * WebProcess/WebPage/WebPage.h:
1562         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
1563         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
1564
1565 2019-03-07  Zalan Bujtas  <zalan@apple.com>
1566
1567         [ContentChangeObserver] Add a setting to be able to turn content change observation on/off
1568         https://bugs.webkit.org/show_bug.cgi?id=195353
1569         <rdar://problem/48626394>
1570
1571         Reviewed by Simon Fraser.
1572
1573         * Shared/WebPreferences.yaml:
1574         * UIProcess/API/C/WKPreferences.cpp:
1575         (WKPreferencesSetContentChangeObserverEnabled):
1576         (WKPreferencesGetContentChangeObserverEnabled):
1577         * UIProcess/API/C/WKPreferencesRefPrivate.h:
1578         * UIProcess/API/Cocoa/WKPreferences.mm:
1579         (-[WKPreferences _contentChangeObserverEnabled]):
1580         (-[WKPreferences _setContentChangeObserverEnabled:]):
1581         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
1582         * WebProcess/WebPage/ios/WebPageIOS.mm:
1583         (WebKit::WebPage::handleSyntheticClick):
1584
1585 2019-03-07  Andy Estes  <aestes@apple.com>
1586
1587         [Apple Pay] Untangle PKPaymentAuthorizationViewController from WebPaymentCoordinatorProxy
1588         https://bugs.webkit.org/show_bug.cgi?id=195349
1589         <rdar://problem/48625510>
1590
1591         Reviewed by Alex Christensen.
1592
1593         Introduced PaymentAuthorizationPresenter and WKPaymentAuthorizationDelegate to encapsulate
1594         PKPaymentAuthorizationViewController and its delegate. Taught WebPaymentCoordinatorProxy to
1595         interact with PaymentAuthorizationPresenter rather than PKPAVC directly.
1596
1597         These changes will allow us to swap out PKPaymentAuthorizationViewController with PKPaymentAuthorizationController in a follow-on patch.
1598
1599         * Platform/cocoa/PaymentAuthorizationPresenter.h: Added. Defined the abstract interface for
1600         payment authorization presenters that use PKPA(V)C.
1601         * Platform/cocoa/PaymentAuthorizationPresenter.mm: Added.
1602         (WebKit::toPKPaymentAuthorizationStatus): Moved from WebPaymentCoordinatorProxyCocoa.mm.
1603         (WebKit::toPKPaymentErrorCode): Ditto.
1604         (WebKit::toNSError): Ditto.
1605         (WebKit::toNSErrors): Ditto.
1606         (WebKit::toPKShippingMethods): Ditto.
1607         (WebKit::PaymentAuthorizationPresenter::completeMerchantValidation): Added. Implements the
1608         logic previously in WebPaymentCoordinatorProxy::platformCompleteMerchantValidation.
1609         (WebKit::PaymentAuthorizationPresenter::completePaymentMethodSelection): Ditto for
1610         WebPaymentCoordinatorProxy::platformCompletePaymentMethodSelection.
1611         (WebKit::PaymentAuthorizationPresenter::completePaymentSession): Ditto for 
1612         (WebKit::PaymentAuthorizationPresenter::completeShippingContactSelection): Ditto for
1613         WebPaymentCoordinatorProxy::platformCompletePaymentSession.
1614         (WebKit::PaymentAuthorizationPresenter::completeShippingMethodSelection): Ditto for
1615         WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection.
1616         * Platform/cocoa/PaymentAuthorizationViewController.h: Added. Defined a subclass of PaymentAuthorizationPresenter for PKPaymentAuthorizationViewController.
1617         * Platform/cocoa/PaymentAuthorizationViewController.mm: Added.
1618         (-[WKPaymentAuthorizationViewControllerDelegate initWithPresenter:]): Added a PKPAVC
1619         delegate that's a subclass of WKPaymentAuthorizationDelegate.
1620         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewControllerDidFinish:]):
1621         Called -[WKPaymentAuthorizationDelegate _didFinish].
1622         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:handler:]): Called
1623         -[WKPaymentAuthorizationDelegate _didAuthorizePayment:completion:].
1624         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:handler:]): Called
1625         -[WKPaymentAuthorizationDelegate _didSelectShippingMethod:completion:].
1626         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:handler:]): Called
1627         -[WKPaymentAuthorizationDelegate _didSelectShippingContact:completion:].
1628         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:handler:]): Called
1629         -[WKPaymentAuthorizationDelegate _didSelectPaymentMethod:completion:].
1630         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:willFinishWithError:]):
1631         Called -[WKPaymentAuthorizationDelegate _willFinishWithError:].
1632         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didRequestMerchantSession:]): Called
1633         -[WKPaymentAuthorizationDelegate _didRequestMerchantSession:].
1634         * Platform/cocoa/WKPaymentAuthorizationDelegate.h: Added.
1635         * Platform/cocoa/WKPaymentAuthorizationDelegate.mm: Added.
1636         (-[WKPaymentAuthorizationDelegate summaryItems]): Added a summaryItems getter.
1637         (-[WKPaymentAuthorizationDelegate shippingMethods]): Ditto for shippingMethods.
1638         (-[WKPaymentAuthorizationDelegate completeMerchantValidation:error:]): Called
1639         _didRequestMerchantSessionCompletion then set it to nil.
1640         (-[WKPaymentAuthorizationDelegate completePaymentMethodSelection:]): Ditto for
1641         _didSelectPaymentMethodCompletion.
1642         (-[WKPaymentAuthorizationDelegate completePaymentSession:errors:didReachFinalState:]): Ditto
1643         for _didAuthorizePaymentCompletion.
1644         (-[WKPaymentAuthorizationDelegate completeShippingContactSelection:summaryItems:shippingMethods:errors:]):
1645         Ditto for _didSelectShippingContactCompletion.
1646         (-[WKPaymentAuthorizationDelegate completeShippingMethodSelection:]): Ditto for
1647         _didSelectShippingMethodCompletion.
1648         (-[WKPaymentAuthorizationDelegate invalidate]): If there's an outstanding authorization
1649         callback, called -completePaymentSession:errors:didReachFinalState: with a state of
1650         PKPaymentAuthorizationStatusFailure.
1651         (-[WKPaymentAuthorizationDelegate _initWithPresenter:]):
1652         (-[WKPaymentAuthorizationDelegate _didAuthorizePayment:completion:]): Added. Implements the
1653         logic previously in WKPaymentAuthorizationViewControllerDelegate.
1654         (-[WKPaymentAuthorizationDelegate _didFinish]): Ditto.
1655         (-[WKPaymentAuthorizationDelegate _didRequestMerchantSession:]): Ditto.
1656         (-[WKPaymentAuthorizationDelegate _didSelectPaymentMethod:completion:]): Ditto.
1657         (-[WKPaymentAuthorizationDelegate _didSelectShippingContact:completion:]): Ditto.
1658         (toShippingMethod): Moved from WebPaymentCoordinatorProxyCocoa.mm.
1659         (-[WKPaymentAuthorizationDelegate _didSelectShippingMethod:completion:]): Added. Implements
1660         the logic previously in WKPaymentAuthorizationViewControllerDelegate.
1661         (-[WKPaymentAuthorizationDelegate _willFinishWithError:]): Ditto.
1662         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
1663         (WebKit::WebPaymentCoordinatorProxy::presenterWillValidateMerchant): To conform to
1664         PaymentAuthorizationPresenter::Client, renamed from validateMerchant.
1665         (WebKit::WebPaymentCoordinatorProxy::presenterDidAuthorizePayment): Renamed from
1666         didAuthorizePayment.
1667         (WebKit::WebPaymentCoordinatorProxy::presenterDidFinish): Moved logic here that previously
1668         existed in WKPaymentAuthorizationViewControllerDelegate.
1669         (WebKit::WebPaymentCoordinatorProxy::presenterDidSelectShippingMethod): Renamed from
1670         didSelectShippingMethod.
1671         (WebKit::WebPaymentCoordinatorProxy::presenterDidSelectShippingContact): Renamed from
1672         didSelectShippingContact.
1673         (WebKit::WebPaymentCoordinatorProxy::presenterDidSelectPaymentMethod): Renamed from
1674         didSelectPaymentMethod.
1675         (WebKit::WebPaymentCoordinatorProxy::validateMerchant): Renamed to
1676         presenterWillValidateMerchant.
1677         (WebKit::WebPaymentCoordinatorProxy::didAuthorizePayment): Renamed to
1678         presenterDidAuthorizePayment.
1679         (WebKit::WebPaymentCoordinatorProxy::didSelectShippingMethod): Renamed to
1680         presenterDidSelectShippingMethod.
1681         (WebKit::WebPaymentCoordinatorProxy::didSelectShippingContact): Renamed to
1682         presenterDidSelectShippingContact.
1683         (WebKit::WebPaymentCoordinatorProxy::didSelectPaymentMethod): Renamed to
1684         didSelectPaymentMethod.
1685         * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Changed WebPaymentCoordinatorProxy to
1686         subclass PaymentAuthorizationPresenter::Client.
1687         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h: Removed WKPaymentAuthorizationViewControllerDelegate interface and declared some helper functions
1688         needed by PaymentAuthorizationPresenter.
1689         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
1690         (WebKit::toPKPaymentSummaryItemType): Removed static keyword.
1691         (WebKit::toDecimalNumber): Ditto.
1692         (WebKit::toPKPaymentSummaryItem): Ditto.
1693         (WebKit::toPKPaymentSummaryItems): Ditto.
1694         (WebKit::toPKShippingMethod): Ditto.
1695         (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Changed to call
1696         m_authorizationPresenter.
1697         (WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentSession): Ditto.
1698         (WebKit::WebPaymentCoordinatorProxy::platformCompleteMerchantValidation): Ditto.
1699         (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection): Ditto.
1700         (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingContactSelection): Ditto.
1701         (WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentMethodSelection): Ditto.
1702         (-[WKPaymentAuthorizationViewControllerDelegate initWithPaymentCoordinatorProxy:]): Deleted.
1703         (-[WKPaymentAuthorizationViewControllerDelegate invalidate]): Deleted.
1704         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:willFinishWithError:]): Deleted.
1705         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didRequestMerchantSession:]): Deleted.
1706         (toShippingMethod): Deleted.
1707         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:handler:]): Deleted.
1708         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:handler:]): Deleted.
1709         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:handler:]): Deleted.
1710         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:handler:]): Deleted.
1711         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:completion:]): Deleted.
1712         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:completion:]): Deleted.
1713         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:completion:]): Deleted.
1714         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:completion:]): Deleted.
1715         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewControllerDidFinish:]): Deleted.
1716         (WebKit::toPKPaymentAuthorizationStatus): Moved to PaymentAuthorizationPresenter.mm.
1717         (WebKit::toPKPaymentErrorCode): Ditto.
1718         (WebKit::toNSError): Ditto.
1719         (WebKit::toNSErrors): Ditto.
1720         * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
1721         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Changed to present a
1722         PaymentAuthorizationPresenter rather than a PKPAVC.
1723         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Changed to dismiss a
1724         PaymentAuthorizationPresenter rather than a PKPAVC.
1725         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
1726         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Ditto.
1727         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Ditto.
1728         * SourcesCocoa.txt:
1729         * UIProcess/WebPageProxy.h:
1730         * UIProcess/ios/WebPageProxyIOS.mm:
1731         (WebKit::WebPageProxy::paymentCoordinatorAuthorizationPresenter): Added. Returns a new
1732         PaymentAuthorizationViewController.
1733         * WebKit.xcodeproj/project.pbxproj:
1734
1735 2019-03-07  Chris Dumez  <cdumez@apple.com>
1736
1737         Regression(r242580) WebKit.NetworkProcessCrashWithPendingConnection API is crashing on iOS debug
1738         https://bugs.webkit.org/show_bug.cgi?id=195416
1739
1740         Reviewed by Antti Koivisto.
1741
1742         Drop ASSERT_NOT_REACHED() in WebPage::didCompletePageTransition() when the tree is still frozen due to
1743         LayerTreeFreezeReason::ProcessSuspended. As demonstrated by this API test, nothing prevents a load from
1744         completing and WebPage::didCompletePageTransition() to get called *after* WebProcess::prepareToSuspend()
1745         has been called. From the logging during the test, I can tell that WebProcess::processDidResume() gets
1746         called later on and the LayerTreeFreezeReason::ProcessSuspended freezing reason gets dropped, as expected.
1747
1748         * WebProcess/WebPage/WebPage.cpp:
1749         (WebKit::WebPage::didCompletePageTransition):
1750
1751 2019-03-07  Chris Dumez  <cdumez@apple.com>
1752
1753         Clean up / simplify ProcessAssertion code
1754         https://bugs.webkit.org/show_bug.cgi?id=195394
1755
1756         Reviewed by Geoffrey Garen.
1757
1758         Clean up / simplify ProcessAssertion code to facilitate its maintenance and make it
1759         less error-prone.
1760
1761         * Platform/IPC/mac/ConnectionMac.mm:
1762         (IPC::ConnectionTerminationWatchdog::ConnectionTerminationWatchdog):
1763         * UIProcess/ProcessAssertion.cpp:
1764         (WebKit::ProcessAssertion::ProcessAssertion):
1765         (WebKit::ProcessAssertion::setState):
1766         * UIProcess/ProcessAssertion.h:
1767         (WebKit::ProcessAssertion::Client::~Client):
1768         (WebKit::ProcessAssertion::setClient):
1769         (WebKit::ProcessAssertion::client):
1770         * UIProcess/ProcessThrottler.cpp:
1771         (WebKit::ProcessThrottler::didConnectToProcess):
1772         * UIProcess/ProcessThrottler.h:
1773         * UIProcess/ios/ProcessAssertionIOS.mm:
1774         (-[WKProcessAssertionBackgroundTaskManager dealloc]):
1775         (-[WKProcessAssertionBackgroundTaskManager addAssertionNeedingBackgroundTask:]):
1776         (-[WKProcessAssertionBackgroundTaskManager removeAssertionNeedingBackgroundTask:]):
1777         (-[WKProcessAssertionBackgroundTaskManager _notifyAssertionsOfImminentSuspension]):
1778         (-[WKProcessAssertionBackgroundTaskManager _releaseBackgroundTask]):
1779         (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]):
1780         (WebKit::ProcessAssertion::ProcessAssertion):
1781         (WebKit::ProcessAssertion::processAssertionWasInvalidated):
1782         (WebKit::ProcessAssertion::setState):
1783         (WebKit::ProcessAndUIAssertion::updateRunInBackgroundCount):
1784         (WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion):
1785         (WebKit::ProcessAndUIAssertion::~ProcessAndUIAssertion):
1786         (WebKit::ProcessAndUIAssertion::processAssertionWasInvalidated):
1787         (WebKit::ProcessAndUIAssertion::setState):
1788         (WebKit::ProcessAndUIAssertion::uiAssertionWillExpireImminently):
1789
1790 2019-03-07  Commit Queue  <commit-queue@webkit.org>
1791
1792         Unreviewed, rolling out r242297.
1793         https://bugs.webkit.org/show_bug.cgi?id=195430
1794
1795         Broke Microsoft Visio. (Requested by dydz on #webkit).
1796
1797         Reverted changeset:
1798
1799         "[iOS] Turn mouse event simulation on by default"
1800         https://bugs.webkit.org/show_bug.cgi?id=195218
1801         https://trac.webkit.org/changeset/242297
1802
1803 2019-03-07  John Wilander  <wilander@apple.com>
1804
1805         Resource Load Statistics: Log first-party navigations with link decoration
1806         https://bugs.webkit.org/show_bug.cgi?id=195301
1807         <rdar://problem/48569971>
1808
1809         Reviewed by Brent Fulgham.
1810
1811         This patch adds a call to the network process' resource load statistics to
1812         log cross-site navigations with link decoration. The logging checks if the
1813         source of the navigation is a prevalent resource and if so, sets the
1814         appropriate flag for the destination.
1815
1816         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
1817         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
1818         (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
1819         (WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceRedirect):
1820         (WebKit::ResourceLoadStatisticsDatabaseStore::logCrossSiteLoadWithLinkDecoration):
1821         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
1822         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
1823         (WebKit::ResourceLoadStatisticsMemoryStore::logCrossSiteLoadWithLinkDecoration):
1824         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
1825         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
1826         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1827         (WebKit::WebResourceLoadStatisticsStore::logCrossSiteLoadWithLinkDecoration):
1828         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
1829         * NetworkProcess/NetworkProcess.cpp:
1830         (WebKit::NetworkProcess::committedCrossSiteLoadWithLinkDecoration):
1831             This now receives a completion handler. This is in preparation for
1832             test cases where we need to log such an event and wait for it to
1833             finish before continuing.
1834         * NetworkProcess/NetworkProcess.h:
1835         * NetworkProcess/NetworkProcess.messages.in:
1836         * UIProcess/Network/NetworkProcessProxy.cpp:
1837         (WebKit::NetworkProcessProxy::committedCrossSiteLoadWithLinkDecoration):
1838         * UIProcess/Network/NetworkProcessProxy.h:
1839         * UIProcess/WebPageProxy.cpp:
1840         (WebKit::WebPageProxy::didCommitLoadForFrame):
1841         * UIProcess/WebProcessPool.cpp:
1842         (WebKit::WebProcessPool::committedCrossSiteLoadWithLinkDecoration):
1843         * UIProcess/WebProcessPool.h:
1844
1845 2019-03-07  Per Arne Vollan  <pvollan@apple.com>
1846
1847         [iOS] Disable permissive call logging in sandbox
1848         https://bugs.webkit.org/show_bug.cgi?id=195288
1849         <rdar://problem/47683804>
1850
1851         Reviewed by Brent Fulgham.
1852
1853         As on macOS, we should enable strict call filtering in sandbox on iOS.
1854
1855         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
1856
1857 2019-03-07  Youenn Fablet  <youenn@apple.com>
1858
1859         Introduce a quota manager for Cache API/Service Worker/IDB storage
1860         https://bugs.webkit.org/show_bug.cgi?id=195283
1861
1862         Reviewed by Chris Dumez.
1863
1864         Remove quota handling from Cache API storage and use StorageQuotaManager/StorageQuotaUser.
1865         CacheStorage::Caches becomes a quota user and has a StorageQuotaManager to check for space for any cache API write task.
1866         NetworkProcess is responsible to manage the quota managers.
1867         Quota managers will go through network process to ask UIProcess for quota extension.
1868
1869         Remove pending callback handling from CacheStorage since they are queued in QuotaManager now.
1870
1871         * NetworkProcess/NetworkProcess.cpp:
1872         (WebKit::NetworkProcess::~NetworkProcess):
1873         (WebKit::NetworkProcess::destroySession):
1874         (WebKit::NetworkProcess::cacheStorageRootPath):
1875         (WebKit::NetworkProcess::setCacheStorageParameters):
1876         (WebKit::NetworkProcess::storageQuotaManager):
1877         * NetworkProcess/NetworkProcess.h:
1878         * NetworkProcess/cache/CacheStorageEngine.cpp:
1879         (WebKit::CacheStorage::Engine::from):
1880         (WebKit::CacheStorage::Engine::Engine):
1881         (WebKit::CacheStorage::Engine::readCachesFromDisk):
1882         * NetworkProcess/cache/CacheStorageEngine.h:
1883         * NetworkProcess/cache/CacheStorageEngineCache.cpp:
1884         (WebKit::CacheStorage::Cache::put):
1885         * NetworkProcess/cache/CacheStorageEngineCache.h:
1886         * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
1887         (WebKit::CacheStorage::Caches::Caches):
1888         (WebKit::CacheStorage::Caches::~Caches):
1889         (WebKit::CacheStorage::Caches::requestSpace):
1890         (WebKit::CacheStorage::Caches::writeRecord):
1891         * NetworkProcess/cache/CacheStorageEngineCaches.h:
1892
1893 2019-03-07  John Wilander  <wilander@apple.com>
1894
1895         Resource Load Statistics: Make it possible to purge only script-accessible cookies
1896         https://bugs.webkit.org/show_bug.cgi?id=195383
1897         <rdar://problem/48570136>
1898
1899         Reviewed by Brent Fulgham.
1900
1901         This patch provides the ability to purge all script-accessible cookies while leaving
1902         HttpOnly cookies in place.
1903
1904         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
1905         (WebKit::ResourceLoadStatisticsStore::removeDataRecords):
1906         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1907         (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores):
1908             Support for a new boolean flag on whether or not to include HttpOnly Cookies.
1909         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
1910         * NetworkProcess/NetworkProcess.cpp:
1911         (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores):
1912             Support for a new boolean flag on whether or not to include HttpOnly Cookies.
1913         (WebKit::NetworkProcess::deleteCookiesForTesting):
1914             Test infrastructure.
1915         * NetworkProcess/NetworkProcess.h:
1916         * NetworkProcess/NetworkProcess.messages.in:
1917         * NetworkProcess/NetworkSession.cpp:
1918         (WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores):
1919             Support for a new boolean flag on whether or not to include HttpOnly Cookies.
1920         * NetworkProcess/NetworkSession.h:
1921         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
1922         (WKWebsiteDataStoreStatisticsDeleteCookiesForTesting):
1923             Test infrastructure.
1924         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
1925         * UIProcess/Network/NetworkProcessProxy.cpp:
1926         (WebKit::NetworkProcessProxy::deleteCookiesForTesting):
1927             Test infrastructure.
1928         * UIProcess/Network/NetworkProcessProxy.h:
1929         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1930         (WebKit::WebsiteDataStore::deleteCookiesForTesting):
1931             Test infrastructure.
1932         * UIProcess/WebsiteData/WebsiteDataStore.h:
1933
1934 2019-03-07  Carlos Garcia Campos  <cgarcia@igalia.com>
1935
1936         REGRESSION(r242364): [WPE] Do not stop the compositing run loop update timer on suspend
1937         https://bugs.webkit.org/show_bug.cgi?id=195410
1938
1939         Reviewed by Žan Doberšek.
1940
1941         Calling CompositingRunLoop::stopUpdates() on suspend is leaving the threaded compositor in an inconsistent
1942         state, failing to resume and stopping the updates forever. This is causing timeouts in WPE layout tests. Instead
1943         of calling stopUpdates(), a new suspend() is called, that stops the update timer, without changing the current
1944         updae tha compositing state. A new method resume() is also added to schedule an update if needed.
1945
1946         * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
1947         (WebKit::CompositingRunLoop::suspend): Set state as suspended and stop the update timer.
1948         (WebKit::CompositingRunLoop::resume): Set state as not suspended and start the update timer if it was scheduled
1949         while suspended.
1950         (WebKit::CompositingRunLoop::scheduleUpdate): Do not start the update timer when suspended.
1951         (WebKit::CompositingRunLoop::compositionCompleted): Ditto.
1952         (WebKit::CompositingRunLoop::updateCompleted): Ditto.
1953         (WebKit::CompositingRunLoop::updateTimerFired): Add an assert to ensure the update timer is not fired while suspended.
1954         * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
1955         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
1956         (WebKit::ThreadedCompositor::suspend): Call CompositingRunLoop::suspend() instead of stopUpdates().
1957         (WebKit::ThreadedCompositor::resume): Call CompositingRunLoop::resume().
1958
1959 2019-03-06  Mark Lam  <mark.lam@apple.com>
1960
1961         Exception is a JSCell, not a JSObject.
1962         https://bugs.webkit.org/show_bug.cgi?id=195392
1963
1964         Reviewed by Saam Barati.
1965
1966         * WebProcess/Plugins/Netscape/JSNPObject.cpp:
1967         (WebKit::JSNPObject::throwInvalidAccessError):
1968         * WebProcess/Plugins/Netscape/JSNPObject.h:
1969
1970 2019-03-07  Commit Queue  <commit-queue@webkit.org>
1971
1972         Unreviewed, rolling out r242354.
1973         https://bugs.webkit.org/show_bug.cgi?id=195402
1974
1975         breaks layout tests in all configurations (Requested by
1976         zdobersek on #webkit).
1977
1978         Reverted changeset:
1979
1980         "[WPE] Enable web process sandbox"
1981         https://bugs.webkit.org/show_bug.cgi?id=195169
1982         https://trac.webkit.org/changeset/242354
1983
1984 2019-03-06  Ross Kirsling  <ross.kirsling@sony.com>
1985
1986         [Win] Remove -DUCHAR_TYPE=wchar_t stopgap and learn to live with char16_t.
1987         https://bugs.webkit.org/show_bug.cgi?id=195346
1988
1989         Reviewed by Fujii Hironori.
1990
1991         * Platform/IPC/win/ConnectionWin.cpp:
1992         (IPC::Connection::createServerAndClientIdentifiers):
1993         * Platform/win/ModuleWin.cpp:
1994         (WebKit::Module::load):
1995         * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
1996         (WebKit::ProcessLauncher::launchProcess):
1997         * UIProcess/win/WebContextMenuProxyWin.cpp:
1998         (WebKit::createMenuItem):
1999         * UIProcess/win/WebView.cpp:
2000         (WebKit::WebView::setToolTip):
2001         * WebProcess/InjectedBundle/win/InjectedBundleWin.cpp:
2002         (WebKit::InjectedBundle::initialize):
2003         Use wchar helpers as needed.
2004
2005 2019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
2006
2007         Crash when attempting to change input type while dismissing datalist suggestions
2008         https://bugs.webkit.org/show_bug.cgi?id=195384
2009         <rdar://problem/48563718>
2010
2011         Reviewed by Brent Fulgham.
2012
2013         See WebCore ChangeLog for more details.
2014
2015         * WebProcess/WebPage/WebPage.cpp:
2016         (WebKit::WebPage::setActiveDataListSuggestionPicker):
2017         (WebKit::WebPage::didSelectDataListOption):
2018         (WebKit::WebPage::didCloseSuggestions):
2019         * WebProcess/WebPage/WebPage.h:
2020
2021         Turn m_activeDataListSuggestionPicker from a raw pointer into a WeakPtr.
2022
2023 2019-03-06  Chris Dumez  <cdumez@apple.com>
2024
2025         [iOS] ProcessDidResume() IPC should be sent upon resuming when ProcessWillSuspendImminently() IPC was sent
2026         https://bugs.webkit.org/show_bug.cgi?id=195382
2027         <rdar://problem/48642739>
2028
2029         Reviewed by Geoffrey Garen.
2030
2031         ProcessDidResume() IPC should be sent upon resuming when ProcessWillSuspendImminently() IPC was sent. Previously,
2032         we only send ProcessDidResume() to the WebProcess if PrepareToSuspend() was sent, not when the more urgent
2033         ProcessWillSuspendImminently() IPC was sent.
2034
2035         This mismatch has lead to bugs because the WebProcess does not know it got resumed and failed to unfreeze the
2036         layers it froze upon suspension.
2037
2038         * UIProcess/ProcessAssertion.h:
2039         (WebKit::ProcessAssertionClient::~ProcessAssertionClient):
2040
2041         * UIProcess/ProcessThrottler.cpp:
2042         (WebKit::ProcessThrottler::updateAssertion):
2043         (WebKit::ProcessThrottler::uiAssertionWillExpireImminently):
2044         (WebKit::ProcessThrottler::assertionWillExpireImminently): Deleted.
2045
2046         * UIProcess/ProcessThrottler.h:
2047         * UIProcess/ios/ProcessAssertionIOS.mm:
2048         (-[WKProcessAssertionBackgroundTaskManager _notifyClientsOfImminentSuspension]):
2049         (WebKit::ProcessAssertion::~ProcessAssertion):
2050         (WebKit::ProcessAndUIAssertion::~ProcessAndUIAssertion):
2051         (WebKit::ProcessAndUIAssertion::setClient):
2052
2053         * WebProcess/WebPage/WebPage.cpp:
2054         (WebKit::WebPage::didCompletePageTransition):
2055         Revert change that was landed in r242098 to work around this ProcessThrottler bug.
2056
2057         * WebProcess/WebPage/ios/WebPageIOS.mm:
2058         (WebKit::WebPage::applicationWillEnterForeground):
2059         Revert change that was landed in r242554 to work around this ProcessThrottler bug.
2060
2061 2019-03-06  Alex Christensen  <achristensen@webkit.org>
2062
2063         Add gettid to allowed syscalls on Mac
2064         https://bugs.webkit.org/show_bug.cgi?id=195386
2065         <rdar://problem/48651255>
2066
2067         Reviewed by Brent Fulgham.
2068
2069         * WebProcess/com.apple.WebProcess.sb.in:
2070
2071 2019-03-06  Per Arne Vollan  <pvollan@apple.com>
2072
2073         [macOS] Sandbox call violation causes WebContent process to crash
2074         https://bugs.webkit.org/show_bug.cgi?id=195379
2075         <rdar://problem/48647263>
2076
2077         Reviewed by Brent Fulgham.
2078
2079         A new call needs to be added to the allow list in the WebContent process' sandbox.
2080
2081         * WebProcess/com.apple.WebProcess.sb.in:
2082
2083 2019-03-06  Antti Koivisto  <antti@apple.com>
2084
2085         [iOS] Basic hit testing for content overlapping fast-scrollable overflow
2086         https://bugs.webkit.org/show_bug.cgi?id=195360
2087
2088         Reviewed by Simon Fraser.
2089
2090         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
2091         (WebKit::RemoteLayerTreeHost::makeNode):
2092
2093         Use new UIView subclass for tiled layer hosting (so we know they have content even when contents property is nil).
2094
2095         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h:
2096         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
2097         (collectDescendantViewsAtPoint):
2098
2099         Factor collection step into a function.
2100         Do basic skipping of event-transparent layers.
2101
2102         (-[UIView _web_findDescendantViewAtPoint:withEvent:]):
2103
2104         To handle overlap cases, find the scroll view that has the deepest non-transparent view hit as its descendant.
2105
2106         (-[UIView _web_recursiveFindDescendantInteractibleViewAtPoint:withEvent:]): Deleted.
2107
2108 2019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
2109
2110         Move RenderObject::isTransparentOrFullyClippedRespectingParentFrames() to RenderLayer
2111         https://bugs.webkit.org/show_bug.cgi?id=195300
2112
2113         Reviewed by Simon Fraser.
2114
2115         Refactor some logic to use isTransparentOrFullyClippedRespectingParentFrames on RenderLayer rather than
2116         RenderObject; introduce a helper method to ask whether the enclosing layer of a renderer is transparent or
2117         clipped.
2118
2119         * WebProcess/WebPage/ios/WebPageIOS.mm:
2120         (WebKit::enclosingLayerIsTransparentOrFullyClipped):
2121         (WebKit::WebPage::platformEditorState const):
2122         (WebKit::WebPage::requestEvasionRectsAboveSelection):
2123         (WebKit::WebPage::getFocusedElementInformation):
2124
2125 2019-03-06  Chris Dumez  <cdumez@apple.com>
2126
2127         REGRESSION (r238490): YouTube.com: Returning PiP to Safari after sleeping device loses page
2128         https://bugs.webkit.org/show_bug.cgi?id=195364
2129         <rdar://problem/48538837>
2130
2131         Reviewed by Geoffrey Garen.
2132
2133         Make sure we unset the LayerTreeFreezeReason::ProcessSuspended layer tree freeze reason
2134         when WebPage::applicationWillEnterForeground() is called. This restores pre-r238490
2135         behavior and addresses the issue with PiP on youtube.com.
2136
2137         * WebProcess/WebPage/ios/WebPageIOS.mm:
2138         (WebKit::WebPage::applicationWillEnterForeground):
2139
2140 2019-03-05  Dean Jackson  <dino@apple.com>
2141
2142         Fix WKPasswordView compilation on iOS
2143         https://bugs.webkit.org/show_bug.cgi?id=195344
2144         <rdar://problem/48620066>
2145
2146         Reviewed by Dan Bates.
2147
2148         Use WebKitAdditions.
2149
2150         * UIProcess/ios/WKPasswordView.mm:
2151         (-[WKPasswordView showInScrollView:]):
2152
2153 2019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
2154
2155         [iOS] Frequent 1 second IPC deadlocks when showing a paste callout
2156         https://bugs.webkit.org/show_bug.cgi?id=195354
2157         <rdar://problem/48624675>
2158
2159         Reviewed by Tim Horton.
2160
2161         When triggering programmatic paste, we frequently hit deadlocks due to sync IPC going from the UI process to the
2162         web process and vice versa. What happens in this scenario is that prior to triggering programmatic paste, the
2163         page may try to move focus to a different element (e.g. a hidden editable area) before calling `execCommand`.
2164         This causes us to send an ElementDidFocus message to the UI process, followed by RequestDOMPasteAccess.
2165
2166         However, upon receiving ElementDidFocus, we reload input views and (in the process) UIKit requests the
2167         autocorrection context, which we implement in WebKit using a sync message to the web process due to
2168         <rdar://problem/16207002> and its blocking bug <rdar://problem/48383001>. This means we'll end up in a state
2169         where both the UI process and web process are blocked on each other waiting for a sync IPC response, and the UI
2170         process is hung for a second until the IPC message times out.
2171
2172         Ideally, we should fix this by addressing <rdar://problem/16207002>. However, this requires potentially large
2173         changes in UIKit (<rdar://problem/48383001>); for the time being, work around this deadlock by refactoring
2174         synchronous autocorrection context requests such that they can be resolved by an out-of-band IPC response
2175         (HandleAutocorrectionContext). Then prior to requesting DOM paste access, preemptively send a
2176         HandleAutocorrectionContext message to the UI process to unblock any pending synchronous autocorrection context
2177         requests.
2178
2179         * UIProcess/PageClient.h:
2180         * UIProcess/WebPageProxy.h:
2181         * UIProcess/WebPageProxy.messages.in:
2182         * UIProcess/ios/PageClientImplIOS.h:
2183         * UIProcess/ios/PageClientImplIOS.mm:
2184         (WebKit::PageClientImpl::handleAutocorrectionContext):
2185         * UIProcess/ios/WKContentViewInteraction.h:
2186
2187         Make it possible for WKContentView to remember its current pending autocorrection context completion handler.
2188         This is invoked and cleared out in `-_invokePendingAutocorrectionContextHandler:`.
2189
2190         * UIProcess/ios/WKContentViewInteraction.mm:
2191         (-[WKContentView _invokePendingAutocorrectionContextHandler:]):
2192         (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
2193         (-[WKContentView _handleAutocorrectionContext:]):
2194
2195         Handle an autocorrection context response. This is invoked when the web process either handles an autocorrection
2196         context message, or when it preemptively sends an autocorrection context before requesting DOM paste access.
2197
2198         (+[WKAutocorrectionContext emptyAutocorrectionContext]):
2199
2200         Add a helper to create an empty autocorrection context.
2201
2202         * UIProcess/ios/WebPageProxyIOS.mm:
2203         (WebKit::WebPageProxy::requestAutocorrectionContext):
2204         (WebKit::WebPageProxy::handleAutocorrectionContext):
2205         (WebKit::WebPageProxy::autocorrectionContextSync): Deleted.
2206
2207         Removed this sync version, since we now only have requestAutocorrectionContext.
2208
2209         * WebProcess/WebPage/WebPage.cpp:
2210         (WebKit::WebPage::requestDOMPasteAccess):
2211
2212         Send WebPageProxy::HandleAutocorrectionContext, and add a FIXME referencing <rdar://problem/16207002>.
2213
2214         * WebProcess/WebPage/WebPage.h:
2215         * WebProcess/WebPage/WebPage.messages.in:
2216
2217         Split AutocorrectionContextSync into RequestAutocorrectionContext and HandleAutocorrectionContext; additionally,
2218         remove the existing RequestAutocorrectionContext message.
2219
2220         * WebProcess/WebPage/ios/WebPageIOS.mm:
2221         (WebKit::WebPage::requestAutocorrectionContext):
2222         (WebKit::WebPage::autocorrectionContextSync): Deleted.
2223
2224 2019-03-06  Rob Buis  <rbuis@igalia.com>
2225
2226         Consider supporting the `referrerpolicy` attribute.
2227         https://bugs.webkit.org/show_bug.cgi?id=179053
2228
2229         Reviewed by Darin Adler.
2230
2231         Add a runtime flag for referrerpolicy attribute.
2232
2233         * Shared/WebPreferences.yaml:
2234         * UIProcess/API/C/WKPreferences.cpp:
2235         (WKPreferencesSetReferrerPolicyAttributeEnabled):
2236         (WKPreferencesGetReferrerPolicyAttributeEnabled):
2237         * UIProcess/API/C/WKPreferencesRefPrivate.h:
2238         * WebProcess/Network/WebLoaderStrategy.cpp:
2239         (WebKit::WebLoaderStrategy::loadResource): do not hardcode choosing
2240         the document referrer policy.
2241
2242 2019-03-06  Philippe Normand  <pnormand@igalia.com>
2243
2244         Unreviewed, WPE build fix after r242503
2245
2246         * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
2247         ServiceWorker messages moved from network process to another
2248         header, so it needs to be included.
2249
2250 2019-03-05  David Quesada  <david_quesada@apple.com>
2251
2252         [WK2] It should be possible to follow links with 'download' attributes
2253         https://bugs.webkit.org/show_bug.cgi?id=195145
2254         rdar://problem/48462642
2255
2256         Reviewed by Alex Christensen.
2257
2258         When a link with a 'download' attribute is clicked and the navigation client
2259         says to allow the navigation (i.e. provides PolicyAction::Use),
2260         WebPageProxy::receivedNavigationPolicyDecision() should stop overriding this
2261         decision and downloading the link instead. Instead, web view should honor the
2262         policy chosen by the navigation delegate. This supports clients that want to
2263         offer the user the ability to view, rather than download, the contents of
2264         such links, which is permitted per the HTML spec.
2265
2266         This change is only made on Cocoa platforms for now since no other ports
2267         expose an API on their navigation action to express whether the page intends
2268         to download the linked resource.
2269
2270         * UIProcess/API/APINavigation.h:
2271         (API::Navigation::shouldPerformDownload const):
2272             Rename this to be in line with APINavigationAction's shouldPerformDownload()
2273             for consistency. 'Force' seems like too strong of a word for this property
2274             considering that 'forcing' the download isn't really an attribute inherent
2275             to the navigation, but a behavior implemented by the web page proxy.
2276         (API::Navigation::shouldForceDownload const): Deleted.
2277         * UIProcess/Cocoa/VersionChecks.h:
2278         * UIProcess/WebPageProxy.cpp:
2279         (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
2280
2281 2019-03-05  Takashi Komori  <Takashi.Komori@sony.com>
2282
2283         [Curl] Implement Cookie Accept Policy.
2284         https://bugs.webkit.org/show_bug.cgi?id=191645
2285
2286         Reviewed by Fujii Hironori.
2287
2288         * NetworkProcess/Cookies/curl/WebCookieManagerCurl.cpp:
2289         (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
2290         (WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy):
2291         * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
2292         (WebKit::NetworkDataTaskCurl::curlDidReceiveResponse):
2293         (WebKit::NetworkDataTaskCurl::handleCookieHeaders):
2294         * NetworkProcess/curl/NetworkDataTaskCurl.h:
2295
2296 2019-03-05  Youenn Fablet  <youenn@apple.com>
2297
2298         Introduce ServiceWorkerFetchTask
2299         https://bugs.webkit.org/show_bug.cgi?id=195130
2300
2301         Reviewed by Chris Dumez.
2302
2303         ServiceWorkerFetchTask is added to represent NetworkProcess side of an ongoing fetch intercepted by service worker.
2304         This patch should not change existing behavior.
2305
2306         * CMakeLists.txt:
2307         * DerivedSources-input.xcfilelist:
2308         * DerivedSources-output.xcfilelist:
2309         * DerivedSources.make:
2310         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
2311         (WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
2312         * NetworkProcess/NetworkProcess.cpp:
2313         (WebKit::NetworkProcess::didFailFetch): Deleted.
2314         (WebKit::NetworkProcess::didNotHandleFetch): Deleted.
2315         (WebKit::NetworkProcess::didReceiveFetchRedirectResponse): Deleted.
2316         (WebKit::NetworkProcess::didReceiveFetchResponse): Deleted.
2317         (WebKit::NetworkProcess::didReceiveFetchData): Deleted.
2318         (WebKit::NetworkProcess::didReceiveFetchFormData): Deleted.
2319         (WebKit::NetworkProcess::didFinishFetch): Deleted.
2320         * NetworkProcess/NetworkProcess.h:
2321         * NetworkProcess/NetworkProcess.messages.in:
2322         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
2323         (WebKit::WebSWServerConnection::cancelFetch):
2324         (WebKit::WebSWServerConnection::continueDidReceiveFetchResponse):
2325         (WebKit::WebSWServerConnection::startFetch):
2326         (WebKit::WebSWServerConnection::didReceiveFetchRedirectResponse): Deleted.
2327         (WebKit::WebSWServerConnection::didReceiveFetchResponse): Deleted.
2328         (WebKit::WebSWServerConnection::didReceiveFetchData): Deleted.
2329         (WebKit::WebSWServerConnection::didReceiveFetchFormData): Deleted.
2330         (WebKit::WebSWServerConnection::didFinishFetch): Deleted.
2331         (WebKit::WebSWServerConnection::didFailFetch): Deleted.
2332         (WebKit::WebSWServerConnection::didNotHandleFetch): Deleted.
2333         * NetworkProcess/ServiceWorker/WebSWServerConnection.h:
2334         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
2335         (WebKit::WebSWServerToContextConnection::connectionClosed):
2336         (WebKit::WebSWServerToContextConnection::startFetch):
2337         (WebKit::WebSWServerToContextConnection::cancelFetch):
2338         (WebKit::WebSWServerToContextConnection::continueDidReceiveFetchResponse):
2339         (WebKit::WebSWServerToContextConnection::didReceiveFetchTaskMessage):
2340         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
2341         * SourcesCocoa.txt:
2342         * WebKit.xcodeproj/project.pbxproj:
2343         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
2344         (WebKit::WebSWContextManagerConnection::startFetch):
2345         * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
2346         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveRedirection):
2347         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveResponse):
2348         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveData):
2349         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish):
2350         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveBlobChunk):
2351         (WebKit::WebServiceWorkerFetchTaskClient::didFail):
2352         (WebKit::WebServiceWorkerFetchTaskClient::didFinish):
2353         (WebKit::WebServiceWorkerFetchTaskClient::didNotHandle):
2354         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: Added.
2355         (WebKit::ServiceWorkerFetchTask::didReceiveRedirectResponse):
2356         (WebKit::ServiceWorkerFetchTask::didReceiveResponse):
2357         (WebKit::ServiceWorkerFetchTask::didReceiveData):
2358         (WebKit::ServiceWorkerFetchTask::didReceiveFormData):
2359         (WebKit::ServiceWorkerFetchTask::didFinish):
2360         (WebKit::ServiceWorkerFetchTask::didFail):
2361         (WebKit::ServiceWorkerFetchTask::didNotHandle):
2362         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h: Added.
2363         (WebKit::ServiceWorkerFetchTask::create):
2364         (WebKit::ServiceWorkerFetchTask::Identifier::hash const):
2365         (WebKit::ServiceWorkerFetchTask::identifier const):
2366         (WebKit::ServiceWorkerFetchTask::ServiceWorkerFetchTask):
2367         (WebKit::operator==):
2368         (WTF::ServiceWorkerFetchTaskIdentifierHash::hash):
2369         (WTF::ServiceWorkerFetchTaskIdentifierHash::equal):
2370         (WTF::HashTraits<WebKit::ServiceWorkerFetchTask::Identifier>::emptyValue):
2371         (WTF::HashTraits<WebKit::ServiceWorkerFetchTask::Identifier>::constructDeletedValue):
2372         (WTF::HashTraits<WebKit::ServiceWorkerFetchTask::Identifier>::isDeletedValue):
2373         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.messages.in: Added.
2374
2375 2019-03-05  Youenn Fablet  <youenn@apple.com>
2376
2377         Rename requestCacheStorageSpace to requestStorageSpace
2378         https://bugs.webkit.org/show_bug.cgi?id=195282
2379
2380         Reviewed by Chris Dumez.
2381
2382         Make the name more abstract as it might be used in the future for other storage
2383         like IDB or service worker registrations.
2384
2385         * NetworkProcess/NetworkProcess.cpp:
2386         (WebKit::NetworkProcess::requestStorageSpace):
2387         (WebKit::NetworkProcess::requestCacheStorageSpace): Deleted.
2388         * NetworkProcess/NetworkProcess.h:
2389         * NetworkProcess/cache/CacheStorageEngine.cpp:
2390         (WebKit::CacheStorage::Engine::requestSpace):
2391         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2392         (WebsiteDataStoreClient::WebsiteDataStoreClient):
2393         * UIProcess/API/Cocoa/_WKWebsiteDataStoreDelegate.h:
2394         * UIProcess/Network/NetworkProcessProxy.cpp:
2395         (WebKit::NetworkProcessProxy::requestStorageSpace):
2396         (WebKit::NetworkProcessProxy::requestCacheStorageSpace): Deleted.
2397         * UIProcess/Network/NetworkProcessProxy.h:
2398         * UIProcess/Network/NetworkProcessProxy.messages.in:
2399         * UIProcess/WebsiteData/WebsiteDataStoreClient.h:
2400         (WebKit::WebsiteDataStoreClient::requestStorageSpace):
2401         (WebKit::WebsiteDataStoreClient::requestCacheStorageSpace): Deleted.
2402
2403 2019-03-05  Chris Dumez  <cdumez@apple.com>
2404
2405         Drop cached WebProcesses for a given session when this session is destroyed
2406         https://bugs.webkit.org/show_bug.cgi?id=195212
2407         <rdar://problem/48301483>
2408
2409         Reviewed by Geoffrey Garen.
2410
2411         Drop cached WebProcesses for a give session when this session is destroyed. This way, when you close
2412         your private browsing window, all the processes it used get cleared and it cannot leave any state
2413         behind.
2414
2415         * UIProcess/WebProcessCache.cpp:
2416         (WebKit::WebProcessCache::canCacheProcess const):
2417         (WebKit::WebProcessCache::addProcessIfPossible):
2418         (WebKit::WebProcessCache::addProcess):
2419         (WebKit::WebProcessCache::clearAllProcessesForSession):
2420         * UIProcess/WebProcessCache.h:
2421         (WebKit::WebProcessCache::capacity const):
2422         * UIProcess/WebProcessPool.cpp:
2423         (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore):
2424         (WebKit::WebProcessPool::hasPagesUsingWebsiteDataStore const):
2425         * UIProcess/WebProcessPool.h:
2426
2427 2019-03-05  Brady Eidson  <beidson@apple.com>
2428
2429         Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
2430         <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
2431
2432         Reviewed by Tim Horton.
2433
2434         * WebProcess/WebPage/WebPage.cpp:
2435         (WebKit::WebPage::SandboxExtensionTracker::shouldReuseCommittedSandboxExtension): If there is a pendingProvisionalSandboxExtension
2436           then its existence should override our willingness to reuse the existing committed extension.
2437         (WebKit::shouldReuseCommittedSandboxExtension): Deleted.
2438         * WebProcess/WebPage/WebPage.h:
2439
2440 2019-03-05  Ryan Haddad  <ryanhaddad@apple.com>
2441
2442         Unreviewed, rolling out r242403.
2443
2444         Caused layout test crashes on iOS simulator.
2445
2446         Reverted changeset:
2447
2448         "[ContentChangeObserver] Introduce fixed duration content
2449         observation"
2450         https://bugs.webkit.org/show_bug.cgi?id=195295
2451         https://trac.webkit.org/changeset/242403
2452
2453 2019-03-05  Loïc Yhuel  <loic.yhuel@softathome.com>
2454
2455         [WPE] Do not create a PlatformDisplay in the Service Worker process
2456         https://bugs.webkit.org/show_bug.cgi?id=194830
2457
2458         Reviewed by Žan Doberšek.
2459
2460         It avoids opening the Wayland socket in this WPEWebProcess, which might cause issues
2461         depending on the platform, and allocates unneeded resources.
2462
2463         * Shared/WebProcessCreationParameters.cpp:
2464         (WebKit::WebProcessCreationParameters::encode const):
2465         (WebKit::WebProcessCreationParameters::decode):
2466         * Shared/WebProcessCreationParameters.h: Add new isServiceWorkerProcess parameter.
2467         * UIProcess/WebProcessPool.cpp:
2468         (WebKit::WebProcessPool::initializeNewWebProcess): Set isServiceWorkerProcess parameter.
2469         * UIProcess/glib/WebProcessPoolGLib.cpp:
2470         (WebKit::WebProcessPool::platformInitializeWebProcess): No implementationLibraryName and hostClientFileDescriptor for Service Worker.
2471         * WebProcess/glib/WebProcessGLib.cpp:
2472         (WebKit::WebProcess::platformInitializeWebProcess): No wpe_loader_init nor PlatformDisplayLibWPE for Service Worker.
2473
2474 2019-03-04  Brady Eidson  <beidson@apple.com>
2475
2476         Unreviewed, rolling out r242376.
2477
2478         Broke some tests
2479
2480         Reverted changeset:
2481
2482         "Correctly handle sandbox extensions when the same WKWebView
2483         loads multiple file:// URLs."
2484         https://bugs.webkit.org/show_bug.cgi?id=195291
2485         https://trac.webkit.org/changeset/242376
2486
2487 2019-03-04  Fujii Hironori  <Hironori.Fujii@sony.com>
2488
2489         Use a SQLite database to hold the ResourceLoadStatistics data
2490         https://bugs.webkit.org/show_bug.cgi?id=194867
2491         <rdar://problem/24240854>
2492
2493         Unreviewed build fix for WinCairo.
2494
2495         ResourceLoadStatisticsDebug and RELEASE_LOG_INFO_IF are not
2496         defined because WinCairo port defines RELEASE_LOG_DISABLED.
2497
2498         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
2499         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess): Enclosed RELEASE_LOG_INFO_IF with #if !RELEASE_LOG_DISABLED.
2500         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener): Ditto.
2501         (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlocking): Ditto.
2502
2503 2019-03-04  Brent Fulgham  <bfulgham@apple.com>
2504
2505         Use a SQLite database to hold the ResourceLoadStatistics data
2506         https://bugs.webkit.org/show_bug.cgi?id=194867
2507         <rdar://problem/24240854>
2508
2509         Reviewed by Chris Dumez.
2510
2511         The ResourceLoadStatistics database plist is inefficient. It requires more memory use
2512         than it needs, and forces lots of looping and string comparisons to find information.
2513
2514         This problem has already been solved in the form of relational databases. We use them
2515         elsewhere in WebKit, and should do so for this storage as well.
2516
2517         This patch creates an optional SQLite database to handle ITP operations.
2518
2519         1. It adds a new internal experimental feature flag to activate it. It requires the user
2520            exit and restart the process to take effect.
2521         2. It populates itself from the existing plist file (if it exists).
2522         3. It stops using the plist in favor of the database.
2523         4. It does queries and other operations using the database instead of the old hash table
2524            implementation.
2525
2526         This patch refactors the exisiting ResourceLoadStatisticsMemoryStore class into a base
2527         ResourceLoadStatisticsStore class, which ResourceLoadStatisticsMemoryStore is based on.
2528         It adds a new ResourceLoadStatisticsDatabaseStore that is implemented in terms of SQL
2529         operations.
2530
2531         These code changes should not have any impact on existing operations, and when enabled
2532         should produce the same test results.
2533
2534         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: Added.
2535         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
2536         (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
2537         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements):
2538         (WebKit::ResourceLoadStatisticsDatabaseStore::insertObservedDomain):
2539         (WebKit::ResourceLoadStatisticsDatabaseStore::relationshipExists const):
2540         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationship):
2541         (WebKit::ResourceLoadStatisticsDatabaseStore::confirmDomainDoesNotExist const):
2542         (WebKit::ResourceLoadStatisticsDatabaseStore::domainIDFromString const):
2543         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
2544         (WebKit::ResourceLoadStatisticsDatabaseStore::databaseIsEmpty const):
2545         (WebKit::ResourceLoadStatisticsDatabaseStore::populateFromMemoryStore):
2546         (WebKit::ResourceLoadStatisticsDatabaseStore::calculateAndSubmitTelemetry const):
2547         (WebKit::ResourceLoadStatisticsDatabaseStore::incrementRecordsDeletedCountForDomains):
2548         (WebKit::ResourceLoadStatisticsDatabaseStore::recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain):
2549         (WebKit::buildList):
2550         (WebKit::ResourceLoadStatisticsDatabaseStore::markAsPrevalentIfHasRedirectedToPrevalent):
2551         (WebKit::listToString):
2552         (WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources):
2553         (WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources):
2554         (WebKit::ResourceLoadStatisticsDatabaseStore::classifyPrevalentResources):
2555         (WebKit::ResourceLoadStatisticsDatabaseStore::syncStorageIfNeeded):
2556         (WebKit::ResourceLoadStatisticsDatabaseStore::syncStorageImmediately):
2557         (WebKit::ResourceLoadStatisticsDatabaseStore::hasStorageAccess):
2558         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
2559         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener):
2560         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
2561         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
2562         (WebKit::ResourceLoadStatisticsDatabaseStore::grandfatherDataForDomains):
2563         (WebKit::ResourceLoadStatisticsDatabaseStore::ensurePrevalentResourcesForDebugMode):
2564         (WebKit::ResourceLoadStatisticsDatabaseStore::logFrameNavigation):
2565         (WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceLoading):
2566         (WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceRedirect):
2567         (WebKit::ResourceLoadStatisticsDatabaseStore::setUserInteraction):
2568         (WebKit::ResourceLoadStatisticsDatabaseStore::logUserInteraction):
2569         (WebKit::ResourceLoadStatisticsDatabaseStore::clearUserInteraction):
2570         (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction):
2571         (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource):
2572         (WebKit::ResourceLoadStatisticsDatabaseStore::setDomainsAsPrevalent):
2573         (WebKit::ResourceLoadStatisticsDatabaseStore::dumpResourceLoadStatistics const):
2574         (WebKit::ResourceLoadStatisticsDatabaseStore::predicateValueForDomain const):
2575         (WebKit::ResourceLoadStatisticsDatabaseStore::isPrevalentResource const):
2576         (WebKit::ResourceLoadStatisticsDatabaseStore::isVeryPrevalentResource const):
2577         (WebKit::ResourceLoadStatisticsDatabaseStore::isRegisteredAsSubresourceUnder const):
2578         (WebKit::ResourceLoadStatisticsDatabaseStore::isRegisteredAsSubFrameUnder const):
2579         (WebKit::ResourceLoadStatisticsDatabaseStore::isRegisteredAsRedirectingTo const):
2580         (WebKit::ResourceLoadStatisticsDatabaseStore::clearPrevalentResource):
2581         (WebKit::ResourceLoadStatisticsDatabaseStore::setGrandfathered):
2582         (WebKit::ResourceLoadStatisticsDatabaseStore::isGrandfathered const):
2583         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubframeUnderTopFrameOrigin):
2584         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUnderTopFrameOrigin):
2585         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUniqueRedirectTo):
2586         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUniqueRedirectFrom):
2587         (WebKit::ResourceLoadStatisticsDatabaseStore::setTopFrameUniqueRedirectTo):
2588         (WebKit::ResourceLoadStatisticsDatabaseStore::setTopFrameUniqueRedirectFrom):
2589         (WebKit::ResourceLoadStatisticsDatabaseStore::ensureResourceStatisticsForPrimaryDomain):
2590         (WebKit::ResourceLoadStatisticsDatabaseStore::clear):
2591         (WebKit::ResourceLoadStatisticsDatabaseStore::cookieTreatmentForOrigin const):
2592         (WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt):
2593         (WebKit::ResourceLoadStatisticsDatabaseStore::domainsToBlock const):
2594         (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlocking):
2595         (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlockingForDomains):
2596         (WebKit::ResourceLoadStatisticsDatabaseStore::clearBlockingStateForDomains):
2597         (WebKit::ResourceLoadStatisticsDatabaseStore::processStatistics const):
2598         (WebKit::ResourceLoadStatisticsDatabaseStore::prevalentDomains const):
2599         (WebKit::ResourceLoadStatisticsDatabaseStore::findExpiredUserInteractions const):
2600         (WebKit::ResourceLoadStatisticsDatabaseStore::clearExpiredUserInteractions):
2601         (WebKit::ResourceLoadStatisticsDatabaseStore::clearGrandfathering):
2602         (WebKit::ResourceLoadStatisticsDatabaseStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
2603         (WebKit::ResourceLoadStatisticsDatabaseStore::pruneStatisticsIfNeeded):
2604         (WebKit::ResourceLoadStatisticsDatabaseStore::updateLastSeen):
2605         (WebKit::ResourceLoadStatisticsDatabaseStore::setLastSeen):
2606         (WebKit::ResourceLoadStatisticsDatabaseStore::setVeryPrevalentResource):
2607         (WebKit::ResourceLoadStatisticsDatabaseStore::removeAllStorageAccess):
2608         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: Added.
2609         (WebKit::ResourceLoadStatisticsDatabaseStore::isEmpty const):
2610         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
2611         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
2612         (WebKit::ResourceLoadStatisticsMemoryStore::incrementRecordsDeletedCountForDomains):
2613         (WebKit::ResourceLoadStatisticsMemoryStore::classifyPrevalentResources):
2614         (WebKit::ResourceLoadStatisticsMemoryStore::syncStorageIfNeeded):
2615         (WebKit::ResourceLoadStatisticsMemoryStore::syncStorageImmediately):
2616         (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherDataForDomains):
2617         (WebKit::domainsToString): Deleted.
2618         (WebKit::OperatingDate::fromWallTime): Deleted.
2619         (WebKit::OperatingDate::today): Deleted.
2620         (WebKit::OperatingDate::secondsSinceEpoch const): Deleted.
2621         (WebKit::OperatingDate::operator== const): Deleted.
2622         (WebKit::OperatingDate::operator< const): Deleted.
2623         (WebKit::OperatingDate::operator<= const): Deleted.
2624         (WebKit::OperatingDate::OperatingDate): Deleted.
2625         (WebKit::mergeOperatingDates): Deleted.
2626         (WebKit::computeImportance): Deleted.
2627         (WebKit::ResourceLoadStatisticsMemoryStore::~ResourceLoadStatisticsMemoryStore): Deleted.
2628         (WebKit::ResourceLoadStatisticsMemoryStore::setNotifyPagesWhenDataRecordsWereScanned): Deleted.
2629         (WebKit::ResourceLoadStatisticsMemoryStore::setShouldClassifyResourcesBeforeDataRecordsRemoval): Deleted.
2630         (WebKit::ResourceLoadStatisticsMemoryStore::setShouldSubmitTelemetry): Deleted.
2631         (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords): Deleted.
2632         (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords): Deleted.
2633         (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData): Deleted.
2634         (WebKit::ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode): Deleted.
2635         (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode): Deleted.
2636         (WebKit::ResourceLoadStatisticsMemoryStore::scheduleStatisticsProcessingRequestIfNecessary): Deleted.
2637         (WebKit::ResourceLoadStatisticsMemoryStore::cancelPendingStatisticsProcessingRequest): Deleted.
2638         (WebKit::ResourceLoadStatisticsMemoryStore::setTimeToLiveUserInteraction): Deleted.
2639         (WebKit::ResourceLoadStatisticsMemoryStore::setMinimumTimeBetweenDataRecordsRemoval): Deleted.
2640         (WebKit::ResourceLoadStatisticsMemoryStore::setGrandfatheringTime): Deleted.
2641         (WebKit::ResourceLoadStatisticsMemoryStore::setCacheMaxAgeCap): Deleted.
2642         (WebKit::ResourceLoadStatisticsMemoryStore::updateCacheMaxAgeCap): Deleted.
2643         (WebKit::ResourceLoadStatisticsMemoryStore::setAgeCapForClientSideCookies): Deleted.
2644         (WebKit::ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap): Deleted.
2645         (WebKit::ResourceLoadStatisticsMemoryStore::shouldRemoveDataRecords const): Deleted.
2646         (WebKit::ResourceLoadStatisticsMemoryStore::setDataRecordsBeingRemoved): Deleted.
2647         (WebKit::debugLogDomainsInBatches): Deleted.
2648         (WebKit::ResourceLoadStatisticsMemoryStore::includeTodayAsOperatingDateIfNecessary): Deleted.
2649         (WebKit::ResourceLoadStatisticsMemoryStore::hasStatisticsExpired const): Deleted.
2650         (WebKit::ResourceLoadStatisticsMemoryStore::setMaxStatisticsEntries): Deleted.
2651         (WebKit::ResourceLoadStatisticsMemoryStore::setPruneEntriesDownTo): Deleted.
2652         (WebKit::ResourceLoadStatisticsMemoryStore::resetParametersToDefaultValues): Deleted.
2653         (WebKit::ResourceLoadStatisticsMemoryStore::logTestingEvent): Deleted.
2654         (WebKit::ResourceLoadStatisticsMemoryStore::didCreateNetworkProcess): Deleted.
2655         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
2656         (WebKit::ResourceLoadStatisticsMemoryStore::data const):
2657         (WebKit::ResourceLoadStatisticsMemoryStore::isDebugModeEnabled const): Deleted.
2658         (WebKit::ResourceLoadStatisticsMemoryStore::store const): Deleted.
2659         (WebKit::ResourceLoadStatisticsMemoryStore::setStorageAccessPromptsEnabled): Deleted.
2660         (WebKit::ResourceLoadStatisticsMemoryStore::setDebugLogggingEnabled): Deleted.
2661         (): Deleted.
2662         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: Added.
2663         (WebKit::domainsToString):
2664         (WebKit::OperatingDate::fromWallTime):
2665         (WebKit::OperatingDate::today):
2666         (WebKit::OperatingDate::secondsSinceEpoch const):
2667         (WebKit::OperatingDate::operator== const):
2668         (WebKit::OperatingDate::operator< const):
2669         (WebKit::OperatingDate::operator<= const):
2670         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
2671         (WebKit::ResourceLoadStatisticsStore::~ResourceLoadStatisticsStore):
2672         (WebKit::ResourceLoadStatisticsStore::calculateAndSubmitTelemetry const):
2673         (WebKit::ResourceLoadStatisticsStore::computeImportance):
2674         (WebKit::ResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
2675         (WebKit::ResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
2676         (WebKit::ResourceLoadStatisticsStore::setShouldSubmitTelemetry):
2677         (WebKit::ResourceLoadStatisticsStore::removeDataRecords):
2678         (WebKit::ResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2679         (WebKit::ResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
2680         (WebKit::ResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
2681         (WebKit::ResourceLoadStatisticsStore::setPrevalentResourceForDebugMode):
2682         (WebKit::ResourceLoadStatisticsStore::scheduleStatisticsProcessingRequestIfNecessary):
2683         (WebKit::ResourceLoadStatisticsStore::cancelPendingStatisticsProcessingRequest):
2684         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
2685         (WebKit::ResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
2686         (WebKit::ResourceLoadStatisticsStore::setGrandfatheringTime):
2687         (WebKit::ResourceLoadStatisticsStore::setCacheMaxAgeCap):
2688         (WebKit::ResourceLoadStatisticsStore::updateCacheMaxAgeCap):
2689         (WebKit::ResourceLoadStatisticsStore::setAgeCapForClientSideCookies):
2690         (WebKit::ResourceLoadStatisticsStore::updateClientSideCookiesAgeCap):
2691         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords const):
2692         (WebKit::ResourceLoadStatisticsStore::setDataRecordsBeingRemoved):
2693         (WebKit::ResourceLoadStatisticsStore::updateCookieBlockingForDomains):
2694         (WebKit::ResourceLoadStatisticsStore::clearBlockingStateForDomains):
2695         (WebKit::ResourceLoadStatisticsStore::processStatistics const):
2696         (WebKit::ResourceLoadStatisticsStore::statisticsEpirationTime const):
2697         (WebKit::ResourceLoadStatisticsStore::mergeOperatingDates):
2698         (WebKit::ResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
2699         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired const):
2700         (WebKit::ResourceLoadStatisticsStore::setMaxStatisticsEntries):
2701         (WebKit::ResourceLoadStatisticsStore::setPruneEntriesDownTo):
2702         (WebKit::ResourceLoadStatisticsStore::resetParametersToDefaultValues):
2703         (WebKit::ResourceLoadStatisticsStore::logTestingEvent):
2704         (WebKit::ResourceLoadStatisticsStore::removeAllStorageAccess):
2705         (WebKit::ResourceLoadStatisticsStore::didCreateNetworkProcess):
2706         (WebKit::ResourceLoadStatisticsStore::debugLogDomainsInBatches):
2707         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: Copied from Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h.
2708         (WebKit::OperatingDate::OperatingDate):
2709         (WebKit::ResourceLoadStatisticsStore::isEmpty const):
2710         (WebKit::ResourceLoadStatisticsStore::data const):
2711         (WebKit::ResourceLoadStatisticsStore::isDebugModeEnabled const):
2712         (WebKit::ResourceLoadStatisticsStore::store const):
2713         (WebKit::ResourceLoadStatisticsStore::setStorageAccessPromptsEnabled):
2714         (WebKit::ResourceLoadStatisticsStore::setDebugLogggingEnabled):
2715         * NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm: Renamed from Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm.
2716         (WebKit::ResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):
2717         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
2718         (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
2719         (WebKit::WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
2720         (WebKit::WebResourceLoadStatisticsStore::setShouldSubmitTelemetry):
2721         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
2722         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
2723         (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
2724         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode):
2725         (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
2726         (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess):
2727         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
2728         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener):
2729         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
2730         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
2731         (WebKit::WebResourceLoadStatisticsStore::logFrameNavigation):
2732         (WebKit::WebResourceLoadStatisticsStore::logWebSocketLoading):
2733         (WebKit::WebResourceLoadStatisticsStore::logSubresourceLoading):
2734         (WebKit::WebResourceLoadStatisticsStore::logSubresourceRedirect):
2735         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
2736         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
2737         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
2738         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
2739         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
2740         (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
2741         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
2742         (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource):
2743         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder):
2744         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder):
2745         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo):
2746         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
2747         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
2748         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
2749         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
2750         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
2751         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
2752         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom):
2753         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo):
2754         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom):
2755         (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdate):
2756         (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains):
2757         (WebKit::WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains):
2758         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
2759         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
2760         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
2761         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
2762         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
2763         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
2764         (WebKit::WebResourceLoadStatisticsStore::resetParametersToDefaultValues):
2765         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
2766         * NetworkProcess/NetworkProcess.cpp:
2767         (WebKit::NetworkProcess::initializeNetworkProcess):
2768         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2769         (WebKit::NetworkProcessCreationParameters::encode const):
2770         (WebKit::NetworkProcessCreationParameters::decode):
2771         * NetworkProcess/NetworkProcessCreationParameters.h:
2772         * Platform/classifier/ResourceLoadStatisticsClassifier.cpp:
2773         (WebKit::ResourceLoadStatisticsClassifier::calculateResourcePrevalence):
2774         * Platform/classifier/ResourceLoadStatisticsClassifier.h:
2775         * Shared/WebPreferences.yaml:
2776         * Sources.txt:
2777         * SourcesCocoa.txt:
2778         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2779         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
2780         * UIProcess/WebProcessPool.cpp:
2781         * WebKit.xcodeproj/project.pbxproj:
2782
2783 2019-03-04  Zalan Bujtas  <zalan@apple.com>
2784
2785         [ContentChangeObserver] Introduce fixed duration content observation
2786         https://bugs.webkit.org/show_bug.cgi?id=195295
2787         <rdar://problem/48579913>
2788
2789         Reviewed by Simon Fraser.
2790
2791         * WebProcess/WebPage/ios/WebPageIOS.mm:
2792         (WebKit::WebPage::handleSyntheticClick):
2793
2794 2019-03-04  Truitt Savell  <tsavell@apple.com>
2795
2796         Unreviewed, rolling out r242396.
2797
2798         Found issue to be unrelated. reverting my rollout.
2799
2800         Reverted changeset:
2801
2802         "Unreviewed, rolling out r242222."
2803         https://bugs.webkit.org/show_bug.cgi?id=193683
2804         https://trac.webkit.org/changeset/242396
2805
2806 2019-03-04  Jiewen Tan  <jiewen_tan@apple.com>
2807
2808         Unreviewed, a followup after r242336
2809
2810         * UIProcess/WebPageProxy.cpp:
2811         (WebKit::WebPageProxy::webViewDidMoveToWindow):
2812         Copy the list of observers before iterating it to avoid observers modifying the list.
2813
2814 2019-03-04  Truitt Savell  <tsavell@apple.com>
2815
2816         Unreviewed, rolling out r242222.
2817
2818         Broke internal debug testing
2819
2820         Reverted changeset:
2821
2822         "[iOS] Move calls to [UIKeyboard isInHardwareKeyboardMode] to
2823         the UI process."
2824         https://bugs.webkit.org/show_bug.cgi?id=193683
2825         https://trac.webkit.org/changeset/242222
2826
2827 2019-03-04  Brent Fulgham  <bfulgham@apple.com>
2828
2829         Unreviewed build fix after r242378
2830
2831         * UIProcess/ios/EditableImageController.mm:
2832         (WebKit::EditableImageController::associateWithAttachment):
2833
2834 2019-03-04  Brent Fulgham  <bfulgham@apple.com>
2835
2836         Check contextIDs when handling WebContent messages
2837         https://bugs.webkit.org/show_bug.cgi?id=195289
2838         <rdar://problem/48475870>
2839
2840         Reviewed by Alex Christensen.
2841
2842         The WebContent process is untrusted because it handles arbitrary markup and javascript from untrusted sources.
2843         We should handle its messages with suspicion, and make sure the arguments are valid and usable before honoring them.
2844
2845         This patch hardens the message passing layer by performing MESSAGE_CHECK in places that had been overlooked.
2846
2847         * UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
2848         (WebKit::PlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID):
2849         (WebKit::PlaybackSessionManagerProxy::currentTimeChanged):
2850         (WebKit::PlaybackSessionManagerProxy::bufferedTimeChanged):
2851         (WebKit::PlaybackSessionManagerProxy::seekableRangesVectorChanged):
2852         (WebKit::PlaybackSessionManagerProxy::canPlayFastReverseChanged):
2853         (WebKit::PlaybackSessionManagerProxy::audioMediaSelectionOptionsChanged):
2854         (WebKit::PlaybackSessionManagerProxy::legibleMediaSelectionOptionsChanged):
2855         (WebKit::PlaybackSessionManagerProxy::audioMediaSelectionIndexChanged):
2856         (WebKit::PlaybackSessionManagerProxy::legibleMediaSelectionIndexChanged):
2857         (WebKit::PlaybackSessionManagerProxy::externalPlaybackPropertiesChanged):
2858         (WebKit::PlaybackSessionManagerProxy::wirelessVideoPlaybackDisabledChanged):
2859         (WebKit::PlaybackSessionManagerProxy::mutedChanged):
2860         (WebKit::PlaybackSessionManagerProxy::volumeChanged):
2861         (WebKit::PlaybackSessionManagerProxy::durationChanged):
2862         (WebKit::PlaybackSessionManagerProxy::playbackStartedTimeChanged):
2863         (WebKit::PlaybackSessionManagerProxy::rateChanged):
2864         (WebKit::PlaybackSessionManagerProxy::pictureInPictureSupportedChanged):
2865         (WebKit::PlaybackSessionManagerProxy::pictureInPictureActiveChanged):
2866         (WebKit::PlaybackSessionManagerProxy::handleControlledElementIDResponse const):
2867         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
2868         (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
2869         (WebKit::UserMediaCaptureManagerProxy::startProducingData):
2870         (WebKit::UserMediaCaptureManagerProxy::stopProducingData):
2871         (WebKit::UserMediaCaptureManagerProxy::end):
2872         (WebKit::UserMediaCaptureManagerProxy::capabilities):
2873         (WebKit::UserMediaCaptureManagerProxy::setMuted):
2874         (WebKit::UserMediaCaptureManagerProxy::applyConstraints):
2875         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
2876         (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
2877         (WebKit::VideoFullscreenManagerProxy::setHasVideo):
2878         (WebKit::VideoFullscreenManagerProxy::setVideoDimensions):
2879         (WebKit::VideoFullscreenManagerProxy::enterFullscreen):
2880         (WebKit::VideoFullscreenManagerProxy::exitFullscreen):
2881         (WebKit::VideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode):
2882         (WebKit::VideoFullscreenManagerProxy::setInlineRect):
2883         (WebKit::VideoFullscreenManagerProxy::setHasVideoContentLayer):
2884         (WebKit::VideoFullscreenManagerProxy::cleanupFullscreen):
2885         (WebKit::VideoFullscreenManagerProxy::preparedToReturnToInline):
2886         (WebKit::VideoFullscreenManagerProxy::preparedToExitFullscreen):
2887         * UIProcess/ios/EditableImageController.mm:
2888         (WebKit::EditableImageController::didCreateEditableImage):
2889         (WebKit::EditableImageController::didDestroyEditableImage):
2890         (WebKit::EditableImageController::associateWithAttachment):
2891
2892 2019-03-04  Alex Christensen  <achristensen@webkit.org>
2893
2894         Fix crashes when NetworkResourceLoader/NetworkLoadChecker are destroyed during HTTPS upgrade check
2895         https://bugs.webkit.org/show_bug.cgi?id=195238
2896         <rdar://problem/47598656>
2897
2898         Reviewed by Chris Dumez.
2899
2900         * NetworkProcess/NetworkLoadChecker.cpp:
2901         (WebKit::NetworkLoadChecker::checkRequest):
2902
2903 2019-03-04  Brady Eidson  <beidson@apple.com>
2904
2905         Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
2906         <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
2907
2908         Reviewed by Andy Estes.
2909
2910         * WebProcess/WebPage/WebPage.cpp:
2911         (WebKit::shouldReuseCommittedSandboxExtension): Only retain the previous sandbox extension if the file URL
2912           we're currently loading is functionally equivalent to the previous one.
2913
2914 2019-03-04  Chris Dumez  <cdumez@apple.com>
2915
2916         Drop legacy userAgentForURL injected bundle SPI
2917         https://bugs.webkit.org/show_bug.cgi?id=195222
2918         <rdar://problem/46734147>
2919
2920         Reviewed by Darin Adler.
2921
2922         Drop legacy userAgentForURL injected bundle SPI. There are no longer any clients, and using
2923         WebsitePolicies.customUserAgent is the way to go nowadays.
2924
2925         * WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h:
2926         (API::InjectedBundle::PageLoaderClient::willDestroyFrame):
2927         (API::InjectedBundle::PageLoaderClient::userAgentForURL const): Deleted.
2928         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h:
2929         * WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h:
2930         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
2931         (setUpPageLoaderClient):
2932         (userAgentForURL): Deleted.
2933         * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
2934         (WebKit::InjectedBundlePageLoaderClient::userAgentForURL const): Deleted.
2935         * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
2936         * WebProcess/WebPage/WebPage.cpp:
2937         (WebKit::WebPage::userAgent const):
2938
2939 2019-03-04  Chris Dumez  <cdumez@apple.com>
2940
2941         Do not share WebProcesses between private and regular sessions
2942         https://bugs.webkit.org/show_bug.cgi?id=195189
2943         <rdar://problem/48421064>
2944
2945         Reviewed by Alex Christensen.
2946
2947         Do not share WebProcesses between private and regular sessions. There are some privacy concerns.
2948         Also, some of the WebsiteDataStore informations are passed via WebProcessCreationParameters (e.g.
2949         ApplicationCache path) and cannot be updated later.
2950
2951         There were 2 cases where this could happen and that are fixed in the patch:
2952         - A process may be prewarmed with a given website data store and then later on used for a page
2953           associated with a different data store. We now prevent this. While this is not necessary for
2954           privacy reasons, it is still useful because our code currently does not support well uses
2955           different sessions inside a single WebProcess, as mentioned above.
2956         - The client can force a WebsiteDataStore swap when responding to the decidePolicyForNavigationAction,
2957           via the WebsitePolicies. To address the issue, we now force a process swap whenever the client
2958           makes such a change.
2959
2960         As a result, WebProcessProxy::websiteDataStore() now makes sense and is always correct. It can
2961         also only contains pages whose WebPageProxy::websiteDataStore() returns the same store.
2962
2963         * UIProcess/API/C/WKContext.cpp:
2964         (WKContextWarmInitialProcess):
2965         * UIProcess/API/Cocoa/WKProcessPool.mm:
2966         (-[WKProcessPool _warmInitialProcess]):
2967         * UIProcess/ProvisionalPageProxy.cpp:
2968         (WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
2969         (WebKit::ProvisionalPageProxy::~ProvisionalPageProxy):
2970         * UIProcess/WebPageProxy.cpp:
2971         (WebKit::WebPageProxy::notifyProcessPoolToPrewarm):
2972         (WebKit::WebPageProxy::reattachToWebProcess):
2973         (WebKit::WebPageProxy::swapToWebProcess):
2974         (WebKit::WebPageProxy::close):
2975         (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
2976         (WebKit::WebPageProxy::commitProvisionalPage):
2977         (WebKit::WebPageProxy::creationParameters):
2978         * UIProcess/WebPageProxy.h:
2979         (WebKit::WebPageProxy::websiteDataStore):
2980         * UIProcess/WebProcessPool.cpp:
2981         (WebKit::WebProcessPool::ensureNetworkProcess):
2982         (WebKit::WebProcessPool::tryTakePrewarmedProcess):
2983         (WebKit::WebProcessPool::prewarmProcess):
2984         (WebKit::WebProcessPool::createWebPage):
2985         (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
2986         (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore):
2987         (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
2988         (WebKit::WebProcessPool::processForNavigation):
2989         (WebKit::WebProcessPool::processForNavigationInternal):
2990         (WebKit::WebProcessPool::findReusableSuspendedPageProcess):
2991         * UIProcess/WebProcessPool.h:
2992         (WebKit::WebProcessPool::sendToOneProcess):
2993         * UIProcess/WebProcessProxy.cpp:
2994         (WebKit::WebProcessProxy::createWebPage):
2995         (WebKit::WebProcessProxy::addExistingWebPage):
2996         (WebKit::WebProcessProxy::removeWebPage):
2997         * UIProcess/WebProcessProxy.h:
2998
2999 2019-03-04  Chris Dumez  <cdumez@apple.com>
3000
3001         [iOS] Improve our file picker
3002         https://bugs.webkit.org/show_bug.cgi?id=195284
3003         <rdar://problem/45655856>
3004
3005         Reviewed by Tim Horton and Wenson Hsieh.
3006
3007         Improve our file picker on iOS so that:
3008         - Accepted file extensions specified in the HTML (e.g. <input type="file"> accept=".pdf">) are now
3009           properly reflected in the file picker. Previously, we only we only supported MIME types in the
3010           accept attribute that only Image / Video ones.
3011         - If accepted types are specified in the HTML and not of them are Video or Image types, then bypass
3012           the UIDocumentMenuViewController and show the file picker directly (as if the user had tapped on
3013           "Browse..." on that menu). Other menu items such as "Take Photo or Video" and "Photo Library" do
3014           not make sense if the page only accepts PDF files for example.
3015
3016         Things that we should do but are not fixed in this patch:
3017         - Stop using UIDocumentMenuViewController entirely since it was deprecated in favor of using
3018           UIDocumentPickerViewController directly.
3019         - Add multiple selection support, which is supported both on the HTML side and in the
3020           UIDocumentPickerViewController API.
3021
3022         * UIProcess/ios/forms/WKFileUploadPanel.mm:
3023         (arrayContainsUTIThatConformsTo):
3024         (-[WKFileUploadPanel dealloc]):
3025         (-[WKFileUploadPanel presentWithParameters:resultListener:]):
3026         (UTIsForMIMETypes):
3027         (-[WKFileUploadPanel _mediaTypesForPickerSourceType:]):
3028         (-[WKFileUploadPanel _cameraButtonLabelAllowingPhoto:allowingVideo:]):
3029         (-[WKFileUploadPanel _showDocumentPickerMenu]):
3030
3031 2019-03-04  Alex Christensen  <achristensen@webkit.org>
3032
3033         REGRESSION: ( r240978-r240985 ) [ iOS Release ] Layout Test imported/w3c/web-platform-tests/xhr/send-redirect-post-upload.htm is crashing
3034         https://bugs.webkit.org/show_bug.cgi?id=194523
3035
3036         Reviewed by Ryosuke Niwa.
3037
3038         Attempt to work around a CFNetwork bug in the timing of tearing down tasks with upload streams.
3039         See rdar://problem/28233746.
3040
3041         * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
3042         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
3043         (WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
3044         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
3045         (-[WKNetworkSessionDelegate URLSession:task:needNewBodyStream:]):
3046
3047 2019-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
3048
3049         [CoordinatedGraphics] The compositing loop is still running even after exiting AC mode
3050         https://bugs.webkit.org/show_bug.cgi?id=195270
3051
3052         Reviewed by Don Olmstead.
3053
3054         Suspend the threaded compositor when the painting is paused or layer flush disabled, and resume it again when
3055         painting is resumed and layer flush enabled.
3056
3057         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
3058         (WebKit::ThreadedCompositor::suspend): Increment the suspend counter and mark the scene as inactive if it was suspended.
3059         (WebKit::ThreadedCompositor::resume): Decrement the suspend counter and mark the scene as active if it's now resumed.
3060         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
3061         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
3062         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaint): Return early if layer tree state is frozen.
3063         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaintAsync): Ditto.
3064         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
3065         (WebKit::LayerTreeHost::setLayerFlushSchedulingEnabled): Call ThreadedCompositor::suspend()/resume().
3066         (WebKit::LayerTreeHost::pauseRendering): Call ThreadedCompositor::suspend.
3067         (WebKit::LayerTreeHost::resumeRendering): Call ThreadedCompositor::resume().
3068
3069 2019-03-04  Simon Fraser  <simon.fraser@apple.com>
3070
3071         Share more code between overflow and frame scrolling nodes, fixing overflow scrollbar display
3072         https://bugs.webkit.org/show_bug.cgi?id=195258
3073
3074         Reviewed by Antti Koivisto.
3075
3076         This patch moves management of scrollbar layers and scrollbar painters ("NSScrollerImp") down to
3077         ScrollingStateScrollingNode to be shared between frame and overflow nodes, allowing for
3078         scrolling thread updates of overflow scrollbars. It also moves some scrolling tree-side code
3079         to ScrollingTreeScrollingNodeDelegateMac to be shared between the "tree" nodes for overflow and frames.
3080
3081         Layers for scrollbars are given to scrolling state nodes via setNodeLayers() now, and
3082         RenderLayerCompositor::updateScrollingNodeLayers() is added to provide a bottleneck to call that.
3083         At some point AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange() should be relieved
3084         of the responsibility of pushing scrollbar layers (but the scrolling state tree needs to hold
3085         references to GraphicsLayers before that becomes safe).
3086         
3087         The actual fix that allows overflow scrollbars to show is the change in
3088         AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange() that calls scrollableArea.*ScrollbarLayerDidChange()
3089         for all ScrollableAreas. This ensures that the CALayer is pushed onto the NSScrollerImp.
3090
3091         * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
3092         (ArgumentCoder<ScrollingStateScrollingNode>::encode):
3093         (ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
3094         (ArgumentCoder<ScrollingStateScrollingNode>::decode):
3095         (ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):
3096         * SourcesCocoa.txt:
3097         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
3098         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
3099         * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
3100         (WebKit::RemoteScrollingTree::createScrollingTreeNode):
3101         * UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp:
3102         (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::commitStateBeforeChildren):
3103         (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::repositionRelatedLayers):
3104         (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::handleMouseEvent):
3105         * UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp: Copied from Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp.
3106         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::create):
3107         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::ScrollingTreeOverflowScrollingNodeRemoteMac):
3108         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::~ScrollingTreeOverflowScrollingNodeRemoteMac):
3109         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::commitStateBeforeChildren):
3110         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::repositionRelatedLayers):
3111         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::handleWheelEvent):
3112         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::handleMouseEvent):
3113         * WebKit.xcodeproj/project.pbxproj:
3114
3115 2019-03-04  Andy Estes  <aestes@apple.com>
3116
3117         [Apple Pay] Move WebPaymentCoordinatorProxy from Source/WebKit/UIProcess to Source/WebKit/Shared
3118         https://bugs.webkit.org/show_bug.cgi?id=195080
3119         <rdar://problem/48421558>
3120
3121         Reviewed by Antti Koivisto.
3122
3123         * CMakeLists.txt:
3124         * DerivedSources-input.xcfilelist:
3125         * DerivedSources.make:
3126         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp: Renamed from Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp.
3127         * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Renamed from Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h.
3128         * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Renamed from Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in.
3129         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h: Renamed from Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h.
3130         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: Renamed from Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm.
3131         * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm: Renamed from Source/WebKit/UIProcess/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm.
3132         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm: Renamed from Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm.
3133         * Shared/mac/WebHitTestResultData.mm:
3134         * SourcesCocoa.txt:
3135         * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h:
3136         * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
3137         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
3138         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
3139         * WebKit.xcodeproj/project.pbxproj:
3140
3141 2019-03-04  Jer Noble  <jer.noble@apple.com>
3142
3143         [iOS] Fullscreen "stay in page" option breaks video playback
3144         https://bugs.webkit.org/show_bug.cgi?id=195277
3145         <rdar://problem/48537317>
3146
3147         Reviewed by Eric Carlson.
3148
3149         Make sure we resume media playback when the user chooses "stay in page" from the deceptive
3150         website warning dialog.
3151
3152         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
3153         (-[WKFullScreenViewController _showPhishingAlert]):
3154
3155 2019-03-04  Michael Catanzaro  <mcatanzaro@igalia.com>
3156
3157         [WPE] Enable web process sandbox
3158         https://bugs.webkit.org/show_bug.cgi?id=195169
3159
3160         Reviewed by Daniel Bates.
3161
3162         * PlatformWPE.cmake:
3163         * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
3164         (WebKit::bubblewrapSpawn):
3165         * UIProcess/glib/WebProcessPoolGLib.cpp:
3166         (WebKit::WebProcessPool::platformInitialize):
3167
3168 2019-03-04  Adrian Perez de Castro  <aperez@igalia.com>
3169
3170         [GTK][WPE] Wrong license header in WebKit{,WebExtension}Autocleanups.h
3171         https://bugs.webkit.org/show_bug.cgi?id=195245
3172
3173         Reviewed by Carlos Garcia Campos.
3174
3175         Changed license headers to contain the LGPL, which is the correct one for the GTK
3176         and WPE ports. The change was agreed by the contributors to the files involved.
3177
3178         * UIProcess/API/gtk/WebKitAutocleanups.h:
3179         * UIProcess/API/wpe/WebKitAutocleanups.h:
3180         * WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionAutocleanups.h:
3181         * WebProcess/InjectedBundle/API/wpe/WebKitWebExtensionAutocleanups.h:
3182
3183 2019-03-04  Commit Queue  <commit-queue@webkit.org>
3184
3185         Unreviewed, rolling out r242045.
3186         https://bugs.webkit.org/show_bug.cgi?id=195273
3187
3188         WE not ready to enable PSON yet (Requested by KaL on #webkit).
3189
3190         Reverted changeset:
3191
3192         "[GTK] Enable PSON"
3193         https://bugs.webkit.org/show_bug.cgi?id=194979
3194         https://trac.webkit.org/changeset/242045
3195
3196 2019-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
3197
3198         [CoordinatedGraphics] Unify DrawingArea classes
3199         https://bugs.webkit.org/show_bug.cgi?id=195167
3200
3201         Reviewed by Žan Doberšek.
3202
3203         Add DrawingAreaProxyCoordinatedGraphics and DrawingAreaCoordinatedGraphics.
3204
3205         * PlatformGTK.cmake:
3206         * PlatformWPE.cmake:
3207         * PlatformWin.cmake:
3208         * Shared/DrawingAreaInfo.h:
3209         * SourcesGTK.txt:
3210         * SourcesWPE.txt:
3211         * UIProcess/API/gtk/PageClientImpl.cpp:
3212         (WebKit::PageClientImpl::createDrawingAreaProxy):
3213         (WebKit::PageClientImpl::viewSize):
3214         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
3215         (webkitWebViewBaseRealize):
3216         (webkitWebViewBaseUnrealize):
3217         (webkitWebViewBaseDraw):
3218         (webkitWebViewBaseSizeAllocate):
3219         (webkitWebViewBaseDidRelaunchWebProcess):
3220         (webkitWebViewBasePageClosed):
3221         * UIProcess/API/wpe/PageClientImpl.cpp:
3222         (WebKit::PageClientImpl::createDrawingAreaProxy):
3223         * UIProcess/AcceleratedDrawingAreaProxy.cpp: Removed.
3224         * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp: Added.
3225         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingAreaProxyCoordinatedGraphics):
3226         (WebKit::DrawingAreaProxyCoordinatedGraphics::~DrawingAreaProxyCoordinatedGraphics):
3227         (WebKit::DrawingAreaProxyCoordinatedGraphics::paint):
3228         (WebKit::DrawingAreaProxyCoordinatedGraphics::sizeDidChange):
3229         (WebKit::DrawingAreaProxyCoordinatedGraphics::deviceScaleFactorDidChange):
3230         (WebKit::DrawingAreaProxyCoordinatedGraphics::waitForBackingStoreUpdateOnNextPaint):
3231         (WebKit::DrawingAreaProxyCoordinatedGraphics::setBackingStoreIsDiscardable):
3232         (WebKit::DrawingAreaProxyCoordinatedGraphics::update):
3233         (WebKit::DrawingAreaProxyCoordinatedGraphics::didUpdateBackingStoreState):
3234         (WebKit::DrawingAreaProxyCoordinatedGraphics::enterAcceleratedCompositingMode):
3235         (WebKit::DrawingAreaProxyCoordinatedGraphics::exitAcceleratedCompositingMode):
3236         (WebKit::DrawingAreaProxyCoordinatedGraphics::updateAcceleratedCompositingMode):
3237         (WebKit::DrawingAreaProxyCoordinatedGraphics::incorporateUpdate):
3238         (WebKit::DrawingAreaProxyCoordinatedGraphics::alwaysUseCompositing const):
3239         (WebKit::DrawingAreaProxyCoordinatedGraphics::backingStoreStateDidChange):
3240         (WebKit::DrawingAreaProxyCoordinatedGraphics::sendUpdateBackingStoreState):
3241         (WebKit::DrawingAreaProxyCoordinatedGraphics::waitForAndDispatchDidUpdateBackingStoreState):
3242         (WebKit::DrawingAreaProxyCoordinatedGraphics::discardBackingStoreSoon):
3243         (WebKit::DrawingAreaProxyCoordinatedGraphics::discardBackingStore):
3244         (WebKit::DrawingAreaProxyCoordinatedGraphics::setNativeSurfaceHandleForCompositing):
3245         (WebKit::DrawingAreaProxyCoordinatedGraphics::destroyNativeSurfaceHandleForCompositing):
3246         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::DrawingMonitor):
3247         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::~DrawingMonitor):
3248         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::webViewDrawCallback):
3249         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start):
3250         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::stop):
3251         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::didDraw):
3252         (WebKit::DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing):
3253         * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h: Renamed from Source/WebKit/UIProcess/AcceleratedDrawingAreaProxy.h.
3254         * UIProcess/DrawingAreaProxyImpl.cpp: Removed.
3255         * UIProcess/DrawingAreaProxyImpl.h: Removed.
3256         * UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
3257         (WebKit::AcceleratedBackingStoreX11::update):
3258         * UIProcess/win/PageClientImpl.cpp:
3259         (WebKit::PageClientImpl::createDrawingAreaProxy):
3260         * UIProcess/win/WebView.cpp:
3261         (WebKit::WebView::paint):
3262         * WebProcess/WebPage/AcceleratedDrawingArea.cpp: Removed.
3263         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp: Added.
3264         (WebKit::DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics):
3265         (WebKit::DrawingAreaCoordinatedGraphics::~DrawingAreaCoordinatedGraphics):
3266         (WebKit::DrawingAreaCoordinatedGraphics::setNeedsDisplay):
3267         (WebKit::DrawingAreaCoordinatedGraphics::setNeedsDisplayInRect):
3268         (WebKit::DrawingAreaCoordinatedGraphics::scroll):
3269         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaint):
3270         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaintAsync):
3271         (WebKit::DrawingAreaCoordinatedGraphics::setLayerTreeStateIsFrozen):
3272         (WebKit::DrawingAreaCoordinatedGraphics::updatePreferences):
3273         (WebKit::DrawingAreaCoordinatedGraphics::mainFrameContentSizeChanged):
3274         (WebKit::DrawingAreaCoordinatedGraphics::deviceOrPageScaleFactorChanged):
3275         (WebKit::DrawingAreaCoordinatedGraphics::didChangeViewportAttributes):
3276         (WebKit::DrawingAreaCoordinatedGraphics::graphicsLayerFactory):
3277         (WebKit::DrawingAreaCoordinatedGraphics::setRootCompositingLayer):
3278         (WebKit::DrawingAreaCoordinatedGraphics::scheduleCompositingLayerFlush):
3279         (WebKit::DrawingAreaCoordinatedGraphics::layerHostDidFlushLayers):
3280         (WebKit::DrawingAreaCoordinatedGraphics::createDisplayRefreshMonitor):
3281         (WebKit::DrawingAreaCoordinatedGraphics::setNativeSurfaceHandleForCompositing):
3282         (WebKit::DrawingAreaCoordinatedGraphics::destroyNativeSurfaceHandleForCompositing):
3283         (WebKit::DrawingAreaCoordinatedGraphics::activityStateDidChange):
3284         (WebKit::DrawingAreaCoordinatedGraphics::attachViewOverlayGraphicsLayer):
3285         (WebKit::DrawingAreaCoordinatedGraphics::updateBackingStoreState):
3286         (WebKit::DrawingAreaCoordinatedGraphics::didUpdate):
3287         (WebKit::DrawingAreaCoordinatedGraphics::sendDidUpdateBackingStoreState):
3288         (WebKit::DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingModeSoon):
3289         (WebKit::DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingModeNow):
3290         (WebKit::DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost):
3291         (WebKit::DrawingAreaCoordinatedGraphics::suspendPainting):
3292         (WebKit::DrawingAreaCoordinatedGraphics::resumePainting):
3293         (WebKit::DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode):
3294         (WebKit::DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingMode):
3295         (WebKit::DrawingAreaCoordinatedGraphics::scheduleDisplay):
3296         (WebKit::DrawingAreaCoordinatedGraphics::displayTimerFired):
3297         (WebKit::DrawingAreaCoordinatedGraphics::display):
3298         (WebKit::shouldPaintBoundsRect):
3299         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h: Renamed from Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h.
3300         * WebProcess/WebPage/DrawingArea.cpp:
3301         (WebKit::DrawingArea::create):
3302         * WebProcess/WebPage/DrawingArea.h:
3303         (WebKit::DrawingArea::layerFlushThrottlingIsActive const):
3304         * WebProcess/WebPage/DrawingAreaImpl.cpp: Removed.
3305         * WebProcess/WebPage/DrawingAreaImpl.h: Removed.
3306
3307 2019-03-03  Zalan Bujtas  <zalan@apple.com>
3308
3309         [ContentChangeObserver] Content observation should be limited to the current document.
3310         https://bugs.webkit.org/show_bug.cgi?id=195256
3311         <rdar://problem/48544402>
3312
3313         Reviewed by Simon Fraser.
3314
3315         * WebProcess/WebPage/WebPage.h:
3316         * WebProcess/WebPage/ios/WebPageIOS.mm:
3317         (WebKit::WebPage::handleSyntheticClick):
3318         (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
3319         (WebKit::WebPage::completeSyntheticClick):
3320         (WebKit::WebPage::handleTap):
3321         (WebKit::WebPage::handleTwoFingerTapAtPoint):
3322         (WebKit::WebPage::commitPotentialTap):
3323
3324 2019-03-03  Tim Horton  <timothy_horton@apple.com>
3325
3326         Rid the world of WK_API_ENABLED
3327         https://bugs.webkit.org/show_bug.cgi?id=195263
3328
3329         Reviewed by Dan Bernstein.
3330
3331         List of changed files elided because it's useless.
3332
3333 2019-03-03  Jiewen Tan  <jiewen_tan@apple.com>
3334
3335         Add a WebViewDidMoveToWindowObserver for WKWebView
3336         https://bugs.webkit.org/show_bug.cgi?id=195223
3337         <rdar://problem/48520161>
3338
3339         Reviewed by Darin Adler.
3340
3341         The load optimizer would only allow itself to optimize loads whenever the web view
3342         who owns the page is (visible && focused), otherwises it will wait until the web view
3343         becomes (visible && focused). Therefore, we need a way to notify the load optimizer
3344         changes of statuses.
3345
3346         * UIProcess/API/Cocoa/WKWebView.mm:
3347         (-[WKWebView didMoveToWindow]):
3348         * UIProcess/Cocoa/WebViewImpl.mm:
3349         (WebKit::WebViewImpl::viewDidMoveToWindow):