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