44ebe141a21d969570e6f01c9efee99c9a9eb179
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2019-05-14  Ross Kirsling  <ross.kirsling@sony.com>
2
3         Unreviewed restoration of non-unified build.
4
5         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
6         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
7         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
8         * UIProcess/WebProcessProxy.cpp:
9
10 2019-05-14  Youenn Fablet  <youenn@apple.com>
11
12         A service worker process should app nap when all its clients app nap
13         https://bugs.webkit.org/show_bug.cgi?id=185626
14         <rdar://problem/46785908>
15
16         Reviewed by Alex Christensen.
17
18         Compute whether a given web process can be throttled on every page throttling change.
19         Send that information to network process which stores that information in WebSWServerConnection.
20         Every WebSWServerToContextConnection throttle state is then computed based on all WebSWServerConnection
21         that have a client that matches the registrable domain of the context connection.
22
23         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
24         (WebKit::WebSWServerConnection::registerServiceWorkerClient):
25         (WebKit::WebSWServerConnection::unregisterServiceWorkerClient):
26         (WebKit::WebSWServerConnection::hasMatchingClient const):
27         (WebKit::WebSWServerConnection::computeThrottleState const):
28         (WebKit::WebSWServerConnection::setThrottleState):
29         (WebKit::WebSWServerConnection::updateThrottleState):
30         (WebKit::WebSWServerConnection::serverToContextConnectionCreated):
31         * NetworkProcess/ServiceWorker/WebSWServerConnection.h:
32         (WebKit::WebSWServerConnection::isThrottleable const):
33         * NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in:
34         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
35         (WebKit::WebSWServerToContextConnection::setThrottleState):
36         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
37         (WebKit::WebSWServerToContextConnection::isThrottleable const):
38         * UIProcess/ServiceWorkerProcessProxy.cpp:
39         * UIProcess/ServiceWorkerProcessProxy.h:
40         * WebProcess/Storage/WebSWClientConnection.cpp:
41         (WebKit::WebSWClientConnection::WebSWClientConnection):
42         (WebKit::WebSWClientConnection::updateThrottleState):
43         * WebProcess/Storage/WebSWClientConnection.h:
44         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
45         (WebKit::WebSWContextManagerConnection::setThrottleState):
46         (WebKit::WebSWContextManagerConnection::isThrottleable const):
47         * WebProcess/Storage/WebSWContextManagerConnection.h:
48         * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
49         * WebProcess/WebPage/WebPage.cpp:
50         (WebKit::WebPage::updateUserActivity):
51         (WebKit::WebPage::isThrottleable const):
52         * WebProcess/WebPage/WebPage.h:
53         * WebProcess/WebProcess.cpp:
54         (WebKit::WebProcess::arePagesThrottleable const):
55         * WebProcess/WebProcess.h:
56
57 2019-05-14  Chris Dumez  <cdumez@apple.com>
58
59         Crash under WebKit::WebProcessProxy::didBecomeUnresponsive()
60         https://bugs.webkit.org/show_bug.cgi?id=197883
61         <rdar://problem/50665984>
62
63         Reviewed by Alex Christensen.
64
65         Protect |this| in didBecomeUnresponsive() and didExceedCPULimit() since we call client
66         delegates and those may cause |this| to get destroyed.
67
68         * UIProcess/WebProcessProxy.cpp:
69         (WebKit::WebProcessProxy::didBecomeUnresponsive):
70         (WebKit::WebProcessProxy::didExceedCPULimit):
71
72 2019-05-14  Chris Dumez  <cdumez@apple.com>
73
74         The network process tries to take a process assertion when NetworkProcess::processWillSuspendImminently() is called
75         https://bugs.webkit.org/show_bug.cgi?id=197888
76
77         Reviewed by Geoffrey Garen.
78
79         When actualPrepareToSuspend() in the Network process is called set the 'IsSuspended' flag on the SQLite database tracker and unset
80         the flag when the process resume. This is consistent with what we already do in the WebProcess and makes sure that
81         the network process does not try and take on a new assertion due to locked files when getting notified it is about to get
82         suspended.
83
84         * NetworkProcess/NetworkProcess.cpp:
85         (WebKit::NetworkProcess::actualPrepareToSuspend):
86         (WebKit::NetworkProcess::processWillSuspendImminently):
87         (WebKit::NetworkProcess::resume):
88
89 2019-05-14  Chris Dumez  <cdumez@apple.com>
90
91         Update TBA macros for API / SPI that has already shipped
92         https://bugs.webkit.org/show_bug.cgi?id=197841
93         <rdar://problem/50698499>
94
95         Reviewed by Geoffrey Garen.
96
97         * Configurations/WebKit.xcconfig:
98         Disable header postprocessing when building for macOS Mojave
99
100         * Shared/API/Cocoa/_WKRenderingProgressEvents.h:
101         * UIProcess/API/C/WKPage.h:
102         * UIProcess/API/Cocoa/WKBackForwardListItemPrivate.h:
103         * UIProcess/API/Cocoa/WKBrowsingContextController.h:
104         * UIProcess/API/Cocoa/WKBrowsingContextGroup.h:
105         * UIProcess/API/Cocoa/WKBrowsingContextHistoryDelegate.h:
106         * UIProcess/API/Cocoa/WKBrowsingContextLoadDelegate.h:
107         * UIProcess/API/Cocoa/WKBrowsingContextPolicyDelegate.h:
108         * UIProcess/API/Cocoa/WKConnection.h:
109         * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
110         * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
111         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
112         * UIProcess/API/Cocoa/WKProcessGroup.h:
113         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
114         * UIProcess/API/Cocoa/WKTypeRefWrapper.h:
115         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
116         * UIProcess/API/Cocoa/WKView.h:
117         (WK_CLASS_DEPRECATED_WITH_REPLACEMENT):
118         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
119         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
120         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
121         * UIProcess/API/Cocoa/_WKAttachment.h:
122         * UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.h:
123         * UIProcess/API/Cocoa/_WKDownload.h:
124         * UIProcess/API/Cocoa/_WKFormInputSession.h:
125         * UIProcess/API/Cocoa/_WKInspector.h:
126         * UIProcess/API/Cocoa/_WKInternalDebugFeature.h:
127         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
128         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
129         * UIProcess/API/Cocoa/_WKWebsitePolicies.h:
130         * WebProcess/API/Cocoa/WKWebProcess.h:
131         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.h:
132         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h:
133
134 2019-05-14  Commit Queue  <commit-queue@webkit.org>
135
136         Unreviewed, rolling out r245281.
137         https://bugs.webkit.org/show_bug.cgi?id=197887
138
139         Broke API Test TestWebKitAPI.Challenge.ClientCertificate
140         (Requested by aakashjain on #webkit).
141
142         Reverted changeset:
143
144         "Add a unit test for client certificate authentication"
145         https://bugs.webkit.org/show_bug.cgi?id=197800
146         https://trac.webkit.org/changeset/245281
147
148 2019-05-14  Daniel Bates  <dabates@apple.com>
149
150         [iOS] Cannot scroll to beginning of document after scrolling to end of document and vice versa via key commands
151         https://bugs.webkit.org/show_bug.cgi?id=197848
152         <rdar://problem/49523065>
153
154         Reviewed by Brent Fulgham.
155
156         Following the fix for <rdar://problem/49523065>, UIKit no longer emits a keyup event for a Command-
157         modified key. This breaks WebKit's own implementation of key command handling for scrolling to the
158         beginning or end of the document (triggered using Command + Arrow Up and Command + Arrow Down,
159         respectively) because it watches for keyup events to reset state after initiating a scroll. If state
160         is not reset then the scroll key command logic becomes confused and may not perform a subsequent scroll.
161         It seems like we can actually get away with supporting these key commands and future Command modified
162         commands by preemptively reseting state on keydown if the Command modifier is held down. If this does
163         not work out then we can do something more complicated.
164
165         * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
166         (-[WKKeyboardScrollingAnimator handleKeyEvent:]):
167
168 2019-05-14  Brent Fulgham  <bfulgham@apple.com>
169
170         Protect current WebFrame during form submission
171         https://bugs.webkit.org/show_bug.cgi?id=197459
172         <rdar://problem/50368618>
173
174         Reviewed by Alex Christensen.
175
176         The 'continueWillSubmitForm' method calls a completion handler that
177         might affect the state of the current frame. Ensure the frame is valid
178         for the scope of the function.
179
180         * WebProcess/WebPage/WebFrame.cpp:
181         (WebKit::WebFrame::continueWillSubmitForm):
182
183 2019-05-14  Daniel Bates  <dabates@apple.com>
184
185         [iOS] Cannot tab or shift + tab out of address bar on google.com
186         https://bugs.webkit.org/show_bug.cgi?id=197859
187         <rdar://problem/46651565>
188
189         Reviewed by Darin Adler.
190
191         Non-editable elements can participate in tab cycling via the HTML tabindex attribute.
192         We should allow setting the initial focus to such an element when transitioning from
193         the chrome (e.g. address bar) to the web page.
194
195         * UIProcess/ios/WKContentViewInteraction.mm:
196         (-[WKContentView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]):
197
198 2019-05-14  Alex Christensen  <achristensen@webkit.org>
199
200         Add a unit test for client certificate authentication
201         https://bugs.webkit.org/show_bug.cgi?id=197800
202
203         Reviewed by Youenn Fablet.
204
205         * Shared/cf/ArgumentCodersCF.cpp:
206         Move SPI declarations to SecuritySPI.h.
207
208 2019-05-13  Wenson Hsieh  <wenson_hsieh@apple.com>
209
210         Followup to r245267: fix some more deprecated uses of -[UIApplication interfaceOrientation]
211         https://bugs.webkit.org/show_bug.cgi?id=197867
212         <rdar://problem/50743963>
213
214         Reviewed by Simon Fraser.
215
216         Add a helper method on WKContentView that asks the view's window's scene for an interface orientation; then,
217         use this helper from various places in WebKit instead of invoking -[UIApplication interfaceOrientation]
218         directly. No change in behavior.
219
220         * UIProcess/ios/WKContentView.h:
221         * UIProcess/ios/WKContentView.mm:
222         (-[WKContentView interfaceOrientation]):
223         * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
224         (-[WKDataListSuggestionsPicker initWithInformation:inView:]):
225         * UIProcess/ios/forms/WKFormColorPicker.mm:
226         (-[WKColorPicker initWithView:]):
227         * UIProcess/ios/forms/WKFormInputControl.mm:
228         (-[WKDateTimePicker initWithView:datePickerMode:]):
229         * UIProcess/ios/forms/WKFormSelectPicker.mm:
230         (-[WKMultipleSelectPicker initWithView:]):
231         * UIProcess/ios/forms/WKFormSelectPopover.mm:
232         (-[WKSelectPopover initWithView:hasGroups:]):
233
234 2019-05-13  Wenson Hsieh  <wenson_hsieh@apple.com>
235
236         [iOS] When running layout tests that tap in the same location, subsequent tests fail to fire click handlers
237         https://bugs.webkit.org/show_bug.cgi?id=197821
238         <rdar://problem/50700512>
239
240         Reviewed by Tim Horton.
241
242         After r244775, when running back-to-back layout tests on iOS that simulate taps in the same location, the double
243         tap gesture recognizer for recognizing double clicks ends up recognizing instead of the single tap gesture
244         recognizer in the subsequent test. This means that click handlers in the subsequent test will fail to recognize,
245         unless the element with the click handler is also accompanied by a dblclick handler.
246
247         To avoid this, we reset the double click gesture recognizer when navigating; this has the additional effect of
248         making it such that the second page doesn't end up observing a dblclick when the first click was only sent to
249         the first page.
250
251         * UIProcess/ios/PageClientImplIOS.mm:
252         (WebKit::PageClientImpl::didStartProvisionalLoadForMainFrame):
253         * UIProcess/ios/WKContentViewInteraction.h:
254         * UIProcess/ios/WKContentViewInteraction.mm:
255         (-[WKContentView setupInteraction]):
256         (-[WKContentView _didStartProvisionalLoadForMainFrame]):
257
258 2019-05-13  Wenson Hsieh  <wenson_hsieh@apple.com>
259
260         Unreviewed, fix some deprecation warnings when using a recent SDK
261
262         * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
263         (-[WKDataListSuggestionsPicker initWithInformation:inView:]):
264
265 2019-05-13  Jiewen Tan  <jiewen_tan@apple.com>
266
267         [WebAuthN] InvalidStateError should be reported to sites
268         https://bugs.webkit.org/show_bug.cgi?id=193269
269         <rdar://problem/48298264>
270
271         Reviewed by Brent Fulgham.
272
273         This patch implements step 20 about InvalidStateError of the spec:
274         https://www.w3.org/TR/webauthn/#createCredential.
275
276         * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
277         (WebKit::AuthenticatorManager::respondReceived):
278         * UIProcess/WebAuthentication/fido/CtapHidAuthenticator.cpp:
279         (WebKit::CtapHidAuthenticator::continueMakeCredentialAfterResponseReceived const):
280
281 2019-05-13  Jer Noble  <jer.noble@apple.com>
282
283         Take out MediaPlayback UI assertion when any WebProcess is playing audible media
284         https://bugs.webkit.org/show_bug.cgi?id=197798
285
286         Reviewed by Chris Dumez.
287
288         To keep the system from suspending the UIProcess (and all the other constellation of processes that
289         are necessary to play media), take a UIProcess assertion with the MediaPlayback reason whenever there
290         is a WebContent process that is playing audible media.
291
292         * Platform/spi/ios/AssertionServicesSPI.h:
293         * UIProcess/ProcessAssertion.h:
294         * UIProcess/WebPageProxy.cpp:
295         (WebKit::WebPageProxy::updatePlayingMediaDidChange):
296         * UIProcess/WebProcessPool.cpp:
297         (WebKit::WebProcessPool::setWebProcessIsPlayingAudibleMedia):
298         (WebKit::WebProcessPool::clearWebProcessIsPlayingAudibleMedia):
299         * UIProcess/WebProcessPool.h:
300         * UIProcess/WebProcessProxy.cpp:
301         (WebKit::WebProcessProxy::webPageMediaStateDidChange):
302         * UIProcess/WebProcessProxy.h:
303         * UIProcess/ios/ProcessAssertionIOS.mm:
304         (WebKit::toBKSProcessAssertionReason):
305         (WebKit::ProcessAssertion::ProcessAssertion):
306         * WebProcess/WebProcess.h:
307
308 2019-05-13  Per Arne Vollan  <pvollan@apple.com>
309
310         [iOS] Crash when trying to QuickLook
311         https://bugs.webkit.org/show_bug.cgi?id=197853
312         <rdar://problem/49795964>
313
314         Reviewed by Brent Fulgham.
315
316         This is caused by a syscall sandbox violation.
317
318         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
319
320 2019-05-13  Brent Fulgham  <bfulgham@apple.com>
321
322         Correct the sandbox to allow loading libraries from /Library/Apple 
323         https://bugs.webkit.org/show_bug.cgi?id=197844
324
325         Reviewed by Per Arne Vollan.
326
327         Grant access to '/Library/Apple' as an appropriate place to load
328         system frameworks.
329
330         * WebProcess/com.apple.WebProcess.sb.in:
331
332 2019-05-13  Chris Dumez  <cdumez@apple.com>
333
334         Unreviewed, rolling out r245240.
335
336         Broke the build
337
338         Reverted changeset:
339
340         "Update TBA macros for API / SPI that has already shipped"
341         https://bugs.webkit.org/show_bug.cgi?id=197841
342         https://trac.webkit.org/changeset/245240
343
344 2019-05-13  Youenn Fablet  <youenn@apple.com>
345
346         Use kDNSServiceFlagsKnownUnique for DNSServiceRegisterRecord only on platforms supporting it
347         https://bugs.webkit.org/show_bug.cgi?id=197802
348
349         Reviewed by Eric Carlson.
350
351         * NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
352         (WebKit::NetworkMDNSRegister::registerMDNSName):
353
354 2019-05-13  Don Olmstead  <don.olmstead@sony.com>
355
356         decidePolicyForInstallMissingMediaPluginsPermissionRequest requires GStreamer
357         https://bugs.webkit.org/show_bug.cgi?id=197843
358
359         Reviewed by Alex Christensen.
360
361         * UIProcess/API/wpe/PageClientImpl.cpp:
362         ENABLE(VIDEO) && USE(GSTREAMER)
363         * UIProcess/WebPageProxy.h:
364         Cleanup the declaration.
365
366 2019-05-13  Don Olmstead  <don.olmstead@sony.com>
367
368         Move StorageManager.cpp into WebKit/Sources.txt
369         https://bugs.webkit.org/show_bug.cgi?id=197842
370
371         Reviewed by Michael Catanzaro.
372
373         StorageManager.cpp is used by all ports so it should just go into Sources.txt.
374
375         * PlatformMac.cmake:
376         * PlatformWin.cmake:
377         * Sources.txt:
378         * SourcesCocoa.txt:
379         * SourcesGTK.txt:
380         * SourcesWPE.txt:
381
382 2019-05-13  Chris Dumez  <cdumez@apple.com>
383
384         Update TBA macros for API / SPI that has already shipped
385         https://bugs.webkit.org/show_bug.cgi?id=197841
386         <rdar://problem/50698499>
387
388         Reviewed by Alex Christensen.
389
390         * Shared/API/Cocoa/_WKRenderingProgressEvents.h:
391         * UIProcess/API/C/WKPage.h:
392         * UIProcess/API/Cocoa/WKBackForwardListItemPrivate.h:
393         * UIProcess/API/Cocoa/WKBrowsingContextController.h:
394         * UIProcess/API/Cocoa/WKBrowsingContextGroup.h:
395         * UIProcess/API/Cocoa/WKBrowsingContextHistoryDelegate.h:
396         * UIProcess/API/Cocoa/WKBrowsingContextLoadDelegate.h:
397         * UIProcess/API/Cocoa/WKBrowsingContextPolicyDelegate.h:
398         * UIProcess/API/Cocoa/WKConnection.h:
399         * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
400         * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
401         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
402         * UIProcess/API/Cocoa/WKProcessGroup.h:
403         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
404         * UIProcess/API/Cocoa/WKTypeRefWrapper.h:
405         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
406         * UIProcess/API/Cocoa/WKView.h:
407         (WK_CLASS_DEPRECATED_WITH_REPLACEMENT):
408         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
409         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
410         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
411         * UIProcess/API/Cocoa/_WKAttachment.h:
412         * UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.h:
413         * UIProcess/API/Cocoa/_WKDownload.h:
414         * UIProcess/API/Cocoa/_WKFormInputSession.h:
415         * UIProcess/API/Cocoa/_WKInspector.h:
416         * UIProcess/API/Cocoa/_WKInternalDebugFeature.h:
417         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
418         * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
419         * UIProcess/API/Cocoa/_WKWebsitePolicies.h:
420         * WebProcess/API/Cocoa/WKWebProcess.h:
421         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.h:
422         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h:
423
424 2019-05-13  Chris Fleizach  <cfleizach@apple.com>
425
426         AX: Need an entitlement for WebContent to send accessibility notifications
427         https://bugs.webkit.org/show_bug.cgi?id=197832
428
429         Reviewed by Brent Fulgham.
430
431         In order to send accessibility notifications on iOS, we need to be able to look up this port.
432
433         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
434
435 2019-05-13  Michael Catanzaro  <mcatanzaro@igalia.com>
436
437         Unreviewed, fix unused variable warnings in release builds
438
439         * UIProcess/WebProcessPool.cpp:
440         (WebKit::WebProcessPool::clearWebProcessHasUploads):
441
442 2019-05-12  Takashi Komori  <Takashi.Komori@sony.com>
443
444         [Curl] Suppress extra didReceiveAuthenticationChallenge call when accessing a server which checks basic auth.
445         https://bugs.webkit.org/show_bug.cgi?id=197650
446
447         Reviewed by Fujii Hironori.
448
449         * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
450         (WebKit::NetworkDataTaskCurl::restartWithCredential):
451
452 2019-05-10  Chris Dumez  <cdumez@apple.com>
453
454         [PSON] Prevent flashing when the process-swap is forced by the client
455         https://bugs.webkit.org/show_bug.cgi?id=197799
456
457         Reviewed by Geoffrey Garen.
458
459         When the process-swap is forced by the client, we would not construct a SuspendedPageProxy for
460         the previous page, which would cause a white/black flash upon navigation on macOS. The reason
461         we did not construct a SuspendedPageProxy is that it would be unsafe to keep the page around
462         in this case because other windows might have an opener link to the page when the swap is forced
463         and we need those opener / openee links to get severed.
464
465         The new approach to maintain the Web facing behavior without flashing is to create a suspended
466         page proxy for the previous page when the process swap is forced by the client. We then close
467         the page as soon as we can do so without flashing (when pageEnteredAcceleratedCompositingMode()
468         has been called).
469
470         * UIProcess/SuspendedPageProxy.cpp:
471         (WebKit::SuspendedPageProxy::SuspendedPageProxy):
472         (WebKit::SuspendedPageProxy::close):
473         (WebKit::SuspendedPageProxy::pageEnteredAcceleratedCompositingMode):
474         (WebKit::SuspendedPageProxy::closeWithoutFlashing):
475         (WebKit::SuspendedPageProxy::didProcessRequestToSuspend):
476         * UIProcess/SuspendedPageProxy.h:
477         * UIProcess/WebPageProxy.cpp:
478         (WebKit::WebPageProxy::suspendCurrentPageIfPossible):
479         (WebKit::WebPageProxy::commitProvisionalPage):
480         * UIProcess/WebPageProxy.h:
481
482 2019-05-10  Brent Fulgham  <bfulgham@apple.com>
483
484         Streamline test-and-clear operation for ContextMenu
485         https://bugs.webkit.org/show_bug.cgi?id=197795
486         <rdar://problem/50473746>
487
488         Reviewed by Wenson Hsieh.
489
490         Rather than performing a check when entering the function, doing work,
491         then clearing the member variable, perform the check and clear in
492         a single operation. Only perform the selection if the menu exists.
493
494         * WebProcess/WebPage/WebPage.cpp:
495         (WebKit::WebPage::didSelectItemFromActiveContextMenu):
496
497 2019-05-10  Megan Gardner  <megan_gardner@apple.com>
498
499         Returning incorrect marked text rects
500         https://bugs.webkit.org/show_bug.cgi?id=197758
501         <rdar://problem/46548586>
502
503         Reviewed by Tim Horton.
504
505         We are not returning marked text rects in the correct view coordinate space.
506         This is the same translation we are applying to the caret rects. 
507
508         * WebProcess/WebPage/ios/WebPageIOS.mm:
509         (WebKit::WebPage::platformEditorState const):
510
511 2019-05-10  Wenson Hsieh  <wenson_hsieh@apple.com>
512
513         Let WebKit clients supply an application name for user agent in modern compatibility mode
514         https://bugs.webkit.org/show_bug.cgi?id=197782
515         <rdar://problem/50646747>
516
517         Reviewed by Beth Dakin.
518
519         Add plumbing for a new private property on WKWebpagePreferences.
520
521         * UIProcess/API/APIWebsitePolicies.cpp:
522         (API::WebsitePolicies::copy const):
523         * UIProcess/API/APIWebsitePolicies.h:
524         * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
525         (-[WKWebpagePreferences _applicationNameForUserAgentWithModernCompatibility]):
526         (-[WKWebpagePreferences _setApplicationNameForUserAgentWithModernCompatibility:]):
527         * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
528
529 2019-05-10  Chris Dumez  <cdumez@apple.com>
530
531         The active tab sometimes app naps even though it should not
532         https://bugs.webkit.org/show_bug.cgi?id=197791
533         <rdar://problem/48460054>
534
535         Reviewed by Geoffrey Garen.
536
537         The WebPage constructor was initializing m_activityState but not calling updateThrottleState().
538         As a result, we would not take a UserActivity even when warranted by the initial activity state.
539
540         * WebProcess/WebPage/WebPage.cpp:
541
542 2019-05-10  Fujii Hironori  <Hironori.Fujii@sony.com>
543
544         [WinCairo] storage/indexeddb tests are timing out
545         https://bugs.webkit.org/show_bug.cgi?id=196289
546
547         Reviewed by Alex Christensen.
548
549         storage/indexeddb tests were timing out for WinCairo port because
550         WebKit::NetworkCache classes were not implemented yet for Windows.
551
552         Implement WebKit::NetworkCache classes by using WTF::FileSystem
553         functions.
554
555         * NetworkProcess/cache/CacheStorageEngine.cpp:
556         (WebKit::CacheStorage::Engine::readFile): Use
557         IOChannel::isOpened() to check the channel is opened instead of
558         checking the file descriptor.
559         * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
560         (WebKit::NetworkCache::BlobStorage::add):
561         (WebKit::NetworkCache::BlobStorage::remove):
562         * NetworkProcess/cache/NetworkCacheData.cpp:
563         (WebKit::NetworkCache::Data::mapToFile const):
564         (WebKit::NetworkCache::mapFile):
565         (WebKit::NetworkCache::adoptAndMapFile):
566         (WebKit::NetworkCache::makeSalt):
567         (WebKit::NetworkCache::readOrMakeSalt):
568         * NetworkProcess/cache/NetworkCacheData.h:
569         (WebKit::NetworkCache::Data::isEmpty const):
570         (WebKit::NetworkCache::Data::size const):
571         * NetworkProcess/cache/NetworkCacheDataCurl.cpp:
572         (WebKit::NetworkCache::Data::Data):
573         (WebKit::NetworkCache::Data::empty):
574         (WebKit::NetworkCache::Data::data const):
575         (WebKit::NetworkCache::Data::isNull const):
576         (WebKit::NetworkCache::Data::apply const):
577         (WebKit::NetworkCache::Data::subrange const):
578         (WebKit::NetworkCache::concatenate):
579         (WebKit::NetworkCache::Data::adoptMap): Deleted.
580         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
581         (WebKit::NetworkCache::traverseDirectory):
582         (WebKit::NetworkCache::fileTimes):
583         (WebKit::NetworkCache::updateFileModificationTimeIfNeeded):
584         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
585         * NetworkProcess/cache/NetworkCacheIOChannel.h:
586         (WebKit::NetworkCache::IOChannel::isOpened const):
587         (WebKit::NetworkCache::IOChannel::fileDescriptor const): Deleted.
588         * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
589         (WebKit::NetworkCache::IOChannel::IOChannel):
590         (WebKit::NetworkCache::IOChannel::~IOChannel):
591         (WebKit::NetworkCache::runTaskInQueue):
592         (WebKit::NetworkCache::IOChannel::read):
593         (WebKit::NetworkCache::IOChannel::write):
594
595 2019-05-10  Chris Dumez  <cdumez@apple.com>
596
597         Do not wait until requestPermission() is called to fire deviceorientation events if permission was already granted
598         https://bugs.webkit.org/show_bug.cgi?id=197750
599
600         Reviewed by Geoffrey Garen.
601
602         The UIProcess remembers previous device orientation permission decisions per origin for the duration of the browsing
603         session. However, the WebContent process was not aware of previous decisions and would therefore not fire any
604         deviceorientation / devicemotion events until the JS has called requestPermission(). This patches addresses this
605         problem by having the UIProcess communicate any previous permission decision for the origin via WebSitePolicies.
606
607         * UIProcess/WebPageProxy.cpp:
608         (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
609         * UIProcess/WebsiteData/WebDeviceOrientationAndMotionAccessController.cpp:
610         (WebKit::WebDeviceOrientationAndMotionAccessController::shouldAllowAccess):
611         (WebKit::WebDeviceOrientationAndMotionAccessController::cachedDeviceOrientationPermission const):
612         (WebKit::WebDeviceOrientationAndMotionAccessController::deviceOrientationPermission const): Deleted.
613         * UIProcess/WebsiteData/WebDeviceOrientationAndMotionAccessController.h:
614
615 2019-05-10  Chris Dumez  <cdumez@apple.com>
616
617         Add WKWebViewConfiguration._canShowWhileLocked SPI
618         https://bugs.webkit.org/show_bug.cgi?id=197777
619         <rdar://problem/50065100>
620
621         Reviewed by Tim Horton.
622
623         * Platform/mac/LayerHostingContext.h:
624         * Platform/mac/LayerHostingContext.mm:
625         (WebKit::LayerHostingContext::createForExternalHostingProcess):
626         * Shared/WebPageCreationParameters.cpp:
627         (WebKit::WebPageCreationParameters::encode const):
628         (WebKit::WebPageCreationParameters::decode):
629         * Shared/WebPageCreationParameters.h:
630         * UIProcess/API/APIPageConfiguration.cpp:
631         (API::PageConfiguration::copy const):
632         * UIProcess/API/APIPageConfiguration.h:
633         (API::PageConfiguration::canShowWhileLocked const):
634         (API::PageConfiguration::setCanShowWhileLocked):
635         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
636         (-[WKWebViewConfiguration _setCanShowWhileLocked:]):
637         (-[WKWebViewConfiguration _canShowWhileLocked]):
638         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
639         * UIProcess/WebPageProxy.cpp:
640         (WebKit::WebPageProxy::creationParameters):
641         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm:
642         (WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
643         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h:
644         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
645         (WebKit::RemoteLayerTreeContext::canShowWhileLocked const):
646         * WebProcess/WebPage/WebPage.cpp:
647         (WebKit::m_canShowWhileLocked):
648         (WebKit::m_shrinkToFitContentTimer): Deleted.
649         * WebProcess/WebPage/WebPage.h:
650         (WebKit::WebPage::canShowWhileLocked const):
651
652 2019-05-10  Michael Catanzaro  <mcatanzaro@igalia.com>
653
654         Fix a bunch of compiler warnings
655         https://bugs.webkit.org/show_bug.cgi?id=197785
656
657         Reviewed by Don Olmstead.
658
659         Guard Cocoa-specific format modifier to avoid -Wformat warning.
660
661         * NetworkProcess/AdClickAttributionManager.cpp:
662         (WebKit::AdClickAttributionManager::fireConversionRequest):
663
664 2019-05-10  Chris Fleizach  <cfleizach@apple.com>
665
666         AX: Crash at WebKit: WebKit::WebSpeechSynthesisClient::speak
667         https://bugs.webkit.org/show_bug.cgi?id=197761
668         <rdar://problem/50237614>
669
670         Reviewed by Per Arne Vollan.
671
672         It's valid for the incoming voice to be nil, so we need to protect against that.
673
674         Tests: fast/speechsynthesis/speech-synthesis-real-client-version.html
675
676         * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp:
677         (WebKit::WebSpeechSynthesisClient::speak):
678
679 2019-05-10  Michael Catanzaro  <mcatanzaro@igalia.com>
680
681         [WPE][GTK] Add webkit_frame_get_id() API
682         https://bugs.webkit.org/show_bug.cgi?id=197270
683
684         Reviewed by Carlos Garcia Campos.
685
686         It's as simple as can be: just an API to return the ID of a frame.
687
688         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
689         * WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp:
690         (webkit_frame_get_id):
691         * WebProcess/InjectedBundle/API/gtk/WebKitFrame.h:
692         * WebProcess/InjectedBundle/API/wpe/WebKitFrame.h:
693         * WebProcess/InjectedBundle/API/wpe/docs/wpe-webextensions-1.0-sections.txt:
694
695 2019-05-10  Michael Catanzaro  <mcatanzaro@igalia.com>
696
697         [WPE][GTK] Add WebKitWebPage::did-associate-form-controls-for-frame and deprecate original did-associate-form-controls
698         https://bugs.webkit.org/show_bug.cgi?id=197271
699
700         Reviewed by Youenn Fablet.
701
702         * WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h:
703         * WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp:
704         (webkit_web_page_class_init):
705         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
706         (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]):
707         * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:
708         (API::InjectedBundle::FormClient::didAssociateFormControls):
709         * WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
710         (WebKit::InjectedBundlePageFormClient::didAssociateFormControls):
711         * WebProcess/InjectedBundle/InjectedBundlePageFormClient.h:
712         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
713         (WebKit::WebChromeClient::didAssociateFormControls):
714         * WebProcess/WebCoreSupport/WebChromeClient.h:
715
716 2019-05-09  Rob Buis  <rbuis@igalia.com>
717
718         Limit number of prefetches of a given page
719         https://bugs.webkit.org/show_bug.cgi?id=197736
720
721         Reviewed by Darin Adler.
722
723         Limit prefetches for same url to 1.
724
725         * NetworkProcess/cache/PrefetchCache.cpp:
726         (WebKit::PrefetchCache::store):
727
728 2019-05-09  Alex Christensen  <achristensen@webkit.org>
729
730         Unreviewed, rolling out most of r245151.
731
732         Caused assertions in High Sierra
733
734         Reverted most of changeset:
735
736         "Remove now-unnecessary Connection::sendMessageWithReply"
737         https://bugs.webkit.org/show_bug.cgi?id=197747
738         https://trac.webkit.org/changeset/245151
739
740 2019-05-09  Daniel Bates  <dabates@apple.com>
741
742         [iOS] Lazily request keyboard on first hardware keydown when a non-editable element is focused
743         https://bugs.webkit.org/show_bug.cgi?id=197746
744         <rdar://problem/50630406>
745
746         Reviewed by Brent Fulgham.
747
748         Be even lazier. We only need to create a keyboard if an editable element is focused or on
749         the first hardware keydown when a non-editable element is focused. We currently do the former.
750         Let's also do the latter.
751
752         * UIProcess/ios/WKContentViewInteraction.h:
753         * UIProcess/ios/WKContentViewInteraction.mm:
754         (-[WKContentView cleanupInteraction]): Reset bookkeeping.
755         (-[WKContentView _requiresKeyboardWhenFirstResponder]): Further condition the result on
756         whether we have seen a hardware keydown event in a non-editable element.
757         (-[WKContentView _handleKeyUIEvent:]): If this is the first hardware key event we've seen then
758         update state and call -reloadInputView. -reloadInputView will call us back in -_requiresKeyboardWhenFirstResponder
759         and we will now return YES. So, it will create the keyboard.
760         (-[WKContentView _hardwareKeyboardAvailabilityChanged]): Reset bookkeeping.
761
762 2019-05-08  Dean Jackson  <dino@apple.com>
763
764         Guard long press link preview with a USE macro rather than complicated includes
765         https://bugs.webkit.org/show_bug.cgi?id=197728
766         <rdar://problem/50604700>
767
768         Reviewed by Wenson Hsieh.
769
770         It was getting complicated to manage the coordination between WebKitAdditions
771         and WebKit without having to split up the includes into multiple files
772         or have lots of duplication.
773
774         Instead, WebKitAdditions will now define a USE macro which can be used
775         in various places through WebKit.
776
777         * UIProcess/ios/WKContentViewInteraction.h:
778         * UIProcess/ios/WKContentViewInteraction.mm:
779         (-[WKContentView dragInteraction:itemsForBeginningSession:]):
780         (-[WKContentView _contentsOfUserInterfaceItem:]):
781         (previewIdentifierForElementAction):
782         (-[WKContentView shouldUsePreviewForLongPress]):
783         (-[WKContentView _registerPreview]):
784         (-[WKContentView _unregisterPreview]):
785         (shouldUsePreviewForLongPress): Deleted.
786         (-[WKContentView _registerPreviewLongPress]): Deleted.
787         (-[WKContentView _unregisterPreviewLongPress]): Deleted.
788
789 2019-05-09  Alex Christensen  <achristensen@webkit.org>
790
791         Remove now-unnecessary Connection::sendMessageWithReply
792         https://bugs.webkit.org/show_bug.cgi?id=197747
793
794         Reviewed by Tim Horton.
795
796         The WebProcess messages that use it already do the right thing with CompletionHandlers and can be replaced by sendWithAsyncReply.
797         The SecItemShim message that uses it can be replaced by sendSync.
798
799         This patch only increases responsiveness when clearing website data and removes the need for a WorkQueue dedicated entirely to the SecItemShim.
800
801         * Platform/IPC/Connection.cpp:
802         (IPC::Connection::invalidate):
803         (IPC::Connection::processIncomingSyncReply):
804         (IPC::Connection::connectionDidClose):
805         (IPC::Connection::sendMessageWithReply): Deleted.
806         * Platform/IPC/Connection.h:
807         (IPC::Connection::send):
808         (IPC::Connection::sendWithReply): Deleted.
809         * Shared/mac/SecItemResponseData.h:
810         * Shared/mac/SecItemShim.cpp:
811         (WebKit::sendSecItemRequest):
812         (WebKit::workQueue): Deleted.
813         * UIProcess/WebProcessProxy.cpp:
814         (WebKit::WebProcessProxy::fetchWebsiteData):
815         (WebKit::WebProcessProxy::deleteWebsiteData):
816         (WebKit::WebProcessProxy::deleteWebsiteDataForOrigins):
817         * WebProcess/WebProcess.messages.in:
818
819 2019-05-09  Dean Jackson  <dino@apple.com>
820
821         Build fix for iOS.
822
823         * UIProcess/WKImagePreviewViewController.mm:
824
825 2019-05-09  Alex Christensen  <achristensen@webkit.org>
826
827         Remove unnecessary test SPI after r244883
828         https://bugs.webkit.org/show_bug.cgi?id=197575
829
830         Reviewed by Tim Horton.
831
832         We now have two ways of doing the same thing.  Let's remove the one that's only for testing,
833         and make the tests clean up like an application would.
834
835         * NetworkProcess/NetworkProcess.cpp:
836         (WebKit::NetworkProcess::removeCredential): Deleted.
837         * NetworkProcess/NetworkProcess.h:
838         * NetworkProcess/NetworkProcess.messages.in:
839         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
840         (WebKit::NetworkProcess::removeCredential): Deleted.
841         * UIProcess/API/Cocoa/WKProcessPool.mm:
842         (-[WKProcessPool _removeCredential:forProtectionSpace:completionHandler:]): Deleted.
843         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
844         * UIProcess/WebProcessPool.cpp:
845         (WebKit::WebProcessPool::removeCredential): Deleted.
846         * UIProcess/WebProcessPool.h:
847
848 2019-05-09  Daniel Bates  <dabates@apple.com>
849
850         REGRESSION (r241734): 1% slower PLT on iPad
851         https://bugs.webkit.org/show_bug.cgi?id=197745
852         <rdar://problem/50457731>
853
854         Reviewed by Per Arne Vollan.
855
856         For now, only create a keyboard when WKContentView becomes first responder if a hardware keyboard
857         is attached or an editable element is focused to recover the 1% loss when a keyboard is not attached.
858         We can do better and by that I mean be lazier. We'll do this <https://bugs.webkit.org/show_bug.cgi?id=197746>.
859
860         In r241734 we unified the key event handling code paths so we use exactly one for both software and
861         hardware key events. We took a simple approach of always requesting UIKit to create a keyboard when
862         the WKContentView becomes first responder. We did this so that we could continue listening for hardware
863         key events even when a non-editable element is focused and dispatch DOM events. As it turns out, always
864         creating a keyboard is expensive and caused a ~1% slowdown in page load time on iPad.
865
866         * UIProcess/ios/WKContentViewInteraction.mm:
867         (-[WKContentView _requiresKeyboardWhenFirstResponder]): Only create a keyboard if a hardware keyboard is
868         attached or an editable element is focused.
869         (-[WKContentView _hardwareKeyboardAvailabilityChanged]): Reload all input view (this will cause keyboard
870         creation) if -_requiresKeyboardWhenFirstResponder returns YES.
871
872 2019-05-09  Daniel Bates  <dabates@apple.com>
873
874         [iOS] Unable to commit search on MSN.com, qq.com, or sina.com.cn using enter key (hardware or software keyboard)
875         https://bugs.webkit.org/show_bug.cgi?id=197632
876         <rdar://problem/47902054>
877
878         Reviewed by Brent Fulgham.
879
880         Fixes an issue where it is not possible to submit a <form> with target = "_blank": a form that
881         opens a new window.
882
883         By default we only allow popups to open if they were user initiated (like when a person clicks
884         on a link). We achieve this by putting a token on the stack, called the UserGestureToken when
885         WebCore processes an event from WebKit. So long as this token is on the stack we consider
886         all requests to open a popup to be user initiated. And we implicitly submit a form when pressing
887         the Return key in an HTML input element during the processing of a TextInputEvent dispatched as
888         part of inserting a '\n' into the field. On Mac, the keydown dispatches a TextInputEvent synchronously.
889         However on iOS text insertion, and hence a dispatch of a TextInputEvent event, occurs asynchronously
890         with respect to the keydown event. So, by the time the UI process calls back to the WebProcess
891         to perform the text insertion of '\n' we have long since popped the UserGestureToken off the stack
892         and hence we disallow opening a popup. To fix this, when -insertText is called we query the keyboard
893         to determine if it's being called by the keyboard. If it is then we can assume that this is
894         part of key event handling and hence was initiated by the user. We can pass along this detail
895         to the WebProcess for it to push a new UserGestureToken onto the stack.
896
897         For now we only track whether text inserted by the keyboard was user initiated or not. In
898         <https://bugs.webkit.org/show_bug.cgi?id=197721> we will fix this up for all editing commands.
899
900         * Platform/spi/ios/UIKitSPI.h: Expose SPI.
901         * Shared/Cocoa/InsertTextOptions.cpp:
902         (IPC::ArgumentCoder<WebKit::InsertTextOptions>::encode):
903         (IPC::ArgumentCoder<WebKit::InsertTextOptions>::decode):
904         Encode and decode whether we are processing a user gesture.
905
906         * Shared/Cocoa/InsertTextOptions.h:
907         * UIProcess/ios/WKContentViewInteraction.mm:
908         (-[WKContentView insertText:]): Query the keyboard to determine whether it called us or
909         the embedding client did. We only want to privilege user initiated actions (the keyboard).
910         * WebProcess/WebPage/WebPage.cpp:
911         (WebKit::WebPage::insertTextAsync): Push a UserGestureToken onto the stack that is initialized
912         depending on whether we are or are not processing a user gesture.
913
914 2019-05-09  Antoine Quint  <graouts@apple.com>
915
916         pointerevents/ios/touch-action-none-in-overflow-scrolling-touch.html is a timeout
917         https://bugs.webkit.org/show_bug.cgi?id=197738
918         <rdar://problem/50588613>
919
920         Reviewed by Antti Koivisto.
921
922         We clear the touch actions for a given touch identifier when the matching touch is released in -[WKContentViewInteraction _handleTouchActionsForTouchEvent:].
923         This happens before -[WKScrollingNodeScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:] is called and thus, which we correctly
924         respected the touch actions during the panning gesture, we would not be able to respect them during the deceleration animation. This caused the test to fail
925         because it would check that no scrolling happened after the panning gesture completed, ie. during the deceleration animation.
926
927         To work around this, we now store the touch actions for a given UIScrollView interaction in the ScrollingTreeScrollingNodeDelegateIOS object when the interaction
928         starts.
929
930         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
931         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::activeTouchActions const):
932         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::clearActiveTouchActions):
933         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
934         (-[WKScrollingNodeScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
935         (-[WKScrollingNodeScrollViewDelegate _scrollView:adjustedOffsetForOffset:translation:startPoint:locationInView:horizontalVelocity:verticalVelocity:]):
936         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::computeActiveTouchActionsForGestureRecognizer):
937         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::activeTouchActionsForGestureRecognizer const): Deleted.
938
939 2019-05-08  Antoine Quint  <graouts@apple.com>
940
941         [iOS] Correctly handle overlapping regions for elements with a touch-action property
942         https://bugs.webkit.org/show_bug.cgi?id=194813
943         <rdar://problem/48194708>
944
945         Reviewed by Antti Koivisto.
946
947         We now use WebKit::touchActionsForPoint() to determine the touch actions for a given touch using its location in -[WKContentViewInteraction
948         _handleTouchActionsForTouchEvent:]. We then record these touch actions for the touch's identifier on the RemoteScrollingCoordinatorProxy.
949
950         Then, as we interact with a UIScrollView, we get its gesture recognizer and get its active touch identifier through the new
951         -[WKContentViewInteraction activeTouchIdentifierForGestureRecognizer:] method, and query the RemoteScrollingCoordinatorProxy for the touch
952         actions matching that touch identifier.
953
954         Tests: pointerevents/ios/touch-action-none-overlap.html
955                pointerevents/ios/touch-action-pan-x-overlap.html
956                pointerevents/ios/touch-action-pan-y-overlap.html
957                pointerevents/ios/touch-action-pinch-zoom-overlap.html
958
959         * UIProcess/PageClient.h:
960         (WebKit::PageClient::activeTouchIdentifierForGestureRecognizer):
961         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: Maintain a touch identifier to touch actions map.
962         (WebKit::RemoteScrollingCoordinatorProxy::activeTouchActionsForTouchIdentifier const):
963         (WebKit::RemoteScrollingCoordinatorProxy::setTouchActionsForTouchIdentifier):
964         (WebKit::RemoteScrollingCoordinatorProxy::clearTouchActionsForTouchIdentifier):
965         (WebKit::RemoteScrollingCoordinatorProxy::touchActionDataAtPoint const): Deleted.
966         (WebKit::RemoteScrollingCoordinatorProxy::touchActionDataForScrollNodeID const): Deleted.
967         (WebKit::RemoteScrollingCoordinatorProxy::setTouchDataForTouchIdentifier): Deleted.
968         (WebKit::RemoteScrollingCoordinatorProxy::clearTouchDataForTouchIdentifier): Deleted.
969         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
970         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
971         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
972         (-[WKScrollingNodeScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
973         (-[WKScrollingNodeScrollViewDelegate _scrollView:adjustedOffsetForOffset:translation:startPoint:locationInView:horizontalVelocity:verticalVelocity:]):
974         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::activeTouchActionsForGestureRecognizer const):
975         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::touchActionData const): Deleted.
976         * UIProcess/ios/PageClientImplIOS.h:
977         * UIProcess/ios/PageClientImplIOS.mm:
978         (WebKit::PageClientImpl::activeTouchIdentifierForGestureRecognizer):
979         * UIProcess/ios/WKContentViewInteraction.h:
980         * UIProcess/ios/WKContentViewInteraction.mm:
981         (-[WKContentView activeTouchIdentifierForGestureRecognizer:]):
982         (-[WKContentView _handleTouchActionsForTouchEvent:]):
983
984 2019-05-08  Megan Gardner  <megan_gardner@apple.com>
985
986         Add quirks to emulate undo and redo in hidden editable areas on some websites
987         https://bugs.webkit.org/show_bug.cgi?id=197452
988
989         Reviewed by Alex Christensen.
990
991         We need to make our own undo manager to allow undo even when 
992         the manager is empty. This is to interface with rich editing 
993         websites that don't actually interface with our undo abilities.
994         Then we need to generate synthetic undo and redo in the web process.
995
996         * UIProcess/WebPageProxy.cpp:
997         (WebKit::WebPageProxy::isCurrentURLHost const):
998         * UIProcess/WebPageProxy.h:
999         * UIProcess/ios/WKContentView.mm:
1000         (-[WKNSUndoManager initWithContentView:]):
1001         (-[WKNSUndoManager canUndo]):
1002         (-[WKNSUndoManager canRedo]):
1003         (-[WKNSUndoManager undo]):
1004         (-[WKNSUndoManager redo]):
1005         (-[WKContentView undoManager]):
1006         * UIProcess/ios/WKContentViewInteraction.h:
1007         * UIProcess/ios/WKContentViewInteraction.mm:
1008         (-[WKContentView generateSyntheticUndoRedo:]):
1009         (-[WKContentView hasHiddenContentEditable]):
1010         * UIProcess/ios/WebPageProxyIOS.mm:
1011         (WebKit::WebPageProxy::generateSyntheticUndoRedo):
1012         * WebProcess/WebPage/WebPage.h:
1013         * WebProcess/WebPage/WebPage.messages.in:
1014         * WebProcess/WebPage/ios/WebPageIOS.mm:
1015         (WebKit::WebPage::handleEditingKeyboardEvent):
1016         (WebKit::WebPage::generateSyntheticUndoRedo):
1017
1018 2019-05-08  Alex Christensen  <achristensen@webkit.org>
1019
1020         Add SPI to set HSTS storage directory
1021         https://bugs.webkit.org/show_bug.cgi?id=197259
1022         <rdar://problem/48797895>
1023
1024         Reviewed by Brady Eidson.
1025
1026         It is with great sadness that I lament the design of this SPI, which is necessitated by the process-global nature of the SPI that
1027         I must call and the time at which I must call it (before any networking calls have been made).
1028         I'm also not thrilled about the fact that the unit test infrastructure I developed for this in r244594 cannot be used because
1029         the SPI that I must call does not work on iOS simulator or Mac.  I have verified the SPI is being called and that when called on iOS,
1030         and that CFNetwork does the right thing with it.
1031
1032         * NetworkProcess/NetworkProcessCreationParameters.cpp:
1033         (WebKit::NetworkProcessCreationParameters::encode const):
1034         (WebKit::NetworkProcessCreationParameters::decode):
1035         * NetworkProcess/NetworkProcessCreationParameters.h:
1036         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
1037         (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
1038         * UIProcess/API/APIProcessPoolConfiguration.cpp:
1039         (API::ProcessPoolConfiguration::copy):
1040         * UIProcess/API/APIProcessPoolConfiguration.h:
1041         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
1042         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
1043         (-[_WKProcessPoolConfiguration setHSTSStorageDirectory:]):
1044         (-[_WKProcessPoolConfiguration hstsStorageDirectory]):
1045         * UIProcess/WebProcessPool.cpp:
1046         (WebKit::WebProcessPool::ensureNetworkProcess):
1047
1048 2019-05-08  Daniel Bates  <dabates@apple.com>
1049
1050         Pass insertTextAsync options as a struct
1051         https://bugs.webkit.org/show_bug.cgi?id=197710
1052
1053         Reviewed by Brent Fulgham.
1054
1055         WebPageProxy::insertTextAsync() is becoming unwieldy to work with given the large number of
1056         optional arguments that can be passed to it. Let's pass a struct instead.
1057
1058         * Shared/Cocoa/InsertTextOptions.cpp: Added.
1059         (IPC::ArgumentCoder<WebKit::InsertTextOptions>::encode):
1060         (IPC::ArgumentCoder<WebKit::InsertTextOptions>::decode):
1061         * Shared/Cocoa/InsertTextOptions.h: Added.
1062         * Shared/EditingRange.h: Add EnumTrait so that we can encode the EditingRangeIsRelativeTo
1063         enumeration.
1064         * SourcesCocoa.txt: Add a new file.
1065         * UIProcess/Cocoa/WebViewImpl.mm:
1066         (WebKit::WebViewImpl::insertText): Update code now that we pass a struct.
1067         (WebKit::WebViewImpl::setMarkedText): Ditto.
1068         * UIProcess/WebPageProxy.cpp:
1069         (WebKit::WebPageProxy::insertTextAsync): Ditto.
1070         * UIProcess/WebPageProxy.h:
1071         * UIProcess/ios/WKContentViewInteraction.mm:
1072         (-[WKContentView insertText:]): Ditto.
1073         * UIProcess/mac/WebPageProxyMac.mm:
1074         (WebKit::WebPageProxy::insertDictatedTextAsync): Ditto.
1075         * WebKit.xcodeproj/project.pbxproj: Add new files.
1076         * WebProcess/WebPage/WebPage.cpp:
1077         (WebKit::WebPage::insertTextAsync): Ditto.
1078         * WebProcess/WebPage/WebPage.h:
1079         * WebProcess/WebPage/WebPage.messages.in: Ditto.
1080
1081 2019-05-08  Timothy Hatcher  <timothy@apple.com>
1082
1083         Add plumbing for inactive system colors in RenderTheme cache.
1084         https://bugs.webkit.org/show_bug.cgi?id=197699
1085         rdar://problem/49406936
1086
1087         Reviewed by Tim Horton.
1088
1089         * Shared/WebPageCreationParameters.cpp:
1090         (WebKit::WebPageCreationParameters::encode const):
1091         (WebKit::WebPageCreationParameters::decode):
1092         * Shared/WebPageCreationParameters.h:
1093         * UIProcess/Cocoa/WebViewImpl.h:
1094         * UIProcess/Cocoa/WebViewImpl.mm:
1095         (WebKit::WebViewImpl::effectiveAppearanceIsInactive):
1096         * UIProcess/PageClient.h:
1097         (WebKit::PageClient::effectiveAppearanceIsInactive const):
1098         * UIProcess/WebPageProxy.cpp:
1099         (WebKit::WebPageProxy::creationParameters):
1100         (WebKit::WebPageProxy::useInactiveAppearance const):
1101         (WebKit::WebPageProxy::effectiveAppearanceDidChange):
1102         * UIProcess/WebPageProxy.h:
1103         * UIProcess/mac/PageClientImplMac.h:
1104         * UIProcess/mac/PageClientImplMac.mm:
1105         (WebKit::PageClientImpl::effectiveAppearanceIsInactive const):
1106         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
1107         (WKBundlePageSetUseDarkAppearance):
1108         * WebProcess/WebPage/WebPage.cpp:
1109         (WebKit::m_shrinkToFitContentTimer):
1110         (WebKit::WebPage::effectiveAppearanceDidChange): Renamed from setUseDarkAppearance.
1111         * WebProcess/WebPage/WebPage.h:
1112         * WebProcess/WebPage/WebPage.messages.in:
1113         * WebProcess/WebPage/gtk/WebPageGtk.cpp:
1114         (WebKit::WebPage::effectiveAppearanceDidChange): Renamed from setUseDarkAppearance.
1115
1116 2019-05-08  Chris Dumez  <cdumez@apple.com>
1117
1118         Regression: Crash at WebKit: PAL::HysteresisActivity::start
1119         https://bugs.webkit.org/show_bug.cgi?id=197666
1120         <rdar://problem/50037153>
1121
1122         Reviewed by Geoffrey Garen.
1123
1124         We've recently made it so that the WebContent process destroys its WebSQLiteDatabaseTracker when preparing
1125         for process suspension and then re-constructs it when resuming. The issue is that the WebSQLiteDatabaseTracker
1126         internal implementation was calling callOnMainThread() and capturing |this| to start/stop its HysteresisActivity.
1127         As a result, |this| could be dead by the time we're on the main thread and we'd crash.
1128
1129         To address the issue, we no longer destroy the WebSQLiteDatabaseTracker when preparing to suspend. Instead, we
1130         set a 'isSuspended' flag on the WebSQLiteDatabaseTracker so that it stops notifying the WebProcess of changes.
1131
1132         Also clean up the class a bit so that:
1133         1. The constructor takes in a WTF::Function instead of a NetworkProcess / WebProcess reference. This is provides
1134            better layering. The WebSQLiteDatabaseTracker should not need to know anything about those objects.
1135         2. Use RunLoop::main().dispatch() instead of callOnMainThread() since we're in WebKit2 code.
1136
1137         * NetworkProcess/NetworkProcess.cpp:
1138         (WebKit::NetworkProcess::NetworkProcess):
1139         * Shared/WebSQLiteDatabaseTracker.cpp:
1140         (WebKit::WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker):
1141         (WebKit::WebSQLiteDatabaseTracker::~WebSQLiteDatabaseTracker):
1142         (WebKit::WebSQLiteDatabaseTracker::willBeginFirstTransaction):
1143         (WebKit::WebSQLiteDatabaseTracker::didFinishLastTransaction):
1144         (WebKit::WebSQLiteDatabaseTracker::hysteresisUpdated): Deleted.
1145         * Shared/WebSQLiteDatabaseTracker.h:
1146         * WebProcess/WebProcess.cpp:
1147         (WebKit::m_nonVisibleProcessCleanupTimer):
1148         (WebKit::WebProcess::initializeSQLiteDatabaseTracker):
1149         (WebKit::WebProcess::cancelPrepareToSuspend):
1150         (WebKit::WebProcess::processDidResume):
1151         (WebKit::m_webSQLiteDatabaseTracker): Deleted.
1152         * WebProcess/WebProcess.h:
1153
1154 2019-05-08  Tim Horton  <timothy_horton@apple.com>
1155
1156         iOS: Selection is dismissed even if click is preventDefault()'d
1157         https://bugs.webkit.org/show_bug.cgi?id=197686
1158         <rdar://problem/49398824>
1159
1160         Reviewed by Wenson Hsieh.
1161
1162         We currently unconditionally dismiss the selection on any tap; however
1163         if a site preventDefault()s on click, we shouldn't perform the default
1164         action of dismissing the selection.
1165
1166         Instead of clearing the selection in the UI process, clear it in the
1167         Web content process if we don't dispatch a synthetic click; the normal
1168         WebCore machinery will handle it in the case that we do.
1169
1170         * UIProcess/ios/WKContentViewInteraction.mm:
1171         (-[WKContentView _singleTapRecognized:]):
1172         * WebProcess/WebPage/WebPage.h:
1173         * WebProcess/WebPage/ios/WebPageIOS.mm:
1174         (WebKit::WebPage::commitPotentialTapFailed):
1175         (WebKit::WebPage::selectWithGesture):
1176         (WebKit::WebPage::clearSelection):
1177         (WebKit::WebPage::selectTextWithGranularityAtPoint):
1178
1179 2019-05-08  Alexander Mikhaylenko  <exalm7659@gmail.com>
1180
1181         [GTK] Support navigation gesture on touchscreens
1182         https://bugs.webkit.org/show_bug.cgi?id=197690
1183
1184         Reviewed by Michael Catanzaro.
1185
1186         Touch events generate scroll events that are handled in webkitWebViewBaseHandleWheelEvent(),
1187         bypassing webkitWebViewBaseScrollEvent(). Because of that, ViewGestureController never receives
1188         them. Hence pass scroll events to ViewGestureController in webkitWebViewBaseHandleWheelEvent()
1189         instead.
1190
1191         For touch events, gesture progress calculation has to take window width into account to make
1192         the page perfectly follow finger, and deltas are additionally divided by Scrollbar::pixelsPerLineStep(),
1193         so compensate for that.
1194
1195         For touchpad events, change delta multiplier to 10 to match GTK behavior, and introduce a 400px
1196         base width so the swipe speed doesn't change from the previous behavior.
1197
1198         Because of the multiplier change, threshold for triggering the gesture with touchpad is now 4
1199         times larger.
1200
1201         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
1202         (webkitWebViewBaseHandleWheelEvent): Move ViewGestureController bits here.
1203         (webkitWebViewBaseScrollEvent): Removed ViewGestureController bits.
1204         * UIProcess/gtk/ViewGestureControllerGtk.cpp:
1205         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe):
1206         Allow events from touchscreen devices.
1207         (WebKit::isTouchEvent): Added.
1208         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
1209         Change delta multipliers.
1210         (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
1211         Change delta multipliers, account for view width for touchscreen events.
1212
1213 2019-05-08  Wenson Hsieh  <wenson_hsieh@apple.com>
1214
1215         [iOS] Add a quirk to synthesize mouse events when modifying the selection
1216         https://bugs.webkit.org/show_bug.cgi?id=197683
1217         <rdar://problem/48003980>
1218
1219         Reviewed by Tim Horton.
1220
1221         Introduces support for dispatching synthetic mouse events when modifying the selection on some websites. See
1222         below for more details.
1223
1224         * UIProcess/WebPageProxy.cpp:
1225         (WebKit::WebPageProxy::selectAll):
1226         * UIProcess/WebPageProxy.h:
1227
1228         Instead of executing a "SelectAll" editing command using the generic WebPage::executeEditCommand method,
1229         introduce a separate method for selectAll that executes the "SelectAll" edit command and then does some
1230         platform-specific work. See platformDidSelectAll.
1231
1232         * UIProcess/ios/WKContentViewInteraction.mm:
1233         (-[WKContentView selectAllForWebView:]):
1234         * WebProcess/WebPage/WebPage.cpp:
1235         (WebKit::WebPage::selectAll):
1236         (WebKit::WebPage::shouldDispatchSyntheticMouseEventsWhenModifyingSelection const):
1237
1238         Add a helper method to determine whether the quirk should be enabled.
1239
1240         (WebKit::WebPage::platformDidSelectAll):
1241         * WebProcess/WebPage/WebPage.h:
1242         * WebProcess/WebPage/WebPage.messages.in:
1243         * WebProcess/WebPage/ios/WebPageIOS.mm:
1244         (WebKit::elementRectInRootViewCoordinates):
1245
1246         Move this function closer to the top of the file so that it can be used in
1247         dispatchSyntheticMouseEventsForSelectionGesture.
1248
1249         (WebKit::WebPage::clearSelection):
1250         (WebKit::WebPage::dispatchSyntheticMouseEventsForSelectionGesture):
1251
1252         Add a helper method to dispatch a synthetic mouse event for a given selection gesture type. Used in several
1253         places in WebPageIOS to synthesize and dispatch mouse events during selection.
1254
1255         (WebKit::WebPage::updateSelectionWithTouches):
1256
1257         When changing the selection with selection handles, fake mousedown when the user first touches down on the
1258         selection handle; mousemove as the user is moving the handle around; and finally, mouseup when the user lets go.
1259
1260         (WebKit::WebPage::extendSelection):
1261         (WebKit::WebPage::platformDidSelectAll):
1262
1263         When tapping "Select All" and/or "Select" in the callout menu, fake a mousedown at the selection start, then a
1264         mousemove at selection end, and finally, a mouseup at selection end.
1265
1266         (WebKit::WebPage::getFocusedElementInformation):
1267
1268 2019-05-08  Alexander Mikhaylenko  <exalm7659@gmail.com>
1269
1270         [GTK] Pinch Zooming has no maximum
1271         https://bugs.webkit.org/show_bug.cgi?id=194865
1272
1273         Reviewed by Michael Catanzaro.
1274
1275         Set maximum zoom to 3.0, reflecting the value on macOS and iOS.
1276
1277         * UIProcess/gtk/GestureController.cpp:
1278         (WebKit::GestureController::ZoomGesture::scaleChanged):
1279
1280 2019-05-08  Rob Buis  <rbuis@igalia.com>
1281
1282         Link prefetch not useful for top-level navigation
1283         https://bugs.webkit.org/show_bug.cgi?id=195623
1284
1285         Reviewed by Youenn Fablet.
1286
1287         Cache cross-domain top-level prefetches in a dedicated cache. When a navigation
1288         to the same url is done within a threshold (5 seconds), reuse the
1289         prefetch cache entry, move it to the disk cache and navigate to
1290         the url, meaning no extra network trip is needed. When not used within
1291         the threshold period, the prefetch entry will be erased using a timer.
1292
1293         * NetworkProcess/NetworkProcess.cpp:
1294         (WebKit::NetworkProcess::lowMemoryHandler):
1295         * NetworkProcess/NetworkResourceLoader.cpp:
1296         (WebKit::NetworkResourceLoader::retrieveCacheEntry):
1297         (WebKit::NetworkResourceLoader::didReceiveResponse):
1298         (WebKit::NetworkResourceLoader::didReceiveBuffer):
1299         (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry):
1300         (WebKit::NetworkResourceLoader::isCrossOriginPrefetch const):
1301         * NetworkProcess/NetworkResourceLoader.h:
1302         * NetworkProcess/NetworkSession.h:
1303         (WebKit::NetworkSession::prefetchCache):
1304         (WebKit::NetworkSession::clearPrefetchCache):
1305         * NetworkProcess/cache/PrefetchCache.cpp: Added.
1306         (WebKit::PrefetchCache::Entry::Entry):
1307         (WebKit::PrefetchCache::PrefetchCache):
1308         (WebKit::PrefetchCache::~PrefetchCache):
1309         (WebKit::PrefetchCache::clear):
1310         (WebKit::PrefetchCache::take):
1311         (WebKit::PrefetchCache::store):
1312         (WebKit::PrefetchCache::clearExpiredEntries):
1313         * NetworkProcess/cache/PrefetchCache.h: Added.
1314         (WebKit::PrefetchCache::Entry::releaseBuffer):
1315         * Shared/WebPreferences.yaml:
1316         * Sources.txt:
1317         * WebKit.xcodeproj/project.pbxproj:
1318
1319 2019-05-07  Chris Dumez  <cdumez@apple.com>
1320
1321         Simplify logic to prevent App Nap in WebPage
1322         https://bugs.webkit.org/show_bug.cgi?id=197674
1323
1324         Reviewed by Geoff Garen.
1325
1326         Simplify logic to prevent App Nap in WebPage. We do not need both m_userActivityHysteresis and
1327         m_userActivity since UserActivity is already a HysteresisActivity. We had 2 levels of
1328         HysteresisActivity stacked on top of one another. Also rename "process suppression" to "app nap" as
1329         I find it clearer.
1330
1331         * WebProcess/WebPage/WebPage.cpp:
1332         (WebKit::WebPage::updateThrottleState):
1333         (WebKit::WebPage::mouseEvent):
1334         (WebKit::WebPage::wheelEvent):
1335         (WebKit::WebPage::keyEvent):
1336         (WebKit::WebPage::updatePreferences):
1337         (WebKit::m_userActivityHysteresis): Deleted.
1338         (WebKit::WebPage::updateUserActivity): Deleted.
1339         * WebProcess/WebPage/WebPage.h:
1340
1341 2019-05-07  Carlos Garcia Campos  <cgarcia@igalia.com>
1342
1343         REGRESSION(r244230): Web Automation: use null instead of empty string as success result of scripts when alert is open
1344         https://bugs.webkit.org/show_bug.cgi?id=197655
1345
1346         Reviewed by Devin Rousso.
1347
1348         This regressed in r244230, the case of an alert open while running a script is now handled in WebKit side, but
1349         an empty string is returned as a result, which is not a valid JSON serialized string. That made all user prompts
1350         tests to fail.
1351
1352         * UIProcess/Automation/WebAutomationSession.cpp:
1353         (WebKit::WebAutomationSession::willShowJavaScriptDialog): Use null as script result instead of an empty string.
1354
1355 2019-05-07  Ryan Haddad  <ryanhaddad@apple.com>
1356
1357         Unreviewed, rolling out r245038.
1358
1359         Breaks internal builds.
1360
1361         Reverted changeset:
1362
1363         "Add SPI to set a list of hosts to which to send custom header
1364         fields cross-origin"
1365         https://bugs.webkit.org/show_bug.cgi?id=197397
1366         https://trac.webkit.org/changeset/245038
1367
1368 2019-05-07  Jiewen Tan  <jiewen_tan@apple.com>
1369
1370         [WebAuthN] A new request should always suppress the pending request if any
1371         https://bugs.webkit.org/show_bug.cgi?id=191517
1372         <rdar://problem/46888222>
1373
1374         Reviewed by Brent Fulgham.
1375
1376         Previously we blocked new WebAuthN requests whenever a pending request was in progress
1377         to prevent background tabs from DoS foreground tabs. However, in r244938, the WebAuthN
1378         API was changed to restrict request handling to the focused document. Therefore, we no
1379         longer have a risk of DoS.
1380
1381         Apart from the vanished benefit, this behavoir actually blocks new pages to use
1382         WebAuthN API in the period between [the previous initating page is closed, the pending
1383         request is hanedled/timeout].
1384
1385         Also, it makes sense to have the current focused document preempt the pending request.
1386         Therefore, the policy will be to always cancel any pending requests whenever a new
1387         request is made. This will enforce the policy of handling only one request at a time.
1388
1389         Note that the current implementation doesn't explicitly cancel pending requests in the
1390         Authenticators, which means that we could receive responses from the Authenticator that
1391         were meant for a previous (now cancelled) request. A follow-up patch (see Bug 191523)
1392         will implement an Authenticator feature to support immediate cancellation.
1393
1394         In the meantime, to protect the atomicity of the request/response pair, i.e., preventing an old
1395         response being used for a new request, there are two safeguards:
1396         1) In web process, each request to UI process is paired with an incremental ID, and therefore an old
1397         response from UI process would have a different ID than the current request, which will then be ignored.
1398         2) In UI process, all responses from authenticators will be piped to the main run loop for processing.
1399         Therefore, when the new request comes in, the old response is either processed or waiting in the pipe.
1400         To prevent the latter being processed, the new request will immediately destroy any authenticators bound
1401         to the old response in the current run loop. Hence, in the next run loop when dealing the old response,
1402         the lambda will have no where to hand the response over.
1403
1404         * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
1405         (WebKit::AuthenticatorManager::makeCredential):
1406         (WebKit::AuthenticatorManager::getAssertion):
1407         (WebKit::AuthenticatorManager::clearStateAsync):
1408         (WebKit::AuthenticatorManager::clearState):
1409         (WebKit::AuthenticatorManager::timeOutTimerFired):
1410         * UIProcess/WebAuthentication/AuthenticatorManager.h:
1411         * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
1412         (WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
1413         (WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
1414         (WebKit::WebAuthenticatorCoordinatorProxy::requestReply):
1415         * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h:
1416         * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in:
1417         * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp:
1418         (WebKit::WebAuthenticatorCoordinator::makeCredential):
1419         (WebKit::WebAuthenticatorCoordinator::getAssertion):
1420         * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in:
1421
1422 2019-05-07  Per Arne Vollan  <pvollan@apple.com>
1423
1424         [macOS] Crash with sandbox error
1425         https://bugs.webkit.org/show_bug.cgi?id=197675
1426         <rdar://problem/50473330>
1427
1428         Reviewed by Geoffrey Garen.
1429
1430         This crash is caused by missing syscall rules in the sandbox.
1431
1432         * WebProcess/com.apple.WebProcess.sb.in:
1433
1434 2019-05-07  Alex Christensen  <achristensen@webkit.org>
1435
1436         Add SPI to set a list of hosts to which to send custom header fields cross-origin
1437         https://bugs.webkit.org/show_bug.cgi?id=197397
1438
1439         Reviewed by Geoff Garen.
1440
1441         * Shared/API/APIObject.h:
1442         * Shared/Cocoa/APIObject.mm:
1443         (API::Object::newObject):
1444         * Shared/WebsitePoliciesData.cpp:
1445         (WebKit::WebsitePoliciesData::decode):
1446         * Shared/WebsitePoliciesData.h:
1447         * SourcesCocoa.txt:
1448         * UIProcess/API/APICustomHeaderFields.h: Added.
1449         * UIProcess/API/APIWebsitePolicies.cpp:
1450         (API::WebsitePolicies::WebsitePolicies):
1451         (API::WebsitePolicies::copy const):
1452         (API::WebsitePolicies::data):
1453         * UIProcess/API/APIWebsitePolicies.h:
1454         * UIProcess/API/C/WKWebsitePolicies.cpp:
1455         (WKWebsitePoliciesCopyCustomHeaderFields):
1456         (WKWebsitePoliciesSetCustomHeaderFields):
1457         * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
1458         (-[WKWebpagePreferences _customHeaderFields]):
1459         (-[WKWebpagePreferences _setCustomHeaderFields:]):
1460         * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
1461         * UIProcess/API/Cocoa/_WKCustomHeaderFields.h: Added.
1462         * UIProcess/API/Cocoa/_WKCustomHeaderFields.mm: Added.
1463         (-[_WKCustomHeaderFields init]):
1464         (-[_WKCustomHeaderFields dealloc]):
1465         (-[_WKCustomHeaderFields fields]):
1466         (-[_WKCustomHeaderFields setFields:]):
1467         (-[_WKCustomHeaderFields thirdPartyDomains]):
1468         (-[_WKCustomHeaderFields setThirdPartyDomains:]):
1469         (-[_WKCustomHeaderFields _apiObject]):
1470         * UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h: Added.
1471         * UIProcess/API/Cocoa/_WKWebsitePolicies.h:
1472         * UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
1473         (-[_WKWebsitePolicies customHeaderFields]): Deleted.
1474         (-[_WKWebsitePolicies setCustomHeaderFields:]): Deleted.
1475         * UIProcess/Cocoa/WebViewImpl.h:
1476         * UIProcess/Cocoa/WebViewImpl.mm:
1477         (WebKit::WebViewImpl::takeFocus):
1478         (WebKit::WebViewImpl::accessibilityAttributeValue):
1479         * WebKit.xcodeproj/project.pbxproj:
1480
1481 2019-05-07  Adrian Perez de Castro  <aperez@igalia.com>
1482
1483         [GTK][WPE] Cannot build documentation with gtk-doc
1484         https://bugs.webkit.org/show_bug.cgi?id=197663
1485
1486         Reviewed by Philippe Normand.
1487
1488         * UIProcess/API/glib/WebKitSettings.cpp:
1489         (webkit_settings_class_init): Escape content which gets wrongly interpreted as
1490         SGML tags by gtk-doc as Markdown preformatted content, which fits well for the
1491         tag names in the documentation for the WebKitSettings:enable-media property.
1492
1493 2019-05-07  John Wilander  <wilander@apple.com>
1494
1495         Storage Access API: Make two changes requested by developers and complete refactoring and cleanup
1496         https://bugs.webkit.org/show_bug.cgi?id=197648
1497         <rdar://problem/50527493>
1498
1499         Reviewed by Chris Dumez.
1500
1501         Developers have requested two minor changes to the Storage Access API:
1502         - Only consume the user gesture when the user explicitly denies access.
1503         - Make document.hasStorageAccess() return true instead of false when the feature is off.
1504
1505         In addition to this, we have refactoring and cleanup to do. Namely:
1506         - Make use of WebCore::RegistrableDomain all the way.
1507         - Remove dead code in WebKit::NetworkProcess since the calls now go through NetworkConnectionToWebProcess.
1508         - Introduce boolean enums for state handling.
1509         - Break out the Storage Access API functionality into a supplement of WebCore::Document.
1510
1511         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
1512         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
1513         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
1514         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener):
1515         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
1516         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
1517         (WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt const):
1518             These changes are due to the new enums WebCore::StorageAccessWasGranted and
1519             WebCore::StorageAccessPromptWasShown.
1520         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
1521         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
1522         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
1523         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
1524         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccess):
1525         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
1526         (WebKit::ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt):
1527             These changes are due to the new enums WebCore::StorageAccessWasGranted and
1528             WebCore::StorageAccessPromptWasShown.
1529         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
1530         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
1531             These changes are due to the new enums WebCore::StorageAccessWasGranted and
1532             WebCore::StorageAccessPromptWasShown.
1533         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1534         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
1535         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
1536         (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
1537             These changes are due to the new enums WebCore::StorageAccessWasGranted and
1538             WebCore::StorageAccessPromptWasShown.
1539         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted): Deleted.
1540             This function is now no longer exposed and its functionality could be folded into
1541             the existing WebResourceLoadStatisticsStore::requestStorageAccess() which is more
1542             clearly named.
1543         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
1544         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
1545         (WebKit::NetworkConnectionToWebProcess::hasStorageAccess):
1546         (WebKit::NetworkConnectionToWebProcess::requestStorageAccess):
1547             These changes are due to the new enums WebCore::StorageAccessWasGranted and
1548             WebCore::StorageAccessPromptWasShown.
1549         * NetworkProcess/NetworkConnectionToWebProcess.h:
1550         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
1551         * NetworkProcess/NetworkProcess.cpp:
1552         (WebKit::NetworkProcess::hasStorageAccessForFrame): Deleted.
1553         (WebKit::NetworkProcess::hasStorageAccess): Deleted.
1554         (WebKit::NetworkProcess::requestStorageAccess): Deleted.
1555         (WebKit::NetworkProcess::requestStorageAccessGranted): Deleted.
1556         (WebKit::NetworkProcess::grantStorageAccess): Deleted.
1557         (WebKit::NetworkProcess::removeAllStorageAccess): Deleted.
1558             These functions were left behind in the move of ITP to the network process.
1559             This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
1560         * NetworkProcess/NetworkProcess.h:
1561         * NetworkProcess/NetworkProcess.messages.in:
1562         * Scripts/webkit/messages.py:
1563             Instructions for derived IPC code on how to include the new enums
1564             WebCore::StorageAccessWasGranted and WebCore::StorageAccessPromptWasShown.
1565         * UIProcess/Network/NetworkProcessProxy.cpp:
1566         (WebKit::NetworkProcessProxy::hasStorageAccessForFrame): Deleted.
1567         (WebKit::NetworkProcessProxy::hasStorageAccess): Deleted.
1568         (WebKit::NetworkProcessProxy::requestStorageAccess): Deleted.
1569         (WebKit::NetworkProcessProxy::grantStorageAccess): Deleted.
1570         (WebKit::NetworkProcessProxy::removeAllStorageAccess): Deleted.
1571             These functions were left behind in the move of ITP to the network process.
1572             This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
1573         * UIProcess/Network/NetworkProcessProxy.h:
1574         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1575         (WebKit::WebsiteDataStore::hasStorageAccess): Deleted.
1576         (WebKit::WebsiteDataStore::requestStorageAccess): Deleted.
1577         (WebKit::WebsiteDataStore::grantStorageAccess): Deleted.
1578             These functions were left behind in the move of ITP to the network process.
1579             This communication goes through WebKit::NetworkConnectionToWebProcess since a while back.
1580         * UIProcess/WebsiteData/WebsiteDataStore.h:
1581         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
1582         (WebKit::WebChromeClient::hasStorageAccess):
1583         (WebKit::WebChromeClient::requestStorageAccess):
1584             These changes are due to the new enums WebCore::StorageAccessWasGranted and
1585             WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
1586             objects instead of Strings now.
1587         * WebProcess/WebCoreSupport/WebChromeClient.h:
1588         * WebProcess/WebPage/WebPage.cpp:
1589         (WebKit::WebPage::hasStorageAccess):
1590         (WebKit::WebPage::requestStorageAccess):
1591             These changes are due to the new enums WebCore::StorageAccessWasGranted and
1592             WebCore::StorageAccessPromptWasShown. They also receive WebCore::RegistrableDomain
1593             objects instead of Strings now.
1594         * WebProcess/WebPage/WebPage.h:
1595
1596 2019-05-07  John Wilander  <wilander@apple.com>
1597
1598         Change IsITPFirstPartyWebsiteDataRemovalEnabled from DEFAULT_EXPERIMENTAL_FEATURES_ENABLED to true.
1599         https://bugs.webkit.org/show_bug.cgi?id=197667
1600         <rdar://problem/50549288>
1601
1602         Reviewed by Brent Fulgham.
1603
1604         * Shared/WebPreferences.yaml:
1605
1606 2019-05-07  Tim Horton  <timothy_horton@apple.com>
1607
1608         iOSMac Share Sheet shows up at the wrong place
1609         https://bugs.webkit.org/show_bug.cgi?id=197649
1610         <rdar://problem/49922942>
1611
1612         Reviewed by Megan Gardner.
1613
1614         * UIProcess/ios/WKContentViewInteraction.h:
1615         * UIProcess/ios/WKContentViewInteraction.mm:
1616         (-[WKContentView _showShareSheet:inRect:completionHandler:]):
1617         (-[WKContentView _hoverGestureRecognizerChanged:]):
1618         Pass the last mouse-over location as the presentation location for the 
1619         share sheet, if we don't have a rect to present from. Centering the popover
1620         like we do on iPad doesn't work so well (at all) with a macOS context menu.
1621
1622 2019-05-07  Chris Dumez  <cdumez@apple.com>
1623
1624         Rename ConnectionMac.mm to ConnectionCocoa.mm since it is used on both macOS and iOS
1625         https://bugs.webkit.org/show_bug.cgi?id=197661
1626
1627         Reviewed by Alexey Proskuryakov.
1628
1629         * Platform/IPC/cocoa/ConnectionCocoa.mm: Renamed from Source/WebKit/Platform/IPC/mac/ConnectionMac.mm.
1630         (IPC::ConnectionTerminationWatchdog::createConnectionTerminationWatchdog):
1631         (IPC::ConnectionTerminationWatchdog::ConnectionTerminationWatchdog):
1632         (IPC::ConnectionTerminationWatchdog::watchdogTimerFired):
1633         (IPC::Connection::platformInvalidate):
1634         (IPC::Connection::cancelReceiveSource):
1635         (IPC::Connection::terminateSoon):
1636         (IPC::Connection::platformInitialize):
1637         (IPC::Connection::open):
1638         (IPC::Connection::sendMessage):
1639         (IPC::Connection::platformCanSendOutgoingMessages const):
1640         (IPC::Connection::sendOutgoingMessage):
1641         (IPC::Connection::initializeSendSource):
1642         (IPC::Connection::resumeSendSource):
1643         (IPC::createMessageDecoder):
1644         (IPC::readFromMachPort):
1645         (IPC::Connection::receiveSourceEventHandler):
1646         (IPC::Connection::identifier const):
1647         (IPC::Connection::getAuditToken):
1648         (IPC::Connection::kill):
1649         (IPC::AccessibilityProcessSuspendedNotification):
1650         (IPC::Connection::willSendSyncMessage):
1651         (IPC::Connection::didReceiveSyncReply):
1652         (IPC::Connection::remoteProcessID const):
1653         * Platform/IPC/cocoa/ImportanceAssertion.h: Renamed from Source/WebKit/Platform/IPC/mac/ImportanceAssertion.h.
1654         (IPC::ImportanceAssertion::ImportanceAssertion):
1655         (IPC::ImportanceAssertion::~ImportanceAssertion):
1656         * Platform/IPC/cocoa/MachMessage.cpp: Renamed from Source/WebKit/Platform/IPC/mac/MachMessage.cpp.
1657         (IPC::MachMessage::create):
1658         (IPC::MachMessage::MachMessage):
1659         (IPC::MachMessage::~MachMessage):
1660         (IPC::MachMessage::messageSize):
1661         (IPC::MachMessage::leakDescriptors):
1662         * Platform/IPC/cocoa/MachMessage.h: Renamed from Source/WebKit/Platform/IPC/mac/MachMessage.h.
1663         (IPC::MachMessage::size const):
1664         (IPC::MachMessage::header):
1665         (IPC::MachMessage::messageReceiverName const):
1666         (IPC::MachMessage::messageName const):
1667         * Platform/IPC/cocoa/MachPort.h: Renamed from Source/WebKit/Platform/IPC/mac/MachPort.h.
1668         (IPC::MachPort::MachPort):
1669         (IPC::MachPort::encode const):
1670         (IPC::MachPort::decode):
1671         (IPC::MachPort::port const):
1672         (IPC::MachPort::disposition const):
1673         * PlatformMac.cmake:
1674         * SourcesCocoa.txt:
1675         * WebKit.xcodeproj/project.pbxproj:
1676
1677 2019-05-07  Antti Koivisto  <antti@apple.com>
1678
1679         <body> with overflow:hidden shouldn't be keyboard scrollable on iOS
1680         https://bugs.webkit.org/show_bug.cgi?id=197659
1681         <rdar://problem/50541453>
1682
1683         Reviewed by Antoine Quint.
1684
1685         * UIProcess/ios/WKContentViewInteraction.mm:
1686         (-[WKContentView isScrollableForKeyboardScrollViewAnimator:]):
1687
1688         Disable also keyboard scrolling when touch scrolling is disabled.
1689
1690 2019-05-07  Wenson Hsieh  <wenson_hsieh@apple.com>
1691
1692         [macOS] Avoid crashing the UI process when writing empty data to the pasteboard
1693         https://bugs.webkit.org/show_bug.cgi?id=197644
1694         <rdar://problem/50526364>
1695
1696         Reviewed by Tim Horton.
1697
1698         Test: WebKit.WKWebProcessPlugInDoNotCrashWhenCopyingEmptyClientData
1699
1700         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
1701         (WebKit::WebPlatformStrategies::setBufferForType):
1702
1703         Make this function robust by not attempting to create a shared memory buffer in the case where the given data
1704         buffer is empty.
1705
1706 2019-05-07  Carlos Garcia Campos  <cgarcia@igalia.com>
1707
1708         [GTK] Crash in webkitWebViewBaseSetEnableBackForwardNavigationGesture
1709         https://bugs.webkit.org/show_bug.cgi?id=197653
1710
1711         Reviewed by Žan Doberšek.
1712
1713         We still need to null-check the ViewGestureController there, since it can be called with a running process but
1714         not yet attached when using a related view.
1715
1716         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
1717         (webkitWebViewBaseSetEnableBackForwardNavigationGesture):
1718
1719 2019-05-07  Antti Koivisto  <antti@apple.com>
1720
1721         <body> with overflow:hidden CSS is scrollable on iOS
1722         https://bugs.webkit.org/show_bug.cgi?id=153852
1723         <rdar://problem/38715356>
1724
1725         Reviewed by Antoine Quint.
1726
1727         Disable touch scrolling of the main scroll view when <body> has overflow:hidden.
1728
1729         This already works for subframes where we don't create a scrollview in the first place.
1730         The patch also adds a test for that.
1731
1732         * UIProcess/API/Cocoa/WKWebView.mm:
1733         (-[WKWebView _didCommitLayerTree:]):
1734
1735         Update scrollability after scrolling tree commits.
1736
1737         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
1738         (WebKit::RemoteScrollingCoordinatorProxy::hasScrollableMainFrame const):
1739
1740         Base the decision on root ScrollingTreeScrollingNode::canHaveScrollbars() which is computed from overflow.
1741         This matches Mac where wheel event dispatch is similarly blocked based on this property.
1742
1743         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
1744
1745 2019-05-06  James Savage  <james.savage@apple.com>
1746
1747         Improve coordination for creating UIWindow instances.
1748         https://bugs.webkit.org/show_bug.cgi?id=197578.
1749         <rdar://problem/50456965>.
1750
1751         Reviewed by Wenson Hsieh.
1752
1753         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
1754         (makeWindowFromView): Pull out window creation.
1755         (-[WKFullScreenWindowController enterFullScreen]): Call new helper function.
1756
1757 2019-05-06  Tim Horton  <timothy_horton@apple.com>
1758
1759         _overrideViewportWithArguments does not work when called before loading
1760         https://bugs.webkit.org/show_bug.cgi?id=197638
1761         <rdar://problem/50505111>
1762
1763         Reviewed by Wenson Hsieh.
1764
1765         * WebProcess/WebPage/ios/WebPageIOS.mm:
1766         (WebKit::WebPage::setOverrideViewportArguments):
1767
1768 2019-05-06  Chris Dumez  <cdumez@apple.com>
1769
1770         ASSERT at WebKit::NetworkCache::makeSafeToUseMemoryMapForPath under Storage::StoreBodyAsBlob when running WebDriver tests
1771         https://bugs.webkit.org/show_bug.cgi?id=197635
1772         <rdar://problem/50473149>
1773
1774         Reviewed by Geoffrey Garen.
1775
1776         We need to make sure the the path at blobPathString exists before calling FileSystem::makeSafeToUseMemoryMapForPath().
1777         If the blob does not already exist when BlobStorage::add() is called, what will create it is the call to Data::mapToFile().
1778
1779         * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
1780         (WebKit::NetworkCache::BlobStorage::add):
1781
1782 2019-05-06  Wenson Hsieh  <wenson_hsieh@apple.com>
1783
1784         Occasional crashes in layout tests when firing the shrink-to-fit-content timer
1785         https://bugs.webkit.org/show_bug.cgi?id=197629
1786         <rdar://problem/50514382>
1787
1788         Reviewed by Tim Horton.
1789
1790         Fixes several crashing layout tests by stopping the shrink-to-fit-content timer when the page closes.
1791
1792         * WebProcess/WebPage/WebPage.cpp:
1793         (WebKit::WebPage::close):
1794
1795 2019-05-04  Per Arne Vollan  <pvollan@apple.com>
1796
1797         -[WKWebsiteDataStore removeDataOfTypes:forDataRecords:completionHandler:] doesn't delete _WKWebsiteDataTypeCredentials
1798         https://bugs.webkit.org/show_bug.cgi?id=197510
1799
1800         Reviewed by Alex Christensen.
1801
1802         * NetworkProcess/NetworkProcess.cpp:
1803         (WebKit::NetworkProcess::fetchWebsiteData):
1804         (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
1805         (WebKit::NetworkProcess::registrableDomainsWithWebsiteData):
1806
1807 2019-05-06  Keith Rollin  <krollin@apple.com>
1808
1809         Temporarily disable generate-xcfilelists
1810         https://bugs.webkit.org/show_bug.cgi?id=197619
1811         <rdar://problem/50507392>
1812
1813         Reviewed by Alex Christensen.
1814
1815         We need to perform a significant update to the generate-xcfilelist
1816         scripts. This work involves coordinated work with another facility. If
1817         the work does not occur in tandem, the build will be broken. To avoid
1818         this, disable the invoking of the scripts during the transition. The
1819         checking will be restored once the new scripts are in place.
1820
1821         * Scripts/check-xcfilelists.sh:
1822
1823 2019-05-06  Chris Dumez  <cdumez@apple.com>
1824
1825         Unreviewed build fix after r244984.
1826
1827         * WebProcess/cocoa/WebProcessCocoa.mm:
1828
1829 2019-05-06  Chris Dumez  <cdumez@apple.com>
1830
1831         Prewarmed WebContent processes never app nap
1832         https://bugs.webkit.org/show_bug.cgi?id=197630
1833
1834         Reviewed by Geoffrey Garen.
1835
1836         Do not require actually having a WebPage in the WebContent process to App Nap.
1837
1838         * WebProcess/WebPage/WebPage.cpp:
1839         (WebKit::WebPage::updateThrottleState):
1840         * WebProcess/cocoa/WebProcessCocoa.mm:
1841         (WebKit::WebProcess::platformInitializeWebProcess):
1842
1843 2019-05-06  Daniel Bates  <dabates@apple.com>
1844
1845         Fix the build after r244975
1846         (https://bugs.webkit.org/show_bug.cgi?id=197474)
1847
1848         Actually make use of the Keyboard Event when building with USE(UIKIT_KEYBOARD_ADDITIONS)
1849         and substitute -> for . since it's now passed by reference.
1850
1851         * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
1852         (WebKit::WebEditorClient::handleInputMethodKeydown):
1853
1854 2019-05-06  Jer Noble  <jer.noble@apple.com>
1855
1856         Adopt AVStreamDataParser.audiovisualMIMETypes
1857         https://bugs.webkit.org/show_bug.cgi?id=197581
1858         <rdar://problem/50458981>
1859
1860         Reviewed by Eric Carlson.
1861
1862         * WebProcess/cocoa/WebProcessCocoa.mm:
1863         (WebKit::WebProcess::platformInitializeWebProcess):
1864         (WebKit::WebProcess::platformTerminate):
1865         (WebKit::WebProcess::setMediaMIMETypes):
1866
1867 2019-05-06  Chris Dumez  <cdumez@apple.com>
1868
1869         Terminate service workers that use too much CPU / power
1870         https://bugs.webkit.org/show_bug.cgi?id=197626
1871         <rdar://problem/50374707>
1872
1873         Reviewed by Geoffrey Garen.
1874
1875         Terminate service worker processes that use over 50% CPU on average over the last 8 minutes,
1876         similarly to what we do for background WebContent processes.
1877
1878         * UIProcess/WebProcessProxy.cpp:
1879         (WebKit::WebProcessProxy::didExceedCPULimit):
1880         * WebProcess/WebProcess.cpp:
1881         (WebKit::WebProcess::initializeProcess):
1882         * WebProcess/cocoa/WebProcessCocoa.mm:
1883         (WebKit::WebProcess::updateCPULimit):
1884         (WebKit::WebProcess::updateCPUMonitorState):
1885
1886 2019-05-06  Daniel Bates  <dabates@apple.com>
1887
1888         Google Docs & Yahoo! Japan: Can’t compose characters with Chinese or Japanese keyboard
1889         https://bugs.webkit.org/show_bug.cgi?id=197474
1890         <rdar://problem/47219324>
1891
1892         Reviewed by Ryosuke Niwa.
1893
1894         Adopt UIKit SPI (added in <rdar://problem/50181162>) to ask the Input Manager to handle
1895         the key event. If the Input Manager handled it then we pass along this information to
1896         WebCore, just as we do for Mac, so that it can alter its event handling logic. Otherwise,
1897         we handle the event as we do now.
1898
1899         A large part of this patch is fixing up #if defs to compile more Mac code when building
1900         on iOS.
1901
1902         * Platform/spi/ios/UIKitSPI.h: Expose more SPI.
1903         * Shared/NativeWebKeyboardEvent.h:
1904         * Shared/WebEvent.h:
1905         * Shared/WebEventConversion.cpp:
1906         (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
1907         * Shared/WebKeyboardEvent.cpp:
1908         (WebKit::WebKeyboardEvent::WebKeyboardEvent):
1909         (WebKit::WebKeyboardEvent::encode const):
1910         (WebKit::WebKeyboardEvent::decode):
1911         * Shared/ios/NativeWebKeyboardEventIOS.mm:
1912         (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
1913         * Shared/ios/WebIOSEventFactory.h:
1914         * Shared/ios/WebIOSEventFactory.mm:
1915         (WebIOSEventFactory::createWebKeyboardEvent):
1916         Compile more Mac code on iOS. Just like on Mac we maintain some bookkeeping on
1917         whether an event was handled by the Input Manager.
1918
1919         * UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
1920         (WebKit::WebAutomationSession::sendSynthesizedEventsToPage): Pass NativeWebKeyboardEvent::HandledByInputMethod::No
1921         to keep the behavior we have now.
1922
1923         * UIProcess/ios/WKContentViewInteraction.h:
1924         * UIProcess/ios/WKContentViewInteraction.mm:
1925         (-[WKContentView cleanupInteraction]):
1926         (-[WKContentView shouldSuppressUpdateCandidateView]): Added. Used to tell UIKit whether to
1927         suppress updating/showing the candidate view.
1928         (-[WKContentView setMarkedText:selectedRange:]):
1929         Bookkeeping to track whether we need to delay showing/updating the inline candidate view.
1930         The concept in UIKit is deferment, but at the time of writing its simply a request to delay
1931         the update for 0.4 seconds. We opt into this delay only for the first key that begins
1932         marked text (i.e. the transition from no marked text to marked text). We do this because we
1933         may not have up-to-date editor state at the time UIKit is ready to show/update the inline
1934         candidate view for us to answer -textFirstRect and -textLastRect, which UIKit calls as part
1935         of computing the frame rect for the inline candidate view on screen. Once we receive up-to-date
1936         editor state, in -selectionChanged, we tell UIKit to layout the keyboard, which ultimately
1937         causes it to re-compute the frame rect for the inline candidate view and show it.
1938
1939         (-[WKContentView handleKeyWebEvent:]): Pass NativeWebKeyboardEvent::HandledByInputMethod::No
1940         to keep the behavior we have now. 
1941         (-[WKContentView handleKeyWebEvent:withCompletionHandler:]): Ask the keyboard to handle the
1942         event using the Input Manager. If it was handled then there is no need to delay calling the
1943         completion handler, call it, then tell the web process about the key event and that it was
1944         already handled by the Input Manager.
1945         (-[WKContentView _selectionChanged]): Tell the keyboard to update the candidate view, if needed.
1946         * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
1947         (WebKit::WebEditorClient::handleInputMethodKeydown): Mark the event as default handled if
1948         the UI process told us that the event was handled by the Input Manager just like we do on Mac.
1949
1950 2019-05-06  Alex Christensen  <achristensen@webkit.org>
1951
1952         Null check m_mainFrame in WebPageProxy.cpp
1953         https://bugs.webkit.org/show_bug.cgi?id=197618
1954         <rdar://problem/47463054>
1955
1956         Reviewed by Geoffrey Garen.
1957
1958         It's already null checked in some places, and the places where it isn't are causing crashes.
1959         Let's fix all of them.
1960
1961         * UIProcess/WebPageProxy.cpp:
1962         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
1963         (WebKit::WebPageProxy::decidePolicyForNewWindowAction):
1964         (WebKit::WebPageProxy::createNewPage):
1965
1966 2019-05-06  Brent Fulgham  <bfulgham@apple.com>
1967
1968         Use more efficient path resolution logic
1969         https://bugs.webkit.org/show_bug.cgi?id=197389
1970         <rdar://problem/50268491>
1971
1972         Reviewed by Maciej Stachowiak.
1973
1974         The code in SandboxExtensionsCocoa.mm 'resolveSymlinksInPath' is pretty inefficient, and tries to reproduce (badly)
1975         logic that is already provided by the operating system.
1976
1977         To make matters worse, 'resolvePathForSandboxExtension' was effectively performing the work of fully resolving
1978         symlinks twice, since NSString's 'stringByStandardizingPath' method does some of this already.
1979
1980         Instead, we should just use NSString's 'stringByResolvingSymlinksInPath', which does the symlink resolution
1981         using more efficient logic than our 'resolveSymlinksInPath' code.
1982
1983         * Shared/Cocoa/SandboxExtensionCocoa.mm:
1984         (WebKit::resolveSymlinksInPath): Removed.
1985         (WebKit::resolvePathForSandboxExtension): Remove redundant call to 'resolveSymlinksInPath', and switches from
1986         'stringByStandardizingPath' to 'stringByResolvingSymlinksInPath', which can take the place of both calls.
1987         (WebKit::stringByResolvingSymlinksInPath): Switch to call 'stringByResolvingSymlinksInPath'.
1988
1989 2019-05-06  Wenson Hsieh  <wenson_hsieh@apple.com>
1990
1991         Introduce SPI to request modern compatibility mode but defer to site-specific quirks
1992         https://bugs.webkit.org/show_bug.cgi?id=197614
1993         <rdar://problem/50208577>
1994
1995         Reviewed by Tim Horton.
1996
1997         Add plumbing for a new _allowSiteSpecificQuirksToOverrideCompatibilityMode SPI property on
1998         WKWebpagePreferences.
1999
2000         * UIProcess/API/APIWebsitePolicies.cpp:
2001         (API::WebsitePolicies::copy const):
2002         * UIProcess/API/APIWebsitePolicies.h:
2003         * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
2004         (-[WKWebpagePreferences _allowSiteSpecificQuirksToOverrideCompatibilityMode]):
2005         (-[WKWebpagePreferences _setAllowSiteSpecificQuirksToOverrideCompatibilityMode:]):
2006         * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
2007         * UIProcess/WebPageProxy.cpp:
2008
2009         Use currentRequest instead of originalRequest; see internal change for more details.
2010
2011         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
2012
2013 2019-05-06  Ryan Haddad  <ryanhaddad@apple.com>
2014
2015         Unreviewed, rolling out r244917.
2016
2017         Caused
2018         TestWebKitAPI.WKWebView.InitializingWebViewWithEphemeralStorageDoesNotLog
2019         failure on debug bots.
2020
2021         Reverted changeset:
2022
2023         "Use more efficient path resolution logic"
2024         https://bugs.webkit.org/show_bug.cgi?id=197389
2025         https://trac.webkit.org/changeset/244917
2026
2027 2019-05-04  Alex Christensen  <achristensen@webkit.org>
2028
2029         Revert r244953 and r244954 because they broke internal builds.
2030         https://bugs.webkit.org/show_bug.cgi?id=197534
2031
2032         * Platform/spi/ios/PDFKitSPI.h:
2033         * Platform/spi/ios/UIKitSPI.h: Added.
2034         (currentUserInterfaceIdiomIsPad):
2035         * Shared/DocumentEditingContext.mm:
2036         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
2037         * Shared/ios/NativeWebKeyboardEventIOS.mm:
2038         * Shared/ios/NativeWebTouchEventIOS.mm:
2039         * Shared/ios/WebIconUtilities.mm:
2040         * UIProcess/API/Cocoa/NSAttributedString.mm:
2041         * UIProcess/API/Cocoa/WKWebView.mm:
2042         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
2043         * UIProcess/API/Cocoa/WKWebViewInternal.h:
2044         * UIProcess/ApplicationStateTracker.mm:
2045         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
2046         * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
2047         * UIProcess/Cocoa/WKShareSheet.mm:
2048         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2049         * UIProcess/Gamepad/ios/UIGamepadProviderIOS.mm:
2050         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
2051         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h:
2052         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
2053         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
2054         * UIProcess/WKImagePreviewViewController.mm:
2055         * UIProcess/_WKTouchEventGenerator.mm:
2056         * UIProcess/ios/DragDropInteractionState.h:
2057         * UIProcess/ios/InputViewUpdateDeferrer.mm:
2058         * UIProcess/ios/PageClientImplIOS.mm:
2059         * UIProcess/ios/SmartMagnificationController.mm:
2060         * UIProcess/ios/TextCheckerIOS.mm:
2061         * UIProcess/ios/ViewGestureControllerIOS.mm:
2062         * UIProcess/ios/WKActionSheet.mm:
2063         * UIProcess/ios/WKActionSheetAssistant.mm:
2064         * UIProcess/ios/WKContentView.mm:
2065         * UIProcess/ios/WKContentViewInteraction.h:
2066         * UIProcess/ios/WKContentViewInteraction.mm:
2067         * UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm:
2068         * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
2069         * UIProcess/ios/WKPDFPageNumberIndicator.mm:
2070         * UIProcess/ios/WKPDFView.mm:
2071         * UIProcess/ios/WKPasswordView.mm:
2072         * UIProcess/ios/WKScrollView.h:
2073         * UIProcess/ios/WKScrollView.mm:
2074         * UIProcess/ios/WKSyntheticTapGestureRecognizer.h:
2075         * UIProcess/ios/WKWebEvent.mm:
2076         * UIProcess/ios/WebDataListSuggestionsDropdownIOS.h:
2077         * UIProcess/ios/WebPageProxyIOS.mm:
2078         * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
2079         * UIProcess/ios/forms/WKFileUploadPanel.mm:
2080         * UIProcess/ios/forms/WKFocusedFormControlView.h:
2081         * UIProcess/ios/forms/WKFormColorControl.mm:
2082         * UIProcess/ios/forms/WKFormColorPicker.mm:
2083         * UIProcess/ios/forms/WKFormInputControl.mm:
2084         * UIProcess/ios/forms/WKFormPopover.mm:
2085         * UIProcess/ios/forms/WKFormSelectControl.h:
2086         * UIProcess/ios/forms/WKFormSelectControl.mm:
2087         * UIProcess/ios/forms/WKFormSelectPicker.mm:
2088         * UIProcess/ios/forms/WKFormSelectPopover.mm:
2089         * UIProcess/ios/forms/WKNumberPadViewController.mm:
2090         * UIProcess/ios/forms/WKQuickboardListViewController.h:
2091         * UIProcess/ios/forms/WKSelectMenuListViewController.mm:
2092         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
2093         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
2094         * UIProcess/ios/fullscreen/WKFullscreenStackView.mm:
2095         * WebKit.xcodeproj/project.pbxproj:
2096         * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
2097         * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
2098         * WebProcess/WebPage/ios/WebPageIOS.mm:
2099         * WebProcess/cocoa/WebProcessCocoa.mm:
2100
2101 2019-05-04  Alex Christensen  <achristensen@webkit.org>
2102
2103         Merge the three UIKitSPI.h files into a single one in PAL
2104         https://bugs.webkit.org/show_bug.cgi?id=197534
2105
2106         Reviewed by Darin Adler.
2107
2108         * Platform/spi/ios/PDFKitSPI.h:
2109         * Platform/spi/ios/UIKitSPI.h: Removed.
2110         * Shared/DocumentEditingContext.mm:
2111         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
2112         * Shared/ios/NativeWebKeyboardEventIOS.mm:
2113         * Shared/ios/NativeWebTouchEventIOS.mm:
2114         * Shared/ios/WebIconUtilities.mm:
2115         * UIProcess/API/Cocoa/NSAttributedString.mm:
2116         * UIProcess/API/Cocoa/WKWebView.mm:
2117         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
2118         * UIProcess/API/Cocoa/WKWebViewInternal.h:
2119         * UIProcess/ApplicationStateTracker.mm:
2120         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
2121         * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
2122         * UIProcess/Cocoa/WKShareSheet.mm:
2123         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2124         * UIProcess/Gamepad/ios/UIGamepadProviderIOS.mm:
2125         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
2126         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h:
2127         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
2128         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
2129         * UIProcess/WKImagePreviewViewController.mm:
2130         * UIProcess/_WKTouchEventGenerator.mm:
2131         * UIProcess/ios/DragDropInteractionState.h:
2132         * UIProcess/ios/InputViewUpdateDeferrer.mm:
2133         * UIProcess/ios/PageClientImplIOS.mm:
2134         * UIProcess/ios/SmartMagnificationController.mm:
2135         * UIProcess/ios/TextCheckerIOS.mm:
2136         * UIProcess/ios/ViewGestureControllerIOS.mm:
2137         * UIProcess/ios/WKActionSheet.mm:
2138         * UIProcess/ios/WKActionSheetAssistant.mm:
2139         * UIProcess/ios/WKContentView.mm:
2140         * UIProcess/ios/WKContentViewInteraction.h:
2141         * UIProcess/ios/WKContentViewInteraction.mm:
2142         * UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm:
2143         * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
2144         * UIProcess/ios/WKPDFPageNumberIndicator.mm:
2145         * UIProcess/ios/WKPDFView.mm:
2146         * UIProcess/ios/WKPasswordView.mm:
2147         * UIProcess/ios/WKScrollView.h:
2148         * UIProcess/ios/WKScrollView.mm:
2149         * UIProcess/ios/WKSyntheticTapGestureRecognizer.h:
2150         * UIProcess/ios/WKWebEvent.mm:
2151         * UIProcess/ios/WebDataListSuggestionsDropdownIOS.h:
2152         * UIProcess/ios/WebPageProxyIOS.mm:
2153         * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
2154         * UIProcess/ios/forms/WKFileUploadPanel.mm:
2155         * UIProcess/ios/forms/WKFocusedFormControlView.h:
2156         * UIProcess/ios/forms/WKFormColorControl.mm:
2157         * UIProcess/ios/forms/WKFormColorPicker.mm:
2158         * UIProcess/ios/forms/WKFormInputControl.mm:
2159         * UIProcess/ios/forms/WKFormPopover.mm:
2160         * UIProcess/ios/forms/WKFormSelectControl.h:
2161         * UIProcess/ios/forms/WKFormSelectControl.mm:
2162         * UIProcess/ios/forms/WKFormSelectPicker.mm:
2163         * UIProcess/ios/forms/WKFormSelectPopover.mm:
2164         * UIProcess/ios/forms/WKNumberPadViewController.mm:
2165         * UIProcess/ios/forms/WKQuickboardListViewController.h:
2166         * UIProcess/ios/forms/WKSelectMenuListViewController.mm:
2167         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
2168         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
2169         * UIProcess/ios/fullscreen/WKFullscreenStackView.mm:
2170         * WebKit.xcodeproj/project.pbxproj:
2171         * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
2172         * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
2173         * WebProcess/WebPage/ios/WebPageIOS.mm:
2174         * WebProcess/cocoa/WebProcessCocoa.mm:
2175
2176 2019-05-03  Wenson Hsieh  <wenson_hsieh@apple.com>
2177
2178         REGRESSION (r244897): Caret may appear wider than normal after zooming to focus an editable element
2179         https://bugs.webkit.org/show_bug.cgi?id=197579
2180
2181         Reviewed by Tim Horton.
2182
2183         Fixes a couple of flaky tests (CaretSelectionRectAfterRestoringFirstResponderWithRetainActiveFocusedState and
2184         CaretSelectionRectAfterRestoringFirstResponder) that began failing after r244897. These tests both begin by
2185         focusing an editable element, which causes the web view to zoom in. The tests subsequently check that the caret
2186         rect is {{ 16, 13 }, { 2, 15 }}. While the specified caret rect (coming from EditorState) is {{ 16, 13 }, { 3,
2187         15 }}, the narrower caret rect is used because we take measures to preserve the width of the caret relative to
2188         the view (see the inverse scaling logic in -[WKContentView selectedTextRange] for more details).
2189
2190         See below for more details.
2191
2192         * UIProcess/ios/WKContentViewInteraction.h:
2193
2194         Remove _isZoomingToRevealFocusedElement, now that we don't need it anymore (see -observeValueForKeyPath:).
2195
2196         * UIProcess/ios/WKContentViewInteraction.mm:
2197         (-[WKContentView cleanupInteraction]):
2198         (-[WKContentView observeValueForKeyPath:ofObject:change:context:]):
2199
2200         Stop bailing from a selection update when changing scale, while zooming to reveal the focused element. This
2201         check was added in r239441 to prevent UIWKTextInteractionAssistant's selection scrolling logic from interfering
2202         with WKContentView-driven logic for zooming to the focused element. However, since r244141, this is no longer
2203         necessary since selection scrolling is only driven by code in the web process.
2204
2205         This new update while zooming to reveal the focused element ensures that the WKTextRange returned by
2206         -selectedTextRange after zooming will have a width that is inversely scaled using the content view's current
2207         scale, such that it has a consistent width (relative to the web view) across different scales.
2208
2209         (-[WKContentView _zoomToRevealFocusedElement]):
2210         * UIProcess/ios/WebPageProxyIOS.mm:
2211         (WebKit::WebPageProxy::layerTreeCommitComplete):
2212
2213         Remove any attempt here to notify PageClient about editor states after focus. This logic was actually incorrect,
2214         since it didn't ensure that the layer tree commit that is being completed actually contained an editor state; as
2215         such, the "editor state" received here could be stale.
2216
2217 2019-05-03  Zalan Bujtas  <zalan@apple.com>
2218
2219         [iOS] outlook.live.com: Compose email frame not fully visible and not scrollable
2220         https://bugs.webkit.org/show_bug.cgi?id=197573
2221         <rdar://problem/48008441>
2222
2223         Reviewed by Wenson Hsieh.
2224
2225         * WebProcess/WebPage/WebPage.h:
2226         * WebProcess/WebPage/ios/WebPageIOS.mm:
2227         (WebKit::WebPage::adjustLayoutSizeIfNeeded):
2228         (WebKit::WebPage::setViewportConfigurationViewLayoutSize):
2229         (WebKit::WebPage::dynamicViewportSizeUpdate):
2230         (WebKit::WebPage::immediatelyShrinkToFitContent):
2231
2232 2019-05-03  Dean Jackson  <dino@apple.com>
2233
2234         Make imageForElementActionType a class method on _WKElementAction
2235         https://bugs.webkit.org/show_bug.cgi?id=197588
2236         <rdar://problem/50463157>
2237
2238         Reviewed by Wenson Hsieh.
2239
2240         Make this helper function a class method, so that it can
2241         be more easily detected.
2242
2243         * UIProcess/API/Cocoa/_WKElementAction.h:
2244         * UIProcess/API/Cocoa/_WKElementAction.mm:
2245         (+[_WKElementAction imageForElementActionType:]):
2246         (_WKUIImageForElementActionType): Deleted.
2247
2248 2019-05-03  Chris Dumez  <cdumez@apple.com>
2249
2250         Unresponsive Service Worker processes should get killed
2251         https://bugs.webkit.org/show_bug.cgi?id=197580
2252         <rdar://problem/50458239>
2253
2254         Reviewed by Geoffrey Garen.
2255
2256         Enable the background responsiveness logic for service worker processes so that they get
2257         killed if they becomes unresponsive. The logic was previously not enabling the timer for
2258         service worker processes because it required having a page.
2259
2260         * UIProcess/BackgroundProcessResponsivenessTimer.cpp:
2261         (WebKit::BackgroundProcessResponsivenessTimer::shouldBeActive const):
2262         * UIProcess/WebProcessProxy.cpp:
2263         (WebKit::WebProcessProxy::didBecomeUnresponsive):
2264         (WebKit::WebProcessProxy::didFinishLaunching):
2265
2266 2019-05-03  Youenn Fablet  <youenn@apple.com>
2267
2268         [iOS] set the default maximum camera count to 1 for enumerateDevices
2269         https://bugs.webkit.org/show_bug.cgi?id=197566
2270
2271         Reviewed by Eric Carlson.
2272
2273         The previous number for iOS was 2 as there is a front and a back camera.
2274         Since we are by default setting deviceIds to "", it is better to just have one,
2275         as it might confuse applications to have two devices with the same ID.
2276
2277         Covered by updated test.
2278
2279         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
2280         (WebKit::UserMediaPermissionRequestManagerProxy::computeFilteredDeviceList):
2281
2282 2019-05-03  Daniel Bates  <dabates@apple.com>
2283
2284         Pass KeyboardEvent by reference in more places
2285         https://bugs.webkit.org/show_bug.cgi?id=197480
2286
2287         Reviewed by Wenson Hsieh.
2288
2289         * WebProcess/WebCoreSupport/WebEditorClient.cpp:
2290         (WebKit::WebEditorClient::handleKeyboardEvent):
2291         (WebKit::WebEditorClient::handleInputMethodKeydown):
2292         * WebProcess/WebCoreSupport/WebEditorClient.h:
2293         * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
2294         (WebKit::WebEditorClient::handleKeyboardEvent):
2295         (WebKit::WebEditorClient::handleInputMethodKeydown):
2296         * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
2297         (WebKit::WebEditorClient::handleKeyboardEvent):
2298         (WebKit::WebEditorClient::handleInputMethodKeydown):
2299         * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
2300         (WebKit::WebEditorClient::handleKeyboardEvent):
2301         (WebKit::WebEditorClient::handleInputMethodKeydown):
2302         * WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:
2303         (WebKit::WebEditorClient::handleKeyboardEvent):
2304         (WebKit::WebEditorClient::handleInputMethodKeydown):
2305         * WebProcess/WebPage/WebPage.h:
2306         * WebProcess/WebPage/ios/WebPageIOS.mm:
2307         (WebKit::WebPage::handleEditingKeyboardEvent):
2308         * WebProcess/WebPage/mac/WebPageMac.mm:
2309         (WebKit::WebPage::handleEditingKeyboardEvent):
2310         * WebProcess/WebPage/win/WebPageWin.cpp:
2311         (WebKit::WebPage::handleEditingKeyboardEvent):
2312
2313 2019-05-03  Youenn Fablet  <youenn@apple.com>
2314
2315         Enable Fetch Keep Alive by default
2316         https://bugs.webkit.org/show_bug.cgi?id=197331
2317
2318         Reviewed by Geoffrey Garen.
2319
2320         * Shared/WebPreferences.yaml:
2321
2322 2019-05-03  Devin Rousso  <drousso@apple.com>
2323
2324         REGRESSION(r230367): a "." is prepended before cookies set without an explicit domain
2325         https://bugs.webkit.org/show_bug.cgi?id=197268
2326         <rdar://problem/49767847>
2327
2328         Reviewed by Alex Christensen.
2329
2330         RFC 2965 states "If an explicitly specified value does not start with a dot, the user agent
2331         supplies a leading dot.", so we should only be adding a leading "." if a `domain` is provided.
2332
2333         In order to not regress r230367, also delete all cookies for the non-"."-prefixed domain.
2334
2335         * UIProcess/Automation/WebAutomationSession.cpp:
2336         (WebKit::WebAutomationSession::addSingleCookie):
2337         (WebKit::WebAutomationSession::deleteAllCookies):
2338
2339         * UIProcess/WebCookieManagerProxy.h:
2340         * UIProcess/WebCookieManagerProxy.cpp:
2341         (WebKit::WebCookieManagerProxy::deleteCookiesForHostnames): Added.
2342         (WebKit::WebCookieManagerProxy::deleteCookiesForHostname): Deleted.
2343         * UIProcess/API/C/WKCookieManager.cpp:
2344         (WKCookieManagerDeleteCookiesForHostname):
2345         * NetworkProcess/Cookies/WebCookieManager.messages.in:
2346         * NetworkProcess/Cookies/WebCookieManager.h:
2347         * NetworkProcess/Cookies/WebCookieManager.cpp:
2348         (WebKit::WebCookieManager::deleteCookiesForHostnames): Added.
2349         (WebKit::WebCookieManager::deleteCookiesForHostname): Deleted.
2350         Since the underlying `NetworkStorageSession` accepts a list of domains, extend that support
2351         to allow the IPC to send a list of domains as well, but still keep the C API the same.
2352
2353 2019-05-03  Sihui Liu  <sihui_liu@apple.com>
2354
2355         Add assertion to check whether shm files have maximum FileProtection of CompleteUnlessOpen
2356         https://bugs.webkit.org/show_bug.cgi?id=197390
2357         <rdar://problem/42685773>
2358
2359         Reviewed by Geoffrey Garen.
2360
2361         Move data protection check to WebCore so it can be applied to database files.
2362
2363         * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
2364         (WebKit::NetworkCache::BlobStorage::add):
2365         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
2366         (WebKit::NetworkCache::makeSafeToUseMemoryMapForPath): Deleted.
2367         * NetworkProcess/cache/NetworkCacheFileSystem.h:
2368         * NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm: Removed.
2369         * SourcesCocoa.txt:
2370         * UIProcess/API/APIContentRuleListStore.cpp:
2371         (API::openAndMapOrCopyContentRuleList):
2372         (API::compiledToFile):
2373
2374 2019-05-03  Chris Dumez  <cdumez@apple.com>
2375
2376         ASSERTION FAILED: [weakThis->m_view window] == weakThis->m_targetWindowForMovePreparation
2377         https://bugs.webkit.org/show_bug.cgi?id=197574
2378         <rdar://problem/50453181>
2379
2380         Reviewed by Tim Horton.
2381
2382         Tweak the assertion so that it holds even if the WebView gets closed because the completion
2383         handler has been called.
2384
2385         * UIProcess/Cocoa/WebViewImpl.mm:
2386         (WebKit::WebViewImpl::prepareForMoveToWindow):
2387
2388 2019-05-03  Brent Fulgham  <bfulgham@apple.com>
2389
2390         Use more efficient path resolution logic
2391         https://bugs.webkit.org/show_bug.cgi?id=197389
2392         <rdar://problem/50268491>
2393
2394         Reviewed by Maciej Stachowiak.
2395
2396         The code in SandboxExtensionsCocoa.mm 'resolveSymlinksInPath' is pretty inefficient, and tries to reproduce (badly)
2397         logic that is already provided by the operating system.
2398
2399         To make matters worse, 'resolvePathForSandboxExtension' was effectively performing the work of fully resolving
2400         symlinks twice, since NSString's 'stringByStandardizingPath' method does some of this already.
2401
2402         Instead, we should just use NSString's 'stringByResolvingSymlinksInPath', which does the symlink resolution
2403         using more efficient logic than our 'resolveSymlinksInPath' code.
2404
2405         * Shared/Cocoa/SandboxExtensionCocoa.mm:
2406         (WebKit::resolveSymlinksInPath): Removed.
2407         (WebKit::resolvePathForSandboxExtension): Remove redundant call to 'resolveSymlinksInPath', and switches from
2408         'stringByStandardizingPath' to 'stringByResolvingSymlinksInPath', which can take the place of both calls.
2409         (WebKit::stringByResolvingSymlinksInPath): Switch to call 'stringByResolvingSymlinksInPath'.
2410
2411 2019-05-02  Dean Jackson  <dino@apple.com>
2412
2413         Need additional UIPreviewAction information in WKImagePreviewViewController
2414         https://bugs.webkit.org/show_bug.cgi?id=197540
2415         <rdar://problem/50430510>
2416
2417         Reviewed by Wenson Hsieh.
2418
2419         Include a WebKitAdditions file to provide a macro for
2420         additional UIPreviewAction information.
2421
2422         While here, take the opportunity to move from the deprecated
2423         UIViewControllerPreviewAction to the newer UIPreviewAction.
2424
2425         * UIProcess/WKImagePreviewViewController.mm:
2426         (-[WKImagePreviewViewController previewActionItems]):
2427
2428 2019-05-02  Dean Jackson  <dino@apple.com>
2429
2430         Provide UIImages for element actions
2431         https://bugs.webkit.org/show_bug.cgi?id=197539
2432         <rdar://problem/50430363>
2433
2434         Reviewed by Wenson Hsieh.
2435
2436         Use an additions include to export a function that
2437         relates a UIImage to a _WKElementAction.
2438
2439         * UIProcess/API/Cocoa/_WKElementAction.h:
2440         * UIProcess/API/Cocoa/_WKElementAction.mm:
2441         (_WKUIImageForElementActionType):
2442
2443 2019-05-03  Jay Mulani  <jmulani@apple.com>
2444
2445         Expose full screen controller SPI to check if full screen is open and close full screen
2446         https://bugs.webkit.org/show_bug.cgi?id=197263
2447
2448         Reviewed by Jer Noble.
2449
2450         * UIProcess/API/Cocoa/WKWebView.mm:
2451         (-[WKWebView closeFullScreenWindowController]):
2452         (-[WKWebView fullScreenWindowController]):
2453         * UIProcess/API/Cocoa/WKWebViewInternal.h:
2454         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2455
2456 2019-05-03  Youenn Fablet  <youenn@apple.com>
2457
2458         LayoutTest imported/w3c/web-platform-tests/xhr/event-upload-progress-crossorigin.htm is a flaky failure
2459         https://bugs.webkit.org/show_bug.cgi?id=182849
2460         <rdar://problem/50353372>
2461
2462         Reviewed by Alex Christensen.
2463
2464         In case of restarting the load after a redirection, which now happens in case
2465         of following cross origin redirections with same-origin credentials, make sure to
2466         update the request as would do NetworkLoad.
2467         This is in particular important to preserve the request body.
2468
2469         Covered by WPT updated test.
2470
2471         * NetworkProcess/NetworkLoad.cpp:
2472         (WebKit::updateRequest):
2473         (WebKit::NetworkLoad::updateRequestAfterRedirection const):
2474         (WebKit::NetworkLoad::continueWillSendRequest):
2475         * NetworkProcess/NetworkLoad.h:
2476         * NetworkProcess/NetworkResourceLoader.cpp:
2477         (WebKit::NetworkResourceLoader::continueWillSendRequest):
2478
2479 2019-05-03  Commit Queue  <commit-queue@webkit.org>
2480
2481         Unreviewed, rolling out r244881.
2482         https://bugs.webkit.org/show_bug.cgi?id=197559
2483
2484         Breaks compilation of jsconly on linux, breaking compilation
2485         for jsc-i386-ews, jsc-mips-ews and jsc-armv7-ews (Requested by
2486         guijemont on #webkit).
2487
2488         Reverted changeset:
2489
2490         "[CMake] Refactor WEBKIT_MAKE_FORWARDING_HEADERS into
2491         WEBKIT_COPY_FILES"
2492         https://bugs.webkit.org/show_bug.cgi?id=197174
2493         https://trac.webkit.org/changeset/244881
2494
2495 2019-05-02  Wenson Hsieh  <wenson_hsieh@apple.com>
2496
2497         REGRESSION: Layout test editing/selection/ios/selection-after-changing-text-with-callout-menu.html is failing
2498         https://bugs.webkit.org/show_bug.cgi?id=197532
2499         <rdar://problem/50177144>
2500
2501         Reviewed by Ryosuke Niwa.
2502
2503         Fixes layout tests that began failing after r244546. See below for details.
2504
2505         * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
2506         (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
2507
2508         Partially reverts a change in r244546, after which we commit the layer tree and scroll before updating the
2509         page's editor state. The purpose of this change was to ensure that UI process-side element focus scrolling logic
2510         would not conflict with web-process-driven scrolling logic.
2511
2512         Instead, we split the existing logic in WebPageProxy::editorStateChanged into two pieces: one that updates the
2513         editor state (by setting m_editorState), and a second that dispatches updates to PageClient when the first
2514         editor state is received after focusing an element. During a layer tree commit in the UI process, we first
2515         update the editor state, then commit the layer tree and apply scroll position changes, and finally scroll to
2516         reveal the focused element if necessary.
2517
2518         When an editor state is delivered to the UI process in an out-of-band update (i.e. not in a layer tree commit),
2519         simply dispatch the initial editor state for a focused element immediately.
2520
2521         * UIProcess/WebPageProxy.cpp:
2522         (WebKit::WebPageProxy::scheduleFullEditorStateUpdate):
2523
2524         Add an IPC message to schedule an editor state update in the next remote layer tree commit. See below for more
2525         details.
2526
2527         (WebKit::WebPageProxy::editorStateChanged):
2528         (WebKit::WebPageProxy::dispatchDidReceiveEditorStateAfterFocus):
2529         * UIProcess/WebPageProxy.h:
2530         * UIProcess/gtk/WebPageProxyGtk.cpp:
2531         (WebKit::WebPageProxy::updateEditorState):
2532         (WebKit::WebPageProxy::editorStateChanged): Deleted.
2533         * UIProcess/ios/WKContentViewInteraction.mm:
2534         (-[WKContentView willFinishIgnoringCalloutBarFadeAfterPerformingAction]):
2535
2536         Additionally ensure that an editor state update is scheduled. This addresses a potential source of flakiness in
2537         the layout test editing/selection/ios/selection-after-changing-text-with-callout-menu.html, where an editor
2538         state update may only be scheduled after the next layout timer fires (this is the case in custom callout menu
2539         actions that change the DOM but do not otherwise trigger any editing commands).
2540
2541         In the problematic scenario, the client could make a change that triggers layout soon; but before the layout
2542         timer fires, the timer for the next remote layer tree commit could fire, such that the next layer tree commit
2543         would not contain the relevant editor state.
2544
2545         This extra step ensures that we always *schedule* an editor state update when performing a callout menu action
2546         that does not automatically dismiss, so that we can prevent the callout bar from dismissing during the correct
2547         scope.
2548
2549         * UIProcess/ios/WebPageProxyIOS.mm:
2550         (WebKit::WebPageProxy::layerTreeCommitComplete):
2551         (WebKit::WebPageProxy::updateEditorState):
2552
2553         Rename editorStateChanged to updateEditorState, and make the editorStateChanged codepath only executed when an
2554         out-of-band editor state update is delivered to the UI process.
2555
2556         (WebKit::WebPageProxy::dispatchDidReceiveEditorStateAfterFocus):
2557
2558         Notify the UI process that the initial editor state has been received; this prompts us to scroll to reveal the
2559         focused element, if needed.
2560
2561         (WebKit::WebPageProxy::editorStateChanged): Deleted.
2562         * UIProcess/mac/WebPageProxyMac.mm:
2563         (WebKit::WebPageProxy::updateEditorState):
2564         (WebKit::WebPageProxy::editorStateChanged): Deleted.
2565         * UIProcess/win/WebPageProxyWin.cpp:
2566         (WebKit::WebPageProxy::updateEditorState):
2567         (WebKit::WebPageProxy::editorStateChanged): Deleted.
2568         * UIProcess/wpe/WebPageProxyWPE.cpp:
2569         (WebKit::WebPageProxy::updateEditorState):
2570         (WebKit::WebPageProxy::editorStateChanged): Deleted.
2571         * WebProcess/WebPage/WebPage.h:
2572         * WebProcess/WebPage/WebPage.messages.in:
2573
2574 2019-05-02  Timothy Hatcher  <timothy@apple.com>
2575
2576         NSAttributedString conversion in a loop returns nil and WKUnknownError every other time.
2577         https://bugs.webkit.org/show_bug.cgi?id=197523
2578
2579         Reviewed by Darin Adler.
2580
2581         Caching the WKWebView was loading about:blank to unload the previous content.
2582         This was causing subsequent rapid conversions to fail since the blank load
2583         would be confused with the real content loading. Loading a blank page wasn't
2584         really needed, it just helped keep the cached view in a cleaner state. Instead
2585         of adding complexity to track the extra navigation, we can eliminate the blank load.
2586         Ultimately a process swap will likely happen on the next navigation, and unused
2587         cached views are closed quickly -- so stale content isn't held around too long.
2588         This also avoids extra work and speeds up conversions a bit.
2589
2590         * UIProcess/API/Cocoa/NSAttributedString.mm:
2591         (+[_WKAttributedStringWebViewCache cacheWebView:]): Don't load about:blank when caching.
2592         * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
2593         (WebKit::WebPage::getContentsAsAttributedString): Use rangeOfContents() for a fail
2594         safe way to get the range needed.
2595
2596 2019-05-02  John Wilander  <wilander@apple.com>
2597
2598         Make both filterForRegistrableDomains() in WebKit::NetworkProcess use WebCore::RegistrableDomain::uncheckedCreateFromHost()
2599         https://bugs.webkit.org/show_bug.cgi?id=197521
2600         <rdar://problem/49651503>
2601
2602         Reviewed by Brent Fulgham.
2603
2604         * NetworkProcess/NetworkProcess.cpp:
2605         (WebKit::filterForRegistrableDomains):
2606
2607 2019-05-02  Per Arne Vollan  <pvollan@apple.com>
2608
2609         -[WKWebsiteDataStore removeDataOfTypes:forDataRecords:completionHandler:] doesn't delete _WKWebsiteDataTypeCredentials
2610         https://bugs.webkit.org/show_bug.cgi?id=197510
2611         <rdar://problem/50372338>
2612
2613         Reviewed by Alex Christensen.
2614
2615         When asked to delete persistent credentials for a set of origins, send a message to the network process with the
2616         list of origins. The network process will then delete all persistent credentials from these origins from
2617         NSURLCredentialStorage.
2618
2619         * NetworkProcess/NetworkProcess.cpp:
2620         (WebKit::NetworkProcess::removeCredentialsWithOrigins):
2621         * NetworkProcess/NetworkProcess.h:
2622         * NetworkProcess/NetworkProcess.messages.in:
2623         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
2624         (WebKit::NetworkProcess::removeCredentialsWithOrigins):
2625         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2626         (WebKit::WebsiteDataStore::removeData):
2627
2628 2019-05-02  Don Olmstead  <don.olmstead@sony.com>
2629
2630         [CMake] Refactor WEBKIT_MAKE_FORWARDING_HEADERS into WEBKIT_COPY_FILES
2631         https://bugs.webkit.org/show_bug.cgi?id=197174
2632
2633         Reviewed by Alex Christensen.
2634
2635         Replace WEBKIT_MAKE_FORWARDING_HEADERS with WEBKIT_COPY_FILES and make dependencies
2636         for framework headers explicit.
2637
2638         * CMakeLists.txt:
2639         * PlatformWin.cmake:
2640
2641 2019-05-02  Per Arne Vollan  <pvollan@apple.com>
2642
2643         [macOS] Fix syscall sandbox violation
2644         https://bugs.webkit.org/show_bug.cgi?id=197517
2645         <rdar://problem/49945031>
2646
2647         Reviewed by Brent Fulgham.
2648
2649         A syscall needs to be added to the sandbox on macOS.
2650
2651         * WebProcess/com.apple.WebProcess.sb.in:
2652
2653 2019-05-02  Alex Christensen  <achristensen@webkit.org>
2654
2655         Safe browsing warning should update colors when a user switches between light and dark appearance
2656         https://bugs.webkit.org/show_bug.cgi?id=197443
2657         <rdar://problem/49883917>
2658
2659         Reviewed by Tim Horton.
2660
2661         We draw the WKSafeBrowsingExclamationPoint ourselves, so we need to call setNeedsDisplay when viewDidChangeEffectiveAppearance is called.
2662         Instead of setting NSView.layer.backgroundColor we need to make an NSView subclass I call WKSafeBrowsingBox and we need to set its layer's
2663         backgroundColor in updateLayer, otherwise the CGColor isn't updated from the NSColor.
2664
2665         * UIProcess/Cocoa/WKSafeBrowsingWarning.h:
2666         * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
2667         (colorForItem):
2668         (-[WKSafeBrowsingExclamationPoint viewDidChangeEffectiveAppearance]):
2669         (-[WKSafeBrowsingBox setSafeBrowsingBackgroundColor:]):
2670         (-[WKSafeBrowsingBox updateLayer]):
2671         (-[WKSafeBrowsingWarning initWithFrame:safeBrowsingWarning:completionHandler:]):
2672         (-[WKSafeBrowsingWarning addContent]):
2673         (-[WKSafeBrowsingWarning showDetailsClicked]):
2674         (setBackground): Deleted.
2675
2676 2019-05-02  Frederic Wang  <fwang@igalia.com>
2677
2678         [GTK][WPE] Disable "thin", "thick", "medium" values of mfrac@linethickness at runtime
2679         https://bugs.webkit.org/show_bug.cgi?id=196142
2680
2681         This patch introduces some experimental runtime flag to let users
2682         disable MathML features that are removed from MathML Core [1]. For now,
2683         these features are only disabled on GTK and WPE ports.
2684
2685         [1] https://mathml-refresh.github.io/mathml-core/
2686
2687         Reviewed by Rob Buis.
2688
2689         * Shared/WebPreferences.yaml:
2690         * Shared/WebPreferencesDefaultValues.h:
2691
2692 2019-05-01  Wenson Hsieh  <wenson_hsieh@apple.com>
2693
2694         Add the ability to import WebKitAdditions snippets in WebKit.apinotes
2695         https://bugs.webkit.org/show_bug.cgi?id=197487
2696         <rdar://problem/50389085>
2697
2698         Reviewed by Tim Horton.
2699
2700         * Shared/API/Cocoa/WebKit.apinotes: Import a new WebKitAdditions file.
2701
2702         * WebKit.xcodeproj/project.pbxproj: Check all files in Headers/ and PrivateHeaders/ that need replacement, not
2703         simply anything ending with ".h".
2704
2705         * mac/replace-webkit-additions-includes.py:
2706         (main): Teach the replacement script to handle files in Headers/ or PrivateHeaders/ that don't end in ".h".
2707
2708 2019-05-01  Alex Christensen  <achristensen@webkit.org>
2709
2710         Protect against null crash in fetchDiskCacheEntries
2711         https://bugs.webkit.org/show_bug.cgi?id=197399
2712         <rdar://problem/47759337>
2713
2714         Reviewed by Antti Koivisto.
2715
2716         If the call to Entry::decodeStorageRecord returns nullptr in Storage::traverse, do not call the traverseHandler, which expects
2717         that when it is called with nullptr that is the end of the traversal.
2718
2719         * NetworkProcess/cache/NetworkCache.cpp:
2720         (WebKit::NetworkCache::Cache::traverse):
2721
2722 2019-05-01  Wenson Hsieh  <wenson_hsieh@apple.com>
2723
2724         [iOS] Add a version of viewport shrink-to-fit heuristics that preserves page layout
2725         https://bugs.webkit.org/show_bug.cgi?id=197342
2726         <rdar://problem/50063091>
2727
2728         Reviewed by Tim Horton.
2729
2730         This patch introduces a new shrink-to-fit heuristic that attempts to lay out the contents of the page at a
2731         larger width in order to shrink content to fit the viewport. This is similar to existing shrink-to-fit behaviors
2732         used for viewport sizing in multitasking mode, except that it not only scales the view, but additionally expands
2733         the layout size, such that the overall layout of the page is preserved. In fact, the reason we ended up
2734         reverting the existing flavor of shrink-to-fit in all cases except for multitasking was that page layout was not
2735         preserved, which caused elements that poke out of the viewport to make the rest of the page look out of
2736         proportion — see <rdar://problem/23818102> and related radars.
2737
2738         Covered by 5 new layout tests, and by adjusting a couple of existing layout tests. See comments below for more
2739         details.
2740
2741         * Platform/Logging.h:
2742
2743         Add a new ViewportSizing logging channel. This will only log on pages that overflow the viewport and shrink to
2744         fit as a result.
2745
2746         * Shared/WebPreferences.yaml:
2747
2748         Turn IgnoreViewportScalingConstraints off by default. This preference currently controls whether we allow
2749         shrink-to-fit behaviors, and is only used by Safari when it is in multitasking mode. The value of this
2750         preference is currenly *on* by default, and is turned off almost immediately during every page load after the
2751         first visible content rect update, wherein visibleContentRectUpdateInfo.allowShrinkToFit() is false.
2752
2753         However, this sometimes causes a brief jitter during page load; to fix this, make the default value for
2754         IgnoreViewportScalingConstraints false, and change the logic in WebPage::updateVisibleContentRects to
2755         setCanIgnoreScalingConstraints to true if either the IgnoreViewportScalingConstraints preference (not only
2756         affected by an internal debug switch) is true, or WKWebView SPI is used to enable the behavior.
2757
2758         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2759         (WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad):
2760         (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad):
2761
2762         Add a new hook for WebFrameLoaderClient to call into WebPage when document load finishes. Also, tweak
2763         dispatchDidFinishLoad to take a WebFrame& instead of a WebFrame* in a drive-by fix (the frame is assumed to be
2764         non-null anyways).
2765
2766         * WebProcess/WebPage/WebPage.cpp:
2767         (WebKit::WebPage::didCommitLoad):
2768         (WebKit::WebPage::didFinishDocumentLoad):
2769         (WebKit::WebPage::didFinishLoad):
2770
2771         When finishing document load or finishing the overall load, kick off the shrink-to-fit timer; when committing a
2772         load, cancel the timer.
2773
2774         * WebProcess/WebPage/WebPage.h:
2775         * WebProcess/WebPage/ios/WebPageIOS.mm:
2776         (WebKit::WebPage::setViewportConfigurationViewLayoutSize):
2777
2778         Don't allow the minimum effective device width from the client to stomp over any minimum effective device width
2779         set as a result of the new shrink-to-fit heuristic; on some pages that load quickly, this can result in a race
2780         where the minimum effective device width (i.e. a value that lower-bounds the minimum layout width) is first set
2781         by the shrink-to-fit heuristic, and then set to an incorrect value by the client.
2782
2783         In the near future, web view SPI used to set the minimum effective device width should actually be removed
2784         altogether, since the new shrink-to-fit heuristic supersedes any need for the client to fiddle with the minimum
2785         effective device width.
2786
2787         (WebKit::WebPage::dynamicViewportSizeUpdate):
2788
2789         When performing a dynamic viewport size update, additionally re-run the shrink-to-fit heuristic. This allows
2790         the minimum layout size of the viewport to be updated, if necessary. An example of where this matters is when a
2791         web page is *below* a tablet/desktop layout breakpoint in portrait device orientation, but then exceeds this
2792         layout breakpoint in landscape orientation. In this scenario, rotating the device should swap between these two
2793         page layouts.
2794
2795         (WebKit::WebPage::resetViewportDefaultConfiguration):
2796         (WebKit::WebPage::scheduleShrinkToFitContent):
2797         (WebKit::WebPage::shrinkToFitContentTimerFired):
2798         (WebKit::WebPage::immediatelyShrinkToFitContent):
2799
2800         Leverage the existing capability for a viewport to have a "minimum effective device width" to grant the viewport
2801         a larger layout size than it would normally have, and then scale down to fit within the bounds of the view. One
2802         challenge with this overall approach is that laying out at a larger width may cause the page to lay out even
2803         wider in response, which may actually worsen horizontal scrolling. To mitigate this, we only attempt to lay out
2804         at the current content width once; if laying out at this width reduced the amount of horizontal scrolling by any
2805         amount, then proceed with this layout width; otherwise, revert to the previous layout width.
2806
2807         (WebKit::WebPage::shouldIgnoreMetaViewport const):
2808
2809         Pull some common logic out into a readonly getter.
2810
2811         (WebKit::WebPage::updateVisibleContentRects):
2812
2813         See the comment below WebPreferences.yaml, above.
2814
2815 2019-05-01  Dean Jackson  <dino@apple.com>
2816
2817         Link Previews that use WKImagePreviewViewController are not always scaled correctly
2818         https://bugs.webkit.org/show_bug.cgi?id=197450
2819         <rdar://problem/50357695>
2820
2821         Reviewed by Wenson Hsieh.
2822
2823         Tell the UIImageView that we create in WKImagePreviewViewController to use
2824         a filling scaling method.
2825
2826         * UIProcess/WKImagePreviewViewController.mm:
2827         (-[WKImagePreviewViewController initWithCGImage:defaultActions:elementInfo:]):
2828
2829 2019-05-01  Darin Adler  <darin@apple.com>
2830
2831         WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support
2832         https://bugs.webkit.org/show_bug.cgi?id=195535
2833
2834         Reviewed by Alexey Proskuryakov.
2835
2836         * Shared/API/APIString.h: Removed uneeded includes and also switched to #pragma once.
2837
2838         * Shared/API/c/WKString.cpp: Moved include of UTF8Conversion.h here.
2839         (WKStringGetUTF8CStringImpl): Updated for changes to return values.
2840
2841 2019-05-01  Shawn Roberts  <sroberts@apple.com>
2842
2843         Unreviewed, rolling out r244821.
2844
2845         Causing
2846
2847         Reverted changeset:
2848
2849         "WebKit has too much of its own UTF-8 code and should rely
2850         more on ICU's UTF-8 support"
2851         https://bugs.webkit.org/show_bug.cgi?id=195535
2852         https://trac.webkit.org/changeset/244821
2853
2854 2019-05-01  Youenn Fablet  <youenn@apple.com>
2855
2856         Kept alive loaders should use the redirected request in case of redirections
2857         https://bugs.webkit.org/show_bug.cgi?id=197337
2858
2859         Reviewed by Alex Christensen.
2860
2861         Instead of using the request, the redirected request should be used in case of redirection.
2862
2863         * NetworkProcess/NetworkResourceLoader.cpp:
2864         (WebKit::m_shouldCaptureExtraNetworkLoadMetrics):
2865         (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
2866
2867 2019-04-29  Darin Adler  <darin@apple.com>
2868
2869         WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support
2870         https://bugs.webkit.org/show_bug.cgi?id=195535
2871
2872         Reviewed by Alexey Proskuryakov.
2873
2874         * Shared/API/APIString.h: Removed uneeded includes and also switched to #pragma once.
2875
2876         * Shared/API/c/WKString.cpp: Moved include of UTF8Conversion.h here.
2877         (WKStringGetUTF8CStringImpl): Updated for changes to return values.
2878
2879 2019-04-30  Chris Dumez  <cdumez@apple.com>
2880
2881         Regression(PSON) URL scheme handlers can no longer respond asynchronously
2882         https://bugs.webkit.org/show_bug.cgi?id=197426
2883         <rdar://problem/50256169>
2884
2885         Reviewed by Brady Eidson.
2886
2887         The issue was that when committing the provisional process, we would call WebPageProxy::processDidTerminate()
2888         which would call WebPageProxy::stopAllURLSchemeTasks(). This would terminate all URL scheme tasks associated
2889         with the page, including the one associated with the provisisional page / process.
2890
2891         To address the issue, pass m_process to stopAllURLSchemeTasks() in processDidTerminate() and only stop the
2892         tasks associated with the m_process (which is the process we're about to swap away from).
2893
2894         * UIProcess/WebPageProxy.cpp:
2895         (WebKit::WebPageProxy::processDidTerminate):
2896         (WebKit::WebPageProxy::stopAllURLSchemeTasks):
2897         * UIProcess/WebPageProxy.h:
2898         * UIProcess/WebURLSchemeHandler.cpp:
2899         (WebKit::WebURLSchemeHandler::processForTaskIdentifier):
2900         (WebKit::WebURLSchemeHandler::stopAllTasksForPage):
2901         * UIProcess/WebURLSchemeHandler.h:
2902         * UIProcess/WebURLSchemeTask.h:
2903         (WebKit::WebURLSchemeTask::process const):
2904
2905 2019-04-30  John Wilander  <wilander@apple.com>
2906
2907         Add logging of Ad Click Attribution errors and events to a dedicated channel
2908         https://bugs.webkit.org/show_bug.cgi?id=197332
2909         <rdar://problem/49918800>
2910
2911         Reviewed by Youenn Fablet.
2912
2913         This patch adds an experimental Ad Click Attribution debug mode which
2914         logs information. Most changes are just log output in the various
2915         functions in WebKit::AdClickAttributionManager.
2916
2917         The constructor to WebKit::AdClickAttributionManager now takes a
2918         PAL::SessionID so that the log functions can make sure they don't
2919         output anything in ephemeral sessions.
2920
2921         WebProcessPool::platformInitializeNetworkProcess() now picks up the
2922         debug mode setting from the incoming
2923         WebKit::NetworkProcessCreationParameters object.
2924
2925         NetworkResourceLoader::handleAdClickAttributionConversion() was
2926         moved to AdClickAttributionManager::handleConversion() to keep all
2927         the logging in one file.
2928
2929         * NetworkProcess/AdClickAttributionManager.cpp:
2930         (WebKit::AdClickAttributionManager::storeUnconverted):
2931         (WebKit::AdClickAttributionManager::handleConversion):
2932         (WebKit::AdClickAttributionManager::convert):
2933         (WebKit::AdClickAttributionManager::fireConversionRequest):
2934         (WebKit::AdClickAttributionManager::firePendingConversionRequests):
2935         (WebKit::AdClickAttributionManager::clearExpired):
2936         (WebKit::AdClickAttributionManager::debugModeEnabled const):
2937         * NetworkProcess/AdClickAttributionManager.h:
2938         (WebKit::AdClickAttributionManager::AdClickAttributionManager):
2939         (WebKit::AdClickAttributionManager::m_sessionID):
2940         * NetworkProcess/NetworkProcess.cpp:
2941         (WebKit::NetworkProcess::initializeNetworkProcess):
2942         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2943         (WebKit::NetworkProcessCreationParameters::encode const):
2944         (WebKit::NetworkProcessCreationParameters::decode):
2945         * NetworkProcess/NetworkProcessCreationParameters.h:
2946         * NetworkProcess/NetworkResourceLoader.cpp:
2947         (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
2948         (WebKit::NetworkResourceLoader::handleAdClickAttributionConversion): Deleted.
2949         * NetworkProcess/NetworkSession.cpp:
2950         (WebKit::NetworkSession::NetworkSession):
2951         (WebKit::NetworkSession::handleAdClickAttributionConversion):
2952         (WebKit::NetworkSession::convertAdClickAttribution): Deleted.
2953         * NetworkProcess/NetworkSession.h:
2954         * Platform/Logging.h:
2955         * Shared/WebPreferences.yaml:
2956         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2957         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
2958
2959 2019-04-30  Devin Rousso  <drousso@apple.com>
2960
2961         Crash when running test wpt/tests/element_click/bubbling.py::test_element_disappears_during_click
2962         https://bugs.webkit.org/show_bug.cgi?id=197361
2963         <rdar://problem/49861407>
2964
2965         Reviewed by Brian Burg.
2966
2967         Don't assume that all elements have client rects (e.g. `getClientRects`). If the container
2968         element isn't visible, then the child won't be either.
2969
2970         * UIProcess/Automation/SimulatedInputDispatcher.cpp:
2971         (WebKit::SimulatedInputDispatcher::resolveLocation):
2972         (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
2973         * UIProcess/Automation/WebAutomationSession.cpp:
2974         (WebKit::WebAutomationSession::viewportInViewCenterPointOfElement):
2975
2976 2019-04-30  Chris Dumez  <cdumez@apple.com>
2977
2978         Unreviewed, rolling out r244802.
2979
2980         Caused an API test failure
2981
2982         Reverted changeset:
2983
2984         "Regression(PSON) URL scheme handlers can no longer respond
2985         asynchronously"
2986         https://bugs.webkit.org/show_bug.cgi?id=197426
2987         https://trac.webkit.org/changeset/244802
2988
2989 2019-04-30  Chris Dumez  <cdumez@apple.com>
2990
2991         Regression(PSON) URL scheme handlers can no longer respond asynchronously
2992         https://bugs.webkit.org/show_bug.cgi?id=197426
2993         <rdar://problem/50256169>
2994
2995         Reviewed by Brady Eidson.
2996
2997         The issue was that when committing the provisional process, we would call WebPageProxy::processDidTerminate()
2998         which would call WebPageProxy::stopAllURLSchemeTasks(). This would terminate all URL scheme tasks associated
2999         with the page, including the one associated with the provisisional page / process.
3000
3001         To address the issue, pass m_process to stopAllURLSchemeTasks() in processDidTerminate() and only stop the
3002         tasks associated with the m_process (which is the process we're about to swap away from).
3003
3004         * UIProcess/WebPageProxy.cpp:
3005         (WebKit::WebPageProxy::processDidTerminate):
3006         (WebKit::WebPageProxy::stopAllURLSchemeTasks):
3007         * UIProcess/WebPageProxy.h:
3008         * UIProcess/WebURLSchemeHandler.cpp:
3009         (WebKit::WebURLSchemeHandler::processForTaskIdentifier):
3010         (WebKit::WebURLSchemeHandler::stopAllTasksForPage):
3011         * UIProcess/WebURLSchemeHandler.h:
3012         * UIProcess/WebURLSchemeTask.h:
3013         (WebKit::WebURLSchemeTask::process const):
3014
3015 2019-04-30  Chris Dumez  <cdumez@apple.com>
3016
3017         Only use a related page's process if that page has not been closed yet
3018         https://bugs.webkit.org/show_bug.cgi?id=197393
3019         <rdar://problem/50302423>
3020
3021         Reviewed by Tim Horton.
3022
3023         We should not attempt to use a related page's process if that related page has already been closed.
3024         Once closed, a page's process is invalid and trying to launch a new process for the closed page
3025         leads to crashes such as the one in the radar.
3026
3027         * UIProcess/WebPageProxy.cpp:
3028         (WebKit::WebPageProxy::launchProcess):
3029         * UIProcess/WebProcessPool.cpp:
3030         (WebKit::WebProcessPool::createWebPage):
3031
3032 2019-04-30  Tim Horton  <timothy_horton@apple.com>
3033
3034         Long-standing rare crash under -[WKWebView _web_immediateActionAnimationControllerForHitTestResultInternal...]
3035         https://bugs.webkit.org/show_bug.cgi?id=197404
3036         <rdar://problem/24589331>
3037
3038         Reviewed by Wenson Hsieh.
3039
3040         * UIProcess/mac/WKImmediateActionController.mm:
3041         (-[WKImmediateActionController _updateImmediateActionItem]):
3042         (-[WKImmediateActionController menuItem:previewItemAtPoint:]):
3043         (-[WKImmediateActionController menuItem:itemFrameForPoint:]):
3044         (-[WKImmediateActionController _animationControllerForDataDetectedLink]):
3045         Add some null checks; _webHitTestResult can be null if we (somehow) get
3046         an immediate action gesture without having previously gotten a
3047         mouseDidMoveOverElement from the Web Content process. Cover all our bases.
3048
3049 2019-04-30  Per Arne Vollan  <pvollan@apple.com>
3050
3051         [iOS] Fix crash caused by sandbox violation
3052         https://bugs.webkit.org/show_bug.cgi?id=197416
3053         <rdar://problem/50266257>
3054
3055         Reviewed by Brent Fulgham.
3056
3057         Add syscall to the iOS sandbox.
3058
3059         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
3060
3061 2019-04-30  Zalan Bujtas  <zalan@apple.com>
3062
3063         [iOS] Double-tapping a post to like doesn't work on Instagram.com (needs 'dblclick' event)
3064         https://bugs.webkit.org/show_bug.cgi?id=197347
3065         <rdar://problem/49393423>
3066
3067         Reviewed by Wenson Hsieh.
3068
3069         This patch adds support for dispatching dblclick event as the result of the double tap gesture.
3070
3071         1. The new double tap gesture recognizer always fires regardless of what type of action the other, existing double gesture recognizers (double-tap to zoom) trigger.
3072         2. The dblclick event is dispatched on the node with registered dblclick event handler unless the node prohibits double tap gesture (touch-action != auto).
3073
3074         * UIProcess/WebPageProxy.h:
3075         * UIProcess/ios/WKContentViewInteraction.h:
3076         * UIProcess/ios/WKContentViewInteraction.mm:
3077         (-[WKContentView setupInteraction]):
3078         (-[WKContentView cleanupInteraction]):
3079         (-[WKContentView _removeDefaultGestureRecognizers]):
3080         (-[WKContentView _addDefaultGestureRecognizers]):
3081         (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
3082         (-[WKContentView gestureRecognizerShouldBegin:]):
3083         (-[WKContentView _doubleTapRecognizedForDoubleClick:]):
3084         * UIProcess/ios/WebPageProxyIOS.mm:
3085         (WebKit::WebPageProxy::handleDoubleTapForDoubleClickAtPoint):
3086         * WebProcess/WebPage/WebPage.h:
3087         * WebProcess/WebPage/WebPage.messages.in:
3088         * WebProcess/WebPage/ios/WebPageIOS.mm:
3089         (WebKit::WebPage::handleDoubleTapForDoubleClickAtPoint):
3090
3091 2019-04-30  Antti Koivisto  <antti@apple.com>
3092
3093         Tighten type of ScrollingTree:rootNode() to ScrollingTreeFrameScrollingNode
3094         https://bugs.webkit.org/show_bug.cgi?id=197414
3095
3096         Reviewed by Frédéric Wang.
3097
3098         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
3099
3100 2019-04-30  Carlos Garcia Campos  <cgarcia@igalia.com>
3101
3102         REGRESSION(r244750): [GTK][WPE] Network process is crashing in all layout tests
3103         https://bugs.webkit.org/show_bug.cgi?id=197406
3104
3105         Reviewed by Žan Doberšek.
3106
3107         Do not trasnfer ownership of cachePath to traverseDirectory() lambda, since it's passed also as first argument
3108         and it can be passed as a reference.
3109
3110         * NetworkProcess/cache/NetworkCacheStorage.cpp:
3111         (WebKit::NetworkCache::Storage::deleteOldVersions):
3112
3113 2019-04-29  Truitt Savell  <tsavell@apple.com>
3114
3115         Unreviewed, rolling out r244755.
3116
3117         Casued several test failures on iOS
3118
3119         Reverted changeset:
3120
3121         "Double-tapping a post to like doesn't work on Instagram.com
3122         (needs 'dblclick' event)"
3123         https://bugs.webkit.org/show_bug.cgi?id=197347
3124         https://trac.webkit.org/changeset/244755
3125
3126 2019-04-29  Chris Dumez  <cdumez@apple.com>
3127
3128         [iOS] The UIProcess may get killed for trying to stay runnable in the background for more than 30 seconds
3129         https://bugs.webkit.org/show_bug.cgi?id=197385
3130         <rdar://problem/50001505>
3131
3132         Reviewed by Geoffrey Garen.
3133
3134         If the UIProcess holds a background assertion for itself for 30 seconds, the assertion's invalidation handler
3135         will get called and it is our responsibility to release this assertion or the UIProcess will get killed by the
3136         system. The logic in ProcessAssertion would normally do that but it would also happily try and re-take another
3137         background process assertion shortly after the previous one expired (and before the UIProcess got suspended).
3138         When doing so, the new background assertion would expire right away and we would get killed without its
3139         invalidation handler getting called.
3140
3141         To address the issue, the logic in ProcessAssertion will now prevent taking a new background assertion after
3142         one expires and until the application becomes foreground again.
3143
3144         * UIProcess/ios/ProcessAssertionIOS.mm:
3145         (-[WKProcessAssertionBackgroundTaskManager init]):
3146         (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]):
3147
3148 2019-04-29  Alex Christensen  <achristensen@webkit.org>
3149
3150         <rdar://problem/50299396> Fix internal High Sierra build
3151         https://bugs.webkit.org/show_bug.cgi?id=197388
3152
3153         * Configurations/Base.xcconfig:
3154
3155 2019-04-29  Zalan Bujtas  <zalan@apple.com>
3156
3157         [iOS] Double-tapping a post to like doesn't work on Instagram.com (needs 'dblclick' event)
3158         https://bugs.webkit.org/show_bug.cgi?id=197347
3159         <rdar://problem/49393423>
3160
3161         Reviewed by Wenson Hsieh.
3162
3163         This patch adds support for dispatching dblclick event as the result of the double tap gesture.
3164
3165         1. The new double tap gesture recognizer always fires regardless of what type of action the other, existing double gesture recognizers (double-tap to zoom) trigger.
3166         2. The dblclick event is dispatched on the node with registered dblclick event handler unless the node prohibits double tap gesture (touch-action != auto).
3167
3168         * UIProcess/WebPageProxy.h:
3169         * UIProcess/ios/WKContentViewInteraction.h:
3170         * UIProcess/ios/WKContentViewInteraction.mm:
3171         (-[WKContentView setupInteraction]):
3172         (-[WKContentView cleanupInteraction]):
3173         (-[WKContentView _removeDefaultGestureRecognizers]):
3174         (-[WKContentView _addDefaultGestureRecognizers]):
3175         (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
3176         (-[WKContentView gestureRecognizerShouldBegin:]):
3177         (-[WKContentView _doubleTapRecognizedForDoubleClick:]):
3178         * UIProcess/ios/WebPageProxyIOS.mm:
3179         (WebKit::WebPageProxy::handleDoubleTapForDoubleClickAtPoint):
3180         * WebProcess/WebPage/WebPage.h:
3181         * WebProcess/WebPage/WebPage.messages.in:
3182         * WebProcess/WebPage/ios/WebPageIOS.mm:
3183         (WebKit::WebPage::handleDoubleTapForDoubleClickAtPoint):
3184
3185 2019-04-29  Tim Horton  <timothy_horton@apple.com>
3186
3187         REGRESSION (r244142): Fandango accounts tab crashes under Color()
3188         https://bugs.webkit.org/show_bug.cgi?id=197380
3189         <rdar://problem/50186175>
3190
3191         Reviewed by Megan Gardner.
3192
3193         * UIProcess/API/Cocoa/WKWebView.mm:
3194         (baseScrollViewBackgroundColor):
3195         We now call -_updateScrollViewBackground from -setBackgroundColor:.
3196         -setBackgroundColor: can be called from -[UIView initWithCoder:]; if it
3197         is, WKWebView's _page is not yet initialized, so we crash. Return an invalid color.
3198         Then, the caller falls back to WKContentView's backgroundColor. But WKContentView
3199         isn't initialized yet either. So add a further fallback.
3200
3201 2019-04-29  Dean Jackson  <dino@apple.com>
3202
3203         Add InteractionIsHappening to SuppressSelectionAssistantReason
3204         https://bugs.webkit.org/show_bug.cgi?id=197375
3205         <rdar://problem/50304986>
3206
3207         Reviewed by Megan Gardner.
3208
3209         Add a new reason for suppressing the selection assistant, to
3210         be used in a follow-up patch.
3211
3212         * UIProcess/ios/WKContentViewInteraction.h: Add InteractionIsHappening.
3213
3214 2019-04-29  Alex Christensen  <achristensen@webkit.org>
3215
3216         Storage::deleteOldVersions does not need to retain Storage
3217         https://bugs.webkit.org/show_bug.cgi?id=197336
3218         <rdar://problem/48679972>
3219
3220         Reviewed by Darin Adler.
3221
3222         * NetworkProcess/cache/NetworkCacheStorage.cpp:
3223         (WebKit::NetworkCache::Storage::deleteOldVersions):
3224         Something is wrong with the lifetime of Storage, but we only need a String, not the whole Storage.
3225
3226 2019-04-29  Brent Fulgham  <bfulgham@apple.com>
3227
3228         [Cocoa] Move common sandbox files from Shared/mac to Shared/Cocoa
3229         https://bugs.webkit.org/show_bug.cgi?id=197376
3230         <rdar://problem/50305272>
3231
3232         Reviewed by Dean Jackson.
3233
3234         The Apple sandboxing logic currently lives in the inappropriate 'Shared/mac' directory. This is
3235         confusing because the code is used by all Apple ports, not just macOS.
3236
3237         This patch just moves the relevant files from 'Shared/mac' to 'Shared/Cocoa' to avoid this confusion.
3238
3239         * Shared/Cocoa/SandboxExtensionCocoa.mm: Renamed from Source/WebKit/Shared/mac/SandboxExtensionMac.mm.
3240         * Shared/Cocoa/SandboxInitialiationParametersCocoa.mm: Renamed from Source/WebKit/Shared/mac/SandboxInitialiationParametersMac.mm.
3241         * Shared/Cocoa/SandboxUtilities.h: Renamed from Source/WebKit/Shared/mac/SandboxUtilities.h.
3242         * Shared/Cocoa/SandboxUtilities.mm: Renamed from Source/WebKit/Shared/mac/SandboxUtilities.mm.
3243         * SourcesCocoa.txt:
3244         * WebKit.xcodeproj/project.pbxproj:
3245
3246 2019-04-29  Alexander Mikhaylenko  <exalm7659@gmail.com>
3247
3248         [GTK] Back/forward gesture snapshot always times out
3249         https://bugs.webkit.org/show_bug.cgi?id=197233
3250
3251         Reviewed by Michael Catanzaro.
3252
3253         Delaying web process launch caused a regression where we create ViewGestureController when the
3254         web process doesn't yet exist. The controller immediately tries to connect to it and fails,
3255         and because of that never receives DidHitRenderTreeSizeThreshold() message, so navigation
3256         snapshot always stays until timeout after performing the gesture.
3257
3258         To prevent this, create the controller in webkitWebViewBaseDidRelaunchWebProcess() instead of
3259         webkitWebViewBaseCreateWebPage(). Additionally, since settings are now created earlier than
3260         ViewGestureController, store the value of whether swipe gesture is enabled in WebKitWebViewBase
3261         and immediately apply it when creating the controller.
3262
3263         Since there is now a point where controller is null, make webkitWebViewBaseViewGestureController()
3264         return null and add null checks everywhere.
3265
3266         * UIProcess/API/glib/WebKitWebView.cpp:
3267         (enableBackForwardNavigationGesturesChanged):
3268         Move the logic into webkitWebViewBaseSetEnableBackForwardNavigationGesture().
3269         * UIProcess/API/gtk/PageClientImpl.cpp:
3270         (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore): Add a null check.
3271         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
3272         (webkitWebViewBaseDraw): Ditto.
3273         (webkitWebViewBaseScrollEvent): Ditto.
3274         (webkitWebViewBaseSetEnableBackForwardNavigationGesture): Added. In addition to what was in
3275         WebKitWebViewBase::enableBackForwardNavigationGesturesChanged(), store the value in a field
3276         for the case ViewGestureController doesn't exist yet.
3277         (webkitWebViewBaseViewGestureController): Return a pointer instead of reference.
3278         (webkitWebViewBaseCreateWebPage): Stop creating ViewGestureController.
3279         (webkitWebViewBaseDidRelaunchWebProcess): Move creating ViewGestureController here. Also
3280         immediately call setSwipeGestureEnabled() with the stored value.
3281         (webkitWebViewBaseDidStartProvisionalLoadForMainFrame): Add a null check.
3282         (webkitWebViewBaseDidFirstVisuallyNonEmptyLayoutForMainFrame):Ditto.
3283         (webkitWebViewBaseDidFinishLoadForMainFrame): Ditto.
3284         (webkitWebViewBaseDidFailLoadForMainFrame): Ditto.
3285         (webkitWebViewBaseDidSameDocumentNavigationForMainFrame): Ditto.
3286         (webkitWebViewBaseDidRestoreScrollPosition): Ditto.
3287         * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
3288
3289 2019-04-29  Chris Dumez  <cdumez@apple.com>
3290
3291         User-facing strings should use curly quotes instead of straight
3292         https://bugs.webkit.org/show_bug.cgi?id=197370
3293
3294         Reviewed by Geoffrey Garen.
3295
3296         Update localizable alert text that was recently added to use curly quotes instead of
3297         straight ones, as per our guidelines.
3298
3299         * UIProcess/Cocoa/WKOrientationAccessAlert.mm:
3300         (WebKit::presentOrientationAccessAlert):
3301         * UIProcess/Cocoa/WKStorageAccessAlert.mm:
3302         (WebKit::presentStorageAccessAlert):
3303
3304 2019-04-29  Alex Christensen  <achristensen@webkit.org>
3305
3306         Build fix.
3307
3308         * UIProcess/ios/WKActionSheet.mm:
3309         (-[WKActionSheet updateSheetPosition]):
3310
3311 2019-04-29  Commit Queue  <commit-queue@webkit.org>
3312
3313         Unreviewed, rolling out r244648.
3314         https://bugs.webkit.org/show_bug.cgi?id=197363
3315
3316          Lots of tests  are crashing (Requested by KaL on #webkit).
3317
3318         Reverted changeset:
3319
3320         "[GTK] Back/forward gesture snapshot always times out"
3321         https://bugs.webkit.org/show_bug.cgi?id=197233
3322         https://trac.webkit.org/changeset/244648
3323
3324 2019-04-29  Michael Catanzaro  <mcatanzaro@igalia.com>
3325
3326         [WPE][GTK] window-object-cleared documentation should reference webkit_frame_get_js_context_for_script_world()
3327         https://bugs.webkit.org/show_bug.cgi?id=197357
3328
3329         Reviewed by Carlos Garcia Campos.
3330
3331         We should recommend using the non-deprecated replacement for
3332         webkit_frame_get_javascript_context_for_script_world().
3333
3334         * WebProcess/InjectedBundle/API/glib/WebKitScriptWorld.cpp:
3335
3336 2019-04-27  Chris Dumez  <cdumez@apple.com>
3337
3338         Improve safety of MachMessage class
3339         https://bugs.webkit.org/show_bug.cgi?id=197323
3340         <rdar://problem/44291920>
3341
3342         Reviewed by Darin Adler.
3343
3344         Improve safety of MachMessage class and clean things up a bit.
3345
3346         * Platform/IPC/mac/ConnectionMac.mm:
3347         (IPC::Connection::sendOutgoingMessage):
3348         - Pass MessageReceiverName / MessageName when constructing the MachMessage rather
3349           than setting them afterwards since they never change for a given MachMessage.
3350         - Set header->msgh_id to the right value right away instead of setting it first
3351           to inlineBodyMessageID and then later fixing it to be outOfLineBodyMessageID
3352           when the body is out of line.
3353         - When messageBodyIsOOL was true, we would call getDescriptorAndSkip() which
3354           would advance the pointer by sizeof(mach_msg_port_descriptor_t), even though
3355           the descriptor type is mach_msg_ool_descriptor_t. This would not matter in
3356           the end because we would not use the messageData pointer after this but
3357           still.
3358
3359         * Platform/IPC/mac/MachMessage.cpp:
3360         (IPC::MachMessage::create):
3361         Use fastZeroedMalloc() instead of fastMalloc() for safety, given that this class
3362         has a mach_msg_header_t flexible array member. This is what is recommended by the
3363         mach documentation. It is much safer because it otherwize relies on the user
3364         (Connection::sendOutgoingMessage()) to initialize ALL the message members
3365         correctly. I suspect this was the cause of <rdar://problem/44291920> because
3366         Connection::sendOutgoingMessage() would fail to initialize header->msgh_voucher_port
3367         and the MachMessage destructor would then call mach_msg_destroy(header()), which
3368         would mach_msg_destroy_port(header->msgh_voucher_port).
3369
3370         (IPC::MachMessage::MachMessage):
3371         Pass MessageReceiverName / MessageName when constructing the MachMessage rather
3372         than setting them afterwards since they never change for a given MachMessage.
3373
3374         (IPC::MachMessage::messageSize):
3375         Drop if checks for portDescriptorCount and memoryDescriptorCount since the logic
3376         will do the right thing even if they are 0.
3377
3378         * Platform/IPC/mac/MachMessage.h:
3379         (IPC::MachMessage::header):
3380         (IPC::MachMessage::messageReceiverName const):
3381         (IPC::MachMessage::messageName const):
3382
3383 2019-04-26  Wenson Hsieh  <wenson_hsieh@apple.com>
3384
3385         Rename m_LayerTreeFreezeReasons to m_layerTreeFreezeReasons
3386         https://bugs.webkit.org/show_bug.cgi?id=197343
3387
3388         Reviewed by Antti Koivisto.
3389
3390         No change in behavior.
3391
3392         * WebProcess/WebPage/WebPage.cpp:
3393         (WebKit::WebPage::freezeLayerTree):
3394         (WebKit::WebPage::unfreezeLayerTree):
3395         (WebKit::WebPage::updateDrawingAreaLayerTreeFreezeState):
3396         * WebProcess/WebPage/WebPage.h:
3397
3398 2019-04-26  Keith Rollin  <krollin@apple.com>
3399
3400         Enable new build rule for post-processing headers when using XCBuild
3401         https://bugs.webkit.org/show_bug.cgi?id=197340
3402         <rdar://problem/50226685>
3403
3404         Reviewed by Brent Fulgham.
3405
3406         In Bug 197116, we conditionally disabled the old method for
3407         post-processing header files when we are using the new XCBuild build
3408         system. This check-in conditionally enables the new post-processing
3409         facility. Note that the old system is disabled and the new system
3410         enabled only when the USE_NEW_BUILD_SYSTEM environment variable is set
3411         to YES.
3412
3413         * Configurations/WebKit.xcconfig:
3414
3415 2019-04-26  Jessie Berlin  <jberlin@webkit.org>
3416
3417         Add new mac target numbers
3418         https://bugs.webkit.org/show_bug.cgi?id=197313
3419
3420         Reviewed by Alex Christensen.
3421
3422         * Configurations/Version.xcconfig:
3423         * Configurations/WebKitTargetConditionals.xcconfig:
3424
3425 2019-04-26  Youenn Fablet  <youenn@apple.com>
3426
3427         Use kDNSServiceFlagsKnownUnique to speed up mdns name registration for ICE candidates
3428         https://bugs.webkit.org/show_bug.cgi?id=197328
3429
3430         Reviewed by Eric Carlson.
3431
3432         This allows skipping the probing step of MDNS name registration.
3433         We can do that as registered names are random UUIDs.
3434
3435         * NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
3436         (WebKit::NetworkMDNSRegister::registerMDNSName):
3437
3438 2019-04-26  Chris Dumez  <cdumez@apple.com>
3439
3440         [iOS] Our process assertion should not allow idle sleep
3441         https://bugs.webkit.org/show_bug.cgi?id=197317
3442         <rdar://problem/50137740>
3443
3444         Reviewed by Geoffrey Garen.
3445
3446         Our process assertion should not allow idle sleep. This is bad for power because the device
3447         may switch between sleep and awake state frequently, as it get woken up by network packages.
3448
3449         * UIProcess/ios/ProcessAssertionIOS.mm:
3450
3451 2019-04-26  Eric Carlson  <eric.carlson@apple.com>
3452
3453         Create AVFoundationSoftLink.{h,mm} to reduce duplicate code
3454         https://bugs.webkit.org/show_bug.cgi?id=197171
3455         <rdar://problem/47454979>
3456
3457         Reviewed by Youenn Fablet.
3458
3459         * Shared/ios/WebIconUtilities.mm:
3460         (WebKit::iconForVideoFile):
3461         * Shared/mac/WebCoreArgumentCodersMac.mm:
3462         (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData):
3463         (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData):
3464         * UIProcess/Cocoa/UIDelegate.mm:
3465         (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):
3466         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm:
3467         (WebKit::PlatformCALayerRemoteCustom::clone const):
3468
3469 2019-04-26  Commit Queue  <commit-queue@webkit.org>
3470
3471         Unreviewed, rolling out r244683.
3472         https://bugs.webkit.org/show_bug.cgi?id=197320
3473
3474         Causing crash on iOS Simulator and EWS failures (Requested by
3475         sroberts on #webkit).
3476
3477         Reverted changeset:
3478
3479         "[iOS] Add internal setting to force -webkit-text-size-adjust
3480         to "auto""
3481         https://bugs.webkit.org/show_bug.cgi?id=197275
3482         https://trac.webkit.org/changeset/244683
3483
3484 2019-04-26  Youenn Fablet  <youenn@apple.com>
3485
3486         Use normal loading path for ping loads
3487         https://bugs.webkit.org/show_bug.cgi?id=196807
3488
3489         Reviewed by Alex Christensen.
3490
3491         In case a NetworkResourceLoader has the keepAlive option we do the following:
3492         - Always use NetworkLoadChecker as we might need it to do checks after the Web context is gone.
3493         - In case of aborting a KeepAlive loader, remove it from NetworkConnectionToWebProcess map
3494         and add it to a kept-alive NetworkSession load set. The loader is only kept alive if it
3495         has not yet received a response. Mark the loader as kept-alive.
3496         - In case loader is kept-alive, cancel the load as soon as a response is gathered.
3497
3498         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
3499         (WebKit::NetworkConnectionToWebProcess::transferKeptAliveLoad):
3500         * NetworkProcess/NetworkConnectionToWebProcess.h:
3501         * NetworkProcess/NetworkProcess.cpp:
3502         (WebKit::NetworkProcess::addKeptAliveLoad):
3503         (WebKit::NetworkProcess::removeKeptAliveLoad):
3504         * NetworkProcess/NetworkProcess.h:
3505         * NetworkProcess/NetworkResourceLoadMap.cpp:
3506         (WebKit::NetworkResourceLoadMap::remove):
3507         (WebKit::NetworkResourceLoadMap::take):
3508         * NetworkProcess/NetworkResourceLoadMap.h:
3509         * NetworkProcess/NetworkResourceLoader.cpp:
3510         (WebKit::m_shouldCaptureExtraNetworkLoadMetrics):
3511         (WebKit::NetworkResourceLoader::cleanup):
3512         (WebKit::NetworkResourceLoader::abort):
3513         (WebKit::NetworkResourceLoader::didReceiveResponse):
3514         (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
3515         * NetworkProcess/NetworkResourceLoader.h:
3516         * WebProcess/Network/WebLoaderStrategy.cpp:
3517         (WebKit::maximumBufferingTime):
3518         (WebKit::WebLoaderStrategy::usePingLoad const):
3519         * WebProcess/Network/WebLoaderStrategy.h:
3520
3521 2019-04-26  Alex Christensen  <achristensen@webkit.org>
3522
3523         Fix internal High Sierra build after r244653
3524         https://bugs.webkit.org/show_bug.cgi?id=197131
3525
3526         * DerivedSources.make:
3527         -std=gnu++17 didn't exist yet.  -std=gnu++1z did.
3528
3529 2019-04-26  Alex Christensen  <achristensen@webkit.org>
3530
3531         Fix an internal High Sierra build after r244653
3532        ​https://bugs.webkit.org/show_bug.cgi?id=197131
3533
3534         * DerivedSources.make:
3535         Apparently we can't use gnu++17 when preprocessing Platform.h in the makefile.
3536
3537 2019-04-26  Sihui Liu  <sihui_liu@apple.com>
3538
3539         Stop IDB transactions to release locked database files when network process is ready to suspend
3540         https://bugs.webkit.org/show_bug.cgi?id=196372
3541         <rdar://problem/48930116>
3542
3543         Reviewed by Brady Eidson.
3544
3545         * NetworkProcess/NetworkProcess.cpp:
3546         (WebKit::NetworkProcess::processWillSuspendImminently):
3547         (WebKit::NetworkProcess::prepareToSuspend):
3548         (WebKit::NetworkProcess::resume):
3549
3550 2019-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
3551
3552         [iOS] Add internal setting to force -webkit-text-size-adjust to "auto"
3553         https://bugs.webkit.org/show_bug.cgi?id=197275
3554         <rdar://problem/50211019>
3555
3556         Reviewed by Simon Fraser.
3557
3558         * Shared/WebPreferences.yaml:
3559         * UIProcess/WebPreferences.h:
3560
3561 2019-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
3562
3563         [iOS] Implement idempotent mode for text autosizing
3564         https://bugs.webkit.org/show_bug.cgi?id=197250
3565         <rdar://problem/50211034>
3566
3567         Reviewed by Jon Lee.
3568
3569         Push the initial scale down into the page.
3570
3571         * WebProcess/WebPage/ios/WebPageIOS.mm:
3572         (WebKit::WebPage::dynamicViewportSizeUpdate):
3573         (WebKit::WebPage::viewportConfigurationChanged):
3574
3575 2019-04-25  Alex Christensen  <achristensen@webkit.org>
3576
3577         Make NetworkCache blobs safe for mmap instead of not using blobs
3578         https://bugs.webkit.org/show_bug.cgi?id=197264
3579         <rdar://problem/49564348>
3580
3581         Reviewed by Antti Koivisto.
3582
3583         This does what r244597 did for WKContentRuleLists but for the NetworkCache's blobs.
3584         Those are the two cases where we were calling mmap and seeing crashes in apps with
3585         default file protection of NSFileProtectionComplete.
3586
3587         * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
3588         (WebKit::NetworkCache::BlobStorage::add):
3589         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
3590         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): Deleted.
3591         * NetworkProcess/cache/NetworkCacheFileSystem.h:
3592         * NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm:
3593         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
3594         * NetworkProcess/cache/NetworkCacheStorage.cpp:
3595         (WebKit::NetworkCache::Storage::Storage):
3596         (WebKit::NetworkCache::Storage::synchronize):
3597         (WebKit::NetworkCache::Storage::mayContainBlob const):
3598         (WebKit::NetworkCache::Storage::shouldStoreBodyAsBlob):
3599         (WebKit::NetworkCache::estimateRecordsSize): Deleted.
3600         * NetworkProcess/cache/NetworkCacheStorage.h:
3601
3602 2019-04-25  Simon Fraser  <simon.fraser@apple.com>
3603
3604         REGRESSION (r234330): 3 legacy-animation-engine/compositing tests are flaky failures
3605         https://bugs.webkit.org/show_bug.cgi?id=188357
3606         <rdar://problem/42986633>
3607
3608         Reviewed by Dean Jackson.
3609         
3610         DumpRenderTree had no code that set page.setCompositingPolicyOverride() to Normal, so some
3611         tests would fall into low memory mode and have different behavior.
3612         
3613         Fix by moving the code that calls setCompositingPolicyOverride(Normal) from the WK2 layer
3614         to Internals, so it's shared by DRT and WTR.
3615         
3616         We no longer need the WK2 C SPI glue.
3617
3618         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
3619         (WKBundlePageSetEventThrottlingBehaviorOverride):
3620         (WKBundlePageSetCompositingPolicyOverride): Deleted.
3621         * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
3622
3623 2019-04-25  Chris Dumez  <cdumez@apple.com>
3624
3625         Trying to load a main resource outside the sandbox should not crash the WebContent process
3626         https://bugs.webkit.org/show_bug.cgi?id=197299
3627         <rdar://problem/49808042>
3628
3629         Reviewed by Geoffrey Garen.
3630
3631         Trying to load a main resource outside the sandbox should not crash the WebContent process. We should
3632         simply ignore the load and log an error message.
3633
3634         * UIProcess/WebPageProxy.cpp:
3635         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
3636
3637 2019-04-25  Timothy Hatcher  <timothy@apple.com>
3638
3639         Only send a synthetic mouse out event if synthetic mouse move events were sent.
3640         https://bugs.webkit.org/show_bug.cgi?id=197295
3641         rdar://problem/49040233
3642
3643         Reviewed by Zalan Bujtas.
3644
3645         * WebProcess/WebPage/ios/WebPageIOS.mm:
3646         (WebKit::WebPage::completeSyntheticClick):
3647
3648 2019-04-25  Timothy Hatcher  <timothy@apple.com>
3649
3650         Disable date and time inputs on iOSMac.
3651         https://bugs.webkit.org/show_bug.cgi?id=197287
3652         rdar://problem/46794376
3653
3654         Reviewed by Wenson Hsieh.
3655
3656         * Configurations/FeatureDefines.xcconfig:
3657
3658 2019-04-25  Brady Eidson  <beidson@apple.com>
3659
3660         REGRESSION (243388): WebProcess::shouldFreezeOnSuspension() decision is flipped
3661         <rdar://problem/49755494> and https://bugs.webkit.org/show_bug.cgi?id=197284
3662
3663         Reviewed by Chris Dumez.
3664
3665         * WebProcess/cocoa/WebProcessCocoa.mm:
3666         (WebKit::WebProcess::shouldFreezeOnSuspension const): If any non-suspended pages are in the process it should
3667           be eligible. Only if all pages are suspended should it be jetsam-able.
3668
3669 2019-04-25  Alex Christensen  <achristensen@webkit.org>
3670
3671         Start using C++17
3672         https://bugs.webkit.org/show_bug.cgi?id=197131
3673
3674         Reviewed by Darin Adler.
3675
3676         * Configurations/Base.xcconfig:
3677         * DerivedSources.make:
3678
3679 2019-04-25  Alexander Mikhaylenko  <exalm7659@gmail.com>
3680
3681         [GTK] Back/Forward gesture interferes with scrolling
3682         https://bugs.webkit.org/show_bug.cgi?id=197168
3683
3684         Reviewed by Michael Catanzaro.
3685
3686         When the gesture is released with 0 velocity close to an edge of the webview,
3687         the finishing animation is way too long, and in some cases it can look like the
3688         gesture is already over, when it's still animating. By scrolling vertically while
3689         that happens, it's possible to reset animation over and over again.
3690
3691         To reduce the duration in this case, instead of using maximum possible duration
3692         (400ms), introduce a base velocity and use it for calculating the duration if
3693         the actual velocity, relative to the end point, is equal to or less than 0.
3694
3695         * UIProcess/gtk/ViewGestureControllerGtk.cpp:
3696         (WebKit::ViewGestureController::SwipeProgressTracker::startAnimation):
3697
3698 2019-04-25  Alexander Mikhaylenko  <exalm7659@gmail.com>
3699
3700         [GTK] Back/forward gesture snapshot always times out
3701         https://bugs.webkit.org/show_bug.cgi?id=197233
3702
3703         Reviewed by Michael Catanzaro.
3704
3705         Delaying web process launch caused a regression where we create ViewGestureController when the
3706         web process doesn't yet exist. The controller immediately tries to connect to it and fails,
3707         and because of that never receives DidHitRenderTreeSizeThreshold() message, so navigation
3708         snapshot always stays until timeout after performing the gesture.
3709
3710         To prevent this, create the controller in webkitWebViewBaseDidRelaunchWebProcess() instead of
3711         webkitWebViewBaseCreateWebPage(). Additionally, since settings are now created earlier than
3712         ViewGestureController, store the value of whether swipe gesture is enabled in WebKitWebViewBase
3713         and immediately apply it when creating the controller.
3714
3715         * UIProcess/API/glib/WebKitWebView.cpp:
3716         (enableBackForwardNavigationGesturesChanged):
3717         Move the logic into webkitWebViewBaseSetEnableBackForwardNavigationGesture().
3718         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
3719         (webkitWebViewBaseSetEnableBackForwardNavigationGesture): Added. In addition to what was in
3720         WebKitWebViewBase::enableBackForwardNavigationGesturesChanged(), store the value in a field
3721         for the case ViewGestureController doesn't exist yet.
3722         (webkitWebViewBaseCreateWebPage): Stop creating ViewGestureController.
3723         (webkitWebViewBaseDidRelaunchWebProcess): Move creating ViewGestureController here. Also
3724         immediately call setSwipeGestureEnabled() with the stored value.
3725         * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
3726
3727 2019-04-25  Youenn Fablet  <youenn@apple.com>
3728
3729         [Mac iOS WK2] Layout Test http/wpt/cache-storage/cache-quota-after-restart.any.html is a flaky failure
3730         https://bugs.webkit.org/show_bug.cgi?id=197040
3731         <rdar://problem/49997641>
3732
3733         Reviewed by Antti Koivisto.
3734
3735         Delay write operations in case synchronize is ongoing.
3736         This is restricted to AvoidRandomness mode which is always used by CacheAPI
3737         and is also used by network cache for layout tests.
3738
3739         Tested by cache-quota-after-restart.any.html no longer exhibiting write disk errors.
3740
3741         * NetworkProcess/cache/NetworkCacheStorage.cpp:
3742         (WebKit::NetworkCache::Storage::synchronize):
3743         (WebKit::NetworkCache::Storage::store):
3744
3745 2019-04-25  Commit Queue  <commit-queue@webkit.org>
3746
3747         Unreviewed, rolling out r244627.
3748         https://bugs.webkit.org/show_bug.cgi?id=197282
3749
3750         Causing internal build failures (Requested by ShawnRoberts on
3751         #webkit).
3752
3753         Reverted changeset:
3754
3755         "Create AVFoundationSoftLink.{h,mm} to reduce duplicate code"
3756         https://bugs.webkit.org/show_bug.cgi?id=197171
3757         https://trac.webkit.org/changeset/244627
3758
3759 2019-04-24  Carlos Garcia Campos  <cgarcia@igalia.com>
3760
3761         [GTK] Hardcoded text color in input fields
3762         https://bugs.webkit.org/show_bug.cgi?id=126907
3763
3764         Reviewed by Michael Catanzaro.
3765
3766         Implement PageClient::effectiveAppearanceIsDark() for GTK port.
3767
3768         * UIProcess/API/gtk/PageClientImpl.cpp:
3769         (WebKit::PageClientImpl::effectiveAppearanceIsDark const): Check if gtk-application-prefer-dark-theme setting is
3770         enabled, or the theme name contains the -dark suffix or the GTK_THEME environment variable contains the :dark suffix.
3771         * UIProcess/API/gtk/PageClientImpl.h:
3772         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
3773         (themeChanged): Notify the WebPageProxy that the theme has changed.
3774         (webkitWebViewBaseSetToplevelOnScreenWindow): Connect to notify::gtk-application-prefer-dark-theme and notify::gtk-theme-name.
3775         * WebProcess/WebPage/WebPage.cpp:
3776         * WebProcess/WebPage/gtk/WebPageGtk.cpp:
3777         (WebKit::WebPage::setUseDarkAppearance): Set gtk-application-prefer-dark-theme setting accordingly.
3778
3779 2019-04-24  Zalan Bujtas  <zalan@apple.com>
3780
3781         Regression (r244291): Broken API Test AutoLayoutRenderingProgressRelativeOrdering
3782         https://bugs.webkit.org/show_bug.cgi?id=196948
3783         <rdar://problem/49927131>
3784
3785         Reviewed by Tim Horton.
3786
3787         Move intrinsicContentSizeDidChange out of DrawingArea. Intrinsic content size is a layout concept and
3788         after r244291 there's no reason to have it in DrawingArea.
3789
3790         * UIProcess/DrawingAreaProxy.h:
3791         (WebKit::DrawingAreaProxy::didUpdateGeometry):
3792         (WebKit::DrawingAreaProxy::intrinsicContentSizeDidChange): Deleted.
3793         * UIProcess/DrawingAreaProxy.messages.in:
3794         * UIProcess/WebPageProxy.cpp:
3795         (WebKit::WebPageProxy::didChangeIntrinsicContentSize):
3796         (WebKit::WebPageProxy::setViewLayoutSize):
3797         * UIProcess/WebPageProxy.h:
3798         * UIProcess/WebPageProxy.messages.in:
3799         * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
3800         * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
3801         (WebKit::TiledCoreAnimationDrawingAreaProxy::intrinsicContentSizeDidChange): Deleted.
3802         * UIProcess/mac/WebPageProxyMac.mm:
3803         (WebKit::WebPageProxy::intrinsicContentSizeDidChange): Deleted.
3804         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
3805         (WebKit::WebChromeClient::intrinsicContentsSizeChanged const):
3806         * WebProcess/WebCoreSupport/WebChromeClient.h:
3807         * WebProcess/WebPage/WebPage.cpp:
3808         (WebKit::WebPage::updateIntrinsicContentSizeIfNeeded):
3809         (WebKit::WebPage::dispatchDidReachLayoutMilestone):
3810         * WebProcess/WebPage/WebPage.h:
3811         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
3812         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
3813         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
3814         (WebKit::TiledCoreAnimationDrawingArea::updateIntrinsicContentSizeIfNeeded): Deleted.
3815
3816 2019-04-24  Commit Queue  <commit-queue@webkit.org>
3817
3818         Unreviewed, rolling out r244228.
3819         https://bugs.webkit.org/show_bug.cgi?id=197262
3820
3821         Causes compat issues (Requested by smfr on #webkit).
3822
3823         Reverted changeset:
3824
3825         "Unreviewed test gardening for Windows."
3826         https://trac.webkit.org/changeset/244228
3827
3828 2019-04-24  Eric Carlson  <eric.carlson@apple.com>
3829
3830         Create AVFoundationSoftLink.{h,mm} to reduce duplicate code
3831         https://bugs.webkit.org/show_bug.cgi?id=197171
3832         <rdar://problem/47454979>
3833
3834         Reviewed by Youenn Fablet.
3835
3836         * Shared/ios/WebIconUtilities.mm:
3837         (WebKit::iconForVideoFile):
3838         * Shared/mac/WebCoreArgumentCodersMac.mm:
3839         (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData):
3840         (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData):
3841         * UIProcess/Cocoa/UIDelegate.mm:
3842         (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):
3843         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm:
3844         (WebKit::PlatformCALayerRemoteCustom::clone const):
3845
3846 2019-04-24  Per Arne Vollan  <pvollan@apple.com>
3847
3848         [macOS] Fix syscall sandbox violation
3849         https://bugs.webkit.org/show_bug.cgi?id=197247
3850         <rdar://problem/50026580>
3851
3852         Reviewed by Brent Fulgham.
3853
3854         A missing syscall in the sandbox of the WebContent process is causing a crash.
3855
3856         * WebProcess/com.apple.WebProcess.sb.in:
3857
3858 2019-04-24  John Wilander  <wilander@apple.com>
3859
3860         Age out unconverted Ad Click Attributions after one week.
3861         https://bugs.webkit.org/show_bug.cgi?id=197238
3862         <rdar://problem/50177349>
3863
3864         Reviewed by Chris Dumez.
3865
3866         AdClickAttributionManager::storeUnconverted() and
3867         AdClickAttributionManager::convert() now start by calling the new
3868         AdClickAttributionManager::clearExpired() function to remove any
3869         expired, unconverted attributions before continuing.
3870
3871         The rest of the patch is infrastructure to allow tests to expire
3872         all unconverted attributions early.
3873
3874         * NetworkProcess/AdClickAttributionManager.cpp:
3875         (WebKit::AdClickAttributionManager::storeUnconverted):
3876         (WebKit::AdClickAttributionManager::convert):
3877         (WebKit::AdClickAttributionManager::clearExpired):
3878         (WebKit::AdClickAttributionManager::markAllUnconvertedAsExpiredForTesting):
3879         * NetworkProcess/AdClickAttributionManager.h:
3880         * NetworkProcess/NetworkProcess.cpp:
3881         (WebKit::NetworkProcess::markAdClickAttributionsAsExpiredForTesting):
3882         * NetworkProcess/NetworkProcess.h:
3883         * NetworkProcess/NetworkProcess.messages.in:
3884         * NetworkProcess/NetworkSession.cpp:
3885         (WebKit::NetworkSession::markAdClickAttributionsAsExpiredForTesting):
3886         * NetworkProcess/NetworkSession.h:
3887         * UIProcess/API/C/WKPage.cpp:
3888         (WKPageSetAdClickAttributionConversionURLForTesting):
3889         (WKPageMarkAdClickAttributionsAsExpiredForTesting):
3890         * UIProcess/API/C/WKPagePrivate.h:
3891         * UIProcess/WebPageProxy.cpp:
3892         (WebKit::WebPageProxy::markAdClickAttributionsAsExpiredForTesting):
3893         * UIProcess/WebPageProxy.h:
3894
3895 2019-04-24  Wenson Hsieh  <wenson_hsieh@apple.com>
3896
3897         Plumb the navigation's request when determining recommended compatibility mode
3898         https://bugs.webkit.org/show_bug.cgi?id=197225
3899         <rdar://problem/48389965>
3900
3901         Reviewed by Alex Christensen.
3902
3903         Adds a new argument to effectiveCompatibilityModeAfterAdjustingPolicies.
3904
3905         * UIProcess/WebPageProxy.cpp:
3906         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
3907         (WebKit::WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies):
3908         * UIProcess/WebPageProxy.h:
3909
3910 2019-04-24  Tim Horton  <timothy_horton@apple.com>
3911
3912         Clean up WKActionSheetAssistant's use of LaunchServices
3913         https://bugs.webkit.org/show_bug.cgi?id=194645
3914         <rdar://problem/47707952>
3915
3916         Reviewed by Andy Estes.
3917
3918         * UIProcess/ios/WKActionSheetAssistant.mm:
3919         (applicationHasAppLinkEntitlements):
3920         (-[WKActionSheetAssistant _appendAppLinkOpenActionsForURL:actions:elementInfo:]):
3921         (-[WKActionSheetAssistant _appendOpenActionsForURL:actions:elementInfo:]):
3922         (appLinkForURL): Deleted.
3923         Make this function much more early-returny and flat.
3924         Adopt LS sync SPI instead of using a semaphore ourselves.
3925         Adopt modern open SPI.
3926
3927 2019-04-24  Simon Fraser  <simon.fraser@apple.com>
3928
3929         Make it possible to control the renderTreeAsText output by setting options on testRunner
3930         https://bugs.webkit.org/show_bug.cgi?id=197133
3931
3932         Reviewed by Sam Weinig.
3933
3934         Add testRunner.setRenderTreeDumpOptions() and expose the subset of RenderAsTextFlag flags
3935         that make sense in testing (those that don't dump unstable data like addresses), and plumb
3936         these flags through the various framework layers.
3937
3938         Convert RenderAsTextBehavior to an OptionSet<RenderAsTextFlag>.
3939
3940         Fix code generation in WebKitTestRunner to generate bindings for IDL const values,
3941         and hand-code DumpRenderTree bindings.
3942
3943         Some cleanup of the TestRunners, using member initializers.
3944
3945         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
3946         (WKBundlePageCopyRenderTreeExternalRepresentation):
3947         * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
3948         * WebProcess/WebPage/WebPage.cpp:
3949         (WebKit::toRenderAsTextFlags):
3950         (WebKit::WebPage::renderTreeExternalRepresentation const):
3951         (WebKit::WebPage::renderTreeExternalRepresentationForPrinting const):
3952         * WebProcess/WebPage/WebPage.h:
3953
3954 2019-04-24  Alex Christensen  <achristensen@webkit.org>
3955
3956         WKContentRuleLists should have a maximum FileProtection of CompleteUnlessOpen
3957         https://bugs.webkit.org/show_bug.cgi?id=197078
3958         <rdar://problem/49564348>
3959
3960         Reviewed by Geoff Garen.
3961
3962         r242735 was a fix for crashes when using mmap'd memory in apps with default FileProtection of NSFileProtectionComplete.
3963         It is more memory efficient and just as secure to reduce the FileProtection of these files to NSFileProtectionCompleteUnlessOpen.
3964
3965         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
3966         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
3967         (WebKit::NetworkCache::makeSafeToUseMemoryMapForPath):
3968         (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting): Deleted.
3969         (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting): Deleted.
3970         * NetworkProcess/cache/NetworkCacheFileSystem.h:
3971         * NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm: Added.
3972         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
3973         (WebKit::NetworkCache::makeSafeToUseMemoryMapForPath):
3974         * Shared/WebCompiledContentRuleList.cpp:
3975         (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):
3976         (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const):
3977         (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const):
3978         (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const):
3979         (WebKit::WebCompiledContentRuleList::actions const):
3980         (WebKit::WebCompiledContentRuleList::usesCopiedMemory const): Deleted.
3981         * Shared/WebCompiledContentRuleList.h:
3982         * Shared/WebCompiledContentRuleListData.cpp:
3983         (WebKit::WebCompiledContentRuleListData::encode const):
3984         (WebKit::WebCompiledContentRuleListData::decode):
3985         (WebKit::WebCompiledContentRuleListData::size const): Deleted.
3986         (WebKit::WebCompiledContentRuleListData::dataPointer const): Deleted.
3987         * Shared/WebCompiledContentRuleListData.h:
3988         (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
3989         * SourcesCocoa.txt:
3990         * UIProcess/API/APIContentRuleList.cpp:
3991         (API::ContentRuleList::usesCopiedMemory const): Deleted.
3992         * UIProcess/API/APIContentRuleList.h:
3993         * UIProcess/API/APIContentRuleListStore.cpp:
3994         (API::openAndMapOrCopyContentRuleList):
3995         (API::compiledToFile):
3996         (API::createExtension):
3997         (API::ContentRuleListStore::getContentRuleListSource):
3998         (API::ContentRuleListStore::readContentsOfFile): Deleted.
3999         (API::MappedOrCopiedData::dataPointer const): Deleted.
4000         * UIProcess/API/APIContentRuleListStore.h:
4001         * UIProcess