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