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