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