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