Extended Color Cleanup: Move Color coder definitions to Color to allow for future...
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2020-05-21  Sam Weinig  <weinig@apple.com>
2
3         Extended Color Cleanup: Move Color coder definitions to Color to allow for future encaspulation improvements
4         https://bugs.webkit.org/show_bug.cgi?id=212247
5
6         Reviewed by Simon Fraser.
7
8         Move IPC encoder/decoder definitions from WebKit down into Color itself to move closer
9         to making Color::rgb() private.
10
11         * Shared/WebCoreArgumentCoders.cpp:
12         (IPC::ArgumentCoder<Color>::encode): Deleted.
13         (IPC::ArgumentCoder<Color>::decode): Deleted.
14         * Shared/WebCoreArgumentCoders.h:
15
16 2020-05-21  Peng Liu  <peng.liu6@apple.com>
17
18         Fix issues of the Picture-in-Picture API under stress tests
19         https://bugs.webkit.org/show_bug.cgi?id=212191
20
21         Reviewed by Eric Carlson.
22
23         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
24         (WebKit::VideoFullscreenManagerProxy::enterFullscreen):
25         Mock the behavior of the VideoFullscreenInterface[AVKit|Mac] regarding
26         the Picture-in-Picture mode support.
27
28         * WebProcess/cocoa/VideoFullscreenManager.mm:
29         (WebKit::VideoFullscreenManager::didEnterFullscreen):
30         (WebKit::VideoFullscreenManager::didCleanupFullscreen):
31         Add callbacks for the end of entering/exiting fullscreen.
32
33 2020-05-21  Tyler Wilcock  <twilco.o@protonmail.com>
34
35         Fix misspelling -- m_releaseNetwrokActivityTimer --> m_releaseNetworkActivityTimer
36         https://bugs.webkit.org/show_bug.cgi?id=212237
37
38         Reviewed by Simon Fraser.
39
40         No new tests required -- simply fixing a misspelling.
41
42         * UIProcess/Cocoa/NavigationState.h: Rename m_releaseNetwrokActivityTimer to m_releaseNetworkActivityTimer
43         * UIProcess/Cocoa/NavigationState.mm: Rename m_releaseNetwrokActivityTimer to m_releaseNetworkActivityTimer
44         (WebKit::NavigationState::NavigationState):
45         (WebKit::NavigationState::releaseNetworkActivity):
46         (WebKit::NavigationState::didChangeIsLoading):
47
48 2020-05-21  Sam Weinig  <weinig@apple.com>
49
50         Extended Color Cleanup: Remove trivial uses of Color::rgb()
51         https://bugs.webkit.org/show_bug.cgi?id=212231
52
53         Reviewed by Darin Adler.
54
55         * UIProcess/API/ios/WKWebViewIOS.mm:
56         (scrollViewBackgroundColor):
57         Replace colorWithOverrideAlpha() with Color::colorWithAlphaUsingAlternativeRounding() to avoid
58         unnecessary use of Color::rgb()
59
60 2020-05-21  Alex Christensen  <achristensen@webkit.org>
61
62         Use an OptionSet instead of uint8_t for MessageFlags
63         https://bugs.webkit.org/show_bug.cgi?id=212230
64         <rdar://problem/63496543>
65
66         Reviewed by Darin Adler.
67
68         I also reduce the encoding size of OptionSet.
69
70         * Platform/IPC/ArgumentCoders.h:
71         (IPC::ArgumentCoder<OptionSet<T>>::encode):
72         (IPC::ArgumentCoder<OptionSet<T>>::decode):
73         * Platform/IPC/Decoder.cpp:
74         (IPC::Decoder::isSyncMessage const):
75         (IPC::Decoder::shouldDispatchMessageWhenWaitingForSyncReply const):
76         (IPC::Decoder::shouldUseFullySynchronousModeForTesting const):
77         * Platform/IPC/Decoder.h:
78         * Platform/IPC/Encoder.cpp:
79         (IPC::Encoder::isSyncMessage const):
80         (IPC::Encoder::shouldDispatchMessageWhenWaitingForSyncReply const):
81         (IPC::Encoder::setIsSyncMessage):
82         (IPC::Encoder::setShouldDispatchMessageWhenWaitingForSyncReply):
83         (IPC::Encoder::setFullySynchronousModeForTesting):
84         (IPC::Encoder::messageFlags):
85         (IPC::Encoder::messageFlags const):
86         * Platform/IPC/Encoder.h:
87         * Platform/IPC/MessageFlags.h:
88         (): Deleted.
89
90 2020-05-21  John Wilander  <wilander@apple.com>
91
92         Storage Access API: Allow configurable storage access scope
93         https://bugs.webkit.org/show_bug.cgi?id=212114
94         <rdar://problem/63423063>
95
96         Reviewed by Alex Christensen.
97
98         The scope of storage access as per-frame or per-page was discussed in the
99         standards process here: https://github.com/privacycg/storage-access/issues/3
100
101         The decision was to have per-page storage access by default. Recent feedback
102         from Google and conversation with Mozilla suggest that we might want to
103         support the caller choosing the scope.
104
105         This patch adds support for different scope configurations while keeping the
106         existing default as per-frame. A later patch will switch the default and add
107         test cases for per-page scope.
108
109         Most of the changes is piping through the new enum
110         WebCore::StorageAccessScope from the call side to encode per-frame and
111         per-page access, and piping through the new struct
112         WebCore::RequestStorageAccessResult on the return side which carries full
113         information about the storage access request result.
114
115         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
116         (WebKit::CompletionHandler<void):
117         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
118         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
119         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
120         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
121         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccess):
122         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
123         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
124         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
125         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
126         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
127         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessEphemeral):
128         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
129         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccessEphemeral):
130         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccessInStorageSession):
131             Renamed from WebResourceLoadStatisticsStore::grantStorageAccess()
132             to reduce confusion since we already have another function called
133             WebResourceLoadStatisticsStore::grantStorageAccess().
134         (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
135         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
136         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
137         (WebKit::NetworkConnectionToWebProcess::requestStorageAccess):
138         * NetworkProcess/NetworkConnectionToWebProcess.h:
139         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
140         * Scripts/webkit/messages.py:
141         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
142         (WebKit::WebChromeClient::requestStorageAccess):
143         * WebProcess/WebCoreSupport/WebChromeClient.h:
144         * WebProcess/WebPage/WebPage.cpp:
145         (WebKit::WebPage::requestStorageAccess):
146         * WebProcess/WebPage/WebPage.h:
147
148 2020-05-21  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
149
150         [PlayStation] Add minimal WKView API to enable TestWebKitAPI
151         https://bugs.webkit.org/show_bug.cgi?id=211868
152
153         Reviewed by Alex Christensen.
154
155         Enable TestWebKitAPI
156
157         * Platform/IPC/Connection.h:
158         * Platform/IPC/unix/ConnectionUnix.cpp:
159         (IPC::Connection::platformInvalidate):
160         (IPC::Connection::open):
161         Add SocketMonitor to monitor received messages.
162
163         * UIProcess/API/APIProcessPoolConfiguration.cpp:
164         (API::ProcessPoolConfiguration::copy):
165         * UIProcess/API/APIProcessPoolConfiguration.h:
166         Add PlayStation specific members: WebProcess and NetworkProcess paths, and user ID.
167
168         * UIProcess/Launcher/ProcessLauncher.h:
169         Add PlayStation specific members: Process path and user ID.
170
171         * NetworkProcess/EntryPoint/playstation/NetworkProcessMain.cpp: Copied from Tools\TestWebKitAPI\playstation\main.cpp.
172         (loadLibraryOrExit):
173         (main):
174         * PlatformPlayStation.cmake:
175         * Shared/API/c/playstation/WKEventPlayStation.cpp: Added.
176         (WKKeyboardEventMake):
177         (WKMouseEventMake):
178         (WKWheelEventMake):
179         * Shared/API/c/playstation/WKEventPlayStation.h: Added.
180         * UIProcess/API/C/playstation/WKAPICastPlayStation.h:
181         (WebKit::toAPI<>):
182         (WebKit::toImpl<>):
183         * UIProcess/API/C/playstation/WKContextConfigurationPlayStation.cpp: Copied from Tools\TestWebKitAPI\playstation\PlatformUtilitiesPlayStation.cpp.
184         (WKContextConfigurationSetWebProcessPath):
185         (WKContextConfigurationCopyWebProcessPath):
186         (WKContextConfigurationSetNetworkProcessPath):
187         (WKContextConfigurationCopyNetworkProcessPath):
188         (WKContextConfigurationSetUserId):
189         (WKContextConfigurationGetUserId):
190         * UIProcess/API/C/playstation/WKContextConfigurationPlayStation.h: Copied from Source\WebKit\UIProcess\API\C\playstation\WKView.h.
191         * UIProcess/API/C/playstation/WKPagePrivatePlayStation.cpp: Added.
192         (WKPageHandleKeyboardEvent):
193         (WKPageHandleMouseEvent):
194         (WKPageHandleWheelEvent):
195         * UIProcess/API/C/playstation/WKPagePrivatePlayStation.h: Copied from Source\WebKit\UIProcess\API\C\playstation\WKView.h.
196         * UIProcess/API/C/playstation/WKView.cpp: Copied from Source\WebKit\WebProcess\InjectedBundle\playstation\InjectedBundlePlayStation.cpp.
197         (WKViewCreate):
198         (WKViewGetPage):
199         * UIProcess/API/C/playstation/WKView.h:
200         * UIProcess/Launcher/playstation/ProcessLauncherPlayStation.cpp:
201         (WebKit::defaultProcessPath):
202         (WebKit::ProcessLauncher::launchProcess):
203         (WebKit::ProcessLauncher::terminateProcess):
204         (WebKit::ProcessLauncher::platformInvalidate):
205         * UIProcess/Network/NetworkProcessProxy.cpp:
206         (WebKit::NetworkProcessProxy::getLaunchOptions):
207         * UIProcess/WebProcessPool.h:
208         * UIProcess/WebProcessProxy.cpp:
209         (WebKit::WebProcessProxy::getLaunchOptions):
210         * UIProcess/playstation/PageClientImpl.cpp: Added.
211         (WebKit::PageClientImpl::PageClientImpl):
212         (WebKit::PageClientImpl::createDrawingAreaProxy):
213         (WebKit::PageClientImpl::setViewNeedsDisplay):
214         (WebKit::PageClientImpl::requestScroll):
215         (WebKit::PageClientImpl::viewScrollPosition):
216         (WebKit::PageClientImpl::viewSize):
217         (WebKit::PageClientImpl::isViewWindowActive):
218         (WebKit::PageClientImpl::isViewFocused):
219         (WebKit::PageClientImpl::isViewVisible):
220         (WebKit::PageClientImpl::isViewInWindow):
221         (WebKit::PageClientImpl::processDidExit):
222         (WebKit::PageClientImpl::didRelaunchProcess):
223         (WebKit::PageClientImpl::pageClosed):
224         (WebKit::PageClientImpl::preferencesDidChange):
225         (WebKit::PageClientImpl::toolTipChanged):
226         (WebKit::PageClientImpl::didCommitLoadForMainFrame):
227         (WebKit::PageClientImpl::handleDownloadRequest):
228         (WebKit::PageClientImpl::didChangeContentSize):
229         (WebKit::PageClientImpl::setCursor):
230         (WebKit::PageClientImpl::setCursorHiddenUntilMouseMoves):
231         (WebKit::PageClientImpl::didChangeViewportProperties):
232         (WebKit::PageClientImpl::registerEditCommand):
233         (WebKit::PageClientImpl::clearAllEditCommands):
234         (WebKit::PageClientImpl::canUndoRedo):
235         (WebKit::PageClientImpl::executeUndoRedo):
236         (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
237         (WebKit::PageClientImpl::convertToDeviceSpace):
238         (WebKit::PageClientImpl::convertToUserSpace):
239         (WebKit::PageClientImpl::screenToRootView):
240         (WebKit::PageClientImpl::rootViewToScreen):
241         (WebKit::PageClientImpl::accessibilityScreenToRootView):
242         (WebKit::PageClientImpl::rootViewToAccessibilityScreen):
243         (WebKit::PageClientImpl::doneWithKeyEvent):
244         (WebKit::PageClientImpl::createPopupMenuProxy):
245         (WebKit::PageClientImpl::enterAcceleratedCompositingMode):
246         (WebKit::PageClientImpl::exitAcceleratedCompositingMode):
247         (WebKit::PageClientImpl::updateAcceleratedCompositingMode):
248         (WebKit::PageClientImpl::fullScreenManagerProxyClient):
249         (WebKit::PageClientImpl::didFinishLoadingDataForCustomContentProvider):
250         (WebKit::PageClientImpl::navigationGestureDidBegin):
251         (WebKit::PageClientImpl::navigationGestureWillEnd):
252         (WebKit::PageClientImpl::navigationGestureDidEnd):
253         (WebKit::PageClientImpl::willRecordNavigationSnapshot):
254         (WebKit::PageClientImpl::didRemoveNavigationGestureSnapshot):
255         (WebKit::PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame):
256         (WebKit::PageClientImpl::didFinishLoadForMainFrame):
257         (WebKit::PageClientImpl::didFailLoadForMainFrame):
258         (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
259         (WebKit::PageClientImpl::didChangeBackgroundColor):
260         (WebKit::PageClientImpl::isPlayingAudioWillChange):
261         (WebKit::PageClientImpl::isPlayingAudioDidChange):
262         (WebKit::PageClientImpl::refView):
263         (WebKit::PageClientImpl::derefView):
264         (WebKit::PageClientImpl::didRestoreScrollPosition):
265         (WebKit::PageClientImpl::userInterfaceLayoutDirection):
266         (WebKit::PageClientImpl::requestDOMPasteAccess):
267         * UIProcess/playstation/PageClientImpl.h: Added.
268         * UIProcess/playstation/WebProcessPoolPlayStation.cpp:
269         (WebKit::WebProcessPool::platformInitialize):
270         * UIProcess/playstation/PlayStationWebView.cpp: Copied from Source\WebKit\UIProcess\playstation\WebProcessPoolPlayStation.cpp.
271         (WebKit::PlayStationWebView::create):
272         (WebKit::PlayStationWebView::PlayStationWebView):
273         (WebKit::PlayStationWebView::~PlayStationWebView):
274         (WebKit::PlayStationWebView::isActive const):
275         (WebKit::PlayStationWebView::isFocused const):
276         (WebKit::PlayStationWebView::isVisible const):
277         * UIProcess/playstation/PlayStationWebView.h: Copied from Source\WebKit\WebProcess\InjectedBundle\playstation\InjectedBundlePlayStation.cpp.
278         (WebKit::PlayStationWebView::page):
279         * WebProcess/EntryPoint/playstation/WebProcessMain.cpp: Copied from Tools\TestWebKitAPI\playstation\main.cpp.
280         (loadLibraryOrExit):
281         (main):
282         * WebProcess/InjectedBundle/playstation/InjectedBundlePlayStation.cpp:
283         (WebKit::InjectedBundle::initialize):
284         (WebKit::InjectedBundle::setBundleParameter):
285         * WebProcess/WebPage/AcceleratedSurface.cpp:
286         (WebKit::AcceleratedSurface::create):
287
288 2020-05-21  Chris Dumez  <cdumez@apple.com>
289
290         Address post review comments from Mitz after r262004.
291
292         * Shared/mac/AuxiliaryProcessMac.mm:
293         (WebKit::sandboxDataVaultParentDirectory):
294
295 2020-05-21  Chris Dumez  <cdumez@apple.com>
296
297         [WK2] WebKit abandons compiled sandbox profiles
298         https://bugs.webkit.org/show_bug.cgi?id=212177
299         <rdar://problem/54613619>
300
301         Reviewed by Saam Barati.
302
303         WebKit generates new compiled sandbox profiles whenever sandbox profiles are updated or
304         whenever webkit directories change (which is super common for WebKitTestRunner). Previous
305         compiled sandbox profiles do not get deleted and therefore may accumulate.
306
307         To address the issue, we now save compiled sandbox profiles under _CS_DARWIN_USER_TEMP_DIR
308         instead of _CS_DARWIN_USER_CACHE_DIR. The system takes care of deleting the files under
309         _CS_DARWIN_USER_TEMP_DIR upon reboot or if they have not been accessed for 3 days.
310
311         * Shared/mac/AuxiliaryProcessMac.mm:
312         (WebKit::sandboxDataVaultParentDirectory):
313
314 2020-05-21  Wenson Hsieh  <wenson_hsieh@apple.com>
315
316         Unreviewed, fix the iOS 13.4 build after r261978
317
318         * Platform/spi/ios/UIKitSPI.h:
319
320         Only declare `_UIHoverEventRespondable` if HAVE(UI_HOVER_EVENT_RESPONDABLE) is defined.
321
322         * UIProcess/ios/WKMouseGestureRecognizer.mm:
323
324         If `_UIHoverEventRespondable` is not present, fall back to declaring internal methods on
325         `UIHoverGestureRecognizer`.
326
327 2020-05-21  Yoshiaki JITSUKAWA  <yoshiaki.jitsukawa@sony.com>
328
329         [ConnectionUnix] Set MSG_NOSIGNAL to avoid SIGPIPE
330         https://bugs.webkit.org/show_bug.cgi?id=211719
331
332         Reviewed by Don Olmstead.
333
334         Set MSG_NOSIGNAL to sendmsg()/resvmsg() in order to avoid
335         SIGPIPE when the other process disappears.
336         * Platform/IPC/unix/ConnectionUnix.cpp:
337         (IPC::readBytesFromSocket):
338         (IPC::Connection::sendOutputMessage):
339
340 2020-05-21  Enrique Ocaña González  <eocanha@igalia.com>
341
342         [GStreamer][GTK][WPE] Expose and honor the media content types requiring hardware support setting
343         https://bugs.webkit.org/show_bug.cgi?id=211950
344
345         Reviewed by Adrian Perez de Castro.
346
347         Expose mediaContentTypesRequiringHardwareSupport as a setting on WPE and WebKitGTK.
348
349         * UIProcess/API/glib/WebKitSettings.cpp:
350         (_WebKitSettingsPrivate::_WebKitSettingsPrivate):
351         (webKitSettingsSetProperty):
352         (webKitSettingsGetProperty):
353         (webkit_settings_class_init):
354         (webkit_settings_get_media_content_types_requiring_hardware_support):
355         (webkit_settings_set_media_content_types_requiring_hardware_support):
356         * UIProcess/API/gtk/WebKitSettings.h:
357         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
358         * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
359         * UIProcess/API/wpe/WebKitSettings.h:
360         * UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
361
362 2020-05-20  Darin Adler  <darin@apple.com>
363
364         Dictation context should be an object identifier, not a type-punned pointer
365         https://bugs.webkit.org/show_bug.cgi?id=212174
366
367         Reviewed by Anders Carlsson.
368
369         * Scripts/webkit/messages.py: Added DictationContext to the list of types that are
370         not C++ classes.
371
372         * Shared/WebCoreArgumentCoders.cpp:
373         (IPC::ArgumentCoder<DictationAlternative>::encode): Updated for change to
374         DictationAlternative structure.
375         (IPC::ArgumentCoder<DictationAlternative>::decode): Ditto.
376
377         * UIProcess/Cocoa/PageClientImplCocoa.h: Use DictationContext instead of uint64_t.
378         * UIProcess/Cocoa/PageClientImplCocoa.mm:
379         (WebKit::PageClientImplCocoa::addDictationAlternatives): Ditto.
380         (WebKit::PageClientImplCocoa::removeDictationAlternatives): Ditto.
381         (WebKit::PageClientImplCocoa::dictationAlternatives): Ditto.
382         * UIProcess/Cocoa/WebPageProxyCocoa.mm:
383         (WebKit::WebPageProxy::insertDictatedTextAsync): Ditto.
384         * UIProcess/PageClient.h: Ditto.
385         * UIProcess/WebPageProxy.cpp:
386         (WebKit::WebPageProxy::showDictationAlternativeUI): Ditto.
387         (WebKit::WebPageProxy::removeDictationAlternatives): Ditto.
388         (WebKit::WebPageProxy::dictationAlternatives): Ditto.
389         * UIProcess/WebPageProxy.h: Ditto.
390         * UIProcess/WebPageProxy.messages.in: Ditto.
391         * UIProcess/ios/PageClientImplIOS.h: Ditto.
392         * UIProcess/ios/PageClientImplIOS.mm:
393         (WebKit::PageClientImpl::showDictationAlternativeUI): Ditto.
394         * UIProcess/mac/PageClientImplMac.h: Ditto.
395         * UIProcess/mac/PageClientImplMac.mm:
396         (WebKit::PageClientImpl::showDictationAlternativeUI): Ditto.
397
398         * UIProcess/mac/WebPageProxyMac.mm: Removed unneeded include of
399         DictationAlternative.h.
400
401         * WebProcess/WebCoreSupport/WebAlternativeTextClient.h: Use DictationContext
402         instead of uint64_t. Also marked class final and made everything private.
403         * WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp:
404         (WebKit::WebAlternativeTextClient::removeDictationAlternatives): Ditto.
405         (WebKit::WebAlternativeTextClient::showDictationAlternativeUI): Ditto.
406         (WebKit::WebAlternativeTextClient::dictationAlternatives): Ditto.
407
408 2020-05-20  Tim Horton  <timothy_horton@apple.com>
409
410         WKMouseGestureRecognizer should be implemented without using UIKit internals
411         https://bugs.webkit.org/show_bug.cgi?id=212173
412         <rdar://problem/61163726>
413
414         Reviewed by Wenson Hsieh.
415
416         * Platform/spi/ios/UIKitSPI.h:
417         * UIProcess/ios/WKContentViewInteraction.mm:
418         (-[WKContentView gestureRecognizer:shouldReceiveTouch:]):
419         * UIProcess/ios/WKMouseGestureRecognizer.h:
420         * UIProcess/ios/WKMouseGestureRecognizer.mm:
421         (-[WKMouseGestureRecognizer _hoverEntered:withEvent:]):
422         (-[WKMouseGestureRecognizer initWithTarget:action:]): Deleted.
423         (-[WKMouseGestureRecognizer setView:]): Deleted.
424         (-[WKMouseGestureRecognizer _wantsHoverEvents]): Deleted.
425         (-[WKMouseGestureRecognizer canPreventGestureRecognizer:]): Deleted.
426         (-[WKMouseGestureRecognizer canBePreventedByGestureRecognizer:]): Deleted.
427         Reimplement WKMouseGestureRecognizer as a UIHoverGestureRecognizer subclass,
428         so we can decouple ourselves a bit from UIKit internals.
429
430 2020-05-20  Per Arne Vollan  <pvollan@apple.com>
431
432         [iOS] Fix message filter sandbox violation
433         https://bugs.webkit.org/show_bug.cgi?id=212100
434         <rdar://problem/63407155>
435
436         Reviewed by Brent Fulgham.
437
438         A message needs to be added to the message filter in the WebContent sandbox on iOS.
439
440         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
441
442 2020-05-20  Sam Weinig  <weinig@apple.com>
443
444         Replace Color::getHSL() with sRGBToHSL to ensure it at least gives somewhat sensible results for ExtendedColors and reduce code duplication
445         https://bugs.webkit.org/show_bug.cgi?id=212143
446
447         Reviewed by Simon Fraser.
448
449         * UIProcess/API/ios/WKWebViewIOS.mm:
450         (-[WKWebView _updateScrollViewBackground]):
451         Switch to using Color::lightness().
452
453 2020-05-20  Megan Gardner  <megan_gardner@apple.com>
454
455         Hide password echo when screen is being captured.
456         https://bugs.webkit.org/show_bug.cgi?id=212060
457         <rdar://problem/47653578>
458
459         Reviewed by Wenson Hsieh.
460
461         Use the UIScreen state and notification to determine if the
462         screen is being shared or captured. This flag is for all
463         capture methods, Air Play, Screen Recording, etc. If the screen is
464         being captured, turn off the password echo to prevent the password from
465         being leaked.
466
467         * UIProcess/WebPageProxy.h:
468         * UIProcess/ios/WKContentView.mm:
469         (-[WKContentView _commonInitializationWithProcessPool:configuration:]):
470         (-[WKContentView _screenCapturedDidChange:]):
471         * UIProcess/ios/WebPageProxyIOS.mm:
472         (WebKit::WebPageProxy::setIsScreenCaptured):
473         * WebProcess/WebCoreSupport/WebEditorClient.h:
474         * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
475         (WebKit::WebEditorClient::isScreenCaptured const):
476         * WebProcess/WebPage/WebPage.h:
477         (WebKit::WebPage::isScreenCaptured const):
478         * WebProcess/WebPage/WebPage.messages.in:
479         * WebProcess/WebPage/ios/WebPageIOS.mm:
480         (WebKit::WebPage::setIsScreenCaptured):
481
482 2020-05-20  ChangSeok Oh  <changseok@webkit.org>
483
484         [GTK] Implement connected and disconnected events of GAMEPAD API with libmanette
485         https://bugs.webkit.org/show_bug.cgi?id=133854
486
487         Reviewed by Carlos Garcia Campos.
488
489         This patch brings initial GAMEPAD API support to the gtk port. We use libmanette,
490         a simple GObject game controller library to handle gamepad connection and input.
491
492         * SourcesGTK.txt:
493         * UIProcess/Gamepad/UIGamepadProvider.cpp: Add a build flag to void default interface
494         * UIProcess/Gamepad/gtk/UIGamepadProviderGtk.cpp: Added to retrieve WebPageProxy to which
495           a gamepad connects. The returned WebPageProxy handles input events from the gamepad.
496         (WebKit::getWebPageProxy):
497         (WebKit::UIGamepadProvider::platformWebPageProxyForGamepadInput):
498         * UIProcess/Gamepad/manette/UIGamepadProviderManette.cpp: Added.
499         (WebKit::UIGamepadProvider::platformSetDefaultGamepadProvider):
500         (WebKit::UIGamepadProvider::platformWebPageProxyForGamepadInput):
501         (WebKit::UIGamepadProvider::platformStopMonitoringInput):
502         (WebKit::UIGamepadProvider::platformStartMonitoringInput):
503
504 2020-05-20  Kate Cheney  <katherine_cheney@apple.com>
505
506         Support operating dates in ResourceLoadStatisticsDatabaseStore
507         https://bugs.webkit.org/show_bug.cgi?id=212034
508         <rdar://problem/63349242>
509
510         Reviewed by Brent Fulgham.
511
512         Tests: http/tests/resourceLoadStatistics/operating-dates-all-but-cookies-removed-database.html
513                http/tests/resourceLoadStatistics/operating-dates-all-but-cookies-removed.html
514                http/tests/resourceLoadStatistics/operating-dates-all-website-data-removed-database.html
515                http/tests/resourceLoadStatistics/operating-dates-all-website-data-removed.html
516
517         Patch to support Operating Dates in the ResourceLoadStatisticsDatabaseStore.
518         Moves functions out of ResourceLoadStatisticsStore now that each store
519         needs its own implementation.
520
521         Adds a new function for testing which inserts an expired statistic
522         and makes sure the proper behavior occurs depending on additional
523         parameters.
524
525         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
526         (WebKit::createTableQueries):
527         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
528         (WebKit::ResourceLoadStatisticsDatabaseStore::checkForMissingTablesInSchema):
529         (WebKit::ResourceLoadStatisticsDatabaseStore::createUniqueIndices):
530         (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
531         (WebKit::ResourceLoadStatisticsDatabaseStore::getLeastRecentOperatingDate):
532         (WebKit::ResourceLoadStatisticsDatabaseStore::mergeOperatingDates):
533         (WebKit::ResourceLoadStatisticsDatabaseStore::includeTodayAsOperatingDateIfNecessary):
534         (WebKit::ResourceLoadStatisticsDatabaseStore::hasStatisticsExpired const):
535         (WebKit::ResourceLoadStatisticsDatabaseStore::insertExpiredStatisticForTesting):
536         Migrated Operating Dates functions from ResourceLoadStatisticsStore and implemented
537         them using SQLite instead of a vector. Functionality is
538         identical to the original in-memory implementation.
539
540         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
541         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
542         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
543         (WebKit::ResourceLoadStatisticsMemoryStore::mergeOperatingDates):
544         (WebKit::ResourceLoadStatisticsMemoryStore::includeTodayAsOperatingDateIfNecessary):
545         (WebKit::ResourceLoadStatisticsMemoryStore::hasStatisticsExpired const):
546         (WebKit::ResourceLoadStatisticsMemoryStore::insertExpiredStatisticForTesting):
547         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
548         Migrated Operating Dates functions from ResourceLoadStatisticsStore
549         now that the database store does not use them.
550
551         * NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp:
552         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
553         Spelling error.
554
555         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
556         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
557         (WebKit::ResourceLoadStatisticsStore::updateCookieBlockingForDomains):
558         (WebKit::ResourceLoadStatisticsStore::statisticsEpirationTime const): Deleted.
559         (WebKit::ResourceLoadStatisticsStore::mergeOperatingDates): Deleted.
560         (WebKit::ResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary): Deleted.
561         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired const): Deleted.
562         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
563         (WebKit::OperatingDate::year const):
564         (WebKit::OperatingDate::month const):
565         (WebKit::OperatingDate::monthDay const):
566         These functions should be public now that they are needed outside
567         of this file after migrating OperatingDates functions.
568
569         (WebKit::ResourceLoadStatisticsStore::parameters const):
570         (WebKit::ResourceLoadStatisticsStore::operatingDates const): Deleted.
571         (WebKit::ResourceLoadStatisticsStore::clearOperatingDates): Deleted.
572         Moved OperatingDates functions to the memory store. Moved
573         operatingDatesWindow constexpr variables to the header file so that
574         the database and memory stores can both use them.
575
576         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
577         (WebKit::WebResourceLoadStatisticsStore::insertExpiredStatisticForTesting):
578         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
579         * NetworkProcess/NetworkProcess.cpp:
580         (WebKit::NetworkProcess::insertExpiredStatisticForTesting):
581         * NetworkProcess/NetworkProcess.h:
582         * NetworkProcess/NetworkProcess.messages.in:
583         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
584         (WKWebsiteDataStoreSetStatisticsExpiredStatistic):
585         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
586         * UIProcess/Network/NetworkProcessProxy.cpp:
587         (WebKit::NetworkProcessProxy::insertExpiredStatisticForTesting):
588         * UIProcess/Network/NetworkProcessProxy.h:
589         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
590         (WebKit::WebsiteDataStore::mergeStatisticForTesting):
591         (WebKit::WebsiteDataStore::insertExpiredStatisticForTesting):
592         * UIProcess/WebsiteData/WebsiteDataStore.h:
593         Function to add expired statistic to the ITP store.
594
595 2020-05-20  Chris Dumez  <cdumez@apple.com>
596
597         Deprecate WKBundlePageSetPolicyClient() Injected bundle C API
598         https://bugs.webkit.org/show_bug.cgi?id=212166
599
600         Reviewed by Alex Christensen.
601
602         Deprecate WKBundlePageSetPolicyClient() Injected bundle C API. Approving navigations from
603         the injected bundle can lead to WebProcess terminations like in <rdar://problem/60340647>
604         because the WebProcess is not in a position to do sandbox checks when navigating to file
605         URLs.
606
607         * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
608
609 2020-05-20  Simon Fraser  <simon.fraser@apple.com>
610
611         Plumb the display's nominal refresh rate down to ScrollingTree for use in scroll synchronization
612         https://bugs.webkit.org/show_bug.cgi?id=212159
613
614         Reviewed by Tim Horton.
615
616         Plumb an Optional<unsigned> down windowScreenDidChange, which contains the nominal
617         display refresh rate (as frames per second) if available. On macOS, we get this
618         from CVDisplayLinkGetNominalOutputVideoRefreshPeriod().
619
620         To read it, WebProcessPool::nominalFramesPerSecondForDisplay() makes a DisplayLink
621         that doesn't get any observers, but that DisplayLink will very likely get used
622         as soon as we schedule a rendering update.
623
624         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
625         (WebKit::WebProcessPool::nominalFramesPerSecondForDisplay):
626         * UIProcess/Cocoa/WebViewImpl.mm:
627         (WebKit::WebViewImpl::windowDidChangeScreen):
628         * UIProcess/WebPageProxy.cpp:
629         (WebKit::WebPageProxy::windowScreenDidChange):
630         * UIProcess/WebPageProxy.h:
631         * UIProcess/WebProcessPool.h:
632         * UIProcess/mac/DisplayLink.cpp:
633         (WebKit::DisplayLink::DisplayLink):
634         (WebKit::DisplayLink::nominalFramesPerSecond const):
635         * UIProcess/mac/DisplayLink.h:
636         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
637         (WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
638         * WebProcess/WebPage/WebPage.cpp:
639         (WebKit::WebPage::windowScreenDidChange):
640         * WebProcess/WebPage/WebPage.h:
641         * WebProcess/WebPage/WebPage.messages.in:
642
643 2020-05-20  Myles C. Maxfield  <mmaxfield@apple.com>
644
645         [iPadOS] -webkit-text-size-adjust:percentage doesn't work in native apps
646         https://bugs.webkit.org/show_bug.cgi?id=212122
647         <rdar://problem/54560875>
648
649         Reviewed by Wenson Hsieh.
650
651         * Shared/WebsitePoliciesData.cpp:
652         (WebKit::WebsitePoliciesData::encode const):
653         (WebKit::WebsitePoliciesData::decode):
654         (WebKit::WebsitePoliciesData::applyToDocumentLoader):
655         * Shared/WebsitePoliciesData.h:
656         * UIProcess/API/APIWebsitePolicies.cpp:
657         (API::WebsitePolicies::copy const):
658         (API::WebsitePolicies::data):
659         * UIProcess/API/APIWebsitePolicies.h:
660         * UIProcess/ios/WebPageProxyIOS.mm:
661         (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
662
663 2020-05-20  Kate Cheney  <katherine_cheney@apple.com>
664
665         REGRESSION (r261892) [ Mac Debug ] 4 API tests failing related to ResourceLoadStatistics
666         https://bugs.webkit.org/show_bug.cgi?id=212153
667         <rdar://problem/63452541>
668
669         Reviewed by Sihui Liu.
670
671         Accidentally deleted necessary reset() call for a SQLite statement
672         when converting stored statements to SQLiteStatementAutoResetScope in
673         https://trac.webkit.org/changeset/261892/webkit.
674
675         This statement is used in a loop with multiple bind() calls so it must be reset.
676
677         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
678         (WebKit::ResourceLoadStatisticsDatabaseStore::checkForMissingTablesInSchema):
679
680 2020-05-20  Eric Carlson  <eric.carlson@apple.com>
681
682         Update some media logging
683         https://bugs.webkit.org/show_bug.cgi?id=212109
684         <rdar://problem/63424816>
685
686         Unreviewed, remove a change unintentionally included in r261899.
687
688         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
689         (-[WKFullScreenWindowController _interactivePinchDismissChanged:]):
690
691 2020-05-20  Andy Estes  <aestes@apple.com>
692
693         [Mac] UI processes spin when creating the "Share" context menu item
694         https://bugs.webkit.org/show_bug.cgi?id=212137
695         <rdar://problem/54498394>
696
697         Reviewed by Wenson Hsieh.
698
699         On Mac, WebKit has been using the +[NSMenuItem standardShareMenuItemForItems:] SPI to create
700         the "Share" context submenu and menu item. This call performs synchronous IPC and can result
701         in UI process spins.
702
703         Where available, switch to using the asynchronous
704         -[NSSharingServicePicker getMenuWithCompletion:] SPI instead. This method only creates the
705         submenu, not the menu item, so when using this new method we must create the "Share" menu
706         item ourselves.
707
708         * UIProcess/mac/WebContextMenuProxyMac.h:
709         * UIProcess/mac/WebContextMenuProxyMac.mm:
710         (WebKit::getStandardShareMenuItem):
711         (WebKit::WebContextMenuProxyMac::getShareMenuItem):
712         (WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
713         (WebKit::WebContextMenuProxyMac::getContextMenuItem):
714         (WebKit::WebContextMenuProxyMac::showContextMenuWithItems):
715         (WebKit::WebContextMenuProxyMac::createShareMenuItem): Deleted.
716         (WebKit::WebContextMenuProxyMac::createContextMenuFromItems): Deleted.
717         (WebKit::WebContextMenuProxyMac::createContextMenuItem): Deleted.
718
719 2020-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
720
721         Unreviewed. Fix GTK4 build with GTK 3.98.4
722
723         * PlatformGTK.cmake:
724         * UIProcess/API/gtk/WebKitPrintOperation.cpp:
725         (webkitPrintOperationRunDialog):
726         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
727         (webkitWebViewBaseAddDialog):
728         (webkitWebViewBaseRemoveChild):
729         (webkitWebViewBaseContainerForall):
730         (webkitWebViewBaseAddWebInspector):
731         (webkitWebViewBaseRemoveWebInspector):
732         (webkitWebViewBaseDispose):
733         (webkitWebViewBaseSizeAllocate):
734         (webkitWebViewBaseConstructed):
735         (webkit_web_view_base_class_init):
736         * UIProcess/API/gtk/WebKitWebViewBase.h: Removed.
737         * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
738         * UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp:
739         (WebKit::RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow):
740         (WebKit::RemoteWebInspectorProxy::platformSave):
741         * UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp:
742         (WebKit::WebInspectorProxy::platformCreateFrontendWindow):
743         (WebKit::WebInspectorProxy::platformAttach):
744         (WebKit::WebInspectorProxy::platformDetach):
745         (WebKit::WebInspectorProxy::platformSave):
746         * UIProcess/gtk/WebContextMenuProxyGtk.cpp:
747         (WebKit::WebContextMenuProxyGtk::~WebContextMenuProxyGtk):
748
749 2020-05-12  Carlos Garcia Campos  <cgarcia@igalia.com>
750
751         [GTK4] Add support for drag and drop operations
752         https://bugs.webkit.org/show_bug.cgi?id=211779
753
754         Reviewed by Adrian Perez de Castro.
755
756         * UIProcess/API/gtk/DragSource.h:
757         * UIProcess/API/gtk/DragSourceGtk4.cpp:
758         (WebKit::DragSource::begin):
759         * UIProcess/API/gtk/DropTarget.h:
760         * UIProcess/API/gtk/DropTargetGtk4.cpp:
761         (WebKit::DropTarget::DropTarget):
762         (WebKit::DropTarget::~DropTarget):
763         (WebKit::DropTarget::accept):
764         (WebKit::DropReadAsyncData::DropReadAsyncData):
765         (WebKit::DropTarget::loadData):
766         (WebKit::DropTarget::didLoadData):
767         (WebKit::DropTarget::enter):
768         (WebKit::DropTarget::update):
769         (WebKit::DropTarget::didPerformAction):
770         (WebKit::DropTarget::leave):
771         (WebKit::DropTarget::drop):
772
773 2020-05-19  Wenson Hsieh  <wenson_hsieh@apple.com>
774
775         REGRESSION (r258919): fast/events/ios/key-events-comprehensive/key-events-control tests are failing
776         https://bugs.webkit.org/show_bug.cgi?id=212124
777         <rdar://problem/60893744>
778
779         Reviewed by Tim Horton.
780
781         After the changes in r258919, WKContentView's text input traits report that we're in a single line input, even
782         when there is no editable focused element. This prevents UIKit from allowing WebKit to handle the `CTRL + M`
783         key command, which is interpreted at the system level as inserting a line break in a multi-line editable area.
784
785         It seems odd to consider ourselves in a single line input when there isn't even an editable element focused
786         element; for now, we can fix these failing tests by just going with the default value for the text input traits'
787         `setIsSingleLineDocument` property, but not explicitly setting it to either `NO` or `YES` when no element is
788         focused.
789
790         * UIProcess/ios/WKContentViewInteraction.mm:
791         (-[WKContentView textInputTraits]):
792
793 2020-05-19  Sam Weinig  <weinig@apple.com>
794
795         Remove almost always incorrect Color::getRGBA
796         https://bugs.webkit.org/show_bug.cgi?id=212059
797
798         Reviewed by Darin Adler and Simon Fraser.
799
800         * UIProcess/API/wpe/WebKitColor.cpp:
801         (webkitColorFillFromWebCoreColor):
802         * UIProcess/gtk/ViewGestureControllerGtk.cpp:
803         (WebKit::ViewGestureController::beginSwipeGesture):
804         * WebProcess/WebPage/WebFrame.cpp:
805         (WebKit::WebFrame::getDocumentBackgroundColor):
806         Replace Color::getRGBA with Color::toSRGBAComponentsLossy()
807
808 2020-05-19  Simon Fraser  <simon.fraser@apple.com>
809
810         Use an ObjectIdentifier<> for DisplayLink observer IDs
811         https://bugs.webkit.org/show_bug.cgi?id=212112
812
813         Reviewed by Per Arne Vollan.
814
815         Replace unsigned observerID with DisplayLinkObserverID, which is a typesafe ObjectIdentifier<>.
816
817         Use PlatformDisplayID in more places.
818
819         * Scripts/webkit/messages.py:
820         * Shared/DisplayLinkObserverID.h: Copied from Source/WebKit/UIProcess/mac/DisplayLink.h.
821         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
822         (WebKit::WebProcessPool::startDisplayLink):
823         (WebKit::WebProcessPool::stopDisplayLink):
824         * UIProcess/WebProcessPool.h:
825         * UIProcess/WebProcessProxy.h:
826         * UIProcess/WebProcessProxy.messages.in:
827         * UIProcess/mac/DisplayLink.cpp:
828         (WebKit::DisplayLink::addObserver):
829         (WebKit::DisplayLink::removeObserver):
830         * UIProcess/mac/DisplayLink.h:
831         * UIProcess/mac/WebProcessProxyMac.mm:
832         (WebKit::WebProcessProxy::startDisplayLink):
833         (WebKit::WebProcessProxy::stopDisplayLink):
834         * WebKit.xcodeproj/project.pbxproj:
835         * WebProcess/WebPage/mac/DrawingAreaMac.cpp:
836         (WebKit::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
837
838 2020-05-19  Alex Christensen  <achristensen@webkit.org>
839
840         Add _WKDownloadDelegate callback including totalBytesWritten
841         https://bugs.webkit.org/show_bug.cgi?id=212110
842         <rdar://problem/63358981>
843
844         Reviewed by Geoffrey Garen.
845
846         Without this new callback, after resuming a download, a client has no way to tell whether the download was successfully
847         resumed by a server that has proper etag and range request support or whether the download began at the beginning again.
848         A client was guessing that the download did not restart, causing incorrect reported download sizes when the download did restart.
849         Luckily, the data on disk was not corrupted, just the UI.  This allows us to fix the UI.
850
851         Testing covered by expanding the API test for resuming downloads.
852
853         * NetworkProcess/Downloads/Download.cpp:
854         (WebKit::Download::didReceiveData):
855         * NetworkProcess/Downloads/Download.h:
856         * NetworkProcess/NetworkDataTaskBlob.cpp:
857         (WebKit::NetworkDataTaskBlob::writeDownload):
858         * NetworkProcess/NetworkDataTaskBlob.h:
859         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
860         (-[WKNetworkSessionDelegate URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:]):
861         * UIProcess/API/APIDownloadClient.h:
862         (API::DownloadClient::didReceiveData):
863         * UIProcess/API/C/WKContext.cpp:
864         (WKContextSetDownloadClient):
865         * UIProcess/API/Cocoa/_WKDownloadDelegate.h:
866         * UIProcess/Cocoa/DownloadClient.h:
867         * UIProcess/Cocoa/DownloadClient.mm:
868         (WebKit::DownloadClient::DownloadClient):
869         (WebKit::DownloadClient::didReceiveResponse):
870         (WebKit::DownloadClient::didReceiveData):
871         * UIProcess/Downloads/DownloadProxy.cpp:
872         (WebKit::DownloadProxy::didReceiveData):
873         * UIProcess/Downloads/DownloadProxy.h:
874         (WebKit::DownloadProxy::expectedContentLength const): Deleted.
875         (WebKit::DownloadProxy::setExpectedContentLength): Deleted.
876         (WebKit::DownloadProxy::bytesLoaded const): Deleted.
877         (WebKit::DownloadProxy::setBytesLoaded): Deleted.
878         * UIProcess/Downloads/DownloadProxy.messages.in:
879
880 2020-05-19  Kate Cheney  <katherine_cheney@apple.com>
881
882         ITP database should finalize all prepared statements before closing
883         https://bugs.webkit.org/show_bug.cgi?id=211929
884         <rdar://problem/63246945>
885
886         Reviewed by John Wilander.
887
888         No new tests, behavior confirmed by existing tests.
889
890         Convert all SQLite statement objects to be unique pointers to better
891         manage the lifetime of each statement object. Only initialize and
892         prepare an object when it is needed instead of preparing all objects
893         at once. Set each statement to null before closing the database
894         because ~SQLiteStatement() will finalize the statement.
895
896         This patch removes all reset() commands now that we initialize
897         each statement using SQLiteStatementAutoResetScope.
898
899         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
900         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
901         (WebKit::ResourceLoadStatisticsDatabaseStore::close):
902         (WebKit::ResourceLoadStatisticsDatabaseStore::getScopedStatement const):
903         Function to initialize and prepare a statement.
904
905         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationship):
906         This function is not used and can be deleted.
907
908         (WebKit::ResourceLoadStatisticsDatabaseStore::checkForMissingTablesInSchema):
909         (WebKit::ResourceLoadStatisticsDatabaseStore::isMigrationNecessary):
910         (WebKit::ResourceLoadStatisticsDatabaseStore::openAndUpdateSchemaIfNecessary):
911         (WebKit::ResourceLoadStatisticsDatabaseStore::isEmpty const):
912         (WebKit::ResourceLoadStatisticsDatabaseStore::destroyStatements):
913         (WebKit::ResourceLoadStatisticsDatabaseStore::insertObservedDomain):
914         (WebKit::ResourceLoadStatisticsDatabaseStore::relationshipExists const):
915         (WebKit::ResourceLoadStatisticsDatabaseStore::domainID const):
916         (WebKit::ResourceLoadStatisticsDatabaseStore::merge):
917         (WebKit::ResourceLoadStatisticsDatabaseStore::mergeStatistic):
918         (WebKit::CompletionHandler<void):
919         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements): Deleted.
920         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
921         Updated all statement variables to end with "Statement" to follow the
922         established pattern.
923
924         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
925         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
926
927 2020-05-19  Per Arne Vollan  <pvollan@apple.com>
928
929         [iOS] Fix message filter sandbox violation
930         https://bugs.webkit.org/show_bug.cgi?id=212100
931         <rdar://problem/63407155>
932
933         Reviewed by Andy Estes.
934
935         A message needs to be added to the message filter in the WebContent sandbox on iOS.
936
937         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
938
939 2020-05-19  Kate Cheney  <katherine_cheney@apple.com>
940
941         Revert WebKitTestRunner to reset ITP to the memory store between all tests.
942         https://bugs.webkit.org/show_bug.cgi?id=212094
943         <rdar://problem/63405806>
944
945         Reviewed by Chris Dumez.
946
947         Changing this in https://bugs.webkit.org/show_bug.cgi?id=211637 caused
948         test flakiness.
949
950         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
951         (WKWebsiteDataStoreStatisticsResetToConsistentState):
952
953 2020-05-19  Simon Fraser  <simon.fraser@apple.com>
954
955         Push a PlatformDisplayID to scrolling trees, and allow the scrolling thread to get displayDidRefresh notifications
956         https://bugs.webkit.org/show_bug.cgi?id=211034
957
958         Reviewed by Sam Weinig.
959
960         Prep work for webkit.org/b210884.
961
962         Have EventDispatcher call displayDidRefresh() on each scrolling tree it knows about. It calls this
963         on the EventDispatcher thread; the scrolling tree is responsible for bouncing that to the scrolling thread.
964
965         * WebProcess/WebPage/EventDispatcher.cpp:
966         (WebKit::EventDispatcher::displayDidRefreshOnScrollingThread):
967         (WebKit::EventDispatcher::displayWasRefreshed):
968         * WebProcess/WebPage/EventDispatcher.h:
969
970 2020-05-19  Wenson Hsieh  <wenson_hsieh@apple.com>
971
972         [macOS] Drag and drop within a contenteditable area duplicates attachment-backed images
973         https://bugs.webkit.org/show_bug.cgi?id=212075
974         <rdar://problem/62434146>
975
976         Reviewed by Andy Estes.
977
978         When the attachment API is enabled, starting a drag on an attachment-element-backed image within a
979         contenteditable area sometimes causes the ranged selection to collapse. This is because `WebViewImpl::startDrag`
980         has a separate codepath for starting a drag with attachment metadata that doesn't invoke `NSView`'s deprecated
981         `-dragImage:at:offset:event:pasteboar:source:slideBack:` method, but instead uses
982         `-beginDraggingSessionWithItems:event:source:`. While the former spins the runloop until the end of the drag
983         session, the latter does not and returns immediately after beginning the drag. As a result,
984         `WebPageProxy::didStartDrag()` is actually invoked after the drag ends when dragging non-attachment content,
985         whereas `WebPageProxy::didStartDrag()` is invoked immediately after beginning the drag when starting a drag in
986         an attachment or attachment-backed image element.
987
988         This call to `didStartDrag()` is used to inform the web process that dragging has begun, and sets the
989         `m_isStartingDrag` flag on `WebPage` to false. As a result, `m_isStartingDrag` is true over the course of the
990         drag session when dragging non-attachment elements, but it's only true while starting the drag when dragging
991         attachments. This flag is consulted in `WebPage::mouseEvent()` to determine whether we should avoid handling the
992         incoming mouse event when beginning a drag. This prevents these incoming mouse events from triggering selection
993         changes while dragging (for more details, refer to <http://trac.webkit.org/r176687>).
994
995         Now, if we combine this with the fact that mouse events can be queued up in the UI process (refer to
996         <https://trac.webkit.org/r230817>), it's possible to end up handling these queued mouse events in the web
997         process after `m_isStartingDrag` has been set back to false when dragging an attachment. This doesn't happen
998         when dragging non-attachment content, since we don't call `didStartDrag()` until the drag has already ended, so
999         any queued mouse events are sent to the web process and immediately dropped on the floor since
1000         `m_isStartingDrag` is true.
1001
1002         To address this, we make a couple of minor adjustments:
1003
1004         1.  Invoke `didStartDrag()` right before calling into `-dragImage:at:offset:event:pasteboar:source:slideBack:`,
1005             so that we don't wait until the drag ends to set `m_isStartingDrag` to false. This makes the behavior of
1006             both codepaths for starting a drag (attachment and non-attachment) consistent, and also makes it consistent
1007             with iOS.
1008
1009         2.  In `didStartDrag()`, discard any queued mouse events to prevent them from being handled by the page (e.g.
1010             causing the selection to change immediately after starting the drag). We already have identical logic to do
1011             this when showing a context menu, so we can factor this out into a private `WebPageProxy` helper and call it
1012             from both places.
1013
1014         Test: WKAttachmentTestsMac.DraggingAttachmentBackedImagePreservesRangedSelection
1015
1016         * UIProcess/Cocoa/WebViewImpl.mm:
1017         (WebKit::WebViewImpl::startDrag):
1018
1019         Invoke `didStartDrag()` earlier when starting a drag using the deprecated method, such that we don't wait until
1020         the drag ends to set `m_isStartingDrag` to false in the web process.
1021
1022         * UIProcess/WebPageProxy.cpp:
1023         (WebKit::WebPageProxy::discardQueuedMouseEvents):
1024
1025         Refactor logic to discard all queued mouse events into a separate private helper.
1026
1027         (WebKit::WebPageProxy::didStartDrag):
1028
1029         Use the above helper to empty queued mouse events when starting a drag.
1030
1031         (WebKit::WebPageProxy::showContextMenu):
1032         * UIProcess/WebPageProxy.h:
1033
1034 2020-05-19  Andy Estes  <aestes@apple.com>
1035
1036         [Apple Pay] Add testing and logging for ApplePaySetup
1037         https://bugs.webkit.org/show_bug.cgi?id=211972
1038         <rdar://problem/63291965>
1039
1040         Reviewed by Alex Christensen.
1041
1042         * Shared/ApplePay/PaymentSetupConfiguration.mm:
1043         (WebKit::toPlatformConfiguration):
1044         (WebKit::PaymentSetupConfiguration::PaymentSetupConfiguration):
1045         * Shared/ApplePay/PaymentSetupConfigurationWebKit.h:
1046         * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
1047         (WebKit::WebPaymentCoordinator::getSetupFeatures):
1048         (WebKit::WebPaymentCoordinator::beginApplePaySetup):
1049         * WebProcess/ApplePay/WebPaymentCoordinator.h:
1050
1051 2020-05-19  Brent Fulgham  <bfulgham@apple.com>
1052
1053         REGRESSION(r243149): createMediaElementSource not working
1054         https://bugs.webkit.org/show_bug.cgi?id=211394
1055         <rdar://problem/62866132>
1056
1057         Reviewed by Per Arne Vollan.
1058
1059         I removed access to some Audio services in r243149, because we believed they were already
1060         blocked by a global deny command. However, Sandbox rules override generic rules with
1061         explicit rules, so the imported sandbox rules were not being blocked.
1062
1063         This patch re-adds the rules needed to support these audio routines on iOS hardware.
1064
1065         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
1066         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1067         (WebKit::mediaRelatedMachServices):
1068
1069 2020-05-19  Chris Dumez  <cdumez@apple.com>
1070
1071         [iOS] Port Foreground process assertion to RunningBoard
1072         https://bugs.webkit.org/show_bug.cgi?id=211795
1073         <rdar://problem/61831863>
1074
1075         Reviewed by Geoffrey Garen.
1076
1077         Port Foreground process assertion to RunningBoard now that <rdar://problem/62614429>
1078         has been fixed.
1079
1080         * Configurations/WebKit.xcconfig:
1081         * UIProcess/ProcessAssertion.h:
1082         * UIProcess/ios/ProcessAssertionIOS.mm:
1083         (WebKit::runningBoardNameForAssertionType):
1084         (WebKit::ProcessAssertion::ProcessAssertion):
1085         (WebKit::ProcessAssertion::~ProcessAssertion):
1086         (WebKit::ProcessAssertion::isValid const):
1087
1088 2020-05-19  Andy Estes  <aestes@apple.com>
1089
1090         [Apple Pay] Add testing and logging for ApplePaySetup
1091         https://bugs.webkit.org/show_bug.cgi?id=211972
1092         <rdar://problem/63291965>
1093
1094         Reviewed by Alex Christensen.
1095
1096         * Shared/ApplePay/PaymentSetupConfiguration.mm:
1097         (WebKit::toPlatformConfiguration):
1098         (WebKit::PaymentSetupConfiguration::PaymentSetupConfiguration):
1099         * Shared/ApplePay/PaymentSetupConfigurationWebKit.h:
1100         * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
1101         (WebKit::WebPaymentCoordinator::getSetupFeatures):
1102         (WebKit::WebPaymentCoordinator::beginApplePaySetup):
1103         * WebProcess/ApplePay/WebPaymentCoordinator.h:
1104
1105 2020-05-19  Michael Catanzaro  <mcatanzaro@gnome.org>
1106
1107         [GTK] Add WEBKIT_EDITING_COMMAND_PASTE_AS_PLAIN_TEXT
1108         https://bugs.webkit.org/show_bug.cgi?id=212038
1109
1110         Reviewed by Carlos Garcia Campos.
1111
1112         * UIProcess/API/gtk/WebKitEditingCommands.h:
1113         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
1114         * UIProcess/API/wpe/WebKitEditingCommands.h:
1115         * UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
1116
1117 2020-05-18  David Kilzer  <ddkilzer@apple.com>
1118
1119         Replace TextIndicatorOptions with OptionSet<TextIndicatorOption>
1120         <https://webkit.org/b/212051>
1121         <rdar://problem/63368556>
1122
1123         Reviewed by Simon Fraser.
1124
1125         Use OptionSet<TextIndicatorOption> everywhere
1126         TextIndicatorOptions was previously used, plus:
1127         - Make TextIndicatorOption an enum class.  Remove
1128           "TextIndicatorOption" prefix so TextIndicatorOptionBar becomes
1129           TextIndicatorOption::Bar.
1130         - Remove TextIndicatorOptionDefault because OptionSet<>
1131           initializes to zero.
1132         - Replace static variables (including two globals in WebCore)
1133           with constexpr variables.
1134
1135         * Shared/WebCoreArgumentCoders.cpp:
1136         (IPC::ArgumentCoder<TextIndicatorData>::encode):
1137         (IPC::ArgumentCoder<TextIndicatorData>::decode):
1138         * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
1139         (WebKit::WebPage::dictionaryPopupInfoForRange):
1140         * WebProcess/WebPage/FindController.cpp:
1141         (WebKit::FindController::updateFindIndicator):
1142         * WebProcess/WebPage/ios/FindControllerIOS.mm:
1143         * WebProcess/WebPage/ios/WebPageIOS.mm:
1144         (WebKit::WebPage::insertDroppedImagePlaceholders):
1145         (WebKit::WebPage::computeAndSendEditDragSnapshot):
1146         (WebKit::linkIndicatorPositionInformation):
1147         * WebProcess/WebPage/mac/WebPageMac.mm:
1148         (WebKit::WebPage::performImmediateActionHitTestAtLocation):
1149
1150 2020-05-18  Andy Estes  <aestes@apple.com>
1151
1152         http/tests/ssl/applepay/ApplePayInstallmentConfiguration.https.html fails in public SDK builds
1153         https://bugs.webkit.org/show_bug.cgi?id=212000
1154         <rdar://problem/63323082>
1155
1156         Reviewed by Youenn Fablet.
1157
1158         * Configurations/FeatureDefines.xcconfig:
1159         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h:
1160         * Shared/WebCoreArgumentCoders.h:
1161
1162 2020-05-18  Tim Horton  <timothy_horton@apple.com>
1163
1164         Rare crash under -[WKContentView resignFirstResponderForWebView]
1165         https://bugs.webkit.org/show_bug.cgi?id=212050
1166         <rdar://problem/60187111>
1167
1168         Reviewed by Wenson Hsieh.
1169
1170         * UIProcess/ios/WKContentViewInteraction.mm:
1171         (-[WKContentView resignFirstResponderForWebView]):
1172         Reorganize this block so that it always takes a strong reference /before/
1173         null checking and using the pointer. Also, add a _page null check.
1174         This is a speculative fix for an unreproducible low-rate crash.
1175
1176         In theory the existing time-of-check race here should not be a problem,
1177         since WKWebView is supposed to be freed on the main thread, and this code
1178         runs on the main thread, but we have ample evidence of WKWebView
1179         being freed off the main thread in various clients.
1180
1181 2020-05-18  David Kilzer  <ddkilzer@apple.com>
1182
1183         Use default initializers in TextIndicatorData
1184         <https://webkit.org/b/212039>
1185         <rdar://problem/63355619>
1186
1187         Reviewed by Alex Christensen.
1188
1189         * Shared/WebCoreArgumentCoders.cpp:
1190         (IPC::ArgumentCoder<TextIndicatorData>::encode):
1191         (IPC::ArgumentCoder<TextIndicatorData>::decode):
1192         - Switch from decodeEnum() and encodeEnum() to modern
1193           equivalents that check for valid enum values.
1194
1195 2020-05-18  Wenson Hsieh  <wenson_hsieh@apple.com>
1196
1197         Replace uses of +self with +class
1198         https://bugs.webkit.org/show_bug.cgi?id=212041
1199
1200         Reviewed by Darin Adler.
1201
1202         * Shared/API/Cocoa/_WKFrameHandle.mm:
1203         (-[_WKFrameHandle isEqual:]):
1204         (-[_WKFrameHandle initWithCoder:]):
1205         * Shared/Cocoa/APIObject.mm:
1206         (API::Object::newObject):
1207         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
1208         (-[WKWebViewConfiguration _setAttachmentFileWrapperClass:]):
1209         * UIProcess/Cocoa/NavigationState.mm:
1210         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
1211         * UIProcess/Cocoa/PageClientImplCocoa.mm:
1212         (WebKit::PageClientImplCocoa::allocFileWrapperInstance const):
1213         (WebKit::PageClientImplCocoa::serializableFileWrapperClasses const):
1214         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
1215         (+[WKTransformView layerClass]):
1216         (+[WKSimpleBackdropView layerClass]): Deleted.
1217         (+[WKShapeView layerClass]): Deleted.
1218         (-[WKRemoteView initWithFrame:contextID:]): Deleted.
1219         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
1220         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::~ScrollingTreeScrollingNodeDelegateIOS):
1221         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::resetScrollViewDelegate):
1222         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollView const):
1223         * UIProcess/ios/WKContentViewInteraction.mm:
1224         (-[WKContentView selectFormAccessoryPickerRow:]):
1225         (-[WKContentView selectFormPopoverTitle]):
1226
1227 2020-05-18  Alex Christensen  <achristensen@webkit.org>
1228
1229         WebPageProxy::DidCommitLoadForFrame should use FrameLoadType instead of casting to/from uint32_t for IPC
1230         https://bugs.webkit.org/show_bug.cgi?id=212028
1231         <rdar://problem/63343021>
1232
1233         Reviewed by David Kilzer.
1234
1235         * UIProcess/ProvisionalPageProxy.cpp:
1236         (WebKit::ProvisionalPageProxy::didCommitLoadForFrame):
1237         * UIProcess/ProvisionalPageProxy.h:
1238         * UIProcess/WebPageProxy.cpp:
1239         (WebKit::WebPageProxy::commitProvisionalPage):
1240         (WebKit::WebPageProxy::didCommitLoadForFrame):
1241         * UIProcess/WebPageProxy.h:
1242         * UIProcess/WebPageProxy.messages.in:
1243         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1244         (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
1245
1246 2020-05-18  Wenson Hsieh  <wenson_hsieh@apple.com>
1247
1248         Single selection <select> with <optgroups> shows multiple selected options
1249         https://bugs.webkit.org/show_bug.cgi?id=199485
1250         <rdar://problem/52757531>
1251
1252         Reviewed by Megan Gardner.
1253
1254         Fixes a long-standing bug in WKMultipleSelectPicker. Prior to this patch, we rely on the delegate method
1255         `-pickerView:row:column:checked:` to be called twice whenever an item is selected: one time for the item that is
1256         no longer checked, and another for the newly checked item. This method is responsible for updating the cached
1257         `FocusedElementInformation` that determines the data model for the select menu, with the expectation that the
1258         unchecked item would be updated to have `isSelected = false;`, and the new checked item would have `isSelected`
1259         `= true;`.
1260
1261         However, `-pickerView:row:column:checked:` is only called for visible item cells. This means that if the user
1262         checks an item, scrolls the select menu items down so that the checked item is offscreen, and then checks a
1263         different item, we only get notified that the new item is checked, and as a result, fail to uncheck the previous
1264         item.
1265
1266         To address this, tweak our logic for handling a single select so that when an item is checked, we additionally
1267         update the previously checked item to not be selected. Also, fix what seems to be a bug in the logic for
1268         updating `_singleSelectionIndex`, which is currently updated even when the item is unchecked. It seems to work
1269         out at the moment, because `-pickerView:row:column:checked:` seems to be called with `checked := YES` after the
1270         previous item was unchecked (assuming that it was visible).
1271
1272         Test: fast/forms/ios/no-stale-checked-items-in-select-picker.html
1273
1274         * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
1275         * UIProcess/API/ios/WKWebViewTestingIOS.mm:
1276         (-[WKWebView selectFormAccessoryHasCheckedItemAtRow:]):
1277         * UIProcess/ios/WKContentViewInteraction.h:
1278         * UIProcess/ios/WKContentViewInteraction.mm:
1279         (-[WKContentView selectFormAccessoryHasCheckedItemAtRow:]):
1280
1281         Add plumbing for a new testing hook.
1282
1283         * UIProcess/ios/forms/WKFormSelectControl.h:
1284         * UIProcess/ios/forms/WKFormSelectControl.mm:
1285         (-[WKFormSelectControl selectFormAccessoryHasCheckedItemAtRow:]):
1286         * UIProcess/ios/forms/WKFormSelectPicker.mm:
1287         (-[WKMultipleSelectPicker pickerView:viewForRow:forComponent:reusingView:]):
1288         (-[WKMultipleSelectPicker pickerView:row:column:checked:]):
1289         (-[WKMultipleSelectPicker selectRow:inComponent:extendingSelection:]):
1290
1291         Also, fix an existing bug in this testing helper method that crashed the test runner due to calling an
1292         unimplemented selector. Instead of trying to invoke `-pickerView:didSelectRow:inComponent:`, we should be using
1293         `-pickerView:row:column:checked:` instead for multiple select pickers (which, somewhat confusingly, are still
1294         used for single select elements that have `optgroup`s.)
1295
1296         (-[WKMultipleSelectPicker selectFormAccessoryHasCheckedItemAtRow:]):
1297
1298 2020-05-18  Wenson Hsieh  <wenson_hsieh@apple.com>
1299
1300         [iOS] Unexpected capitalization of next word after repositioning caret
1301         https://bugs.webkit.org/show_bug.cgi?id=211969
1302         <rdar://problem/62605526>
1303
1304         Reviewed by Alex Christensen.
1305
1306         The changes in r242551 refactored synchronous autocorrection context request logic such that it uses
1307         `waitForAndDispatchImmediately` instead of `sendSync`, in order to make it interruptible by unbounded sync IPC
1308         sent from the web process. If the UI process receives sync IPC, it will immediately cancel the autocorrection
1309         context request (returning an empty context), before proceeding to handle the incoming sync IPC.
1310
1311         In a more recent version of iOS, other changes around spellchecking have caused the synchronous message
1312         `WebPageProxy::checkTextOfParagraph` to be sent from the web process in such a way that it now frequently
1313         coincides with the synchronous autocorrection context request being sent from the UI process. The result is that
1314         we now frequently end up cancelling autocorrection requests early by responding with empty contexts. This
1315         manifests in the keyboard sometimes losing information about its autocapitalization context and believing that
1316         it is in an empty text field, which reverts to default autocorrection suggestions and autocapitalizes the
1317         software keyboard.
1318
1319         To fix this, instead of using the `InterruptWaitingIfSyncMessageArrives` option when waiting for the IPC
1320         response, add and use a new flag that allows us to process an incoming sync IPC message if we're waiting for
1321         the sync message response. We use this new IPC flag when waiting synchronously for HandleAutocorrectionContext.
1322
1323         Test: editing/selection/ios/changing-selection-does-not-trigger-autocapitalization.html
1324
1325         * Platform/IPC/Connection.cpp:
1326         (IPC::Connection::processIncomingMessage):
1327
1328         If the new IPC flag is set and the incoming message is synchronous, allow it to immediately dispatch the sync
1329         message by enqueueing it and then waking up `m_waitForMessageCondition` so that it can process the message.
1330
1331         * Platform/IPC/Connection.h:
1332         * Platform/spi/ios/UIKitSPI.h:
1333         * UIProcess/ios/WKContentViewInteraction.mm:
1334         (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
1335
1336         Use `DispatchIncomingSyncMessagesWhileWaiting` instead of `InterruptWaitingIfSyncMessageArrives`.
1337
1338 2020-05-18  Lauro Moura  <lmoura@igalia.com>
1339
1340         webkitpy: Update test data after r261776
1341         https://bugs.webkit.org/show_bug.cgi?id=212008
1342
1343         Reviewed by Alex Christensen.
1344
1345         Covered by existing tests.
1346
1347         * Scripts/test-legacyMessageReceiver.cpp:
1348         * Scripts/test-legacyMessages.h:
1349         (Messages::WebPage::DidCreateWebProcessConnection::DidCreateWebProcessConnection):
1350         * Scripts/webkit/messages_unittest.py:
1351         * Scripts/webkit/test-legacy.messages.in:
1352
1353 2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1354
1355         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.29.1 release
1356
1357         * gtk/NEWS: Add release notes for 2.29.1.
1358
1359 2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1360
1361         Move iOS files from Source/WebKit/Sources.txt to Source/WebKit/SourcesCocoa.txt
1362         https://bugs.webkit.org/show_bug.cgi?id=212014
1363
1364         Unreviewed. Move platform specific files to the platform sources file.
1365
1366         * Sources.txt:
1367         * SourcesCocoa.txt:
1368
1369 2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1370
1371         [GTK] "ASSERTION FAILED: !m_adoptionIsRequired" when double clicking on a word
1372         https://bugs.webkit.org/show_bug.cgi?id=211957
1373
1374         Reviewed by Adrian Perez de Castro.
1375
1376         Remove WebSelectionData wrapper since we can just encode/decode WebCore::SelectionData.
1377
1378         * Shared/WebCoreArgumentCoders.h:
1379         * Shared/gtk/ArgumentCodersGtk.cpp:
1380         (IPC::ArgumentCoder<SelectionData>::decode): Use modern decoder.
1381         * Shared/gtk/ArgumentCodersGtk.h:
1382         * Shared/gtk/WebSelectionData.cpp: Removed.
1383         * Shared/gtk/WebSelectionData.h: Removed.
1384         * SourcesGTK.txt:
1385         * UIProcess/API/gtk/DragSource.h:
1386         * UIProcess/API/gtk/DragSourceGtk3.cpp:
1387         (WebKit::DragSource::DragSource):
1388         (WebKit::DragSource::begin):
1389         * UIProcess/API/gtk/DragSourceGtk4.cpp:
1390         (WebKit::DragSource::begin):
1391         * UIProcess/API/gtk/DropTarget.h:
1392         * UIProcess/API/gtk/DropTargetGtk3.cpp:
1393         (WebKit::DropTarget::accept):
1394         (WebKit::DropTarget::enter):
1395         (WebKit::DropTarget::update):
1396         (WebKit::DropTarget::leaveTimerFired):
1397         (WebKit::DropTarget::drop):
1398         * UIProcess/API/gtk/PageClientImpl.cpp:
1399         (WebKit::PageClientImpl::startDrag):
1400         * UIProcess/API/gtk/PageClientImpl.h:
1401         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
1402         (webkitWebViewBaseStartDrag):
1403         * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
1404         * UIProcess/PageClient.h:
1405         * UIProcess/WebPageProxy.cpp:
1406         (WebKit::WebPageProxy::performDragControllerAction):
1407         (WebKit::WebPageProxy::startDrag):
1408         * UIProcess/WebPageProxy.h:
1409         * UIProcess/WebPageProxy.messages.in:
1410         * UIProcess/WebPasteboardProxy.h:
1411         * UIProcess/WebPasteboardProxy.messages.in:
1412         * UIProcess/gtk/Clipboard.h:
1413         * UIProcess/gtk/ClipboardGtk3.cpp:
1414         (WebKit::WriteAsyncData::WriteAsyncData):
1415         (WebKit::Clipboard::write):
1416         * UIProcess/gtk/ClipboardGtk4.cpp:
1417         (WebKit::Clipboard::write):
1418         * UIProcess/gtk/WebPasteboardProxyGtk.cpp:
1419         (WebKit::WebPasteboardProxy::writeToClipboard):
1420         (WebKit::WebPasteboardProxy::writeCustomData):
1421         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
1422         (WebKit::WebPlatformStrategies::writeToClipboard):
1423         * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
1424         (WebKit::WebDragClient::startDrag):
1425         * WebProcess/WebPage/WebPage.cpp:
1426         (WebKit::WebPage::performDragControllerAction):
1427         * WebProcess/WebPage/WebPage.h:
1428         * WebProcess/WebPage/WebPage.messages.in:
1429
1430 2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1431
1432         [GTK] Add WebKitContextMenuItemType for paste as plaintext
1433         https://bugs.webkit.org/show_bug.cgi?id=177638
1434
1435         Reviewed by Michael Catanzaro.
1436
1437         Add WEBKIT_CONTEXT_MENU_ACTION_PASTE_AS_PLAIN_TEXT.
1438
1439         * Shared/API/glib/WebKitContextMenuActions.cpp:
1440         (webkitContextMenuActionGetActionTag):
1441         (webkitContextMenuActionGetForContextMenuItem):
1442         (webkitContextMenuActionGetLabel):
1443         * UIProcess/API/gtk/WebKitContextMenuActions.h:
1444         * UIProcess/gtk/KeyBindingTranslator.cpp:
1445
1446 2020-05-17  Carlos Garcia Campos  <cgarcia@igalia.com>
1447
1448         [GTK] Move to new Pasteboard API
1449         https://bugs.webkit.org/show_bug.cgi?id=177633
1450
1451         Reviewed by Adrian Perez de Castro.
1452
1453         Enable custom pasteboard data.
1454
1455         * Shared/WebPreferencesDefaultValues.h:
1456         * Shared/gtk/ArgumentCodersGtk.cpp:
1457         (IPC::ArgumentCoder<SelectionData>::encode):
1458         (IPC::ArgumentCoder<SelectionData>::decode):
1459         * UIProcess/WebPasteboardProxy.cpp:
1460         * UIProcess/gtk/ClipboardGtk3.cpp:
1461         (WebKit::Clipboard::write): Add support for writing URI list and custom data.
1462         * UIProcess/gtk/ClipboardGtk4.cpp:
1463         (WebKit::Clipboard::write): Ditto.
1464         * UIProcess/gtk/WebPasteboardProxyGtk.cpp:
1465         (WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
1466         (WebKit::WebPasteboardProxy::writeCustomData):
1467
1468 2020-05-16  Andy Estes  <aestes@apple.com>
1469
1470         REGRESSION (r260717): installmentConfiguration member is no longer available on ApplePayPaymentRequest
1471         https://bugs.webkit.org/show_bug.cgi?id=211911
1472         <rdar://problem/63236367>
1473
1474         Reviewed by Tim Horton.
1475
1476         * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
1477         (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::encode):
1478         (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode):
1479         (IPC::finishDecoding): Deleted.
1480         (IPC::finishEncoding): Deleted.
1481
1482 2020-05-16  Yury Semikhatsky  <yurys@chromium.org>
1483
1484         [GTK] Do not leak pages created by window.open
1485         https://bugs.webkit.org/show_bug.cgi?id=211970
1486
1487         Reviewed by Carlos Garcia Campos.
1488
1489         Previously webkitWebViewCreateNewPage created unbalanced refence to WebPageProxy and returned
1490         it as a raw pointer. That raw pointer was later wrapped in a RefPtr in WebKitUIClient.
1491         This change ensures that all refs are balanced by returnin RefPtr instead of
1492         a raw pointer.
1493
1494         * UIProcess/API/glib/WebKitWebView.cpp:
1495         (webkitWebViewCreateNewPage):
1496         * UIProcess/API/glib/WebKitWebViewPrivate.h:
1497
1498 2020-05-15  Alex Christensen  <achristensen@webkit.org>
1499
1500         Use enum serialization instead of casting to/from uint32_t
1501         https://bugs.webkit.org/show_bug.cgi?id=211885
1502
1503         Reviewed by Geoffrey Garen.
1504
1505         * Scripts/webkit/messages.py:
1506         * Shared/DocumentEditingContext.h:
1507         * Shared/ios/GestureTypes.h:
1508         * UIProcess/API/C/WKAPICast.h:
1509         (WebKit::toWebGLLoadPolicy):
1510         (WebKit::toAPI):
1511         * UIProcess/Cocoa/NavigationState.mm:
1512         (WebKit::toWebCoreWebGLLoadPolicy):
1513         (WebKit::NavigationState::NavigationClient::webGLLoadPolicy const):
1514         (WebKit::NavigationState::NavigationClient::resolveWebGLLoadPolicy const):
1515         * UIProcess/WebPageProxy.cpp:
1516         (WebKit::WebPageProxy::webGLPolicyForURL):
1517         (WebKit::WebPageProxy::resolveWebGLPolicyForURL):
1518         * UIProcess/WebPageProxy.h:
1519         * UIProcess/WebPageProxy.messages.in:
1520         * UIProcess/ios/WKContentViewInteraction.mm:
1521         (-[WKContentView selectForWebView:]):
1522         (toUIWKSelectionFlags):
1523         (toSelectionFlags):
1524         (toWKTextGranularity):
1525         (toWKSelectionDirection):
1526         (selectionChangedWithGesture):
1527         (selectionChangedWithTouch):
1528         (-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
1529         (-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
1530         (-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
1531         (-[WKContentView selectWordForReplacement]):
1532         * UIProcess/ios/WebPageProxyIOS.mm:
1533         (WebKit::WebPageProxy::gestureCallback):
1534         (WebKit::WebPageProxy::touchesCallback):
1535         (WebKit::WebPageProxy::selectWithGesture):
1536         (WebKit::WebPageProxy::updateSelectionWithTouches):
1537         (WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
1538         (WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
1539         (WebKit::WebPageProxy::moveSelectionAtBoundaryWithDirection):
1540         (WebKit::WebPageProxy::selectWithTwoTouches):
1541         (WebKit::WebPageProxy::extendSelection):
1542         (WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
1543         * WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
1544         (-[WKDOMRange rangeByExpandingToWordBoundaryByCharacters:inDirection:]):
1545         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1546         (WebKit::WebFrameLoaderClient::webGLPolicyForURL const):
1547         (WebKit::WebFrameLoaderClient::resolveWebGLPolicyForURL const):
1548         * WebProcess/WebPage/WebPage.cpp:
1549         (WebKit::WebPage::webGLPolicyForURL):
1550         (WebKit::WebPage::resolveWebGLPolicyForURL):
1551         * WebProcess/WebPage/WebPage.h:
1552         * WebProcess/WebPage/WebPage.messages.in:
1553         * WebProcess/WebPage/ios/WebPageIOS.mm:
1554         (WebKit::WebPage::getPlatformEditorState const):
1555         (WebKit::WebPage::getSelectionContext):
1556         (WebKit::WebPage::selectWithGesture):
1557         (WebKit::rangeAtWordBoundaryForPosition):
1558         (WebKit::WebPage::updateSelectionWithTouches):
1559         (WebKit::WebPage::selectWithTwoTouches):
1560         (WebKit::WebPage::extendSelection):
1561         (WebKit::WebPage::selectWordBackward):
1562         (WebKit::WebPage::moveSelectionByOffset):
1563         (WebKit::WebPage::getRectsForGranularityWithSelectionOffset):
1564         (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
1565         (WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
1566         (WebKit::WebPage::rangeForGranularityAtPoint):
1567         (WebKit::WebPage::selectTextWithGranularityAtPoint):
1568         (WebKit::WebPage::beginSelectionInDirection):
1569         (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
1570         (WebKit::WebPage::requestDictationContext):
1571         (WebKit::WebPage::applyAutocorrectionInternal):
1572         (WebKit::WebPage::autocorrectionContext):
1573         (WebKit::dataDetectorLinkPositionInformation):
1574         (WebKit::moveByGranularityRespectingWordBoundary):
1575         (WebKit::WebPage::requestDocumentEditingContext):
1576         * WebProcess/WebPage/mac/WebPageMac.mm:
1577         (WebKit::WebPage::webGLPolicyForURL):
1578         (WebKit::WebPage::resolveWebGLPolicyForURL):
1579
1580 2020-05-15  Alex Christensen  <achristensen@webkit.org>
1581
1582         [iOS Simulator] TestWebKitAPI._WKDownload.Resume is a flaky crash
1583         https://bugs.webkit.org/show_bug.cgi?id=211786
1584
1585         Reviewed by Geoffrey Garen.
1586
1587         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
1588         (-[WKNetworkSessionDelegate URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:]):
1589
1590 2020-05-15  Alex Christensen  <achristensen@webkit.org>
1591
1592         Regression (iOS 13.4, r249142): WKWebView.loading is never reset after a Back navigation in an iframe
1593         https://bugs.webkit.org/show_bug.cgi?id=211449
1594
1595         Reviewed by Geoffrey Garen.
1596
1597         Always call clearPendingAPIRequest in WebPageProxy::didStartProvisionalLoadForFrameShared.
1598         r249142 regressed this and caused more "loading appears to continue forever" bugs fixed in r249890.
1599         This should fix both, by removing the problematic half of r249142.
1600
1601         Covered by an API test.
1602
1603         * UIProcess/WebPageProxy.cpp:
1604         (WebKit::WebPageProxy::didStartProvisionalLoadForFrameShared):
1605
1606 2020-05-15  Adrian Perez de Castro  <aperez@igalia.com>
1607
1608         [GTK3] Bring back usage of GtkMenu for context menus
1609         https://bugs.webkit.org/show_bug.cgi?id=211557
1610
1611         Reviewed by Carlos Garcia Campos.
1612
1613         * UIProcess/API/glib/WebKitWebView.cpp:
1614         (contextMenuDismissed): Removed.
1615         (webkitWebViewPopulateContextMenu): Use WebContextMenuProxyGtk::widgetDismissedSignal
1616         and move the code from contextMenuDismissed() into an inline lambda.
1617         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
1618         (activeContextMenuClosed): Removed.
1619         (webkitWebViewBaseSetActiveContextMenuProxy): Use WebContextMenuProxyGtk::widgetDismissedSignal
1620         and move the code from activeContextMenuClosed() into an inline lambda.
1621         * UIProcess/gtk/WebContextMenuProxyGtk.cpp: Add helper functions to manipulate the actual
1622         widget used for context menus depending on whether GTK3 or GTK4 is being used. The GTK3
1623         versions bring back bits of code removed in r260889.
1624         (WebKit::createMenuWidget): Added.
1625         (WebKit::popupMenuWidget): Added.
1626         (WebKit::popdownMenuWidget): Added.
1627         (WebKit::menuWidgetHasItems): Added.
1628         (WebKit::bindModelToMenuWidget): Added.
1629         (WebKit::WebContextMenuProxyGtk::populate): Use context menu widget helper functions.
1630         (WebKit::WebContextMenuProxyGtk::showContextMenuWithItems): Ditto.
1631         (WebKit::WebContextMenuProxyGtk::WebContextMenuProxyGtk): Ditto. Also handle the
1632         signal triggered when the context menu is dismissed and arrange to call
1633         webkitWebViewContextMenuDismissed() and webkitWebViewBaseContextMenuDismissed().
1634         (WebKit::WebContextMenuProxyGtk::~WebContextMenuProxyGtk): Use helper functions.
1635         * UIProcess/gtk/WebContextMenuProxyGtk.h: Add WebContextMenuProxyGtk::widgetDismissedSignal
1636         constant.
1637
1638 2020-05-14  Kate Cheney  <katherine_cheney@apple.com>
1639
1640         Attribute non-network loads and loads with html strings as automatically app-bound
1641         https://bugs.webkit.org/show_bug.cgi?id=211913
1642         <rdar://problem/63157801
1643
1644         Reviewed by Brent Fulgham.
1645
1646         Move logic from WebsiteDataStoreCocoa to WebPageProxy to check for
1647         special app-bound protocols and set m_limitsNavigationToAppBoundDomains
1648         to force these WebViews into app-bound mode.
1649
1650         * UIProcess/API/Cocoa/WKWebView.mm:
1651         (-[WKWebView _isForcedIntoAppBoundMode:]):
1652         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1653         Testing SPI to see whether m_limitsNavigationsToAppBoundDomains was
1654         set.
1655
1656         * UIProcess/WebPageProxy.cpp:
1657         (WebKit::WebPageProxy::loadData):
1658         Check for html string loads and force WebView into app-bound mode if needed.
1659         No need to worry about setting this variable even if the app hasn't
1660         opted in because setIsNavigatingToAppBoundDomainAndCheckIfPermitted
1661         does an early return before checking this variable if
1662         WKAppBoundDomains does not exist.
1663
1664         (WebKit::shouldTreatURLProtocolAsAppBound):
1665         Adds javascript protocols to this check.
1666
1667         (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomainAndCheckIfPermitted):
1668         Check for special protocols here and force WebView into app-bound mode.
1669
1670         (WebKit::WebPageProxy::isForcedIntoAppBoundModeTesting):
1671         * UIProcess/WebPageProxy.h:
1672         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1673         (WebKit::WebsiteDataStore::beginAppBoundDomainCheck):
1674         (WebKit::shouldTreatURLProtocolAsAppBound): Deleted.
1675
1676 2020-05-14  Timothy Hatcher  <timothy@apple.com>
1677
1678         Add baseURL version of _WKUserStyleSheet forWKWebView.
1679         https://bugs.webkit.org/show_bug.cgi?id=211926
1680         rdar://problem/62074675
1681
1682         Reviewed by Devin Rousso.
1683
1684         * UIProcess/API/Cocoa/_WKUserStyleSheet.h:
1685         * UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
1686         (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:baseURL:level:userContentWorld:]): Added.
1687         (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:level:userContentWorld:]): Clean up WebCore::UserStyleSheet initializer.
1688         (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): Ditto.
1689         (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto.
1690         (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): Ditto.
1691         (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:level:userContentWorld:]): Ditto.
1692
1693 2020-05-14  John Wilander  <wilander@apple.com>
1694
1695         Add quirk for cookie blocking latch mode aolmail.com redirecting to aol.com under aol.com
1696         https://bugs.webkit.org/show_bug.cgi?id=211925
1697         <rdar://problem/61901041>
1698
1699         Reviewed by Brent Fulgham.
1700
1701         No new tests. Just a new quirk for a pair of domains added by request.
1702
1703         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
1704         (WebKit::NetworkDataTaskCocoa::needsFirstPartyCookieBlockingLatchModeQuirk const):
1705
1706 2020-05-14  Chris Dumez  <cdumez@apple.com>
1707
1708         Regression(r261163) Causes crashes on builds without libwebrtc.dylib
1709         https://bugs.webkit.org/show_bug.cgi?id=211924
1710         <rdar://problem/63206792>
1711
1712         Reviewed by Jer Noble.
1713
1714         * WebProcess/Network/NetworkProcessConnection.cpp:
1715         (WebKit::NetworkProcessConnection::NetworkProcessConnection):
1716
1717 2020-05-14  Timothy Hatcher  <timothy@apple.com>
1718
1719         Add sourceURL to _evaluateJavaScript: so the scripts appear in Web Inspector.
1720         https://bugs.webkit.org/show_bug.cgi?id=211904
1721         rdar://problem/62074376
1722
1723         Reviewed by Devin Rousso.
1724
1725         Added sourceURL version of _evaluateJavaScript: that passes the sourceURL to RunJavaScriptParameters.
1726         If the sourceURL is invalid, generate a unique user script URL so the source code errors are not showing
1727         up with the frame's document URL and bogus locations.
1728
1729         * UIProcess/API/C/WKPage.cpp:
1730         (WKPageRunJavaScriptInMainFrame): pass API::UserScript::generateUniqueURL() for the sourceURL.
1731         * UIProcess/API/Cocoa/WKUserScript.mm:
1732         (-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]): Clean up WebCore::UserScript initializer.
1733         (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): Ditto.
1734         (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]): Ditto.
1735         (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]): Ditto.
1736         (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]): Ditto.
1737         (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:deferRunningUntilNotification:]): Ditto.
1738         * UIProcess/API/Cocoa/WKWebView.mm:
1739         (-[WKWebView _evaluateJavaScript:asAsyncFunction:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]): Renamed to add sourceURL.
1740         (-[WKWebView _evaluateJavaScript:asAsyncFunction:withSourceURL:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]): Added sourceURL.
1741         (-[WKWebView _evaluateJavaScript:withSourceURL:inFrame:inContentWorld:completionHandler:]): Added. Pass sourceURL through.
1742         (-[WKWebView evaluateJavaScript:completionHandler:]): Call new method with sourceURL as nil.
1743         (-[WKWebView evaluateJavaScript:inContentWorld:completionHandler:]): Ditto.
1744         (-[WKWebView callAsyncJavaScript:arguments:inContentWorld:completionHandler:]): Ditto.
1745         (-[WKWebView _callAsyncJavaScript:arguments:inFrame:inContentWorld:completionHandler:]): Ditto.
1746         (-[WKWebView _evaluateJavaScript:inFrame:inContentWorld:completionHandler:]): Ditto.
1747         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1748
1749 2020-05-14  Chris Dumez  <cdumez@apple.com>
1750
1751         WebsiteDataStore functions should only send IPC to WebProcesses that are associated with its session
1752         https://bugs.webkit.org/show_bug.cgi?id=211917
1753
1754         Reviewed by Alex Christensen.
1755
1756         WebsiteDataStore functions should only send IPC to WebProcesses that are associated with its session.
1757         setResourceLoadStatisticsEnabled() / clearResourceLoadStatisticsInWebProcesses() were talking to all
1758         WebProcesses, even those associated with other sessions, which was wrong.
1759
1760         * UIProcess/WebProcessPool.cpp:
1761         (WebKit::WebProcessPool::clearResourceLoadStatistics): Deleted.
1762         * UIProcess/WebProcessPool.h:
1763         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1764         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
1765         (WebKit::WebsiteDataStore::clearResourceLoadStatisticsInWebProcesses):
1766
1767 2020-05-14  Daniel Bates  <dabates@apple.com>
1768
1769         [iOS] Remove dead dictation code
1770         https://bugs.webkit.org/show_bug.cgi?id=211871
1771
1772         Reviewed by Wenson Hsieh.
1773
1774         UIKit has long removed all callers that would call -nextUnperturbedDictationResultBoundaryFromPosition
1775         and -previousUnperturbedDictationResultBoundaryFromPosition. So, remove the implementations.
1776
1777         * UIProcess/ios/WKContentViewInteraction.mm:
1778         (-[WKContentView previousUnperturbedDictationResultBoundaryFromPosition:]): Deleted.
1779         (-[WKContentView nextUnperturbedDictationResultBoundaryFromPosition:]): Deleted.
1780
1781 2020-05-14  Brady Eidson  <beidson@apple.com>
1782
1783         Crash in PDFPlugin::ensureDataBufferLength
1784         <rdar://problem/62932155> and https://bugs.webkit.org/show_bug.cgi?id=211818
1785
1786         Reviewed by Tim Horton.
1787
1788         There's some currently unreproducible case(s) where a range request finishes
1789         while there's no m_data to append it to.
1790         
1791         It's fair hardening to handle that case.
1792
1793         * WebProcess/Plugins/PDF/PDFPlugin.mm:
1794         (WebKit::PDFPlugin::getResourceBytesAtPositionMainThread): Handle null m_data.
1795         (WebKit::PDFPlugin::ensureDataBufferLength): Ditto.
1796
1797 2020-05-14  Per Arne Vollan  <pvollan@apple.com>
1798
1799         [iOS] Update message filtering rules in the WebContent process' sandbox
1800         https://bugs.webkit.org/show_bug.cgi?id=211188
1801
1802         Reviewed by Brent Fulgham.
1803
1804         Based on telemetry and local testing, update the message filtering rules in the WebContent process' sandbox on iOS.
1805         Messages that have not been observed being in use, should be denied.
1806
1807         No new tests, covered by existing tests.
1808
1809         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
1810
1811 2020-05-14  Adrian Perez de Castro  <aperez@igalia.com>
1812
1813         Non-unified build fixed, mid May 2020 edition
1814         https://bugs.webkit.org/show_bug.cgi?id=211859
1815
1816         Unreviewed build fix.
1817
1818         * UIProcess/gtk/Clipboard.cpp: Add missing includes for <mutex>, wtf/NeverDestroyed.h, and
1819         wtf/text/WTFString.h.
1820         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: Add missing
1821         SharedBufferDataReference.h include.
1822         * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Add missing namespace to usage of
1823         the WebCore::SharedBuffer type.
1824
1825 2020-05-13  David Kilzer  <ddkilzer@apple.com>
1826
1827         [IPC] Use templates to reduce duplicate code in IPC::Decoder and IPC::Encoder classes
1828         <https://webkit.org/b/211861>
1829         <rdar://problem/62360390>
1830
1831         Reviewed by Alex Christensen.
1832
1833         In broad strokes, this change fixes the following issues:
1834         - Change `unsigned` type to `size_t` for `alignment` parameters
1835           for consistency on 32-bit platforms.
1836         - Templatize Encoder::encode(), Decoder::decode() and
1837           Decoder::operator>>() methods to reduce duplicate code.  This
1838           deleted code in source files, added template methods to header
1839           files, and required a few changes to existing templates in
1840           header files to disambiguate std::is_arithmetic parameter
1841           types.
1842         - Use `typename E` for all template methods that handle enum
1843           types.
1844         - Use `typename T` for all other template method types.
1845         - Move WARN_UNUSED_RETURN to same line as `bool` return type.
1846         - Add FIXME comments to validate enum values.
1847
1848         * Platform/IPC/Decoder.cpp:
1849         (IPC::roundUpToAlignment):
1850         (IPC::Decoder::alignBufferPosition):
1851         (IPC::Decoder::bufferIsLargeEnoughToContain const):
1852         (IPC::Decoder::decodeFixedLengthData):
1853         (IPC::decodeValueFromBuffer): Delete.
1854         (IPC::Decoder::getOptional): Delete.
1855         (IPC::Decoder::operator>>): Delete.
1856         (IPC::Decoder::decode): Delete.
1857         * Platform/IPC/Decoder.h:
1858         (IPC::Decoder::decode):
1859         (IPC::Decoder::operator>>):
1860         (IPC::Decoder::decodeEnum):
1861         * Platform/IPC/Encoder.cpp:
1862         (IPC::roundUpToAlignment):
1863         (IPC::Encoder::grow):
1864         (IPC::Encoder::encodeFixedLengthData):
1865         (IPC::copyValueToBuffer): Delete.
1866         (IPC::Encoder::encode): Delete.
1867         * Platform/IPC/Encoder.h:
1868
1869 2020-05-13  Devin Rousso  <drousso@apple.com>
1870
1871         Web Inspector: `RuntimeEnabledFeatures` should also be enabled when remotely inspecting
1872         https://bugs.webkit.org/show_bug.cgi?id=211874
1873
1874         Reviewed by Timothy Hatcher.
1875
1876         * WebProcess/Inspector/WebInspectorUI.h:
1877         * WebProcess/Inspector/WebInspectorUI.cpp:
1878         (WebKit::WebInspectorUI::enableFrontendFeatures): Added.
1879         (WebKit::WebInspectorUI::WebInspectorUI):
1880         * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
1881         (WebKit::RemoteWebInspectorUI::RemoteWebInspectorUI):
1882
1883 2020-05-13  Megan Gardner  <megan_gardner@apple.com>
1884
1885         Unreviewed Build Fix.
1886
1887         * UIProcess/ios/PageClientImplIOS.mm:
1888         (WebKit::PageClientImpl::setMouseEventPolicy):
1889         * UIProcess/ios/forms/WKDateTimeInputControl.mm:
1890         (-[WKDateTimePicker dealloc]):
1891         (-[WKDateTimePicker controlBeginEditing]):
1892         (-[WKDateTimePicker controlEndEditing]):
1893
1894 2020-05-13  Kate Cheney  <katherine_cheney@apple.com>
1895
1896         SHOULD NEVER BE REACHED in WebKit::ResourceLoadStatisticsDatabaseStore::openAndUpdateSchemaIfNecessary
1897         https://bugs.webkit.org/show_bug.cgi?id=211637
1898         <rdar://problem/63031185>
1899
1900         Reviewed by John Wilander.
1901
1902         No new tests, behavior confirmed by existing tests.
1903
1904         Stop reseting ITP to use the memory store between tests. This results
1905         in consecutive calls to NetworkSession::recreateResourceLoadStatisticStore
1906         if two database tests occur in a row, which can set the m_resourceLoadStatistics
1907         object before a previous call to WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore
1908         is done.
1909
1910         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
1911         (WKWebsiteDataStoreStatisticsResetToConsistentState):
1912
1913 2020-05-13  Megan Gardner  <megan_gardner@apple.com>
1914
1915         Change Date/Time popovers to contextMenus.
1916         https://bugs.webkit.org/show_bug.cgi?id=211825
1917         <rdar://problem/63102524>
1918
1919         Reviewed by Wenson Hsieh.
1920
1921         Update the Date/Time picker to use UIContextMenus instead of popovers.
1922         Removed all the unneeded popover code.
1923         Renamed WKFormInputControl to WKDateTimeInputControl because it was only used
1924         for date and time controls, unneccessary abstraction.
1925         We need to ensure the poisition information is up to date before presenting
1926         the context menu, or the position it will be presented from can be stale.
1927
1928         * SourcesCocoa.txt:
1929         * UIProcess/ios/WKContentViewInteraction.h:
1930         * UIProcess/ios/WKContentViewInteraction.mm:
1931         (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]):
1932         (-[WKContentView requiresAccessoryView]):
1933         (-[WKContentView _updateAccessory]):
1934         (mayContainSelectableText):
1935         (createInputPeripheralWithView):
1936         (-[WKContentView inputLabelText]):
1937         (-[WKContentView _removeContextMenuViewIfPossible]):
1938         (-[WKContentView inputLabelTextForViewController:]):
1939         (-[WKContentView formInputControl]):
1940         (-[WKContentView setTimePickerValueToHour:minute:]):
1941         (-[WKContentView timePickerValueHour]):
1942         (-[WKContentView timePickerValueMinute]):
1943         * UIProcess/ios/forms/WKDateTimeInputControl.h: Renamed from Source/WebKit/UIProcess/ios/forms/WKFormInputControl.h.
1944         * UIProcess/ios/forms/WKDateTimeInputControl.mm: Renamed from Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm.
1945         (-[WKDateTimeContextMenuViewController init]):
1946         (-[WKDateTimeContextMenuViewController preferredContentSize]):
1947         (-[WKDateTimePicker initWithView:datePickerMode:]):
1948         (-[WKDateTimePicker contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]):
1949         (-[WKDateTimePicker _contextMenuInteraction:styleForMenuWithConfiguration:]):
1950         (-[WKDateTimePicker contextMenuInteraction:configurationForMenuAtLocation:]):
1951         (-[WKDateTimePicker contextMenuInteraction:willEndForConfiguration:animator:]):
1952         (-[WKDateTimePicker removeContextMenuInteraction]):
1953         (-[WKDateTimePicker ensureContextMenuInteraction]):
1954         (-[WKDateTimePicker showDateTimePicker]):
1955         (-[WKDateTimePicker reset:]):
1956         (-[WKDateTimePicker calendarType]):
1957         (-[WKDateTimePicker dealloc]):
1958         (-[WKDateTimePicker setDateTimePickerToInitialValue]):
1959         (-[WKDateTimePicker controlBeginEditing]):
1960         (-[WKDateTimePicker viewController]):
1961         (-[WKDateTimePicker controlEndEditing]):
1962         (-[WKDateTimeInputControl initWithView:]):
1963         (-[WKDateTimeInputControl setTimePickerHour:minute:]):
1964         (-[WKDateTimeInputControl dateTimePickerCalendarType]):
1965         (-[WKDateTimeInputControl timePickerValueHour]):
1966         (-[WKDateTimeInputControl timePickerValueMinute]):
1967         * WebKit.xcodeproj/project.pbxproj:
1968
1969 2020-05-13  Wenson Hsieh  <wenson_hsieh@apple.com>
1970
1971         Unreviewed, fix tvOS and watchOS builds after r261638
1972
1973         `-[UIPasteboard itemProviders]` is not present on watchOS and tvOS.
1974
1975         * UIProcess/ios/WKContentViewInteraction.mm:
1976         (-[WKContentView _writePromisedAttachmentToPasteboard:]):
1977
1978 2020-05-13  Timothy Horton  <timothy_horton@apple.com>
1979
1980         Build fix.
1981
1982         * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
1983
1984 2020-05-13  Jer Noble  <jer.noble@apple.com>
1985
1986         Replace isNullFunctionPointer with real weak-linking support
1987         https://bugs.webkit.org/show_bug.cgi?id=211751
1988
1989         Reviewed by Sam Weinig.
1990
1991         Use the new WTF_WEAK_LINK_FORCE_IMPORT macro.
1992
1993         * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:
1994         (WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction):
1995
1996 2020-05-13  Tim Horton  <timothy_horton@apple.com>
1997
1998         Add SPI for reverting to touch events for iPad trackpad interactions
1999         https://bugs.webkit.org/show_bug.cgi?id=211824
2000         <rdar://problem/61363084>
2001
2002         Reviewed by Megan Gardner.
2003
2004         New Test: IOSMouseSupport.WebsiteMouseEventPolicies
2005
2006         Plumb a "mouse event policy" WKWebpagePreference, which has two values:
2007
2008         - Default, which means that WebKit decides whether or not indirect
2009         pointing devices send mouse or touch events.
2010
2011         - SynthesizeTouchEvents, which ensures that WebKit will always send
2012         touch events from indirect pointing devices.
2013         This value is only available on platforms that implement touch events.
2014
2015         We use the WKWebpagePreferences mechanism in order to make it easy to
2016         implement it as a "per-site" quirk, but unlike most WKWebpagePreferences,
2017         it turns around and changes UI process state (the enablement of the
2018         WKMouseGestureRecgonizer).
2019
2020         * Scripts/webkit/messages.py:
2021         * Shared/WebsitePoliciesData.cpp:
2022         (WebKit::WebsitePoliciesData::encode const):
2023         (WebKit::WebsitePoliciesData::decode):
2024         (WebKit::WebsitePoliciesData::applyToDocumentLoader):
2025         * Shared/WebsitePoliciesData.h:
2026         * UIProcess/API/APIWebsitePolicies.cpp:
2027         (API::WebsitePolicies::copy const):
2028         (API::WebsitePolicies::data):
2029         * UIProcess/API/APIWebsitePolicies.h:
2030         * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
2031         (WebKit::mouseEventPolicy):
2032         (WebKit::coreMouseEventPolicy):
2033         (-[WKWebpagePreferences _setMouseEventPolicy:]):
2034         (-[WKWebpagePreferences _mouseEventPolicy]):
2035         * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
2036         * UIProcess/PageClient.h:
2037         (WebKit::PageClient::setMouseEventPolicy):
2038         * UIProcess/ProvisionalPageProxy.cpp:
2039         (WebKit::ProvisionalPageProxy::didCommitLoadForFrame):
2040         * UIProcess/ProvisionalPageProxy.h:
2041         * UIProcess/WebPageProxy.cpp:
2042         (WebKit::WebPageProxy::commitProvisionalPage):
2043         (WebKit::WebPageProxy::didCommitLoadForFrame):
2044         * UIProcess/WebPageProxy.h:
2045         * UIProcess/WebPageProxy.messages.in:
2046         * UIProcess/ios/PageClientImplIOS.h:
2047         * UIProcess/ios/PageClientImplIOS.mm:
2048         (WebKit::PageClientImpl::setMouseEventPolicy):
2049         * UIProcess/ios/WKContentViewInteraction.h:
2050         * UIProcess/ios/WKContentViewInteraction.mm:
2051         (-[WKContentView shouldUseMouseGestureRecognizer]):
2052         (-[WKContentView setUpMouseGestureRecognizer]):
2053         (-[WKContentView _configureMouseGestureRecognizer]):
2054         (-[WKContentView _setMouseEventPolicy:]):
2055         * UIProcess/ios/WKMouseGestureRecognizer.mm:
2056         (-[WKMouseGestureRecognizer setEnabled:]):
2057         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2058         (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
2059
2060 2020-05-13  Wenson Hsieh  <wenson_hsieh@apple.com>
2061
2062         [iOS] "Copy" context menu action for attachment element does not work in Mail
2063         https://bugs.webkit.org/show_bug.cgi?id=211817
2064         <rdar://problem/58043110>
2065
2066         Reviewed by Tim Horton.
2067
2068         Implements support for copying an attachment element, via context menu actions. To achieve this, we first
2069         refactor code in WebCore that is currently responsible for converting an attachment element into a
2070         PromisedAttachmentInfo, which provides a handle to an UI-process-side API attachment object. We then use this
2071         helper in WebKit to send PromisedAttachmentInfo back to the UI process when handling the copy action from the
2072         context menu on iOS.
2073
2074         On iOS, we then take this promised attachment info in the UI process, map it to an API::Attachment object, and
2075         use the file handle to create and write an NSItemProvider to the general pasteboard. (In the future, similar
2076         logic could be implemented on macOS as well to handle copying attachment elements by implementing a version of
2077         writePromisedAttachmentToPasteboard in PageClientImplMac. Currently, we fall back to treating this case as if
2078         we're copying a text selection containing a single attachment element).
2079
2080         * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
2081
2082         Add a new helper function to simulate an element action (_WKElementActionType) for an element at the given
2083         location. This is used by the new API test.
2084
2085         * UIProcess/API/ios/WKWebViewTestingIOS.mm:
2086         (-[WKWebView _simulateElementAction:atLocation:]):
2087         * UIProcess/PageClient.h:
2088         (WebKit::PageClient::writePromisedAttachmentToPasteboard):
2089         * UIProcess/WebPageProxy.cpp:
2090         (WebKit::WebPageProxy::writePromisedAttachmentToPasteboard):
2091         * UIProcess/WebPageProxy.h:
2092         * UIProcess/WebPageProxy.messages.in:
2093
2094         Add an IPC message for the UI process to receive a PromisedAttachmentInfo, and copy it to the system pasteboard
2095         if it maps to an actual API::Attachment. For now, we only support copying data if the attachment is backed by
2096         a file wrapper in the UI process (as opposed to blob data written by the web process).
2097
2098         * UIProcess/ios/PageClientImplIOS.h:
2099         * UIProcess/ios/PageClientImplIOS.mm:
2100         (WebKit::PageClientImpl::writePromisedAttachmentToPasteboard):
2101         * UIProcess/ios/WKContentViewInteraction.h:
2102         * UIProcess/ios/WKContentViewInteraction.mm:
2103         (createItemProvider):
2104
2105         Create a helper function to convert PromisedAttachmentInfo into an NSItemProvider. This is similar to
2106         `-_prepareToDragPromisedAttachment:`, but with a couple differences: (1) we only create an NSItemProvider
2107         instead of going through `WebItemProviderRegistrationInfoList`; (2) since there's no opportunity to clean up
2108         temporary after pasting, serialize the attachment data using `-serializedRepresentation`, and provide the
2109         attachment data instead of a file URL.
2110
2111         Ideally, we would offer the data directly to the pasteboard so that even if Mail terminates, the contents of the
2112         pasteboard can still be provided when pasting; however, it doesn't seem like we can do this while being able to
2113         offer a suggested name for the item we're writing. Some other apps work around this limitation by writing the
2114         file name as plain text on the pasteboard, but this doesn't work then attempting to copy a plain text file that
2115         has a file name.
2116
2117         (-[WKContentView _writePromisedAttachmentToPasteboard:]):
2118         (-[WKContentView _simulateElementAction:atLocation:]):
2119         * WebProcess/WebPage/ios/WebPageIOS.mm:
2120         (WebKit::WebPage::performActionOnElement):
2121
2122 2020-05-13  Per Arne Vollan  <pvollan@apple.com>
2123
2124         [iOS] Update message filtering rules in the WebContent process' sandbox
2125         https://bugs.webkit.org/show_bug.cgi?id=211188
2126
2127         Reviewed by Brent Fulgham.
2128
2129         Based on telemetry and local testing, update the message filtering rules in the WebContent process' sandbox on iOS.
2130         Messages that have not been observed being in use, should be denied.
2131
2132         No new tests, covered by existing tests.
2133
2134         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
2135
2136 2020-05-13  Per Arne Vollan  <pvollan@apple.com>
2137
2138         [iOS] In CFPrefs direct mode, the WebContent sandbox needs to allow access to plist files
2139         https://bugs.webkit.org/show_bug.cgi?id=211782
2140
2141         Reviewed by Brent Fulgham.
2142
2143         Since preference files will be read directly in CFPrefs direct mode, the WebContent sandbox on iOS needs to allow reading these files.
2144
2145         No new tests. There is API test coverage for this in PreferenceChanges.mm, but these tests are only run on simulator, not device.
2146
2147         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
2148
2149 2020-05-13  Peng Liu  <peng.liu6@apple.com>
2150
2151         Add the feature flags plist file back
2152         https://bugs.webkit.org/show_bug.cgi?id=211816
2153
2154         Reviewed by Jer Noble.
2155
2156         Add the WebKit.plist file to the WebKit project and use it instead of the one from the WebKitAdditions.
2157
2158         * FeatureFlags/WebKit.plist: Added.
2159         * WebKit.xcodeproj/project.pbxproj:
2160
2161 2020-05-13  Youenn Fablet  <youenn@apple.com>
2162
2163         Allow WebAudioBufferList to dynamically change its number of frames
2164         https://bugs.webkit.org/show_bug.cgi?id=211720
2165
2166         Reviewed by Eric Carlson.
2167
2168         * WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
2169         (WebKit::RemoteCaptureSampleManager::RemoteAudio::setStorage):
2170         (WebKit::RemoteCaptureSampleManager::RemoteAudio::audioSamplesAvailable):
2171         * WebProcess/cocoa/RemoteCaptureSampleManager.h:
2172
2173 2020-05-13  Per Arne Vollan  <pvollan@apple.com>
2174
2175         Unreviewed compile fix after r261584.
2176
2177         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2178         (WebKit::WebProcessPool::platformInitializeWebProcess):
2179
2180 2020-05-13  Chris Dumez  <cdumez@apple.com>
2181
2182         REGRESSION (r261254): Broke Apple Pay on macOS
2183         https://bugs.webkit.org/show_bug.cgi?id=211826
2184         <rdar://problem/63161750>
2185
2186         Reviewed by Alex Christensen.
2187
2188         r261254 dropped the code needed to add the WebPaymentCoordinatorProxy as an IPC message receiver.
2189         This patch re-introduces the code in order to address the regression.
2190
2191         No new tests, tested manually on https://applepaydemo.apple.com.
2192
2193         * NetworkProcess/NetworkConnectionToWebProcess.h:
2194         * NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm:
2195         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAddMessageReceiver):
2196         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorRemoveMessageReceiver):
2197         * Shared/ApplePay/WebPaymentCoordinatorProxy.h:
2198         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
2199         (WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy):
2200         (WebKit::WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy):
2201         * UIProcess/Cocoa/WebPageProxyCocoa.mm:
2202         (WebKit::WebPageProxy::paymentCoordinatorAddMessageReceiver):
2203         (WebKit::WebPageProxy::paymentCoordinatorRemoveMessageReceiver):
2204         * UIProcess/WebPageProxy.h:
2205
2206 2020-05-13  Zan Dobersek  <zdobersek@igalia.com>
2207
2208         REGRESSION(r260571): RequestedScrollPosition doesn't have its scroll change applied to layers anymore
2209         https://bugs.webkit.org/show_bug.cgi?id=211374
2210
2211         Reviewed by Carlos Garcia Campos.
2212
2213         Use WebPage::finalizeRenderingUpdate() to perform the compositing state flush
2214         and the scrolling tree layer positioning, instead of doing things half-baked
2215         by manually invoking the FrameView method.
2216
2217         Additional WebPage calls (updateRendering(), flushPendingEditorStateUpdate())
2218         are moved into CompositingCoordinator::flushPendingLayerChanges() from the
2219         LayerTreeHost::layerFlushTimerFired() method for consistency. The additional
2220         CompositingCoordinator::syncDisplayState() method call is removed -- this call
2221         triggered any necessary layout, but that's already done through WebPage::updateRendering().
2222
2223         CompositingCoordinator::flushPendingLayerChanges() doesn't rely on the
2224         FrameView flush return value since that's not available anymore -- instead,
2225         true is returned always.
2226
2227         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
2228         (WebKit::CompositingCoordinator::flushPendingLayerChanges):
2229         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
2230         (WebKit::LayerTreeHost::layerFlushTimerFired):
2231
2232 2020-05-13  Per Arne Vollan  <pvollan@apple.com>
2233
2234         Unreviewed compile fix after r261584.
2235
2236         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2237
2238 2020-05-13  Tomoki Imai  <Tomoki.Imai@sony.com>
2239
2240         Selected element on Web Inspector is not highlighted with CPU Rendering.
2241         https://bugs.webkit.org/show_bug.cgi?id=195933
2242
2243         Reviewed by Devin Rousso.
2244
2245         Since WebInspectorClient::drawHighlight was not called while non accelerated compositing mode, we cannot see element highlight on web inspector.
2246         This patch adds WebInspectorClient::drawHighlight call in WebPage::drawRect, which draws webpage image while non accelerated compositing mode, to overlay the highlight.
2247         WebInspectorClient::highlight and WebInspectorClient::hideHighlight currently requests re-paint whole web page, but it should be able to optimize by only updating dirty rects in the future.
2248
2249         * WebProcess/Inspector/WebInspectorClient.cpp:
2250         (WebKit::WebInspectorClient::highlight): If it's not acceleratedCompositingEnabled, then just request repaint.
2251         (WebKit::WebInspectorClient::hideHighlight): If it's not acceleratedCompositingEnabled, then just request repaint.
2252         * WebProcess/WebPage/WebPage.cpp:
2253         (WebKit::WebPage::drawRect): Draw inspector overlay here if it's not accelerated compositing mode.
2254
2255 2020-05-13  Carlos Garcia Campos  <cgarcia@igalia.com>
2256
2257         Unreviewed. Fix GTK debug build after r261554
2258
2259         Remove writeToClipboard that receives a const SelectionData& that is no longer used.
2260
2261         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
2262         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
2263
2264 2020-05-12  Peng Liu  <peng.liu6@apple.com>
2265
2266         Add the feature flag plist file parser
2267         https://bugs.webkit.org/show_bug.cgi?id=211457
2268
2269         Reviewed by Tim Horton.
2270
2271         WebKit needs to parse the feature flags plist by itself in some cases.
2272
2273         * Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm: Added.
2274         (WebKit::featureFlagEnabled):
2275         * Shared/WebPreferencesDefaultValues.cpp:
2276         (WebKit::defaultAsyncFrameAndOverflowScrollingEnabled):
2277         (WebKit::defaultUseGPUProcessForMedia):
2278         (WebKit::defaultRenderCanvasInGPUProcessEnabled):
2279         (WebKit::defaultCaptureAudioInGPUProcessEnabled):
2280         (WebKit::defaultCaptureVideoInGPUProcessEnabled):
2281         (WebKit::defaultWebRTCCodecsInGPUProcess):
2282         (WebKit::defaultWebGL2Enabled):
2283         (WebKit::defaultWebGPUEnabled):
2284         (WebKit::defaultInAppBrowserPrivacy):
2285         (WebKit::defaultIncrementalPDFEnabled):
2286         (WebKit::defaultWebXREnabled):
2287         * Shared/WebPreferencesDefaultValues.h:
2288         * SourcesCocoa.txt:
2289         * WebKit.xcodeproj/project.pbxproj:
2290
2291 2020-05-12  Alex Christensen  <achristensen@webkit.org>
2292
2293         Give some NetworkLoadMetrics to WebCoreNSURLSession's delegate
2294         https://bugs.webkit.org/show_bug.cgi?id=211759
2295         <rdar://problem/62909440>
2296
2297         Reviewed by Jer Noble.
2298
2299         This also reduces duplicate lookups in RemoteMediaResourceManager
2300
2301         * GPUProcess/media/RemoteMediaResource.cpp:
2302         (WebKit::RemoteMediaResource::loadFinished):
2303         * GPUProcess/media/RemoteMediaResource.h:
2304         * GPUProcess/media/RemoteMediaResourceManager.cpp:
2305         (WebKit::RemoteMediaResourceManager::responseReceived):
2306         (WebKit::RemoteMediaResourceManager::redirectReceived):
2307         (WebKit::RemoteMediaResourceManager::dataSent):
2308         (WebKit::RemoteMediaResourceManager::dataReceived):
2309         (WebKit::RemoteMediaResourceManager::accessControlCheckFailed):
2310         (WebKit::RemoteMediaResourceManager::loadFailed):
2311         (WebKit::RemoteMediaResourceManager::loadFinished):
2312         * GPUProcess/media/RemoteMediaResourceManager.h:
2313         * GPUProcess/media/RemoteMediaResourceManager.messages.in:
2314         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
2315         (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):
2316         * WebProcess/GPU/media/RemoteMediaResourceProxy.cpp:
2317         (WebKit::RemoteMediaResourceProxy::loadFinished):
2318         * WebProcess/GPU/media/RemoteMediaResourceProxy.h:
2319
2320 2020-05-12  Jiewen Tan  <jiewen_tan@apple.com>
2321
2322         [WebAuthn] Don't assume extensions always exist
2323         https://bugs.webkit.org/show_bug.cgi?id=211760
2324         <rdar://problem/61217642>
2325
2326         Reviewed by Brent Fulgham.
2327
2328         * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
2329         (WebKit::WebCore::processGoogleLegacyAppIdSupportExtension):
2330         * UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp:
2331         (WebKit::CtapAuthenticator::processGoogleLegacyAppIdSupportExtension):
2332
2333 2020-05-12  Chris Dumez  <cdumez@apple.com>
2334
2335         [WK2] Neuter WKFrameIsFrameSet() / WKPageGetFrameSetLargestFrame() C API
2336         https://bugs.webkit.org/show_bug.cgi?id=211808
2337
2338         Reviewed by Darin Adler.
2339
2340         Neuter WKFrameIsFrameSet() / WKPageGetFrameSetLargestFrame() C API. This is only SPI and is only used for slightly
2341         different printing behavior in Safari. Framesets are no longer supported in HTML5 and are now super rare. Support
2342         for this C API adds quite a bit of code complexity and crashes such as <rdar://problem/60322282>, it just does not
2343         seem worth it anymore.
2344
2345         * UIProcess/API/C/WKFrame.cpp:
2346         (WKFrameIsFrameSet):
2347         * UIProcess/API/C/WKPage.cpp:
2348         (WKPageGetFrameSetLargestFrame):
2349         * UIProcess/WebFrameProxy.cpp:
2350         (WebKit::WebFrameProxy::didCommitLoad):
2351         * UIProcess/WebFrameProxy.h:
2352         (WebKit::WebFrameProxy::setIsFrameSet): Deleted.
2353         (WebKit::WebFrameProxy::isFrameSet const): Deleted.
2354         * UIProcess/WebPageProxy.cpp:
2355         (WebKit::WebPageProxy::resetState):
2356         (WebKit::WebPageProxy::frameDidBecomeFrameSet): Deleted.
2357         (WebKit::WebPageProxy::frameSetLargestFrameChanged): Deleted.
2358         * UIProcess/WebPageProxy.h:
2359         (WebKit::WebPageProxy::focusedFrame const):
2360         (WebKit::WebPageProxy::frameSetLargestFrame const): Deleted.
2361         * UIProcess/WebPageProxy.messages.in:
2362         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
2363         (WebKit::WebChromeClient::contentsSizeChanged const):
2364         (WebKit::findLargestFrameInFrameSet): Deleted.
2365         * WebProcess/WebCoreSupport/WebChromeClient.h:
2366         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2367         (WebKit::WebFrameLoaderClient::dispatchDidBecomeFrameset): Deleted.
2368         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
2369
2370 2020-05-12  Per Arne Vollan  <pvollan@apple.com>
2371
2372         [iOS] Rebuild MobileGestalt cache if needed
2373         https://bugs.webkit.org/show_bug.cgi?id=211739
2374
2375         Reviewed by Darin Adler.
2376
2377         This patch was written by Geoff Garen and myself. Rebuild the MobileGestalt cache in the UI process if the
2378         MobileGestalt cache is stale. This should be done before starting a new WebContent process. If the cache
2379         is not rebuilt, every MobileGestalt query in the WebContent process will fail, since access to the daemon
2380         is denied.
2381
2382         No new tests, since testing this is not trivial. It would involve deleting the MobileGestalt cache and
2383         making sure it is rebuilt afterwards. This could be an API test, but API tests are not supported on iOS
2384         devices.
2385
2386         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2387         (WebKit::WebProcessPool::platformInitializeWebProcess):
2388
2389 2020-05-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2390
2391         [GTK] Rework drag and drop handling in preparation for GTK4
2392         https://bugs.webkit.org/show_bug.cgi?id=211723
2393
2394         Reviewed by Adrian Perez de Castro.
2395
2396         Split DragAndDropHelper class into DragSource and DropTarget classes. This separates the source and destination
2397         parts making it easier to follow. This patch also adds PageClient::didPerformDragControllerAction() to notify
2398         back the view when an operation is done to update the result.
2399
2400         * SourcesGTK.txt:
2401         * UIProcess/API/gtk/DragSource.h: Added.
2402         * UIProcess/API/gtk/DragSourceGtk3.cpp: Added.
2403         (WebKit::DragSource::DragSource):
2404         (WebKit::DragSource::~DragSource):
2405         (WebKit::DragSource::begin):
2406         * UIProcess/API/gtk/DropTarget.h: Added.
2407         * UIProcess/API/gtk/DropTargetGtk3.cpp: Added.
2408         (WebKit::DropTarget::DropTarget):
2409         (WebKit::DropTarget::~DropTarget):
2410         (WebKit::DropTarget::accept):
2411         (WebKit::DropTarget::enter):
2412         (WebKit::DropTarget::update):
2413         (WebKit::DropTarget::dataReceived):
2414         (WebKit::DropTarget::didPerformAction):
2415         (WebKit::DropTarget::leaveTimerFired):
2416         (WebKit::DropTarget::leave):
2417         (WebKit::DropTarget::drop):
2418         * UIProcess/API/gtk/PageClientImpl.cpp:
2419         (WebKit::PageClientImpl::startDrag):
2420         (WebKit::PageClientImpl::didPerformDragControllerAction):
2421         * UIProcess/API/gtk/PageClientImpl.h:
2422         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
2423         (webkitWebViewBaseConstructed):
2424         (webkit_web_view_base_class_init):
2425         (webkitWebViewBaseStartDrag):
2426         (webkitWebViewBaseDidPerformDragControllerAction):
2427         * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
2428         * UIProcess/PageClient.h:
2429         (WebKit::PageClient::didPerformDragControllerAction):
2430         * UIProcess/WebPageProxy.cpp:
2431         (WebKit::WebPageProxy::didPerformDragControllerAction):
2432         * UIProcess/gtk/DragAndDropHandler.cpp: Removed.
2433         * WebProcess/WebPage/WebPage.cpp:
2434         (WebKit::WebPage::performDragControllerAction):
2435         * WebProcess/WebPage/gtk/WebPageGtk.cpp:
2436
2437 2020-05-12  Jacob Uphoff  <jacob_uphoff@apple.com>
2438
2439         Unreviewed, reverting r261557.
2440
2441         This commit caused testing to exit early due to too many
2442         crashes on macOS Catalina Asan
2443
2444         Reverted changeset:
2445
2446         "Allow WebAudioBufferList to dynamically change its number of
2447         frames"
2448         https://bugs.webkit.org/show_bug.cgi?id=211720
2449         https://trac.webkit.org/changeset/261557
2450
2451 2020-05-12  Per Arne Vollan  <pvollan@apple.com>
2452
2453         Unreviewed crash fix.
2454
2455         Use correct global name for icon service in RELEASE_ASSERT.
2456
2457         * WebProcess/WebPage/WebPage.cpp:
2458         (WebKit::WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
2459
2460 2020-05-12  Youenn Fablet  <youenn@apple.com>
2461
2462         Allow WebAudioBufferList to dynamically change its number of frames
2463         https://bugs.webkit.org/show_bug.cgi?id=211720
2464
2465         Reviewed by Eric Carlson.
2466
2467         * WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
2468         (WebKit::RemoteCaptureSampleManager::RemoteAudio::setStorage):
2469         (WebKit::RemoteCaptureSampleManager::RemoteAudio::audioSamplesAvailable):
2470         * WebProcess/cocoa/RemoteCaptureSampleManager.h:
2471
2472 2020-05-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2473
2474         [GTK4] Add support for clipboard operations
2475         https://bugs.webkit.org/show_bug.cgi?id=211561
2476
2477         Reviewed by Adrian Perez de Castro.
2478
2479         * UIProcess/gtk/Clipboard.h:
2480         * UIProcess/gtk/ClipboardGtk4.cpp:
2481         (WebKit::Clipboard::Clipboard):
2482         (WebKit::Clipboard::type const):
2483         (WebKit::Clipboard::formats):
2484         (WebKit::ReadTextAsyncData::ReadTextAsyncData):
2485         (WebKit::Clipboard::readText):
2486         (WebKit::ReadFilePathsAsyncData::ReadFilePathsAsyncData):
2487         (WebKit::Clipboard::readFilePaths):
2488         (WebKit::ReadBufferAsyncData::ReadBufferAsyncData):
2489         (WebKit::Clipboard::readBuffer):
2490         (WebKit::Clipboard::write):
2491         (WebKit::Clipboard::clear):
2492
2493 2020-05-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2494
2495         [GTK] Rework clipboard handling in preparation for GTK4
2496         https://bugs.webkit.org/show_bug.cgi?id=211511
2497
2498         Reviewed by Adrian Perez de Castro.
2499
2500         Use async APIs to avoid blocking the UI process during the communication with the clipboard. In GTK4 only async
2501         APIs are available. Add Clipboard class to handle the communication with the clipboard with the GTK
2502         implementation in ClipboardGtk3 and ClipboardGtk4 files.
2503
2504         * Shared/gtk/WebSelectionData.cpp:
2505         (WebKit::WebSelectionData::WebSelectionData): Add constructor receivnig an rvalue reference.
2506         * Shared/gtk/WebSelectionData.h:
2507         * SourcesGTK.txt:
2508         * UIProcess/WebPasteboardProxy.h:
2509         * UIProcess/WebPasteboardProxy.messages.in:
2510         * UIProcess/gtk/Clipboard.cpp: Added.
2511         (WebKit::clipboard):
2512         (WebKit::primary):
2513         (WebKit::Clipboard::get):
2514         * UIProcess/gtk/Clipboard.h: Added.
2515         * UIProcess/gtk/ClipboardGtk3.cpp: Added.
2516         (WebKit::Clipboard::Clipboard):
2517         (WebKit::isPrimaryClipboard):
2518         (WebKit::Clipboard::type const):
2519         (WebKit::FormatsAsyncData::FormatsAsyncData):
2520         (WebKit::Clipboard::formats):
2521         (WebKit::ReadTextAsyncData::ReadTextAsyncData):
2522         (WebKit::Clipboard::readText):
2523         (WebKit::ReadFilePathsAsyncData::ReadFilePathsAsyncData):
2524         (WebKit::Clipboard::readFilePaths):
2525         (WebKit::ReadBufferAsyncData::ReadBufferAsyncData):
2526         (WebKit::Clipboard::readBuffer):
2527         (WebKit::Clipboard::write):
2528         (WebKit::Clipboard::clear):
2529         * UIProcess/gtk/ClipboardGtk4.cpp: Added.
2530         (WebKit::Clipboard::Clipboard):
2531         (WebKit::Clipboard::type const):
2532         (WebKit::Clipboard::formats):
2533         (WebKit::Clipboard::readText):
2534         (WebKit::Clipboard::readFilePaths):
2535         (WebKit::Clipboard::readBuffer):
2536         (WebKit::Clipboard::write):
2537         (WebKit::Clipboard::clear):
2538         * UIProcess/gtk/WebPasteboardProxyGtk.cpp:
2539         (WebKit::WebPasteboardProxy::getTypes):
2540         (WebKit::WebPasteboardProxy::readText):
2541         (WebKit::WebPasteboardProxy::readFilePaths):
2542         (WebKit::WebPasteboardProxy::readBuffer):
2543         (WebKit::WebPasteboardProxy::writeToClipboard):
2544         (WebKit::WebPasteboardProxy::clearClipboard):
2545         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
2546         (WebKit::WebPlatformStrategies::types):
2547         (WebKit::WebPlatformStrategies::readTextFromClipboard):
2548         (WebKit::WebPlatformStrategies::readFilePathsFromClipboard):
2549         (WebKit::WebPlatformStrategies::readBufferFromClipboard):
2550         (WebKit::WebPlatformStrategies::writeToClipboard):
2551         (WebKit::WebPlatformStrategies::clearClipboard):
2552         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
2553
2554 2020-05-12  Youenn Fablet  <youenn@apple.com>
2555
2556         Introduce a RealtimeMediaSource video sample observer
2557         https://bugs.webkit.org/show_bug.cgi?id=211718
2558
2559         Reviewed by Eric Carlson.
2560
2561         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
2562         (WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy):
2563         (WebKit::UserMediaCaptureManagerProxy::SourceProxy::~SourceProxy):
2564         * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
2565         (WebKit::MediaRecorderPrivate::MediaRecorderPrivate):
2566         (WebKit::MediaRecorderPrivate::~MediaRecorderPrivate):
2567         (WebKit::MediaRecorderPrivate::videoSampleAvailable):
2568         (WebKit::MediaRecorderPrivate::stopRecording):
2569         (WebKit::MediaRecorderPrivate::sampleBufferUpdated): Deleted.
2570         * WebProcess/GPU/webrtc/MediaRecorderPrivate.h:
2571
2572 2020-05-12  Mark Lam  <mark.lam@apple.com>
2573
2574         Wasm::enableFastMemory() was called too late.
2575         https://bugs.webkit.org/show_bug.cgi?id=211773
2576
2577         Reviewed by Yusuke Suzuki.
2578
2579         Previously, we were calling Wasm::enableFastMemory() in WebProcess::initializeWebProcess().
2580         By then, it is too late because the JSC::Config and WTF::Config have already been
2581         frozen.  There is nothing special about Wasm::enableFastMemory() that it needs to
2582         be called this late.  This patch moves it into JSC::initializeThreading() where
2583         it belongs.
2584
2585         This change also make the initialization of Wasm fast memory consistent with how
2586         we have always done it for the jsc shell i.e. it is initialized at the end of
2587         JSC::initializeThreading().
2588
2589         * WebProcess/WebProcess.cpp:
2590         (WebKit::WebProcess::initializeWebProcess):
2591
2592 2020-05-11  Darin Adler  <darin@apple.com>
2593
2594         Fix problems caught by replacing WTF::Optional with std::optional
2595         https://bugs.webkit.org/show_bug.cgi?id=211703
2596
2597         Reviewed by Chris Dumez.
2598
2599         * WebProcess/WebPage/ios/WebPageIOS.mm:
2600         (WebKit::plainTextForContext): Clarified ambiguous overload resolution by writing
2601         the conversion from a live range to a SimpleRange out explicitly. Also fixed a typo
2602         where there was a missing "&" in a "const&" argument.
2603
2604 2020-05-11  Simon Fraser  <simon.fraser@apple.com>
2605
2606         [ macOS ] scrollingcoordinator/mac/latching/scrolling-select-should-not-latch-mainframe.html is a flaky failure
2607         https://bugs.webkit.org/show_bug.cgi?id=211747
2608
2609         Reviewed by Tim Horton.
2610
2611         Add an option to monitorWheelEvents to reset latching.
2612
2613         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
2614         (WKBundlePageStartMonitoringScrollOperations):
2615         * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
2616
2617 2020-05-11  Kate Cheney  <katherine_cheney@apple.com>
2618
2619         Fail navigations to non app-bound domains after use of app-bound APIs
2620         https://bugs.webkit.org/show_bug.cgi?id=211647
2621         <rdar://problem/62978159>
2622
2623         Reviewed by Brent Fulgham.
2624
2625         A lot of this patch is deleting the unnecessary variable/function
2626         hasNavigatedAwayFromAppBoundDomain now that navigating away from an
2627         app-bound domain is not possible.
2628         
2629         To address the bug, this sets the default isNavigatingToAppBoundDomain
2630         value to be WTF::nullopt. This will allow app-bound behaviors until
2631         a navigation has been attempted, in which case it will fail or will
2632         update isNavigatingToAppBoundDomain to the correct value.
2633
2634
2635         * Shared/LoadParameters.cpp:
2636         (WebKit::LoadParameters::encode const):
2637         (WebKit::LoadParameters::decode):
2638         * Shared/LoadParameters.h:
2639         * Shared/PolicyDecision.h:
2640         (WebKit::PolicyDecision::encode const):
2641         (WebKit::PolicyDecision::decode):
2642         * UIProcess/ProvisionalPageProxy.cpp:
2643         (WebKit::ProvisionalPageProxy::loadData):
2644         (WebKit::ProvisionalPageProxy::loadRequest):
2645         (WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionSync):
2646         * UIProcess/ProvisionalPageProxy.h:
2647         * UIProcess/WebPageProxy.cpp:
2648         (WebKit::WebPageProxy::loadRequest):
2649         (WebKit::WebPageProxy::loadRequestWithNavigationShared):
2650         (WebKit::WebPageProxy::loadData):
2651         (WebKit::WebPageProxy::loadDataWithNavigationShared):
2652         (WebKit::WebPageProxy::receivedPolicyDecision):
2653         (WebKit::WebPageProxy::continueNavigationInNewProcess):
2654         (WebKit::WebPageProxy::decidePolicyForNavigationActionSyncShared):
2655         (WebKit::WebPageProxy::hasNavigatedAwayFromAppBoundDomain const): Deleted.
2656         Remove hasNavigatedAwayFromAppBoundDomain.
2657
2658         (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomainAndCheckIfPermitted):
2659         Check for new m_hasExecutedAppBoundBehaviorBeforeNavigation parameter
2660         and fail the navigation if a WebView has used app-bound behavior then
2661         tries to navigate to a non app-bound domain.
2662
2663         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
2664         Update error message to be more general now that more than one error
2665         can occur.
2666
2667         * UIProcess/WebPageProxy.h:
2668         (WebKit::WebPageProxy::setHasExecutedAppBoundBehaviorBeforeNavigation):
2669         * UIProcess/WebPageProxy.messages.in:
2670         New parameter to indicate a WebView has used app-bound APIs before
2671         navigating.
2672
2673         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2674         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
2675         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
2676         (WebKit::WebFrameLoaderClient::shouldEnableInAppBrowserPrivacyProtections):
2677         (WebKit::WebFrameLoaderClient::hasNavigatedAwayFromAppBoundDomain): Deleted.
2678         (WebKit::WebFrameLoaderClient::needsInAppBrowserPrivacyQuirks const): Deleted.
2679         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
2680         Combined two functions into a simpler function:
2681         shouldEnableInAppBrowserPrivacyProtections().
2682
2683         * WebProcess/WebPage/WebPage.cpp:
2684         (WebKit::m_limitsNavigationsToAppBoundDomains):
2685         (WebKit::WebPage::updatePreferences):
2686         Store the special app-bound domain flag to gate the service worker
2687         API. This should be stored separately from
2688         m_isNavigatingToAppBoundDomain, because in the WebPage constructor we
2689         don't yet know whether the WKAppBoundDomains key exists.
2690
2691         (WebKit::WebPage::loadRequest):
2692         (WebKit::WebPage::loadDataImpl):
2693         (WebKit::WebPage::loadData):
2694         (WebKit::WebPage::loadAlternateHTML):
2695         (WebKit::WebPage::didReceivePolicyDecision):
2696         Remove hasNavigatedAwayFromAppBoundDomain.
2697
2698         (WebKit::WebPage::runJavaScript):
2699         (WebKit::WebPage::setIsNavigatingToAppBoundDomain):
2700         (WebKit::WebPage::shouldEnableInAppBrowserPrivacyProtections):
2701         If m_needsInAppBrowserPrivacyQuirks are on for testing, don't enable
2702         protections. Only notify the WebPageProxy of app-bound behavior if
2703         a navigation has not occured and we know the webView is not app-bound
2704         (in order to limit IPC).
2705
2706         (WebKit::m_isNavigatingToAppBoundDomain): Deleted.
2707         * WebProcess/WebPage/WebPage.h:
2708         (WebKit::WebPage::isNavigatingToAppBoundDomain const):
2709         (WebKit::WebPage::setIsNavigatingToAppBoundDomain): Deleted.
2710         (WebKit::WebPage::hasNavigatedAwayFromAppBoundDomain const): Deleted.
2711         (WebKit::WebPage::setHasNavigatedAwayFromAppBoundDomain): Deleted.
2712         (WebKit::WebPage::needsInAppBrowserPrivacyQuirks const): Deleted.
2713
2714 2020-05-11  Wenson Hsieh  <wenson_hsieh@apple.com>
2715
2716         Remove some unnecessary indirection when getting Document’s Editor
2717         https://bugs.webkit.org/show_bug.cgi?id=211744
2718
2719         Reviewed by Geoffrey Garen.
2720
2721         See WebCore ChangeLog for more information. No change in behavior.
2722
2723         * WebProcess/WebPage/ios/WebPageIOS.mm:
2724         (WebKit::WebPage::performActionOnElement):
2725
2726 2020-05-11  Simon Fraser  <simon.fraser@apple.com>
2727
2728         Fix possible crash in ViewGestureController on macOS
2729         https://bugs.webkit.org/show_bug.cgi?id=211745
2730
2731         Reviewed by Tim Horton.
2732
2733         When ViewGestureController::resetState() clears m_swipeCancellationTracker, it should set it to canceled so that
2734         any pending -trackSwipeEventWithOptions:... which is holding a reference to the WKSwipeCancellationTracker knows
2735         to stop.
2736
2737         * UIProcess/mac/ViewGestureControllerMac.mm:
2738         (WebKit::ViewGestureController::resetState):
2739         (WebKit::ViewGestureController::reset):
2740
2741 2020-05-11  Peng Liu  <peng.liu6@apple.com>
2742
2743         Enable the mock video presentation mode in related layout tests and fix test failures
2744         https://bugs.webkit.org/show_bug.cgi?id=211645
2745
2746         Reviewed by Darin Adler.
2747
2748         Fix the mistake in VideoFullscreenManager::supportsVideoFullscreen() introduced in r202274.
2749
2750         * WebProcess/cocoa/VideoFullscreenManager.mm:
2751         (WebKit::VideoFullscreenManager::supportsVideoFullscreen const):
2752
2753 2020-05-11  Per Arne Vollan  <pvollan@apple.com>
2754
2755         [iOS] Update message filtering rules in the WebContent process' sandbox
2756         https://bugs.webkit.org/show_bug.cgi?id=211188
2757         <rdar://problem/60922910>
2758
2759         Reviewed by Brent Fulgham.
2760
2761         Based on telemetry and local testing, update the message filtering rules in the WebContent process' sandbox on iOS.
2762         Messages that have not been observed being in use, should be denied.
2763
2764         No new tests, covered by existing tests.
2765
2766         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
2767
2768 2020-05-11  Chris Dumez  <cdumez@apple.com>
2769
2770         [iOS] WKWebView.evaluateJavaScript should run at foreground priority when app is foreground
2771         https://bugs.webkit.org/show_bug.cgi?id=211734
2772
2773         Reviewed by Darin Adler.
2774
2775         * UIProcess/WebPageProxy.cpp:
2776         (WebKit::WebPageProxy::runJavaScriptInFrameInScriptWorld):
2777
2778 2020-05-11  Wenson Hsieh  <wenson_hsieh@apple.com>
2779
2780         REGRESSION (r253267): issues on touchstart/touchend/touchmove (pointerdown/pointerup/pointermove) events
2781         https://bugs.webkit.org/show_bug.cgi?id=211521
2782         <rdar://problem/62942374>
2783
2784         Reviewed by Darin Adler.
2785
2786         As a brief refresher, deferring gesture recognizers allow us to handle otherwise blocking touch events
2787         asynchronously by having all preventable native gesture recognizers require the deferring gesture recognizer to
2788         fail; we only fail the deferring gesture recognizer once the web process has handled the touch event, and did
2789         not call `preventDefault()`.
2790
2791         These additional failure requirements can cause preventable gestures to be linked together in the same gesture
2792         dependency subgraph; since each subgraph is reset only once all gestures in the subgraph have failed or ended,
2793         this might cause some gestures to be reset after a delay (rather than being reset immediately). To mitigate
2794         this, we divide the set of preventable gestures into multiple (currently, 2) subgraphs: one for gestures that
2795         are reset after a delay, and another for gestures that are immediately resettable. This way, immediately
2796         resettable gestures are able to reset and recognize again, without having to wait for other slower preventable
2797         gesture recognizers to reset.
2798
2799         When fast-clicking is disabled (e.g. when loading a desktop web page on a mobile form factor, or when the
2800         viewport has been zoomed in), the blocking synthetic double tap gesture recognizer (that is, `WKContentView`'s
2801         `_doubleTapGestureRecognizer`) is enabled, and adds itself as a dynamic failure requirement to the content
2802         view's synthetic single tap gesture recognizer (`_singleTapGestureRecognizer`). In terms of the gesture
2803         dependency graph, this causes the single tap gesture to form an edge with the double tap gesture, which ends up
2804         uniting both deferring gesture recognizers under the same subgraph. This means UIWebTouchEventsGestureRecognizer,
2805         which should be one of the gestures in the immediately resettable subgraph, is now connected to the rest of the
2806         delayed resettable gestures, meaning that it cannot recognize until "slowly resettable" gestures such as the
2807         tap-and-half text selection gesture have also been reset. This delay causes touch events to be dropped, as is
2808         the case in this bug.
2809
2810         To fix this, simply quarantine the single tap and double tap gestures inside their own subgraph by introducing a
2811         separate deferring gesture recognizer for them. When fast-clicking is enabled, this does not hinder the ability
2812         for the single tap gesture to fire in rapid succession, since the double tap gesture is disabled (and thus, not
2813         a part of the graph at all). when fast-clicking is disabled, then the double tap gesture will prevent the single
2814         tap gesture from being immediately reset anyways, due to the direct failure requirement between the double and
2815         single tap gesture.
2816
2817         Doing this ensures that no other immediately resettable gesture (`UIWebTouchEventsGestureRecognizer` included)
2818         is accidentally blocked from immediately resetting due to being linked to the delayed resettable gestures by way
2819         of the synthetic single and double tap gestures.
2820
2821         Test: fast/events/touch/ios/tap-and-half-when-viewport-is-not-responsive.html
2822
2823         * UIProcess/ios/WKContentViewInteraction.h:
2824
2825         Add a dedicated deferring gesture recognizer for the synthetic single tap and double tap gesture recognizers.
2826
2827         * UIProcess/ios/WKContentViewInteraction.mm:
2828         (-[WKContentView setUpInteraction]):
2829         (-[WKContentView cleanUpInteraction]):
2830
2831         Use -_deferringGestureRecognizers instead of hard-coding logic for each deferring gesture.
2832
2833         (-[WKContentView _removeDefaultGestureRecognizers]): Ditto.
2834         (-[WKContentView _addDefaultGestureRecognizers]): Ditto.
2835         (-[WKContentView _deferringGestureRecognizers]):
2836
2837         We now have 3 distinct deferring gestures; instead of handling the three deferring gestures individually in
2838         various places in this file, group them all behind a getter that returns an array of deferring gestures, and use
2839         this instead.
2840
2841         (-[WKContentView _doneDeferringNativeGestures:]): Ditto.
2842         (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]): Ditto.
2843         (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
2844
2845         Partition the synthetic single tap and double tap gestures into their own subgraph.
2846
2847 2020-05-11  Per Arne Vollan  <pvollan@apple.com>
2848
2849         Unreviewed, reverting r261296.
2850
2851         Rolling r260769 back in, since this was not causing a
2852         regression.
2853
2854         Reverted changeset:
2855
2856         "Unreviewed, reverting r260769."
2857         https://bugs.webkit.org/show_bug.cgi?id=211578
2858         https://trac.webkit.org/changeset/261296
2859
2860 2020-05-11  Wenson Hsieh  <wenson_hsieh@apple.com>
2861
2862         Unreviewed, fix the watchOS build after r261457
2863
2864         Put -[WKActionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:] behind a USE(UICONTEXTMENU)
2865         compiler guard; currently, it is declared everywhere, but only implemented if ENABLE(DATA_DETECTION) &&
2866         USE(UICONTEXTMENU). However, WKContentView only invokes it behind code that is guarded by USE(UICONTEXTMENU).
2867
2868         * UIProcess/ios/WKActionSheetAssistant.h:
2869         * UIProcess/ios/WKActionSheetAssistant.mm:
2870         (-[WKActionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:]):
2871
2872 2020-05-11  Philippe Normand  <pnormand@igalia.com>
2873
2874         [GTK] Media and audio permission request unit tests are timing out
2875         https://bugs.webkit.org/show_bug.cgi?id=158257
2876
2877         Reviewed by Carlos Garcia Campos.
2878
2879         Add new private API to disable secure capture device contexts.
2880         This is needed for the API tests.
2881
2882         * UIProcess/API/glib/WebKitWebView.cpp:
2883         (webkitWebViewSetMediaCaptureRequiresSecureConnection):
2884         * UIProcess/API/glib/WebKitWebViewPrivate.h:
2885
2886 2020-05-10  Basuke Suzuki  <basuke.suzuki@sony.com>
2887
2888         Add ENABLE_PERIODIC_MEMORY_MONITOR flag.
2889         https://bugs.webkit.org/show_bug.cgi?id=211704
2890
2891         Reviewed by Yusuke Suzuki.
2892
2893         No new tests because there's no behavior change.
2894
2895         Replace PLATFORM() macros with ENABLE() macro.
2896
2897         * WebProcess/WebProcess.cpp:
2898         (WebKit::WebProcess::initializeWebProcess):
2899
2900 2020-05-10  Michael Catanzaro  <mcatanzaro@gnome.org>
2901
2902         REGRESSION(r261270): Broke build with python3
2903         https://bugs.webkit.org/show_bug.cgi?id=211699
2904
2905         Reviewed by Yusuke Suzuki.
2906
2907         Remove the problematic print statement. It causes the script to fail. If fixed, it spams the
2908         build output. We only print messages during the build when there are problems to be fixed.
2909
2910         * Scripts/generate-message-receiver.py:
2911         (main):
2912
2913 2020-05-10  Tim Horton  <timothy_horton@apple.com>
2914
2915         Clicking a tel:// link on iPad with a trackpad presents different UI than tapping on it
2916         https://bugs.webkit.org/show_bug.cgi?id=211686
2917         <rdar://problem/57941589>
2918
2919         Reviewed by Wenson Hsieh.
2920
2921         Previously, iOS WebKit had code in handleTap, handleTwoFingerTapAtPoint, and commitPotentialTap,
2922         which introspected the hit element /before/ dispatching the tap (or synthetic click) to the DOM,
2923         short circuiting all normal event handling machinery in order to prevent the default action
2924         and present the Data Detectors UI for the given link.
2925
2926         There's one immediate problem with this, which is that there is no similar code in the direct
2927         click event handler path, which we now use for trackpad/mouse input on iPad. There's also a
2928         secondary problem (which we have not seen in practice), which is that pages cannot preventDefault
2929         to avoid launching the Data Detectors UI on a link, like they could to prevent an ordinary
2930         link from being followed.
2931
2932         In order to resolve both issues and reduce duplication of logic, move the code that introspects
2933         the element and invokes Data Detectors UI from high-level WebKit event dispatch code (where it
2934         doesn't really belong) down to WebCore's default click event handler for anchors, right next to
2935         the code that would ordinarily cause a navigation. This way, no matter how we get here, whether
2936         by synthetic click or real click, we'll invoke the Data Detectors UI.
2937
2938         One alternative considered at length: we could actually let the navigation happen, and instead
2939         handle the switch in navigation policy code, but there are a few reasons that did not seem ideal:
2940         1) We'd need to plumb platform-specific data structures through a ton of FrameLoader code.
2941         2) Clients often block non-HTTP(S) navigations, so in order to keep the feature functional,
2942            we'd have to disregard the client's policy decision, defeating much of the purpose of making
2943            use of the navigation mechanism in the first place.
2944
2945         * UIProcess/PageClient.h:
2946         * UIProcess/WebPageProxy.h:
2947         * UIProcess/WebPageProxy.messages.in:
2948         * UIProcess/ios/PageClientImplIOS.h:
2949         * UIProcess/ios/PageClientImplIOS.mm:
2950         (WebKit::PageClientImpl::showDataDetectorsUIForPositionInformation):
2951         * UIProcess/ios/WebPageProxyIOS.mm:
2952         (WebKit::WebPageProxy::showDataDetectorsUIForPositionInformation):
2953         * WebProcess/WebCoreSupport/WebChromeClient.h:
2954         * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
2955         (WebKit::WebChromeClient::showDataDetectorsUIForElement):
2956         Plumb showDataDetectorsUIForPositionInformation from iOS WebKit's ChromeClient
2957         implementation all the way to WKContentView.
2958
2959         * UIProcess/ios/WKActionSheetAssistant.h:
2960         * UIProcess/ios/WKActionSheetAssistant.mm:
2961         (-[WKActionSheetAssistant showDataDetectorsUIForPositionInformation:]):
2962         (-[WKActionSheetAssistant contextMenuInteraction:configurationForMenuAtLocation:]):
2963         (-[WKActionSheetAssistant contextMenuInteraction:previewForHighlightingMenuWithConfiguration:]):
2964         (-[WKActionSheetAssistant showDataDetectorsSheet]): Deleted.
2965         Make it possible to push InteractionInformationAtPosition into WKActionSheetAssistant,
2966         instead of having it always pull a fresh one upon invocation, so that we can use the
2967         position information passed along with the showDataDetectorsUIForPositionInformation message.
2968
2969         (-[WKActionSheetAssistant _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]):
2970         (-[WKActionSheetAssistant suggestedActionsForContextMenuWithPositionInformation:]):
2971         Fix an existing bug where Data Detectors context menus would show extra default actions,
2972         by moving our implementation of the -_contextMenuInteraction:overrideSuggestedActionsForConfiguration:
2973         delegate here, sharing it with WKContentViewInteraction.
2974
2975         In a future patch, we should reconsider having three separate UIContextMenuInteractions.
2976
2977         Also, remove the contextMenuPresentationLocationForActionSheetAssistant: delegate,
2978         since it will be wrong in the case of pushed-in position information, and instead
2979         use the position information's original hit test point.
2980
2981         * UIProcess/ios/WKContentViewInteraction.h:
2982         * UIProcess/ios/WKContentViewInteraction.mm:
2983         (-[WKContentView _showDataDetectorsUI]):
2984         (-[WKContentView _showDataDetectorsUIForPositionInformation:]):
2985         (-[WKContentView _actionForLongPressFromPositionInformation:]):
2986         (-[WKContentView _didNotHandleTapAsClick:]):
2987         (-[WKContentView dataDetectionContextForPositionInformation:]):
2988         (-[WKContentView dataDetectionContextForActionSheetAssistant:positionInformation:]):
2989         (-[WKContentView _showDataDetectorsSheet]): Deleted.
2990         (-[WKContentView currentPositionInformation]): Deleted.
2991         (-[WKContentView dataDetectionContextForActionSheetAssistant:]): Deleted.
2992         Instead of exposing an unnecessary -currentPositionInformation getter on WKActionSheetAssistant,
2993         provide it as an argument to the WKActionSheetAssistantDelegate methods that actually need it.
2994
2995         (-[WKContentView contextMenuPresentationLocationForActionSheetAssistant:]): Deleted.
2996         (-[WKContentView _contextMenuInteraction:overrideSuggestedActionsForConfiguration:]):
2997         Adopt WKActionSheetAssistant's suggestedActions mechanism so we can share code.
2998
2999         * UIProcess/ios/WKPDFView.mm:
3000         (-[WKPDFView _showActionSheetForURL:atLocation:withAnnotationRect:]):
3001         (-[WKPDFView dataDetectionContextForActionSheetAssistant:positionInformation:]):
3002         (-[WKPDFView dataDetectionContextForActionSheetAssistant:]): Deleted.
3003         Adapt to some WKActionSheetAssistantDelegate changes.
3004
3005         * WebProcess/WebPage/WebPage.h:
3006         * WebProcess/WebPage/ios/WebPageIOS.mm:
3007         (WebKit::WebPage::handleTap):
3008         (WebKit::WebPage::handleTwoFingerTapAtPoint):
3009         (WebKit::WebPage::commitPotentialTap):
3010         Remove the aforementioned short-circuiting paths for Data Detectors links.
3011 2020-05-09  David Kilzer  <ddkilzer@apple.com>
3012
3013         Attempt #2 to fix internal iOS build
3014
3015         * UIProcess/ios/WKMouseGestureRecognizer.mm:
3016         - Use ALLOW_DEPRECATED_IMPLEMENTATIONS_{BEGIN,END}.
3017
3018 2020-05-09  David Kilzer  <ddkilzer@apple.com>
3019
3020         Attemp to fix internal iOS build
3021
3022         * Platform/spi/ios/UIKitSPI.h:
3023         - Define @class UIHoverEvent using header if available, else
3024           fall back to local class definition.
3025         - Define methods separately from class definition.
3026         * UIProcess/ios/WKMouseGestureRecognizer.mm:
3027         (-[WKMouseGestureRecognizer setView:]):
3028         - Use new method if it is available.
3029
3030 2020-05-09  Commit Queue  <commit-queue@webkit.org>
3031
3032         Unreviewed, reverting r261389.
3033         https://bugs.webkit.org/show_bug.cgi?id=211678
3034
3035         Introduced page loading regression. (Requested by perarne on
3036         #webkit).
3037
3038         Reverted changeset:
3039
3040         "[iOS] Update message filtering rules in the WebContent
3041         process' sandbox"
3042         https://bugs.webkit.org/show_bug.cgi?id=211188
3043         https://trac.webkit.org/changeset/261389
3044
3045 2020-05-09  David Kilzer  <ddkilzer@apple.com>
3046
3047         Adapt LocalCurrentGraphicsContext for iOS
3048         <https://webkit.org/b/211660>
3049
3050         Reviewed by Darin Adler.
3051
3052         * UIProcess/Cocoa/WebPageProxyCocoa.mm:
3053         (WebKit::convertPlatformImageToBitmap):
3054         - Use LocalCurrentGraphicsContext for both iOS and Mac code
3055           paths.
3056
3057         * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
3058         - Switch from PLATFORM(MAC) and PLATFORM(IOS_FAMIY) to
3059           USE(APPKIT) to separate platform code.
3060         (WebKit::convertDragImageToBitmap):
3061         (WebKit::convertImageToBitmap): Delete.
3062         (WebKit::convertCGImageToBitmap): Delete.
3063         - Combine Mac-specific convertImageToBitmap() and iOS-specific
3064           convertCGImageToBitmap() into a single method using DragImage
3065           type and special-casing one line of code.
3066         (WebKit::WebDragClient::startDrag):
3067         (WebKit::WebDragClient::didConcludeEditDrag):
3068         - Combine iOS and Mac methods into a singe method.
3069
3070 2020-05-09  David Quesada  <david_quesada@apple.com>
3071
3072         Remove HAVE_UI_SCROLL_VIEW_INDICATOR_FLASHING_SPI
3073         https://bugs.webkit.org/show_bug.cgi?id=211662
3074         rdar://problem/63048713
3075
3076         Reviewed by Darin Adler.
3077
3078         Remove this platform conditional and unconditionally use -[UIScrolView _flashScrollIndicatorsForAxes:
3079         persistingPreviousFlashes:]. All supported platforms with UIScrollView have this SPI, and the conditional
3080         was excluding Mac Catalyst, making WKKeyboardScrollViewAnimator send a message to its scroll view that
3081         is no longer implemented.
3082
3083         * Platform/spi/ios/UIKitSPI.h:
3084             Remove the declaration of the now unused -_flashScrollIndicatorsPersistingPreviousFlashes:.
3085         * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
3086         (axesForDelta):
3087         (-[WKKeyboardScrollViewAnimator scrollToContentOffset:animated:]):
3088
3089 2020-05-08  David Kilzer  <ddkilzer@apple.com>
3090
3091         Remove empty directories from from svn.webkit.org repository
3092         <https://webkit.org/b/211644>
3093
3094         Reviewed by Darin Adler.
3095
3096         * UIProcess/API/win: Removed.
3097
3098 2020-05-08  Chris Dumez  <cdumez@apple.com>
3099
3100         Regression(r210945): No attachment when sharing to mail
3101         https://bugs.webkit.org/show_bug.cgi?id=211651
3102         <rdar://problem/63040170>
3103
3104         Reviewed by Tim Horton.
3105
3106         When failing to determine foreground state, the code before r210945 was assuming
3107         'foreground', while the code in r210945 assume 'background'. This causes things
3108         to not render properly when we fail to determine the foreground state.
3109
3110         This patch merely restores pre-r210945 behavior. I will investigate why we are
3111         unable to determinate the host application PID for the MailCompositionService.
3112
3113         * UIProcess/ApplicationStateTracker.mm:
3114         (WebKit::isApplicationForeground):
3115
3116 2020-05-08  Nikos Mouchtaris  <nmouchtaris@apple.com>
3117
3118         Implement web-share v2 for files
3119         https://bugs.webkit.org/show_bug.cgi?id=209265
3120
3121         Reviewed by Andy Estes.
3122
3123         Added support for passing file objects over IPC and
3124         sharing of files to share sheet.
3125
3126         * Shared/WebCoreArgumentCoders.cpp:
3127         (IPC::ArgumentCoder<Vector<RawFile>>::encode):
3128         (IPC::ArgumentCoder<Vector<RawFile>>::decode):
3129         (IPC::ArgumentCoder<ShareDataWithParsedURL>::encode):
3130         (IPC::ArgumentCoder<ShareDataWithParsedURL>::decode):
3131         * Shared/WebCoreArgumentCoders.h:
3132         * UIProcess/Cocoa/ShareableFileWrite.h: Added.
3133         * UIProcess/Cocoa/ShareableFileWrite.mm: Added.
3134         (+[WKShareableFileWrite getSharingDirectoryPath]):
3135         (+[WKShareableFileWrite getFileDirectoryForSharing]):
3136         (+[WKShareableFileWrite removeFileDirectoryForSharing]):
3137         (+[WKShareableFileWrite setQuarantineInformationForFilePath:]):
3138         (+[WKShareableFileWrite applyQuarantineSandboxAndDownloadFlagsToFileAtPath:]):
3139         (+[WKShareableFileWrite createFilename:]):
3140         (+[WKShareableFileWrite writeFileToShareableURL:data:]):
3141         * UIProcess/Cocoa/WKShareSheet.mm:
3142         (-[WKShareSheet presentWithParameters:inRect:completionHandler:]):
3143         (-[WKShareSheet _didCompleteWithSuccess:]):
3144         * WebKit.xcodeproj/project.pbxproj:
3145
3146 2020-05-08  Brent Fulgham  <bfulgham@apple.com>
3147
3148         Revise sandbox to stop logging some commonly-used properties 
3149         https://bugs.webkit.org/show_bug.cgi?id=211636
3150         <rdar://problem/63014244>
3151
3152         Reviewed by Per Arne Vollan.
3153
3154         Further living on and testing has shown a handful of sysctl entries that are in regular use, and do not need
3155         to be logged or considered for removal. This patch has no change in behavior, just reduces logging.
3156
3157         * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
3158         * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb:
3159
3160 2020-05-08  Chris Dumez  <cdumez@apple.com>
3161
3162         Make WKWebViewConfiguration._alwaysRunsAtForegroundPriority an alias for _clientNavigationsRunAtForegroundPriority
3163         https://bugs.webkit.org/show_bug.cgi?id=211632
3164
3165         Reviewed by Darin Adler.
3166
3167         Make WKWebViewConfiguration._alwaysRunsAtForegroundPriority an alias for _clientNavigationsRunAtForegroundPriority.
3168         _alwaysRunsAtForegroundPriority is a frequent source of process assertion leaks that get blamed on WebKit. Clients
3169         are using this in order to be able to do loads in background views so _clientNavigationsRunAtForegroundPriority
3170         should suffice and is not leak prone since the process assertion is released after the navigation has completed.
3171
3172         * UIProcess/API/APIPageConfiguration.cpp:
3173         (API::PageConfiguration::copy const):
3174         * UIProcess/API/APIPageConfiguration.h:
3175         (API::PageConfiguration::alwaysRunsAtForegroundPriority const): Deleted.
3176         (API::PageConfiguration::setAlwaysRunsAtForegroundPriority): Deleted.
3177         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
3178         (-[WKWebViewConfiguration _alwaysRunsAtForegroundPriority]):
3179         (-[WKWebViewConfiguration _setAlwaysRunsAtForegroundPriority:]):
3180         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
3181         * UIProcess/WebPageProxy.cpp:
3182         (WebKit::WebPageProxy::close):
3183         (WebKit::WebPageProxy::updateThrottleState):
3184         (WebKit::WebPageProxy::resetStateAfterProcessExited):
3185         * UIProcess/WebPageProxy.h:
3186
3187 2020-05-08  Alex Christensen  <achristensen@webkit.org>
3188
3189         Revert r260390
3190         https://bugs.webkit.org/show_bug.cgi?id=210759
3191         <rdar://problem/62608140>
3192
3193         r260390 was intended to stop hitting some assertions in ~PendingFrameLoad, but it seems to have caused a regression.
3194         Reverting it and removing the invalid assertions.
3195
3196         * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
3197         (WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::~PendingFrameLoad):
3198         (WebKit::NetworkCache::SpeculativeLoadManager::~SpeculativeLoadManager):
3199
3200 2020-05-08  Wenson Hsieh  <wenson_hsieh@apple.com>
3201
3202         [iOS] caret appears in the middle of a search field when field is focused on agoda.com
3203         https://bugs.webkit.org/show_bug.cgi?id=211591
3204         <rdar://problem/60605873>
3205
3206         Reviewed by Antoine Quint.
3207
3208         The main search field on the mobile version of this website begins offscreen, with a CSS transform that moves it
3209         to the far right; tapping the button element that (visually) has a search-field-like appearance on the front
3210         page programmatically focuses the real offscreen search field, and animates it onscreen by changing the CSS
3211         transform attribute to remove the x-axis translation.
3212
3213         On iOS, the caret rect is computed and sent to the UI process via editor state updates; however, the editor
3214         state is computed immediately after focusing the input field. As such, the caret rect at this moment is computed
3215         in the middle of the animation, leaving it stuck in an unpredictable location.
3216
3217         To fix this, add plumbing to call into the WebKit client layer when an animation has ended. On iOS, if the
3218         selection is visible (i.e. a ranged selection, or editable caret), then check to see whether the element that
3219         has finished animating contains either endpoint of the selection. If so, then schedule a followup editor state
3220         update to push updated selection information to the UI process.
3221
3222         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
3223         (WebKit::WebChromeClient::animationDidFinishForElement):
3224         * WebProcess/WebCoreSupport/WebChromeClient.h:
3225
3226         Add a new client hook for when animations end.
3227
3228         * WebProcess/WebPage/WebPage.cpp:
3229         (WebKit::WebPage::animationDidFinishForElement):
3230         * WebProcess/WebPage/WebPage.h:
3231         * WebProcess/WebPage/ios/WebPageIOS.mm:
3232
3233         Add logic to schedule a new editor state update if needed, after an animation ends that might affect either
3234         the start or end of the selection.
3235
3236         (WebKit::WebPage::animationDidFinishForElement):
3237
3238 2020-05-08  David Kilzer  <ddkilzer@apple.com>
3239
3240         REGRESSION (r260228): Linker warning about limitsNavigationsToAppBoundDomains property overriding instance methods from class
3241         <https://webkit.org/b/211393>
3242
3243         Reviewed by Brent Fulgham.
3244
3245         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
3246         (-[WKWebViewConfiguration limitsNavigationsToAppBoundDomains]):
3247         (-[WKWebViewConfiguration setLimitsNavigationsToAppBoundDomains:]):
3248         - Move from WKPrivate category to main category to fix linker
3249           warnings.
3250
3251 2020-05-08  Chris Dumez  <cdumez@apple.com>
3252
3253         REGRESSION(r259209) Webview's pending URL is null after restoring session state
3254         https://bugs.webkit.org/show_bug.cgi?id=211626
3255         <rdar://problem/62992262>
3256
3257         Reviewed by Alex Christensen.
3258
3259         The issue was that WebPageProxy::goToBackForwardItem() would behave differently whether
3260         the page has a running process or not. In particular, when the page did not have a
3261         running process, goToBackForwardItem() would return early and call launchProcessWithItem()
3262         instead. Unlike goToBackForwardItem(), launchProcessWithItem() would fail to set the
3263         pending API request.
3264
3265         To address the issue, I am getting rid of launchProcessWithItem() and merging its logic
3266         into goToBackForwardItem() instead. Both methods shared a lot of code anyway and having
3267         2 separate code paths that may diverge is error prone.
3268
3269         Change is covered by new API test.
3270
3271         * UIProcess/WebPageProxy.cpp:
3272         (WebKit::WebPageProxy::goToBackForwardItem):
3273         (WebKit::WebPageProxy::launchProcessWithItem): Deleted.
3274         * UIProcess/WebPageProxy.h:
3275
3276 2020-05-08  Alex Christensen  <achristensen@webkit.org>
3277
3278         WKWebView.title should be safe browsing warning's title during a safe browsing warning
3279         https://bugs.webkit.org/show_bug.cgi?id=211403
3280
3281         Reviewed by Tim Horton.
3282
3283         Add a new property to PageLoadState, which allows the title to be set underneath it.
3284         That way, once the safe browsing warning is closed, we can update the title to what it would've been,
3285         including any changes that happened while the warning was open.
3286
3287         Covered by an API test.  I also manually verified this fixes rdar://problem/56201982
3288
3289         * UIProcess/PageLoadState.cpp:
3290         (WebKit::PageLoadState::commitChanges):
3291         (WebKit::PageLoadState::reset):
3292         (WebKit::PageLoadState::didCommitLoad):
3293         (WebKit::PageLoadState::title const):
3294         (WebKit::PageLoadState::setTitleFromSafeBrowsingWarning):
3295         * UIProcess/PageLoadState.h:
3296         * UIProcess/WebPageProxy.cpp:
3297         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
3298
3299 2020-05-08  Per Arne Vollan  <pvollan@apple.com>
3300
3301         [iOS] Update message filtering rules in the WebContent process' sandbox
3302         https://bugs.webkit.org/show_bug.cgi?id=211188
3303
3304         Reviewed by Brent Fulgham.
3305
3306         Based on telemetry and local testing, update the message filtering rules in the WebContent process' sandbox on iOS.
3307         Messages that have not been observed being in use should be denied.
3308
3309         No new tests, covered by existing tests.
3310
3311         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
3312
3313 2020-05-08  Chris Dumez  <cdumez@apple.com>
3314
3315         Turn processDidBecomeUnresponsive logging into error logging
3316         https://bugs.webkit.org/show_bug.cgi?id=211629
3317
3318         Reviewed by Youenn Fablet.
3319
3320         * UIProcess/WebPageProxy.cpp:
3321         (WebKit::WebPageProxy::processDidBecomeUnresponsive):
3322
3323 2020-05-08  Per Arne Vollan  <pvollan@apple.com>
3324
3325         [Cocoa] Close connections to Launch Services after revoking extension
3326         https://bugs.webkit.org/show_bug.cgi?id=211594
3327
3328         Reviewed by Brent Fulgham.
3329
3330         In <https://trac.webkit.org/changeset/258915/webkit>, connections to the Launch Services database mapping
3331         services were denied, by creating a temporary extension. After revoking this extension in the WebContent
3332         process, it is important to close any open connections to Launch Services initiated by the mapping.
3333
3334         No new tests, covered by existing UTI/MIME type tests.
3335
3336         * WebProcess/cocoa/WebProcessCocoa.mm:
3337         (WebKit::WebProcess::platformInitializeWebProcess):
3338
3339 2020-05-08  Youenn Fablet  <youenn@apple.com>
3340
3341         Handle remote audio capture IPC messages in a background thread
3342         https://bugs.webkit.org/show_bug.cgi?id=211583
3343
3344         Reviewed by Eric Carlson.
3345
3346         We introduce RemoteCaptureSampleManager which is responsible to get remote capture sample IPC messages and treat them from a background thread.
3347         It is currently used to handle audio capture IPC messages.
3348         We move UserMediaCaptureManager::Source in its own file and rename it to RemoteRealtimeMediaSource.
3349
3350         Covered by existing tests.
3351
3352         * DerivedSources-input.xcfilelist:
3353         * DerivedSources-output.xcfilelist:
3354         * DerivedSources.make:
3355         * PlatformMac.cmake:
3356         * SourcesCocoa.txt:
3357         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
3358         * WebKit.xcodeproj/project.pbxproj:
3359         * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: Added.
3360         (WebKit::RemoteCaptureSampleManager::RemoteCaptureSampleManager):
3361         (WebKit::RemoteCaptureSampleManager::~RemoteCaptureSampleManager):
3362         (WebKit::RemoteCaptureSampleManager::setConnection):
3363         (WebKit::RemoteCaptureSampleManager::addSource):
3364         (WebKit::RemoteCaptureSampleManager::removeSource):
3365         (WebKit::RemoteCaptureSampleManager::dispatchToThread):
3366         (WebKit::RemoteCaptureSampleManager::storageChanged):
3367         (WebKit::RemoteCaptureSampleManager::audioSamplesAvailable):
3368         * WebProcess/cocoa/RemoteCaptureSampleManager.h: Added.
3369         * WebProcess/cocoa/RemoteCaptureSampleManager.messages.in: Added.
3370         * WebProcess/cocoa/RemoteRealtimeMediaSource.cpp: Added.
3371         (WebKit::RemoteRealtimeMediaSource::RemoteRealtimeMediaSource):
3372         (WebKit::RemoteRealtimeMediaSource::~RemoteRealtimeMediaSource):
3373         (WebKit::RemoteRealtimeMediaSource::whenReady):
3374         (WebKit::RemoteRealtimeMediaSource::didFail):
3375         (WebKit::RemoteRealtimeMediaSource::setAsReady):
3376         (WebKit::RemoteRealtimeMediaSource::clone):
3377         (WebKit::RemoteRealtimeMediaSource::setCapabilities):
3378         (WebKit::RemoteRealtimeMediaSource::setSettings):
3379         (WebKit::RemoteRealtimeMediaSource::remoteAudioSamplesAvailable):
3380         (WebKit::RemoteRealtimeMediaSource::remoteVideoSampleAvailable):
3381         (WebKit::RemoteRealtimeMediaSource::connection):
3382         (WebKit::RemoteRealtimeMediaSource::startProducingData):
3383         (WebKit::RemoteRealtimeMediaSource::stopProducingData):
3384         (WebKit::RemoteRealtimeMediaSource::setShouldApplyRotation):
3385         (WebKit::RemoteRealtimeMediaSource::capabilities):
3386         (WebKit::RemoteRealtimeMediaSource::applyConstraints):
3387         (WebKit::RemoteRealtimeMediaSource::applyConstraintsSucceeded):
3388         (WebKit::RemoteRealtimeMediaSource::applyConstraintsFailed):
3389         (WebKit::RemoteRealtimeMediaSource::hasEnded):
3390         (WebKit::RemoteRealtimeMediaSource::stopBeingObserved):
3391         (WebKit::RemoteRealtimeMediaSource::requestToEnd):
3392         * WebProcess/cocoa/RemoteRealtimeMediaSource.h: Added.
3393         (WebKit::RemoteRealtimeMediaSource::identifier const):
3394         (WebKit::RemoteRealtimeMediaSource::settings const):
3395         (WebKit::RemoteRealtimeMediaSource::setShouldCaptureInGPUProcess):
3396         (WebKit::RemoteRealtimeMediaSource::shouldCaptureInGPUProcess const):
3397         * WebProcess/cocoa/UserMediaCaptureManager.cpp:
3398         (WebKit::UserMediaCaptureManager::createCaptureSource):
3399         (WebKit::UserMediaCaptureManager::cloneSource):
3400         (WebKit::UserMediaCaptureManager::cloneVideoSource):
3401         (WebKit::UserMediaCaptureManager::AudioFactory::createAudioCaptureSource):
3402         (WebKit::UserMediaCaptureManager::AudioFactory::setShouldCaptureInGPUProcess):
3403         (WebKit::UserMediaCaptureManager::VideoFactory::createVideoCaptureSource):
3404         (WebKit::UserMediaCaptureManager::DisplayFactory::createDisplayCaptureSource):
3405         * WebProcess/cocoa/UserMediaCaptureManager.h:
3406         * WebProcess/cocoa/UserMediaCaptureManager.messages.in:
3407
3408 2020-05-08  Youenn Fablet  <youenn@apple.com>
3409
3410         Video capture does not get unmuted in case of tab switch on iOS
3411         https://bugs.webkit.org/show_bug.cgi?id=211509
3412
3413         Reviewed by Eric Carlson.
3414
3415         Remove no longer needed code.