Allow WebKit clients to specify a minimum effective width for layout.
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2018-11-28  Yongjun Zhang  <yongjun_zhang@apple.com>
2
3         Allow WebKit clients to specify a minimum effective width for layout.
4         https://bugs.webkit.org/show_bug.cgi?id=191499
5         <rdar://problem/45362678>
6
7         Reviewed by Wenson Hsieh.
8
9         If we ignore the meta viewport (_shouldIgnoreMetaViewport is true), the default layout width will be device
10         width. For clients that wish to lay out the content with a different width value, we would need to add a way
11         to specify the effective width for layout.
12
13         * UIProcess/API/Cocoa/WKWebView.mm: Add an iVar _minimumEffectiveDeviceWidth.
14         (-[WKWebView _dispatchSetViewLayoutSize:]): Call the new setViewportConfigurationViewLayoutSize method.
15         (-[WKWebView _setViewScale:]): Ditto.
16         (-[WKWebView _setMinimumEffectiveWidth:]): The setter for _minimumEffectiveDeviceWidth.
17         (-[WKWebView _minimumEffectiveWidth]): Getter for _minimumEffectiveDeviceWidth
18         * UIProcess/API/Cocoa/WKWebViewPrivate.h: Add a property _minimumEffectiveDeviceWidth to WKWebView.
19         * UIProcess/WebPageProxy.h: Change setViewportConfigurationViewLayoutSize to take another argument minimumEffectiveDeviceWidth.
20         * UIProcess/ios/WebPageProxyIOS.mm:
21         (WebKit::WebPageProxy::setViewportConfigurationViewLayoutSize): Also send effectiveWidth to WebContent process.
22         * WebProcess/WebPage/WebPage.cpp:
23         (WebKit::WebPage::WebPage): Set the initial effective width to 0 when creating a web page, this tells ViewportConfiguration
24              to ignore the minimum effective width value.
25         * WebProcess/WebPage/WebPage.h: Change setViewportConfigurationViewLayoutSize to take another argument effectiveWidth.
26         * WebProcess/WebPage/WebPage.messages.in:
27         * WebProcess/WebPage/ios/WebPageIOS.mm:
28         (WebKit::WebPage::setViewportConfigurationViewLayoutSize): Also pass effectiveWidth value to ViewportConfiguration.
29
30 2018-11-28  Fujii Hironori  <Hironori.Fujii@sony.com>
31
32         Remove @no-unify of InjectedBundleRangeHandle.cpp and InjectedBundleNodeHandle.cpp
33         https://bugs.webkit.org/show_bug.cgi?id=191853
34
35         Reviewed by Michael Catanzaro.
36
37         In r235845, I excluded InjectedBundleRangeHandle.cpp and
38         InjectedBundleNodeHandle.cpp from unify source builds in order to
39         work around a MSVC bug.
40
41         Then, I commited a different workaround for the MSVC bug in
42         r238386. Now, we can include InjectedBundleRangeHandle.cpp and
43         InjectedBundleNodeHandle.cpp in unified source builds. Revert
44         r235845.
45
46         * Sources.txt: Removed @no-unify of InjectedBundleRangeHandle.cpp
47         and InjectedBundleNodeHandle.cpp
48         * WebKit.xcodeproj/project.pbxproj: Unchecked Target Membership
49         not to be compiled by XCode.
50
51 2018-11-28  Joseph Pecoraro  <pecoraro@apple.com>
52
53         Web Inspector: REGRESSION(r238378): reloading WebInspector after a settings change doesn't re-show WebInspector
54         https://bugs.webkit.org/show_bug.cgi?id=191971
55
56         Reviewed by Matt Baker.
57
58         * WebProcess/WebPage/WebInspector.cpp:
59         (WebKit::WebInspector::reopen): Deleted.
60         * WebProcess/WebPage/WebInspector.h:
61         * WebProcess/WebPage/WebInspector.messages.in:
62         Move reopen out of the WebProcess...
63
64         * UIProcess/WebInspectorProxy.cpp:
65         (WebKit::WebInspectorProxy::reopen):
66         * UIProcess/WebInspectorProxy.h:
67         * UIProcess/WebInspectorProxy.messages.in:
68         And into the UIProcess where the order of messages won't
69         be as problematic.
70
71         * WebProcess/WebPage/WebInspectorUI.cpp:
72         (WebKit::WebInspectorUI::reopen):
73         Send a message to the WebInspectorProxy instead.
74
75 2018-11-28  Alexey Proskuryakov  <ap@apple.com>
76
77         Remove another OS version check from NetworkDataTaskCocoa.mm
78         https://bugs.webkit.org/show_bug.cgi?id=192046
79
80         Reviewed by Alex Christensen.
81
82         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
83         (WebKit::NetworkDataTaskCocoa::statelessCookieStorage):
84
85 2018-11-28  Alexey Proskuryakov  <ap@apple.com>
86
87         Modernize version checks for same site cookie support
88         https://bugs.webkit.org/show_bug.cgi?id=192054
89
90         Reviewed by Tim Horton.
91
92         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::updateTaskWithFirstPartyForSameSiteCookies):
93         Also removed runtime checks, which are no longer relevant.
94
95 2018-11-27  Mark Lam  <mark.lam@apple.com>
96
97         ENABLE_FAST_JIT_PERMISSIONS should be false for iosmac.
98         https://bugs.webkit.org/show_bug.cgi?id=192055
99         <rdar://problem/46288783>
100
101         Reviewed by Saam Barati.
102
103         * Configurations/FeatureDefines.xcconfig:
104
105 2018-11-27  Alex Christensen  <achristensen@webkit.org>
106
107         Make synchronous IPC introduced in r237267 asynchronous
108         https://bugs.webkit.org/show_bug.cgi?id=190757
109
110         Reviewed by Chris Dumez.
111
112         * UIProcess/API/Cocoa/WKProcessPool.mm:
113         (-[WKProcessPool _getActivePagesOriginsInWebProcessForTesting:completionHandler:]):
114         (-[WKProcessPool _getActivePagesOriginsInWebProcessForTesting:]): Deleted.
115         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
116         * UIProcess/WebProcessPool.cpp:
117         (WebKit::WebProcessPool::activePagesOriginsInWebProcessForTesting):
118         * UIProcess/WebProcessPool.h:
119         * UIProcess/WebProcessProxy.cpp:
120         (WebKit::WebProcessProxy::activePagesDomainsForTesting):
121         * UIProcess/WebProcessProxy.h:
122         * WebProcess/WebProcess.cpp:
123         (WebKit::WebProcess::getActivePagesOriginsForTesting):
124         * WebProcess/WebProcess.messages.in:
125         * WebProcess/cocoa/WebProcessCocoa.mm:
126         (WebKit::WebProcess::getActivePagesOriginsForTesting):
127
128 2018-11-27  Alex Christensen  <achristensen@webkit.org>
129
130         Safe browsing warning text needs to be visible on High Sierra
131         https://bugs.webkit.org/show_bug.cgi?id=192022
132
133         Reviewed by Tim Horton.
134
135         Something about AppKit, autolayout, view insertion order, and NSTextView makes the text lay
136         out with initial size of {0, 0} on High Sierra. Using an NSTextField instead makes the details visible.
137
138         Covered by an API test.
139
140         * UIProcess/Cocoa/WKSafeBrowsingWarning.h:
141         * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
142         (makeLabel):
143         (-[WKSafeBrowsingWarning addContent]):
144         (-[WKSafeBrowsingWarning showDetailsClicked]):
145         (-[WKSafeBrowsingWarning layoutText]):
146         (makeTitleLabel): Deleted.
147
148 2018-11-27  Tim Horton  <timothy_horton@apple.com>
149
150         WKNavigation.AutomaticViewReloadAfterWebProcessCrash asserts after r238538
151         https://bugs.webkit.org/show_bug.cgi?id=192038
152         <rdar://problem/46288457>
153
154         Reviewed by Wenson Hsieh.
155
156         * UIProcess/WebPageProxy.cpp:
157         (WebKit::m_resetRecentCrashCountTimer):
158         (WebKit::WebPageProxy::finishAttachingToWebProcess):
159         (WebKit::WebPageProxy::resetState):
160         (WebKit::m_editableImageController): Deleted.
161         Properly invalidate m_editableImageController when resetting WebPageProxy.
162         Otherwise, the MessageReceiverMaps get invalidated, then later when
163         EditableImageController goes away we assert trying to remove the receiver.
164
165 2018-11-27  Jiewen Tan  <jiewen_tan@apple.com>
166
167         (r238246) [ MacOS Debug ] Layout Test http/wpt/webauthn/ctap-hid-failure.https.html is Crashing
168         https://bugs.webkit.org/show_bug.cgi?id=191757
169
170         Reviewed by Chris Dumez.
171
172         Wrong nonce error causes retransmission, which then trigger wrong nonce error. This is expected
173         behavior for mock testing. However, the main thread could time out when MockHidConnection::send
174         is excuting the block on another thread. The block will then return without invoking the callback,
175         which triggers this WTFCrash. The solution is always invoking the callback before return in the
176         block.
177
178         * UIProcess/WebAuthentication/Mock/MockHidConnection.cpp:
179         (WebKit::MockHidConnection::send):
180
181 2018-11-27  Keith Rollin  <krollin@apple.com>
182
183         Better parsing of comments in generate-message*.py
184         https://bugs.webkit.org/show_bug.cgi?id=191866
185         <rdar://problem/46189563>
186
187         Reviewed by Chris Dumez.
188
189         The script parsing the *.messages.in files would treat a line starting
190         with '#' as a comment, but not a line starting with '<whitespace>#'.
191         This means that jamming a '#' right in front of the first character of
192         a message definition (as opposed to the beginning of a line) will have
193         no effect and the line will get treated just the same as a
194         non-commented line. Fix this by trimming all white space from the
195         beginning and ending of the line before processing it.
196
197         * Scripts/webkit/parser.py:
198         (parse):
199         * Scripts/webkit/test-messages.in:
200
201 2018-11-27  Thibault Saunier  <tsaunier@igalia.com>
202
203         [GTK|WPE] Allow disabling WebRTC unified plan SDP through an env var
204         https://bugs.webkit.org/show_bug.cgi?id=192024
205
206         Reviewed by Michael Catanzaro.
207
208         * UIProcess/API/glib/WebKitSettings.cpp:
209         (webKitSettingsConstructed):
210
211 2018-11-27  Alexey Proskuryakov  <ap@apple.com>
212
213         Modernize the check for async _saveCookies existence
214         https://bugs.webkit.org/show_bug.cgi?id=191987
215
216         Reviewed by Dean Jackson.
217
218         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
219         (WebKit::NetworkProcess::platformSyncAllCookies):
220
221 2018-11-27  Tim Horton  <timothy_horton@apple.com>
222
223         Serialize and deserialize editable image strokes
224         https://bugs.webkit.org/show_bug.cgi?id=192002
225         <rdar://problem/30900149>
226
227         Reviewed by Dean Jackson.
228
229         * UIProcess/API/APIAttachment.cpp:
230         (API::Attachment::updateAttributes):
231         * UIProcess/WebPageProxy.cpp:
232         (WebKit::WebPageProxy::willUpdateAttachmentAttributes):
233         * UIProcess/WebPageProxy.h:
234         When an attachment would update its DOM attributes, plumb a notification
235         to EditableImageController, and allow it to block the update (because
236         we don't really want to set src for editable image attachments,
237         we just want the UI process to fully own the data).
238
239         * Platform/spi/ios/PencilKitSPI.h:
240         Add some SPI.
241
242         * UIProcess/ios/EditableImageController.h:
243         * UIProcess/ios/EditableImageController.mm:
244         (WebKit::EditableImageController::loadStrokesFromAttachment):
245         Add a helper to load strokes from an attachment.
246
247         (WebKit::EditableImageController::associateWithAttachment):
248         Try to load strokes from the attachment when initially associated.
249         Don't create a file wrapper around a null image, so it will be regenerated later.
250
251         (WebKit::EditableImageController::willUpdateAttachmentAttributes):
252         The aforementioned plumbing at update time.
253
254         * UIProcess/ios/WKDrawingView.h:
255         * UIProcess/ios/WKDrawingView.mm:
256         (-[WKDrawingView layoutSubviews]):
257         Invalidate the attachment (so it will be regenerated upon request) if the
258         canvas size changes.
259
260         (-[WKDrawingView PNGRepresentation]):
261         Serialize strokes into the EXIF User Comment field.
262         We will find a different field to use (ideally a custom vendor-specific
263         field that nobody else will use for anything), but this works for now.
264
265         Don't try to render an image if we don't have a size or scale;
266         PKImageRenderer will just fail anyway, so bail early.
267
268         In the iOS Simulator, PKImageRenderer currently returns an unusable image.
269         Instead, so that we have a image on which to serialize the strokes,
270         create a transparent 1x1 image. This makes it possible to serialize strokes
271         even though we don't have a usable rendered image, so that we can still test
272         this change (and future changes).
273
274         (-[WKDrawingView loadDrawingFromPNGRepresentation:]):
275         If available, deserialize strokes from the EXIF User Comment field.
276
277         (-[WKDrawingView drawingDidChange:]):
278         (-[WKDrawingView invalidateAttachment]):
279         Factor invalidateAttachment out of drawingDidChange so we can call
280         it from layoutSubviews too!
281
282 2018-11-27  Chris Dumez  <cdumez@apple.com>
283
284         Regression(PSON) crash under WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame()
285         https://bugs.webkit.org/show_bug.cgi?id=191983
286         <rdar://problem/46246863>
287
288         Reviewed by Geoffrey Garen.
289
290         * UIProcess/WebPageProxy.cpp:
291         (WebKit::WebPageProxy::continueNavigationInNewProcess):
292         Make sure the navigation still exists in m_mainFrameCreationHandler and return early if it
293         does not.
294
295         (WebKit::WebPageProxy::resetState):
296         Clear out m_mainFrameCreationHandler / m_mainFrameWindowCreationHandler if we resetting the state
297         after a crash. At this point, there is no chance the WebProcess will send us the IPC that will
298         cause these to get called and we do not want old state to remain for future navigations.
299
300 2018-11-16  Jiewen Tan  <jiewen_tan@apple.com>
301
302         Disallow loading webarchives as iframes
303         https://bugs.webkit.org/show_bug.cgi?id=191728
304         <rdar://problem/45524528>
305
306         Reviewed by Youenn Fablet.
307
308         * UIProcess/WebPageProxy.cpp:
309         (WebKit::WebPageProxy::unableToImplementPolicy):
310         Add a check to prevent null pointer dereference.
311
312 2018-11-27  Wenson Hsieh  <wenson_hsieh@apple.com>
313
314         WebKit.AddAndRemoveDataDetectors hits a debug assertion after r238515
315         https://bugs.webkit.org/show_bug.cgi?id=191996
316
317         Reviewed by Tim Horton.
318
319         This assertion is hit because `decode(Decoder& decoder, NSArray<Class> *allowedClasses)` expects the decoded
320         object (of class `_NSArrayM`) to be equal to `NSArray.class`.
321
322         We fix the crash by relaxing the debug assertion when decoding securely-codable objects over IPC. Instead of
323         checking that the class of the decoded object is equal to one of the allowed classes, check that the object is a
324         kind of any of the allowed classes.
325
326         * Shared/Cocoa/ArgumentCodersCocoa.h:
327         (IPC::isObjectClassAllowed):
328         (IPC::decode):
329
330 2018-11-27  Tomas Popela  <tpopela@redhat.com>
331
332         [GTK][WPE] Remove temporary workaround in Source/WebKit/Platform*.cmake
333         https://bugs.webkit.org/show_bug.cgi?id=192008
334
335         Reviewed by Michael Catanzaro.
336
337         Looks like it's not needed anymore as the code compiles fine without
338         it.
339
340         * PlatformGTK.cmake:
341         * PlatformWPE.cmake:
342
343 2018-11-27  Antti Koivisto  <antti@apple.com>
344
345         Factor mask layer applying in RemoteLayerTreePropertyApplier into a shared function
346         https://bugs.webkit.org/show_bug.cgi?id=192001
347
348         Reviewed by Tim Horton.
349
350         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
351         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
352         (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
353         (WebKit::RemoteLayerTreePropertyApplier::updateMask):
354
355         Shared function, with some special tricks for iOS backdrop layers.
356
357         (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):
358
359 2018-11-27  Antti Koivisto  <antti@apple.com>
360
361         Stop collecting related layers in RemoteLayerTreeHost::updateLayerTree
362         https://bugs.webkit.org/show_bug.cgi?id=192003
363
364         Reviewed by Tim Horton.
365
366         We can pass the node hash directly to RemoteLayerTreePropertyApplier. The collection step doesn't seem
367         to add anything except an extra hash lookup.
368
369         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
370         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
371         (WebKit::RemoteLayerTreeHost::updateLayerTree):
372
373         Pass m_nodes directly.
374         Some random cleanups.
375
376 2018-11-27  Antti Koivisto  <antti@apple.com>
377
378         Remote tile layers shouldn't be UIViews
379         https://bugs.webkit.org/show_bug.cgi?id=191953
380
381         Reviewed by Tim Horton.
382
383         They don't need any UIView functionality, nor do they ever have UIView descendants.
384         We can use lighter weight objects.
385
386         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
387         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
388         (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
389         (WebKit::RemoteLayerTreePropertyApplier::updateChildren):
390
391         Factor to a function shared between platforms.
392         Support having both views and plain layers in the same tree.
393         Assert that all siblings are of the same type and that we don't attempt to add views to layers.
394
395         (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):
396         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
397         (WebKit::RemoteLayerTreeHost::makeNode):
398
399         Use new plain layer on Mac too.
400
401         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
402         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm:
403         (-[WKPlainRemoteLayer description]):
404
405         Add a CALayer subclass so we can have a description, similar to WKCompositingView and pals.
406
407         (WebKit::RemoteLayerTreeNode::createWithPlainLayer):
408         (WebKit::RemoteLayerTreeNode::detachFromParent):
409
410         Support having null view.
411
412         (WebKit::RemoteLayerTreeNode::appendLayerDescription):
413
414         Helper for layer descriptions.
415
416         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
417         (WebKit::RemoteLayerTreeHost::makeNode):
418
419         Construct plain layers for tiles.
420
421         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
422         (-[WKCompositingView description]):
423         (-[WKUIRemoteView description]):
424         (-[WKBackdropView description]):
425
426 2018-11-27  Fujii Hironori  <Hironori.Fujii@sony.com>
427
428         Remove "using namespace WebCore" under Source/WebKit/WebProcess/InjectedBundle/API
429         https://bugs.webkit.org/show_bug.cgi?id=191995
430
431         Reviewed by Alex Christensen.
432
433         The statement "using namespace WebCore" should be placed inside
434         namespace WebKit for unified source builds. But, source files
435         defining WebKit API can't be enclosed by namespace WebKit { }
436         becuase they are defined in the global scope.
437
438         "using namespace WebCore" in global scope and unified source
439         builds may cause build breaks (Bug 191853).
440
441         Remove "using namespace WebCore" in the global scope. Use
442         "WebCore::" prefix instead.
443
444         * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
445         (WKBundleClearAllDatabases):
446         (WKBundleSetDatabaseQuota):
447         (WKBundleClearResourceLoadStatistics):
448         (WKBundleResourceLoadStatisticsNotifyObserver):
449         * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
450         (WKBundleFrameGetFrameLoadState):
451         (WKBundleFrameClearOpener):
452         (WKBundleFrameCallShouldCloseOnWebView):
453         (WKBundleFrameCopySecurityOrigin):
454         (WKBundleFrameFocus):
455         * WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp:
456         * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
457
458 2018-11-26  Wenson Hsieh  <wenson_hsieh@apple.com>
459
460         [Cocoa] No way for clients to tell whether the content view is in the responder chain when the web view is
461         https://bugs.webkit.org/show_bug.cgi?id=169212
462         <rdar://problem/30899656>
463
464         Reviewed by Tim Horton.
465
466         Add an SPI hook to allow internal WKWebView clients to determine whether the WKWebView's content view is the
467         first responder. Intended for use by clients, such as Mail, that embed native text input views and other views
468         that may become first responder within the view hierarchy of the WKWebView.
469
470         * UIProcess/API/Cocoa/WKWebView.mm:
471         (-[WKWebView _contentViewIsFirstResponder]):
472         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
473
474 2018-11-26  Tim Horton  <timothy_horton@apple.com>
475
476         Insert <attachment> elements under editable images to make their backing data accessible
477         https://bugs.webkit.org/show_bug.cgi?id=191844
478         <rdar://problem/30900149>
479
480         Reviewed by Simon Fraser.
481
482         * DerivedSources.make:
483         * SourcesCocoa.txt:
484         * UIProcess/API/APIAttachment.h:
485         fileWrapper() is no longer a trivial getter; it can now construct
486         the file wrapper from a file wrapper generator if necessary.
487
488         Add setFileWrapperGenerator() and invalidateGeneratedFileWrapper().
489
490         Make m_fileWrapper mutable so it can be adjusted inside its own getter.
491
492         * UIProcess/API/Cocoa/APIAttachmentCocoa.mm:
493         (API::Attachment::fileWrapper const):
494         If we have a fileWrapperGenerator and don't have a cached file wrapper,
495         create one before returning it.
496
497         (API::Attachment::invalidateGeneratedFileWrapper):
498         Invalidate the currently-cached file wrapper. The next time a client
499         requests the file wrapper it will be regenerated.
500
501         (API::Attachment::fileName const):
502         (API::Attachment::fileSizeForDisplay const):
503         (API::Attachment::enclosingImageData const):
504         (API::Attachment::isEmpty const):
505         (API::Attachment::createSerializedRepresentation const):
506         Make use of fileWrapper() instead of m_fileWrapper directly, to ensure
507         that it is created lazily if necessary.
508
509         (API::Attachment::setFileWrapperGenerator):
510         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
511         (WebKit::RemoteLayerTreeHost::createEmbeddedView):
512         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h:
513         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
514         (-[WKEmbeddedView initWithEmbeddedViewID:]):
515         Defer to EditableImageController for creating WKDrawingViews for
516         editable images. This is done primarily so we don't have to pollute
517         Remote Layer Tree and DrawingArea interfaces with editable-image-specific messages.
518
519         * UIProcess/WebPageProxy.cpp:
520         (WebKit::m_editableImageController):
521         (WebKit::m_resetRecentCrashCountTimer): Deleted.
522         * UIProcess/WebPageProxy.h:
523         (WebKit::WebPageProxy::editableImageController):
524         Keep an EditableImageController on the WebPageProxy.
525
526         * UIProcess/ios/EditableImageController.h: Added.
527         * UIProcess/ios/EditableImageController.messages.in: Added.
528         * UIProcess/ios/EditableImageController.mm: Added.
529         (WebKit::EditableImageController::EditableImageController):
530         (WebKit::EditableImageController::~EditableImageController):
531         (WebKit::EditableImageController::ensureEditableImage):
532         (WebKit::EditableImageController::editableImage):
533         (WebKit::EditableImageController::didCreateEditableImage):
534         (WebKit::EditableImageController::didDestroyEditableImage):
535         (WebKit::EditableImageController::associateWithAttachment):
536         (WebKit::EditableImageController::invalidateAttachmentForEditableImage):
537         Add EditableImageController, which keeps track of EditableImages.
538         It can be messaged directly to create or destroy the UI-side state
539         of an editable image, and also to associate a WKDrawingView with
540         a particular attachment.
541
542         * UIProcess/ios/WKDrawingView.h:
543         * UIProcess/ios/WKDrawingView.mm:
544         (-[WKDrawingView initWithEmbeddedViewID:webPageProxy:]):
545         Store the WebPageProxy (weakly) so that we can get to the EditableImageController.
546
547         (-[WKDrawingView layoutSubviews]):
548         (-[WKDrawingView PNGRepresentation]):
549         Synchronously render the PKCanvasView to PNG.
550
551         (-[WKDrawingView drawingDidChange:]):
552         If the drawing changes, inform the APIAttachment that it needs
553         to discard its NSFileWrapper; a new one will be generated lazily.
554
555         (-[WKDrawingView init]): Deleted.
556         * WebKit.xcodeproj/project.pbxproj:
557         * WebProcess/WebCoreSupport/WebChromeClient.h:
558         * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
559         (WebKit::WebChromeClient::associateEditableImageWithAttachment):
560         (WebKit::WebChromeClient::didCreateEditableImage):
561         (WebKit::WebChromeClient::didDestroyEditableImage):
562
563 2018-11-26  Jer Noble  <jer.noble@apple.com>
564
565         Adopt -setOverrideRouteSharingPolicy:routingContextUID: SPI
566         https://bugs.webkit.org/show_bug.cgi?id=190951
567         <rdar://problem/45213065>
568
569         Reviewed by Alex Christensen.
570
571         Add an asyncronous reply request to VideoFullscreenManager.
572
573         * Platform/IPC/MessageSender.h:
574         (IPC::MessageSender::sendWithAsyncReply):
575         * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
576         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
577         (WebKit::VideoFullscreenModelContext::requestRouteSharingPolicyAndContextUID):
578         * WebProcess/cocoa/VideoFullscreenManager.h:
579         * WebProcess/cocoa/VideoFullscreenManager.messages.in:
580         * WebProcess/cocoa/VideoFullscreenManager.mm:
581         (WebKit::VideoFullscreenManager::requestRouteSharingPolicyAndContextUID):
582
583 2018-11-26  Alex Christensen  <achristensen@webkit.org>
584
585         Rename WKWebView._safeBrowsingWarningForTesting to _safeBrowsingWarning to use it for more than testing
586         https://bugs.webkit.org/show_bug.cgi?id=191981
587
588         Reviewed by Tim Horton.
589
590         * UIProcess/API/Cocoa/WKWebView.mm:
591         (-[WKWebView _safeBrowsingWarning]):
592         (-[WKWebView _safeBrowsingWarningForTesting]): Deleted.
593         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
594
595 2018-11-26  Daniel Bates  <dabates@apple.com>
596
597         REGRESSION (r237738): Command Down Arrow doesn't scroll to the end of a page anymore
598         https://bugs.webkit.org/show_bug.cgi?id=191967
599         <rdar://problem/45976390>
600
601         Reviewed by Tim Horton.
602
603         Fixes an issue where pressing Command + Down Arrow does not scroll the view to the end of the page.
604
605         Following r237738 the value of the enumerations used to identify modifier keys (e.g. Shift) changed
606         to match the values of the corresponding enumerations in GraphicsServices, which are the
607         enumerations UIKit uses to computes the modifier flags bitmask when instantiating a WebEvent to
608         pass to WebKit. Before r237738 WebKit was using enumerations whose values matched the values
609         of the corresponding UIKit public API UIKeyModifier* enumerations. For non-content editable elements,
610         WebKit intercepts UIKit events in -_handleKeyUIEvent, synthesizes and dispatches its own WebEvent.
611         However it was creating WebEvents with a modifier flags bitmask built from the UIKeyModifier* enumerations,
612         -_modifierFlags, as opposed to a bitmask from the GraphicsServices enumerations, -_gsModifierFlags.
613         Instead WebKit should call -_gsModifierFlags to compute the GraphicsServices-compatible modifier
614         flags bitmask when instantiating a WebEvent.
615
616         * Platform/spi/ios/UIKitSPI.h: Expose -_gsModifierFlags and remove -_modifierFlags.
617         * UIProcess/ios/WKContentViewInteraction.mm:
618         (-[WKContentView _handleKeyUIEvent:]): Remove unnecessary code to update the current modifier state.
619         This will be done by the WebProcess when it receives the keyboard event.
620         (-[WKContentView _didHandleKeyEvent:eventWasHandled:]): Do not pass modifier flags changed events
621         to the scrolling animator as it does not know how to handle these kinds of events and triggers an
622         assertion failure when it tries to read the input string from the event (calls -charactersIgnoringModifiers).
623         FlagsChanged WebEvents events do not have an input string just like a FlagsChanged NSEvent that
624         they model on Mac.
625         * UIProcess/ios/WKWebEvent.mm:
626         (-[WKWebEvent initWithEvent:]): Pass the value of -_gsModifierFlags for the modifier flags bitmask
627         instead of the value of -_modifierFlags.
628
629 2018-11-26  Chris Dumez  <cdumez@apple.com>
630
631         [PSON] process pre-warming should not be on for everyone
632         https://bugs.webkit.org/show_bug.cgi?id=191966
633         <rdar://problem/46138499>
634
635         Reviewed by Ryosuke Niwa.
636
637         If automatic process-prewarming is not explicitly turned on/off by the client, then we now only
638         turn it on automatically after the first process swap. Previously, it was always enabled if
639         process-swap on cross-site navigation was enabled (which is the case by default for all apps).
640
641         This is important because some apps do not actually browse (only display static content) or never
642         browse cross-site, and thus would not benefit from process prewarming and yet pay a memory cost.
643
644         * UIProcess/API/APIProcessPoolConfiguration.h:
645         Add m_clientWouldBenefitFromAutomaticProcessPrewarming flag which is false by default and is used
646         as a fallback if the client did not call setIsAutomaticProcessWarmingEnabled().
647
648         * UIProcess/API/C/WKContextConfigurationRef.cpp:
649         (WKContextConfigurationPrewarmsProcessesAutomatically):
650         (WKContextConfigurationSetPrewarmsProcessesAutomatically):
651         Add C API to toggle automatic process prewarming. It is needed for Safari to turn on this feature
652         by default for browsing. This way Safari does not have to wait for the first process swap to
653         start prewarming.
654
655         * UIProcess/API/C/WKContextConfigurationRef.h:
656         * UIProcess/WebProcessPool.cpp:
657         (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
658         Only do automatic process prewarming if process-swap on cross-site navigation is also enabled.
659         This is needed for clients like Safari that explicitly enable automatic process prewarming but
660         only want to have it enabled if PSON is also enabled via experimental features.
661
662         (WebKit::WebProcessPool::processForNavigation):
663         On first process swap, if the client did not explicitly turn on or off automatic process prewarming
664         then we enable it then. This avoids paying the cost of process prewarming in apps that would not
665         benefit from it.
666
667 2018-11-26  Andy Estes  <aestes@apple.com>
668
669         [Cocoa] Make it easier to encode NSObjects
670         https://bugs.webkit.org/show_bug.cgi?id=191948
671
672         Reviewed by Dean Jackson.
673
674         It should be easier to encode objects that conform to NSSecureCoding for WebKit IPC. Right
675         now, several argument coders duplicate the logic for encoding and decoding objects using
676         NSKeyedArchiver and NSKeyedUnarchiver.
677
678         This patch adds encodeObject() and decodeObject() primitives for encoding and decoding using
679         Foundation keyed archiving. It then partially specializes ArgumentCoder for raw pointers and
680         RetainPtrs whose pointee conforms to NSSecureCoding to call these new primitives.
681
682         This allows us to use Encoder::operator<< to encode raw pointers or RetainPtrs and use
683         Decoder::operator>> to decode to an optional RetainPtr. By default, IPC::decode infers the
684         allowed class for decoding by calling `[T class]`. We can also specify the allowed classes
685         explicitly for containers and classes that are loaded at runtime.
686
687         * Shared/Cocoa/ArgumentCodersCocoa.h: Added.
688         * Shared/Cocoa/ArgumentCodersCocoa.mm: Added.
689         * Shared/Cocoa/DataDetectionResult.mm:
690         (WebKit::DataDetectionResult::encode const): Removed custom encoding code and used ArgumentCodersCocoa instead.
691         (WebKit::DataDetectionResult::decode): Ditto.
692         * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
693         (IPC::ArgumentCoder<WebCore::Payment>::encode): Ditto.
694         (IPC::ArgumentCoder<WebCore::Payment>::decode): Ditto.
695         (IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode): Ditto.
696         (IPC::ArgumentCoder<WebCore::PaymentContact>::encode): Ditto.
697         (IPC::ArgumentCoder<WebCore::PaymentContact>::decode): Ditto.
698         (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::encode): Ditto.
699         (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::decode): Ditto.
700         (IPC::ArgumentCoder<WebCore::PaymentMethod>::encode): Ditto.
701         (IPC::ArgumentCoder<WebCore::PaymentMethod>::decode): Ditto.
702         (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode): Ditto.
703         * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
704         (WebKit::RemoteLayerTreeTransaction::description const): Added some needed namespaces due to unified source shuffling.
705         * Shared/WebCoreArgumentCoders.h: Modernized several decoders.
706         * Shared/ios/InteractionInformationAtPosition.mm:
707         (WebKit::InteractionInformationAtPosition::encode const): Removed custom encoding code and used ArgumentCodersCocoa instead.
708         (WebKit::InteractionInformationAtPosition::decode): Ditto.
709         * Shared/mac/WebCoreArgumentCodersMac.mm:
710         (IPC::ArgumentCoder<WebCore::ProtectionSpace>::encodePlatformData): Ditto.
711         (IPC::ArgumentCoder<WebCore::ProtectionSpace>::decodePlatformData): Ditto.
712         (IPC::ArgumentCoder<WebCore::Credential>::encodePlatformData): Ditto.
713         (IPC::ArgumentCoder<WebCore::Credential>::decodePlatformData): Ditto.
714         (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData): Ditto.
715         (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData): Ditto.
716         (IPC::deviceContextKey): Deleted.
717         * Shared/mac/WebHitTestResultData.mm:
718         (WebKit::WebHitTestResultData::platformEncode const): Ditto.
719         (WebKit::WebHitTestResultData::platformDecode): Ditto.
720         * SourcesCocoa.txt: Added ArgumentCodersCocoa.mm.
721         * WebKit.xcodeproj/project.pbxproj: Ditto.
722
723 2018-11-26  Wenson Hsieh  <wenson_hsieh@apple.com>
724
725         CompletionHandler-based async IPC messages only work when the completion handler takes a single argument
726         https://bugs.webkit.org/show_bug.cgi?id=191965
727
728         Reviewed by Tim Horton.
729
730         Teach `messages.py` to handle the case where an async IPC completion handler takes no arguments, or takes more
731         than a single argument. Currently, the generated code attempts to wrap all arguments in a `WTFMove(*~)`, but
732         this either results in `WTFMove(*)` in the case where there are no arguments, or `WTFMove(*foo, *bar, *baz)` in
733         the case where there are several arguments. Both of these results fail to compile.
734
735         Instead, emit `completionHandler()` when there are no arguments, and
736         `completionHandler(WTFMove(*foo), WTFMove(*bar), WTFMove(*baz))` when there are multiple arguments.
737
738         Tests:  TestAsyncMessageWithNoArguments
739                 TestAsyncMessageWithMultipleArguments
740
741         * Scripts/webkit/MessageReceiverSuperclass-expected.cpp:
742         (Messages::WebPage::TestAsyncMessageWithNoArguments::callReply):
743         (Messages::WebPage::TestAsyncMessageWithNoArguments::cancelReply):
744         (Messages::WebPage::TestAsyncMessageWithNoArguments::send):
745         (Messages::WebPage::TestAsyncMessageWithMultipleArguments::callReply):
746         (Messages::WebPage::TestAsyncMessageWithMultipleArguments::cancelReply):
747         (Messages::WebPage::TestAsyncMessageWithMultipleArguments::send):
748         (WebKit::WebPage::didReceiveMessage):
749         * Scripts/webkit/MessagesSuperclass-expected.h:
750         (Messages::WebPage::TestAsyncMessageWithNoArguments::receiverName):
751         (Messages::WebPage::TestAsyncMessageWithNoArguments::name):
752         (Messages::WebPage::TestAsyncMessageWithNoArguments::asyncMessageReplyName):
753         (Messages::WebPage::TestAsyncMessageWithNoArguments::arguments const):
754         (Messages::WebPage::TestAsyncMessageWithMultipleArguments::receiverName):
755         (Messages::WebPage::TestAsyncMessageWithMultipleArguments::name):
756         (Messages::WebPage::TestAsyncMessageWithMultipleArguments::asyncMessageReplyName):
757         (Messages::WebPage::TestAsyncMessageWithMultipleArguments::arguments const):
758         * Scripts/webkit/messages.py:
759         * Scripts/webkit/messages_unittest.py:
760
761         Add new `messages.py` unit tests to cover these cases.
762
763         * Scripts/webkit/test-superclass-messages.in:
764
765 2018-11-26  Jeremy Jones  <jeremyj@apple.com>
766
767         Use Full Screen consistently in localizable strings.
768         https://bugs.webkit.org/show_bug.cgi?id=190363
769         rdar://problem/43882333
770
771         Reviewed by Jon Lee.
772
773         Rename "Fullscreen" to "Full Screen" in localizable strings for consistency.
774
775         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
776         (-[WKFullScreenViewController _showPhishingAlert]):
777
778 2018-11-26  Daniel Bates  <dabates@apple.com>
779
780         Wire up ChromeClient::takeFocus() on iOS
781         https://bugs.webkit.org/show_bug.cgi?id=191763
782         <rdar://problem/18584508>
783
784         Reviewed by Dan Bernstein.
785
786         Expose existing Mac SPI for use on iOS. This will allow Safari to be notified when
787         the engine has cycled through all the tab focusable elements on the page.
788
789         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
790         * UIProcess/Cocoa/UIDelegate.h:
791         * UIProcess/Cocoa/UIDelegate.mm:
792         (WebKit::UIDelegate::setDelegate):
793
794 2018-11-26  Wenson Hsieh  <wenson_hsieh@apple.com>
795
796         Unreviewed, fix the internal 32-bit macOS 10.13 build after r238471
797
798         r238471 added an `#include WebPageMessages.h` in `WebPage.h`, which causes the 32-bit macOS build using an
799         internal macOS SDK ≤ 10.13 to fail. To address this, move the `#include` back under `PLATFORM(IOS_FAMILY)` by
800         changing the parameters of `WebPage::removeDataDetectedLinks` and `WebPage::detectDataInAllFrames` to completion
801         handlers rather than async IPC replies.
802
803         * WebProcess/WebPage/WebPage.cpp:
804         (WebKit::WebPage::removeDataDetectedLinks):
805         (WebKit::WebPage::detectDataInAllFrames):
806         * WebProcess/WebPage/WebPage.h:
807
808 2018-11-26  Antti Koivisto  <antti@apple.com>
809
810         Clean up layer tree freezing logic in WebPage
811         https://bugs.webkit.org/show_bug.cgi?id=191826
812
813         Reviewed by Dean Jackson.
814
815         Use OptionSet<LayerTreeFreezeReason> to track various reasons that can cause layer tree to get frozen.
816
817         * WebProcess/WebPage/WebPage.cpp:
818         (WebKit::WebPage::reinitializeWebPage):
819         (WebKit::WebPage::freezeLayerTree):
820         (WebKit::WebPage::unfreezeLayerTree):
821         (WebKit::WebPage::updateDrawingAreaLayerTreeFreezeState):
822
823         Layer tree is unfrozen when there there are no reasons to freeze it.
824
825         (WebKit::WebPage::didStartPageTransition):
826         (WebKit::WebPage::didCompletePageTransition):
827         (WebKit::WebPage::beginPrinting):
828         (WebKit::WebPage::endPrinting):
829         (WebKit::WebPage::setIsSuspended):
830         (WebKit::WebPage::setLayerTreeStateIsFrozen): Deleted.
831         * WebProcess/WebPage/WebPage.h:
832         * WebProcess/WebPage/ios/WebPageIOS.mm:
833         (WebKit::WebPage::applicationDidEnterBackground):
834         (WebKit::WebPage::applicationWillEnterForeground):
835         * WebProcess/WebProcess.cpp:
836         (WebKit::WebProcess::actualPrepareToSuspend):
837         (WebKit::WebProcess::cancelPrepareToSuspend):
838         (WebKit::WebProcess::freezeAllLayerTrees):
839         (WebKit::WebProcess::unfreezeAllLayerTrees):
840         (WebKit::WebProcess::processDidResume):
841         (WebKit::WebProcess::setAllLayerTreeStatesFrozen): Deleted.
842         * WebProcess/WebProcess.h:
843
844 2018-11-25  Antti Koivisto  <antti@apple.com>
845
846         RemoteLayerTreeNode construction cleanups
847         https://bugs.webkit.org/show_bug.cgi?id=191951
848
849         Reviewed by Tim Horton.
850
851         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
852         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
853         (WebKit::RemoteLayerTreeHost::updateLayerTree):
854
855             Drop unused LayerProperties argument.
856
857         (WebKit::RemoteLayerTreeHost::createLayer):
858
859             Split the actual construction out to makeNode.
860             Map updating is shared between platforms.
861             Move setting of layerID and clearing default actions to RemoteLayerTreeNode.
862
863         (WebKit::RemoteLayerTreeHost::makeNode):
864
865             Returns RemoteLayerTreeNode.
866
867         (WebKit::RemoteLayerTreeHost::setLayerID): Deleted.
868         (WebKit::RemoteLayerTreeHost::layerID): Deleted.
869
870             Move to RemoteLayerTreeNode.
871
872         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
873         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm:
874         (WebKit::RemoteLayerTreeNode::RemoteLayerTreeNode):
875         (WebKit::RemoteLayerTreeNode::setLayerID):
876         (WebKit::RemoteLayerTreeNode::layerID):
877         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
878         (WebKit::RemoteLayerTreeHost::makeNode):
879         (WebKit::RemoteLayerTreeHost::createEmbeddedView):
880         (WebKit::RemoteLayerTreeHost::createLayer): Deleted.
881         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
882         (-[WKCompositingView description]):
883         (-[WKUIRemoteView description]):
884         (-[WKBackdropView description]):
885         * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
886         (WebKit::addAnimationToLayer):
887
888 2018-11-25  Tim Horton  <timothy_horton@apple.com>
889
890         Make it possible to insert editable images with a gesture
891         https://bugs.webkit.org/show_bug.cgi?id=191937
892
893         Reviewed by Wenson Hsieh.
894
895         * UIProcess/API/Cocoa/WKWebView.mm:
896         (-[WKWebView _stylusTapGestureShouldCreateEditableImage]):
897         * UIProcess/API/Cocoa/WKWebViewInternal.h:
898         Add a internal getter for a WKWebViewConfiguration property.
899
900         * UIProcess/WebEditCommandProxy.cpp:
901         (WebKit::WebEditCommandProxy::nameForEditAction):
902         Add a undo name.
903
904         * UIProcess/WebPageProxy.h:
905         * UIProcess/ios/WKContentViewInteraction.h:
906         * UIProcess/ios/WKContentViewInteraction.mm:
907         (-[WKContentView setupInteraction]):
908         (-[WKContentView cleanupInteraction]):
909         (-[WKContentView _removeDefaultGestureRecognizers]):
910         (-[WKContentView _addDefaultGestureRecognizers]):
911         Add a single-stylus-tap gesture recognizer.
912
913         (-[WKContentView _stylusSingleTapRecognized:]):
914         If allowed, request to insert an editable image when a stylus tap occurs.
915
916         * UIProcess/ios/WebPageProxyIOS.mm:
917         (WebKit::WebPageProxy::handleStylusSingleTapAtPoint):
918         * WebProcess/WebPage/WebPage.h:
919         * WebProcess/WebPage/WebPage.messages.in:
920         * WebProcess/WebPage/ios/WebPageIOS.mm:
921         (WebKit::WebPage::handleStylusSingleTapAtPoint):
922         Do a hit test, select the hit position, insert an editable image, and
923         then de-assist any assisted node (to make the keyboard go away).
924         For now, we'll only insert if we hit non-replaced elements,
925         though this heuristic will need to be enhanced significantly once we
926         decide on a design.
927
928 2018-11-25  Tim Horton  <timothy_horton@apple.com>
929
930         Scrolling and drawing compete for incoming gestures
931         https://bugs.webkit.org/show_bug.cgi?id=191940
932
933         Reviewed by Wenson Hsieh.
934
935         * Platform/spi/ios/PencilKitSPI.h:
936         * UIProcess/API/Cocoa/WKWebView.mm:
937         (-[WKWebView _initializeWithConfiguration:]):
938         * UIProcess/ios/WKDrawingView.mm:
939         (-[WKDrawingView initWithEmbeddedViewID:webPageProxy:]):
940         Make scrolling and drawing mutually exclusive if editable images
941         are enabled.
942
943 2018-11-24  Wenson Hsieh  <wenson_hsieh@apple.com>
944
945         [Cocoa] Fix a few localizable string descriptions in WebEditCommandProxy.cpp and WebEditorClient.mm
946         https://bugs.webkit.org/show_bug.cgi?id=191945
947
948         Reviewed by Anders Carlsson.
949
950         Replace some a couple of command undo action name descriptions with "Undo action name", to match all other
951         edit commands.
952
953         * UIProcess/WebEditCommandProxy.cpp:
954         (WebKit::WebEditCommandProxy::nameForEditAction):
955
956 2018-11-24  Wenson Hsieh  <wenson_hsieh@apple.com>
957
958         [Cocoa] Add WKWebView SPI to trigger and remove data detection
959         https://bugs.webkit.org/show_bug.cgi?id=191918
960         <rdar://problem/36185051>
961
962         Reviewed by Tim Horton.
963
964         Adds support for two new WKWebView SPI methods, `-_detectDataWithTypes:completionHandler:` and
965         `-_removeAllDataDetectedLinks:`, to allow internal WebKit clients to run data detection and add links to data
966         detected content, or remove all data detected links from the document.
967
968         Test: WebKit.AddAndRemoveDataDetectors
969
970         * Shared/Cocoa/DataDetectionResult.h:
971         * Shared/Cocoa/DataDetectionResult.mm:
972         (WebKit::DataDetectionResult::decode):
973
974         Modernize DataDetectionResult's IPC decoding, so that it can be used with reply-based async IPC.
975
976         * UIProcess/API/Cocoa/WKWebView.mm:
977         (-[WKWebView _removeDataDetectedLinks:]):
978         (-[WKWebView _detectDataWithTypes:completionHandler:]):
979         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
980         * UIProcess/WebPageProxy.cpp:
981         (WebKit::WebPageProxy::detectDataInAllFrames):
982         (WebKit::WebPageProxy::removeDataDetectedLinks):
983
984         Add or remove data detected links from each frame in the page, and then propagate the new data detector
985         results of the main frame to the UI process (this matches current behavior, where the results of -[WKWebView
986         _dataDetectionResults] only reflects data detection results in the main frame of the page).
987
988         * UIProcess/WebPageProxy.h:
989         * WebProcess/WebPage/WebPage.cpp:
990         (WebKit::WebPage::removeDataDetectedLinks):
991         (WebKit::WebPage::detectDataInAllFrames):
992         * WebProcess/WebPage/WebPage.h:
993         * WebProcess/WebPage/WebPage.messages.in:
994
995 2018-11-24  Andy Estes  <aestes@apple.com>
996
997         [Cocoa] SOFT_LINK_CLASS_FOR_{HEADER,SOURCE} should generate a more concise getter function
998         https://bugs.webkit.org/show_bug.cgi?id=191899
999
1000         Reviewed by Dean Jackson.
1001
1002         * Shared/cocoa/WebCoreArgumentCodersCocoa.mm:
1003         * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
1004         * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
1005
1006 2018-11-23  Antti Koivisto  <antti@apple.com>
1007
1008         Replace LayerOrView typedef with a class
1009         https://bugs.webkit.org/show_bug.cgi?id=191927
1010
1011         Reviewed by Tim Horton.
1012
1013         This typedef restricts remote layer representation to be either a CA layer or a view. We might want
1014         have more flexibility, for example tiles don't really need to be UIViews. It will also make it easier
1015         to unify Mac and iOS code, and hopefully make it less confusing too.
1016
1017         This patch introduces RemoteLayerTreeNode class that replaces most uses of LayerOrView typedef
1018         (the rest are converted to pure CALayer). It also does a bunch of related cleanup.
1019
1020         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.h:
1021         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
1022         (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
1023         (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
1024         (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToUIView):
1025         (WebKit::applyPropertiesToLayer): Deleted.
1026         * SourcesCocoa.txt:
1027         * UIProcess/API/Cocoa/WKWebView.mm:
1028         (-[WKWebView _propertiesOfLayerWithID:]):
1029         * UIProcess/Cocoa/LayerRepresentation.h: Removed.
1030         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
1031         (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
1032         * UIProcess/PageClient.h:
1033         * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
1034         * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
1035         (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
1036         (WebKit::RemoteLayerTreeDrawingAreaProxy::updateDebugIndicator):
1037         (WebKit::RemoteLayerTreeDrawingAreaProxy::layerWithIDForTesting const):
1038         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
1039         (WebKit::RemoteLayerTreeHost::rootNode const):
1040         (WebKit::RemoteLayerTreeHost::rootLayer const): Deleted.
1041         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
1042         (WebKit::RemoteLayerTreeHost::updateLayerTree):
1043         (WebKit::RemoteLayerTreeHost::nodeForID const):
1044         (WebKit::RemoteLayerTreeHost::layerWillBeRemoved):
1045         (WebKit::RemoteLayerTreeHost::animationDidStart):
1046         (WebKit::RemoteLayerTreeHost::animationDidEnd):
1047         (WebKit::RemoteLayerTreeHost::clearLayers):
1048         (WebKit::RemoteLayerTreeHost::layerWithIDForTesting const):
1049         (WebKit::RemoteLayerTreeHost::layerForID const):
1050         (WebKit::RemoteLayerTreeHost::rootLayer const):
1051         (WebKit::RemoteLayerTreeHost::createLayer):
1052         (WebKit::RemoteLayerTreeHost::detachRootLayer):
1053         (WebKit::RemoteLayerTreeHost::mapAllIOSurfaceBackingStore):
1054         (WebKit::RemoteLayerTreeHost::getLayer const): Deleted.
1055         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h: Added.
1056         (WebKit::RemoteLayerTreeNode::layer const):
1057         (WebKit::RemoteLayerTreeNode::uiView const):
1058         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm: Added.
1059         (WebKit::RemoteLayerTreeNode::RemoteLayerTreeNode):
1060         (WebKit::RemoteLayerTreeNode::detachFromParent):
1061         * UIProcess/RemoteLayerTree/RemoteLayerTreeScrollingPerformanceData.mm:
1062         (WebKit::RemoteLayerTreeScrollingPerformanceData::blankPixelCount const):
1063         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
1064         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
1065         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
1066         (WebKit::RemoteLayerTreeHost::createLayer):
1067         * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
1068         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
1069         (WebKit::layerRepresentationFromLayerOrView): Deleted.
1070         * UIProcess/WebAuthentication/Cocoa/HidService.h:
1071         * UIProcess/WebAuthentication/Cocoa/HidService.mm:
1072         * UIProcess/WebPageProxy.h:
1073         * UIProcess/ios/LayerRepresentation.mm: Removed.
1074         * UIProcess/ios/PageClientImplIOS.h:
1075         * UIProcess/ios/PageClientImplIOS.mm:
1076         (WebKit::PageClientImpl::setRemoteLayerTreeRootNode):
1077         (WebKit::PageClientImpl::acceleratedCompositingRootLayer const):
1078         (WebKit::PageClientImpl::setAcceleratedCompositingRootLayer): Deleted.
1079         * UIProcess/ios/WebPageProxyIOS.mm:
1080         (WebKit::WebPageProxy::setRemoteLayerTreeRootNode):
1081         (WebKit::WebPageProxy::setAcceleratedCompositingRootLayer): Deleted.
1082         * UIProcess/mac/PageClientImplMac.h:
1083         * UIProcess/mac/PageClientImplMac.mm:
1084         (WebKit::PageClientImpl::setRemoteLayerTreeRootNode):
1085         (WebKit::PageClientImpl::setAcceleratedCompositingRootLayer): Deleted.
1086         * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
1087         (WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
1088         * UIProcess/mac/WebPageProxyMac.mm:
1089         (WebKit::WebPageProxy::setRemoteLayerTreeRootNode):
1090         (WebKit::WebPageProxy::acceleratedCompositingRootLayer const):
1091         (WebKit::WebPageProxy::setAcceleratedCompositingRootLayer): Deleted.
1092         * WebKit.xcodeproj/project.pbxproj:
1093         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
1094         (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
1095
1096 2018-11-23  Jiewen Tan  <jiewen_tan@apple.com>
1097
1098         [WebAuthN] Enable Web Authentication as an experimental feature for macOS
1099         https://bugs.webkit.org/show_bug.cgi?id=191932
1100         rdar://problem/46225210
1101
1102         Reviewed by Brent Fulgham.
1103
1104         * Shared/WebPreferences.yaml:
1105
1106 2018-11-23  Wenson Hsieh  <wenson_hsieh@apple.com>
1107
1108         Enable drag and drop support for iOSMac
1109         https://bugs.webkit.org/show_bug.cgi?id=191818
1110         <rdar://problem/43907454>
1111
1112         Reviewed by Dean Jackson.
1113
1114         * Configurations/FeatureDefines.xcconfig:
1115         * Shared/WebPreferencesDefaultValues.cpp:
1116         (defaultCustomPasteboardDataEnabled):
1117
1118         Enable custom pasteboard data by default on iOSMac. While writing and reading custom pasteboard data is
1119         currently broken in iOSMac due to the lack of `teamData` and `preferredPresentationStyle`, opting into custom
1120         pasteboard data at least allows us to avoid writing unsanitized data types to the pasteboard.
1121
1122         * WebProcess/WebPage/ios/WebPageIOS.mm:
1123         (WebKit::WebPage::platformEditorState const):
1124
1125         Fix a regression from <https://trac.webkit.org/r236619> wherein the web process crashes when attempting to edit
1126         a text field. This happens because the call to `-[UIKeyboard isInHardwareKeyboardMode]` on the iOSMac platform
1127         attempts to initialize a `UHASWorkspace` from the web process, which then attempts to connect to the UIKit host
1128         application. Instead, we can skip this call altogether on iOSMac, where the platform never considers a hardware
1129         keyboard to be "connected", even when typing.
1130
1131 2018-11-23  Antti Koivisto  <antti@apple.com>
1132
1133         UI side compositing doesn't paint on Mac
1134         https://bugs.webkit.org/show_bug.cgi?id=191908
1135
1136         Reviewed by Tim Horton.
1137
1138         * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
1139         (WebKit::RemoteLayerBackingStore::bytesPerPixel const):
1140         (WebKit::RemoteLayerBackingStore::surfaceBufferFormat const):
1141
1142         These deep color formats are not supported on Mac.
1143
1144 2018-11-22  Chris Dumez  <cdumez@apple.com>
1145
1146         Regression(r238353) Load sometimes hangs when navigating back after a cross-site navigation
1147         https://bugs.webkit.org/show_bug.cgi?id=191914
1148
1149         Reviewed by Ryosuke Niwa.
1150
1151         When process-swapping on a cross-site server-side redirect, we end up doing a decidePolicyForNavigationResponse
1152         policy check for the about:blank suspension load. This policy decision is ignored by the UIProcess because
1153         SuspendedPageProxy does not handle this particular IPC message. To handle the issue, make sure the WebProcess
1154         never sends a DecidePolicyForNavigationResponse IPC to the UIProcess for about:blank suspension loads and let
1155         the load proceed.
1156
1157         The issue was already there before r238353 but it was made obvious by r238353 which caused a hang when trying
1158         to reuse a Suspended page which is hanging while trying to suspend.
1159
1160         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1161         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
1162
1163 2018-11-22  Wenson Hsieh  <wenson_hsieh@apple.com>
1164
1165         [Cocoa] clang emits a warning when building WebKit after r238293
1166         https://bugs.webkit.org/show_bug.cgi?id=191917
1167
1168         Reviewed by Dan Bernstein.
1169
1170         Move the implementations of -setSafeBrowsingEnabled: and -isSafeBrowsingEnabled to the main implementation of
1171         WKPreferences to fix the warning.
1172
1173         * UIProcess/API/Cocoa/WKPreferences.mm:
1174         (-[WKPreferences setSafeBrowsingEnabled:]):
1175         (-[WKPreferences isSafeBrowsingEnabled]):
1176
1177 2018-11-22  Wenson Hsieh  <wenson_hsieh@apple.com>
1178
1179         Address post-review feedback after r238438
1180         https://bugs.webkit.org/show_bug.cgi?id=191913
1181
1182         Reviewed by Ryosuke Niwa.
1183
1184         Replace boolean arguments to setSelectedRange, replaceSelectionWithText and replaceSelectionWithFragment with
1185         enum flags, and tweak a couple of functions to take `const Vector&` instead of `Vector&&`.
1186
1187         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
1188         (WKBundlePageReplaceStringMatches):
1189         * WebProcess/WebPage/FindController.cpp:
1190         (WebKit::FindController::replaceMatches):
1191         * WebProcess/WebPage/FindController.h:
1192         * WebProcess/WebPage/WebPage.cpp:
1193         (WebKit::WebPage::replaceStringMatchesFromInjectedBundle):
1194         (WebKit::WebPage::replaceMatches):
1195         (WebKit::WebPage::replaceSelectionWithText):
1196         * WebProcess/WebPage/WebPage.h:
1197         * WebProcess/WebPage/ios/WebPageIOS.mm:
1198         (WebKit::WebPage::selectWithGesture):
1199         (WebKit::WebPage::updateSelectionWithTouches):
1200         (WebKit::WebPage::selectWithTwoTouches):
1201         (WebKit::WebPage::extendSelection):
1202         (WebKit::WebPage::selectWordBackward):
1203         (WebKit::WebPage::moveSelectionByOffset):
1204         (WebKit::WebPage::selectPositionAtPoint):
1205         (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
1206         (WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
1207         (WebKit::WebPage::selectTextWithGranularityAtPoint):
1208         (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
1209         (WebKit::WebPage::updateSelectionWithExtentPoint):
1210         (WebKit::WebPage::replaceSelectedText):
1211         (WebKit::WebPage::replaceDictatedText):
1212         (WebKit::WebPage::syncApplyAutocorrection):
1213
1214 2018-11-22  Mark Lam  <mark.lam@apple.com>
1215
1216         Rollout r238432: Breaks internal Mac builds.
1217         https://bugs.webkit.org/show_bug.cgi?id=191909
1218         <rdar://problem/46214163>
1219
1220         Unreviewed. Rolling out r238432: Remove @no-unify of InjectedBundleRangeHandle.cpp and InjectedBundleNodeHandle.cpp
1221
1222         * Sources.txt:
1223         * WebKit.xcodeproj/project.pbxproj:
1224
1225 2018-11-22  Carlos Garcia Campos  <cgarcia@igalia.com>
1226
1227         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.23.1 release.
1228
1229         * gtk/NEWS: Add release notes for 2.23.1.
1230
1231 2018-11-21  Wenson Hsieh  <wenson_hsieh@apple.com>
1232
1233         [Cocoa] [WebKit2] Add support for replacing find-in-page text matches
1234         https://bugs.webkit.org/show_bug.cgi?id=191786
1235         <rdar://problem/45813871>
1236
1237         Reviewed by Ryosuke Niwa.
1238
1239         * UIProcess/API/Cocoa/WKWebView.mm:
1240         (-[WKWebView replaceMatches:withString:inSelectionOnly:resultCollector:]):
1241         * UIProcess/WebPageProxy.cpp:
1242         (WebKit::WebPageProxy::replaceMatches):
1243         * UIProcess/WebPageProxy.h:
1244         * UIProcess/mac/WKTextFinderClient.mm:
1245         (-[WKTextFinderClient replaceMatches:withString:inSelectionOnly:resultCollector:]):
1246
1247         Implement this method to opt in to "Replace…" UI on macOS in the find bar. In this API, we're given a list of
1248         matches to replace. We propagate the indices of each match to the web process, where FindController maps them to
1249         corresponding replacement ranges. Currently, the given list of matches is only ever a list containing the first
1250         match, or a list containing all matches.
1251
1252         * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
1253         (WKBundlePageFindStringMatches):
1254         (WKBundlePageReplaceStringMatches):
1255         * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
1256         * WebProcess/WebCoreSupport/WebEditorClient.cpp:
1257         * WebProcess/WebPage/FindController.cpp:
1258         (WebKit::FindController::replaceMatches):
1259
1260         Map match indices to Ranges, and then call into WebCore::Page to do the heavy lifting (see WebCore ChangeLog for
1261         more details). Additionally add a hard find-and-replace limit here to prevent the web process from spinning
1262         indefinitely if there are an enormous number of find matches.
1263
1264         * WebProcess/WebPage/FindController.h:
1265         * WebProcess/WebPage/WebPage.cpp:
1266         (WebKit::WebPage::findStringMatchesFromInjectedBundle):
1267         (WebKit::WebPage::replaceStringMatchesFromInjectedBundle):
1268
1269         Add helpers to exercise find and replace in WebKit2.
1270
1271         (WebKit::WebPage::replaceMatches):
1272         * WebProcess/WebPage/WebPage.h:
1273         * WebProcess/WebPage/WebPage.messages.in:
1274
1275 2018-11-21  Andy Estes  <aestes@apple.com>
1276
1277         [Cocoa] Create a soft-linking file for PassKit
1278         https://bugs.webkit.org/show_bug.cgi?id=191875
1279         <rdar://problem/46203215>
1280
1281         Reviewed by Myles Maxfield.
1282
1283         * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: Removed SOFT_LINK macros and included PassKitSoftLink.h instead.
1284         * SourcesCocoa.txt: Removed @no-unify from WebPaymentCoordinatorProxyIOS.mm and WebPaymentCoordinatorProxyMac.mm.
1285         * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: Removed SOFT_LINK macros and included PassKitSoftLink.h instead.
1286         * UIProcess/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm: Ditto.
1287         * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm: Ditto.
1288         * UIProcess/Cocoa/SafeBrowsingWarningCocoa.mm: Included NSAttributedStringSPI.h.
1289         * UIProcess/mac/WebProcessProxyMac.mm: Included ProcessPrivilege.h.
1290         * WebKit.xcodeproj/project.pbxproj: Removed WebPaymentCoordinatorProxyIOS.mm and WebPaymentCoordinatorProxyMac.mm from the WebKit target.
1291
1292 2018-11-21  Fujii Hironori  <Hironori.Fujii@sony.com>
1293
1294         Remove @no-unify of InjectedBundleRangeHandle.cpp and InjectedBundleNodeHandle.cpp
1295         https://bugs.webkit.org/show_bug.cgi?id=191853
1296
1297         Reviewed by Michael Catanzaro.
1298
1299         In r235845, I excluded InjectedBundleRangeHandle.cpp and
1300         InjectedBundleNodeHandle.cpp from unify source builds in order to
1301         work around a MSVC bug.
1302
1303         Then, I commited a different workaround for the MSVC bug in
1304         r238386. Now, we can include InjectedBundleRangeHandle.cpp and
1305         InjectedBundleNodeHandle.cpp in unified source builds. Revert
1306         r235845.
1307
1308         * Sources.txt: Removed @no-unify of InjectedBundleRangeHandle.cpp
1309         and InjectedBundleNodeHandle.cpp
1310         * WebKit.xcodeproj/project.pbxproj: Unchecked Target Membership
1311         not to be compiled by XCode.
1312
1313 2018-11-20  Jeff Miller  <jeffm@apple.com>
1314
1315         Return nullptr immediately if the key doesn't exist in the HashMap.
1316         https://bugs.webkit.org/show_bug.cgi?id=191841
1317
1318         Reviewed by Chris Dumez.
1319
1320         * Shared/API/APIDictionary.h:
1321
1322 2018-11-20  Don Olmstead  <don.olmstead@sony.com>
1323
1324         WebPasteboard should USE(LIBWPE)
1325         https://bugs.webkit.org/show_bug.cgi?id=191846
1326
1327         Reviewed by Michael Catanzaro.
1328
1329         Add USE(LIBWPE) for Pasteboard related functionality within WebKit.
1330
1331         * UIProcess/WebPasteboardProxy.h:
1332         * UIProcess/WebPasteboardProxy.messages.in:
1333         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
1334         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
1335
1336 2018-11-20  Don Olmstead  <don.olmstead@sony.com>
1337
1338         [WPE] Fix some feature guards in WebKit
1339         https://bugs.webkit.org/show_bug.cgi?id=191847
1340
1341         Reviewed by Michael Catanzaro.
1342
1343         Some feature guards are not present in these files.
1344
1345         * UIProcess/API/wpe/PageClientImpl.cpp:
1346         * UIProcess/API/wpe/PageClientImpl.h:
1347         * UIProcess/wpe/WebProcessPoolWPE.cpp:
1348         (WebKit::WebProcessPool::platformInitializeWebProcess):
1349
1350 2018-11-20  Antti Koivisto  <antti@apple.com>
1351
1352         Avoid potential longer than expected layer flush delays
1353         https://bugs.webkit.org/show_bug.cgi?id=191833
1354
1355         Reviewed by Dean Jackson.
1356
1357         Layer flush throttling also stops style recalcs and layouts. Layouts schedule layer flushes. Especially
1358         on a slow network we can in principle end up in situation where layer flush timer fires but there is no
1359         flush scheduled and so nothing happens. However there is a pending style recalc or layout that would
1360         actually schedule a flush (in practice various things force style recalcs and this doesn't occur
1361         commonly).
1362
1363         To avoid this we should flush unconditionally when the flush timer fires. This performs any pending
1364         style recalc and layout too. If there is nothing to do the flush will be cheap.
1365
1366         PLT doesn't appear to hit cases affected by this patch and there shouldn't be any impact.
1367
1368         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
1369
1370         Remove now unnecessary m_hasPendingFlush bit, simplifying the logic.
1371
1372         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
1373         (WebKit::TiledCoreAnimationDrawingArea::setLayerTreeStateIsFrozen):
1374
1375         Schedule unconditionally when unfreezing.
1376
1377         (WebKit::TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlush):
1378
1379         Remove branch that starts the flush timer. It is not needed as either it was already running
1380         or immediate flush is already scheduled and will start the timer anyway.
1381
1382         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
1383         (WebKit::TiledCoreAnimationDrawingArea::adjustLayerFlushThrottling):
1384         (WebKit::TiledCoreAnimationDrawingArea::layerFlushThrottlingTimerFired):
1385
1386         Flush unconditionally.
1387
1388 2018-11-19  Don Olmstead  <don.olmstead@sony.com>
1389
1390         Simplify platform check in WebEditorClient
1391         https://bugs.webkit.org/show_bug.cgi?id=191848
1392
1393         Reviewed by Fujii Hironori.
1394
1395         !PLATFORM(GTK) && !PLATFORM(COCOA) && !PLATFORM(WPE) can be better
1396         represented as PLATFORM(WIN).
1397
1398         * WebProcess/WebCoreSupport/WebEditorClient.cpp:
1399
1400 2018-11-19  Alex Christensen  <achristensen@webkit.org>
1401
1402         Add SPI to disable JIT in a WKWebView
1403         https://bugs.webkit.org/show_bug.cgi?id=191822
1404         <rdar://problem/28119360>
1405
1406         Reviewed by Geoffrey Garen.
1407
1408         * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
1409         (WebKit::XPCServiceInitializer):
1410         * UIProcess/API/APIProcessPoolConfiguration.h:
1411         * UIProcess/API/Cocoa/WKWebView.mm:
1412         (-[WKWebView _canUseJIT:]):
1413         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1414         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
1415         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
1416         (-[_WKProcessPoolConfiguration enableJIT]):
1417         (-[_WKProcessPoolConfiguration setEnableJIT:]):
1418         * UIProcess/Launcher/ProcessLauncher.h:
1419         (WebKit::ProcessLauncher::Client::enableJIT const):
1420         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
1421         (WebKit::ProcessLauncher::launchProcess):
1422         * UIProcess/WebPageProxy.cpp:
1423         (WebKit::WebPageProxy::canUseJIT):
1424         * UIProcess/WebPageProxy.h:
1425         * UIProcess/WebProcessProxy.cpp:
1426         (WebKit::WebProcessProxy::enableJIT const):
1427         * UIProcess/WebProcessProxy.h:
1428         (WebKit::WebProcessProxy::processPool const):
1429         (WebKit::WebProcessProxy::processPool): Deleted.
1430         * WebProcess/WebProcess.cpp:
1431         (WebKit::WebProcess::canUseJIT):
1432         * WebProcess/WebProcess.h:
1433         * WebProcess/WebProcess.messages.in:
1434
1435 2018-11-19  Basuke Suzuki  <basuke.suzuki@sony.com>
1436
1437         [Curl] Add API for CertificateInfo.
1438         https://bugs.webkit.org/show_bug.cgi?id=191647
1439
1440         Reviewed by Alex Christensen.
1441
1442         Added API for CertificateInfo to create, fetch contents.
1443
1444         Tests: TestWebKitAPI/Tests/WebKit/curl/Certificates.cpp
1445
1446         * PlatformWin.cmake:
1447         * Shared/API/c/curl/WKCertificateInfoCurl.cpp: Added.
1448         (WKCertificateInfoCreateWithCertficateChain):
1449         (WKCertificateInfoGetVerificationError):
1450         (WKCertificateInfoGetCertificateChainSize):
1451         (WKCertificateInfoCopyCertificateAtIndex):
1452         * Shared/API/c/curl/WKCertificateInfoCurl.h: Copied from Source/WebCore/platform/network/curl/CertificateInfoCurl.cpp.
1453         * Shared/curl/WebCoreArgumentCodersCurl.cpp:
1454         (IPC::ArgumentCoder<CertificateInfo>::encode):
1455         (IPC::ArgumentCoder<CertificateInfo>::decode):
1456
1457 2018-11-19  Don Olmstead  <don.olmstead@sony.com>
1458
1459         Add USE(LIBWPE) for WebKit events
1460         https://bugs.webkit.org/show_bug.cgi?id=191842
1461
1462         Reviewed by Michael Catanzaro.
1463
1464         Moves all WPE events to USE(LIBWPE) instead of PLATFORM(WPE). Updates
1465         filenames to LibWPE.
1466
1467         * PlatformWPE.cmake:
1468         * Shared/NativeWebKeyboardEvent.h:
1469         * Shared/NativeWebMouseEvent.h:
1470         * Shared/NativeWebTouchEvent.h:
1471         * Shared/NativeWebWheelEvent.h:
1472         * Shared/WebCoreArgumentCoders.cpp:
1473         * Shared/WebCoreArgumentCoders.h:
1474         * Shared/WebEvent.h:
1475         * Shared/WebKeyboardEvent.cpp:
1476         (WebKit::WebKeyboardEvent::WebKeyboardEvent):
1477         * Shared/libwpe/NativeWebKeyboardEventLibWPE.cpp: Renamed from Source/WebKit/Shared/wpe/NativeWebKeyboardEventWPE.cpp.
1478         * Shared/libwpe/NativeWebMouseEventLibWPE.cpp: Renamed from Source/WebKit/Shared/wpe/NativeWebMouseEventWPE.cpp.
1479         * Shared/libwpe/NativeWebTouchEventLibWPE.cpp: Renamed from Source/WebKit/Shared/wpe/NativeWebTouchEventWPE.cpp.
1480         * Shared/libwpe/NativeWebWheelEventLibWPE.cpp: Renamed from Source/WebKit/Shared/wpe/NativeWebWheelEventWPE.cpp.
1481         * Shared/libwpe/WebEventFactory.cpp: Renamed from Source/WebKit/Shared/wpe/WebEventFactory.cpp.
1482         * Shared/libwpe/WebEventFactory.h: Renamed from Source/WebKit/Shared/wpe/WebEventFactory.h.
1483         * SourcesWPE.txt:
1484
1485 2018-11-19  David Quesada  <david_quesada@apple.com>
1486
1487         EXC_BAD_ACCESS when invoking a DownloadProxy's destination decision handler after the download has been canceled
1488         https://bugs.webkit.org/show_bug.cgi?id=191762
1489         rdar://problem/46151509
1490
1491         Reviewed by Dean Jackson.
1492
1493         When the DownloadClient calls the decision handler with a destination path, check if
1494         m_processPool is null before trying to access its network process. This can happen
1495         if a download is canceled before the client decides its destination.
1496
1497         * UIProcess/Downloads/DownloadProxy.cpp:
1498         (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
1499
1500 2018-11-19  Tomoki Imai  <Tomoki.Imai@sony.com>
1501
1502         [cairo] BackingStore::incorporateUpdate should use CompositeCopy to support drawsBackground=false in general Cairo ports
1503         https://bugs.webkit.org/show_bug.cgi?id=191577
1504
1505         Reviewed by Carlos Garcia Campos.
1506
1507         We should use CompositeCopy operator to update bitmap to overwrite existing bitmap even if source contains
1508         transparent parts. It enables ports which uses Cairo to set drawsBackground to false.
1509         GTK ports has custom background extension, and in such case, we need to use CompositeSourceOver to retain
1510         custom background.
1511
1512         * UIProcess/cairo/BackingStoreCairo.cpp:
1513         (WebKit::BackingStore::incorporateUpdate): Use CompositeCopy operator to update bitmap.
1514
1515 2018-11-19  Joseph Pecoraro  <pecoraro@apple.com>
1516
1517         Web Inspector: "Reload Web Inspector" button no longer partially works
1518         https://bugs.webkit.org/show_bug.cgi?id=191773
1519         <rdar://problem/46139932>
1520
1521         Reviewed by Devin Rousso.
1522
1523         * UIProcess/RemoteWebInspectorProxy.cpp:
1524         (WebKit::RemoteWebInspectorProxy::load):
1525         (WebKit::RemoteWebInspectorProxy::reopen):
1526         * UIProcess/RemoteWebInspectorProxy.h:
1527         * UIProcess/RemoteWebInspectorProxy.messages.in:
1528         * WebProcess/WebPage/RemoteWebInspectorUI.cpp:
1529         (WebKit::RemoteWebInspectorUI::reopen):
1530         * WebProcess/WebPage/RemoteWebInspectorUI.h:
1531         * WebProcess/WebPage/WebInspector.cpp:
1532         (WebKit::WebInspector::reopen):
1533         * WebProcess/WebPage/WebInspector.h:
1534         * WebProcess/WebPage/WebInspector.messages.in:
1535         * WebProcess/WebPage/WebInspectorUI.cpp:
1536         (WebKit::WebInspectorUI::reopen):
1537         * WebProcess/WebPage/WebInspectorUI.h:
1538
1539 2018-11-19  Alejandro G. Castro  <alex@igalia.com>
1540
1541         [GTK][WPE] Solve some issues in the enumerateDevices code
1542         https://bugs.webkit.org/show_bug.cgi?id=191832
1543
1544         Reviewed by Carlos Garcia Campos.
1545
1546         * UIProcess/API/glib/WebKitDeviceInfoPermissionRequest.cpp:
1547         Increase the version to 2.24.
1548         (webkitDeviceInfoPermissionRequestAllow):
1549         (webkitDeviceInfoPermissionRequestDeny):
1550         * UIProcess/API/glib/WebKitDeviceInfoPermissionRequestPrivate.h:
1551         Replace the forward declaration with the include.
1552         * UIProcess/API/gtk/WebKitDeviceInfoPermissionRequest.h: Typo.
1553         * UIProcess/API/gtk/WebKitWebsiteData.h:
1554         Increase the version to 2.24.
1555         * UIProcess/API/wpe/WebKitDeviceInfoPermissionRequest.h: Typo.
1556         * UIProcess/API/wpe/WebKitWebsiteData.h:
1557         Increase the version to 2.24.
1558
1559 2018-11-19  Carlos Garcia Campos  <cgarcia@igalia.com>
1560
1561         Unreviewed. Fix GTK+ build after r238318.
1562
1563         Add new symbols to API documentation files. They should have been added in r237031, but r238318 revealed it.
1564
1565         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
1566         * UIProcess/API/gtk/docs/webkit2gtk-4.0.types:
1567         * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
1568
1569 2018-11-19  Joseph Pecoraro  <pecoraro@apple.com>
1570
1571         Regression(r238330): A lot of WebInspector tests are crashing on the bots
1572         https://bugs.webkit.org/show_bug.cgi?id=191814
1573
1574         Reviewed by Ryosuke Niwa.
1575
1576         Expose the expected connection type from the UIProcess into the WebProcess.
1577         When there is a local inspector connection to the UIProcess expose it as
1578         a local frontend channel to the inspector controllers in the Page.
1579
1580         * UIProcess/WebPageInspectorTargetAgent.h:
1581         * UIProcess/WebPageInspectorTargetAgent.cpp:
1582         (WebKit::WebPageInspectorTargetAgent::frontendChannel):
1583         An additional FrontendChannel class is not needed, just use self.
1584
1585         (WebKit::WebPageInspectorTargetAgent::WebPageInspectorTargetAgent):
1586         (WebKit::WebPageInspectorTargetAgent::connectionType const):
1587         (WebKit::WebPageInspectorTargetAgent::sendMessageToFrontend):
1588         Expose the channel to targets as local if there is a local frontend
1589         in the UIProcess.
1590
1591 2018-11-18  Joseph Pecoraro  <pecoraro@apple.com>
1592
1593         Regression(r238330) ProcessSwap.WebInspector API test is a flaky crash in debug
1594         https://bugs.webkit.org/show_bug.cgi?id=191812
1595
1596         Reviewed by Chris Dumez.
1597
1598         * WebProcess/WebPage/WebInspector.cpp:
1599         (WebKit::WebInspector::setFrontendConnection):
1600         It can be possible to receive a frontend connection multiple times
1601         if another WebProcess opened the inspector and this WebProcess got
1602         swapped in before the InspectorProcess notified the WebProcess of
1603         a connection to use. It is always best to use the latest connection
1604         we have received, since any others would have been invalidated.
1605
1606 2018-11-18  Chris Dumez  <cdumez@apple.com>
1607
1608         [PSON] Received an invalid message "WebPageProxy.DidPerformClientRedirect" from the web process
1609         https://bugs.webkit.org/show_bug.cgi?id=191828
1610
1611         Reviewed by Antti Koivisto.
1612
1613         WebPageProxy::didPerformClientRedirect() had a MESSAGE_CHECK_URL() for both the source
1614         and the destination URL. The macro calls WebProcessProxy::checkURLReceivedFromWebProcess()
1615         to make sure that both URLs were actually loaded by this WebContent process.
1616
1617         However, now that we're enabled process-swap on cross-site navigation, these checks are no
1618         longer fully valid. If the client-side redirect is cross-site, then the source and destination
1619         URLs get loaded by 2 different WebContent processes. Since didPerformClientRedirect() gets
1620         called after the redirect and gets set by the new WebContent process, only the destination URL
1621         is guaranteed to have been loaded by this process. The source URL may have been loaded in
1622         another process so this patch drops the message check for the source URL.
1623
1624         * UIProcess/WebPageProxy.cpp:
1625         (WebKit::WebPageProxy::didPerformClientRedirect):
1626
1627 2018-11-18  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
1628
1629         Use Box<BinarySemaphore> instead of dispatch_semaphore_t
1630         https://bugs.webkit.org/show_bug.cgi?id=189691
1631
1632         Reviewed by Ryosuke Niwa.
1633
1634         Use Box<BinarySemaphore> instead, which utilizes our WTF::Lock mechanism.
1635
1636         * NetworkProcess/watchos/NetworkProximityManager.mm:
1637         (WebKit::NetworkProximityManager::updateRecommendation):
1638
1639 2018-11-17  Wenson Hsieh  <wenson_hsieh@apple.com>
1640
1641         [iOS] Remove all usages of UIItemProvider, UIItemProviderReading, and related classes
1642         https://bugs.webkit.org/show_bug.cgi?id=191819
1643
1644         Reviewed by Dan Bernstein.
1645
1646         Replace UIItemProvider (and related classes) with NSItemProvider.
1647
1648         * Platform/spi/ios/UIKitSPI.h:
1649         * UIProcess/ios/WKContentViewInteraction.mm:
1650         (-[WKContentView _itemsForBeginningOrAddingToSessionWithRegistrationList:stagedDragSource:]):
1651         (-[WKContentView dropInteraction:performDrop:]):
1652
1653 2018-11-17  Ross Kirsling  <ross.kirsling@sony.com>
1654
1655         Unreviewed WinCairo build fix for r238353.
1656
1657         * UIProcess/WebPageProxy.cpp:
1658         (WebKit::WebPageProxy::continueNavigationInNewProcess):
1659
1660 2018-11-17  Chris Dumez  <cdumez@apple.com>
1661
1662         ASSERTION FAILED: m_messageReceivers.contains(...) under ViewGestureController removeMessageReceiver
1663         https://bugs.webkit.org/show_bug.cgi?id=191734
1664         <rdar://problem/46151497>
1665
1666         Reviewed by Ryosuke Niwa.
1667
1668         When a WebProcess crashes, we destroy the ViewGestureController and reconstruct it later
1669         after we've relaunched a new WebProcess. The ViewGestureController controller takes care
1670         of adding itself as an IPC message receiver to the WebProcessProxy, and the destructor
1671         takes care of removing itself as an IPC message receiver.
1672
1673         However, when process-swapping on navigation, we do not destroy the ViewGestureController
1674         because doing so would take down the swipe gesture snapshot on cross-site swipe navigation.
1675         This led to hitting this assertion later on because the ViewGestureController is still
1676         registered as an IPC message receiver with the old process after process swapping.
1677
1678         To address the issue, we now make sure the ViewGestureController unregisters itself from
1679         the old process and registers itself with the new process on process-swap.
1680
1681         * UIProcess/Cocoa/ViewGestureController.cpp:
1682         (WebKit::ViewGestureController::ViewGestureController):
1683         (WebKit::ViewGestureController::~ViewGestureController):
1684         (WebKit::ViewGestureController::disconnectFromProcess):
1685         (WebKit::ViewGestureController::connectToProcess):
1686         * UIProcess/Cocoa/ViewGestureController.h:
1687         * UIProcess/Cocoa/WebViewImpl.mm:
1688         (WebKit::WebViewImpl::processWillSwap):
1689         (WebKit::WebViewImpl::didRelaunchProcess):
1690
1691 2018-11-17  Chris Dumez  <cdumez@apple.com>
1692
1693         [PSON] ASSERTION FAILED: m_uncommittedState.state == State::Committed
1694         https://bugs.webkit.org/show_bug.cgi?id=191781
1695
1696         Reviewed by Ryosuke Niwa.
1697
1698         The crash was happening when switching to a suspended page that is not yet done
1699         suspending (e.g. in case of very fast back/forward navigation). The WebPageProxy
1700         would reattach to the suspended process and get load notifications that it did
1701         not expect since it did not schedule any load yet. Those notifications are for
1702         the about:blank load we do for page suspension.
1703
1704         To address the issue, make swapToWebProcess() asynchronous and take a completion
1705         handler. When we try to unsuspend a SuspendedPageProxy, we first make sure it
1706         is actually done suspending. If it is not done suspending, we wait until it is
1707         before telling in to unsuspend and proceeding with the new load.
1708
1709         * UIProcess/SuspendedPageProxy.cpp:
1710         (WebKit::SuspendedPageProxy::unsuspend):
1711         (WebKit::SuspendedPageProxy::didFinishLoad):
1712         * UIProcess/SuspendedPageProxy.h:
1713         * UIProcess/WebPageProxy.cpp:
1714         (WebKit::WebPageProxy::swapToWebProcess):
1715         (WebKit::WebPageProxy::continueNavigationInNewProcess):
1716         * UIProcess/WebPageProxy.h:
1717
1718 2018-11-17  Chris Dumez  <cdumez@apple.com>
1719
1720         Unreviewed follow-up to r238343 to address debug assertions in 2 API tests.
1721
1722         * UIProcess/Network/NetworkProcessProxy.cpp:
1723         (WebKit::NetworkProcessProxy::networkProcessCrashed):
1724
1725 2018-11-17  Devin Rousso  <drousso@apple.com>
1726
1727         Web Inspector: Network: add button to show system certificate dialog
1728         https://bugs.webkit.org/show_bug.cgi?id=191458
1729         <rdar://problem/45977019>
1730
1731         Reviewed by Joseph Pecoraro.
1732
1733         * UIProcess/WebInspectorProxy.messages.in:
1734         * UIProcess/WebInspectorProxy.h:
1735         * UIProcess/WebInspectorProxy.cpp:
1736         (WebKit::WebInspectorProxy::showCertificate): Added.
1737         (WebKit::WebInspectorProxy::platformShowCertificate): Added.
1738         * UIProcess/mac/WebInspectorProxyGtk.cpp:
1739         (WebKit::WebInspectorProxy::platformShowCertificate): Added.
1740         * UIProcess/mac/WebInspectorProxyMac.mm:
1741         (WebKit::WebInspectorProxy::platformShowCertificate): Added.
1742         * UIProcess/mac/WebInspectorProxyWPE.cpp:
1743         (WebKit::WebInspectorProxy::platformShowCertificate): Added.
1744         * UIProcess/mac/WebInspectorProxyWin.cpp:
1745         (WebKit::WebInspectorProxy::platformShowCertificate): Added.
1746         * WebProcess/WebPage/WebInspectorUI.h:
1747         * WebProcess/WebPage/WebInspectorUI.cpp:
1748         (WebKit::WebInspectorUI::showCertificate): Added.
1749
1750         * UIProcess/RemoteWebInspectorProxy.messages.in:
1751         * UIProcess/RemoteWebInspectorProxy.h:
1752         * UIProcess/RemoteWebInspectorProxy.cpp:
1753         (WebKit::RemoteWebInspectorProxy::showCertificate): Added.
1754         (WebKit::RemoteWebInspectorProxy::platformShowCertificate): Added.
1755         * UIProcess/mac/RemoteWebInspectorProxyGtk.cpp:
1756         (WebKit::RemoteWebInspectorProxy::platformShowCertificate): Added.
1757         * UIProcess/mac/RemoteWebInspectorProxyMac.mm:
1758         (WebKit::RemoteWebInspectorProxy::platformShowCertificate): Added.
1759         * WebProcess/WebPage/RemoteWebInspectorUI.h:
1760         * WebProcess/WebPage/RemoteWebInspectorUI.cpp:
1761         (WebKit::RemoteWebInspectorUI::showCertificate): Added.
1762
1763         * NetworkProcess/cache/NetworkCacheCoders.h:
1764         * NetworkProcess/cache/NetworkCacheCodersCocoa.cpp: Removed.
1765         * NetworkProcess/cache/NetworkCacheCodersCurl.cpp: Removed.
1766         * NetworkProcess/cache/NetworkCacheCodersSoup.cpp: Removed.
1767         Moved `WebCore::CertificateInfo` code for `WTF::Encoder` and `WTF::Decoder` into their
1768         respective platform's CertificateInfo.h file.
1769
1770         * UIProcess/Authentication/mac/WebCredentialMac.mm:
1771
1772         * Configurations/WebKit.xcconfig:
1773         * PlatformMac.cmake:
1774         * PlatformWin.cmake:
1775         * SourcesCocoa.txt:
1776         * SourcesGTK.txt:
1777         * SourcesWPE.txt:
1778         * WebKit.xcodeproj/project.pbxproj:
1779
1780 2018-11-16  Chris Dumez  <cdumez@apple.com>
1781
1782         Regression(ProcessPrewarming) Assertion hit in NetworkProcessProxy destructor
1783         https://bugs.webkit.org/show_bug.cgi?id=191800
1784
1785         Reviewed by Ryosuke Niwa.
1786
1787         Make sure the NetworkProcessProxy destructor calls its remaining m_pendingConnectionReplies
1788         completion handlers to avoid hitting an assertion in the CompletionHandler destructor.
1789
1790         Prewarmed WebProcess do not keep the ProcessPool alive and thus not the NetworkProcessProxy
1791         either. As a result, it is possible for NetworkProcessProxy to have pending connection
1792         requests from those prewarmed processes when it is destroyed. Similar story for the
1793         suspended page processes when they are destroyed.
1794
1795         * UIProcess/Network/NetworkProcessProxy.cpp:
1796         (WebKit::NetworkProcessProxy::~NetworkProcessProxy):
1797
1798 2018-11-16  Alex Christensen  <achristensen@webkit.org>
1799
1800         Tweak _showSafeBrowsingWarningWithTitle SPI
1801         https://bugs.webkit.org/show_bug.cgi?id=191799
1802
1803         Reviewed by Wenson Hsieh.
1804
1805         * UIProcess/API/Cocoa/WKWebView.mm:
1806         (-[WKWebView _showSafeBrowsingWarningWithTitle:warning:details:completionHandler:]):
1807         (+[WKWebView _visitUnsafeWebsiteSentinel]):
1808         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1809         * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
1810         (-[WKSafeBrowsingWarning clickedOnLink:]):
1811         I need to localize "Continue" and "Cancel" so they aren't always in English.
1812
1813 2018-11-16  Chris Dumez  <cdumez@apple.com>
1814
1815         WKWebViewMacEditingTests.DoNotCrashWhenInterpretingKeyEventWhileDeallocatingView API test is crashing in debug
1816         https://bugs.webkit.org/show_bug.cgi?id=191797
1817
1818         Reviewed by Ryosuke Niwa.
1819
1820         We were hitting the assertion because the error handler was first getting called. It would
1821         deallocate the send right, cancel/null out the XPC connection and call
1822         didFinishLaunchingProcess(0, IPC::Connection::Identifier()).
1823
1824         Then the xpc_connection_send_message_with_reply() block would get called later and
1825         would try to deallocate the send right again, and call
1826         didFinishLaunchingProcess(0, IPC::Connection::Identifier()) again because the xpc
1827         connection is null.
1828
1829         Handle this case by having the xpc_connection_send_message_with_reply() block check
1830         that we're still launching (i.e. didFinishLaunchingProcess() has not been called
1831         yet).
1832
1833         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
1834         (WebKit::ProcessLauncher::launchProcess):
1835
1836 2018-11-16  Joseph Pecoraro  <pecoraro@apple.com>
1837
1838         Unreviewed follow-up to r238330.
1839
1840         * UIProcess/WebPageProxy.cpp:
1841         (WebKit::WebPageProxy::close):
1842         Don't clear the pointer after invalidating since the pointer is
1843         used later one. We don't mind it being used after invalidation
1844         it will do the right thing, we'd rather have the WebInspectorProxy
1845         lifetime match the WebPageProxy.
1846
1847 2018-11-16  Chris Dumez  <cdumez@apple.com>
1848
1849         ProcessSwap.NavigationWithLockedHistoryWithoutPSON API test is a flaky crash in debug
1850         https://bugs.webkit.org/show_bug.cgi?id=191795
1851
1852         Reviewed by Alex Christensen.
1853
1854         If the WebProcessPool is getting destroyed while there is a prewarmed WebContent process
1855         that is awaiting its connnection to the network process, then we'll hit the
1856         process->hasOneRef() assertion in the WebProcessPool destructor. This is because
1857         NetworkProcessProxy::m_pendingConnectionReplies keeps a RefPtr to the WebProcessProxy
1858         that is awaiting the connection. The NetworkProcessProxy does not really need to keep
1859         the WebProcessProxy alive in this case so this patch switches to using a WeakPtr instead.
1860
1861         * UIProcess/Network/NetworkProcessProxy.cpp:
1862         (WebKit::NetworkProcessProxy::getNetworkProcessConnection):
1863         (WebKit::NetworkProcessProxy::networkProcessCrashed):
1864         * UIProcess/Network/NetworkProcessProxy.h:
1865         * UIProcess/WebProcessProxy.h:
1866
1867 2018-11-16  Chris Dumez  <cdumez@apple.com>
1868
1869         [macOS] Label "prewarmed" WebContent processes in Activity Monitor
1870         https://bugs.webkit.org/show_bug.cgi?id=191765
1871         <rdar://problem/45953463>
1872
1873         Reviewed by Geoffrey Garen.
1874
1875         Label "prewarmed" WebContent processes in Activity Monitor to facilitate debugging.
1876
1877         * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
1878         (WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
1879         * UIProcess/WebProcessProxy.cpp:
1880         (WebKit::WebProcessProxy::getLaunchOptions):
1881         (WebKit::WebProcessProxy::markIsNoLongerInPrewarmedPool):
1882         * WebProcess/WebProcess.cpp:
1883         (WebKit::WebProcess::markIsNoLongerPrewarmed):
1884         * WebProcess/WebProcess.h:
1885         * WebProcess/WebProcess.messages.in:
1886         * WebProcess/cocoa/WebProcessCocoa.mm:
1887         (WebKit::WebProcess::initializeProcessName):
1888         (WebKit::WebProcess::updateProcessName):
1889         (WebKit::WebProcess::platformInitializeProcess):
1890
1891 2018-11-16  Joseph Pecoraro  <pecoraro@apple.com>
1892
1893         Web Inspector: Keep Web Inspector window alive across process swaps (PSON) (Local Inspector)
1894         https://bugs.webkit.org/show_bug.cgi?id=191740
1895         <rdar://problem/45470897>
1896
1897         Reviewed by Timothy Hatcher.
1898
1899         When a web page asks to open a local Web Inspector, that inspector
1900         will now connect in the UIProcess (WebPageProxy / WebPageInspectorController)
1901         instead of the WebContentProcess (WebKit::WebInspector / InspectorController).
1902
1903         Previously a WebInspectorProxy was re-created every time the WebPageProxy's
1904         WebPage / WebProcess was changed, effectively closing the Web Inspector
1905         frontend when the WebPage was swapped or crashed.
1906
1907         This change keeps the WebInspectorProxy alive as long as the WebPageProxy
1908         is alive. During process swaps, or process crashes, the WebInspectorProxy
1909         is reset when the page is reset and updated when the page's WebProcess
1910         changes. Since WebInspectorProxy owns the Web Inspector view / window
1911         the Web Inspector window can be kept alive across (and attached state)
1912         across WebPage / WebProcess changes.
1913
1914         Previously the WebContentProcess's WebKit::WebInspector was the Local
1915         FrontendChannel for the WebCore::InspectorController. This can't
1916         outlive the single WebContentProcess.
1917
1918         This change makes the UIProcesses' WebInspectorProxy the Local FrontendChannel
1919         for the WebKit::WebPageInspectorController. Given the WebInspectorProxy
1920         now stays alive alongside the WebPageProxy this will live across process changes.
1921         This means that the WebInspectorUI process must send its backend messages to
1922         the WebInspectorProxy -> WebPageInspectorController now instead of the
1923         old path WebInspector -> WebCore::InspectorController.
1924
1925         A direct IPC connection is still maintained between the WebContentProcess's
1926         WebKit::WebInspector and the InspectorProcess's WebInspectorUI. Previously
1927         this connection was established by WebKit::WebInspector vending an
1928         IPC::Attachment to the WebInspectorUI process. This patch inverts that
1929         relationship, because the WebInspectorUI process now lives across multiple
1930         WebContentProcess changes. The WebInspectorUI now vends the IPC::Attachment
1931         to the WebContentProcess each time the process changes. This way they can both
1932         still communicate through normal Messages::WebInspector/WebInspectorUI
1933         messages and everything behaves as previously expected.
1934
1935         * Scripts/webkit/messages.py:
1936         Header for Inspector::FrontendChannel::ConnectionType.
1937
1938         * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
1939         (WebKit::WebInspectorClient::openLocalFrontend):
1940         * WebProcess/WebPage/WebInspector.cpp:
1941         (WebKit::WebInspector::openLocalInspectorFrontend):
1942         (WebKit::WebInspector::setFrontendConnection):
1943         (WebKit::WebInspector::closeFrontendConnection):
1944         (WebKit::WebInspector::close):
1945         (WebKit::WebInspector::openFrontendConnection): Deleted.
1946         (WebKit::WebInspector::sendMessageToBackend): Deleted.
1947         (WebKit::WebInspector::sendMessageToFrontend): Deleted.
1948         On the WebProcess side we ask the UIProcess to open a local frontend and now
1949         receive instead of vend an IPC connection to the WebInspectorUI process.
1950
1951         * UIProcess/WebPageProxy.cpp:
1952         (WebKit::WebPageProxy::finishAttachingToWebProcess):
1953         (WebKit::WebPageProxy::close):
1954         (WebKit::WebPageProxy::resetState):
1955         Keep the WebInspectorProxy alive alongside the WebPageProxy.
1956         Update it as processes / states change.
1957
1958         * UIProcess/WebInspectorProxy.h:
1959         * UIProcess/WebInspectorProxy.messages.in:
1960         * UIProcess/WebInspectorProxy.cpp:
1961         (WebKit::WebInspectorProxy::openLocalInspectorFrontend):
1962         (WebKit::WebInspectorProxy::createInspectorPage): Deleted.
1963         (WebKit::WebInspectorProxy::sendMessageToFrontend):
1964         (WebKit::WebInspectorProxy::closeFrontendPageAndWindow):
1965         Open and close a local frontend by being the FrontendChannel on the UIProcess side.
1966
1967         (WebKit::WebInspectorProxy::sendMessageToBackend):
1968         Dispatch WebInspectorUI backend messages to the UIProcess's InspectorController
1969         now that the InspectorController is here instead of in the WebProcess.
1970
1971         (WebKit::WebInspectorProxy::setFrontendConnection):
1972         Transfer the WebProcess <-> InspectorProcess IPC connection through us
1973         because we are the one link between them when processes change.
1974
1975         (WebKit::WebInspectorProxy::invalidate):
1976         (WebKit::WebInspectorProxy::frontendLoaded):
1977         Be safer and handle inspectedPage being potentially null.
1978
1979         * WebProcess/WebPage/WebPageInspectorTargetController.cpp:
1980         (WebKit::WebPageInspectorTargetController::connectInspector):
1981         * WebProcess/WebPage/WebPageInspectorTargetController.h:
1982         * WebProcess/WebPage/WebPageInspectorTargetFrontendChannel.cpp:
1983         (WebKit::WebPageInspectorTargetFrontendChannel::create):
1984         (WebKit::WebPageInspectorTargetFrontendChannel::WebPageInspectorTargetFrontendChannel):
1985         * WebProcess/WebPage/WebPageInspectorTargetFrontendChannel.h:
1986         * UIProcess/InspectorTargetProxy.cpp:
1987         (WebKit::InspectorTargetProxy::connect):
1988         Proxy the ConnectionType received on the UIProcess side to the WebProcess side
1989         when connecting to sub-targets.
1990
1991         * WebProcess/WebPage/WebPage.cpp:
1992         (WebKit::WebPage::connectInspector):
1993         (WebKit::WebPage::setHasLocalInspectorFrontend): Deleted.
1994         * WebProcess/WebPage/WebPage.h:
1995         * WebProcess/WebPage/WebPage.messages.in:
1996         * UIProcess/WebPageProxy.h:
1997         (WebKit::WebPageProxy::hasLocalInspectorFrontend const): Deleted.
1998         (WebKit::WebPageProxy::setHasLocalInspectorFrontend): Deleted.
1999         * UIProcess/WebPageProxy.messages.in:
2000         * UIProcess/WebProcessPool.cpp:
2001         (WebKit::WebProcessPool::processForNavigationInternal):
2002         Eliminate the hasLocalInspectorFrontend state that was only used
2003         to disable PSON. PSON no longer needs to be disabled for this reason.
2004
2005         * WebProcess/WebPage/WebInspector.h:
2006         * WebProcess/WebPage/WebInspector.messages.in:
2007         * WebProcess/WebPage/WebInspectorUI.cpp:
2008         (WebKit::WebInspectorUI::establishConnection):
2009         (WebKit::WebInspectorUI::updateConnection):
2010         (WebKit::WebInspectorUI::closeWindow):
2011         (WebKit::WebInspectorUI::sendMessageToBackend):
2012         * WebProcess/WebPage/WebInspectorUI.h:
2013         * WebProcess/WebPage/WebInspectorUI.messages.in:
2014         Vend an IPC connection on demand to the WebProcess side.
2015
2016 2018-11-16  Michael Catanzaro  <mcatanzaro@igalia.com>
2017
2018         [GTK][WPE] Add "WebKitDeviceInfoPermissionRequest.h" into webkit2.h
2019         https://bugs.webkit.org/show_bug.cgi?id=191744
2020         <rdar://problem/46125461>
2021
2022         Unreviewed, install the file.
2023
2024         * PlatformGTK.cmake:
2025         * PlatformWPE.cmake:
2026
2027 2018-11-16  Zalan Bujtas  <zalan@apple.com>
2028
2029         Add DidFirstMeaningfulPaint milestone.
2030         https://bugs.webkit.org/show_bug.cgi?id=191754
2031
2032         Reviewed by Simon Fraser.
2033
2034         * Shared/API/c/WKPageLoadTypes.h:
2035         * Shared/API/c/WKSharedAPICast.h:
2036         (WebKit::toWKLayoutMilestones):
2037         (WebKit::toLayoutMilestones):
2038         * UIProcess/API/C/WKPageRenderingProgressEvents.h:
2039         * UIProcess/API/C/WKPageRenderingProgressEventsInternal.h:
2040         (pageRenderingProgressEvents):
2041
2042 2018-11-16  Chris Dumez  <cdumez@apple.com>
2043
2044         Automatic process prewarming should be turned on if PSON is enabled via experimental features
2045         https://bugs.webkit.org/show_bug.cgi?id=191761
2046
2047         Reviewed by Ryosuke Niwa.
2048
2049         m_isAutomaticProcessWarmingEnabledByClient is a std::optional and should not be initialized to
2050         true / false until the client calls API to toggle the feature. When m_isAutomaticProcessWarmingEnabledByClient
2051         is std::nullopt then m_processSwapsOnNavigationFromExperimentalFeatures controls automatic
2052         process prewarming.
2053
2054         * UIProcess/API/APIProcessPoolConfiguration.h:
2055
2056 2018-11-16  Alex Christensen  <achristensen@webkit.org>
2057
2058         Add API to disable safe browsing checks
2059         https://bugs.webkit.org/show_bug.cgi?id=191610
2060
2061         Reviewed by Dean Jackson.
2062
2063         * UIProcess/API/Cocoa/WKPreferences.h:
2064         * UIProcess/API/Cocoa/WKPreferences.mm:
2065         (-[WKPreferences setSafeBrowsingEnabled:]):
2066         (-[WKPreferences isSafeBrowsingEnabled]):
2067         (-[WKPreferences _setSafeBrowsingEnabled:]): Deleted.
2068         (-[WKPreferences _safeBrowsingEnabled]): Deleted.
2069         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
2070
2071 2018-11-16  Chris Dumez  <cdumez@apple.com>
2072
2073         WebKit.UnavailablePlugIn API test is crashing in debug
2074         https://bugs.webkit.org/show_bug.cgi?id=191753
2075
2076         Reviewed by Alex Christensen.
2077
2078         Add missing early returns. Those were mistakenly dropped in r235200.
2079
2080         * UIProcess/Cocoa/NavigationState.mm:
2081         (WebKit::NavigationState::NavigationClient::decidePolicyForPluginLoad):
2082
2083 2018-11-16  Chris Dumez  <cdumez@apple.com>
2084
2085         [Mac] Regression: WebContent process's display name is no longer set
2086         https://bugs.webkit.org/show_bug.cgi?id=191722
2087         <rdar://problem/45960550>
2088
2089         Reviewed by Per Arne Vollan.
2090
2091         Make sure The WebContent process calls _RegisterApplication() during initialization and
2092         *before* trying to set its display name. Setting the display name fails otherwise.
2093
2094         * WebProcess/cocoa/WebProcessCocoa.mm:
2095         (WebKit::WebProcess::initializeProcessName):
2096         (WebKit::WebProcess::platformInitializeProcess):
2097
2098 2018-11-16  Ryosuke Niwa  <rniwa@webkit.org>
2099
2100         Enable process swap on cross-site navigation by default on iOS
2101         https://bugs.webkit.org/show_bug.cgi?id=191735
2102
2103         Reviewed by Chris Dumez.
2104
2105         Enabled the feature.
2106
2107         * Shared/WebPreferencesDefaultValues.h:
2108
2109 2018-11-16  Antti Koivisto  <antti@apple.com>
2110
2111         REGRESSION(r237467) [PSON] iOS: Going back to a page sometimes doesn't restore the full page
2112         https://bugs.webkit.org/show_bug.cgi?id=191737
2113
2114         Reviewed by Simon Fraser.
2115
2116         * WebProcess/WebPage/WebPage.cpp:
2117         (WebKit::WebPage::setLayerTreeStateIsFrozen):
2118
2119         Layer tree should stay frozen in m_shouldResetDrawingArea state. Otherwise spurious commit transactions may
2120         mess up state on UI process side.
2121
2122         Specifically WKWebView._needsResetViewStateAfterCommitLoadForMainFrame would get stuck to TRUE and prevent
2123         all viewport updates because WKWebView._firstPaintAfterCommitLoadTransactionID has value greater
2124         than any current transaction IDs.
2125
2126 2018-11-16  Chris Dumez  <cdumez@apple.com>
2127
2128         Unreviewed typo fix in comment added in r238250.
2129
2130         * UIProcess/WebProcessPool.cpp:
2131         (WebKit::WebProcessPool::ensureNetworkProcess):
2132
2133 2018-11-16  Sihui Liu  <sihui_liu@apple.com>
2134
2135         Storing blobs in IDB on iOS: "Error preparing blob/file"
2136         https://bugs.webkit.org/show_bug.cgi?id=188438
2137         <rdar://problem/43097279>
2138
2139         Reviewed by Alex Christensen.
2140
2141         Grant sandbox extension of temp folder to network process, and clean up some code that managed sandbox extension
2142         of IDB temporary blob files in network process.
2143
2144         * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
2145         (WebKit::NetworkBlobRegistry::registerBlobURLOptionallyFileBacked):
2146         * NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp:
2147         (WebKit::WebIDBConnectionToClient::handleGetResult):
2148         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
2149         (WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
2150         (WebKit::NetworkConnectionToWebProcess::preregisterSandboxExtensionsForOptionallyFileBackedBlob): Deleted.
2151         (WebKit::NetworkConnectionToWebProcess::getBlobDataFileReferenceForPath): Deleted.
2152         * NetworkProcess/NetworkConnectionToWebProcess.h:
2153         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
2154         * NetworkProcess/NetworkProcess.cpp:
2155         (WebKit::NetworkProcess::accessToTemporaryFileComplete):
2156         (WebKit::NetworkProcess::getSandboxExtensionsForBlobFiles):
2157         (WebKit::NetworkProcess::prepareForAccessToTemporaryFile): Deleted.
2158         (WebKit::NetworkProcess::updateTemporaryFileSandboxExtensions): Deleted.
2159         * NetworkProcess/NetworkProcess.h:
2160         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2161         (WebKit::NetworkProcessCreationParameters::encode const):
2162         (WebKit::NetworkProcessCreationParameters::decode):
2163         * NetworkProcess/NetworkProcessCreationParameters.h:
2164         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
2165         (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
2166         * UIProcess/WebProcessPool.cpp:
2167         (WebKit::WebProcessPool::ensureNetworkProcess):
2168         * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
2169         (WebKit::WebIDBConnectionToServer::didGetRecord):
2170         (WebKit::WebIDBConnectionToServer::didGetAllRecords):
2171         (WebKit::WebIDBConnectionToServer::didOpenCursor):
2172         (WebKit::WebIDBConnectionToServer::didIterateCursor):
2173         (WebKit::preregisterSandboxExtensionsIfNecessary): Deleted.
2174
2175 2018-11-16  Don Olmstead  <don.olmstead@sony.com>
2176
2177         Add USE(LIBWPE) to WebCore
2178         https://bugs.webkit.org/show_bug.cgi?id=191401
2179
2180         Reviewed by Michael Catanzaro.
2181
2182         Rename PlatformDisplayWPE to PlatformDisplayLibWPE.
2183
2184         * WebProcess/WebPage/wpe/AcceleratedSurfaceWPE.cpp:
2185         (WebKit::AcceleratedSurfaceWPE::initialize):
2186         * WebProcess/wpe/WebProcessMainWPE.cpp:
2187
2188 2018-11-16  Thibault Saunier  <tsaunier@igalia.com>
2189
2190         [GStreamer][WebRTC] Add API to enable/disable device mocks
2191         https://bugs.webkit.org/show_bug.cgi?id=191699
2192
2193         This basically us to test MediaStream/WebRTC support without
2194         requiring cameras or microphones and is quite useful.
2195
2196         Also fix the GStreamerAudioMock by:
2197           - Stop setting `leaky-upstream` on the GStreamerCapturer queue,
2198             this was usefull when we were trying to bring the MediaStream
2199             sources inside the main pipeline, it is not the case anymore
2200             (and not doable with latest version of LibWebRTC).
2201           - Use a 'ticks' wave on the gstreamer audiotestsrc so the test
2202             stream is similar to what Apple port does.
2203
2204         Reviewed by Xabier Rodriguez-Calvar.
2205
2206         The mocks are already tested and the API is really simple.
2207
2208         * UIProcess/API/glib/WebKitSettings.cpp:
2209         (webKitSettingsSetProperty):
2210         (webKitSettingsGetProperty):
2211         (webkit_settings_class_init):
2212         (webkit_settings_get_enable_mock_capture_devices):
2213         (webkit_settings_set_enable_mock_capture_devices):
2214         * UIProcess/API/gtk/WebKitSettings.h:
2215         * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
2216
2217 2018-11-16  Thibault Saunier  <tsaunier@igalia.com>
2218
2219         [GTK][WPE] Add "WebKitDeviceInfoPermissionRequest.h" into webkit2.h
2220         https://bugs.webkit.org/show_bug.cgi?id=191744
2221
2222         It should always have been there.
2223
2224         Reviewed by Carlos Garcia Campos.
2225
2226         * UIProcess/API/gtk/webkit2.h:
2227
2228 2018-11-16  Antoine Quint  <graouts@apple.com>
2229
2230         PointerEvents should not require touch event listeners to be registered
2231         https://bugs.webkit.org/show_bug.cgi?id=191333
2232         <rdar://problem/45857523>
2233
2234         Reviewed by Dean Jackson.
2235
2236         * UIProcess/WebPageProxy.cpp:
2237         (WebKit::WebPageProxy::updateTouchEventTracking):
2238         (WebKit::WebPageProxy::touchEventTrackingType const):
2239         (WebKit::WebPageProxy::handleTouchEventSynchronously):
2240         (WebKit::WebPageProxy::handleTouchEventAsynchronously):
2241         (WebKit::WebPageProxy::handleTouchEvent):
2242         (WebKit::WebPageProxy::resetState):
2243         * UIProcess/WebPageProxy.h:
2244
2245 2018-11-15  Myles C. Maxfield  <mmaxfield@apple.com>
2246
2247         WKPreferencesSetFontSmoothingLevel doesn't actually do anything
2248         https://bugs.webkit.org/show_bug.cgi?id=191708
2249
2250         Reviewed by Simon Fraser.
2251
2252         Delete the symbol because no one calls it and it doesn't do anything
2253
2254         * Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb:
2255         * Shared/FontSmoothingLevel.h: Removed.
2256         * Shared/WebPreferences.yaml:
2257         * UIProcess/API/C/WKAPICast.h:
2258         (WebKit::toFontSmoothingLevel): Deleted.
2259         * UIProcess/API/C/WKPreferences.cpp:
2260         (WKPreferencesSetFontSmoothingLevel): Deleted.
2261         (WKPreferencesGetFontSmoothingLevel): Deleted.
2262         * UIProcess/API/C/WKPreferencesRefPrivate.h:
2263         * UIProcess/WebPreferences.h:
2264         * WebKit.xcodeproj/project.pbxproj:
2265         * mac/WebKit2.order:
2266
2267 2018-11-15  Truitt Savell  <tsavell@apple.com>
2268
2269         Unreviewed, rolling out r238244.
2270
2271         Caused High Sierra test runs to fail early with 50 crashes and
2272         casued 25 API failures.
2273
2274         Reverted changeset:
2275
2276         "[css-logical] Implement flow-relative margin, padding and
2277         border shorthands"
2278         https://bugs.webkit.org/show_bug.cgi?id=188697
2279         https://trac.webkit.org/changeset/238244
2280
2281 2018-11-15  Joseph Pecoraro  <pecoraro@apple.com>
2282
2283         Web Inspector: Remove unused WebInspectorProxy code
2284         https://bugs.webkit.org/show_bug.cgi?id=191674
2285
2286         Reviewed by Dean Jackson.
2287
2288         * UIProcess/WebInspectorProxy.cpp:
2289         (WebKit::WebInspectorProxy::createInspectorPage):
2290         (WebKit::WebInspectorProxy::closeFrontendPageAndWindow):
2291         * UIProcess/WebInspectorProxy.h:
2292         * UIProcess/mac/WebInspectorProxyMac.mm:
2293         (WebKit::WebInspectorProxy::setInspectorWindowFrame): Deleted.
2294         (WebKit::WebInspectorProxy::inspectorWindowFrame): Deleted.
2295         * WebProcess/WebPage/WebInspector.h:
2296
2297 2018-11-15  Ryosuke Niwa  <rniwa@webkit.org>
2298
2299         Enable process swap on cross-site navigation by default on macOS
2300         https://bugs.webkit.org/show_bug.cgi?id=191572
2301
2302         Reviewed by Chris Dumez.
2303
2304         Enabled the feature by default on macOS.
2305
2306         * Shared/WebPreferences.yaml:
2307         * Shared/WebPreferencesDefaultValues.h:
2308
2309 2018-11-15  Chris Dumez  <cdumez@apple.com>
2310
2311         IndexedDB.IndexedDBTempFileSize API test times out with process prewarming enabled
2312         https://bugs.webkit.org/show_bug.cgi?id=191671
2313         <rdar://problem/46086062>
2314
2315         Reviewed by Alex Christensen.
2316
2317         Enabling process prewarming caused IndexedDB.IndexedDBTempFileSize API to time out and print
2318         the following line:
2319         "Attempted to create a NetworkLoad with a session (id=2) that does not exist."
2320
2321         This actually identified a pre-existing bug with our handling of non-default data store.
2322         Whenever a page starts using a data store, we call WebProcessPool::pageBeginUsingWebsiteDataStore()
2323         which will call NetworkProcessProxy::addSession() if the network process was already started
2324         to let the network process know about this non-default session. There are several issues with the
2325         current model:
2326         1. If the network process was not created yet when pageBeginUsingWebsiteDataStore() is called,
2327            then the network process will not know about the non-default session when it actually gets
2328            started later on. This is unlikely to happen in practice, except in case of network process
2329            crash because we create the network process as soon as we initialize the first WebProcessProxy.
2330         2. Even if we successfuly managed to register the session with the network process proxy, we get
2331            in trouble if the network process crashes or is terminated later on as we do not re-register
2332            those sessions with the new network process.
2333
2334         To address these 2 issues, WebProcessPool::ensureNetworkProcess() now takes care of registering
2335         all the non-default sessions (that are associated with this process pool) with the new network
2336         process. The WebProcessPool knows about these sessions because it adds them to m_sessionToPagesMap
2337         whenever WebProcessPool::pageBeginUsingWebsiteDataStore() is called, even if the network process
2338         proxy was not created yet.
2339
2340         The reason the IndexedDB.IndexedDBTempFileSize API test was failing was because it did:
2341         1. A load in a WebView V1 with a non-default session
2342         2. Process prewarming kicked in after this load and would create a new WebProcessProxy.
2343         3. Terminate the network process
2344         4. Another load in a WebView V2 with the same non-defaut session, which would reuse the
2345           prewarmed process. Because the network process was terminated, constructing the new
2346           page would not register the session ID with the new network process when
2347           pageBeginUsingWebsiteDataStore() is called.
2348         -> The load would hang because the new network process would not know about the
2349            non-default session when started later on.
2350
2351         The bug was previously hidden without process prewarming because step 4 would create a *new*
2352         WebProcessProxy and WebProcessPool::initializeNewWebProcess() would call ensureNetworkProcess()
2353         so that pageBeginUsingWebsiteDataStore() would successfuly register the session with the
2354         network process later on.
2355
2356         I wrote a second API test (WebKit.DoLoadWithNonDefaultDataStoreAfterTerminatingNetworkProcess)
2357         to demonstrate the pre-existing bug without process prewarming enabled.
2358
2359         * UIProcess/WebProcessPool.cpp:
2360         (WebKit::WebProcessPool::ensureNetworkProcess):
2361
2362 2018-11-15  Vivek Seth  <v_seth@apple.com>
2363
2364         Create feature flag (HTTPS_UPGRADE)
2365         https://bugs.webkit.org/show_bug.cgi?id=191613
2366         <rdar://problem/45851068>
2367
2368         Reviewed by Dean Jackson.
2369
2370         * config.h:
2371
2372 2018-11-15  Chris Dumez  <cdumez@apple.com>
2373
2374         Regression(r238215) WKProcessPool.WarmInitialProcess API test is failing
2375         https://bugs.webkit.org/show_bug.cgi?id=191693
2376
2377         Reviewed by Alex Christensen.
2378
2379         Allow *explicit* process prewarming to construct the default data store if necessary or we would
2380         not be obeying the client's request. Only automatic process prewarming should avoid constructing
2381         the default data store unnecessarily to avoid causing memory regressions.
2382
2383         * UIProcess/API/C/WKContext.cpp:
2384         (WKContextWarmInitialProcess):
2385         * UIProcess/API/Cocoa/WKProcessPool.mm:
2386         (-[WKProcessPool _warmInitialProcess]):
2387         * UIProcess/WebProcessPool.cpp:
2388         (WebKit::WebProcessPool::prewarmProcess):
2389         (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
2390         * UIProcess/WebProcessPool.h:
2391         (WebKit::WebProcessPool::sendToOneProcess):
2392
2393 2018-11-14  Jiewen Tan  <jiewen_tan@apple.com>
2394
2395         Unreviewed, comment improvement over r238166.
2396
2397         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
2398         (WKWebsiteDataStoreSetWebAuthenticationMockConfiguration):
2399         * UIProcess/WebAuthentication/fido/CtapHidAuthenticator.h:
2400
2401 2018-11-15  Jiewen Tan  <jiewen_tan@apple.com>
2402
2403         [WebAuthN] Use a real nonce for CTAPHID_INIT
2404         https://bugs.webkit.org/show_bug.cgi?id=191533
2405         <rdar://problem/46103502>
2406
2407         Reviewed by Brent Fulgham.
2408
2409         Use a real nonce for CTAPHID_INIT request according to:
2410         https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html#ctaphid_init-0x06.
2411         The challenge here is the new transaction needs to start in the next runloop otherwise a dead lock will form:
2412         wrong nonce -> new transaction -> new nonce -> write init request -> read init response from last run as it
2413         piped in the run loop -> wrong nonce of course -> ...
2414         To break the above dead lock, we have to start the new transaction in the next run. However, that isn't
2415         sufficient as the arrived init response will be piped in HidConnection::m_inputReports, which is designed
2416         on purpose to store any data packets within (initialized, terminated) time interval to prevent data loss in
2417         the case when HidConnection::registerDataReceivedCallback is called after the first data packet's arrival.
2418         In order to break the dead lock completely, HidConnection::invalidateCache will bnnne called prior to every
2419         send to delete any potential init response from last run. HidConnection::invalidateCache is not necessary
2420         for other protocols though. The above scenario is more or less a design flaw in CTAP HID.
2421
2422         Of course, all above scenarios are covered in our mock tests.
2423
2424         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
2425         (WKWebsiteDataStoreSetWebAuthenticationMockConfiguration):
2426         * UIProcess/WebAuthentication/Cocoa/HidConnection.h:
2427         (WebKit::HidConnection::invalidateCache):
2428         * UIProcess/WebAuthentication/Mock/MockHidConnection.cpp:
2429         (WebKit::MockHidConnection::send):
2430         (WebKit::MockHidConnection::parseRequest):
2431         (WebKit::MockHidConnection::feedReports):
2432         * UIProcess/WebAuthentication/Mock/MockHidConnection.h:
2433         * UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h:
2434         * UIProcess/WebAuthentication/fido/CtapHidDriver.cpp:
2435         (WebKit::CtapHidDriver::Worker::transact):
2436         (WebKit::CtapHidDriver::CtapHidDriver):
2437         (WebKit::CtapHidDriver::transact):
2438         (WebKit::CtapHidDriver::continueAfterChannelAllocated):
2439         (WebKit::CtapHidDriver::returnResponse):
2440         * UIProcess/WebAuthentication/fido/CtapHidDriver.h:
2441
2442 2018-11-15  Oriol Brufau  <obrufau@igalia.com>
2443
2444         [css-logical] Implement flow-relative margin, padding and border shorthands
2445         https://bugs.webkit.org/show_bug.cgi?id=188697
2446
2447         Reviewed by Simon Fraser and Antti Koivisto.
2448
2449         Add a CSSLogicalEnabled runtime flag.
2450
2451         * Shared/WebPreferences.yaml:
2452
2453 2018-11-15  Jiewen Tan  <jiewen_tan@apple.com>
2454
2455         [WebAuthN] PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria::AuthenticatorAttachment should be optional
2456         https://bugs.webkit.org/show_bug.cgi?id=191522
2457
2458         Reviewed by Brent Fulgham.
2459
2460         * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
2461         (WebKit::AuthenticatorManagerInternal::collectTransports):
2462
2463 2018-11-15  Michael Catanzaro  <mcatanzaro@igalia.com>
2464
2465         [SOUP] Make Accept-Languages header look more like other browsers
2466         https://bugs.webkit.org/show_bug.cgi?id=191614
2467
2468         Reviewed by Carlos Garcia Campos.
2469
2470         This changes our Accept-Language header to better match other browsers, from something
2471         like this:
2472
2473         Accept-Language: en-us, en;q=0.90, es-es;q=0.80, es;q=0.70
2474
2475         to something like this:
2476
2477         Accept-Language: en-US,en;q=0.90,es-ES;q=0.80,es;q=0.70
2478
2479         There's no particular motivation for this change. I just noticed we were different for no
2480         clear reason.
2481
2482         * NetworkProcess/soup/NetworkProcessSoup.cpp:
2483         (WebKit::buildAcceptLanguages):
2484         * UIProcess/API/glib/WebKitWebContext.cpp:
2485         (webkit_web_context_set_preferred_languages):
2486
2487 2018-11-15  Daniel Bates  <dabates@apple.com>
2488
2489         [iOS] Shift + Tab does not focus previous field
2490         https://bugs.webkit.org/show_bug.cgi?id=191596
2491         <rdar://problem/45892053>
2492
2493         Reviewed by Wenson Hsieh.
2494
2495         Wire up the the tab and shift + tab key commands to the WKWebView/WKContentView's
2496         action forwarding mechanism. Also rename -_prevAccessoryTab to -_previousAccessoryTab.
2497
2498         * Platform/spi/ios/UIKitSPI.h: Add more SPI.
2499         * UIProcess/API/Cocoa/WKWebViewInternal.h:
2500         * UIProcess/ios/WKContentViewInteraction.h:
2501         * UIProcess/ios/WKContentViewInteraction.mm:
2502         (-[WKContentView canPerformActionForWebView:withSender:]):
2503         (-[WKContentView keyCommands]):
2504         (-[WKContentView _nextAccessoryTabForWebView:]): Added.
2505         (-[WKContentView _previousAccessoryTabForWebView:]): Added.
2506         (-[WKContentView _nextAccessoryTab:]): Deleted.
2507         (-[WKContentView _prevAccessoryTab:]): Deleted.
2508
2509 2018-11-15  Keith Rollin  <krollin@apple.com>
2510
2511         Delete old .xcfilelist files
2512         https://bugs.webkit.org/show_bug.cgi?id=191669
2513         <rdar://problem/46081994>
2514
2515         Reviewed by Chris Dumez.
2516
2517         .xcfilelist files were created and added to the Xcode project files in
2518         https://trac.webkit.org/changeset/238008/webkit. However, they caused
2519         build issues and they were removed from the Xcode projects in
2520         https://trac.webkit.org/changeset/238055/webkit. This check-in removes
2521         the files from the repository altogether. They'll ultimately be
2522         replaced with new files with names that indicate whether the
2523         associated files are inputs to the Run Script phase or are files
2524         created by the Run Script phase.
2525
2526         * DerivedSources.xcfilelist: Removed.
2527         * UnifiedSources.xcfilelist: Removed.
2528
2529 2018-11-15  Frederic Wang  <fwang@igalia.com>
2530
2531         [WebAuthN] Make AuthenticatorManager
2532         https://bugs.webkit.org/show_bug.cgi?id=189279
2533
2534         Unreviewed build fix.
2535
2536         * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: Add missing header.
2537         * UIProcess/WebAuthentication/Cocoa/LocalConnection.mm: Ditto.
2538         * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp: Ditto.
2539
2540 2018-11-14  Keith Rollin  <krollin@apple.com>
2541
2542         Move scripts for Derived and Unified Sources to external files
2543         https://bugs.webkit.org/show_bug.cgi?id=191670
2544         <rdar://problem/46082278>
2545
2546         Reviewed by Keith Miller.
2547
2548         Move the scripts in the Generate Derived Sources and Generate Unified
2549         Sources Run Script phases from the Xcode projects to external shell
2550         script files. Then invoke those scripts from the Run Script phases.
2551         This refactoring is being performed to support later work that will
2552         invoke these scripts in other contexts.
2553
2554         The scripts were maintained as-is when making the move. I did a little
2555         reformatting and added 'set -e' to the top of each file, but that's
2556         it.
2557
2558         * Scripts/generate-derived-sources.sh: Added.
2559         * Scripts/generate-unified-sources.sh: Added.
2560         * WebKit.xcodeproj/project.pbxproj:
2561
2562 2018-11-14  Chris Dumez  <cdumez@apple.com>
2563
2564         WebKit.DecidePolicyForNavigationActionForHyperlinkThatRedirects API fails when PSON is enabled
2565         https://bugs.webkit.org/show_bug.cgi?id=191640
2566
2567         Reviewed by Alex Christensen.
2568
2569         The issue was that when process-swapping on a redirect, the parameters provided by the new
2570         WebContent process for navigationActionData / originatingFrameInfoData / frameSecurityOrigin
2571         are not correct because it does not have sufficient information (it does not know a swap
2572         happened).
2573
2574         To address the issue, we now store the navigationActionData / originatingFrameInfoData /
2575         frameSecurityOrigin on the Navigation object whenever decidePolicyForNavigationAction is
2576         called. If the decidePolicyForNavigationAction is for a redirect, use the ones we stored
2577         on the Navigation object instead of the ones provided by the WebContent process. In case
2578         of redirect, those do not change anyway.
2579
2580         This fixes all WebKit.DecidePolicyForNavigationAction* tests with PSON enabled.
2581
2582         * UIProcess/API/APINavigation.h:
2583         (API::Navigation::currentRequestIsRedirect const):
2584         (API::Navigation::wasUserInitiated const):
2585         (API::Navigation::shouldForceDownload const):
2586         (API::Navigation::treatAsSameOriginNavigation const):
2587         (API::Navigation::hasOpenedFrames const):
2588         (API::Navigation::openedViaWindowOpenWithOpener const):
2589         (API::Navigation::opener const):
2590         (API::Navigation::requesterOrigin const):
2591         (API::Navigation::lockHistory const):
2592         (API::Navigation::lockBackForwardList const):
2593         (API::Navigation::clientRedirectSourceForHistory const):
2594         (API::Navigation::setLastNavigationAction):
2595         (API::Navigation::lastNavigationAction const):
2596         (API::Navigation::setOriginatingFrameInfo):
2597         (API::Navigation::originatingFrameInfo const):
2598         (API::Navigation::setDestinationFrameSecurityOrigin):
2599         (API::Navigation::destinationFrameSecurityOrigin const):
2600         * UIProcess/WebPageProxy.cpp:
2601         (WebKit::WebPageProxy::decidePolicyForNavigationActionAsync):
2602         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
2603         (WebKit::WebPageProxy::decidePolicyForNavigationActionSync):
2604         * UIProcess/WebPageProxy.h:
2605
2606 2018-11-14  Chris Dumez  <cdumez@apple.com>
2607
2608         WebKit.WebsiteDataStoreCustomPaths API test is failing when enabling process prewarming
2609         https://bugs.webkit.org/show_bug.cgi?id=191638
2610
2611         Reviewed by Alex Christensen.
2612
2613         WebProcessPool::prewarmProcess() should not create the default WebSite Data Store if it
2614         does not exist yet. This is bad for memory consumption and it is what was causing this
2615         API test to fail.
2616
2617         WebProcessPool::prewarmProcess() now tries to use the following data stores in this
2618         order of preference:
2619         1. WebProcessPool::m_websiteDataStore (aka this process pool's primary data store)
2620         2. The data store of the last WebProcessProxy that was created
2621         3. The default data store if it exists
2622
2623         If no suitable data store is found, we cancel the process prewarming and log a console
2624         message instead.
2625
2626         * UIProcess/WebProcessPool.cpp:
2627         (WebKit::WebProcessPool::prewarmProcess):
2628
2629 2018-11-14  Timothy Hatcher  <timothy@apple.com>
2630
2631         Enabled dark mode CSS support by default.
2632         https://bugs.webkit.org/show_bug.cgi?id=191609
2633         rdar://problem/46046861
2634
2635         Reviewed by Megan Gardner.
2636
2637         * Shared/WebPreferences.yaml: Set DarkModeCSSEnabled's defaultValue to true.
2638
2639 2018-11-14  Timothy Hatcher  <timothy@apple.com>
2640
2641         Default the view background color and text color to different values when in dark mode.
2642         https://bugs.webkit.org/show_bug.cgi?id=191607
2643         rdar://problem/46045854
2644
2645         Reviewed by Dean Jackson.
2646
2647         * UIProcess/Cocoa/WebViewImpl.mm:
2648         (WebKit::WebViewImpl::backgroundColor const): Use controlBackgroundColor.
2649         (WebKit::WebViewImpl::updateLayer): Simplified and use backgroundColor() getter.
2650         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2651         (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Drop backgroundColor.
2652         * WebProcess/WebPage/WebPage.cpp:
2653         (WebKit::WebPage::setDrawsBackground): Drop backgroundColor.
2654
2655 2018-11-14  Joseph Pecoraro  <pecoraro@apple.com>
2656
2657         Web Inspector: Pass Inspector::FrontendChannel as a reference connect/disconnect methods
2658         https://bugs.webkit.org/show_bug.cgi?id=191612
2659
2660         Reviewed by Matt Baker.
2661
2662         * UIProcess/Automation/WebAutomationSession.cpp:
2663         (WebKit::WebAutomationSession::connect):
2664         (WebKit::WebAutomationSession::disconnect):
2665         (WebKit::WebAutomationSession::terminate):
2666         * UIProcess/Automation/WebAutomationSession.h:
2667         * UIProcess/WebPageDebuggable.cpp:
2668         (WebKit::WebPageDebuggable::connect):
2669         (WebKit::WebPageDebuggable::disconnect):
2670         * UIProcess/WebPageDebuggable.h:
2671         * UIProcess/WebPageInspectorController.cpp:
2672         (WebKit::WebPageInspectorController::connectFrontend):
2673         (WebKit::WebPageInspectorController::disconnectFrontend):
2674         * UIProcess/WebPageInspectorController.h:
2675         * WebProcess/WebPage/WebInspector.cpp:
2676         (WebKit::WebInspector::close):
2677         * WebProcess/WebPage/WebPageInspectorTarget.cpp:
2678         (WebKit::WebPageInspectorTarget::connect):
2679         (WebKit::WebPageInspectorTarget::disconnect):
2680
2681 2018-11-14  Joseph Pecoraro  <pecoraro@apple.com>
2682
2683         Unreviewed attempted wincairo build fix after 238192.
2684
2685         * WebProcess/WebPage/WebPageInspectorTargetController.h:
2686         * WebProcess/WebPage/WebPageInspectorTargetFrontendChannel.cpp:
2687
2688 2018-11-14  Joseph Pecoraro  <pecoraro@apple.com>
2689
2690         Web Inspector: Follow-up: Keep Disabling Process Swap for Local Web Inspector
2691         https://bugs.webkit.org/show_bug.cgi?id=191494
2692         <rdar://problem/45469854>
2693
2694         Reviewed by Devin Rousso.
2695
2696         Continue to have the Local Inspector disable PSON while open
2697         until support is added.
2698
2699         * UIProcess/WebPageProxy.cpp:
2700         (WebKit::WebPageProxy::resetState):
2701         * UIProcess/WebPageProxy.h:
2702         (WebKit::WebPageProxy::hasLocalInspectorFrontend const):
2703         (WebKit::WebPageProxy::setHasLocalInspectorFrontend):
2704         * UIProcess/WebPageProxy.messages.in:
2705         * UIProcess/WebProcessPool.cpp:
2706         (WebKit::WebProcessPool::processForNavigationInternal):
2707         * WebProcess/WebPage/WebInspector.cpp:
2708         (WebKit::WebInspector::openFrontendConnection):
2709         (WebKit::WebInspector::closeFrontendConnection):
2710         * WebProcess/WebPage/WebPage.cpp:
2711         (WebKit::WebPage::setHasLocalInspectorFrontend):
2712         * WebProcess/WebPage/WebPage.h:
2713
2714 2018-11-14  Joseph Pecoraro  <pecoraro@apple.com>
2715
2716         Web Inspector: Keep Web Inspector window alive across process swaps (PSON) (Remote Inspector)
2717         https://bugs.webkit.org/show_bug.cgi?id=191494
2718         <rdar://problem/45469854>
2719
2720         Reviewed by Devin Rousso.
2721
2722         To support process swapping a slim Web Inspector backend lives in the UIProcess.
2723         The Web Inspector frontend connects to it and is told about sub-targets, namely
2724         pages, that it can further connect to. When performing a process swap the backend
2725         tells the frontend to destroy existing targets and create new targets.
2726
2727         In the UIProcess the WebPageProxy has a WebPageInspectorController, with a single
2728         TargetAgent holding InspectorTargetProxies to targets it knows about. Inspector
2729         protocol messages go through this inspector controller and are routed to the
2730         WebPage and its WebCore::Page's InspectorController. The WebPageProxy decides
2731         when to close and expose new page targets during process swap, or basically
2732         any time it reconnects to a WebProcess. So this patch also makes Web Inspector
2733         stay alive and reconnect to a page when the inspected page crashes!
2734
2735         In the WebContentProcess the WebPage has a WebPageInspectorTarget. It also
2736         has a WebPageInspectorTargetController in anticipation of further sub-targets
2737         within the page (workers, frames) but none exist at the moment. The WebPage
2738         relies on the WebPageProxy to know when to expose this target as a debuggable.
2739
2740         * Sources.txt:
2741         * WebKit.xcodeproj/project.pbxproj:
2742         New files.
2743
2744         * Shared/WebPageCreationParameters.cpp:
2745         (WebKit::WebPageCreationParameters::encode const):
2746         (WebKit::WebPageCreationParameters::decode):
2747         * Shared/WebPageCreationParameters.h:
2748         Remote inspector state can now stay in the UIProcess and does not need to
2749         be passed down to the WebContentProcess.
2750
2751         * UIProcess/WebPageDebuggable.cpp: Copied from Source/WebCore/page/PageDebuggable.cpp.
2752         (WebKit::WebPageDebuggable::WebPageDebuggable):
2753         (WebKit::WebPageDebuggable::name const):
2754         (WebKit::WebPageDebuggable::url const):
2755         (WebKit::WebPageDebuggable::hasLocalDebugger const):
2756         (WebKit::WebPageDebuggable::connect):
2757         (WebKit::WebPageDebuggable::disconnect):
2758         (WebKit::WebPageDebuggable::dispatchMessageFromRemote):
2759         (WebKit::WebPageDebuggable::setIndicating):
2760         (WebKit::WebPageDebuggable::setNameOverride):
2761         * UIProcess/WebPageDebuggable.h: Copied from Source/WebCore/page/PageDebuggable.h.
2762         Remote debuggable entry point into the UIProcess for a page.
2763         This is pretty much identical to the PageDebuggable in WebCore.
2764
2765         * Scripts/webkit/messages.py:
2766         * UIProcess/WebPageProxy.messages.in:
2767         * UIProcess/WebPageProxy.cpp:
2768         (WebKit::m_resetRecentCrashCountTimer):
2769         (WebKit::WebPageProxy::finishAttachingToWebProcess):
2770         (WebKit::WebPageProxy::close):
2771         (WebKit::WebPageProxy::createInspectorTarget):
2772         (WebKit::WebPageProxy::destroyInspectorTarget):
2773         (WebKit::WebPageProxy::sendMessageToInspectorFrontend):
2774         (WebKit::WebPageProxy::setIndicating):
2775         (WebKit::WebPageProxy::allowsRemoteInspection const):
2776         (WebKit::WebPageProxy::setAllowsRemoteInspection):
2777         (WebKit::WebPageProxy::remoteInspectionNameOverride const):
2778         (WebKit::WebPageProxy::setRemoteInspectionNameOverride):
2779         (WebKit::WebPageProxy::remoteInspectorInformationDidChange):
2780         (WebKit::WebPageProxy::clearInspectorTargets):
2781         (WebKit::WebPageProxy::createInspectorTargets):
2782         (WebKit::WebPageProxy::didCommitLoadForFrame):
2783         (WebKit::WebPageProxy::didReceiveTitleForFrame):
2784         (WebKit::WebPageProxy::creationParameters):
2785         * UIProcess/WebPageProxy.h:
2786         (WebKit::WebPageProxy::inspectorController):
2787         (WebKit::WebPageProxy::allowsRemoteInspection const): Deleted.
2788         (WebKit::WebPageProxy::remoteInspectionNameOverride const): Deleted.
2789         Own more inspector state in the UIProcess including a debuggable and inspector controller.
2790
2791         * UIProcess/WebPageInspectorController.h: Added.
2792         * UIProcess/WebPageInspectorController.cpp: Added.
2793         (WebKit::WebPageInspectorController::WebPageInspectorController):
2794         (WebKit::WebPageInspectorController::pageClosed):
2795         (WebKit::WebPageInspectorController::hasLocalFrontend const):
2796         (WebKit::WebPageInspectorController::hasRemoteFrontend const):
2797         (WebKit::WebPageInspectorController::connectFrontend):
2798         (WebKit::WebPageInspectorController::disconnectFrontend):
2799         (WebKit::WebPageInspectorController::disconnectAllFrontends):
2800         (WebKit::WebPageInspectorController::dispatchMessageFromFrontend):
2801         (WebKit::WebPageInspectorController::setIndicating):
2802         (WebKit::WebPageInspectorController::clearTargets):
2803         (WebKit::WebPageInspectorController::createInspectorTarget):
2804         (WebKit::WebPageInspectorController::destroyInspectorTarget):
2805         (WebKit::WebPageInspectorController::sendMessageToInspectorFrontend):
2806         InspectorController with a single TargetAgent in the UIProcess.
2807
2808         * UIProcess/WebPageInspectorTargetAgent.h:
2809         * UIProcess/WebPageInspectorTargetAgent.cpp:
2810         (WebKit::WebPageInspectorTargetAgent::WebPageInspectorTargetAgent):
2811         (WebKit::WebPageInspectorTargetAgent::frontendChannel):
2812         Target agent implementation.
2813
2814         * UIProcess/InspectorTargetProxy.cpp:
2815         (WebKit::InspectorTargetProxy::create):
2816         (WebKit::InspectorTargetProxy::InspectorTargetProxy):
2817         (WebKit::InspectorTargetProxy::connect):
2818         (WebKit::InspectorTargetProxy::disconnect):
2819         (WebKit::InspectorTargetProxy::sendMessageToTargetBackend):
2820         * UIProcess/InspectorTargetProxy.h:
2821         UIProcess proxy for an InspectorTarget in the WebContentProcess.
2822
2823         * UIProcess/WebProcessPool.cpp:
2824         (WebKit::WebProcessPool::processForNavigationInternal):
2825
2826         * WebProcess/WebPage/WebPage.cpp:
2827         (WebKit::m_shouldAttachDrawingAreaOnPageTransition):
2828         (WebKit::WebPage::connectInspector):
2829         (WebKit::WebPage::disconnectInspector):
2830         (WebKit::WebPage::sendMessageToTargetBackend):
2831         (WebKit::WebPage::setIndicating):
2832         (WebKit::WebPage::setAllowsRemoteInspection): Deleted.
2833         (WebKit::WebPage::setRemoteInspectionNameOverride): Deleted.
2834         * WebProcess/WebPage/WebPage.h:
2835         * WebProcess/WebPage/WebPage.messages.in:
2836
2837         * WebProcess/WebPage/WebPageInspectorTarget.h:
2838         * WebProcess/WebPage/WebPageInspectorTarget.cpp:
2839         (WebKit::WebPageInspectorTarget::WebPageInspectorTarget):
2840         (WebKit::WebPageInspectorTarget::identifier const):
2841         (WebKit::WebPageInspectorTarget::connect):
2842         (WebKit::WebPageInspectorTarget::disconnect):
2843         (WebKit::WebPageInspectorTarget::sendMessageToTargetBackend):
2844         InspectorTarget for this WebPage.
2845
2846         * WebProcess/WebPage/WebPageInspectorTargetController.cpp: Added.
2847         (WebKit::WebPageInspectorTargetController::WebPageInspectorTargetController):
2848         (WebKit::WebPageInspectorTargetController::~WebPageInspectorTargetController):
2849         (WebKit::WebPageInspectorTargetController::addTarget):
2850         (WebKit::WebPageInspectorTargetController::removeTarget):
2851         (WebKit::WebPageInspectorTargetController::connectInspector):
2852         (WebKit::WebPageInspectorTargetController::disconnectInspector):
2853         (WebKit::WebPageInspectorTargetController::sendMessageToTargetBackend):
2854         (WebKit::WebPageInspectorTargetController::sendMessageToTargetFrontend):
2855         * WebProcess/WebPage/WebPageInspectorTargetController.h:
2856         * WebProcess/WebPage/WebPageInspectorTargetFrontendChannel.h:
2857         * WebProcess/WebPage/WebPageInspectorTargetFrontendChannel.cpp:
2858         (WebKit::WebPageInspectorTargetFrontendChannel::create):
2859         (WebKit::WebPageInspectorTargetFrontendChannel::WebPageInspectorTargetFrontendChannel):
2860         (WebKit::WebPageInspectorTargetFrontendChannel::sendMessageToFrontend):
2861         Preparation for more target managment in the WebContentProcess.
2862
2863 2018-11-14  Alex Christensen  <achristensen@webkit.org>
2864
2865         Add SPI to show a safe browsing warning
2866         https://bugs.webkit.org/show_bug.cgi?id=191604
2867
2868         Reviewed by Andy Estes.
2869
2870         Safari has a case where it shows safe browsing warnings for a reason other than being told to by the SafeBrowsing framework.
2871         Because safe browsing is moving to WebKit, we will have Safari call this WebKit SPI in that case.
2872         The warning looks a little different, so I had to change the structure of a SafeBrowsingResult and the location of the string processing,
2873         but the existing behavior is the same as verified by existing unit tests.  I added a unit test to verify behavior of the new SPI.
2874
2875         * SourcesCocoa.txt:
2876         * UIProcess/API/Cocoa/WKWebView.mm:
2877         (-[WKWebView _showSafeBrowsingWarningWithTitle:warning:details:completionHandler:]):
2878         (-[WKWebView _showSafeBrowsingWarning:completionHandler:]):
2879         (+[WKWebView _confirmMalwareSentinel]):
2880         (+[WKWebView _visitUnsafeWebsiteSentinel]):
2881         * UIProcess/API/Cocoa/WKWebViewInternal.h:
2882         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2883         * UIProcess/Cocoa/SafeBrowsingResultCocoa.mm: Removed.
2884         * UIProcess/Cocoa/SafeBrowsingWarningCocoa.mm: Copied from Source/WebKit/UIProcess/Cocoa/SafeBrowsingResultCocoa.mm.
2885         (WebKit::malwareDetailsBase):
2886         (WebKit::learnMoreURL):
2887         (WebKit::reportAnErrorBase):
2888         (WebKit::localizedProvider):
2889         (WebKit::SafeBrowsingWarning::visitUnsafeWebsiteSentinel):
2890         (WebKit::SafeBrowsingWarning::confirmMalwareSentinel):
2891         (WebKit::replace):
2892         (WebKit::addLinkAndReplace):
2893         (WebKit::reportAnErrorURL):
2894         (WebKit::malwareDetailsURL):
2895         (WebKit::safeBrowsingTitleText):
2896         (WebKit::safeBrowsingWarningText):
2897         (WebKit::safeBrowsingDetailsText):
2898         (WebKit::SafeBrowsingWarning::SafeBrowsingWarning):
2899         (WebKit::learnMore): Deleted.
2900         (WebKit::SafeBrowsingResult::SafeBrowsingResult): Deleted.
2901         * UIProcess/Cocoa/WKSafeBrowsingWarning.h:
2902         * UIProcess/Cocoa/WKSafeBrowsingWarning.mm:
2903         (-[WKSafeBrowsingWarning initWithFrame:safeBrowsingWarning:completionHandler:]):
2904         (-[WKSafeBrowsingWarning addContent]):
2905         (-[WKSafeBrowsingWarning showDetailsClicked]):
2906         (-[WKSafeBrowsingWarning clickedOnLink:]):
2907         (-[WKSafeBrowsingTextView initWithAttributedString:forWarning:]):
2908         (confirmMalwareSentinel): Deleted.
2909         (visitUnsafeWebsiteSentinel): Deleted.
2910         (replace): Deleted.
2911         (addLinkAndReplace): Deleted.
2912         (reportAnErrorURL): Deleted.
2913         (malwareDetailsURL): Deleted.
2914         (titleText): Deleted.
2915         (warningText): Deleted.
2916         (detailsText): Deleted.
2917         (-[WKSafeBrowsingWarning initWithFrame:safeBrowsingResult:completionHandler:]): Deleted.
2918         * UIProcess/Cocoa/WebPageProxyCocoa.mm:
2919         (WebKit::WebPageProxy::beginSafeBrowsingCheck):
2920         * UIProcess/Cocoa/WebViewImpl.h:
2921         * UIProcess/Cocoa/WebViewImpl.mm:
2922         (WebKit::WebViewImpl::showSafeBrowsingWarning):
2923         * UIProcess/PageClient.h:
2924         (WebKit::PageClient::showSafeBrowsingWarning):
2925         * UIProcess/SafeBrowsingResult.h: Removed.
2926         * UIProcess/SafeBrowsingWarning.h: Copied from Source/WebKit/UIProcess/SafeBrowsingResult.h.
2927         (WebKit::SafeBrowsingWarning::create):
2928         (WebKit::SafeBrowsingWarning::title const):
2929         (WebKit::SafeBrowsingWarning::warning const):
2930         (WebKit::SafeBrowsingWarning::details const):
2931         (WebKit::SafeBrowsingResult::create): Deleted.
2932         (WebKit::SafeBrowsingResult::isPhishing const): Deleted.
2933         (WebKit::SafeBrowsingResult::isMalware const): Deleted.
2934         (WebKit::SafeBrowsingResult::isUnwantedSoftware const): Deleted.
2935         (WebKit::SafeBrowsingResult::url const): Deleted.
2936         (WebKit::SafeBrowsingResult::provider const): Deleted.
2937         (WebKit::SafeBrowsingResult::localizedProviderName const): Deleted.
2938         (WebKit::SafeBrowsingResult::malwareDetailsURLBase const): Deleted.
2939         (WebKit::SafeBrowsingResult::reportAnErrorURLBase const): Deleted.
2940         (WebKit::SafeBrowsingResult::learnMoreURL const): Deleted.
2941         (WebKit::SafeBrowsingResult::needsSafeBrowsingWarning const): Deleted.
2942         (): Deleted.
2943         * UIProcess/WebFramePolicyListenerProxy.cpp:
2944         (WebKit::WebFramePolicyListenerProxy::didReceiveSafeBrowsingResults):
2945         (WebKit::WebFramePolicyListenerProxy::use):
2946         * UIProcess/WebFramePolicyListenerProxy.h:
2947         * UIProcess/WebFrameProxy.cpp:
2948         (WebKit::WebFrameProxy::WebFrameProxy):
2949         (WebKit::WebFrameProxy::setUpPolicyListenerProxy):
2950         (WebKit::WebFrameProxy::didHandleContentFilterUnblockNavigation):
2951         * UIProcess/WebFrameProxy.h:
2952         (WebKit::WebFrameProxy::create):
2953         (WebKit::WebFrameProxy::page const):
2954         * UIProcess/WebPageProxy.cpp:
2955         (WebKit::WebPageProxy::swapToWebProcess):
2956         (WebKit::WebPageProxy::didCreateMainFrame):
2957         (WebKit::WebPageProxy::didCreateSubframe):
2958         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
2959         (WebKit::WebPageProxy::decidePolicyForNewWindowAction):
2960         (WebKit::WebPageProxy::decidePolicyForResponse):
2961         * UIProcess/ios/PageClientImplIOS.h:
2962         * UIProcess/ios/PageClientImplIOS.mm:
2963         (WebKit::PageClientImpl::showSafeBrowsingWarning):
2964         * UIProcess/mac/PageClientImplMac.h:
2965         * UIProcess/mac/PageClientImplMac.mm:
2966         (WebKit::PageClientImpl::showSafeBrowsingWarning):
2967         * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
2968         * WebKit.xcodeproj/project.pbxproj:
2969
2970 2018-11-14  Wenson Hsieh  <wenson_hsieh@apple.com>
2971
2972         [iOS] A few drag and drop tests are crashing after r238146
2973         https://bugs.webkit.org/show_bug.cgi?id=191617
2974
2975         Reviewed by Dean Jackson.
2976
2977         The notion of temporarily suppressing the selection assistant was introduced during iOS drag and drop
2978         development as a way of allowing both the selection view and dropped content snapshot to fade in simultaneously
2979         during a drop in an editable element. r238146 piggy-backs on this mechanism by changing selection suppression
2980         state when an element is focused, when the selection changes, and when an element is blurred, depending on
2981         whether the currently focused element is transparent.
2982
2983         However, in the case where the selection assistant is suppressed due to a running drop animation, if focus moves
2984         to an element that is not fully transparent, we end up prematurely unsuppressing the text selection assistant.
2985         This subsequently causes selection UI to immediately show up after a drop instead of animating in alongside a
2986         snapshot of the inserted document fragment, if the drop moved focus to an editable element.
2987
2988         A number of drag and drop tests on iOS exercised this codepath by dragging content into editable fields and/or
2989         moving content between editable elements in a web view. These tests began to crash due to selection views and
2990         the accompanying callout bar appearing earlier than usual, which triggers an unrelated UIKit assertion in
2991         <https://webkit.org/b/190401>.
2992
2993         This patch fixes the failing tests by refactoring our selection assistant suppression code. Instead of
2994         maintaining a single `BOOL` flag indicating whether the selection is suppressed, we use an `OptionSet` of
2995         `SuppressSelectionAssistantReason`s, which (at the moment) only include (1) a running drop animation, and (2)
2996         focusing a transparent element. The text selection assistant is considered suppressed when either of the reasons
2997         apply. This allows us to correctly handle a drop animation that occurs simultaneously as an element is focused
2998         without unsuppressing the selection assistant early, and also allows us to handle selection assistant
2999         suppression in more nuanced ways, depending on the suppression reason.
3000
3001         * UIProcess/ios/WKContentViewInteraction.h:
3002         * UIProcess/ios/WKContentViewInteraction.mm:
3003         (-[WKContentView cleanupInteraction]):
3004         (-[WKContentView _displayFormNodeInputView]):
3005
3006         Only prevent zooming to the focused element during drop if we're suppressing the selection assistant due to
3007         focusing a transparent element. In the case of a drop, we still want to allow scrolling and zooming.
3008
3009         (-[WKContentView canShowNonEmptySelectionView]):
3010         (-[WKContentView hasSelectablePositionAtPoint:]):
3011         (-[WKContentView pointIsNearMarkedText:]):
3012         (-[WKContentView textInteractionGesture:shouldBeginAtPoint:]):
3013         (-[WKContentView _startAssistingKeyboard]):
3014         (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
3015         (-[WKContentView _stopAssistingNode]):
3016         (-[WKContentView _updateChangedSelection:]):
3017         (-[WKContentView _shouldSuppressSelectionCommands]):
3018         (-[WKContentView _beginSuppressingSelectionAssistantForReason:]):
3019         (-[WKContentView _stopSuppressingSelectionAssistantForReason:]):
3020
3021         Add helper methods for adding or removing selection assistant suppression reasons. When the last selection
3022         assistant suppression reason is removed, we activate the selection assistant, and conversely, when the first
3023         suppression reason is added, we deactivate the selection assistant.
3024
3025         (-[WKContentView _didConcludeEditDataInteraction:]):
3026         (-[WKContentView _didPerformDragOperation:]):
3027         (-[WKContentView dropInteraction:performDrop:]):
3028         (-[WKContentView suppressAssistantSelectionView]): Deleted.
3029         (-[WKContentView setSuppressAssistantSelectionView:]): Deleted.
3030
3031 2018-11-14  Wenson Hsieh  <wenson_hsieh@apple.com>
3032
3033         [Cocoa] [WebKit2] Hook up some more editing actions (-_pasteAndMatchStyle:, -makeTextWritingDirectionNatural:)
3034         https://bugs.webkit.org/show_bug.cgi?id=191605
3035         <rdar://problem/45813991>
3036
3037         Reviewed by Dean Jackson.
3038
3039         Hook up a couple of editing actions on iOS and macOS. The `-pasteAndMatchStyle:` selector is privately declared
3040         in UIKit, but does not exist on macOS; as such, add `-_pasteAndMatchStyle:` as SPI on WKWebView, and
3041         additionally implement the unprefixed version, `-pasteAndMatchStyle:`, on iOS.
3042
3043         Since `-makeTextWritingDirectionNatural:` is already declared on both iOS and macOS (SPI on UIResponder and API
3044         on macOS, respectively) we simply implement the unprefixed variant on both platforms.
3045
3046         * Platform/spi/ios/UIKitSPI.h:
3047         * UIProcess/API/Cocoa/WKWebView.mm:
3048         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
3049         * UIProcess/ios/WKContentViewInteraction.h:
3050         * UIProcess/ios/WKContentViewInteraction.mm:
3051         (-[WKContentView makeTextWritingDirectionNaturalForWebView:]):
3052         (-[WKContentView canPerformActionForWebView:withSender:]):
3053
3054 2018-11-14  Per Arne Vollan  <pvollan@apple.com>
3055
3056         REGRESSION (WEBPROCESS_WINDOWSERVER_BLOCKING): requestAnimationFrame Stops Completing
3057         https://bugs.webkit.org/show_bug.cgi?id=190884
3058
3059         Reviewed by Dean Jackson.
3060
3061         Since the Web page currently owns the display link on the UI process side, the display link will be
3062         deleted in the UI process when a Web page is closed. This is incorrect, since a display link can be
3063         reused between Web pages in the WebContent process. This patch moves the ownership of the UI process
3064         display links to the Web process object to address this issue. Also, the display ID of the display
3065         being updated is included in the message to the WebContent process.
3066
3067         * UIProcess/WebPageProxy.cpp:
3068         (WebKit::WebPageProxy::close):
3069         (WebKit::WebPageProxy::resetStateAfterProcessExited):
3070         * UIProcess/WebPageProxy.h:
3071         * UIProcess/WebPageProxy.messages.in:
3072         * UIProcess/WebProcessProxy.h:
3073         * UIProcess/WebProcessProxy.messages.in:
3074         * UIProcess/mac/DisplayLink.cpp:
3075         (WebKit::DisplayLink::DisplayLink):
3076         (WebKit::DisplayLink::displayLinkCallback):
3077         * UIProcess/mac/DisplayLink.h:
3078         (WebKit::DisplayLink::displayID const):
3079         * UIProcess/mac/WebPageProxyMac.mm:
3080         (WebKit::WebPageProxy::startDisplayLink): Deleted.
3081         (WebKit::WebPageProxy::stopDisplayLink): Deleted.
3082         * UIProcess/mac/WebProcessProxyMac.mm:
3083         (WebKit::WebProcessProxy::startDisplayLink):
3084         (WebKit::WebProcessProxy::stopDisplayLink):
3085         * WebProcess/WebPage/DrawingArea.h:
3086         * WebProcess/WebPage/DrawingArea.messages.in:
3087         * WebProcess/WebPage/mac/DrawingAreaMac.cpp:
3088         (WebKit::DisplayRefreshMonitorMac::create):
3089         (WebKit::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
3090         (WebKit::DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac):
3091         (WebKit::DisplayRefreshMonitorMac::requestRefreshCallback):
3092         (WebKit::DrawingArea::createDisplayRefreshMonitor):
3093         (WebKit::DrawingArea::displayWasRefreshed): Deleted.
3094         * WebProcess/WebProcess.h:
3095         * WebProcess/WebProcess.messages.in:
3096         * WebProcess/cocoa/WebProcessCocoa.mm:
3097         (WebKit::WebProcess::displayWasRefreshed):
3098
3099 2018-11-14  Chris Dumez  <cdumez@apple.com>
3100
3101         Client should be able to disable PSON even if the experimental feature is on by default
3102         https://bugs.webkit.org/show_bug.cgi?id=191634
3103
3104         Reviewed by Dean Jackson.
3105
3106         Instead of overriding the APIProcessPoolConfiguration's m_processSwapsOnNavigation flag to true
3107         when the experimental is enabled, use a separate flag to store this information. If the client
3108         explicitly sets the APIProcessPoolConfiguration's m_processSwapsOnNavigation flag then we obey
3109         the client's request, otherwise, we fall back to using the state from experimental features.
3110
3111         This allows:
3112         - API tests to explicitely disable PSON / Process prewarming even if those are on by default
3113           in experimental features.
3114         - If the client does not set those flags on the APIProcessPoolConfiguration (Safari for e.g.),
3115           then the experimental feature flag still fully controls the feature.
3116
3117         * UIProcess/API/APIProcessPoolConfiguration.cpp:
3118         (API::ProcessPoolConfiguration::copy):
3119         * UIProcess/API/APIProcessPoolConfiguration.h:
3120         * UIProcess/WebProcessPool.cpp:
3121         (WebKit::WebProcessPool::createWebPage):
3122
3123 2018-11-14  Chris Dumez  <cdumez@apple.com>
3124
3125         WebKit.ApplicationManifestBasic API test is failing when enabling PSON
3126         https://bugs.webkit.org/show_bug.cgi?id=191602
3127
3128         Reviewed by Alex Christensen.
3129
3130         Add support for process swapping for a [WKWebView loadHTML:] load by storing
3131         the necessary data on the API::Navigation and doing a loadData() instead of
3132         a loadRequest() after process swapping when this data is present on the
3133         navigation.
3134
3135         * UIProcess/API/APINavigation.cpp:
3136         (API::Navigation::Navigation):
3137         * UIProcess/API/APINavigation.h:
3138         (API::Navigation::create):
3139         (API::Navigation::substituteData const):
3140         * UIProcess/WebNavigationState.cpp:
3141         (WebKit::WebNavigationState::createLoadDataNavigation):
3142         * UIProcess/WebNavigationState.h:
3143         * UIProcess/WebPageProxy.cpp:
3144         (WebKit::WebPageProxy::loadData):
3145         (WebKit::WebPageProxy::continueNavigationInNewProcess):
3146
3147 2018-11-14  Antti Koivisto  <antti@apple.com>
3148
3149         Align Mac WK2 layer flush throttling with iOS
3150         https://bugs.webkit.org/show_bug.cgi?id=191632
3151
3152         Reviewed by Zalan Bujtas.
3153
3154         Currently Mac WK2 uses WebCore side throttling implementation in RenderLayerCompositor. This code has
3155         throttling timer per-frame while the actual decision making and layer flushes itself are per page. These
3156         timers generate way more flushes than expected in presence of multiple frames. There are also bugs in how
3157         flushing state is updated when frames are created dynamically.
3158
3159         On iOS WK2 throttling is implemented on WebKit side and controlled by a per-page timer. Recent fixes also
3160         make this implementation visually fast. We should align the Mac implementation and eventually unify them.
3161
3162         This patch implements throttling in TiledCoreAnimationDrawingArea mirroring the iOS RemoteLayerTreeDrawingArea
3163         implementation. There are some adjustments for platform differences (local vs remote layers) and we continue
3164         using runloop observer for the actual flushes. Timings are as in the existing Mac code.
3165
3166         The patch appears to be a significant performance progression.
3167
3168         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
3169         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
3170         (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
3171         (WebKit::TiledCoreAnimationDrawingArea::setLayerTreeStateIsFrozen):
3172
3173         Schedule an immediate flush when layers are unfrozen.
3174
3175         (WebKit::TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlush):
3176         (WebKit::TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlushImmediately):
3177
3178         Track pending flushes with m_hasPendingFlush bit.
3179         Delay flush if the flush throttling timer is active. Start it if we throttling but it is not active yet.
3180
3181         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
3182
3183         Clear m_hasPendingFlush if the flush succeeded.
3184         Restart the throttling timer if we are still throttling.
3185         Manage runloop observer invalidation here instead of the caller (and stop returning value).
3186
3187         (WebKit::TiledCoreAnimationDrawingArea::layerFlushRunLoopCallback):
3188         (WebKit::TiledCoreAnimationDrawingArea::adjustLayerFlushThrottling):
3189
3190         Returning 'true' here disables WebCore side throttling code.
3191
3192         Start or stop the throttling timer on state changes.
3193
3194         (WebKit::TiledCoreAnimationDrawingArea::layerFlushThrottlingIsActive const):
3195
3196         This is used to control style and layout timers on WebCore side. Return false on frozen
3197         state since unfreezing depends on style and layout.
3198
3199         (WebKit::TiledCoreAnimationDrawingArea::startLayerFlushThrottlingTimer):
3200         (WebKit::TiledCoreAnimationDrawingArea::layerFlushThrottlingTimerFired):
3201
3202 2018-11-14  Chris Dumez  <cdumez@apple.com>
3203
3204         WebKit.WKHTTPCookieStoreWithoutProcessPool API test is failing with process prewarming is enabled
3205         https://bugs.webkit.org/show_bug.cgi?id=191624
3206
3207         Reviewed by Alex Christensen.
3208
3209         Stop setting the WebProcessPool's primary data store (m_websiteDataStore) to the default one in
3210         WebProcessPool::prewarmProcess(). We did not really need to, we can pass the default data store
3211         to the new WebPageProxy without having to set m_websiteDataStore. m_websiteDataStore only gets
3212         set upon constructor if thr default data store already exists or later on when creating a WebPage
3213         that uses the default data store.
3214
3215         In the case of the API test, the following was happening:
3216         1. Create an ephemeral data store EDS
3217         2. Create a WebView V1 using datastore EDS
3218         3. Do a load in V1
3219         4. Process prewarming would kick in and wrongly associated V1's process pool PP1 with the default data store
3220         5. Create/Get the default datastore and set a few cookies on it
3221         6. Create a WebView V2 using default datastore and a fresh new process pool PP2
3222         7. Do a load in V2 and expect the cookies to be there
3223
3224         In HTTPCookieStore::setCookie() that is called at step 5, we call:
3225         m_owningDataStore->processPoolForCookieStorageOperations()
3226
3227         In this case, m_owningDataStore is the default datastore and this call would previously return null because
3228         there is no WebProcessPool yet associated with the default datastore. However, with the process prewarming
3229         bug at step 4, the process pool PP1 would be returned since it was wrongly associated with the default
3230         data store. As a result, we would call setCookie() on PP1's WebCookieManagerProxy and this would fail
3231         because PP1's network process knows nothing about this session ID (it was only ever used with an ephemeral
3232         session).
3233
3234         * UIProcess/WebProcessPool.cpp:
3235         (WebKit::WebProcessPool::prewarmProcess):
3236
3237 2018-11-13  Jiewen Tan  <jiewen_tan@apple.com>
3238
3239         [WebAuthN] Support CTAP HID authenticators on macOS
3240         https://bugs.webkit.org/show_bug.cgi?id=188623
3241         <rdar://problem/43353777>
3242
3243         Reviewed by Brent Fulgham and Chris Dumez.
3244
3245         This patch introduces a primitive support of CTAP HID authenticators for WebAuthN in macOS.
3246         It involves low level HID device management&communication, high level CTAP HID authenticator
3247         management&communication, and mock testing. The above three aspects will be covered in details:
3248         1) Low level HID device management&communication: HidService&HidConnection
3249         It relies on IOHIDManager to discover appropriate hid devices by passing a matching dictionary:
3250         { PrimaryUsagePage: 0xf1d0, PrimaryUsage: 0x01}. For communication, it utilizes HID reports.
3251         To send a report, it calls IOHIDDeviceSetReport since the async version is not implemented.
3252         To recieve a report, it calls IOHIDDeviceRegisterInputReportCallback to asynchronously wait
3253         for incoming reports.
3254         Here is the corresponding reference:
3255         https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/HID/new_api_10_5/tn2187.html#//apple_ref/doc/uid/TP40000970-CH214-SW2
3256         2) High level CTAP HID authenticator management&communication: HidService&CtapHidDriver
3257         Whenever an appropriate hid device is discovered by IOHIDManager, an AuthenticatorGetInfo command
3258         is sent to the device to determine properties of the authenticator, says, which version of protocol
3259         it supports, i.e. CTAP or U2F. So far, we only support CTAP authenticators. Once the authenticator
3260         is determined to support CTAP, we then instantiate CtapHidAuthenticator which will then take care
3261         of even higher level WebAuthN requests&responses.
3262         Binaries are constructed and packaged according to the CTAP HID porotocol. CtapHidDriver takes care
3263         of concurrency and channels, i.e. allocating channel and establishing the actual request/response
3264         transaction. At the meantime, CtapHidDriver::Worker is then responsible for each single transaction.
3265         Here is the corresponding reference:
3266         https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html#usb.
3267         3) Mock Testing: MockHidService & MockHidConnection
3268         A CTAP hid authenticator is simulated within MockHidConnection with options of specifying specific
3269         error scenarios and of course could take care of successful cases. Four stages are presented in the
3270         simulated authenticator to reflect: a) allocating channel for AuthenticatorGetInfo, b) sending
3271         AuthenticatorGetInfo, c) allocating channel for actual request, and d) sending the actual request.
3272
3273         Besides implementing the above, it also does a few other things:
3274         1) Make AuthenticatorManager::clearState asynchronous to avoid cyclic dependency:
3275         Authenticator::returnResponse => AuthenticatorManager::respondReceived => AuthenticatorManager::clearState
3276         => Authenticator::~Authenticator.
3277         2) Reorganize unified build sources to make it clear that which files are .mm and which are .cpp.
3278         3) Import LocalAuthentication.framework in LocalAuthenticationSoftLink instead of being scattered.
3279
3280         * Sources.txt:
3281         * SourcesCocoa.txt:
3282         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
3283         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
3284         (WKWebsiteDataStoreSetWebAuthenticationMockConfiguration):
3285         * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
3286         (WebKit::AuthenticatorManagerInternal::collectTransports):
3287         (WebKit::AuthenticatorManager::clearStateAsync):
3288         (WebKit::AuthenticatorManager::respondReceived):
3289         (WebKit::AuthenticatorManager::initTimeOutTimer):
3290         * UIProcess/WebAuthentication/AuthenticatorManager.h:
3291         * UIProcess/WebAuthentication/AuthenticatorTransportService.cpp:
3292         (WebKit::AuthenticatorTransportService::create):
3293         (WebKit::AuthenticatorTransportService::createMock):
3294         (WebKit::AuthenticatorTransportService::startDiscovery):
3295         (WebKit::AuthenticatorTransportService::startDiscovery const): Deleted.
3296         * UIProcess/WebAuthentication/AuthenticatorTransportService.h:
3297         * UIProcess/WebAuthentication/Cocoa/HidConnection.h: Copied from Source/WebKit/UIProcess/WebAuthentication/AuthenticatorTransportService.h.
3298         * UIProcess/WebAuthentication/Cocoa/HidConnection.mm: Added.
3299         (WebKit::reportReceived):
3300         (WebKit::HidConnection::HidConnection):
3301         (WebKit::HidConnection::~HidConnection):
3302         (WebKit::HidConnection::initialize):
3303         (WebKit::HidConnection::terminate):
3304         (WebKit::HidConnection::send):
3305         (WebKit::HidConnection::registerDataReceivedCallback):
3306         (WebKit::HidConnection::unregisterDataReceivedCallback):
3307         (WebKit::HidConnection::receiveReport):
3308         (WebKit::HidConnection::consumeReports):
3309         (WebKit::HidConnection::registerDataReceivedCallbackInternal):
3310         * UIProcess/WebAuthentication/Cocoa/HidService.h: Copied from Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalService.h.
3311         * UIProcess/WebAuthentication/Cocoa/HidService.mm: Added.
3312         (WebKit::deviceAddedCallback):
3313         (WebKit::deviceRemovedCallback):
3314         (WebKit::HidService::HidService):
3315         (WebKit::HidService::~HidService):
3316         (WebKit::HidService::startDiscoveryInternal):
3317         (WebKit::HidService::platformStartDiscovery):
3318         (WebKit::HidService::createHidConnection const):
3319         (WebKit::HidService::deviceAdded):
3320         (WebKit::HidService::continueAddDeviceAfterGetInfo):
3321         * UIProcess/WebAuthentication/Cocoa/LocalAuthenticationSoftLink.h:
3322         * UIProcess/WebAuthentication/Cocoa/LocalConnection.mm:
3323         * UIProcess/WebAuthentication/Cocoa/LocalService.h:
3324         * UIProcess/WebAuthentication/Cocoa/LocalService.mm:
3325         (WebKit::LocalService::startDiscoveryInternal):
3326         (WebKit::LocalService::startDiscoveryInternal const): Deleted.
3327         * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp:
3328         (WebKit::MockAuthenticatorManager::respondReceivedInternal):
3329         * UIProcess/WebAuthentication/Mock/MockHidConnection.cpp: Added.
3330         (WebKit::MockHidConnection::MockHidConnection):
3331         (WebKit::MockHidConnection::initialize):
3332         (WebKit::MockHidConnection::terminate):
3333         (WebKit::MockHidConnection::send):
3334         (WebKit::MockHidConnection::registerDataReceivedCallbackInternal):
3335         (WebKit::MockHidConnection::assembleRequest):
3336         (WebKit::MockHidConnection::parseRequest):
3337         (WebKit::MockHidConnection::feedReports):
3338         (WebKit::MockHidConnection::stagesMatch const):
3339         (WebKit::MockHidConnection::shouldContinueFeedReports):
3340         (WebKit::MockHidConnection::continueFeedReports):
3341         * UIProcess/WebAuthentication/Mock/MockHidConnection.h: Copied from Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h.
3342         * UIProcess/WebAuthentication/Mock/MockHidService.cpp: Copied from Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalService.cpp.
3343         (WebKit::MockHidService::MockHidService):
3344         (WebKit::MockHidService::platformStartDiscovery):
3345         (WebKit::MockHidService::createHidConnection const):
3346         * UIProcess/WebAuthentication/Mock/MockHidService.h: Copied from Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h.
3347         * UIProcess/WebAuthentication/Mock/MockLocalConnection.h:
3348         * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
3349         * UIProcess/WebAuthentication/Mock/MockLocalService.mm: Renamed from Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalService.cpp.
3350         (WebKit::MockLocalService::MockLocalService):
3351         (WebKit::MockLocalService::platformStartDiscovery const):
3352         (WebKit::MockLocalService::createLocalConnection const):
3353         * UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h:
3354         * UIProcess/WebAuthentication/fido/CtapHidAuthenticator.cpp: Added.
3355         (WebKit::CtapHidAuthenticator::CtapHidAuthenticator):
3356         (WebKit::CtapHidAuthenticator::makeCredential):
3357         (WebKit::CtapHidAuthenticator::continueMakeCredentialAfterResponseReceived const):
3358         (WebKit::CtapHidAuthenticator::getAssertion):
3359         (WebKit::CtapHidAuthenticator::continueGetAssertionAfterResponseReceived const):
3360         * UIProcess/WebAuthentication/fido/CtapHidAuthenticator.h: Copied from Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalService.h.
3361         * UIProcess/WebAuthentication/fido/CtapHidDriver.cpp: Added.
3362         (WebKit::CtapHidDriver::Worker::Worker):
3363         (WebKit::CtapHidDriver::Worker::~Worker):
3364         (WebKit::CtapHidDriver::Worker::transact):
3365         (WebKit::CtapHidDriver::Worker::write):
3366         (WebKit::CtapHidDriver::Worker::read):
3367         (WebKit::CtapHidDriver::Worker::returnMessage):
3368         (WebKit::CtapHidDriver::CtapHidDriver):
3369         (WebKit::CtapHidDriver::transact):
3370         (WebKit::CtapHidDriver::continueAfterChannelAllocated):
3371         (WebKit::CtapHidDriver::continueAfterResponseReceived):
3372         (WebKit::CtapHidDriver::returnResponse):
3373         * UIProcess/WebAuthentication/fido/CtapHidDriver.h: Added.
3374         * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
3375         * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
3376         * WebKit.xcodeproj/project.pbxproj:
3377
3378 2018-11-13  Ross Kirsling  <ross.kirsling@sony.com>
3379
3380         Unreviewed correction to previous build fix to avoid any internal/downstream repercussions.
3381
3382         * WebProcess/Network/webrtc/LibWebRTCProvider.h:
3383
3384 2018-11-13  Ross Kirsling  <ross.kirsling@sony.com>
3385
3386         Unreviewed GTK/WPE build fix for r238159. 
3387
3388         * WebProcess/Network/webrtc/LibWebRTCProvider.h:
3389
3390 2018-11-13  Timothy Hatcher  <timothy@apple.com>
3391
3392         Use a light scrollbar for transparent web views in dark mode.
3393         https://bugs.webkit.org/show_bug.cgi?id=191559
3394         rdar://problem/46000489
3395
3396         Reviewed by Dean Jackson.
3397
3398         * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
3399         (WebKit::InjectedBundleRangeHandle::renderedImage): Use FrameView's useDarkAppaearance().
3400         * WebProcess/WebPage/WebPage.cpp:
3401         (WebKit::WebPage::drawRect): Ditto.
<