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