45fd9954cee0ca6ae1462a9a51adac48b7bed209
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2019-02-21  Tim Horton  <timothy_horton@apple.com>
2
3         Crash under RemoteLayerTreePropertyApplier::applyProperties when reattaching to old process
4         https://bugs.webkit.org/show_bug.cgi?id=194845
5         <rdar://problem/47944579>
6
7         Reviewed by Antti Koivisto.
8
9         New test: ProcessSwap.PageOverlayLayerPersistence
10
11         * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
12         (WebKit::RemoteLayerTreeTransaction::LayerProperties::notePropertiesChanged):
13         Keep track of all properties that have ever changed on a layer, so we
14         can re-send them if a layer moves between contexts.
15
16         * WebProcess/WebPage/DrawingArea.cpp:
17         (WebKit::DrawingArea::~DrawingArea):
18         (WebKit::DrawingArea::removeMessageReceiverIfNeeded):
19         * WebProcess/WebPage/DrawingArea.h:
20         (WebKit::DrawingArea::layerHostDidFlushLayers):
21         Make it possible to tear down DrawingArea's MessageReceiver before it is destroyed,
22         so that we can keep two DrawingAreas alive in a single process for a short time.
23
24         (WebKit::DrawingArea::adoptLayersFromDrawingArea):
25         Add adoptLayersFromDrawingArea; see below for its only useful implementation.
26
27         * WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.cpp:
28         (WebKit::GraphicsLayerCARemote::GraphicsLayerCARemote):
29         (WebKit::GraphicsLayerCARemote::~GraphicsLayerCARemote):
30         (WebKit::GraphicsLayerCARemote::createPlatformCALayer):
31         (WebKit::GraphicsLayerCARemote::createPlatformCALayerForEmbeddedView):
32         (WebKit::GraphicsLayerCARemote::moveToContext):
33         * WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.h:
34         Make it possible to move a GraphicsLayerCARemote between RemoteLayerTreeContexts.
35
36         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
37         (WebKit::PlatformCALayerRemote::create):
38         (WebKit::PlatformCALayerRemote::createForEmbeddedView):
39         (WebKit::PlatformCALayerRemote::~PlatformCALayerRemote):
40         (WebKit::PlatformCALayerRemote::moveToContext):
41         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
42         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm:
43         (WebKit::PlatformCALayerRemoteCustom::create):
44         (WebKit::PlatformCALayerRemoteCustom::clone const):
45         Make it possible to move a PlatformCALayerRemote between RemoteLayerTreeContexts.
46
47         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h:
48         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
49         (WebKit::RemoteLayerTreeContext::~RemoteLayerTreeContext):
50         (WebKit::RemoteLayerTreeContext::adoptLayersFromContext):
51         (WebKit::RemoteLayerTreeContext::layerDidEnterContext):
52         (WebKit::RemoteLayerTreeContext::layerWillLeaveContext):
53         (WebKit::RemoteLayerTreeContext::graphicsLayerDidEnterContext):
54         (WebKit::RemoteLayerTreeContext::graphicsLayerWillLeaveContext):
55         (WebKit::RemoteLayerTreeContext::layerWasCreated): Deleted.
56         (WebKit::RemoteLayerTreeContext::layerWillBeDestroyed): Deleted.
57         Keep track of all GraphicsLayerCARemote instances in the context, like we
58         do for PlatformCALayerRemote, so that we can update their context backpointers if needed.
59
60         Also make it possible to move all outstanding layers to a new context.
61
62         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
63         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
64         (WebKit::RemoteLayerTreeDrawingArea::adoptLayersFromDrawingArea):
65         * WebProcess/WebPage/WebPage.cpp:
66         (WebKit::WebPage::reinitializeWebPage):
67         When doing a DrawingArea swap, transition all layers from the old context
68         to the new one. In order to do this, we temporarily keep both DrawingAreas
69         alive, but make use of the new mechanism to remove the old one's MessageReceiver
70         before installing the new one, so that destroying the old one later doesn't
71         remove it (avoiding re-introducing bug 189481).
72
73 2019-02-21  Chris Dumez  <cdumez@apple.com>
74
75         Unreviewed API test fix after r241855.
76
77         * UIProcess/WebProcessProxy.cpp:
78         (WebKit::WebProcessProxy::~WebProcessProxy):
79
80 2019-02-21  Antoine Quint  <graouts@apple.com>
81
82         Move UIWebTouchEventsGestureRecognizer.activeTouchesByIdentifier to SPI
83         https://bugs.webkit.org/show_bug.cgi?id=194531
84         <rdar://problem/47714562>
85
86         Reviewed by Dean Jackson.
87
88         * Platform/spi/ios/UIKitSPI.h:
89         * UIProcess/ios/WKContentViewInteraction.mm:
90         (-[WKContentView cancelPointersForGestureRecognizer:]): We update the referenced Radar since we need to keep the call
91         to respondsToSelector until the SPI has shipped for OpenSource builds to work.
92
93 2019-02-20  Antti Koivisto  <antti@apple.com>
94
95         Make programmatic frame scrolling work on iOS
96         https://bugs.webkit.org/show_bug.cgi?id=194886
97
98         Reviewed by Simon Fraser.
99
100         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
101         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren):
102
103         Don't move based on the layout scroll position. This just overrides the user scroll position.
104         Remove ScrolledContentsLayer checks, we only need to deal with the ScrollContainerLayer here.
105
106         (WebKit::ScrollingTreeScrollingNodeDelegateIOS::setScrollLayerPosition):
107
108         Scroll the UIScrollView correctly. This is called as a result of setting the RequestedScrollPosition property.
109         Remove scroll origin code, it doesn't look correct (and is untested).
110
111 2019-02-20  Chris Dumez  <cdumez@apple.com>
112
113         [PSON] Make sure hung processes are not kept alive by suspended pages or process caching
114         https://bugs.webkit.org/show_bug.cgi?id=194881
115         <rdar://problem/48249014>
116
117         Reviewed by Geoffrey Garen.
118
119         After we construct a SuspendedPageProxy and before we send the IPC to the WebProcess to
120         ask it to suspend, start a 10 seconds timer. If the process does not answer the request
121         to suspend before the timer fires, we destroy the SuspendedPageProxy so that we do not
122         keep a hung process around.
123
124         For the WebProcessCache, we now call WebProcessProxy::isResponsive() on the process
125         before adding it to the cache. Internally, this relies on an IPC handshake with the
126         WebProcess. If the process is not responsive, we do not add it to the cache and we
127         shut it down. If it is responsive then we proceed normally with adding it to the
128         cache.
129
130         * UIProcess/SuspendedPageProxy.cpp:
131         (WebKit::SuspendedPageProxy::SuspendedPageProxy):
132         (WebKit::SuspendedPageProxy::didProcessRequestToSuspend):
133         (WebKit::SuspendedPageProxy::suspensionTimedOut):
134         * UIProcess/SuspendedPageProxy.h:
135         * UIProcess/WebProcessCache.cpp:
136         (WebKit::WebProcessCache::addProcessIfPossible):
137         (WebKit::WebProcessCache::addProcess):
138         * UIProcess/WebProcessCache.h:
139         * UIProcess/WebProcessProxy.cpp:
140         (WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
141         (WebKit::WebProcessProxy::maybeShutDown):
142         (WebKit::WebProcessProxy::isResponsive):
143         * UIProcess/WebProcessProxy.h:
144
145 2019-02-20  Chris Dumez  <cdumez@apple.com>
146
147         Unreviewed build fix after r241823.
148
149         * UIProcess/SuspendedPageProxy.h:
150
151 2019-02-20  Alex Christensen  <achristensen@webkit.org>
152
153         Unreviewed, rolling out r241838.
154
155         Broke API tests
156
157         Reverted changeset:
158
159         "Resolve WebsiteDataStore/HTTPCookieStore ref cycle"
160         https://bugs.webkit.org/show_bug.cgi?id=194868
161         https://trac.webkit.org/changeset/241838
162
163 2019-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
164
165         REGRESSION: [ iOS ] Layout Test editing/input/ios/rtl-keyboard-input-on-focus.html is a Timeout
166         https://bugs.webkit.org/show_bug.cgi?id=194601
167         <rdar://problem/48080316>
168
169         Reviewed by Tim Horton.
170
171         Following r241311, if a web view becomes first responder and is then moved offscreen (or obscured, hidden, or in
172         the case of WebKitTestRunner, its UIWindow loses its status as keyWindow), we end up holding on to the input
173         view update deferral token indefinitely, waiting for the current focused element to be blurred or refocused.
174
175         This also manifests other user-facing bugs, the most common of which is the keyboard occasionally remaining
176         onscreen after typing a URL in the unified field in MobileSafari and hitting Return, in the case where there is
177         no autofocused element on the page.
178
179         To fix this, when becoming the first responder, additionally install a callback to detect when the page is
180         finished handling the activity state change, and invalidate the input deferral token then. This retains the
181         behavior where calling -becomeFirstResponder on the web view while a different view is focused will keep the
182         keyboard stable, since the focused element message from the web process should be dispatched when handling the
183         activity state change within the web process.
184
185         Of course, the web process may not be responsive at all while the web view is still in the view hierarchy, in
186         which case we may still end up deferring input view updates indefinitely. In this case, we maintain a separate
187         watchdog timer with a short delay, after which we unconditionally invalidate the token.
188
189         * UIProcess/WebPageProxy.cpp:
190         (WebKit::WebPageProxy::installActivityStateChangeCompletionHandler):
191
192         Move the implementation of installActivityStateChangeCompletionHandler into cross-platform code.
193
194         * UIProcess/WebPageProxy.h:
195         * UIProcess/ios/WKContentView.mm:
196         * UIProcess/ios/WKContentViewInteraction.mm:
197         (-[WKContentView cleanupInteraction]):
198         (-[WKContentView _cancelPreviousResetInputViewDeferralRequest]):
199         (-[WKContentView _scheduleResetInputViewDeferralAfterBecomingFirstResponder]):
200         (-[WKContentView _resetInputViewDeferral]):
201         (-[WKContentView becomeFirstResponderForWebView]):
202         (-[WKContentView resignFirstResponderForWebView]):
203         (-[WKContentView _commitPotentialTapFailed]):
204         (-[WKContentView _didNotHandleTapAsClick:]):
205         (-[WKContentView _didCompleteSyntheticClick]):
206
207         Funnel all existing calls that reset _inputViewDeferralToken to nullptr, such that they go through a helper
208         method instead that also cancels any scheduled requests to clear the token.
209
210         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
211         (WebKit::RemoteLayerTreeDrawingArea::activityStateDidChange):
212
213         Respond to all pending callbacks after handling the activity state change.
214
215 2019-02-20  Chris Dumez  <cdumez@apple.com>
216
217         Regression(PSON) "Reload without content extensions" does not work when the main resource is blocked
218         https://bugs.webkit.org/show_bug.cgi?id=194872
219         <rdar://problem/47924500>
220
221         Reviewed by Alex Christensen.
222
223         [WKWebView _reloadWithoutContentBlockers] relies on a ReloadOption flag that is passed to WebCore
224         instead of using WebsitePolicies.contentBlockersEnabled flag. If the reload causes a process swap
225         due to PSON, then the new process does not know about this ReloadOption and fails to honor it.
226
227         Since the modern way to do this is WebsitePolicies, and since WebsitePolicies are properly
228         propagated cross-process in case of process swap, this patch updates _reloadWithoutContentBlockers
229         to set a flag on the Navigation which we use to later set the WebsitePolicies.contentBlockersEnabled
230         flag in WebPageProxy::receivedNavigationPolicyDecision().
231
232         * UIProcess/API/APINavigation.h:
233         (API::Navigation::setUserContentExtensionsEnabled):
234         (API::Navigation::userContentExtensionsEnabled const):
235         * UIProcess/WebPageProxy.cpp:
236         (WebKit::WebPageProxy::reload):
237         (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
238
239 2019-02-20  Truitt Savell  <tsavell@apple.com>
240
241         Unreviewed, rolling out r241817.
242
243         Caused 4 API failures
244
245         Reverted changeset:
246
247         "[GTK] Epiphany searching for plugins even if plugins are
248         disabled"
249         https://bugs.webkit.org/show_bug.cgi?id=194352
250         https://trac.webkit.org/changeset/241817
251
252 2019-02-20  Andy Estes  <aestes@apple.com>
253
254         [Xcode] Add SDKVariant.xcconfig to various Xcode projects
255         https://bugs.webkit.org/show_bug.cgi?id=194869
256
257         Rubber-stamped by Jer Noble.
258
259         * WebKit.xcodeproj/project.pbxproj:
260
261 2019-02-20  Alex Christensen  <achristensen@webkit.org>
262
263         Resolve WebsiteDataStore/HTTPCookieStore ref cycle
264         https://bugs.webkit.org/show_bug.cgi?id=194868
265
266         Reviewed by Geoffrey Garen.
267
268         * UIProcess/API/APIHTTPCookieStore.cpp:
269         (API::HTTPCookieStore::HTTPCookieStore):
270         (API::HTTPCookieStore::cookies):
271         (API::HTTPCookieStore::setCookie):
272         (API::HTTPCookieStore::deleteCookie):
273         (API::HTTPCookieStore::registerObserver):
274         (API::HTTPCookieStore::unregisterObserver):
275         (API::HTTPCookieStore::cookieManagerDestroyed):
276         (API::HTTPCookieStore::registerForNewProcessPoolNotifications):
277         (API::HTTPCookieStore::ref const):
278         (API::HTTPCookieStore::deref const):
279         * UIProcess/API/APIHTTPCookieStore.h:
280
281 2019-02-20  Per Arne Vollan  <pvollan@apple.com>
282
283         [iOS] Open sandbox for specific call.
284         https://bugs.webkit.org/show_bug.cgi?id=194860
285         <rdar://problem/48166729>
286
287         Reviewed by Brent Fulgham.
288
289         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
290
291 2019-02-20  Alex Christensen  <achristensen@webkit.org>
292
293         Move API::HTTPCookieStore ownership from API::WebsiteDataStore to WebKit::WebsiteDataStore
294         https://bugs.webkit.org/show_bug.cgi?id=194842
295
296         Reviewed by Geoff Garen.
297
298         We need a way to get from WebKit::WebsiteDataStore to API::HTTPCookieStore.  It can't be done before this.
299         This made an existing reference cycle easier to see, and we should fix it in a followup patch.
300
301         * UIProcess/API/APIWebsiteDataStore.cpp:
302         (API::WebsiteDataStore::httpCookieStore):
303         * UIProcess/API/APIWebsiteDataStore.h:
304         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
305         (WebKit::WebsiteDataStore::cookieStore):
306         * UIProcess/WebsiteData/WebsiteDataStore.h:
307
308 2019-02-20  Chris Dumez  <cdumez@apple.com>
309
310         Regression(PSON) Crash under WebKit::WebPageProxy::decidePolicyForNavigationActionSync
311         https://bugs.webkit.org/show_bug.cgi?id=194857
312         <rdar://problem/47759323>
313
314         Reviewed by Alex Christensen.
315
316         The ProvisionalPageProxy was blindly forwarding the DecidePolicyForNavigationActionSync
317         synchronous IPC to the WebPageProxy, without passing it the process the IPC came from.
318         As a result, WebPageProxy::decidePolicyForNavigationActionSync() would try to look up
319         a WebFrameProxy using the provided frameID from the wrong process and we would end up
320         hitting a RELEASE_ASSERT().
321
322         * UIProcess/ProvisionalPageProxy.cpp:
323         (WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionSync):
324         (WebKit::ProvisionalPageProxy::didReceiveSyncMessage):
325         * UIProcess/ProvisionalPageProxy.h:
326         * UIProcess/WebPageProxy.cpp:
327         (WebKit::WebPageProxy::decidePolicyForNavigationActionSync):
328         (WebKit::WebPageProxy::decidePolicyForNavigationActionSyncShared):
329         * UIProcess/WebPageProxy.h:
330
331 2019-02-20  Don Olmstead  <don.olmstead@sony.com>
332
333         [MSVC] Fix compilation errors with lambdas in Service Workers
334         https://bugs.webkit.org/show_bug.cgi?id=194841
335
336         Reviewed by Alex Christensen.
337
338         * WebProcess/Storage/ServiceWorkerClientFetch.cpp:
339         (WebKit::ServiceWorkerClientFetch::didReceiveRedirectResponse):
340
341 2019-02-20  Carlos Garcia Campos  <cgarcia@igalia.com>
342
343         [GTK] Epiphany searching for plugins even if plugins are disabled
344         https://bugs.webkit.org/show_bug.cgi?id=194352
345
346         Reviewed by Michael Catanzaro.
347
348         Check pluginsEnabled setting before trying to get plugins from UI process.
349
350         * WebProcess/Plugins/WebPluginInfoProvider.cpp:
351         (WebKit::WebPluginInfoProvider::populatePluginCache):
352
353 2019-02-20  Carlos Garcia Campos  <cgarcia@igalia.com>
354
355         [WPE] Send client host fd and library name as web process creation parameters
356         https://bugs.webkit.org/show_bug.cgi?id=194494
357
358         Reviewed by Žan Doberšek.
359
360         Instead of using command line arguments. The code is simpler and we don't need wpe specific code in process
361         launcher glib implementation.
362
363         * Shared/WebProcessCreationParameters.cpp:
364         (WebKit::WebProcessCreationParameters::encode const):
365         (WebKit::WebProcessCreationParameters::decode):
366         * Shared/WebProcessCreationParameters.h:
367         * UIProcess/Launcher/glib/ProcessLauncherGLib.cpp:
368         (WebKit::ProcessLauncher::launchProcess):
369         * UIProcess/glib/WebProcessPoolGLib.cpp:
370         (WebKit::WebProcessPool::platformInitializeWebProcess):
371         * WebProcess/glib/WebProcessGLib.cpp:
372         (WebKit::WebProcess::platformInitializeWebProcess):
373         * WebProcess/wpe/WebProcessMainWPE.cpp:
374
375 2019-02-20  Adrian Perez de Castro  <aperez@igalia.com>
376
377         [WPE][GTK] Enable support for CONTENT_EXTENSIONS
378         https://bugs.webkit.org/show_bug.cgi?id=167941
379
380         Reviewed by Carlos Garcia Campos.
381
382         Adds new API to manage a collection of content extensions on disk (including compilation
383         of new ones) using WebKitUserContentFilterStore; the associated WebKitUserContentFilter
384         type (which represents a compiled content extension); and the functions needed to enable
385         and disable them for a given WebKitUserContentManager.
386
387         The WebKitUserContentFilterStore public API is expressed in abstract terms of "saving"
388         filters into the store (which involves compiling the JSON source rule set); and "loading"
389         them back as main operations. This way we do not disclose to users of the API any detail
390         about compilation, nor how contents are laid out on disk, and the documentation explicitly
391         tells about only using the provided functions to manipulate the on-disk contents. This
392         way we allow ourselves some leeway if the implementation needs changing in the future.
393
394         * PlatformGTK.cmake: Added WebKitUserContentFilterStore.h to the list of public API headers.
395         * PlatformWPE.cmake: Ditto.
396         * SourcesGTK.txt: Added WebKitUserContentFilterStore.cpp
397         * SourcesWPE.txt: Ditto.
398         * UIProcess/API/glib/WebKitError.cpp: Add definition of webkit_user_content_filter_error_quark().
399         * UIProcess/API/glib/WebKitUserContent.cpp: Added WebKitUserContentFilter.
400         (_WebKitUserContentFilter::_WebKitUserContentFilter):
401         (webkit_user_content_filter_ref):
402         (webkit_user_content_filter_unref):
403         (webkit_user_content_filter_get_identifier):
404         (webkitUserContentFilterCreate):
405         (webkitUserContentFilterGetContentRuleList):
406         * UIProcess/API/glib/WebKitUserContentFilterStore.cpp: Added.
407         (toGError): Utility function to convert content extension error codes to GError.
408         (webkit_user_content_filter_store_class_init):
409         (webkit_user_content_filter_store_new):
410         (webkit_user_content_filter_store_get_path):
411         (webkitUserContentFilterStoreSaveBytes): Common function used as final step for all the
412         functions which save (compile) JSON rule sets into the store, to avoid duplicating code.
413         (webkit_user_content_filter_store_save):
414         (webkit_user_content_filter_store_save_finish):
415         (webkit_user_content_filter_store_save_from_file):
416         (webkit_user_content_filter_store_save_from_file_finish):
417         (webkit_user_content_filter_store_remove):
418         (webkit_user_content_filter_store_remove_finish):
419         (webkit_user_content_filter_store_load):
420         (webkit_user_content_filter_store_lookup_finish):
421         (webkit_user_content_filter_store_fetch_identifiers):
422         (webkit_user_content_filter_store_fetch_identifiers_finish):
423         * UIProcess/API/glib/WebKitUserContentManager.cpp: Added definitions for the new API
424         functions to add and remove filters from an user content manager.
425         (webkit_user_content_manager_add_filter):
426         (webkit_user_content_manager_remove_filter):
427         (webkit_user_content_manager_remove_all_filters):
428         * UIProcess/API/glib/WebKitUserContentPrivate.h: Added declarations for
429         webkitUserContentFilterCreate() and webkitUserContentFilterGetContentRuleList().
430         * UIProcess/API/gtk/WebKitAutocleanups.h: Added autocleanups for WebKitUserContentFilter
431         and WebKitUserContentFilterStore.
432         * UIProcess/API/gtk/WebKitError.h: Added declarations for WEBKIT_USER_CONTENT_FILTER_ERROR
433         plus the associated webkit_user_content_filter_error_quark() function and
434         WebKitUserContentFilterErrror enum.
435         * UIProcess/API/gtk/WebKitUserContent.h: Added declarations for WebKitUserContentFilter
436         and its associated functions.
437         * UIProcess/API/gtk/WebKitUserContentFilterStore.h: Added.
438         * UIProcess/API/gtk/WebKitUserContentManager.h: Added declarations for the functions to
439         add and remove filters from the user content manager.
440         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Added new API functions and types to
441         be included in the documentation.
442         * UIProcess/API/gtk/webkit2.h: Added inclusion of WebKitUserContentFilterStore.h
443         * UIProcess/API/wpe/WebKitError.h: Same as for the GTK port header.
444         * UIProcess/API/wpe/WebKitUserContent.h: Same as for the GTK port header.
445         * UIProcess/API/wpe/WebKitUserContentFilterStore.h: Added.
446         * UIProcess/API/wpe/WebKitUserContentManager.h: Same as for the GTK port header.
447         * UIProcess/API/wpe/docs/wpe-0.1-sections.txt: Added new API functions and types to be
448         included in the documentation.
449         * UIProcess/API/wpe/webkit.h: Added inclusion of WebKitUserContentFilterStore.h
450
451 2019-02-19  Antti Koivisto  <antti@apple.com>
452
453         Pass rootContentsLayer to Mac remote layer tree
454         https://bugs.webkit.org/show_bug.cgi?id=194828
455
456         Reviewed by Simon Fraser.
457
458         Make this code path work again.
459
460         * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
461         (ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
462         (ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):
463         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
464         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
465
466 2019-02-19  Alex Christensen  <achristensen@webkit.org>
467
468         Reduce use of LegacySync IPC messages
469         https://bugs.webkit.org/show_bug.cgi?id=194783
470
471         Reviewed by Geoffrey Garen.
472
473         * UIProcess/WebProcessPool.cpp:
474         (WebKit::WebProcessPool::handleSynchronousMessage):
475         * UIProcess/WebProcessPool.h:
476         * UIProcess/WebProcessPool.messages.in:
477         * UIProcess/WebProcessProxy.cpp:
478         (WebKit::WebProcessProxy::getPlugins):
479         (WebKit::WebProcessProxy::shouldTerminate):
480         * UIProcess/WebProcessProxy.h:
481         * UIProcess/WebProcessProxy.messages.in:
482         * WebProcess/Plugins/PluginProcessConnection.cpp:
483         (WebKit::PluginProcessConnection::setException):
484         * WebProcess/Plugins/PluginProcessConnection.h:
485         * WebProcess/Plugins/PluginProcessConnection.messages.in:
486         * WebProcess/Plugins/PluginProxy.cpp:
487         (WebKit::PluginProxy::didCreatePlugin):
488         (WebKit::PluginProxy::didFailToCreatePlugin):
489         (WebKit::PluginProxy::proxiesForURL):
490         (WebKit::PluginProxy::cookiesForURL):
491         (WebKit::PluginProxy::getAuthenticationInfo):
492         (WebKit::PluginProxy::getPluginElementNPObject):
493         (WebKit::PluginProxy::evaluate):
494         (WebKit::PluginProxy::createPluginContainer):
495         * WebProcess/Plugins/PluginProxy.h:
496         * WebProcess/Plugins/PluginProxy.messages.in:
497
498 2019-02-19  Alex Christensen  <achristensen@webkit.org>
499
500         Remove assertion introduced in r229683
501         https://bugs.webkit.org/show_bug.cgi?id=194825
502         <rdar://problem/47628258>
503
504         Reviewed by Geoffrey Garen.
505
506         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
507         (WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
508         If we reach this code and the form's original Document's Frame has been destroyed,
509         we have already been told to submit the form so do so, just like we do if the WebPage
510         has been destroyed.  This is a rare edge case having to do with the timing of Frame
511         destruction and decidePolicyForNavigationAction response, which unfortunately does not
512         reproduce with a test case unless the timing of IPC is just right.
513
514 2019-02-19  Antoine Quint  <graouts@apple.com>
515
516         [iOS] "touch-action: none" should not prevent text selection or tapping on a link
517         https://bugs.webkit.org/show_bug.cgi?id=194812
518         <rdar://problem/47901131>
519
520         Reviewed by Dean Jackson.
521
522         We shouldn't prevent all gestures to be disabled when "touch-action: none" is set and instead follow the same code path we would use should
523         "pan-x", "pan-y" or "pinch-zoom" be used.
524
525         * UIProcess/ios/WKContentViewInteraction.mm:
526         (-[WKContentView _handleTouchActionsForTouchEvent:]):
527
528 2019-02-18  Alex Christensen  <achristensen@webkit.org>
529
530         Revert functional part of r241451
531         https://bugs.webkit.org/show_bug.cgi?id=194510
532
533         * UIProcess/WebPageProxy.cpp:
534         (WebKit::WebPageProxy::didFinishDocumentLoadForFrame):
535         It caused crashes and assertions on Linux and Cocoa without safe browsing, which
536         means it's fundamentally flawed in some way.  The testing piping was fine.
537
538 2019-02-18  Chris Dumez  <cdumez@apple.com>
539
540         REGRESSION (PSON): Can't access optumbank.com from myuhc.com
541         https://bugs.webkit.org/show_bug.cgi?id=194797
542         <rdar://problem/48055151>
543
544         Reviewed by Geoffrey Garen.
545
546         The issue was caused by us mistakenly process-swapping for a same-site server side redirect.
547         The reason we were getting it wrong is because the logic in
548         WebProcessPool::processForNavigationInternal() was expecting page.process() to be the source
549         process and page.pageLoadState().url() to be the source URL. Those assumptions are incorrect
550         when a server-side redirect occurs in a provisional process. In such case, the source process
551         is the ProvisionalPageProxy's process and the source URL is the provisional URL, not the
552         committed one.
553
554         * UIProcess/ProvisionalPageProxy.cpp:
555         (WebKit::ProvisionalPageProxy::didPerformServerRedirect):
556         (WebKit::ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame):
557         (WebKit::ProvisionalPageProxy::didReceiveMessage):
558         * UIProcess/ProvisionalPageProxy.h:
559         Make sure the provisional page forwards IPC related to server-side redirects to the page so
560         that the client gets informed.
561
562         * UIProcess/WebPageProxy.cpp:
563         (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
564         (WebKit::WebPageProxy::didPerformServerRedirect):
565         (WebKit::WebPageProxy::didPerformServerRedirectShared):
566         * UIProcess/WebPageProxy.h:
567         * UIProcess/WebProcessPool.cpp:
568         (WebKit::WebProcessPool::processForNavigation):
569         (WebKit::WebProcessPool::processForNavigationInternal):
570         * UIProcess/WebProcessPool.h:
571
572 2019-02-16  Darin Adler  <darin@apple.com>
573
574         Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.
575         https://bugs.webkit.org/show_bug.cgi?id=194752
576
577         Reviewed by Daniel Bates.
578
579         * Platform/IPC/win/ConnectionWin.cpp:
580         (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of
581         String::format.
582         * Shared/win/WebEventFactory.cpp:
583         (WebKit::keyIdentifierFromEvent): Ditto.
584
585         * UIProcess/API/APINavigation.cpp:
586         (API::Navigation::loggingString const): Use hex instead of String::format.
587         * UIProcess/SuspendedPageProxy.cpp:
588         (WebKit::SuspendedPageProxy::loggingString const): Ditto.
589
590         * UIProcess/WebBackForwardList.cpp:
591         (WebKit::WebBackForwardList::loggingString): Added a "0x".
592
593         * UIProcess/gtk/InputMethodFilter.cpp:
594         (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex
595         instead of String::format and "%x".
596         (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting):
597         Ditto.
598
599 2019-02-18  Wenson Hsieh  <wenson_hsieh@apple.com>
600
601         [iOS] Support pasting item-provider-backed data on the pasteboard as attachment elements
602         https://bugs.webkit.org/show_bug.cgi?id=194670
603         <rdar://problem/39066529>
604
605         Reviewed by Tim Horton.
606
607         Remove all IPC plumbing for getTypesByFidelityForItemAtIndex, now that the types in fidelity order have been
608         rolled into PasteboardItemInfo.
609
610         Additionally, remove support for subresource URL replacement. This feature was originally added with the
611         intention that private clients (i.e. Mail) would intercept pasted or dropped images and replace their URLs.
612         However, since <rdar://problem/43216836>, our strategy for this scenario has changed, such that WebKit now
613         handles the drop/paste, and later delivers the image data to the client via NSFileWrappers in the UI process.
614         At this time, there are no adopters of this SPI, and no adopters of the V2 injected bundle editing client. As
615         such, we can simply revert all of this to its state prior to the introduction of the replacement URL SPI, with
616         the exception to changes in WKBundlePageEditorClient.h, wherein there is a nonzero (but likely tiny) chance of
617         completely breaking binary compatability with any third parties on macOS which may have tried to adopt
618         subresource URL replacement.
619
620         * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
621         (WebKit::WebPasteboardProxy::getPasteboardTypesByFidelityForItemAtIndex): Deleted.
622         * UIProcess/WebPasteboardProxy.h:
623         * UIProcess/WebPasteboardProxy.messages.in:
624         * UIProcess/ios/WKContentViewInteraction.mm:
625         (-[WKContentView canPerformActionForWebView:withSender:]):
626
627         Return YES for -paste: in the case where:
628         1. The pasteboard contains items that are explicitly marked as attachments.
629         2. The selection is richly contenteditable.
630         3. Attachment elements are enabled.
631
632         Among other things, this allows the callout bar on iOS to show the "Paste" action.
633
634         * WebProcess/InjectedBundle/API/APIInjectedBundleEditorClient.h:
635         (API::InjectedBundle::EditorClient::performTwoStepDrop):
636         (API::InjectedBundle::EditorClient::replacementURLForResource): Deleted.
637         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInEditingDelegate.h:
638         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
639         (-[WKWebProcessPlugInBrowserContextController _setEditingDelegate:]):
640         * WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp:
641         (WebKit::InjectedBundlePageEditorClient::replacementURLForResource): Deleted.
642         * WebProcess/InjectedBundle/InjectedBundlePageEditorClient.h:
643         * WebProcess/WebCoreSupport/WebEditorClient.cpp:
644         (WebKit::WebEditorClient::replacementURLForResource): Deleted.
645         * WebProcess/WebCoreSupport/WebEditorClient.h:
646         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
647         (WebKit::WebPlatformStrategies::getTypesByFidelityForItemAtIndex): Deleted.
648         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
649
650 2019-02-18  Jeremy Jones  <jeremyj@apple.com>
651
652         exitFullscreen should not instantiate a new model/interface mapping.
653         https://bugs.webkit.org/show_bug.cgi?id=191988
654         rdar://problem/42327939
655
656         Reviewed by Jer Noble.
657
658         This change is a speculative fix for a crash that cannot be reproduced.
659
660         Somehow, exitFullscreen is being requested after didCleanupFullscreen has completed.
661         This change should allow us to prevent the crash in release, and assert in debug.
662
663         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
664         (WebKit::VideoFullscreenManagerProxy::exitFullscreen):
665
666 2019-02-18  John Wilander  <wilander@apple.com>
667
668         Check the existence of the frame in Document::hasFrameSpecificStorageAccess() and Document::setHasFrameSpecificStorageAccess()
669         https://bugs.webkit.org/show_bug.cgi?id=194777
670         <rdar://problem/47731945>
671
672         Reviewed by Geoffrey Garen and Chris Dumez.
673
674         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
675         (WebKit::NetworkConnectionToWebProcess::logUserInteraction):
676            Now returns early if the incoming session ID is invalid.
677            Added an ASSERT to help us find other call sites passing invalid session IDs.
678
679 2019-02-18  Per Arne Vollan  <pvollan@apple.com>
680
681         It should be possible to get the mouse event modifiers for a page overlay client.
682         https://bugs.webkit.org/show_bug.cgi?id=189621
683         <rdar://problem/44437279>
684
685         Reviewed by Daniel Bates.
686
687         When access to the WindowServer is blocked, [NSEvent modifierFlags] always returns 0.
688         This can be fixed by swizzling the class method, and getting the cached modifiers from
689         PlatformKeyboardEvent.
690  
691         * WebProcess/cocoa/WebProcessCocoa.mm:
692         (WebKit::currentModifierFlags):
693         (WebKit::WebProcess::platformInitializeProcess):
694
695 2019-02-18  Claudio Saavedra  <csaavedra@igalia.com>
696
697         WebPageProxy::didFinishDocumentLoadForFrame() crashing in WPE and GTK+ ports
698         https://bugs.webkit.org/show_bug.cgi?id=194774
699
700         Reviewed by Alex Christensen.
701
702         * UIProcess/WebPageProxy.cpp:
703         (WebKit::WebPageProxy::didFinishDocumentLoadForFrame):
704         Null check navigation before using it.
705         This is a regression from r241451.
706
707 2019-02-18  Daniel Bates  <dabates@apple.com>
708
709         [iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element
710         https://bugs.webkit.org/show_bug.cgi?id=192824
711         <rdar://problem/47100332>
712
713         Reviewed by Wenson Hsieh.
714
715         Use the same code path for key events to editable elements and non-editable elements.
716
717         Currently we have different code paths for hardware key events depending on whether the active element
718         is editable or non-editable. Historically to support dispatching DOM keyboard events for hardware key
719         presses this differentiation was a necessary workaround for UIKit's event processing precedence of
720         interpreting key events for system text editing commands and app commands before dispatching unhandled
721         key events to WebKit. This workaround intercepted raw key UIEvents and manually reconstructed a
722         WebEvent from it. However there is not enough information in an UIEvent to reconstruct a WebEvent that
723         is identical to the WebEvent that UIKit would have dispatched. In particular, keyup UIEvents always have
724         empty modified and unmodified input strings. The UIKit keyboard machinery maintains additional state
725         that is necessary to manufacture the correct WebEvent corresponding to a UIEvent.
726
727         As a side benefit of this change, with the exception of modifier flag changes, both hardware and software
728         key events use the same code path.
729
730         * UIProcess/ios/WKContentViewInteraction.h:
731         * UIProcess/ios/WKContentViewInteraction.mm:
732         (-[WKContentView shouldShowAutomaticKeyboardUI]): Extracted code from _requiresKeyboardWhenFirstResponder
733         (-[WKContentView _disableAutomaticKeyboardUI]): Implement UIKit SPI to prevent showing the keyboard UI
734         when there is no focused element now that we are no longer intercepting key UIEvents. Formerly the
735         keyboard UI was disabled as a side effect of not becoming first responder when there was no focused
736         element (by returning NO in -_requiresKeyboardWhenFirstResponder).
737         (-[WKContentView _requiresKeyboardWhenFirstResponder]): Always return YES when building with USE(UIKIT_KEYBOARD_ADDITIONS)
738         so that we always accept key events. Instead of selectively replying to create a keyboard as a means of
739         hiding the automatic keyboard UI we now implement _disableAutomaticKeyboardUI to selectively hide the
740         automatic keyboard UI.
741         (-[WKContentView applyAutocorrection:toString:withCompletionHandler:]): If we are not in an editable
742         element then we cannot perform the replacement. This logic was necessary now that we always require a
743         keyboard.
744         (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]): If we are not in an editable
745         element then return an autocorrection object that indicates that we could not compute this data. This
746         logic was necessary now that we always require a keyboard.
747         (-[WKContentView textInputTraits]): Do not update traits when the keyboard is going to be dismissed
748         now that we require a keyboard when first responder even if the focused element is non-editable.
749         (-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Skip logic for re-sending UIEvents to UIKit
750         as UIKit now processes the event first. This logic was necessary in order to finally allow UIKit
751         its chance to interpret the UIEvent, we intercepted, for app key commands.
752         (-[WKContentView _elementDidBlur]): Call [self _endEditing] so that we dismiss any open form controls
753         (e.g. a <select> popover menu). Currently this happens either by -_requiresKeyboardWhenFirstResponder
754         responding NO when switching to another field or pressing Tab or Shift + Tab key command, which we will
755         no longer use when building with USE(UIKIT_KEYBOARD_ADDITIONS) once I land <https://bugs.webkit.org/show_bug.cgi?id=193048>.
756         * UIProcess/ios/forms/WKFormSelectPopover.mm:
757         (-[WKSelectPopover initWithView:hasGroups:]): Do not assign ourself as the keyboard delegate. Otherwise,
758         type ahead and tab cycling will not work. Currently type ahead and tab cycling work by using the non-
759         editable code path via -_handleKeyUIEvent. Now that we no longer differentiate between key events for
760         editable and non-editable elements we need to ensure that the WKContentView is the keyboard delegate
761         when the popover is presented.
762
763 2019-02-18  Jiewen Tan  <jiewen_tan@apple.com>
764
765         Tell Networking Process to not optimize load
766         https://bugs.webkit.org/show_bug.cgi?id=194753
767         <rdar://problem/48143603>
768
769         Reviewed by Brent Fulgham.
770
771         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
772         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
773
774 2019-02-18  Dean Jackson  <dino@apple.com>
775
776         iOS Safari will not load USDZ in QLPreview when opening as BLOB
777         https://bugs.webkit.org/show_bug.cgi?id=194766
778         <rdar://problem/42769186>
779
780         Reviewed by Wenson Hsieh.
781
782         A download from a Blob URL can happen effectively instantly, which means
783         that the loadHandler on the registerItemForTypeIdentifier method might not have
784         been called yet, and we haven't been told what the completionHandler is.
785         In this case, keep a record of the URL we finished with, and call the completionHandler
786         right away.
787
788         * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: Add a new private member variable: _downloadedURL.
789         (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): Call the completionHandler
790         right away if we've finished.
791         (-[_WKPreviewControllerDataSource finish:]): Remember that we've finished by recording the URL.
792
793 2019-02-18  Alex Christensen  <achristensen@webkit.org>
794
795         Disable safe browsing in WKWebView and remove its WKPreferences API
796         https://bugs.webkit.org/show_bug.cgi?id=194723
797         <rdar://problem/48122993>
798
799         Reviewed by Geoffrey Garen.
800
801         * Shared/WebPreferences.yaml:
802         * UIProcess/API/Cocoa/WKPreferences.h:
803         * UIProcess/API/Cocoa/WKPreferences.mm:
804         (-[WKPreferences setSafeBrowsingEnabled:]): Deleted.
805         (-[WKPreferences isSafeBrowsingEnabled]): Deleted.
806
807 2019-02-18  Chris Fleizach  <cfleizach@apple.com>
808
809         AX: PSON: Going back from apple.com to search results, cannot interact with HTML content. Disabling Swap Processes on Cross-Site Navigation resolves the issue.
810         https://bugs.webkit.org/show_bug.cgi?id=194742
811
812         Reviewed by Chris Dumez.
813
814         Re-initialize the accessibility web process tokens when swapping processes.
815         Send page load notifications from the UIProcess instead of the WebProcess to improve reliability.
816
817         * UIProcess/mac/PageClientImplMac.mm:
818         (WebKit::PageClientImpl::didFinishLoadForMainFrame):
819         (WebKit::PageClientImpl::didFailLoadForMainFrame):
820         * WebProcess/WebPage/WebPage.cpp:
821         (WebKit::WebPage::reinitializeWebPage):
822         * WebProcess/WebPage/WebPage.h:
823         * WebProcess/WebPage/gtk/WebPageGtk.cpp:
824         (WebKit::WebPage::platformReinitialize):
825         (WebKit::WebPage::platformDetach): Deleted.
826         (WebKit::WebPage::platformEditorState const): Deleted.
827         (WebKit::WebPage::updateAccessibilityTree): Deleted.
828         (WebKit::WebPage::performDefaultBehaviorForKeyEvent): Deleted.
829         (WebKit::WebPage::platformCanHandleRequest): Deleted.
830         (WebKit::WebPage::platformUserAgent const): Deleted.
831         (WebKit::WebPage::getCenterForZoomGesture): Deleted.
832         (WebKit::WebPage::setInputMethodState): Deleted.
833         (WebKit::WebPage::collapseSelectionInFrame): Deleted.
834         * WebProcess/WebPage/ios/WebPageIOS.mm:
835         (WebKit::WebPage::platformReinitialize):
836         * WebProcess/WebPage/mac/WebPageMac.mm:
837         (WebKit::WebPage::platformReinitialize):
838         * WebProcess/WebPage/win/WebPageWin.cpp:
839         (WebKit::WebPage::platformReinitialize):
840         * WebProcess/WebPage/wpe/WebPageWPE.cpp:
841         (WebKit::WebPage::platformReinitialize):
842
843 2019-02-18  Carlos Garcia Campos  <cgarcia@igalia.com>
844
845         [GTK] Crash while filling selection data during drag and drop
846         https://bugs.webkit.org/show_bug.cgi?id=194698
847
848         Reviewed by Michael Catanzaro.
849
850         I can't reproduce this, but it seems that m_draggingSelectionData is nullptr in fillDragData(). That can happen
851         when startDrag cancels a previous DND operation, because the new m_draggingSelectionData is set before the
852         current DND operation is cancelled, which sets it to nullptr.
853
854         * UIProcess/gtk/DragAndDropHandler.cpp:
855         (WebKit::DragAndDropHandler::startDrag): Finish the previous operation before setting m_draggingSelectionData.
856
857 2019-02-17  Youenn Fablet  <youenn@apple.com>
858
859         https://device.login.microsoftonline.com is hanging on STP75
860         https://bugs.webkit.org/show_bug.cgi?id=194734
861         <rdar://problem/47573830>
862
863         Reviewed by Jiewen Tan.
864
865         Make sure to only go the XPC route if SecKeyProxyStore has credentials.
866         Tested manually by going to the above website with and without the patch.
867         Load hangs without the patch and completes with the patch.
868
869         * UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
870         (WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
871         * UIProcess/Authentication/cocoa/SecKeyProxyStore.h:
872         * UIProcess/Authentication/cocoa/SecKeyProxyStore.mm:
873         (WebKit::SecKeyProxyStore::initialize):
874
875 2019-02-17  David Kilzer  <ddkilzer@apple.com>
876
877         Unreviewed, rolling out r241620.
878
879         "Causes use-after-free crashes running layout tests with ASan and GuardMalloc."
880         (Requested by ddkilzer on #webkit.)
881
882         Reverted changeset:
883
884         "[WTF] Add environment variable helpers"
885         https://bugs.webkit.org/show_bug.cgi?id=192405
886         https://trac.webkit.org/changeset/241620
887
888 2019-02-15  Youenn Fablet  <youenn@apple.com>
889
890         NetworkDataTask should check its client before calling shouldCaptureExtraNetworkLoadMetrics
891         https://bugs.webkit.org/show_bug.cgi?id=194732
892
893         Reviewed by Geoffrey Garen.
894
895         NetworkDataTask may be kept alive if refing it after its NetworkLoad is gone.
896         This might happen for instance in DownloadManager or when checking for TLS certificates.
897         In that case, if the NetworkLoad gets destroyed, it clears the client of the NetworkDataTask.
898         To ensure that NetworkDataTask does not try to use its client, add a null check.
899
900         * NetworkProcess/NetworkDataTask.cpp:
901         (WebKit::NetworkDataTask::shouldCaptureExtraNetworkLoadMetrics const):
902
903 2019-02-15  Chris Dumez  <cdumez@apple.com>
904
905         [PSON] Allow tweaking WebProcess cache parameters via user defaults
906         https://bugs.webkit.org/show_bug.cgi?id=194731
907         <rdar://problem/48125377>
908
909         Reviewed by Geoffrey Garen.
910
911         Allow tweaking WebProcess cache parameters via user defaults like so:
912         $ defaults write com.apple.Safari WebProcessCacheCachedProcessLifetimeInSeconds 120
913         -> Cached processes will be evicted after 2 minutes (instead of 30)
914
915         $ defaults write com.apple.Safari WebProcessCacheClearingDelayAfterApplicationResignsActiveInSeconds 60
916         -> Web process cache will be cleared if Safari is no longer active for 1 minutes (instead of 5).
917
918         * SourcesCocoa.txt:
919         * UIProcess/Cocoa/WebProcessCacheCocoa.mm: Copied from Source/WebKit/UIProcess/WebProcessCache.h.
920         (WebKit::WebProcessCache::platformInitialize):
921         * UIProcess/WebProcessCache.cpp:
922         (WebKit::WebProcessCache::WebProcessCache):
923         (WebKit::WebProcessCache::platformInitialize):
924         * UIProcess/WebProcessCache.h:
925         * WebKit.xcodeproj/project.pbxproj:
926
927 2019-02-15  Chris Dumez  <cdumez@apple.com>
928
929         [PSON] Disable WebContent process cache on devices with less than 3GB of RAM
930         https://bugs.webkit.org/show_bug.cgi?id=194726
931         <rdar://problem/48126255>
932
933         Reviewed by Geoffrey Garen.
934
935         * UIProcess/WebProcessCache.cpp:
936         (WebKit::WebProcessCache::updateCapacity):
937
938 2019-02-15  Andy Estes  <aestes@apple.com>
939
940         [iOS] Stop setting a background color on the PDF host view
941         https://bugs.webkit.org/show_bug.cgi?id=194722
942         <rdar://48124152>
943
944         Reviewed by Wenson Hsieh.
945
946         PDFKit already sets a background color on this view, so there’s no need (and some harm) in
947         us doing it too.
948
949         * UIProcess/ios/WKPDFView.mm:
950         (-[WKPDFView web_setContentProviderData:suggestedFilename:]):
951
952 2019-02-15  Alex Christensen  <achristensen@webkit.org>
953
954         Update IPC code generator unit test expectations after r241611
955         https://bugs.webkit.org/show_bug.cgi?id=194678
956
957         * Scripts/webkit/LegacyMessages-expected.h:
958         * Scripts/webkit/Messages-expected.h:
959         * Scripts/webkit/MessagesSuperclass-expected.h:
960
961 2019-02-15  Ross Kirsling  <ross.kirsling@sony.com>
962
963         [WTF] Add environment variable helpers
964         https://bugs.webkit.org/show_bug.cgi?id=192405
965
966         Reviewed by Michael Catanzaro.
967
968         * NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp:
969         (main):
970         * Platform/unix/LoggingUnix.cpp:
971         (WebKit::logLevelString):
972         * Platform/win/LoggingWin.cpp:
973         (WebKit::logLevelString):
974         * PluginProcess/mac/PluginProcessMac.mm:
975         (WebKit::shouldCallRealDebugger):
976         * Shared/Plugins/unix/PluginSearchPath.cpp:
977         (WebKit::pluginsDirectories):
978         * Shared/glib/ProcessExecutablePathGLib.cpp:
979         (WebKit::findWebKitProcess):
980         * UIProcess/API/glib/WebKitSettings.cpp:
981         (webKitSettingsConstructed):
982         (webKitSettingsSetProperty):
983         * UIProcess/API/glib/WebKitWebContext.cpp:
984         (injectedBundleDirectory):
985         (webkitWebContextConstructed):
986         * UIProcess/API/gtk/WebKitWebViewGtk.cpp:
987         (webkitWebViewMaximizeWindow):
988         (webkitWebViewRestoreWindow):
989         * UIProcess/API/wpe/WPEView.cpp:
990         (WKWPE::m_backend):
991         * UIProcess/AuxiliaryProcessProxy.cpp:
992         (WebKit::AuxiliaryProcessProxy::getLaunchOptions):
993         * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
994         (WebKit::XDGDBusProxyLauncher::launch):
995         (WebKit::bindDBusSession):
996         (WebKit::bindX11):
997         (WebKit::bindWayland):
998         (WebKit::bindPulse):
999         (WebKit::bindPathVar):
1000         (WebKit::bindGStreamerData):
1001         (WebKit::bubblewrapSpawn):
1002         * UIProcess/Launcher/glib/ProcessLauncherGLib.cpp:
1003         (WebKit::ProcessLauncher::launchProcess):
1004         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
1005         (WebKit::systemDirectoryPath):
1006         (WebKit::ProcessLauncher::launchProcess):
1007         * UIProcess/glib/WebProcessPoolGLib.cpp:
1008         (WebKit::memoryPressureMonitorDisabled):
1009         (WebKit::WebProcessPool::platformInitialize):
1010         (WebKit::WebProcessPool::platformInitializeWebProcess):
1011         * UIProcess/gtk/HardwareAccelerationManager.cpp:
1012         (WebKit::HardwareAccelerationManager::HardwareAccelerationManager):
1013         * WebProcess/EntryPoint/unix/WebProcessMain.cpp:
1014         (main):
1015         * WebProcess/gtk/WebProcessMainGtk.cpp:
1016         * WebProcess/wpe/WebProcessMainWPE.cpp:
1017         Utilize WTF::Environment where possible.
1018
1019 2019-02-15  Alex Christensen  <achristensen@webkit.org>
1020
1021         Add SPI version of WKPreferences.safeBrowsingEnabled
1022         https://bugs.webkit.org/show_bug.cgi?id=194718
1023         <rdar://problem/48122993>
1024
1025         Rubber-stamped by Brady Eidson.
1026
1027         * UIProcess/API/Cocoa/WKPreferences.mm:
1028         (-[WKPreferences _isSafeBrowsingEnabled]):
1029         (-[WKPreferences _setSafeBrowsingEnabled:]):
1030         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
1031
1032 2019-02-15  Wenson Hsieh  <wenson_hsieh@apple.com>
1033
1034         [iOS] WKWebView callout bar is missing Change Writing Direction item
1035         https://bugs.webkit.org/show_bug.cgi?id=190015
1036         <rdar://problem/44810366>
1037
1038         Reviewed by Tim Horton.
1039
1040         Support -makeTextWritingDirectionLeftToRight: and -makeTextWritingDirectionRightToLeft: in WKWebView on iOS.
1041         To match behavior in native UITextViews on iOS, we implement these methods by changing the *base* writing
1042         direction, rather than the text writing direction (this is in contrast to macOS, which has different
1043         NSResponder methods for changing the base writing direction as opposed to the text writing direction).
1044
1045         Additionally fixes the implementation of -makeTextWritingDirectionNatural:, which currently attempts to change
1046         the text writing direction instead of the base writing direction.
1047
1048         * Platform/spi/ios/UIKitSPI.h:
1049
1050         Add a forward declaration for keyboards SPI to determine whether the user has an active RTL keyboard.
1051
1052         * Shared/EditorState.cpp:
1053         (WebKit::EditorState::PostLayoutData::encode const):
1054         (WebKit::EditorState::PostLayoutData::decode):
1055         (WebKit::operator<<):
1056         * Shared/EditorState.h:
1057
1058         Plumb the base writing direction to the UI process through EditorState.
1059
1060         * UIProcess/ios/WKContentViewInteraction.h:
1061         * UIProcess/ios/WKContentViewInteraction.mm:
1062         (-[WKContentView makeTextWritingDirectionNaturalForWebView:]):
1063         (-[WKContentView makeTextWritingDirectionLeftToRightForWebView:]):
1064         (-[WKContentView makeTextWritingDirectionRightToLeftForWebView:]):
1065
1066         Implement the new SPI (see above for more details).
1067
1068         (-[WKContentView canPerformActionForWebView:withSender:]):
1069
1070         Implement -canPerformAction: for LTR and RTL actions. To match existing UIWebView behavior, we only enable
1071         these actions if either the base writing direction is RTL, or the user has an active RTL keyboard. This means,
1072         for instance, that in the case where a user with only an English keyboard is editing LTR content, we would never
1073         show an option to convert to RTL.
1074
1075         * WebProcess/WebPage/WebPage.cpp:
1076         (WebKit::WebPage::editorState const):
1077
1078 2019-02-15  Alex Christensen  <achristensen@webkit.org>
1079
1080         Make WebPaymentCoordinatorProxy more robust and modern
1081         https://bugs.webkit.org/show_bug.cgi?id=194678
1082
1083         Reviewed by Andy Estes.
1084
1085         Use WeakPtr instead of storing raw pointers in lambdas or the global activePaymentCoordinatorProxy to avoid UAF problems.
1086         Call CompletionHandlers in all code paths to avoid hangs.
1087         Use Delayed instead of LegacySync for synchronous messaging to progress towards removing LegacySync messages.
1088
1089         * Scripts/webkit/messages.py:
1090         * UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp:
1091         (WebKit::activePaymentCoordinatorProxy):
1092         (WebKit::WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy):
1093         (WebKit::WebPaymentCoordinatorProxy::availablePaymentNetworks):
1094         (WebKit::WebPaymentCoordinatorProxy::canMakePayments):
1095         (WebKit::WebPaymentCoordinatorProxy::showPaymentUI):
1096         (WebKit::WebPaymentCoordinatorProxy::didReachFinalState):
1097         * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
1098         * UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in:
1099         * UIProcess/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
1100         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
1101         * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
1102         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
1103
1104 2019-02-15  Youenn Fablet  <youenn@apple.com>
1105
1106         Make ServiceWorkerClientFetch closer to WebResourceLoader
1107         https://bugs.webkit.org/show_bug.cgi?id=194651
1108
1109         Unreviewed, build fix for WPE.
1110
1111         * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h:
1112
1113 2019-02-15  Chris Dumez  <cdumez@apple.com>
1114
1115         Regression(PSON) Navigating quickly back and forth can lead to getting 'about:blank' in the backforward list
1116         https://bugs.webkit.org/show_bug.cgi?id=194717
1117         <rdar://problem/47884404>
1118
1119         Reviewed by Brady Eidson.
1120
1121         When the client does a history navigation, the UIProcess sends a WebPage::GoToBackForwardItem IPC to the
1122         WebProcess and the WebProcess sends a WebPageProxy::BackForwardGoToItem IPC back to the UIProcess to
1123         update the current item in the BackForwardList. This means that there is a slight delay between the
1124         point a client requests a history navigation and the point where the BackForwardList's current item gets
1125         update. This delay is pre-existing behavior and not new to PSON.
1126
1127         However, with PSON enabled, if we decide to process-swap for the history navigation, we'll tell the
1128         previous (committed) process to ignore the load and we ask a new (provisional) process to do the history
1129         navigation. When the previous process receives the request to ignore the history navigation, it restores
1130         the History's current item to the one previous the navigation, which sends a WebPageProxy::GoToBackForwardItem
1131         IPC to the UIProcess to update the BackForwardList as well. In parallel, the new process starts the
1132         history navigation and also sends a WebPageProxy::GoToBackForwardItem to update the BackForwardList's
1133         current item as well. We end up with a race between the 2 GoToBackForwardItem IPC messages coming from
1134         the old and new process. If the old process's message loses the race, we end up with the wrong current
1135         history item getting set in the UIProcess. Later, when we commit the provisional load and try to suspend
1136         the previous page, we would save the SuspendedPage on the *wrong* BackForwardList item. If one tries to
1137         load this BackForwardList item later, we'll use its SuspendedPage and try to unsuspend it. However,
1138         because the PageCache entry is saved on another HistoryItem than the one getting loaded in the WebProcess
1139         side, we attempt to do a regular load instead of a PageCache restore. We end up failing the load because
1140         pages cannot trigger new loads while in page cache. Because the load fails, we end up loading the
1141         initial empty document and this is how we end up with 'about:blank' in the back forward list.
1142
1143         To address the issue, update WebPageProxy::backForwardGoToItem() to ignore messages from the old/committed
1144         WebProcess when there is a pending provisional load. If the committed processes starts a legit new
1145         load, it would clear any existing pending provisional load before attempting the call backForwardGoToItem().
1146         As a result, ignoring such messages from the old processes when there is a pending provisional load is
1147         safe.
1148
1149         In the future, we should probably move more of the history / backForwardList management to the UIProcess
1150         to avoid this sort of issues. This would be a much larger refactoring though so I am going with this
1151         simpler fix that is easily cherry-pickable for now.
1152
1153         * UIProcess/WebPageProxy.cpp:
1154         (WebKit::WebPageProxy::suspendCurrentPageIfPossible):
1155         (WebKit::WebPageProxy::continueNavigationInNewProcess):
1156         (WebKit::WebPageProxy::backForwardGoToItem):
1157
1158 2019-02-15  Alex Christensen  <achristensen@webkit.org>
1159
1160         Update IPC code generator unit test expectations after r241595
1161         https://bugs.webkit.org/show_bug.cgi?id=194679
1162
1163         * Scripts/webkit/LegacyMessageReceiver-expected.cpp:
1164         (WebKit::WebPage::didReceiveSyncWebPageMessage):
1165         * Scripts/webkit/MessageReceiver-expected.cpp:
1166         (WebKit::WebPage::didReceiveSyncMessage):
1167
1168 2019-02-15  Youenn Fablet  <youenn@apple.com>
1169
1170         Make ServiceWorkerClientFetch closer to WebResourceLoader
1171         https://bugs.webkit.org/show_bug.cgi?id=194651
1172
1173         Reviewed by Alex Christensen.
1174
1175         The goal of this refactoring is to, at some point use the regular network process load path for service worker loads.
1176         This should simplify things and allow less IPC exchanges, for instance in the case of fetch not handled by service worker.
1177
1178         Introduce two IPC messages for supporting redirect responses and allow the didReceiveResponse/continueDidReceiveResponse
1179         handshake for navigation loads.
1180
1181         This makes ServiceWorker having to buffer load information for this particular case.
1182
1183         * NetworkProcess/NetworkProcess.cpp:
1184         (WebKit::NetworkProcess::didReceiveFetchRedirectResponse):
1185         (WebKit::NetworkProcess::didReceiveFetchResponse):
1186         * NetworkProcess/NetworkProcess.h:
1187         * NetworkProcess/NetworkProcess.messages.in:
1188         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
1189         (WebKit::WebSWServerConnection::continueDidReceiveFetchResponse):
1190         (WebKit::WebSWServerConnection::didReceiveFetchRedirectResponse):
1191         (WebKit::WebSWServerConnection::didReceiveFetchResponse):
1192         * NetworkProcess/ServiceWorker/WebSWServerConnection.h:
1193         * NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in:
1194         * WebProcess/Storage/ServiceWorkerClientFetch.cpp:
1195         (WebKit::ServiceWorkerClientFetch::start):
1196         (WebKit::ServiceWorkerClientFetch::didReceiveRedirectResponse):
1197         (WebKit::ServiceWorkerClientFetch::didReceiveResponse):
1198         (WebKit::ServiceWorkerClientFetch::didReceiveData):
1199         (WebKit::ServiceWorkerClientFetch::didFinish):
1200         (WebKit::ServiceWorkerClientFetch::didFail):
1201         (WebKit::ServiceWorkerClientFetch::didNotHandle):
1202         (WebKit::ServiceWorkerClientFetch::cancel):
1203         * WebProcess/Storage/ServiceWorkerClientFetch.h:
1204         * WebProcess/Storage/ServiceWorkerClientFetch.messages.in:
1205         * WebProcess/Storage/WebSWClientConnection.cpp:
1206         (WebKit::WebSWClientConnection::startFetch):
1207         (WebKit::WebSWClientConnection::cancelFetch):
1208         (WebKit::WebSWClientConnection::continueDidReceiveFetchResponse):
1209         * WebProcess/Storage/WebSWClientConnection.h:
1210         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
1211         (WebKit::WebSWContextManagerConnection::continueDidReceiveFetchResponse):
1212         (WebKit::WebSWContextManagerConnection::startFetch):
1213         * WebProcess/Storage/WebSWContextManagerConnection.h:
1214         * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
1215         * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
1216         (WebKit::WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient):
1217         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveRedirection):
1218         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveResponse):
1219         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveData):
1220         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish):
1221         (WebKit::WebServiceWorkerFetchTaskClient::didFail):
1222         (WebKit::WebServiceWorkerFetchTaskClient::didFinish):
1223         (WebKit::WebServiceWorkerFetchTaskClient::continueDidReceiveResponse):
1224         * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h:
1225
1226 2019-02-15  Brian Burg  <bburg@apple.com>
1227
1228         [Mac] WebInspectorUI.framework does not need to be soft-linked anymore
1229         https://bugs.webkit.org/show_bug.cgi?id=194411
1230         <rdar://problem/47787614>
1231
1232         Reviewed by Joseph Pecoraro.
1233
1234         * Configurations/WebKit.xcconfig:
1235         Conditionalize weak linking to WebInspectorUI.framework for Mac only.
1236
1237         * UIProcess/mac/WebInspectorProxyMac.mm:
1238         (WebKit::WebInspectorProxy::inspectorPageURL):
1239         (WebKit::WebInspectorProxy::inspectorTestPageURL):
1240         (WebKit::WebInspectorProxy::inspectorBaseURL):
1241         * WebProcess/WebPage/mac/WebInspectorUIMac.mm:
1242         (WebKit::webInspectorUILocalizedStringsURL):
1243         Rewrite uses of the bundle to exit early if bundle couldn't be loaded.
1244
1245 2019-02-15  Alex Christensen  <achristensen@webkit.org>
1246
1247         IPC code should support messages with both Delayed and WantsConnection attributes
1248         https://bugs.webkit.org/show_bug.cgi?id=194679
1249
1250         Reviewed by Geoffrey Garen.
1251
1252         * Platform/IPC/HandleMessage.h:
1253         (IPC::callMemberFunctionImpl):
1254         (IPC::callMemberFunction):
1255         (IPC::handleMessageDelayedWantsConnection):
1256         * Scripts/webkit/messages.py:
1257         * UIProcess/WebStorage/StorageManager.cpp:
1258         (WebKit::StorageManager::getValues):
1259         * UIProcess/WebStorage/StorageManager.h:
1260         * UIProcess/WebStorage/StorageManager.messages.in:
1261
1262 2019-02-15  Commit Queue  <commit-queue@webkit.org>
1263
1264         Unreviewed, rolling out r241559 and r241566.
1265         https://bugs.webkit.org/show_bug.cgi?id=194710
1266
1267         Causes layout test crashes under GuardMalloc (Requested by
1268         ryanhaddad on #webkit).
1269
1270         Reverted changesets:
1271
1272         "[WTF] Add environment variable helpers"
1273         https://bugs.webkit.org/show_bug.cgi?id=192405
1274         https://trac.webkit.org/changeset/241559
1275
1276         "Unreviewed build fix for WinCairo Debug after r241559."
1277         https://trac.webkit.org/changeset/241566
1278
1279 2019-02-15  Michael Catanzaro  <mcatanzaro@igalia.com>
1280
1281         [WPE][GTK] Defer sandboxing APIs to 2.26
1282         https://bugs.webkit.org/show_bug.cgi?id=194274
1283
1284         Reviewed by Carlos Garcia Campos.
1285
1286         The web process sandbox has not been widely-tested yet, so we should defer the new APIs to
1287         2.26.
1288
1289         * UIProcess/API/glib/WebKitWebContext.cpp:
1290
1291 2019-02-10  Darin Adler  <darin@apple.com>
1292
1293         Replace more uses of String::format with StringConcatenate (mostly non-Apple platform-specific cases)
1294         https://bugs.webkit.org/show_bug.cgi?id=194487
1295
1296         Reviewed by Daniel Bates.
1297
1298         * NetworkProcess/NetworkProcess.cpp:
1299         (WebKit::NetworkProcess::switchToNewTestingSession): Use makeString instead of String::format.
1300         * NetworkProcess/soup/NetworkProcessSoup.cpp:
1301         (WebKit::buildAcceptLanguages): Ditto.
1302         * UIProcess/API/glib/IconDatabase.cpp:
1303         (WebKit::IconDatabase::performURLImport): Ditto.
1304         * UIProcess/gtk/InputMethodFilter.cpp:
1305         (WebKit::InputMethodFilter::logConfirmCompositionForTesting): Ditto.
1306         (WebKit::InputMethodFilter::logSetPreeditForTesting): Ditto.
1307
1308 2019-02-15  Truitt Savell  <tsavell@apple.com>
1309
1310         Unreviewed, rolling out r241564.
1311
1312         Caused 50+ Timeouts on Mac WK2, mostly in the http/ directory
1313
1314         Reverted changeset:
1315
1316         "[Mac] WebInspectorUI.framework does not need to be soft-
1317         linked anymore"
1318         https://bugs.webkit.org/show_bug.cgi?id=194411
1319         https://trac.webkit.org/changeset/241564
1320
1321 2019-02-15  Carlos Garcia Campos  <cgarcia@igalia.com>
1322
1323         Unreviewed. Fix GTK+ build after r241556
1324
1325         I guess this is due to unified builds after a new file being added in r241556.
1326
1327         * UIProcess/API/C/WKAuthenticationDecisionListener.cpp:
1328         * UIProcess/API/C/WKPage.cpp:
1329
1330 2019-02-14  Brent Fulgham  <bfulgham@apple.com>
1331
1332         REGRESSION (r240446): Storage Access API does not handle domains consistently
1333         https://bugs.webkit.org/show_bug.cgi?id=194664
1334
1335         Reviewed by Alex Christensen.
1336         
1337         During my refactoring of the ResourceLoadStatistics code, I introduced two bugs:
1338         (1) I neglected to be consistent in my use of 'primaryDomain', causing some Storage
1339         Access API code paths to store approves under one domain (e.g., 'www.example.com'),
1340         while checking status under the eTLD+1 (e.g., 'example.com'). The exact string matching
1341         requirement caused these to get missed.
1342
1343         (2) I used a move operator before a final set of copies of domain names, leading to
1344         some empty strings being passed to Storage Access API calls.
1345
1346         Both issues are corrected in this patch.
1347
1348         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1349         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode): Always make the
1350         domain comply with our 'primaryDomain' logic.
1351         (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): Ditto.
1352         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted): Ditto.
1353         (WebKit::WebResourceLoadStatisticsStore::logFrameNavigation): Ditto.
1354         (WebKit::WebResourceLoadStatisticsStore::logWebSocketLoading): Ditto.
1355         (WebKit::WebResourceLoadStatisticsStore::logSubresourceLoading): Ditto.
1356         (WebKit::WebResourceLoadStatisticsStore::logSubresourceRedirect): Ditto.
1357         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction): Ditto.
1358         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction): Ditto.
1359         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction): Ditto.
1360         (WebKit::WebResourceLoadStatisticsStore::setLastSeen): Ditto.
1361         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): Ditto.
1362         (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource): Ditto.
1363         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource): Ditto.
1364         (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource): Ditto.
1365         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder): Ditto.
1366         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder): Ditto.
1367         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo): Ditto.
1368         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource): Ditto.
1369         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered): Ditto.
1370         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered): Ditto.
1371         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): Ditto.
1372         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): Ditto.
1373         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): Ditto.
1374         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): Ditto.
1375         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): Ditto.
1376         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): Ditto.
1377         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1378         (WebKit::WebsiteDataStore::hasStorageAccess): Always make the
1379         domain comply with our 'primaryDomain' logic.
1380         (WebKit::WebsiteDataStore::requestStorageAccess): Ditto. Also make copy of domain
1381         names before moving them to the completion handler.
1382         (WebKit::WebsiteDataStore::grantStorageAccess): Ditto.
1383         * WebProcess/WebPage/WebPage.cpp:
1384         (WebKit::WebPage::hasStorageAccess):  Always make the domain comply with our
1385         'primaryDomain' logic.
1386         (WebKit::WebPage::requestStorageAccess): Ditto.
1387
1388 2019-02-14  Tim Horton  <timothy_horton@apple.com>
1389
1390         Fix the build.
1391
1392         * UIProcess/ios/WKDrawingView.mm:
1393         (-[WKDrawingView renderedDrawing]):
1394
1395 2019-02-14  Youenn Fablet  <youenn@apple.com>
1396
1397         ASSERTION FAILED: m_caches.isEmpty() || !m_pendingInitializationCallbacks.isEmpty() in WebKit::CacheStorage::Caches::clearMemoryRepresentation()
1398         https://bugs.webkit.org/show_bug.cgi?id=188393
1399         <rdar://problem/43025665>
1400
1401         Reviewed by Alex Christensen.
1402
1403         In case Caches::dispose is called, clearMemoryRepresentation might be called if there is no active cache.
1404         We also ensure to not clear the memory representation if there is any remaining removed cache.
1405         Update the clearMemoryRepresentation assertion to take that into account.
1406
1407         In case a Caches is cleared twice, the clearMemoryRepresentation assertion will assert while it should not.
1408         In that case m_storage is null the second time. Update the assertion accordingly.
1409
1410         * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
1411         (WebKit::CacheStorage::Caches::hasActiveCache const):
1412         (WebKit::CacheStorage::Caches::dispose):
1413         (WebKit::CacheStorage::Caches::clearMemoryRepresentation):
1414         * NetworkProcess/cache/CacheStorageEngineCaches.h:
1415
1416 2019-02-14  Brian Burg  <bburg@apple.com>
1417
1418         [Mac] WebInspectorUI.framework does not need to be soft-linked anymore
1419         https://bugs.webkit.org/show_bug.cgi?id=194411
1420         <rdar://problem/47787614>
1421
1422         Reviewed by Joseph Pecoraro.
1423
1424         * Configurations/WebKit.xcconfig:
1425         Conditionalize weak linking to WebInspectorUI.framework for Mac only.
1426
1427         * UIProcess/mac/WebInspectorProxyMac.mm:
1428         (WebKit::WebInspectorProxy::inspectorPageURL):
1429         (WebKit::WebInspectorProxy::inspectorTestPageURL):
1430         (WebKit::WebInspectorProxy::inspectorBaseURL):
1431         * WebProcess/WebPage/mac/WebInspectorUIMac.mm:
1432         (WebKit::webInspectorUILocalizedStringsURL):
1433         Rewrite uses of the bundle to exit early if bundle couldn't be loaded.
1434
1435 2019-02-14  Michael Catanzaro  <mcatanzaro@igalia.com>
1436
1437         [GTK] WebKitGTK+ -> WebKitGTK
1438         https://bugs.webkit.org/show_bug.cgi?id=194658
1439
1440         Reviewed by Alex Christensen.
1441
1442         This renames WebKitGTK+ to WebKitGTK in a few user-visible places: the API documentation,
1443         the pkg-config, and an error message.
1444
1445         In a couple places where it's exposed in WPE documentation, WPE is now mentioned, or the
1446         reference to "WebKitGTK+" is changed to just "WebKit."
1447
1448         * UIProcess/API/glib/WebKitSettings.cpp:
1449         (webkit_settings_class_init):
1450         * UIProcess/API/glib/WebKitWebView.cpp:
1451         * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
1452         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMPrivateGtk.h:
1453         * gtk/webkit2gtk-web-extension.pc.in:
1454         * gtk/webkit2gtk.pc.in:
1455
1456 2019-02-14  Ross Kirsling  <ross.kirsling@sony.com>
1457
1458         [WTF] Add environment variable helpers
1459         https://bugs.webkit.org/show_bug.cgi?id=192405
1460
1461         Reviewed by Michael Catanzaro.
1462
1463         * NetworkProcess/EntryPoint/unix/NetworkProcessMain.cpp:
1464         (main):
1465         * Platform/unix/EnvironmentUtilities.cpp:
1466         (WebKit::EnvironmentUtilities::stripValuesEndingWithString):
1467         * Platform/unix/LoggingUnix.cpp:
1468         (WebKit::logLevelString):
1469         * Platform/win/LoggingWin.cpp:
1470         (WebKit::logLevelString):
1471         * PluginProcess/mac/PluginProcessMac.mm:
1472         (WebKit::shouldCallRealDebugger):
1473         * Shared/Plugins/unix/PluginSearchPath.cpp:
1474         (WebKit::pluginsDirectories):
1475         * Shared/glib/ProcessExecutablePathGLib.cpp:
1476         (WebKit::findWebKitProcess):
1477         * UIProcess/API/glib/WebKitSettings.cpp:
1478         (webKitSettingsConstructed):
1479         (webKitSettingsSetProperty):
1480         * UIProcess/API/glib/WebKitWebContext.cpp:
1481         (injectedBundleDirectory):
1482         (webkitWebContextConstructed):
1483         * UIProcess/API/gtk/WebKitWebViewGtk.cpp:
1484         (webkitWebViewMaximizeWindow):
1485         (webkitWebViewRestoreWindow):
1486         * UIProcess/API/wpe/WPEView.cpp:
1487         (WKWPE::m_backend):
1488         * UIProcess/AuxiliaryProcessProxy.cpp:
1489         (WebKit::AuxiliaryProcessProxy::getLaunchOptions):
1490         * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
1491         (WebKit::XDGDBusProxyLauncher::launch):
1492         (WebKit::bindDBusSession):
1493         (WebKit::bindX11):
1494         (WebKit::bindWayland):
1495         (WebKit::bindPulse):
1496         (WebKit::bindPathVar):
1497         (WebKit::bindGStreamerData):
1498         (WebKit::bubblewrapSpawn):
1499         * UIProcess/Launcher/glib/ProcessLauncherGLib.cpp:
1500         (WebKit::ProcessLauncher::launchProcess):
1501         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
1502         (WebKit::systemDirectoryPath):
1503         (WebKit::ProcessLauncher::launchProcess):
1504         * UIProcess/glib/WebProcessPoolGLib.cpp:
1505         (WebKit::memoryPressureMonitorDisabled):
1506         (WebKit::WebProcessPool::platformInitialize):
1507         (WebKit::WebProcessPool::platformInitializeWebProcess):
1508         * UIProcess/gtk/HardwareAccelerationManager.cpp:
1509         (WebKit::HardwareAccelerationManager::HardwareAccelerationManager):
1510         * WebProcess/EntryPoint/unix/WebProcessMain.cpp:
1511         (main):
1512         * WebProcess/gtk/WebProcessMainGtk.cpp:
1513         * WebProcess/wpe/WebProcessMainWPE.cpp:
1514         Utilize WTF::Environment where possible.
1515
1516 2019-02-14  Jiewen Tan  <jiewen_tan@apple.com>
1517
1518         Handle _WKNavigationActionPolicyAllowWithoutTryingAppLink for LoadOptimizer
1519         https://bugs.webkit.org/show_bug.cgi?id=194640
1520         <rdar://problem/48064140>
1521
1522         Reviewed by Brent Fulgham.
1523
1524         * UIProcess/Cocoa/NavigationState.mm:
1525         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
1526
1527 2019-02-14  Chris Dumez  <cdumez@apple.com>
1528
1529         [PSON] Introduce a WebContent Process cache
1530         https://bugs.webkit.org/show_bug.cgi?id=194594
1531         <rdar://problem/46793397>
1532
1533         Reviewed by Geoff Garen.
1534
1535         Introduce a WebContent Process cache to reduce the number of process launches when
1536         process swap on navigation is enabled, and to reduce the power cost of the feature.
1537
1538         If a WebProcess loaded pages from a single registrable domain then it is eligible
1539         for the cache. When process-swapping on navigation to a new registrable domain, we
1540         now attempt to retrieve a process from the cache for the domain in question instead
1541         of always launching a new one.
1542
1543         The WebProcess cache currently has the following attributes:
1544         - It may contains 4 processes per GB of RAM the machine has, up to 30 processes.
1545         - WebProcesses automatically get evicted from the cache after 30 minutes.
1546         - If the application is no longer the active app, then the cache will get cleared
1547           after 5 minutes.
1548         - WebProcesses that are in the cache are reported as "(Cached)" in Activity Monitor.
1549
1550         The WebProcess cache is currently disabled by default and can by enabled by the
1551         client via SPI.
1552
1553         * Shared/WebBackForwardListItem.cpp:
1554         (WebKit::WebBackForwardListItem::WebBackForwardListItem):
1555         * Shared/WebBackForwardListItem.h:
1556         (WebKit::WebBackForwardListItem::lastProcessIdentifier const):
1557         (WebKit::WebBackForwardListItem::setLastProcessIdentifier):
1558         Add new lastProcessIdentifier data member that reflects which process this item
1559         was last loaded in. It is normally identical to the identifier of the process
1560         that created the item but it gets overriden in case of cross-site client-side
1561         redirect, since a new process takes over the item in this case.
1562
1563         * Sources.txt:
1564         Add new source file.
1565
1566         * UIProcess/API/APIProcessPoolConfiguration.cpp:
1567         (API::ProcessPoolConfiguration::copy):
1568         * UIProcess/API/APIProcessPoolConfiguration.h:
1569         * UIProcess/API/C/WKContextConfigurationRef.cpp:
1570         (WKContextConfigurationUsesWebProcessCache):
1571         (WKContextConfigurationSetUsesWebProcessCache):
1572         * UIProcess/API/C/WKContextConfigurationRef.h:
1573         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
1574         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
1575         (-[_WKProcessPoolConfiguration setUsesWebProcessCache:]):
1576         (-[_WKProcessPoolConfiguration usesWebProcessCache]):
1577         Add new SPI to enable the WebProcess cache.
1578
1579         * UIProcess/API/Cocoa/WKProcessPool.mm:
1580         (-[WKProcessPool _webProcessCountIgnoringPrewarmedAndCached]):
1581         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
1582         Add new SPI for testing which returns the number of WebProcesses ignoring
1583         both prewarmed and cached ones.
1584
1585         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1586         (WebKit::WebProcessPool::registerNotificationObservers):
1587         (WebKit::WebProcessPool::unregisterNotificationObservers):
1588         Add application active state observers as the WebProcess cache gets cleared
1589         when the application resigns active state for more than 5 minutes.
1590
1591         * UIProcess/ProvisionalPageProxy.cpp:
1592         (WebKit::ProvisionalPageProxy::loadRequest):
1593         When doing a load in a new process with the BackForwardList locked (i.e. client-side
1594         redirect), make sure we update the last process identifier for the BackForwardListItem.
1595         This is important because the logic in WebProcessPool::processForNavigation() relies on
1596         this identifier to select which process to do the history navigation into, and we want
1597         to do the load in the post-redirect process, not the pre-redirect one.
1598
1599         * UIProcess/WebPageProxy.cpp:
1600         (WebKit::WebPageProxy::didStartProvisionalLoadForFrameShared):
1601         Tell the WebProcess whenever a main frame provisional load is started, providing the URL.
1602
1603         * UIProcess/WebProcessCache.cpp: Added.
1604         (WebKit::WebProcessCache::WebProcessCache):
1605         (WebKit::WebProcessCache::addProcess):
1606         (WebKit::WebProcessCache::takeProcess):
1607         (WebKit::WebProcessCache::updateMaximumSize):
1608         (WebKit::WebProcessCache::clear):
1609         (WebKit::WebProcessCache::setApplicationIsActive):
1610         (WebKit::WebProcessCache::evictProcess):
1611         (WebKit::WebProcessCache::CachedProcess::CachedProcess):
1612         (WebKit::WebProcessCache::CachedProcess::~CachedProcess):
1613         (WebKit::WebProcessCache::CachedProcess::takeProcess):
1614         (WebKit::WebProcessCache::CachedProcess::evictionTimerFired):
1615         * UIProcess/WebProcessCache.h: Added.
1616         (WebKit::WebProcessCache::maximumSize):
1617         (WebKit::WebProcessCache::size const):
1618         (WebKit::WebProcessCache::CachedProcess::process):
1619         Add process cache implementation.
1620
1621         * UIProcess/WebProcessPool.cpp:
1622         (WebKit::m_webProcessCache):
1623         WebProcessCache is stored on the WebProcessPool via m_webProcessCache data member.
1624
1625         (WebKit::WebProcessPool::~WebProcessPool):
1626         Clear the WebProcess cache in the destructor.
1627
1628         (WebKit::WebProcessPool::setApplicationIsActive):
1629         Notify the WebProcessCache whenever the application's active state changes.
1630
1631         (WebKit::WebProcessPool::createWebPage):
1632         If the state of PSON changes via the experimental features menu, dynamically
1633         update the WebProcessCache's size. This is needed because the cache is disabled
1634         when PSON is disabled.
1635
1636         (WebKit::WebProcessPool::handleMemoryPressureWarning):
1637         Clear the WebProcess cache on memory pressure.
1638
1639         (WebKit::WebProcessPool::processForNavigationInternal):
1640         Query the WebProcessCache before attempting to create a new WebProcess for a cross-site
1641         navigation.
1642
1643         (WebKit::WebProcessPool::findReusableSuspendedPageProcess):
1644         This logic was split out of processForNavigationInternal() to reduce the size
1645         of the method.
1646
1647         * UIProcess/WebProcessPool.h:
1648         * UIProcess/WebProcessProxy.cpp:
1649         (WebKit::WebProcessProxy::setIsInProcessCache):
1650         Update the isInProcessCache flag on the WebProcessProxy and send an IPC to the WebContent
1651         process so that it can update its name in Activity Monitor.
1652         We also need to stop holding a strong reference to the WebProcessPool whenever the process
1653         is in the cache, similarly to what we do for pre-warmed processes, given that such processes
1654         should not keep the process pool alive.
1655
1656         (WebKit::WebProcessProxy::addExistingWebPage):
1657         Assert that we never try to add a page to a cached process, it should be taken out of the
1658         cache before use.
1659
1660         (WebKit::WebProcessProxy::hasProvisionalPageWithID const):
1661         (WebKit::WebProcessProxy::isAllowedToUpdateBackForwardItem const):
1662         (WebKit::WebProcessProxy::updateBackForwardItem):
1663         In case of client-side redirects, the previous process would sometimes send an IPC causing
1664         the UIProcess' backforward list item to get updated with the pre-redirect URL after we've
1665         already redirected. This previously would be unlikely to occur because we do not suspend
1666         client-redirect pages and their process would normally exit before getting a chance to send
1667         the IPC. However, with the process cache, the bug became obvious as the process would stay
1668         alive and send up the "bad" IPC. To address the issue, we now only let the IPC update the
1669         item if the item's page is (still) associated with the process. In the future, we may want
1670         to update the IPC so that it gets sent to the WebPageProxy instead of the WebProcessProxy.
1671
1672         (WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
1673         If a cached WebProcess crashes, remove it from the cache so that we do not attempt to use
1674         it for a load later.
1675
1676         (WebKit::WebProcessProxy::canBeAddedToWebProcessCache const):
1677         Only cache WebProcesses that have loaded a single registrable domain. Also prevent caching
1678         for service worker and inspector processes.
1679
1680         (WebKit::WebProcessProxy::maybeShutDown):
1681         If the process is cacheable, add it to the cache instead of shutting it down right away.
1682
1683         (WebKit::WebProcessProxy::canTerminateAuxiliaryProcess):
1684         Make sure we do not attempt to terminate a processes that is in the cache.
1685
1686         (WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame):
1687         Whenever a main frame provisional load starts, make sure we update the process's associated
1688         registrable domain. nullopt indicates that there is no associated domain yet. Null string
1689         indicates that the process is associated with several registrable domain and is therefore
1690         not eligible for caching.
1691
1692         * UIProcess/WebProcessProxy.h:
1693         (WebKit::WebProcessProxy::registrableDomain const):
1694         (WebKit::WebProcessProxy::isInProcessCache const):
1695         (WebKit::WebProcessProxy::provisionalPageCount const):
1696         Add convenience getters.
1697
1698         * WebKit.xcodeproj/project.pbxproj:
1699         Add new files to project.
1700
1701         * WebProcess/WebProcess.cpp:
1702         (WebKit::WebProcess::setIsInProcessCache):
1703         * WebProcess/WebProcess.h:
1704         * WebProcess/WebProcess.messages.in:
1705         * WebProcess/cocoa/WebProcessCocoa.mm:
1706         (WebKit::WebProcess::updateProcessName):
1707         Update the WebProcess' name in Activity Monitor whenever it goes into or out of the WebProcess
1708         cache.
1709
1710 2019-02-14  Per Arne Vollan  <pvollan@apple.com>
1711
1712         [iOS] Open sandbox for certain calls.
1713         https://bugs.webkit.org/show_bug.cgi?id=194626
1714
1715         Reviewed by Brent Fulgham.
1716
1717         Reporting shows that certain calls needs to be allowed in the sandbox.
1718
1719         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
1720
1721 2019-02-14  Chris Fleizach  <cfleizach@apple.com>
1722
1723         AX: ARIA Reflection was disabled in error
1724         https://bugs.webkit.org/show_bug.cgi?id=194647
1725         <rdar://problem/48068336>
1726
1727         Reviewed by Ryosuke Niwa.
1728
1729         * Shared/WebPreferences.yaml:
1730
1731 2019-02-14  Commit Queue  <commit-queue@webkit.org>
1732
1733         Unreviewed, rolling out r241486.
1734         https://bugs.webkit.org/show_bug.cgi?id=194655
1735
1736         causing API failures in builds (Requested by ShawnRoberts on
1737         #webkit).
1738
1739         Reverted changeset:
1740
1741         "[Cocoa] Media elements will restart network buffering just
1742         before suspending"
1743         https://bugs.webkit.org/show_bug.cgi?id=193691
1744         https://trac.webkit.org/changeset/241486
1745
1746 2019-02-14  Youenn Fablet  <youenn@apple.com>
1747
1748         Do not add a caches to its engine if the salt cannot be initialized
1749         https://bugs.webkit.org/show_bug.cgi?id=194604
1750
1751         Reviewed by Antti Koivisto.
1752
1753         This is a follow-up to https://bugs.webkit.org/show_bug.cgi?id=194588.
1754         We should return early if initialize fails.
1755
1756         * NetworkProcess/cache/CacheStorageEngine.cpp:
1757         (WebKit::CacheStorage::Engine::readCachesFromDisk):
1758
1759 2019-02-13  Carlos Garcia Campos  <cgarcia@igalia.com>
1760
1761         [GTK] Use a scrolled window for script alerts text
1762         https://bugs.webkit.org/show_bug.cgi?id=184875
1763
1764         Reviewed by Michael Catanzaro.
1765
1766         To ensure long text doesn't make the dialog bigger.
1767
1768         * UIProcess/API/gtk/WebKitScriptDialogImpl.cpp:
1769         (webkitScriptDialogImplConstructed): Use PANGO_ELLIPSIZE_END for the title and add a scrolled window for the body.
1770         (webkitScriptDialogImplSetText): Helper function to set the dialog body, ensuring the scrolled window fills the
1771         dialog available size.
1772         (webkitScriptDialogImplNew): It now receives the maximum size and uses webkitScriptDialogImplSetText().
1773         * UIProcess/API/gtk/WebKitScriptDialogImpl.h:
1774         * UIProcess/API/gtk/WebKitWebViewGtk.cpp:
1775         (webkitWebViewScriptDialog): Pass the 80% of the web view size as the maximum size of script dialogs.
1776
1777 2019-02-13  Ryosuke Niwa  <rniwa@webkit.org>
1778
1779         Crash in WKBundleFrameGetParentFrame when called inside didRemoveFrameFromHierarchy
1780         https://bugs.webkit.org/show_bug.cgi?id=194641
1781
1782         Reviewed by Geoffrey Garen.
1783
1784         Fixed the bug by adding a null check to WebFrame::parentFrame.
1785
1786         * WebProcess/WebPage/WebFrame.cpp:
1787         (WebKit::WebFrame::parentFrame const):
1788
1789 2019-02-13  Timothy Hatcher  <timothy@apple.com>
1790
1791         Allow some deprecations in WKDrawingView.
1792         https://bugs.webkit.org/show_bug.cgi?id=194636
1793
1794         Reviewed by Wenson Hsieh.
1795
1796         * UIProcess/ios/WKDrawingView.mm:
1797         (-[WKDrawingView PNGRepresentation]):
1798         (-[WKDrawingView loadDrawingFromPNGRepresentation:]):
1799         (-[WKDrawingView _canvasViewWillBeginDrawing:]):
1800         (-[WKDrawingView didChangeInk:]):
1801
1802 2019-02-13  Jer Noble  <jer.noble@apple.com>
1803
1804         [Cocoa] Media elements will restart network buffering just before suspending
1805         https://bugs.webkit.org/show_bug.cgi?id=193691
1806
1807         Reviewed by Eric Carlson.
1808
1809         When the WebProcess receives a notification that the process is about to become
1810         suspended, it tells the MemoryPressureHandler to release all critical memory. This
1811         has the side effect of causing AVFoundation-backed media elements to dump their
1812         in-memory caches and start downloading media data again. Instead, media elements
1813         should all stop buffering media data during suspension. Add new testing SPI to
1814         simulate suspension and resume messages.
1815
1816         * UIProcess/API/Cocoa/WKWebView.mm:
1817         (-[WKWebView _processWillSuspendImminentlyForTesting]):
1818         (-[WKWebView _processDidResumeForTesting]):
1819         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1820         * UIProcess/WebProcessProxy.h:
1821         * UIProcess/ios/WKInkPickerView.mm:
1822         * WebProcess/WebPage/WebPage.cpp:
1823         (WebKit::WebPage::suspendAllMediaBuffering):
1824         (WebKit::WebPage::resumeAllMediaBuffering):
1825         * WebProcess/WebPage/WebPage.h:
1826         * WebProcess/WebProcess.cpp:
1827         (WebKit::WebProcess::actualPrepareToSuspend):
1828         (WebKit::WebProcess::cancelPrepareToSuspend):
1829         (WebKit::WebProcess::processDidResume):
1830         (WebKit::WebProcess::suspendAllMediaBuffering):
1831         (WebKit::WebProcess::resumeAllMediaBuffering):
1832         * WebProcess/WebProcess.h:
1833
1834 2019-02-13  Per Arne Vollan  <pvollan@apple.com>
1835
1836         [iOS] Fix sandbox violation during media playback
1837         https://bugs.webkit.org/show_bug.cgi?id=194616
1838         <rdar://problem/48049264>
1839
1840         Reviewed by Brent Fulgham.
1841
1842         Mach lookup to "com.apple.coremedia.figcontentkeysession.xpc" should be allowed.
1843
1844         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
1845
1846 2019-02-13  Tim Horton  <timothy_horton@apple.com>
1847
1848         Encrypted PDFs inside <embed> or <object> crash the Web Content process
1849         https://bugs.webkit.org/show_bug.cgi?id=194605
1850         <rdar://problem/19894818>
1851
1852         Reviewed by Andy Estes.
1853
1854         * WebProcess/Plugins/PDF/PDFPlugin.mm:
1855         (WebKit::PDFPlugin::createPasswordEntryForm):
1856         Don't try to create a password form field if we can't make form fields.
1857
1858         This means you will be left with a useless embedded PDF, but at least
1859         the Web Content process won't crash.
1860
1861         We'll need to find an alternative implementation of PDF embedded form
1862         fields that is compatible with <embed> and <object> if we want to support
1863         this. Currently we piggy-back off the fact that we can just insert
1864         <input>s into the PluginDocument's DOM, but we can't do that if there
1865         is no PluginDocument, just a main document, like in the <embed> case.
1866
1867 2019-02-12  Jiewen Tan  <jiewen_tan@apple.com>
1868
1869         Further restricting webarchive loads
1870         https://bugs.webkit.org/show_bug.cgi?id=194567
1871         <rdar://problem/47610130>
1872
1873         Reviewed by Youenn Fablet.
1874
1875         * WebProcess/WebPage/WebPage.cpp:
1876         (WebKit::WebPage::loadRequest):
1877         Set a flag to indicate a load is started from clients.
1878
1879 2019-02-13  Michael Catanzaro  <mcatanzaro@igalia.com>
1880
1881         [WPE][GTK] Merge WebProcessPoolWPE.cpp and WebProcessPoolGtk.cpp
1882         https://bugs.webkit.org/show_bug.cgi?id=194551
1883
1884         Reviewed by Carlos Garcia Campos.
1885
1886         * SourcesGTK.txt:
1887         * SourcesWPE.txt:
1888         * UIProcess/glib/WebProcessPoolGLib.cpp: Renamed from Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp.
1889         (WebKit::initializeRemoteInspectorServer):
1890         (WebKit::memoryPressureMonitorDisabled):
1891         (WebKit::WebProcessPool::platformInitialize):
1892         (WebKit::WebProcessPool::platformInitializeWebProcess):
1893         (WebKit::WebProcessPool::platformInvalidateContext):
1894         (WebKit::WebProcessPool::platformResolvePathsForSandboxExtensions):
1895         * UIProcess/wpe/WebProcessPoolWPE.cpp: Removed.
1896
1897 2019-02-13  Michael Catanzaro  <mcatanzaro@igalia.com>
1898
1899         Fix -Wformat warning from r241401
1900         https://bugs.webkit.org/show_bug.cgi?id=194584
1901         <rdar://problem/47761293>
1902
1903         * WebProcess/WebPage/WebPage.cpp:
1904         (WebKit::WebPage::setActivityState):
1905
1906 2019-02-13  Youenn Fablet  <youenn@apple.com>
1907
1908         Make WebRTCUnifiedPlanEnabled true by default
1909         https://bugs.webkit.org/show_bug.cgi?id=194595
1910
1911         Reviewed by Eric Carlson.
1912
1913         * Shared/WebPreferences.yaml:
1914
1915 2019-02-13  John Wilander  <wilander@apple.com>
1916
1917         Store Ad Click Attribution requests in the network process
1918         https://bugs.webkit.org/show_bug.cgi?id=194510
1919         <rdar://problem/47650118>
1920
1921         Reviewed by Alex Christensen and Daniel Bates.
1922
1923         With this patch, WebPageProxy::didCommitLoadForFrame() now looks for
1924         an AdClickAttribution object in its navigation state. If there is an
1925         attribution, it sends it to the network process where the 
1926         WebKit::NetworkSession stores it in an object of a new class,
1927         WebKit::NetworkAdClickAttribution.
1928
1929         This patch also covers test infrastructure to support two new
1930         TestRunner functions:
1931         - dumpAdClickAttribution()
1932         - clearAdClickAttribution()
1933
1934         * NetworkProcess/Cookies/WebCookieManager.cpp:
1935             Added missing header include.
1936         * NetworkProcess/Downloads/DownloadManager.cpp:
1937             Added missing header include.
1938         * NetworkProcess/NetworkAdClickAttribution.cpp: Added.
1939         (WebKit::NetworkAdClickAttribution::ensureDestinationMapForSource):
1940         (WebKit::NetworkAdClickAttribution::store):
1941         (WebKit::NetworkAdClickAttribution::clear):
1942         (WebKit::NetworkAdClickAttribution::toString const):
1943         * NetworkProcess/NetworkAdClickAttribution.h: Added.
1944             Stores WebCore::AdClickAttribution objects in a map structure.
1945         * NetworkProcess/NetworkLoad.cpp:
1946             Added missing header includes.
1947         * NetworkProcess/NetworkProcess.cpp:
1948         (WebKit::NetworkProcess::storeAdClickAttribution):
1949         (WebKit::NetworkProcess::dumpAdClickAttribution):
1950         (WebKit::NetworkProcess::clearAdClickAttribution):
1951         * NetworkProcess/NetworkProcess.h:
1952         * NetworkProcess/NetworkProcess.messages.in:
1953         * NetworkProcess/NetworkSession.cpp:
1954         (WebKit::NetworkSession::NetworkSession):
1955         (WebKit::NetworkSession::storeAdClickAttribution):
1956         (WebKit::NetworkSession::dumpAdClickAttribution):
1957         (WebKit::NetworkSession::clearAdClickAttribution):
1958         * NetworkProcess/NetworkSession.h:
1959         * NetworkProcess/soup/RemoteNetworkingContextSoup.cpp:
1960             Added missing header include.
1961         * Sources.txt:
1962             Added NetworkProcess/NetworkAdClickAttribution.cpp.
1963         * UIProcess/API/APINavigation.h:
1964         (API::Navigation::adClickAttribution const):
1965         * UIProcess/API/C/WKPage.cpp:
1966         (WKPageDumpAdClickAttribution):
1967         (WKPageClearAdClickAttribution):
1968             Test infrastructure.
1969         * UIProcess/API/C/WKPagePrivate.h:
1970         * UIProcess/Network/NetworkProcessProxy.cpp:
1971         (WebKit::NetworkProcessProxy::dumpAdClickAttribution):
1972         (WebKit::NetworkProcessProxy::clearAdClickAttribution):
1973             Test infrastructure.
1974         * UIProcess/Network/NetworkProcessProxy.h:
1975         * UIProcess/WebPageProxy.cpp:
1976         (WebKit::WebPageProxy::didFinishDocumentLoadForFrame):
1977             This is where pending Ad Click Attributions are forwarded to the
1978             network process.
1979         (WebKit::WebPageProxy::dumpAdClickAttribution):
1980         (WebKit::WebPageProxy::clearAdClickAttribution):
1981             Test infrastructure.
1982         * UIProcess/WebPageProxy.h:
1983         * UIProcess/WebProcessPool.cpp:
1984         (WebKit::WebProcessPool::dumpAdClickAttribution):
1985         (WebKit::WebProcessPool::clearAdClickAttribution):
1986             Test infrastructure.
1987         * UIProcess/WebProcessPool.h:
1988         * WebKit.xcodeproj/project.pbxproj:
1989         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1990         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
1991             Added missing data copying from navigationAction to navigationActionData.
1992
1993 2019-02-13  Antti Koivisto  <antti@apple.com>
1994
1995         Crash in WebKit::CacheStorage::Engine::cachesRootPath
1996         https://bugs.webkit.org/show_bug.cgi?id=194588
1997         <rdar://problem/46363997>
1998
1999         Reviewed by Youenn Fablet.
2000
2001         * NetworkProcess/cache/CacheStorageEngine.cpp:
2002         (WebKit::CacheStorage::Engine::cachesRootPath):
2003
2004         Salt may have not been initialized yet when the Engine is destroyed.
2005
2006 2019-02-13  Alex Christensen  <achristensen@webkit.org>
2007
2008         Remove legacy sync messaging in some IPC code
2009         https://bugs.webkit.org/show_bug.cgi?id=194561
2010
2011         Reviewed by Geoffrey Garen.
2012
2013         Changing some LegacySync messages to Delayed messages.  We should probably rename Delayed to Sync.
2014         There are too many ways to send messages.  Let's work to get rid of the old one.
2015
2016         * NetworkProcess/NetworkProcess.cpp:
2017         (WebKit::NetworkProcess::setAllowsAnySSLCertificateForWebSocket):
2018         (WebKit::NetworkProcess::processWillSuspendImminently):
2019         * NetworkProcess/NetworkProcess.h:
2020         * NetworkProcess/NetworkProcess.messages.in:
2021         * PluginProcess/PluginControllerProxy.cpp:
2022         (WebKit::PluginControllerProxy::handleWheelEvent):
2023         (WebKit::PluginControllerProxy::handleMouseEnterEvent):
2024         (WebKit::PluginControllerProxy::handleMouseLeaveEvent):
2025         (WebKit::PluginControllerProxy::handleKeyboardEvent):
2026         (WebKit::PluginControllerProxy::handleEditingCommand):
2027         (WebKit::PluginControllerProxy::isEditingCommandEnabled):
2028         (WebKit::PluginControllerProxy::handlesPageScaleFactor):
2029         (WebKit::PluginControllerProxy::requiresUnifiedScaleFactor):
2030         (WebKit::PluginControllerProxy::paintEntirePlugin):
2031         (WebKit::PluginControllerProxy::supportsSnapshotting):
2032         (WebKit::PluginControllerProxy::snapshot):
2033         (WebKit::PluginControllerProxy::getPluginScriptableNPObject):
2034         (WebKit::PluginControllerProxy::getFormValue):
2035         * PluginProcess/PluginControllerProxy.h:
2036         * PluginProcess/PluginControllerProxy.messages.in:
2037         * Shared/Plugins/NPObjectMessageReceiver.cpp:
2038         (WebKit::NPObjectMessageReceiver::deallocate):
2039         (WebKit::NPObjectMessageReceiver::hasMethod):
2040         (WebKit::NPObjectMessageReceiver::invoke):
2041         (WebKit::NPObjectMessageReceiver::invokeDefault):
2042         (WebKit::NPObjectMessageReceiver::hasProperty):
2043         (WebKit::NPObjectMessageReceiver::getProperty):
2044         (WebKit::NPObjectMessageReceiver::setProperty):
2045         (WebKit::NPObjectMessageReceiver::removeProperty):
2046         (WebKit::NPObjectMessageReceiver::enumerate):
2047         (WebKit::NPObjectMessageReceiver::construct):
2048         * Shared/Plugins/NPObjectMessageReceiver.h:
2049         * Shared/Plugins/NPObjectMessageReceiver.messages.in:
2050         * UIProcess/mac/SecItemShimProxy.cpp:
2051         (WebKit::SecItemShimProxy::secItemRequest):
2052         * UIProcess/mac/SecItemShimProxy.h:
2053         * UIProcess/mac/SecItemShimProxy.messages.in:
2054
2055 2019-02-13  Truitt Savell  <tsavell@apple.com>
2056
2057         Unreviewed, rolling out r241433.
2058
2059         Broke internal builds.
2060
2061         Reverted changeset:
2062
2063         "Move
2064         UIWebTouchEventsGestureRecognizer.activeTouchesByIdentifier to
2065         SPI"
2066         https://bugs.webkit.org/show_bug.cgi?id=194531
2067         https://trac.webkit.org/changeset/241433
2068
2069 2019-02-12  Antoine Quint  <graouts@apple.com>
2070
2071         Move UIWebTouchEventsGestureRecognizer.activeTouchesByIdentifier to SPI
2072         https://bugs.webkit.org/show_bug.cgi?id=194531
2073         <rdar://problem/47714562>
2074
2075         Reviewed by Dean Jackson.
2076
2077         * Platform/spi/ios/UIKitSPI.h:
2078         * UIProcess/ios/WKContentViewInteraction.mm:
2079         (-[WKContentView cancelPointersForGestureRecognizer:]): We update the referenced Radar since we need to keep the call
2080         to respondsToSelector until the SPI has shipped for OpenSource builds to work.
2081
2082 2019-02-13  Antoine Quint  <graouts@apple.com>
2083
2084         Support simulated mouse events on iOS based on a PlatformTouchEvent
2085         https://bugs.webkit.org/show_bug.cgi?id=194501
2086         <rdar://problem/46910790>
2087
2088         Reviewed by Dean Jackson.
2089
2090         Add two new internal runtime flags to control whether simulated mouse events should be dipatched along with touch events and whether
2091         simulated mousemove events dispatched should automatically trigger the behavior preventDefault() would also trigger. We also ensure
2092         that we correctly create touch tracking regions for mouse events.
2093
2094         * Shared/WebPreferences.yaml:
2095         * UIProcess/WebPageProxy.cpp:
2096         (WebKit::WebPageProxy::updateTouchEventTracking):
2097
2098 2019-02-13  Ryosuke Niwa  <rniwa@webkit.org>
2099
2100         Crash in Page::setActivityState because m_page is null
2101         https://bugs.webkit.org/show_bug.cgi?id=194584
2102
2103         Reviewed by Antti Koivisto.
2104
2105         Add a null check to avoid the crash. Also add a debug assertion to help diagnose this in the future.
2106
2107         * WebProcess/WebPage/WebPage.cpp:
2108         (WebKit::WebPage::setActivityState):
2109
2110 2019-02-13  Ryosuke Niwa  <rniwa@webkit.org>
2111
2112         Release assert in PolicyCheckIdentifier::isValidFor via WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction
2113         https://bugs.webkit.org/show_bug.cgi?id=194582
2114
2115         Reviewed by Antti Koivisto.
2116
2117         The bug was caused by WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction invoking the callback
2118         with responseIdentifier even when we had failed to send the policy check IPC. Clearly, responseIdentifier
2119         is invalid in that case, and we should be using requestIdentifier instead.
2120
2121         Unfortunately no new tests since I'm not aware of a way to make sendSync fail in this case.
2122
2123         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2124         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
2125
2126 2019-02-13  Benjamin Poulain  <benjamin@webkit.org>
2127
2128         Responsiveness timers are too expensive for frequent events
2129         https://bugs.webkit.org/show_bug.cgi?id=194003
2130
2131         Reviewed by Geoffrey Garen.
2132
2133         With each event, we set a responsivness timer to check if the WebProcess
2134         is responsive, and reset the timer when the WebProcess sends an answer.
2135
2136         For frequent events (e.g. wheel events, mouse force events, etc),
2137         we are spamming the kernel with hundreds of timers per second.
2138         That is a bit inefficient.
2139
2140         Another source of inefficiency comes from the timer implementation
2141         itself. Stopping a RunLoop::Timer removes the timer from every mode
2142         and invalidate the timer. It becomes costly since we do it a lot.
2143
2144         With this patch, I tweak ResponsivenessTimer and its use to minimize
2145         how often we schedule system timers.
2146
2147         The first change is to not stop the timer when we get the stop()
2148         calls if we expect more events to come in. Instead, we keep track
2149         if we care about the timeout or not in the attribute "m_waitingForTimer".
2150         When the next event starts, we can reschedule the timer without ever
2151         having told the kernel about the stop.
2152         If there are no next events, the timeout fires but m_waitingForTimer
2153         is false. To avoid idle wake up, the lazy stop is only used when having
2154         following events is common.
2155
2156         The second improvements comes from not even rescheduling the timer
2157         when restarted. Instead of changing the timer, we let the original timer
2158         fire and re-shedule a new one with the missing time.
2159
2160         For more context, also see patches r240759 and r240944.
2161
2162         * UIProcess/ResponsivenessTimer.cpp:
2163         (WebKit::ResponsivenessTimer::ResponsivenessTimer):
2164         (WebKit::ResponsivenessTimer::invalidate):
2165         (WebKit::ResponsivenessTimer::timerFired):
2166         (WebKit::ResponsivenessTimer::start):
2167         (WebKit::ResponsivenessTimer::startWithLazyStop):
2168         (WebKit::ResponsivenessTimer::stop):
2169         (WebKit::ResponsivenessTimer::processTerminated):
2170         (WebKit::ResponsivenessTimer::~ResponsivenessTimer): Deleted.
2171         * UIProcess/ResponsivenessTimer.h:
2172         (WebKit::ResponsivenessTimer::hasActiveTimer const):
2173         * UIProcess/WebPageProxy.cpp:
2174         (WebKit::WebPageProxy::processNextQueuedMouseEvent):
2175         (WebKit::WebPageProxy::sendWheelEvent):
2176         (WebKit::WebPageProxy::handleKeyboardEvent):
2177         (WebKit::WebPageProxy::handleGestureEvent):
2178         * UIProcess/WebProcessProxy.cpp:
2179         (WebKit::WebProcessProxy::isResponsiveWithLazyStop):
2180         * UIProcess/WebProcessProxy.h:
2181
2182 2019-02-12  Tim Horton  <timothy_horton@apple.com>
2183
2184         Null deref in userInterfaceLayoutDirection under ViewGestureController::handleSwipeGesture
2185         https://bugs.webkit.org/show_bug.cgi?id=194569
2186         <rdar://problem/46711049>
2187
2188         Reviewed by Wenson Hsieh.
2189
2190         * UIProcess/mac/ViewGestureControllerMac.mm:
2191         (WebKit::ViewGestureController::handleSwipeGesture):
2192         It is conceivable that we could get here if the client closes the page
2193         e.g. in the callback from willEndSwipeGesture. We already guarded against
2194         this ... one line too late! Rearrange the lines so we don't call into
2195         WebPageProxy at all if we don't have a drawing area (which is a strict subset
2196         of the time that isValid would return true). This is a speculative fix,
2197         since I can no longer reproduce the crash on demand.
2198
2199 2019-02-12  Youenn Fablet  <youenn@apple.com>
2200
2201         WebServiceWorkerProvider::handleFetch no longer needs a CachedResource parameter
2202         https://bugs.webkit.org/show_bug.cgi?id=194548
2203
2204         Reviewed by Alex Christensen.
2205
2206         * WebProcess/Network/WebLoaderStrategy.cpp:
2207         (WebKit::WebLoaderStrategy::scheduleLoad):
2208         * WebProcess/Storage/WebServiceWorkerProvider.cpp:
2209         (WebKit::WebServiceWorkerProvider::handleFetch):
2210         * WebProcess/Storage/WebServiceWorkerProvider.h:
2211
2212 2019-02-12  Tim Horton  <timothy_horton@apple.com>
2213
2214         Remove WKLegacyPDFView
2215         https://bugs.webkit.org/show_bug.cgi?id=194559
2216
2217         Reviewed by Andy Estes.
2218
2219         * Platform/spi/ios/CorePDFSPI.h: Removed.
2220         * SourcesCocoa.txt:
2221         * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
2222         (-[WKWebViewContentProviderRegistry initWithConfiguration:]):
2223         * UIProcess/ios/WKLegacyPDFView.h: Removed.
2224         * UIProcess/ios/WKLegacyPDFView.mm: Removed.
2225         * WebKit.xcodeproj/project.pbxproj:
2226
2227 2019-02-12  Chris Dumez  <cdumez@apple.com>
2228
2229         Regression(PSON) MESSAGE_CHECK() hit under WebPageProxy::didFailProvisionalLoadForFrameShared()
2230         https://bugs.webkit.org/show_bug.cgi?id=194568
2231         <rdar://problem/47944490>
2232
2233         Reviewed by Ryosuke Niwa.
2234
2235         When the provisional process crashes, it is unsafe to call ProvisionalPageProxy::cancel() because
2236         the WebProcessProxy clears its frame map as soon as the process crashes. Calling cancel() after
2237         that would call WebPageProxy::didFailProvisionalLoadForFrameShared(), which would try to look up
2238         the frame by ID and MESSAGE_CHECK() that the frame is not null. We would fail this check since
2239         the frame has been removed from the WebProcessProxy at this point.
2240
2241         * UIProcess/API/Cocoa/WKWebView.mm:
2242         (-[WKWebView _provisionalWebProcessIdentifier]):
2243         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2244         * UIProcess/WebPageProxy.cpp:
2245         (WebKit::WebPageProxy::didFailProvisionalLoadForFrameShared):
2246         (WebKit::WebPageProxy::provisionalProcessDidTerminate):
2247
2248 2019-02-12  Per Arne Vollan  <pvollan@apple.com>
2249
2250         [iOS] Youtube fails to play.
2251         https://bugs.webkit.org/show_bug.cgi?id=194565
2252         <rdar://problem/47974770>
2253
2254         Reviewed by Geoffrey Garen.
2255
2256         This is caused by sandbox violations and was introduced in r240500.
2257
2258         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
2259
2260 2019-02-12  Alex Christensen  <achristensen@webkit.org>
2261
2262         Remove firing assertion after r241317
2263         https://bugs.webkit.org/show_bug.cgi?id=194506
2264
2265         * WebProcess/Network/WebLoaderStrategy.cpp:
2266         (WebKit::WebLoaderStrategy::setDefersLoading):
2267         The creation of a PageGroupLoadDeferrer in Chrome.cpp tries to defer loading.
2268         See comments in Chrome::runJavaScriptAlert et al.
2269         This was necessary with WebKitLegacy, so keep it, but it doesn't need to do anything in modern WebKit.
2270
2271 2019-02-12  Tim Horton  <timothy_horton@apple.com>
2272
2273         Find on Page shouldn't zoom in on matches
2274         https://bugs.webkit.org/show_bug.cgi?id=194557
2275         <rdar://problem/42087017>
2276
2277         Reviewed by Wenson Hsieh.
2278
2279         * UIProcess/ios/SmartMagnificationController.h:
2280         * UIProcess/ios/SmartMagnificationController.messages.in:
2281         * UIProcess/ios/SmartMagnificationController.mm:
2282         (WebKit::SmartMagnificationController::scrollToRect):
2283         * WebProcess/WebPage/ios/FindControllerIOS.mm:
2284         (WebKit::FindController::updateFindIndicator):
2285         Only scroll to reveal the find result, do not zoom in.
2286
2287 2019-02-12  Wenson Hsieh  <wenson_hsieh@apple.com>
2288
2289         Allow pages to trigger programmatic paste from script on iOS
2290         https://bugs.webkit.org/show_bug.cgi?id=194271
2291         <rdar://problem/47808810>
2292
2293         Reviewed by Tim Horton.
2294
2295         Cancel the pending DOM paste access handler when the menu is about to hide, rather than when the hiding
2296         animation has completed. This ensures that if the page (on behalf of the user) requests DOM paste again during
2297         user interaction before the callout bar has finished fading after the previous DOM paste, we won't automatically
2298         cancel the incoming DOM paste access request because the callout bar animation finished.
2299
2300         This scenario is exercised in the layout test editing/pasteboard/ios/dom-paste-consecutive-confirmations.html.
2301
2302         * Platform/spi/ios/UIKitSPI.h:
2303         * UIProcess/ios/WKContentViewInteraction.mm:
2304         (-[WKContentView setupInteraction]):
2305         (-[WKContentView _willHideMenu:]):
2306         (-[WKContentView _didHideMenu:]):
2307
2308 2019-02-12  Chris Fleizach  <cfleizach@apple.com>
2309
2310         AX: IsolatedTree: Implement more attributes
2311         https://bugs.webkit.org/show_bug.cgi?id=193911
2312         <rdar://problem/47599217>
2313
2314         Reviewed by Daniel Bates.
2315
2316         * Platform/spi/mac/AccessibilityPrivSPI.h: Added.
2317         * WebKit.xcodeproj/project.pbxproj:
2318         * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.h:
2319         * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
2320         (-[WKAccessibilityWebPageObjectBase clientSupportsIsolatedTree]):
2321         (-[WKAccessibilityWebPageObjectBase isolatedTreeRootObject]):
2322         (-[WKAccessibilityWebPageObjectBase accessibilityRootObjectWrapper]):
2323         * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
2324         (-[WKAccessibilityWebPageObject IGNORE_WARNINGS_END]):
2325         (-[WKAccessibilityWebPageObject convertScreenPointToRootView:]):
2326         (-[WKAccessibilityWebPageObject accessibilityAttributeValue:]):
2327         (-[WKAccessibilityWebPageObject accessibilityAttributeSizeValue]):
2328         (-[WKAccessibilityWebPageObject accessibilityAttributePositionValue]):
2329         (-[WKAccessibilityWebPageObject accessibilityDataDetectorValue:point:]):
2330         (-[WKAccessibilityWebPageObject accessibilityAttributeValue:forParameter:]):
2331         (-[WKAccessibilityWebPageObject accessibilityHitTest:]):
2332
2333 2019-02-12  Wenson Hsieh  <wenson_hsieh@apple.com>
2334
2335         Allow pages to trigger programmatic paste from script on iOS
2336         https://bugs.webkit.org/show_bug.cgi?id=194271
2337         <rdar://problem/47808810>
2338
2339         Reviewed by Ryosuke Niwa.
2340
2341         * Shared/WebPreferences.yaml:
2342         * Shared/WebPreferencesDefaultValues.h:
2343
2344         Add an internal setting to enable or disable DOM paste access requests. This is on by default in iOS only
2345         (excluding watchOS and Apple TV), and is additionally disabled on macOS.
2346
2347         * UIProcess/API/gtk/PageClientImpl.cpp:
2348         (WebKit::PageClientImpl::requestDOMPasteAccess):
2349         * UIProcess/API/gtk/PageClientImpl.h:
2350         * UIProcess/API/wpe/PageClientImpl.cpp:
2351         (WebKit::PageClientImpl::requestDOMPasteAccess):
2352
2353         Plumb DOM paste access requests from the web process (WebEditorClient) to the view (WKContentView). As per the
2354         usual, this involves WebEditorClient, WebPage, WebPageProxy, PageClient and finally WKContentView.
2355
2356         * UIProcess/API/wpe/PageClientImpl.h:
2357         * UIProcess/PageClient.h:
2358         * UIProcess/WebPageProxy.cpp:
2359         (WebKit::WebPageProxy::requestDOMPasteAccess):
2360         * UIProcess/WebPageProxy.h:
2361         * UIProcess/WebPageProxy.messages.in:
2362         * UIProcess/ios/PageClientImplIOS.h:
2363         * UIProcess/ios/PageClientImplIOS.mm:
2364         (WebKit::PageClientImpl::requestDOMPasteAccess):
2365         * UIProcess/ios/WKContentViewInteraction.h:
2366         * UIProcess/ios/WKContentViewInteraction.mm:
2367         (-[WKContentView setupInteraction]):
2368         (-[WKContentView cleanupInteraction]):
2369         (-[WKContentView resignFirstResponderForWebView]):
2370         (-[WKContentView _webTouchEventsRecognized:]):
2371
2372         Bail from any pending DOM paste access handler the moment we start handling touches on the web view, or if the
2373         web view resigns first responder, or if the web process crashes.
2374
2375         (-[WKContentView textInteractionGesture:shouldBeginAtPoint:]):
2376
2377         Reject text selection gestures while waiting for DOM paste access.
2378
2379         (-[WKContentView canPerformAction:withSender:]):
2380         (-[WKContentView canPerformActionForWebView:withSender:]):
2381
2382         If we're handling a DOM paste, always return YES to allow the callout bar to show the "Paste" option.
2383
2384         (-[WKContentView _didHideMenu:]):
2385
2386         If the menu is programmatically hidden by the app while handling a DOM paste request, immediately reject the DOM
2387         paste request.
2388
2389         (-[WKContentView pasteForWebView:]):
2390
2391         Adjust -pasteForWebView: on WKContentView to first check whether there's an outstanding DOM paste completion
2392         handler to invoke, instead of telling the page to execute a paste command.
2393
2394         (-[WKContentView _handleDOMPasteRequestWithResult:]):
2395
2396         Add a helper to take and invoke the current DOM paste completion handler (if it exists) with the given result,
2397         and then dismiss the shared callout bar. Returns whether or not the paste completion handler exists. Invoked
2398         from various sources of user interaction or significant state changes (e.g. following a web process crash in
2399         -cleanupInteraction).
2400
2401         (-[WKContentView _willPerformAction:sender:]):
2402         (-[WKContentView _didPerformAction:sender:]):
2403
2404         Add hooks to detect when WKContentView is executing an editing action. This is to ensure that the page doesn't
2405         get stuck in a bad state in the case where WKWebView has been subclassed, overrides `-paste:`, and does not
2406         invoke the superclass method (which calls back into `-[WKContentView pasteForWebView:]`). There are a few
2407         possibilities here:
2408         1. WKWebView's `-paste:` action is not overridden. In this case, we will call back into `-pasteForWebView:`,
2409            which will notice that we have a pending paste completion handler and invoke it.
2410         2. WKWebView's `-paste:` action is overridden and does not call back into the content view. In this case, we
2411            will invoke the paste completion handler in `-_didPerformAction:sender:`.
2412         3. WKWebView's `-canPerformAction:withSender:` is overridden to include additional actions. In this case, we may
2413            get a call to invoke a different action selector while waiting for a potential paste action. If this happens,
2414            prevent the DOM paste in `-_willPerformAction:sender:` prior to handling the other action.
2415
2416         (-[WKContentView handleKeyWebEvent:withCompletionHandler:]):
2417
2418         Dismiss DOM paste UI upon handling any key event.
2419
2420         (-[WKContentView showGlobalMenuControllerInRect:]):
2421         (-[WKContentView hideGlobalMenuController]):
2422
2423         Helper methods to present and dismiss the global UIMenuController, that accounts for available platform APIs for
2424         presenting or dismissing the menu controller on iOS.
2425
2426         (-[WKContentView _requestDOMPasteAccessWithElementRect:completionHandler:]):
2427
2428         Attempt to find a good target presentation rect when showing the callout menu. First, we will try to use the
2429         rect of the element the user has interacted with when triggering the paste. If such an element is too large or
2430         does not exist, we fall back to presenting the callout menu near the user's last touch location (with a small
2431         amount of margin, such that the action doesn't overlap with the user's finger, stylus, etc.).
2432
2433         (-[WKContentView _resetShowingTextStyle:]): Deleted.
2434
2435         Rename this to `-_didHideMenu:`.
2436
2437         * UIProcess/mac/PageClientImplMac.h:
2438         * UIProcess/win/PageClientImpl.cpp:
2439         (WebKit::PageClientImpl::requestDOMPasteAccess):
2440         * UIProcess/win/PageClientImpl.h:
2441         * WebProcess/WebCoreSupport/WebEditorClient.cpp:
2442         (WebKit::WebEditorClient::requestDOMPasteAccess):
2443         * WebProcess/WebCoreSupport/WebEditorClient.h:
2444         * WebProcess/WebPage/WebPage.cpp:
2445         (WebKit::WebPage::requestDOMPasteAccess):
2446
2447         Add more plumbing and method stubs.
2448
2449         (WebKit::WebPage::updateCurrentModifierState):
2450         (WebKit::WebPage::rectForElementAtInteractionLocation const):
2451         * WebProcess/WebPage/WebPage.h:
2452         * WebProcess/WebPage/ios/WebPageIOS.mm:
2453         (WebKit::WebPage::rectForElementAtInteractionLocation const):
2454         (WebKit::WebPage::rectForElementAtInteractionLocation): Deleted.
2455
2456         Mark this method as const, add a platform-agnostic stub, and adopt it for the purposes of determining where to
2457         position the callout bar when pasting.
2458
2459 2019-02-12  Alex Christensen  <achristensen@webkit.org>
2460
2461         Remove setDefersLoading infrastructure from WebKit2
2462         https://bugs.webkit.org/show_bug.cgi?id=194506
2463
2464         Reviewed by Brady Eidson.
2465
2466         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
2467         (WebKit::NetworkConnectionToWebProcess::setDefersLoading): Deleted.
2468         * NetworkProcess/NetworkConnectionToWebProcess.h:
2469         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
2470         * NetworkProcess/NetworkDataTask.h:
2471         * NetworkProcess/NetworkDataTaskBlob.cpp:
2472         (WebKit::NetworkDataTaskBlob::suspend): Deleted.
2473         * NetworkProcess/NetworkDataTaskBlob.h:
2474         * NetworkProcess/NetworkLoad.cpp:
2475         (WebKit::NetworkLoad::initialize):
2476         (WebKit::NetworkLoad::setDefersLoading): Deleted.
2477         * NetworkProcess/NetworkLoad.h:
2478         * NetworkProcess/NetworkLoadParameters.h:
2479         * NetworkProcess/NetworkResourceLoadParameters.cpp:
2480         (WebKit::NetworkResourceLoadParameters::encode const):
2481         (WebKit::NetworkResourceLoadParameters::decode):
2482         * NetworkProcess/NetworkResourceLoader.cpp:
2483         (WebKit::NetworkResourceLoader::start):
2484         (WebKit::NetworkResourceLoader::startNetworkLoad):
2485         (WebKit::NetworkResourceLoader::setDefersLoading): Deleted.
2486         * NetworkProcess/NetworkResourceLoader.h:
2487         * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
2488         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
2489         (WebKit::NetworkDataTaskCocoa::suspend): Deleted.
2490         * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
2491         (WebKit::NetworkDataTaskCurl::suspend): Deleted.
2492         * NetworkProcess/curl/NetworkDataTaskCurl.h:
2493         * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
2494         (WebKit::NetworkDataTaskSoup::suspend): Deleted.
2495         * NetworkProcess/soup/NetworkDataTaskSoup.h:
2496         * WebProcess/Network/WebLoaderStrategy.cpp:
2497         (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
2498         (WebKit::WebLoaderStrategy::setDefersLoading):
2499
2500 2019-02-12  Michael Catanzaro  <mcatanzaro@igalia.com>
2501
2502         Unreviewed, fix build warnings after content extensions enablement
2503         https://bugs.webkit.org/show_bug.cgi?id=193622
2504         <rdar://problem/47982850>
2505
2506         * UIProcess/API/C/WKUserContentExtensionStoreRef.cpp:
2507         (toResult):
2508
2509 2019-02-12  Tim Horton  <timothy_horton@apple.com>
2510
2511         Switching focus from a UITextField to an editable WKWebView causes the keyboard to dance
2512         https://bugs.webkit.org/show_bug.cgi?id=194524
2513         <rdar://problem/35481797>
2514
2515         Reviewed by Wenson Hsieh.
2516
2517         * Platform/spi/ios/UIKitSPI.h:
2518         * UIProcess/ios/InputViewUpdateDeferrer.h:
2519         * UIProcess/ios/InputViewUpdateDeferrer.mm:
2520         (WebKit::InputViewUpdateDeferrer::InputViewUpdateDeferrer):
2521         (WebKit::InputViewUpdateDeferrer::~InputViewUpdateDeferrer):
2522         Make use of the per-responder and much safer input view pinning mechanism.
2523
2524         * UIProcess/ios/WKContentViewInteraction.mm:
2525         (-[WKContentView becomeFirstResponderForWebView]):
2526         (-[WKContentView _singleTapCommited:]):
2527         (-[WKContentView _attemptClickAtLocation:modifierFlags:]):
2528         Always temporarily pin input views when becoming first responder; there are
2529         many paths (such as through the text interaction assistant) that can
2530         focus us on tap, trying to cover them all is a fool's errand. We'll
2531         just get out the big hammer and call it in becomeFirstResponder.
2532         This also means we can remove it from _singleTapCommitted and _attemptClick...
2533
2534         (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
2535         Don't release the input view pinning until we return from _elementDidFocus;
2536         it does the rebuilding synchronously, so we need to have actually updated
2537         all of the prerequisites of -inputView before depinning.
2538
2539 2019-02-12  Youenn Fablet  <youenn@apple.com>
2540
2541         Make use of is<SubresourceLoader>
2542         https://bugs.webkit.org/show_bug.cgi?id=194541
2543
2544         Reviewed by Alex Christensen.
2545
2546         * WebProcess/Network/WebLoaderStrategy.cpp:
2547         (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
2548
2549 2019-02-12  Alex Christensen  <achristensen@webkit.org>
2550
2551         WebPage::close needs to remove all message receivers associated with that WebPage, not WebPage::~WebPage
2552         https://bugs.webkit.org/show_bug.cgi?id=194522
2553         <rdar://problem/47789393>
2554
2555         Reviewed by Chris Dumez.
2556
2557         The InjectedBundle SPI can retain the WebPage or wrapping objects (WKWebProcessPlugInBrowserContextController/WKBundlePageRef).
2558         This can make it so WebPage::close is called before WebPage::~WebPage, and if the SuspendedPageProxy is reused for a subsequent
2559         navigation to the same domain, the WebProcess is reused with a different WebPage instance with the same PageID, which causes problems
2560         when another WebPage registers message handlers and then the previous WebPage is destroyed, which removes both message handlers.
2561
2562         * WebProcess/WebPage/WebPage.cpp:
2563         (WebKit::WebPage::~WebPage):
2564         (WebKit::WebPage::close):
2565         (WebKit::WebPage::mainFrameDidLayout):
2566         * WebProcess/WebPage/WebPage.h:
2567         * WebProcess/WebProcess.h:
2568         (WebKit::WebProcess::eventDispatcher):
2569
2570 2019-02-12  Michael Catanzaro  <mcatanzaro@igalia.com>
2571
2572         [WPE][GTK] Unsafe g_unsetenv() use in WebProcessPool::platformInitialize
2573         https://bugs.webkit.org/show_bug.cgi?id=194370
2574
2575         Reviewed by Darin Adler.
2576
2577         It is incorrect to use g_unsetenv() here because it is MT-Unsafe. We know that it is
2578         impossible and unreasonable to expect the application has not started other threads at this
2579         point, and threads will be calling getenv(). WebKit itself has probably already started
2580         threads of its own.
2581
2582         Fortunately, the remote inspector in the web process is already prepared to deal with
2583         failure to connect to the inspector server, so we don't need to do anything except stop
2584         messing with the environment.
2585
2586         Note these files are copies of each other. I'll merge them together in a follow-up patch.
2587
2588         * UIProcess/gtk/WebProcessPoolGtk.cpp:
2589         (WebKit::initializeRemoteInspectorServer):
2590         (WebKit::WebProcessPool::platformInitialize):
2591         * UIProcess/wpe/WebProcessPoolWPE.cpp:
2592         (WebKit::initializeRemoteInspectorServer):
2593         (WebKit::WebProcessPool::platformInitialize):
2594
2595 2019-02-08  Beth Dakin  <bdakin@apple.com>
2596
2597         Ensure old binaries have old snapshotting behaviors
2598         https://bugs.webkit.org/show_bug.cgi?id=194449
2599         -and corresponding-
2600         rdar://problem/47931954
2601
2602         Reviewed by Darin Adler.
2603
2604         Make sure that a nil configuration behaves the same way that it used to on apps 
2605         that were linked before FirstWithSnapshotAfterScreenUpdates
2606
2607         * UIProcess/API/Cocoa/WKWebView.mm:
2608         (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
2609         * UIProcess/Cocoa/VersionChecks.h:
2610
2611 2019-02-12  Andy Estes  <aestes@apple.com>
2612
2613         [iOSMac] Enable Parental Controls Content Filtering
2614         https://bugs.webkit.org/show_bug.cgi?id=194521
2615         <rdar://39732376>
2616
2617         Reviewed by Tim Horton.
2618
2619         * Configurations/FeatureDefines.xcconfig:
2620
2621 2019-02-11  Alex Christensen  <achristensen@webkit.org>
2622
2623         Remove noisy and unnecessary logs added in r241223
2624         https://bugs.webkit.org/show_bug.cgi?id=194427
2625
2626         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
2627         (WebKit::ProcessLauncher::launchProcess):
2628         Errors occur all the time in the XPC connection's event handler, like when a process terminates.
2629         We don't need to print an "error" every time any process terminates.
2630
2631 2019-02-11  Brian Burg  <bburg@apple.com>
2632
2633         [Cocoa] Web Automation: client callbacks are not called if delegate does not override
2634         https://bugs.webkit.org/show_bug.cgi?id=194519
2635         <rdar://problem/47981961>
2636
2637         Reviewed by Joseph Pecoraro.
2638
2639         Call the completion handler directly if the delegate does not implement the relevant method.
2640
2641         * UIProcess/Cocoa/AutomationSessionClient.mm:
2642         (WebKit::AutomationSessionClient::requestNewPageWithOptions):
2643         (WebKit::AutomationSessionClient::requestSwitchToPage):
2644         (WebKit::AutomationSessionClient::requestHideWindowOfPage):
2645         (WebKit::AutomationSessionClient::requestRestoreWindowOfPage):
2646         (WebKit::AutomationSessionClient::requestMaximizeWindowOfPage):
2647
2648 2019-02-11  Daniel Bates  <dabates@apple.com>
2649
2650         [iOS] Adopt SPI to support Emacs bindings: transpose and delete to end of paragraph
2651         https://bugs.webkit.org/show_bug.cgi?id=194505
2652         <rdar://problem/47743533>
2653
2654         Reviewed by Tim Horton.
2655
2656         * UIProcess/ios/WKContentViewInteraction.mm:
2657         (-[WKContentView _deleteToEndOfParagraph]): Added.
2658         (-[WKContentView _transpose]): Added.
2659
2660 2019-02-11  Adrian Perez de Castro  <aperez@igalia.com>
2661
2662         [GTK][WPE] Add content extensions support in WKTR and unskip layout tests
2663         https://bugs.webkit.org/show_bug.cgi?id=193622
2664
2665         Reviewed by Michael Catanzaro.
2666
2667         * NetworkProcess/cache/NetworkCacheData.h: Define an adoptAndMapFile() implementation
2668         for GFileIOStream objects.
2669         * NetworkProcess/cache/NetworkCacheDataSoup.cpp:
2670         (WebKit::NetworkCache::adoptAndMapFile): Added implementation, which extracts the file
2671         descriptor from a GFileIOStream, as it inherits from GFileDescriptorBased, and then
2672         reuses the version of adoptAndMapFile() which takes a file descritor for the actual work.
2673         * NetworkProcess/NetworkLoadChecker.cpp:
2674         (Webkit::NetworkLoadChecker::checkRequest): Use "this" when referring to
2675         processContentExtensionRulesForLoad() in order to avoid ambiguity.
2676         * Sources.txt: Add WKUserContentExtensionStoreRef.cpp, all ports use it now.
2677         * SourcesCocoa.txt: Remove WKUserContentExtensionStoreRef.cpp, because it is not
2678         Cocoa-specific anymore.
2679         * SourcesGTK.txt: Add APIContentRuleListStoreGLib.cpp.
2680         * SourcesWPE.txt: Ditto.
2681         * UIProcess/API/C/WKUserContentExtensionStoreRef.cpp:
2682         (WKUserContentExtensionStoreCreate): Added.
2683         (toResult): Added.
2684         (WKUserContentExtensionStoreCompile): Added.
2685         (WKUserContentExtensionStoreLookup): Added.
2686         (WKUserContentExtensionStoreRemove): Added.
2687         * UIProcess/API/C/WKUserContentExtensionStoreRef.h: Add declarations for the new C API
2688         functions and for the WKUserContentExtensionStoreResult status enum.
2689         * UIProcess/API/glib/APIContentRuleListStoreGLib.cpp: Added.
2690         (API::ContentRuleListStore::defaultStorePath): Add a dummy implementation. The public API
2691         for the GLib based ports (GTK+ and WPE) will not allow using the default store and will
2692         always indicating a path.
2693
2694 2019-02-11  Daniel Bates  <dabates@apple.com>
2695
2696         [iOS] Mouse/Touch/Pointer events are missing modifier keys
2697         https://bugs.webkit.org/show_bug.cgi?id=191446
2698         <rdar://problem/45929460>
2699
2700         Reviewed by Tim Horton.
2701
2702         Make use of UIKit SPI to retreive the modifier flags when dispatching mouse and touch events.
2703         Add new WebKit SPI for iOS, -[WKNavigationAction modifierFlags], to retrieve the the modifier
2704         flags held when a navigation action was initiated.
2705
2706         * Platform/spi/ios/UIKitSPI.h: Expose SPI.
2707         * Shared/NativeWebTouchEvent.h: Re-arrange macro guards so that we can expose the helper function
2708         WebKit::webEventModifierFlags(). This is a bit more involved that usual since this header is included
2709         from both C++ and Objective-C source files. It only makes sense to expose this function when
2710         compiling as part of an Objective-C source file.
2711         * Shared/ios/NativeWebTouchEventIOS.mm:
2712         (WebKit::NativeWebTouchEvent::NativeWebTouchEvent): Modified to take the modifier flags held down
2713         when the platform touch event was received and pass them through to the base constructor.
2714         (WebKit::webEventModifierFlags): Added. Converts from the platform-speciifc UIKeyModifierFlags to
2715         OptionSet<WebKit::WebEvent::Modifier>.
2716         * Shared/ios/WebIOSEventFactory.h:
2717         * Shared/ios/WebIOSEventFactory.mm:
2718         (WebIOSEventFactory::toUIKeyModifierFlags): Added. Converts from OptionSet<WebKit::WebEvent::Modifier>
2719         to the platform-specific UIKeyModifierFlags.
2720         * UIProcess/API/Cocoa/WKNavigationAction.mm:
2721         (-[WKNavigationAction modifierFlags]): Added.
2722         * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
2723         * UIProcess/WebPageProxy.h:
2724         * UIProcess/ios/WKContentViewInteraction.h:
2725         * UIProcess/ios/WKContentViewInteraction.mm:
2726         (gestureRecognizerModifierFlags): Added.
2727
2728         (-[WKContentView _webTouchEventsRecognized:]):
2729         (-[WKContentView _highlightLongPressRecognized:]):
2730         (-[WKContentView _twoFingerSingleTapGestureRecognized:]):
2731         (-[WKContentView _singleTapCommited:]):
2732         Pass modifier flags through.
2733
2734         (-[WKContentView _attemptClickAtLocation:modifierFlags:]): Added.
2735         (-[WKContentView actionSheetAssistant:openElementAtLocation:]): This is invoked when a person opens a link
2736         via the action sheet. We don't have access to the modifier flags to pass. It also seems like an implementation
2737         detail that this action is implemented via mouse click and we should re-evaluate this decision in light of
2738         the fact tht the action sheet is browser UI and we tend to be very reserved on what UI actions are visible
2739         to the page. On Mac, opening a link via the context menu is not visible to the page, at least from a mouse
2740         event perspective.
2741         (webEventFlagsForUIKeyModifierFlags): Added.
2742         (-[WKContentView _hoverGestureRecognizerChanged:]): Pass modifier flags through.
2743         (-[WKContentView _attemptClickAtLocation:]): Deleted.
2744         * UIProcess/ios/WebPageProxyIOS.mm:
2745         (WebKit::WebPageProxy::handleTwoFingerTapAtPoint):
2746         (WebKit::WebPageProxy::commitPotentialTap):
2747         (WebKit::WebPageProxy::handleTap):
2748         * WebProcess/WebPage/WebPage.h:
2749         * WebProcess/WebPage/WebPage.messages.in:
2750         * WebProcess/WebPage/ios/WebPageIOS.mm:
2751         (WebKit::WebPage::handleSyntheticClick):
2752         (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
2753         (WebKit::WebPage::completeSyntheticClick):
2754         (WebKit::WebPage::handleTap):
2755         (WebKit::WebPage::handleTwoFingerTapAtPoint):
2756         (WebKit::WebPage::commitPotentialTap):
2757         Pass modifier flags through.
2758
2759 2019-02-11  Jer Noble  <jer.noble@apple.com>
2760
2761         [Cocoa] Notify AVSystemController of our presenting PID before registering as a Now Playing app.
2762         https://bugs.webkit.org/show_bug.cgi?id=194504
2763
2764         Reviewed by Eric Carlson.
2765
2766         * WebKit.xcodeproj/project.pbxproj:
2767         * WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
2768         (WebKit::WebUserMediaClient::requestUserMediaAccess):
2769         * WebProcess/WebPage/WebPage.cpp:
2770         (WebKit::WebPage::prepareToSendUserMediaPermissionRequest): Deleted.
2771         * WebProcess/WebPage/WebPage.h:
2772         (WebKit::WebPage::userMediaPermissionRequestManager):
2773         * WebProcess/WebPage/ios/WebPageIOS.mm:
2774         (WebKit::WebPage::prepareToSendUserMediaPermissionRequest): Deleted.
2775
2776 2019-02-11  Commit Queue  <commit-queue@webkit.org>
2777
2778         Unreviewed, rolling out r241272 and r241276.
2779         https://bugs.webkit.org/show_bug.cgi?id=194514
2780
2781         Broke the Apple Internal build and the fix requires human
2782         intervention :( (Requested by dydz on #webkit).
2783
2784         Reverted changesets:
2785
2786         "[iOS] Mouse/Touch/Pointer events are missing modifier keys"
2787         https://bugs.webkit.org/show_bug.cgi?id=191446
2788         https://trac.webkit.org/changeset/241272
2789
2790         "Fix internal iOS build after r241272"
2791         https://bugs.webkit.org/show_bug.cgi?id=191446
2792         https://trac.webkit.org/changeset/241276
2793
2794 2019-02-11  Alex Christensen  <achristensen@webkit.org>
2795
2796         Fix internal iOS build after r241272
2797         https://bugs.webkit.org/show_bug.cgi?id=191446
2798
2799         * Platform/spi/ios/UIKitSPI.h:
2800         Declare the _modifierFlags when using the internal SDK also.
2801
2802 2019-02-11  Wenson Hsieh  <wenson_hsieh@apple.com>
2803
2804         fast/forms/ios/force-gregorian-calendar-for-credit-card-expiry.html does not work on iPad
2805         https://bugs.webkit.org/show_bug.cgi?id=194313
2806
2807         Reviewed by Tim Horton.
2808
2809         Make `-dateTimePickerCalendarType` work on iPad by handling the case where the date picker control is a
2810         WKDateTimePopover. This fixes UIScriptController::calendarType() returning null on iPad.
2811
2812         * UIProcess/ios/forms/WKFormInputControl.mm:
2813         (-[WKFormInputControl dateTimePickerCalendarType]):
2814         (-[WKDateTimePopover calendarType]):
2815
2816 2019-02-11  Daniel Bates  <dabates@apple.com>
2817
2818         [iOS] Mouse/Touch/Pointer events are missing modifier keys
2819         https://bugs.webkit.org/show_bug.cgi?id=191446
2820         <rdar://problem/45929460>
2821
2822         Reviewed by Tim Horton.
2823
2824         Make use of UIKit SPI to retreive the modifier flags when dispatching mouse and touch events.
2825         Add new WebKit SPI for iOS, -[WKNavigationAction modifierFlags], to retrieve the the modifier
2826         flags held when a navigation action was initiated.
2827
2828         * Platform/spi/ios/UIKitSPI.h: Expose SPI.
2829         * Shared/NativeWebTouchEvent.h: Re-arrange macro guards so that we can expose the helper function
2830         WebKit::webEventModifierFlags(). This is a bit more involved that usual since this header is included
2831         from both C++ and Objective-C source files. It only makes sense to expose this function when
2832         compiling as part of an Objective-C source file.
2833         * Shared/ios/NativeWebTouchEventIOS.mm:
2834         (WebKit::NativeWebTouchEvent::NativeWebTouchEvent): Modified to take the modifier flags held down
2835         when the platform touch event was received and pass them through to the base constructor.
2836         (WebKit::webEventModifierFlags): Added. Converts from the platform-speciifc UIKeyModifierFlags to
2837         OptionSet<WebKit::WebEvent::Modifier>.
2838         * Shared/ios/WebIOSEventFactory.h:
2839         * Shared/ios/WebIOSEventFactory.mm:
2840         (WebIOSEventFactory::toUIKeyModifierFlags): Added. Converts from OptionSet<WebKit::WebEvent::Modifier>
2841         to the platform-specific UIKeyModifierFlags.
2842         * UIProcess/API/Cocoa/WKNavigationAction.mm:
2843         (-[WKNavigationAction modifierFlags]): Added.
2844         * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
2845         * UIProcess/WebPageProxy.h:
2846         * UIProcess/ios/WKContentViewInteraction.h:
2847         * UIProcess/ios/WKContentViewInteraction.mm:
2848         (gestureRecognizerModifierFlags): Added.
2849
2850         (-[WKContentView _webTouchEventsRecognized:]):
2851         (-[WKContentView _highlightLongPressRecognized:]):
2852         (-[WKContentView _twoFingerSingleTapGestureRecognized:]):
2853         (-[WKContentView _singleTapCommited:]):
2854         Pass modifier flags through.
2855
2856         (-[WKContentView _attemptClickAtLocation:modifierFlags:]): Added.
2857         (-[WKContentView actionSheetAssistant:openElementAtLocation:]): This is invoked when a person opens a link
2858         via the action sheet. We don't have access to the modifier flags to pass. It also seems like an implementation
2859         detail that this action is implemented via mouse click and we should re-evaluate this decision in light of
2860         the fact tht the action sheet is browser UI and we tend to be very reserved on what UI actions are visible
2861         to the page. On Mac, opening a link via the context menu is not visible to the page, at least from a mouse
2862         event perspective.
2863         (webEventFlagsForUIKeyModifierFlags): Added.
2864         (-[WKContentView _hoverGestureRecognizerChanged:]): Pass modifier flags through.
2865         (-[WKContentView _attemptClickAtLocation:]): Deleted.
2866         * UIProcess/ios/WebPageProxyIOS.mm:
2867         (WebKit::WebPageProxy::handleTwoFingerTapAtPoint):
2868         (WebKit::WebPageProxy::commitPotentialTap):
2869         (WebKit::WebPageProxy::handleTap):
2870         * WebProcess/WebPage/WebPage.h:
2871         * WebProcess/WebPage/WebPage.messages.in:
2872         * WebProcess/WebPage/ios/WebPageIOS.mm:
2873         (WebKit::WebPage::handleSyntheticClick):
2874         (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
2875         (WebKit::WebPage::completeSyntheticClick):
2876         (WebKit::WebPage::handleTap):
2877         (WebKit::WebPage::handleTwoFingerTapAtPoint):
2878         (WebKit::WebPage::commitPotentialTap):
2879         Pass modifier flags through.
2880
2881 2019-02-11  Youenn Fablet  <youenn@apple.com>
2882
2883         Filter out Overconstrainederror.constraint when getUserMedia is not granted
2884         https://bugs.webkit.org/show_bug.cgi?id=194240
2885
2886         Reviewed by Eric Carlson.
2887
2888         Make sure in UIProcess to filter out constraint if either the page was not granted gum access or it has no persistent access.
2889
2890         Refactor UserMediaPermissionRequestManagerProxy to make the implementation easier to understand.
2891
2892         Covered by added test.
2893
2894         * UIProcess/UserMediaPermissionCheckProxy.cpp:
2895         (WebKit::UserMediaPermissionCheckProxy::setUserMediaAccessInfo):
2896         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
2897         (WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
2898         (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted):
2899         (WebKit::UserMediaPermissionRequestManagerProxy::grantAccess):
2900         (WebKit::UserMediaPermissionRequestManagerProxy::getRequestAction):
2901         (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
2902         (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):
2903         (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionInvalidRequest):
2904         (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest):
2905         (WebKit::UserMediaPermissionRequestManagerProxy::getUserMediaPermissionInfo):
2906         (WebKit::UserMediaPermissionRequestManagerProxy::wasGrantedVideoOrAudioAccess):
2907         (WebKit::UserMediaPermissionRequestManagerProxy::computeFilteredDeviceList):
2908         (WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
2909         (WebKit::UserMediaPermissionRequestManagerProxy::createPermissionRequest): Deleted.
2910         * UIProcess/UserMediaPermissionRequestManagerProxy.h:
2911         * UIProcess/UserMediaPermissionRequestProxy.h:
2912         (WebKit::UserMediaPermissionRequestProxy::isPending const):
2913         (WebKit::UserMediaPermissionRequestProxy::setEligibleVideoDeviceUIDs):
2914         (WebKit::UserMediaPermissionRequestProxy::setEligibleAudioDeviceUIDs):
2915         (WebKit::UserMediaPermissionRequestProxy::hasAudioDevice const):
2916         (WebKit::UserMediaPermissionRequestProxy::hasVideoDevice const):
2917         (WebKit::UserMediaPermissionRequestProxy::hasPersistentAccess const):
2918         (WebKit::UserMediaPermissionRequestProxy::setHasPersistentAccess):
2919         (WebKit::UserMediaPermissionRequestProxy::userMediaID const):
2920         (WebKit::UserMediaPermissionRequestProxy::topLevelDocumentSecurityOrigin const):
2921         (WebKit::UserMediaPermissionRequestProxy::userMediaDocumentSecurityOrigin const):
2922         (WebKit::UserMediaPermissionRequestProxy::userRequest const):
2923         (WebKit::UserMediaPermissionRequestProxy::setDeviceIdentifierHashSalt):
2924         (WebKit::UserMediaPermissionRequestProxy::deviceIdentifierHashSalt const):
2925         (WebKit::UserMediaPermissionRequestProxy::audioDevice const):
2926         (WebKit::UserMediaPermissionRequestProxy::videoDevice const):
2927         * UIProcess/WebPageProxy.cpp:
2928         (WebKit::WebPageProxy::requestUserMediaPermissionForFrame):
2929         * UIProcess/WebPageProxy.h:
2930
2931 2019-02-11  Carlos Garcia Campos  <cgarcia@igalia.com>
2932
2933         [WPE] Do not try to create empty egl windows
2934         https://bugs.webkit.org/show_bug.cgi?id=194497
2935
2936         Reviewed by Žan Doberšek.
2937
2938         In AcceleratedSurfaceWPE we ensure the size we pass to wpe is at least 0x0, but wl_egl_window_create() returns
2939         nullptr if 0 is passed as width or height. We should use at least 1x1 instead.
2940
2941         * WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp:
2942         (WebKit::AcceleratedSurfaceWPE::initialize):
2943         (WebKit::AcceleratedSurfaceWPE::clientResize):
2944
2945 2019-02-10  Carlos Garcia Campos  <cgarcia@igalia.com>
2946
2947         [WPE] Do not use a sync IPC message to send the host FD to the web process
2948         https://bugs.webkit.org/show_bug.cgi?id=194216
2949
2950         Reviewed by Darin Adler.
2951
2952         It can be sent as a web page creation parameter instead.
2953
2954         * PlatformWPE.cmake:
2955         * Shared/WebPageCreationParameters.cpp:
2956         (WebKit::WebPageCreationParameters::encode const):
2957         (WebKit::WebPageCreationParameters::decode):
2958         * Shared/WebPageCreationParameters.h:
2959         * SourcesWPE.txt:
2960         * UIProcess/API/wpe/CompositingManagerProxy.cpp: Removed.
2961         * UIProcess/API/wpe/CompositingManagerProxy.h: Removed.
2962         * UIProcess/API/wpe/CompositingManagerProxy.messages.in: Removed.
2963         * UIProcess/API/wpe/PageClientImpl.cpp:
2964         (WebKit::PageClientImpl::hostFileDescriptor):
2965         * UIProcess/API/wpe/PageClientImpl.h:
2966         * UIProcess/API/wpe/WPEView.cpp:
2967         (WKWPE::m_backend):
2968         * UIProcess/API/wpe/WPEView.h:
2969         (WKWPE::View::create):
2970         * UIProcess/PageClient.h:
2971         * UIProcess/WebPageProxy.cpp:
2972         (WebKit::WebPageProxy::creationParameters):
2973         * WebProcess/WebPage/WebPage.cpp:
2974         (WebKit::m_hostFileDescriptor):
2975         * WebProcess/WebPage/WebPage.h:
2976         (WebKit::WebPage::releaseHostFileDescriptor):
2977         * WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp:
2978         (WebKit::AcceleratedSurfaceWPE::AcceleratedSurfaceWPE):
2979         (WebKit::AcceleratedSurfaceWPE::initialize):
2980         * WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.h:
2981         * WebProcess/WebPage/wpe/CompositingManager.cpp: Removed.
2982         * WebProcess/WebPage/wpe/CompositingManager.h: Removed.
2983
2984 2019-02-04  Carlos Garcia Campos  <cgarcia@igalia.com>
2985
2986         [GTK][WPE] Add enable-javascript-markup setting
2987         https://bugs.webkit.org/show_bug.cgi?id=193439
2988
2989         Reviewed by Michael Catanzaro.
2990
2991         Expose JavaScriptMarkupEnabled setting in the GLib API.
2992
2993         * UIProcess/API/glib/WebKitSettings.cpp:
2994         (webKitSettingsSetProperty):
2995         (webKitSettingsGetProperty):
2996         (webkit_settings_class_init):
2997         (webkit_settings_get_enable_javascript_markup):
2998         (webkit_settings_set_enable_javascript_markup):
2999         * UIProcess/API/gtk/WebKitSettings.h:
3000         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
3001         * UIProcess/API/wpe/WebKitSettings.h:
3002         * UIProcess/API/wpe/docs/wpe-0.1-sections.txt:
3003
3004 2019-02-10  Darin Adler  <darin@apple.com>
3005
3006         Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
3007         https://bugs.webkit.org/show_bug.cgi?id=194485
3008
3009         Reviewed by Daniel Bates.
3010
3011         * UIProcess/DeviceIdHashSaltStorage.cpp:
3012         (WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall): Use
3013         appendUnsignedAsHex instead of appendUnsigned64AsHex.
3014
3015         * UIProcess/WebBackForwardList.cpp:
3016         (WebKit::WebBackForwardList::loggingString): Use appendUnsignedAsHex and
3017         reinterpret_cast<uintptr_t> instead of String::format and "%p".
3018
3019 2019-02-10  Commit Queue  <commit-queue@webkit.org>
3020
3021         Unreviewed, rolling out r241167.
3022         https://bugs.webkit.org/show_bug.cgi?id=194482
3023
3024         Broke the GTK mediastream tests (Requested by philn on
3025         #webkit).
3026
3027         Reverted changeset:
3028
3029         "Filter out Overconstrainederror.constraint when getUserMedia
3030         is not granted"
3031         https://bugs.webkit.org/show_bug.cgi?id=194240
3032         https://trac.webkit.org/changeset/241167
3033
3034 2019-02-09  Darin Adler  <darin@apple.com>
3035
3036         Eliminate unnecessary String temporaries by using StringConcatenateNumbers
3037         https://bugs.webkit.org/show_bug.cgi?id=194021
3038
3039         Reviewed by Geoffrey Garen.
3040
3041         * NetworkProcess/NetworkResourceLoader.cpp:
3042         (WebKit::escapeIDForJSON): Use an ASCIILiteral to create a String.
3043
3044         * NetworkProcess/cache/NetworkCacheStorage.cpp:
3045         (WebKit::NetworkCache::makeVersionedDirectoryPath): Remove String::number and let
3046         makeString do the conversion without allocating/destroying a String.
3047
3048         * NetworkProcess/mac/RemoteNetworkingContext.mm: Removed "using namespace WebCore".
3049         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession): Remove String::number
3050         and let makeString do the conversion without allocating/destroying a String.
3051
3052         * NetworkProcess/webrtc/NetworkMDNSRegister.cpp: Removed "using namespace WebCore".
3053         (WebKit::registerMDNSNameCallback): Added explicit WebCore prefix as needed.
3054         (WebKit::NetworkMDNSRegister::registerMDNSName): Ditto. Also remove String::number
3055         and let makeString do the conversion without allocating/destroying a String.
3056
3057         * UIProcess/WebPageGroup.cpp:
3058         (WebKit::pageGroupData): Remove String::number and let makeString do the conversion
3059         without allocating/destroying a String.
3060         * UIProcess/WebPageProxy.cpp:
3061         (WebKit::WebPageProxy::createInspectorTargets): Ditto.
3062         * UIProcess/ios/WKLegacyPDFView.mm:
3063         (-[WKLegacyPDFView _URLForLinkAnnotation:]): Ditto.
3064         * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
3065         (WebKit::uniqueWorldName): Ditto.
3066         * WebProcess/WebPage/WebPageInspectorTarget.cpp:
3067         (WebKit::WebPageInspectorTarget::identifier const): Ditto.
3068
3069 2019-02-09  Alexander Mikhaylenko  <exalm7659@gmail.com>
3070
3071         [GTK] Fix typo in the newly added API
3072         https://bugs.webkit.org/show_bug.cgi?id=194472
3073
3074         Reviewed by Michael Catanzaro.
3075
3076         Fix a typo: enableed -> enabled.
3077
3078         * UIProcess/API/glib/WebKitSettings.cpp:
3079         (webkit_settings_set_enable_back_forward_navigation_gestures):
3080         * UIProcess/API/gtk/WebKitSettings.h:
3081
3082 2019-02-08  Alex Christensen  <achristensen@webkit.org>
3083
3084         Speculative fix for Mojave API test after r241223
3085         https://bugs.webkit.org/show_bug.cgi?id=194427
3086
3087         * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
3088         (WebKit::XPCInitializationHandler):
3089         (WebKit::XPCServiceMain):
3090         Set the __APPLEEVENTSSERVICENAME environment variable before handling any xpc messages like we used to.
3091         I'll worry about making things right in the daemon later.
3092
3093 2019-02-08  Chris Dumez  <cdumez@apple.com>
3094
3095         [WK2][macOS] Avoid creating new CVDisplayLink objects for each WebProcess
3096         https://bugs.webkit.org/show_bug.cgi?id=194463
3097
3098         Reviewed by Tim Horton.
3099
3100         Avoid creating new CVDisplayLink objects for each WebProcess. We really only need one per
3101         display, creating such object is expensive and it is even worse in a PSON world where we
3102         swap process on navigation.
3103
3104         This patch moves the DisplayLink storing from WebProcessProxy to WebProcessPool. Also,
3105         a DisplayLink can now be associated to several IPC connections instead of having a 1:1
3106         mapping. When a DisplayLink no longer has any observers, we now merely stop it instead
3107         of destroying it.
3108
3109         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
3110         (WebKit::WebProcessPool::startDisplayLink):
3111         (WebKit::WebProcessPool::stopDisplayLink):
3112         (WebKit::WebProcessPool::stopDisplayLinks):
3113         * UIProcess/WebProcessPool.h:
3114         * UIProcess/WebProcessProxy.cpp:
3115         (WebKit::WebProcessProxy::~WebProcessProxy):
3116         (WebKit::WebProcessProxy::processWillShutDown):
3117         (WebKit::WebProcessProxy::shutDown):
3118         * UIProcess/WebProcessProxy.h:
3119         * UIProcess/mac/DisplayLink.cpp:
3120         (WebKit::DisplayLink::DisplayLink):
3121         (WebKit::DisplayLink::addObserver):
3122         (WebKit::DisplayLink::removeObserver):
3123         (WebKit::DisplayLink::removeObservers):
3124         (WebKit::DisplayLink::hasObservers const):
3125         (WebKit::DisplayLink::displayLinkCallback):
3126         * UIProcess/mac/DisplayLink.h:
3127         * UIProcess/mac/WebProcessProxyMac.mm:
3128         (WebKit::WebProcessProxy::startDisplayLink):
3129         (WebKit::WebProcessProxy::stopDisplayLink):
3130
3131 2019-02-08  Alexander Mikhaylenko  <exalm7659@gmail.com>
3132
3133         [GTK] Implement back/forward touchpad gesture
3134         https://bugs.webkit.org/show_bug.cgi?id=193919
3135
3136         Reviewed by Michael Catanzaro.
3137
3138         Move ViewSnapshotStore and ViewGestureController from Cocoa/Mac directory
3139         to UIProcess/, also move some parts of mac/ViewGestreControllerMac.mm to
3140         ViewGestureController.cpp, split up Mac- and iOS-specific parts of
3141         ViewSnapshotStore.cpp into mac/ViewSnapshotMac.mm, then implement 2-finger
3142         touchpad swipe back-forward gesture for GTK based on that.
3143
3144         To avoid name conflict, rename existing ViewGestureController class inside
3145         UIProcess/API/gtk/WebKitWebViewBase.cpp into TouchGestureController.
3146
3147         Since GTK gestures can only work with 3 or 4 fingers, treat horizontal
3148         scrolling events as a swipe as long as there's nowhere to scroll in that
3149         direction and web page doesn't handle the scrolling.
3150
3151         This is only allowed for touchpads, even though it can theoretically work
3152         with touch mice and trackpoints.
3153
3154         The gesture requires every item in back-forward list to have a snapshot.
3155         There's already an existing infrastructure for that, so the patch changes
3156         a bunch of #if PLATFORM(COCOA) statements to also check for GTK platform.
3157         The snapshots have to be taken in sync, so the implementation draws webview
3158         widget into a Cairo image surface.
3159
3160         The gesture is disabled by default, and can be enabled by setting the newly
3161         added 'enable-back-forward-navigation-gestures' property in WebKitSettings to
3162         true.
3163
3164         Gesture drawing is implemented via Cairo. When the gesture is active, the
3165         actual page is drawn into a Cairo group, which is then drawn together with
3166         a given snapshot, as well as dimming and a drop shadow over the "lower" layer.
3167
3168         Also add a memory pressure handler that clears snapshot store when low on memory.
3169
3170         * DerivedSources-input.xcfilelist:
3171         * PlatformGTK.cmake:
3172         * PlatformMac.cmake:
3173         * Shared/SessionState.h: Add snapshot to back-forward items for GTK.
3174         * Shared/WebBackForwardListItem.h: Add snapshot to back-forward items for GTK.
3175         * SourcesCocoa.txt:
3176         * SourcesGTK.txt:
3177         * UIProcess/API/glib/WebKitSettings.cpp:
3178         Added 'enable-back-forward-navigation-gestures' property for enabling the gesture.
3179         (webKitSettingsSetProperty):
3180         (webKitSettingsGetProperty):
3181         (webkit_settings_class_init):
3182         (webkit_settings_get_enable_back_forward_navigation_gestures): Added, GTK only.
3183         (webkit_settings_set_enable_back_forward_navigation_gestures): Added, GTK only.
3184         * UIProcess/API/glib/WebKitWebView.cpp:
3185         (enableBackForwardNavigationGesturesChanged): Added, GTK only.
3186         (webkitWebViewUpdateSettings):
3187         (webkitWebViewDisconnectSettingsSignalHandlers):
3188         * UIProcess/API/gtk/PageClientImpl.cpp:
3189         (WebKit::PageClientImpl::setViewNeedsDisplay): Redraw the whole screen instead of a region during the gesture.
3190         (WebKit::PageClientImpl::takeViewSnapshot): Added.
3191         (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore): Pass unhandled events to the gesture controller.
3192         (WebKit::PageClientImpl::didRemoveNavigationGestureSnapshot): Redraw the widget immediately after removing snapshot.
3193         (WebKit::PageClientImpl::didStartProvisionalLoadForMainFrame): Added, send a notification to the gesture controller.
3194         (WebKit::PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame):  Send a notification to the gesture controller.
3195         (WebKit::PageClientImpl::didFinishLoadForMainFrame):  Send a notification to the gesture controller.
3196         (WebKit::PageClientImpl::didFailLoadForMainFrame):  Added, send a notification to the gesture controller.
3197         (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):  Send a notification to the gesture controller.
3198         (WebKit::PageClientImpl::didRestoreScrollPosition):  Added, send a notification to the gesture controller.
3199         * UIProcess/API/gtk/PageClientImpl.h:
3200         * UIProcess/API/gtk/WebKitSettings.h:
3201         Add webkit_settings_get_enable_back_forward_navigation_gestures() and webkit_settings_get_enable_back_forward_navigation_gestures()
3202         to public API.
3203         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
3204         (webkitWebViewBaseDraw): Pass drawing to ViewGestureController during the gesture.
3205         (webkitWebViewBaseScrollEvent): Pass scroll events to ViewGestureController during the gesture.
3206         (webkitWebViewBaseGestureController): Renamed ViewGestureController to TouchGestureController.
3207         (webkitWebViewBaseViewGestureController): Added.
3208         (webkitWebViewBaseCreateWebPage): Create an instance of ViewGestureController.
3209         (webkitWebViewBaseTakeViewSnapshot): Added.
3210         (webkitWebViewBaseDidStartProvisionalLoadForMainFrame): Added.
3211         (webkitWebViewBaseDidFirstVisuallyNonEmptyLayoutForMainFrame): Added.
3212         (webkitWebViewBaseDidFinishLoadForMainFrame): Added.
3213         (webkitWebViewBaseDidFailLoadForMainFrame): Added.
3214         (webkitWebViewBaseDidSameDocumentNavigationForMainFrame): Added.
3215         (webkitWebViewBaseDidRestoreScrollPosition): Added.
3216         * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
3217         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Mentioned the added functions in docs.
3218         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
3219         (WebKit::WebProcessPool::platformInitialize): Move the check from WebMemoryPressureHandlerCocoa.mm here.
3220         * UIProcess/PageClient.h: Add takeViewSnapshot() for GTK.
3221         * UIProcess/ViewGestureController.cpp: Renamed from Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp.
3222         (WebKit::ViewGestureController::ViewGestureController):
3223         (WebKit::ViewGestureController::~ViewGestureController):
3224         (WebKit::ViewGestureController::disconnectFromProcess):
3225         (WebKit::ViewGestureController::connectToProcess):
3226         (WebKit::ViewGestureController::controllerForGesture):
3227         (WebKit::ViewGestureController::takeNextGestureID):
3228         (WebKit::ViewGestureController::willBeginGesture):
3229         (WebKit::ViewGestureController::didEndGesture):
3230         (WebKit::ViewGestureController::setAlternateBackForwardListSourcePage):
3231         (WebKit::ViewGestureController::canSwipeInDirection const):
3232         (WebKit::ViewGestureController::didStartProvisionalOrSameDocumentLoadForMainFrame):
3233         (WebKit::ViewGestureController::didStartProvisionalLoadForMainFrame):
3234         (WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame):
3235         (WebKit::ViewGestureController::didRepaintAfterNavigation):
3236         (WebKit::ViewGestureController::didHitRenderTreeSizeThreshold):
3237         (WebKit::ViewGestureController::didRestoreScrollPosition):
3238         (WebKit::ViewGestureController::didReachMainFrameLoadTerminalState):
3239         (WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame):
3240         (WebKit::ViewGestureController::checkForActiveLoads):
3241         (WebKit::ViewGestureController::SnapshotRemovalTracker::SnapshotRemovalTracker):
3242         (WebKit::ViewGestureController::SnapshotRemovalTracker::eventsDescription):
3243         (WebKit::ViewGestureController::SnapshotRemovalTracker::log const):
3244         (WebKit::ViewGestureController::SnapshotRemovalTracker::resume):
3245         (WebKit::ViewGestureController::SnapshotRemovalTracker::start):
3246         (WebKit::ViewGestureController::SnapshotRemovalTracker::reset):
3247         (WebKit::ViewGestureController::SnapshotRemovalTracker::stopWaitingForEvent):
3248         (WebKit::ViewGestureController::SnapshotRemovalTracker::eventOccurred):
3249         (WebKit::ViewGestureController::SnapshotRemovalTracker::cancelOutstandingEvent):
3250         (WebKit::ViewGestureController::SnapshotRemovalTracker::hasOutstandingEvent):
3251         (WebKit::ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackIfPossible):
3252         (WebKit::ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackImmediately):
3253         (WebKit::ViewGestureController::SnapshotRemovalTracker::watchdogTimerFired):
3254         (WebKit::ViewGestureController::SnapshotRemovalTracker::startWatchdog):
3255         (WebKit::deltaShouldCancelSwipe):
3256         (WebKit::ViewGestureController::PendingSwipeTracker::PendingSwipeTracker):
3257         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
3258         (WebKit::ViewGestureController::PendingSwipeTracker::handleEvent):
3259         (WebKit::ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore):
3260         (WebKit::ViewGestureController::PendingSwipeTracker::tryToStartSwipe):
3261         (WebKit::ViewGestureController::PendingSwipeTracker::reset):
3262         (WebKit::ViewGestureController::startSwipeGesture):
3263         (WebKit::ViewGestureController::isPhysicallySwipingLeft const):
3264         (WebKit::ViewGestureController::shouldUseSnapshotForSize):
3265         (WebKit::ViewGestureController::forceRepaintIfNeeded):
3266         (WebKit::ViewGestureController::willEndSwipeGesture):
3267         (WebKit::ViewGestureController::endSwipeGesture):
3268         (WebKit::ViewGestureController::requestRenderTreeSizeNotificationIfNeeded):
3269         * UIProcess/ViewGestureController.h: Renamed from Source/WebKit/UIProcess/Cocoa/ViewGestureController.h.
3270         (WebKit::ViewGestureController::wheelEventWasNotHandledByWebCore):
3271         (WebKit::ViewGestureController::shouldIgnorePinnedState):
3272         (WebKit::ViewGestureController::setShouldIgnorePinnedState):
3273         (WebKit::ViewGestureController::hasActiveMagnificationGesture const):
3274         (WebKit::ViewGestureController::setCustomSwipeViews):
3275         (WebKit::ViewGestureController::setCustomSwipeViewsTopContentInset):
3276         (WebKit::ViewGestureController::setDidMoveSwipeSnapshotCallback):
3277         (WebKit::ViewGestureController::backgroundColorForCurrentSnapshot const):
3278         (WebKit::ViewGestureController::didFinishLoadForMainFrame):
3279         (WebKit::ViewGestureController::didFailLoadForMainFrame):
3280         (WebKit::ViewGestureController::setSwipeGestureEnabled):
3281         (WebKit::ViewGestureController::isSwipeGestureEnabled):
3282         (WebKit::ViewGestureController::SnapshotRemovalTracker::pause):
3283         (WebKit::ViewGestureController::SnapshotRemovalTracker::isPaused const):
3284         (WebKit::ViewGestureController::SnapshotRemovalTracker::hasRemovalCallback const):
3285         (WebKit::ViewGestureController::SnapshotRemovalTracker::renderTreeSizeThreshold const):
3286         (WebKit::ViewGestureController::SnapshotRemovalTracker::setRenderTreeSizeThreshold):
3287         (WebKit::ViewGestureController::PendingSwipeTracker::shouldIgnorePinnedState):
3288         (WebKit::ViewGestureController::PendingSwipeTracker::setShouldIgnorePinnedState):
3289         (WebKit::ViewGestureController::SwipeProgressTracker::progress const):
3290         (WebKit::ViewGestureController::SwipeProgressTracker::direction const):
3291         * UIProcess/ViewGestureController.messages.in: Renamed from Source/WebKit/UIProcess/Cocoa/ViewGestureController.messages.in.
3292         * UIProcess/ViewSnapshotStore.cpp: Copied from Source/WebKit/UIProcess/mac/ViewSnapshotStore.mm.
3293         (WebKit::ViewSnapshotStore::ViewSnapshotStore):
3294         (WebKit::ViewSnapshotStore::~ViewSnapshotStore):
3295         (WebKit::ViewSnapshotStore::singleton):
3296         (WebKit::ViewSnapshotStore::didAddImageToSnapshot):
3297         (WebKit::ViewSnapshotStore::willRemoveImageFromSnapshot):
3298         (WebKit::ViewSnapshotStore::pruneSnapshots):
3299         (WebKit::ViewSnapshotStore::recordSnapshot):
3300         (WebKit::ViewSnapshotStore::discardSnapshotImages):
3301         (WebKit::ViewSnapshot::~ViewSnapshot):
3302         * UIProcess/ViewSnapshotStore.h: Renamed from Source/WebKit/UIProcess/mac/ViewSnapshotStore.h.
3303         (WebKit::ViewSnapshot::setRenderTreeSize):
3304         (WebKit::ViewSnapshot::renderTreeSize const):
3305         (WebKit::ViewSnapshot::setBackgroundColor):
3306         (WebKit::ViewSnapshot::backgroundColor const):
3307         (WebKit::ViewSnapshot::setViewScrollPosition):
3308         (WebKit::ViewSnapshot::viewScrollPosition const):
3309         (WebKit::ViewSnapshot::setDeviceScaleFactor):
3310         (WebKit::ViewSnapshot::deviceScaleFactor const):
3311         (WebKit::ViewSnapshot::surface const):
3312         (WebKit::ViewSnapshot::imageSizeInBytes const):
3313         (WebKit::ViewSnapshot::size const):
3314         (WebKit::ViewSnapshotStore::setDisableSnapshotVolatilityForTesting):
3315         (WebKit::ViewSnapshotStore::disableSnapshotVolatilityForTesting const):
3316         * UIProcess/WebBackForwardList.cpp:
3317         (WebKit::WebBackForwardList::didRemoveItem): Unset snapshot for GTK.
3318         * UIProcess/WebMemoryPressureHandler.cpp: Copied from Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm.
3319         (WebKit::installMemoryPressureHandler):
3320         * UIProcess/WebMemoryPressureHandler.h: Renamed from Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h.
3321         * UIProcess/WebPageProxy.cpp:
3322         (WebKit::WebPageProxy::recordNavigationSnapshot): Take snapshots for GTK.
3323         * UIProcess/WebPageProxy.h:
3324         * UIProcess/gtk/ViewGestureControllerGtk.cpp: Added. This is a port of
3325         UIProcess/mac/ViewGestureControllerMac.mm. SwipeProgressTracker class is a
3326         re-implementation of trackSwipeEventWithOptions.
3327         (WebKit::isEventStop):
3328         (WebKit::ViewGestureController::platformTeardown):
3329         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanStartSwipe):
3330         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanEndSwipe):
3331         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe):
3332         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
3333         (WebKit::ViewGestureController::handleScrollWheelEvent):
3334         (WebKit::ViewGestureController::trackSwipeGesture):
3335         (WebKit::ViewGestureController::SwipeProgressTracker::SwipeProgressTracker):
3336         (WebKit::ViewGestureController::SwipeProgressTracker::startTracking):
3337         (WebKit::ViewGestureController::SwipeProgressTracker::reset):
3338         (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
3339         (WebKit::ViewGestureController::SwipeProgressTracker::startAnimation):
3340         (WebKit::easeOutCubic):
3341         (WebKit::ViewGestureController::SwipeProgressTracker::onAnimationTick):
3342         (WebKit::ViewGestureController::SwipeProgressTracker::endAnimation):
3343         (WebKit::ViewGestureController::beginSwipeGesture):
3344         (WebKit::ViewGestureController::handleSwipeGesture):
3345         (WebKit::ViewGestureController::draw):
3346         (WebKit::ViewGestureController::removeSwipeSnapshot):
3347         (WebKit::ViewGestureController::beginSimulatedSwipeInDirectionForTesting):
3348         (WebKit::ViewGestureController::completeSimulatedSwipeInDirectionForTesting):
3349         * UIProcess/gtk/ViewSnapshotStoreGtk.cpp: Renamed from Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm.
3350         (WebKit::ViewSnapshot::create):
3351         (WebKit::ViewSnapshot::ViewSnapshot):
3352         (WebKit::ViewSnapshot::hasImage const):
3353         (WebKit::ViewSnapshot::clearImage):
3354         (WebKit::ViewSnapshot::imageSizeInBytes const):
3355         (WebKit::ViewSnapshot::size const):
3356         * UIProcess/gtk/WebProcessPoolGtk.cpp:
3357         (WebKit::memoryPressureMonitorDisabled): Added.
3358         (WebKit::WebProcessPool::platformInitialize): Install memory pressure handler.
3359         (WebKit::WebProcessPool::platformInitializeWebProcess): Use memoryPressureMonitorDisabled().
3360         * UIProcess/mac/ViewGestureControllerMac.mm:
3361         Moved many functions into UIProcess/ViewGestureController.cpp
3362         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanStartSwipe):
3363         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanEndSwipe):
3364         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe):
3365         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
3366         (WebKit::ViewGestureController::trackSwipeGesture):
3367         (WebKit::scrollEventCanInfluenceSwipe): Deleted.
3368         (WebKit::deltaShouldCancelSwipe): Deleted.
3369         (WebKit::ViewGestureController::PendingSwipeTracker::PendingSwipeTracker): Deleted.
3370         (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe): Deleted.
3371         (WebKit::ViewGestureController::PendingSwipeTracker::handleEvent): Deleted.
3372         (WebKit::ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore): Deleted.
3373         (WebKit::ViewGestureController::PendingSwipeTracker::tryToStartSwipe): Deleted.
3374         (WebKit::ViewGestureController::PendingSwipeTracker::reset): Deleted.
3375         (WebKit::ViewGestureController::willEndSwipeGesture): Deleted.
3376         (WebKit::ViewGestureController::shouldUseSnapshotForSize): Deleted.
3377         (WebKit::ViewGestureController::isPhysicallySwipingLeft const): Deleted.
3378         (WebKit::ViewGestureController::endSwipeGesture): Deleted.
3379         (WebKit::ViewGestureController::forceRepaintIfNeeded): Deleted.
3380         (WebKit::ViewGestureController::requestRenderTreeSizeNotificationIfNeeded): Deleted.
3381         * UIProcess/mac/ViewSnapshotStoreMac.mm: Renamed from Source/WebKit/UIProcess/mac/ViewSnapshotStore.mm.
3382         (WebKit::ViewSnapshotStore::snapshottingContext):
3383         (WebKit::ViewSnapshot::create):
3384         (WebKit::ViewSnapshot::ViewSnapshot):
3385         (WebKit::ViewSnapshot::setSurface):
3386         (WebKit::ViewSnapshot::hasImage const):
3387         (WebKit::ViewSnapshot::clearImage):
3388         (WebKit::ViewSnapshot::setVolatile):
3389         (WebKit::ViewSnapshot::asLayerContents):
3390         (WebKit::ViewSnapshot::asImageForTesting):
3391         * WebKit.xcodeproj/project.pbxproj:
3392         * WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
3393         Make SetRenderTreeSizeNotificationThreshold() cross-platform.
3394         (WebKit::ViewGestureGeometryCollector::ViewGestureGeometryCollector):
3395         (WebKit::ViewGestureGeometryCollector::computeMinimumAndMaximumViewportScales const):
3396         (WebKit::ViewGestureGeometryCollector::mainFrameDidLayout):
3397         * WebProcess/WebPage/ViewGestureGeometryCollector.h:
3398         * WebProcess/WebPage/ViewGestureGeometryCollector.messages.in:
3399         * WebProcess/WebPage/WebPage.cpp:
3400         Start using ViewGestureGeometryCollector for GTK.
3401         (WebKit::WebPage::mainFrameDidLayout):
3402         * WebProcess/WebPage/WebPage.h:
3403
3404 2019-02-08  Alex Christensen  <achristensen@webkit.org>
3405
3406         Add SPI to use networking daemon instead of XPC service
3407         https://bugs.webkit.org/show_bug.cgi?id=194427
3408
3409         Reviewed by Geoffrey Garen.
3410
3411         There is still work to be done, but with the proper plist it starts and loads webpages!
3412
3413         * NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm:
3414         (WebKit::DaemonMain):
3415         * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
3416         * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
3417         (WebKit::XPCEventHandler):
3418         (WebKit::XPCInitializationHandler):
3419         (WebKit::XPCServiceMain):
3420         (WebKit::XPCServiceEventHandler): Deleted.
3421         * UIProcess/API/APIProcessPoolConfiguration.h:
3422         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
3423         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
3424         (-[_WKProcessPoolConfiguration usesNetworkingDaemon]):
3425         (-[_WKProcessPoolConfiguration setUsesNetworkingDaemon:]):
3426         * UIProcess/AuxiliaryProcessProxy.cpp:
3427         (WebKit::AuxiliaryProcessProxy::getLaunchOptions):
3428         * UIProcess/Launcher/ProcessLauncher.h:
3429         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
3430         (WebKit::serviceName):
3431         (WebKit::ProcessLauncher::launchProcess):
3432         * UIProcess/Network/NetworkProcessProxy.cpp:
3433         (WebKit::NetworkProcessProxy::getLaunchOptions):
3434         * UIProcess/WebProcessPool.cpp:
3435         (WebKit::WebProcessPool::usesNetworkingDaemon const):
3436         * UIProcess/WebProcessPool.h:
3437
3438 2019-02-08  Truitt Savell  <tsavell@apple.com>
3439
3440         Unreviewed, rolling out r241197.
3441
3442         Broke iOS Simulator Debug build and casued 1 API failure on
3443         High Sierra
3444
3445         Reverted changeset:
3446
3447         "Add SPI to use networking daemon instead of XPC service"
3448         https://bugs.webkit.org/show_bug.cgi?id=194427
3449         https://trac.webkit.org/changeset/241197
3450
3451 2019-02-08  Beth Dakin  <bdakin@apple.com>
3452
3453         Abstract and discussion comments needed for afterScreenUpdates
3454         https://bugs.webkit.org/show_bug.cgi?id=194442
3455
3456         Reviewed by Wenson Hsieh.
3457
3458         Forgot to add these comments with https://bugs.webkit.org/show_bug.cgi?id=194362
3459         * UIProcess/API/Cocoa/WKSnapshotConfiguration.h:
3460
3461 2019-02-08  Beth Dakin  <bdakin@apple.com>
3462
3463         Add afterScreenUpdates to WKSnapshotConfiguration
3464         https://bugs.webkit.org/show_bug.cgi?id=194362
3465         -and corresponding-
3466         <rdar://problem/40655528> Please add an "after screen updates" property to 
3467         WKSnapshotConfiguration (to solve blank snapshots)
3468
3469         Reviewed by Tim Horton.
3470
3471         This is the WebKit equivalent of - (UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates;
3472         This makes our snapshotting API more predictable and reliable on iOS devices, 
3473         which is why the new configuration property defaults to YES.
3474
3475         New property that defaults to YES.
3476         * UIProcess/API/Cocoa/WKSnapshotConfiguration.h:
3477         * UIProcess/API/Cocoa/WKSnapshotConfiguration.mm:
3478         (-[WKSnapshotConfiguration init]):
3479         (-[WKSnapshotConfiguration copyWithZone:]):
3480
3481         When afterScreenUpdates is set, invoke the snapshot via 
3482         callAfterNextPresentationUpdate.
3483         * UIProcess/API/Cocoa/WKWebView.mm:
3484         (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
3485         (-[WKWebView _callCompletionHandler:withSnapshotImage:atDeviceScale:]):
3486
3487 2019-02-08  Alex Christensen  <achristensen@webkit.org>
3488
3489         Add SPI to use networking daemon instead of XPC service
3490         https://bugs.webkit.org/show_bug.cgi?id=194427
3491
3492         Reviewed by Geoffrey Garen.
3493
3494         There is still work to be done, but with the proper plist it starts and loads webpages!
3495
3496         * NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm:
3497         (WebKit::DaemonMain):
3498         * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
3499         * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
3500         (WebKit::XPCEventHandler):
3501         (WebKit::XPCInitializationHandler):
3502         (WebKit::XPCServiceMain):
3503         (WebKit::XPCServiceEventHandler): Deleted.
3504         * UIProcess/API/APIProcessPoolConfiguration.h:
3505         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
3506         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
3507         (-[_WKProcessPoolConfiguration usesNetworkingDaemon]):
3508         (-[_WKProcessPoolConfiguration setUsesNetworkingDaemon:]):
3509         * UIProcess/AuxiliaryProcessProxy.cpp:
3510         (WebKit::AuxiliaryProcessProxy::getLaunchOptions):
3511         * UIProcess/Launcher/ProcessLauncher.h:
3512         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
3513         (WebKit::serviceName):
3514         (WebKit::ProcessLauncher::launchProcess):
3515         * UIProcess/Network/NetworkProcessProxy.cpp:
3516         (WebKit::NetworkProcessProxy::getLaunchOptions):
3517         * UIProcess/WebProcessPool.cpp:
3518         (WebKit::WebProcessPool::usesNetworkingDaemon const):
3519         * UIProcess/WebProcessPool.h:
3520
3521 2019-02-08  Keith Rollin  <krollin@apple.com>
3522
3523         Unreviewed build fix.
3524
3525         r241135 modified how entitlements were built up for the macOS. Those
3526         changes broke the iOSMac builds. Bring back some deletions in order to
3527         fix iOSMac.
3528
3529         * Configurations/PluginService.64.xcconfig:
3530         * Configurations/PluginService.entitlements: Added.
3531         * WebKit.xcodeproj/project.pbxproj:
3532
3533 2019-02-07  Chris Dumez  <cdumez@apple.com>
3534
3535         Mark more heap-allocated classes as fast allocated
3536         https://bugs.webkit.org/show_bug.cgi?id=194422
3537
3538         Reviewed by Ryosuke Niwa.
3539
3540         * NetworkProcess/NetworkLoad.cpp:
3541         * NetworkProcess/NetworkLoadChecker.h:
3542         * NetworkProcess/NetworkResourceLoader.cpp:
3543         * Platform/IPC/Connection.h:
3544         * Platform/IPC/mac/ImportanceAssertion.h:
3545         * PluginProcess/PluginCreationParameters.h:
3546         * Shared/API/Cocoa/RemoteObjectRegistry.h:
3547         * Shared/WebEvent.h:
3548         * UIProcess/API/APIHTTPCookieStore.cpp:
3549         * UIProcess/API/APINotificationProvider.h:
3550         * UIProcess/API/Cocoa/PageLoadStateObserver.h:
3551         * UIProcess/API/Cocoa/WKHTTPCookieStore.mm:
3552         * UIProcess/API/Cocoa/WKWebView.mm:
3553         (-[WKWebView _setInputDelegate:]):
3554         * UIProcess/API/gtk/PageClientImpl.h:
3555         * UIProcess/BackingStore.h:
3556         * UIProcess/Cocoa/AutomationClient.h:
3557         * UIProcess/Cocoa/DiagnosticLoggingClient.h:
3558         * UIProcess/Cocoa/DownloadClient.h:
3559         * UIProcess/Cocoa/FindClient.h:
3560         * UIProcess/Cocoa/NavigationState.h:
3561         * UIProcess/Cocoa/UIDelegate.h:
3562         * UIProcess/Cocoa/ViewGestureController.h:
3563         * UIProcess/DeviceIdHashSaltStorage.h:
3564         * UIProcess/Downloads/DownloadProxyMap.h:
3565         * UIProcess/Gamepad/UIGamepad.h:
3566         * UIProcess/Notifications/WebNotificationProvider.h:
3567         * UIProcess/ProcessAssertion.h:
3568         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
3569         * UIProcess/WebContextInjectedBundleClient.h:
3570         * UIProcess/WebFormClient.h:
3571         * UIProcess/WebGeolocationProvider.h:
3572         * UIProcess/WebPageProxy.h:
3573         * WebProcess/Automation/WebAutomationSessionProxy.h:
3574         * WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h:
3575         * WebProcess/InjectedBundle/API/APIInjectedBundleEditorClient.h:
3576         * WebProcess/InjectedBundle/API/APIInjectedBundlePageContextMenuClient.h:
3577         * WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h:
3578         * WebProcess/InjectedBundle/API/APIInjectedBundlePageResourceLoadClient.h:
3579         * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h:
3580         * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:
3581         * WebProcess/Network/webrtc/LibWebRTCNetwork.h:
3582         * WebProcess/Network/webrtc/LibWebRTCSocket.h:
3583         * WebProcess/Network/webrtc/WebRTCResolver.h:
3584         * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
3585         * WebProcess/WebPage/DrawingArea.h:
3586
3587 2019-02-07  Wenson Hsieh  <wenson_hsieh@apple.com>
3588
3589         [iOS] [WK2] Modernize code for applying autocorrection
3590         https://bugs.webkit.org/show_bug.cgi?id=194397
3591
3592         Reviewed by Tim Horton.
3593
3594         * UIProcess/ios/WKContentViewInteraction.h:
3595         * UIProcess/ios/WKContentViewInteraction.mm:
3596         (-[WKContentView requestAutocorrectionRectsForString:withCompletionHandler:]):
3597         (-[WKContentView applyAutocorrection:toString:withCompletionHandler:]):
3598
3599         Use BlockPtr instead of temporarily storing the completion handler.
3600
3601         * WebProcess/WebPage/WebPage.h:
3602         * WebProcess/WebPage/WebPage.messages.in:
3603
3604         Change a LegacySync to Delayed.
3605
3606         * WebProcess/WebPage/ios/WebPageIOS.mm:
3607         (WebKit::WebPage::applyAutocorrection):
3608         (WebKit::WebPage::syncApplyAutocorrection):
3609         (WebKit::WebPage::applyAutocorrectionInternal):
3610
3611 2019-02-07  Wenson Hsieh  <wenson_hsieh@apple.com>
3612
3613         [iOS] Clicking links in Safari using Apple Pencil is much more difficult after r238475
3614         https://bugs.webkit.org/show_bug.cgi?id=194415
3615         <rdar://problem/47550281>
3616
3617         Reviewed by Tim Horton.
3618
3619         Fix the bug by not firing the Apple-pencil-exclusive tap gesture recognizer in the case where editable images
3620         are disabled. This gesture recognizer is only used for inserting editable images, and currently conflicts with
3621         the synthetic click gesture recognizer used to recognize clicks from generic digitizer inputs.
3622
3623         * UIProcess/ios/WKContentViewInteraction.mm:
3624         (-[WKContentView gestureRecognizerShouldBegin:]):
3625         (-[WKContentView _stylusSingleTapRecognized:]):
3626
3627 2019-02-07  Per Arne Vollan  <pvollan@apple.com>
3628
3629         [macOS] Block coreservicesd in sandbox.
3630         https://bugs.webkit.org/show_bug.cgi?id=192670
3631
3632         Reviewed by Alexey Proskuryakov.
3633
3634         We should block CoreServices in newer versions of macOS. In order to achieve this we need to avoid calling
3635         _RegisterApplication before entering the sandbox, since this call will open up a connection to CoreServices.
3636         The call to _RegisterApplication is moved to ChildProcess::updateProcessName, since it is needed to
3637         successfully update the process name. The call to ChildProcess::updateProcessName is made after entering
3638         the sandbox.
3639
3640         * Shared/AuxiliaryProcess.cpp:
3641         (WebKit::AuxiliaryProcess::initialize):
3642         * WebProcess/cocoa/WebProcessCocoa.mm:
3643         (WebKit::WebProcess::initializeProcessName):
3644         (WebKit::WebProcess::platformInitializeProcess):
3645         * WebProcess/com.apple.WebProcess.sb.in:
3646
3647 2019-02-07  Youenn Fablet  <youenn@apple.com>
3648
3649         Filter out Overconstrainederror.constraint when getUserMedia is not granted
3650         https://bugs.webkit.org/show_bug.cgi?id=194240
3651
3652         Reviewed by Eric Carlson.
3653
3654         Make sure in UIProcess to filter out constraint if either the page was not granted gum access or it has no persistent access.
3655
3656         Refactor UserMediaPermissionRequestManagerProxy to make the implementation easier to understand.
3657
3658         Covered by added test.
3659
3660         * UIProcess/UserMediaPermissionCheckProxy.cpp:
3661         (WebKit::UserMediaPermissionCheckProxy::setUserMediaAccessInfo):
3662         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
3663         (WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
3664         (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted):
3665         (WebKit::UserMediaPermissionRequestManagerProxy::grantAccess):
3666         (WebKit::UserMediaPermissionRequestManagerProxy::getRequestAction):
3667         (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
3668         (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):
3669         (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionInvalidRequest):
3670         (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest):
3671         (WebKit::UserMediaPermissionRequestManagerProxy::getUserMediaPermissionInfo):
3672         (WebKit::UserMediaPermissionRequestManagerProxy::wasGrantedVideoOrAudioAccess):
3673         (WebKit::UserMediaPermissionRequestManagerProxy::computeFilteredDeviceList):
3674         (WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
3675         (WebKit::UserMediaPermissionRequestManagerProxy::createPermissionRequest): Deleted.
3676         * UIProcess/UserMediaPermissionRequestManagerProxy.h:
3677         * UIProcess/UserMediaPermissionRequestProxy.h:
3678         (WebKit::UserMediaPermissionRequestProxy::isPending const):
3679         (WebKit::UserMediaPermissionRequestProxy::setEligibleVideoDeviceUIDs):
3680         (WebKit::UserMediaPermissionRequestProxy::setEligibleAudioDeviceUIDs):
3681         (WebKit::UserMediaPermissionRequestProxy::hasAudioDevice const):
3682         (WebKit::UserMediaPermissionRequestProxy::hasVideoDevice const):
3683         (WebKit::UserMediaPermissionRequestProxy::hasPersistentAccess const):
3684         (WebKit::UserMediaPermissionRequestProxy::setHasPersistentAccess):
3685         (WebKit::UserMediaPermissionRequestProxy::userMediaID const):
3686         (WebKit::UserMediaPermissionRequestProxy::topLevelDocumentSecurityOrigin const):
3687         (WebKit::UserMediaPermissionRequestProxy::userMediaDocumentSecurityOrigin const):
3688         (WebKit::UserMediaPermissionRequestProxy::userRequest const):
3689         (WebKit::UserMediaPermissionRequestProxy::setDeviceIdentifierHashSalt):
3690         (WebKit::UserMediaPermissionRequestProxy::deviceIdentifierHashSalt const):
3691         (WebKit::UserMediaPermissionRequestProxy::audioDevice const):
3692         (WebKit::UserMediaPermissionRequestProxy::videoDevice const):
3693         * UIProcess/WebPageProxy.cpp:
3694         (WebKit::WebPageProxy::requestUserMediaPermissionForFrame):
3695         * UIProcess/WebPageProxy.h:
3696
3697 2019-02-07  Wenson Hsieh  <wenson_hsieh@apple.com>
3698
3699         [iOS] [WK2] Modernize autocorrection context code
3700         https://bugs.webkit.org/show_bug.cgi?id=194373
3701
3702         Reviewed by Tim Horton.
3703
3704         * Shared/ios/WebAutocorrectionContext.h: Added.
3705         (WebKit::WebAutocorrectionContext::encode const):
3706         (WebKit::WebAutocorrectionContext::decode):
3707
3708         Introduce a WebAutocorrectionContext struct that encapsulates the individual pieces of autocorrection context.
3709         Change to use this instead of a long list of arguments when propagating autocorrection context information over
3710         IPC.
3711
3712         * UIProcess/AutoCorrectionCallback.h:
3713         * UIProcess/WebPageProxy.h:
3714         * UIProcess/WebPageProxy.messages.in:
3715         * UIProcess/ios/WKContentViewInteraction.h:
3716         * UIProcess/ios/WKContentViewInteraction.mm:
3717         (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
3718         (+[WKAutocorrectionContext autocorrectionContextWithContext:]):
3719         (+[WKAutocorrectionContext autocorrectionContextWithData:markedText:selectedText:afterText:selectedRangeInMarkedText:]): Deleted.
3720
3721         Change this constructor to take an entire WebAutocorrectionContext.
3722
3723         * UIProcess/ios/WebPageProxyIOS.mm:
3724         (WebKit::WebPageProxy::autocorrectionContextCallback):
3725         (WebKit::WebPageProxy::requestAutocorrectionContext):
3726         (WebKit::WebPageProxy::autocorrectionContextSync):
3727         (WebKit::WebPageProxy::getAutocorrectionContext): Deleted.
3728         * WebKit.xcodeproj/project.pbxproj:
3729         * WebProcess/WebPage/WebPage.h:
3730         * WebProcess/WebPage/WebPage.messages.in:
3731
3732         Use Delayed instead of LegacySync.
3733
3734         * WebProcess/WebPage/ios/WebPageIOS.mm:
3735         (WebKit::WebPage::autocorrectionContext):
3736
3737         Renamed from computeAutocorrectionContext. This is now a private method on WebPage that uses the focused or main
3738         frame to compute and return a WebAutocorrectionContext.
3739
3740         (WebKit::WebPage::requestAutocorrectionContext):
3741         (WebKit::WebPage::autocorrectionContextSync):
3742
3743         Renamed getAutocorrectionContext to autocorrectionContextSync.
3744
3745         (WebKit::computeAutocorrectionContext): Deleted.
3746         (WebKit::WebPage::getAutocorrectionContext): Deleted.
3747
3748 2019-02-07  Youenn Fablet  <youenn@apple.com>
3749
3750         Simplify applyConstraints callbacks
3751         https://bugs.webkit.org/show_bug.cgi?id=194297
3752
3753         Reviewed by Eric Carlson.
3754
3755         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
3756         (WebKit::UserMediaCaptureManagerProxy::applyConstraints):
3757         * WebProcess/cocoa/UserMediaCaptureManager.cpp:
3758         (WebKit::UserMediaCaptureManager::Source::applyConstraintsSucceeded):
3759         (WebKit::UserMediaCaptureManager::Source::applyConstraintsFailed):
3760         (WebKit::UserMediaCaptureManager::applyConstraintsFailed):
3761         * WebProcess/cocoa/UserMediaCaptureManager.h:
3762
3763 2019-02-07  Brent Fulgham  <bfulgham@apple.com>
3764
3765         Permit additional IOKit Properties needed by Media PlugIns on older Mac Hardware
3766         https://bugs.webkit.org/show_bug.cgi?id=194412
3767         <rdar://problem/47820615>
3768
3769         Reviewed by Per Arne Vollan.
3770
3771         * PluginProcess/mac/com.apple.WebKit.plugin-common.sb.in:
3772
3773 2019-02-07  Brent Fulgham  <bfulgham@apple.com>
3774
3775         Permit additional IOKit Properties needed by older Mac Hardware
3776         https://bugs.webkit.org/show_bug.cgi?id=194410
3777         <rdar://problem/47820620>
3778
3779         Reviewed by Per Arne Vollan.
3780
3781         * WebProcess/com.apple.WebProcess.sb.in:
3782
3783 2019-02-07  Brady Eidson  <beidson@apple.com>
3784
3785         Rename the TAKE_DOWNLOAD_ASSERTION macro.
3786
3787         Rubberstamped by Andy Estes.
3788
3789         * NetworkProcess/Downloads/DownloadMap.cpp:
3790         * NetworkProcess/Downloads/DownloadMap.h:
3791
3792 2019-02-07  Keith Rollin  <krollin@apple.com>
3793
3794         Fix XCBuild issue related to codesigning WebContent process
3795         https://bugs.webkit.org/show_bug.cgi?id=193799
3796         <rdar://problem/47533890>
3797
3798         Reviewed by Brent Fulgham.
3799
3800         Building with XCBuild enabled results in the error message "cannot
3801         read entitlement data" when trying to codesign the macOS XPC
3802         processes. The reason for this error message is that there is a build
3803         step that deletes any previous "stale" generated .xcent file before
3804         building up a new one. With XCBuild enabled, the build steps got
3805         re-ordered, such that the step that deletes this file could get
3806         executed after the steps that build up the file. The built-up set of
3807         entitlements is now gone, and the build process fails when `codesign`
3808         tries to access it.
3809
3810         The apparent quick-fix to this problem -- of tweaking dependencies so
3811         that the build steps execute in the desired order -- wouldn't work
3812         with XCBuild. Establishing these dependencies would require both
3813         having multiple build phases produce the same .xcent file as output,
3814         as well as a build phase that has this file as an input and an output.
3815         XCBuild either forbids or frowns upon these configurations.
3816
3817         Ultimately, the solution that worked was to take over complete control
3818         of the codesigning process. This means (a) not specifying a base
3819         .entitlements file that XCode uses to start with (and which was
3820         subsequently altered via custom build scripts), (b) not letting XCode
3821         automatically and silently inject a 'get-task-all' entitlement used to
3822         facilitate debugging (we now add that entitlement by hand), and (c)
3823         building up all of our entitlements by hand via a single custom
3824         script. Because of the addition of this custom script, many other
3825         scripts and entitlements files could now be removed.
3826
3827         * Configurations/BaseXPCService.xcconfig:
3828         * Configurations/Databases-iOS.entitlements: Removed.
3829         * Configurations/Network-OSX-restricted.entitlements: Removed.
3830         * Configurations/Network-OSX-sandbox.entitlements: Removed.
3831         * Configurations/Network-OSX.entitlements: Removed.
3832         * Configurations/NetworkService.xcconfig:
3833         * Configurations/PluginService.64.xcconfig:
3834         * Configurations/PluginService.entitlements: Removed.
3835         * Configurations/WebContent-OSX-sandbox.entitlements: Removed.
3836         * Configurations/WebContent-OSX.entitlements: Removed.
3837         * Configurations/WebContent-or-Plugin-OSX-restricted.entitlements: Removed.
3838         * Configurations/WebContentService.xcconfig:
3839         * Scripts/copy-webcontent-resources-to-private-headers.sh:
3840         * Scripts/process-entitlements.sh: Added.
3841         * Scripts/process-network-sandbox-entitlements.sh: Removed.
3842         * Scripts/process-webcontent-or-plugin-entitlements.sh: Removed.
3843         * Scripts/process-webcontent-sandbox-entitlements.sh: Removed.
3844         * WebKit.xcodeproj/project.pbxproj:
3845
3846 2019-02-07  Alex Christensen  <achristensen@webkit.org>
3847
3848         Fix internal build after r241127
3849         https://bugs.webkit.org/show_bug.cgi?id=191394
3850
3851         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:
3852         Add some (un)availability macros.
3853
3854 2019-02-07  Youenn Fablet  <youenn@apple.com>
3855
3856         Make to clear sources from UserMediaCaptureManagerProxy and UserMediaCaptureManager when no longer needed
3857         https://bugs.webkit.org/show_bug.cgi?id=194312
3858
3859         Reviewed by Eric Carlson.
3860
3861         Sources in UserMediaCaptureManager and Proxy are never removed once added to their HashMap.
3862         Use the 'ended' mechanism to do the clean-up on WebProcess side.
3863         As part of this clean-up, send IPC to UIProcess to do clean-up on proxy side.
3864         On WebProcess crash case, clean-up the proxy as well.
3865
3866         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
3867         (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
3868         (WebKit::UserMediaCaptureManagerProxy::end):
3869         (WebKit::UserMediaCaptureManagerProxy::clear):
3870         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
3871         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
3872         * UIProcess/WebProcessProxy.cpp:
3873         (WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
3874         * WebProcess/cocoa/UserMediaCaptureManager.cpp:
3875         (WebKit::UserMediaCaptureManager::sourceEnded):
3876         * WebProcess/cocoa/UserMediaCaptureManager.h:
3877
3878 2019-02-07  Alex Christensen  <achristensen@webkit.org>
3879
3880         Print backgrounds preference should be honored instead of WKWebViewConfiguration value
3881         https://bugs.webkit.org/show_bug.cgi?id=194364
3882         <rdar://problem/47627599>
3883
3884         Reviewed by Tim Horton.
3885
3886         Without this patch, changing the preference for printing the background has no effect.
3887         This patch fixes that, and I verified it manually by checking "Print backgrounds" in Safari's print menu.
3888         Unfortunately, the only way to test this is actually printing because only values from WebPageProxy::preferences
3889         or WebPageProxy::configuration's preferences are exposed to the API, but values from WebPageProxy::preferencesStore
3890         are used when printing.  Actually printing verifies this change fixes the bug.
3891
3892         * UIProcess/API/Cocoa/WKWebView.mm:
3893         (-[WKWebView _initializeWithConfiguration:]):
3894
3895 2019-02-07  Chris Dumez  <cdumez@apple.com>
3896
3897         Mark DisplayLink as fast allocated
3898         https://bugs.webkit.org/show_bug.cgi?id=194400
3899
3900         Reviewed by Geoffrey Garen.
3901
3902         * UIProcess/mac/DisplayLink.h:
3903
3904 2019-02-07  Per Arne Vollan  <pvollan@apple.com>
3905
3906         [macOS] API test times out after r241026
3907         https://bugs.webkit.org/show_bug.cgi?id=194372
3908
3909         Reviewed by Alex Christensen.
3910
3911         The API test TestWebKitAPI.RenderingProgress.FirstMeaningfulPaint times out after r241026.
3912         A new function pointer, layoutMilestones, is added to WKBundlePageLoaderClient, in order
3913         for clients to decide which milestones they would like to listen for.
3914
3915         * WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h:
3916         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
3917         (layoutMilestones):
3918         (setUpPageLoaderClient):
3919         * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
3920         (WebKit::InjectedBundlePageLoaderClient::layoutMilestones const):
3921         * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
3922
3923 2019-02-07  Alex Christensen  <achristensen@webkit.org>
3924
3925         Deprecate WKBundlePageSetDefersLoading
3926         https://bugs.webkit.org/show_bug.cgi?id=191394
3927
3928         Reviewed by Dean Jackson.
3929
3930         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
3931         (WKBundlePageSetDefersLoading):
3932         * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
3933         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
3934         (-[WKWebProcessPlugInBrowserContextController _defersLoading]):
3935         (-[WKWebProcessPlugInBrowserContextController _setDefersLoading:]):
3936         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:
3937
3938 2019-02-07  Alex Christensen  <achristensen@webkit.org>
3939
3940         Digital crown should scroll safe browsing warning on watchOS
3941         https://bugs.webkit.org/show_bug.cgi?id=194363
3942         <rdar://problem/47348124>
3943
3944         Reviewed by Wenson Hsieh.
3945
3946         * UIProcess/Cocoa/WKSafeBrowsingWarning.h:
3947         * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
3948         (-[WKSafeBrowsingWarning initWithFrame:safeBrowsingWarning:completionHandler:]):
3949         (-[WKSafeBrowsingWarning addContent]):
3950
3951 2019-02-07  Alex Christensen  <achristensen@webkit.org>
3952
3953    &