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