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