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