REGRESSION (r230843): Flash doesn't work; Produces blue box on page
[WebKit.git] / Source / WebKit / ChangeLog
1 2018-07-05  Youenn Fablet  <youenn@apple.com>
2
3         REGRESSION (r230843): Flash doesn't work; Produces blue box on page
4         https://bugs.webkit.org/show_bug.cgi?id=187346
5         <rdar://problem/41773974>
6
7         Reviewed by Ryosuke Niwa.
8
9         Reset page plugins when the load client policies are updated.
10         This will ensure that pages will rebuild their plugin lists based on the new policies.
11
12         * WebProcess/Plugins/WebPluginInfoProvider.cpp:
13         (WebKit::WebPluginInfoProvider::setPluginLoadClientPolicy):
14         (WebKit::WebPluginInfoProvider::clearPluginClientPolicies):
15
16 2018-07-05  Brady Eidson  <beidson@apple.com>
17
18         IndexedDB operations in a Page fail after a StorageProcess crash.
19         <rdar://problem/41626526> and https://bugs.webkit.org/show_bug.cgi?id=187123
20
21         Reviewed by Alex Christensen.
22
23         When the connection to a StorageProcess goes away, explicitly tell all of the WebPages
24         in the WebProcess about it.
25         
26         This puts Documents/Workers in an error mode where requests fail instead of timeout.
27         It also clears the Page's connection so *new* Documents and Workers will get a fresh 
28         new connection that works.
29         
30         * UIProcess/API/C/WKContext.cpp:
31         (WKContextTerminateStorageProcess):
32         
33         * UIProcess/API/Cocoa/WKProcessPool.mm:
34         (-[WKProcessPool _terminateStorageProcess]):
35         
36         * UIProcess/Storage/StorageProcessProxy.cpp:
37         (WebKit::StorageProcessProxy::terminateForTesting):
38         * UIProcess/Storage/StorageProcessProxy.h:
39         
40         * UIProcess/WebProcessPool.cpp:
41         (WebKit::WebProcessPool::terminateStorageProcessForTesting):
42         (WebKit::WebProcessPool::terminateStorageProcess): Deleted.
43         * UIProcess/WebProcessPool.h:
44         
45         * WebProcess/Storage/WebToStorageProcessConnection.cpp:
46         (WebKit::WebToStorageProcessConnection::didClose):
47         * WebProcess/Storage/WebToStorageProcessConnection.h:
48         (WebKit::WebToStorageProcessConnection::existingIDBConnectionToServerForIdentifier):
49         
50         * WebProcess/WebProcess.cpp:
51         (WebKit::WebProcess::webToStorageProcessConnectionClosed):
52
53 2018-07-05  Simon Fraser  <simon.fraser@apple.com>
54
55         Address two possible causes of missing tiles in iOS Safari, and add logging to gather more data about other possible causes
56         https://bugs.webkit.org/show_bug.cgi?id=187376
57         rdar://problem/40941118
58
59         Reviewed by Tim Horton.
60         
61         We have continual reports of users experiencing missing tiles in MobileSafari, where loading a page
62         shows the tiles at the top, but we don't render new tiles as the user scrolls down. This is consistent
63         with failing to dispatch visible content rect updates via -[WKWebView _updateVisibleContentRects].
64         
65         This patch addresses two possible (but unlikely) causes. First, it resets _currentlyAdjustingScrollViewInsetsForKeyboard
66         after a web process crash. Second, it catches exceptions thrown by [webView _updateVisibleContentRects]
67         and resets _hasScheduledVisibleRectUpdate.
68         
69         This patch also adds release logging that fires if over 1s has elapsed between scheduling
70         a visible content rect update and trying to re-schedule, and logging for all reasons that
71         -_updateVisibleContentRects returns early.
72
73         * UIProcess/API/Cocoa/WKWebView.mm:
74         (-[WKWebView _initializeWithConfiguration:]):
75         (-[WKWebView _processDidExit]):
76         (-[WKWebView _addUpdateVisibleContentRectPreCommitHandler]):
77         (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
78         (-[WKWebView _updateVisibleContentRects]):
79
80 2018-07-05  Olivia Barnett  <obarnett@apple.com>
81
82         iPad: Scrolling with hardware keyboard while SELECT popover is visible scrolls the page, detaches popover
83         https://bugs.webkit.org/show_bug.cgi?id=187363
84         <rdar://problem/41106306>
85
86         Reviewed by Tim Horton.
87
88         Added extra check to prevent keyboard scrolling when the select box is open.
89
90         * UIProcess/ios/WKContentViewInteraction.mm:
91         (-[WKContentView _scrollOffsetForEvent:]):
92
93 2018-07-05  Timothy Hatcher  <timothy@apple.com>
94
95         Rename and flip the meaning of defaultAppearance to be useDarkAppearance.
96         https://bugs.webkit.org/show_bug.cgi?id=187369
97         rdar://problem/41870420
98
99         Reviewed by Tim Horton.
100
101         * Shared/WebPageCreationParameters.cpp:
102         (WebKit::WebPageCreationParameters::encode const):
103         (WebKit::WebPageCreationParameters::decode):
104         * Shared/WebPageCreationParameters.h:
105         * UIProcess/API/Cocoa/WKWebView.mm:
106         (-[WKWebView _effectiveAppearanceIsDark]):
107         (-[WKWebView _initializeWithConfiguration:]):
108         (-[WKWebView _setUseSystemAppearance:]):
109         (-[WKWebView effectiveAppearanceDidChange]):
110         (-[WKWebView _defaultAppearance]): Deleted.
111         * UIProcess/API/mac/WKView.mm:
112         (-[WKView _effectiveAppearanceIsDark]):
113         (-[WKView effectiveAppearanceDidChange]):
114         (-[WKView _setUseSystemAppearance:]):
115         (-[WKView _defaultAppearance]): Deleted.
116         (-[WKView _setDefaultAppearance:]): Deleted.
117         * UIProcess/Cocoa/WebViewImpl.h:
118         * UIProcess/Cocoa/WebViewImpl.mm:
119         (WebKit::WebViewImpl::effectiveAppearanceIsDark):
120         (WebKit::WebViewImpl::setUseDarkAppearance):
121         (WebKit::WebViewImpl::useDefaultAppearance): Deleted.
122         (WebKit::WebViewImpl::setDefaultAppearance): Deleted.
123         * UIProcess/WebPageProxy.cpp:
124         (WebKit::WebPageProxy::creationParameters):
125         (WebKit::WebPageProxy::setUseDarkAppearance):
126         (WebKit::WebPageProxy::showPlaybackTargetPicker):
127         (WebKit::WebPageProxy::setDefaultAppearance): Deleted.
128         * UIProcess/WebPageProxy.h:
129         (WebKit::WebPageProxy::useDarkAppearance const):
130         (WebKit::WebPageProxy::defaultAppearance const): Deleted.
131         * UIProcess/mac/WKPrintingView.mm:
132         (-[WKPrintingView drawRect:]):
133         * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
134         (WebKit::InjectedBundleRangeHandle::renderedImage):
135         * WebProcess/Plugins/PDF/PDFPlugin.mm:
136         (WebKit::PDFPlugin::paintControlForLayerInContext):
137         * WebProcess/WebPage/WebPage.cpp:
138         (WebKit::m_credentialsMessenger):
139         (WebKit::WebPage::drawRect):
140         (WebKit::WebPage::setUseDarkAppearance):
141         (WebKit::WebPage::setDefaultAppearance): Deleted.
142         * WebProcess/WebPage/WebPage.h:
143         * WebProcess/WebPage/WebPage.messages.in:
144
145 2018-07-05  Brian Burg  <bburg@apple.com>
146
147         REGRESSION: ASSERT under WebAutomationSessionProxy::computeElementLayout when elementInViewClientCenterPoint returns nullopt
148         https://bugs.webkit.org/show_bug.cgi?id=187367
149         <rdar://problem/41861346>
150
151         Reviewed by Timothy Hatcher.
152
153         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
154         (WebKit::WebAutomationSessionProxy::computeElementLayout):
155         There's no reason to unwrap this optional, as the IPC argument type is std::optional<IntPoint>.
156
157 2018-07-05  Tim Horton  <timothy_horton@apple.com>
158
159         Upstream hover gesture implementation
160         https://bugs.webkit.org/show_bug.cgi?id=187366
161
162         Reviewed by Wenson Hsieh.
163
164         * UIProcess/ios/WKContentViewInteraction.h:
165         * UIProcess/ios/WKContentViewInteraction.mm:
166         (-[WKContentView setupInteraction]):
167         (-[WKContentView cleanupInteraction]):
168         (-[WKContentView _removeDefaultGestureRecognizers]):
169         (-[WKContentView _addDefaultGestureRecognizers]):
170         (-[WKContentView _hoverGestureRecognizerChanged:]):
171
172 2018-07-05  Tim Horton  <timothy_horton@apple.com>
173
174         Fix some -Wdocumentation warnings in WebKit
175         https://bugs.webkit.org/show_bug.cgi?id=187318
176
177         Reviewed by Dan Bernstein.
178
179         Fix most of the -Wdocumentation warnings in WebKit. The remaining
180         ones are slightly mysterious, so we can't turn the warning on yet.
181
182         * Configurations/BaseTarget.xcconfig:
183         Define U_HIDE_DEPRECATED_API. It's defined in all other WebKit projects,
184         and the doc comments in the deprecated ICU API have some errors.
185
186         * UIProcess/API/Cocoa/WKUIDelegate.h:
187         * UIProcess/API/Cocoa/WKWebView.h:
188         * UIProcess/API/Cocoa/WKWebsiteDataStore.h:
189         Adjust comments or parameter names to be consistent with each other.
190
191 2018-07-05  Chris Dumez  <cdumez@apple.com>
192
193         Regression(r232886): WebsiteDataStore objects may get destroyed on a background thread
194         https://bugs.webkit.org/show_bug.cgi?id=187356
195         <rdar://problem/41854555>
196
197         Reviewed by Geoffrey Garen.
198
199         As of r232886, CallbackAggregators in WebsiteDataStore hold a Ref<> to their WebsiteDataStore. This
200         is an issue because CallbackAggregator objects can get destroyed on a background thread and may be
201         the last ones holding a ref to the data store. When this happens, the WebsiteDataStore would get
202         destroyed on a background store and potentially cause crashes. Note that even if the callback
203         aggregator would not be the last one to hold a ref to the store, it still would not be safe to deref
204         the store on the background thread since WebsiteDataStore is not ThreadSafeRefCounted.
205
206         To address the issue, this patch updates the CallbackAggregators' destructor to deref their data
207         store member on the main thread. Note that we could also have WebsiteDataStore subclass
208         ThreadSafeRefCounted<T, DestructionThread::Main> but the data store technically does not need to
209         be ThreadSafeRefCounted at the moment.
210
211         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
212         (WebKit::WebsiteDataStore::WebsiteDataStore):
213         (WebKit::WebsiteDataStore::~WebsiteDataStore):
214         (WebKit::WebsiteDataStore::fetchDataAndApply):
215         (WebKit::WebsiteDataStore::removeData):
216
217 2018-07-05  Dan Bernstein  <mitz@apple.com>
218
219         [macOS] REGRESSION: Development WebContent service has restricted entitlements, rendering it useless for development
220         https://bugs.webkit.org/show_bug.cgi?id=187355
221
222         Reviewed by Anders Carlsson.
223
224         * Configurations/WebContentService.Development.xcconfig: Set WK_USE_RESTRICTED_ENTITLEMENTS
225           to NO for the Development service.
226
227 2018-07-05  Rob Buis  <rbuis@igalia.com>
228
229         [GTK] Remove soup/DownloadSoupErrors.h
230         https://bugs.webkit.org/show_bug.cgi?id=187339
231
232         This header is not used anymore.
233
234         Reviewed by Frédéric Wang.
235
236         * NetworkProcess/Downloads/soup/DownloadSoupErrors.h: Removed.
237         * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
238         * PlatformGTK.cmake:
239
240 2018-07-04  Carlos Garcia Campos  <cgarcia@igalia.com>
241
242         REGRESSION(r233325): [GTK] Broke 40 animations tests
243         https://bugs.webkit.org/show_bug.cgi?id=187264
244
245         Reviewed by Žan Doberšek.
246
247         Use a different PlatformDisplayID for compositing in the GTK port. This way, when entering AC a window screen
248         changed is emitted and the GTK default display refresh monitor is destroyed, ensuring the one created by the
249         threaded compositor is used.
250
251         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
252         (WebKit::ThreadedCompositor::create): Remove unused WebPage parameter and add PlatformDisplayID.
253         (WebKit::ThreadedCompositor::ThreadedCompositor): Create the display refresh monitor with the given displayID.
254         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
255         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp:
256         (WebKit::ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor): Pass the given displayID to the parent constructor.
257         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h:
258         (WebKit::ThreadedDisplayRefreshMonitor::create): Add PlatformDisplayID parameter.
259         * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
260         (WebKit::ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost): Use compositingDisplayID when
261         creating the threaded compositor and notify about the window screen change.
262         (WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable): Use primaryDisplayID when leaving AC and
263         compositingDisplayID when re-entering.
264
265 2018-07-04  Olivia Barnett  <obarnett@apple.com>
266
267         A WKWebView in a UIViewController that is presented modally and uses a file picker will be incorrectly dismissed by the system
268         https://bugs.webkit.org/show_bug.cgi?id=185257
269         <rdar://problem/40819252>
270
271         Reviewed by Tim Horton.
272
273         Call to dismiss the presented modal was being called on the parent and not the child, which caused the file picker to be incorrectly dismissed along with the modal. A test for this bug-fix could not be completed without additional tools as TestWebKitAPI is not a UI application.
274
275         * UIProcess/ios/forms/WKFileUploadPanel.mm:
276         (-[WKFileUploadPanel _dismissDisplayAnimated:]):
277
278 2018-07-04  Tim Horton  <timothy_horton@apple.com>
279
280         Introduce PLATFORM(IOSMAC)
281         https://bugs.webkit.org/show_bug.cgi?id=187315
282
283         Reviewed by Dan Bernstein.
284
285         * Configurations/Base.xcconfig:
286         * Configurations/FeatureDefines.xcconfig:
287         * Configurations/NetworkService.xcconfig:
288         * Configurations/WebContentService.xcconfig:
289         * Configurations/WebKit.xcconfig:
290         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
291         (WebKit::NetworkProcess::sourceApplicationAuditData const):
292         * NetworkProcess/ios/NetworkProcessIOS.mm:
293         * NetworkProcess/mac/NetworkProcessMac.mm:
294         (WebKit::NetworkProcess::initializeProcessName):
295         (WebKit::overrideSystemProxies):
296         * Platform/mac/LayerHostingContext.mm:
297         (WebKit::LayerHostingContext::createForExternalHostingProcess):
298         * Platform/spi/ios/UIKitSPI.h:
299         * Shared/ios/ChildProcessIOS.mm:
300         (WebKit::ChildProcess::initializeSandbox):
301         * Shared/ios/InteractionInformationAtPosition.h:
302         * Shared/ios/InteractionInformationAtPosition.mm:
303         (WebKit::InteractionInformationAtPosition::encode const):
304         (WebKit::InteractionInformationAtPosition::decode):
305         * Shared/mac/ChildProcessMac.mm:
306         (WebKit::ChildProcess::setApplicationIsDaemon):
307         (WebKit::enableSandboxStyleFileQuarantine):
308         * Shared/mac/CodeSigning.mm:
309         * UIProcess/API/Cocoa/WKWebView.mm:
310         (-[WKWebView _webViewPrintFormatter]):
311         * UIProcess/API/Cocoa/WKWebViewInternal.h:
312         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
313         (WebKit::RemoteLayerTreeHost::updateLayerTree):
314         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
315         (-[WKRemoteView initWithFrame:contextID:]):
316         * UIProcess/_WKWebViewPrintFormatter.mm:
317         * UIProcess/_WKWebViewPrintFormatterInternal.h:
318         * UIProcess/ios/WKContentView.mm:
319         (-[WKContentView _didExitStableState]):
320         * UIProcess/ios/WKContentViewInteraction.mm:
321         (-[WKContentView gestureRecognizer:canBePreventedByGestureRecognizer:]):
322         (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
323         (-[WKContentView canPerformActionForWebView:withSender:]):
324         (-[WKContentView _defineForWebView:]):
325         (-[WKContentView setSelectedTextRange:]):
326         (-[WKContentView closestPositionToPoint:]):
327         (-[WKContentView _updateChangedSelection:]):
328         * UIProcess/ios/WKLegacyPDFView.mm:
329         * UIProcess/ios/WKPDFView.mm:
330         * WebKit.xcodeproj/project.pbxproj:
331         * WebProcess/WebPage/ios/WebPageIOS.mm:
332         (WebKit::WebPage::selectWithGesture):
333         (WebKit::WebPage::getPositionInformation):
334         * WebProcess/cocoa/WebProcessCocoa.mm:
335         (WebKit::WebProcess::initializeSandbox):
336         * config.h:
337
338 2018-07-04  Carlos Garcia Campos  <cgarcia@igalia.com>
339
340         50 failing WebDriver tests after r233417
341         https://bugs.webkit.org/show_bug.cgi?id=187263
342
343         Reviewed by Frédéric Wang.
344
345         A std::optional value is used while being std::nullopt. This is because the wrong input source is used when
346         transitioning keyboard input states.
347
348         * UIProcess/Automation/SimulatedInputDispatcher.cpp:
349         (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
350
351 2018-07-03  Youenn Fablet  <youenn@apple.com>
352
353         Remove quarantine for Webex plugin
354         https://bugs.webkit.org/show_bug.cgi?id=187050
355         rdar://problem/41478189
356
357         Reviewed by Brent Fulgham.
358
359         Update the Plugin Info.plist to not do quarantine of downloaded files by default.
360         Update PluginProcess implementation to reenable quarantine for all plug-ins except cisco webex plug-in.
361
362         * Platform/spi/mac/QuarantineSPI.h: Add qtn_proc_init.
363         * PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist:
364         * PluginProcess/PluginProcess.h:
365         * PluginProcess/mac/PluginProcessMac.mm:
366         (WebKit::PluginProcess::shouldOverrideQuarantine):
367         * Shared/ChildProcess.h:
368         (WebKit::ChildProcess::shouldOverrideQuarantine):
369         * Shared/mac/ChildProcessMac.mm:
370         (WebKit::ChildProcess::initializeSandbox):
371
372 2018-07-03  Youenn Fablet  <youenn@apple.com>
373
374         Crash in  WebKit::CacheStorage::Cache::toRecordInformation when running http/tests/cache-storage/cache-persistency.https.html
375         https://bugs.webkit.org/show_bug.cgi?id=187243
376
377         Reviewed by Chris Dumez.
378
379         In case a caches object has an engine, it uses the engine to get the salt.
380         In case engine/caches are non persistent, no salt was set for the engine, hence the crashes.
381         Add an empty salt whenever initializing a non-persistent engine to remove the crash.
382
383         Covered by updated expectations for two tests.
384
385         * NetworkProcess/cache/CacheStorageEngine.cpp:
386         (WebKit::CacheStorage::Engine::initialize):
387
388 2018-07-03  Youenn Fablet  <youenn@apple.com>
389
390         Fix regression introduced in r233335
391         https://bugs.webkit.org/show_bug.cgi?id=187282
392
393         Reviewed by Chris Dumez.
394
395         When checking for navigation loads, we need to return whether the request URL matches the service worker URL.
396         Before this patch, if the request URL was not matching the service worker URL, we were using the origin/referrer
397         which should only be used for subresource loads.
398
399         Covered by imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https.html
400         being no longer flaky.
401
402         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
403         (WebKit::isValidFetch):
404
405 2018-07-03  Chris Dumez  <cdumez@apple.com>
406
407         Make CallbackMap::invalidate() safe to re-enter
408         https://bugs.webkit.org/show_bug.cgi?id=187298
409         <rdar://problem/41057167>
410
411         Reviewed by Geoffrey Garen.
412
413         Made it safe to re-enter CallbackMap::invalidate(), GenericCallback::performCallbackWithReturnValue(),
414         GenericCallback::invalidate() & invalidateCallbackMap() since those execute client blocks which may
415         re-enter WebKit.
416
417         * UIProcess/GenericCallback.h:
418         (WebKit::GenericCallback::performCallbackWithReturnValue):
419         (WebKit::invalidateCallbackMap):
420
421 2018-07-03  Brent Fulgham  <bfulgham@apple.com>
422
423         [iOS] Clean up sandbox warnings found during Public Beta
424         https://bugs.webkit.org/show_bug.cgi?id=187308
425         <rdar://problem/41203914>
426
427         Reviewed by Eric Carlson.
428
429         I made our sandbox overly restrictive during our iOS 12.0 development cycle, and have found a number of missing items.
430
431         This patch adds the missing IOKit properties, and removes a duplicate call to (play-media).
432
433         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
434
435 2018-07-03  Basuke Suzuki  <Basuke.Suzuki@sony.com>
436
437         [Curl] Embed certificate information into ResourceResponse.
438         https://bugs.webkit.org/show_bug.cgi?id=187102
439
440         Reviewed by Youenn Fablet.
441
442         * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
443         (WebKit::NetworkDataTaskCurl::curlDidComplete):.
444
445 2018-07-03  Simon Fraser  <simon.fraser@apple.com>
446
447         [iOS WK2] We fail to make surfaces volatile when suspending, increasing memory impact
448         https://bugs.webkit.org/show_bug.cgi?id=187285
449         rdar://problem/41732391
450
451         Reviewed by Tim Horton.
452         
453         The "Mach port as layer contents" code path used in iOS WK2 relies on replacing the 
454         Mach port layer contents with the actual IOSurface on suspension (otherwise the
455         live Mach port will keep the surface in use). However, we were never hitting this
456         RemoteLayerTreeHost::mapAllIOSurfaceBackingStore() code path on iOS 11 and later
457         because UIKit stopped firing the notification we relied on.
458         
459         To fix this, use the _UIApplicationDidFinishSuspensionSnapshotNotification notification
460         which is fired on UIApp.
461
462         * Platform/spi/ios/UIKitSPI.h:
463         * UIProcess/ApplicationStateTracker.mm:
464         (WebKit::ApplicationStateTracker::ApplicationStateTracker):
465
466 2018-07-02  Simon Fraser  <simon.fraser@apple.com>
467
468         Clean up the layer volatility code and logging
469         https://bugs.webkit.org/show_bug.cgi?id=187286
470
471         Reviewed by Tim Horton.
472         
473         Fix the layer volatility logging so it doesn't say "succeeded" when it actually failed
474         and gave up.
475         
476         Use a couple of lambda functions in RemoteLayerBackingStore::setBufferVolatility() to
477         make the code easier to read.
478
479         * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
480         * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
481         (WebKit::RemoteLayerBackingStore::setBufferVolatility):
482         * WebProcess/WebPage/WebPage.cpp:
483         (WebKit::WebPage::callVolatilityCompletionHandlers):
484         (WebKit::WebPage::layerVolatilityTimerFired):
485         (WebKit::WebPage::markLayersVolatile):
486         * WebProcess/WebPage/WebPage.h:
487         (WebKit::WebPage::markLayersVolatile):
488         * WebProcess/WebProcess.cpp:
489         (WebKit::WebProcess::actualPrepareToSuspend):
490         (WebKit::WebProcess::markAllLayersVolatile):
491         * WebProcess/WebProcess.h:
492
493 2018-07-03  John Wilander  <wilander@apple.com>
494
495         Resource Load Statistics: Make WebsiteDataStore::getAllStorageAccessEntries() call the right network process instead of iterating over the process pools
496         https://bugs.webkit.org/show_bug.cgi?id=187277
497         <rdar://problem/41745510>
498
499         Reviewed by Chris Dumez.
500
501         Existing tests use this code. The change is for correctness.
502
503         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
504         (-[WKWebsiteDataStore _getAllStorageAccessEntriesFor:completionHandler:]):
505             Now receives a WKWebView from its caller and gets the page ID from it.
506         (-[WKWebsiteDataStore _getAllStorageAccessEntries:]): Deleted.
507         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
508         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
509         (WebKit::WebsiteDataStore::getAllStorageAccessEntries):
510             Now gets a page ID from its caller and gets the right network process
511             through it.
512         * UIProcess/WebsiteData/WebsiteDataStore.h:
513
514 2018-07-03  Jonathan Bedard  <jbedard@apple.com>
515
516         Unreviewed, rolling out r233461.
517
518         Assertions triggered during iOS 11 debug layout and API tests
519
520         Reverted changeset:
521
522         "[iOS] Add assert to catch improper use of WebCore::Timer in
523         UI Process"
524         https://bugs.webkit.org/show_bug.cgi?id=185330
525         https://trac.webkit.org/changeset/233461
526
527 2018-07-03  Youenn Fablet  <youenn@apple.com>
528
529         Update com.cmbchina.CMBSecurity.sb to make it functional
530         https://bugs.webkit.org/show_bug.cgi?id=187278
531
532         Reviewed by Brent Fulgham.
533
534         * Resources/PlugInSandboxProfiles/com.cmbchina.CMBSecurity.sb:
535
536 2018-07-03  Jer Noble  <jer.noble@apple.com>
537
538         Update Fullscreen anti-phishing alert text
539         https://bugs.webkit.org/show_bug.cgi?id=187199
540         <rdar://problem/41162543>
541
542         Reviewed by Brent Fulgham.
543
544         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
545         (-[WKFullScreenViewController _showPhishingAlert]):
546
547 2018-07-03  David Kilzer  <ddkilzer@apple.com>
548
549         [iOS] Add assert to catch improper use of WebCore::Timer in UI Process
550         <https://webkit.org/b/185330>
551         <rdar://problem/32816079>
552
553         Reviewed by Darin Adler.
554
555         * NetworkProcess/NetworkProcess.cpp:
556         (WebKit::NetworkProcess::NetworkProcess):
557         * StorageProcess/StorageProcess.cpp:
558         (WebKit::StorageProcess::StorageProcess):
559         * WebProcess/WebProcess.cpp:
560         (WebKit::m_nonVisibleProcessCleanupTimer):
561         - Call setWebKitProcessType() to se the global for the current
562           process.
563
564 2018-07-03  Frederic Wang  <fred.wang@free.fr>
565
566         [iOS] Animations with Bézier timing function not suspended on UI process when animation-play-state is set to "paused"
567         https://bugs.webkit.org/show_bug.cgi?id=170784
568
569         Reviewed by Antoine Quint.
570
571         In order to pause a running animation, GraphicsLayerCA::pauseCAAnimationOnLayer calls
572         PlatformCALayer::addAnimationForKey, assuming it will replace the current animation.
573         This patch fixes PlatformCALayerRemote::addAnimationForKey to ensure this assumption holds.
574
575         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
576         (WebKit::PlatformCALayerRemote::addAnimationForKey): If the animation was already sent to
577         the UI process, make sure it is properly updated.
578
579 2018-07-02  Youenn Fablet  <youenn@apple.com>
580
581         Add sandbox to microdone plugin
582         https://bugs.webkit.org/show_bug.cgi?id=187149
583         <rdar://problem/41538057>
584
585         Unreviewed.
586
587         * Resources/PlugInSandboxProfiles/cn.microdone.cmb.safari.sb: Renamed from Source/WebKit/Resources/PlugInSandboxProfiles/cn.microdone.cmb.safari.
588         * WebKit.xcodeproj/project.pbxproj:
589
590 2018-07-02  Tim Horton  <timothy_horton@apple.com>
591
592         Adjust now-incorrect animated resize logging after r232544
593         https://bugs.webkit.org/show_bug.cgi?id=187281
594         <rdar://problem/41645347>
595
596         Reviewed by Simon Fraser.
597
598         * UIProcess/API/Cocoa/WKWebView.mm:
599         (-[WKWebView _didCommitLayerTree:]):
600         (-[WKWebView _didCompleteAnimatedResize]):
601         (-[WKWebView _beginAnimatedResizeWithUpdates:]):
602         _beginAnimatedResizeWithUpdate: and _didCompleteAnimatedResize are
603         not strictly paired; we could instead track the SPI, but it's a bit
604         tricky since resizeWithContentHidden has an implicit endAnimatedResize.
605         Instead, just log if we still have a resizeAnimationView when we're
606         committing outside of an animated resize, which seems to be the original concern,
607         and point toward the possibility of unpaired begin/end.
608         Also fix logging that has the wrong method name.
609
610 2018-07-02  Youenn Fablet  <youenn@apple.com>
611
612         Update com.apple.NPSafeInput.sb to make it functional
613         https://bugs.webkit.org/show_bug.cgi?id=187276
614
615         Reviewed by Brent Fulgham.
616
617         * Resources/PlugInSandboxProfiles/com.apple.NPSafeInput.sb:
618
619 2018-07-02  Youenn Fablet  <youenn@apple.com>
620
621         Update com.cfca.npSecEditCtl.MAC.BOC.plugin.sb to make it functional
622         https://bugs.webkit.org/show_bug.cgi?id=187261
623
624         Reviewed by Brent Fulgham.
625
626         * Resources/PlugInSandboxProfiles/com.cfca.npSecEditCtl.MAC.BOC.plugin.sb:
627
628 2018-07-02  Brady Eidson  <beidson@apple.com>
629
630         Crash notifying observers of responsiveness state change
631         <rdar://problem/41267796> and https://bugs.webkit.org/show_bug.cgi?id=187262
632
633         Reviewed by Tim Horton.
634
635         * UIProcess/PageLoadState.cpp:
636         (WebKit::PageLoadState::callObserverCallback): Copy the container ahead of time.
637
638 2018-07-02  Sihui Liu  <sihui_liu@apple.com>
639
640         Remove InitWebCoreThreadSystemInterface() in WKProcessPool _initWithConfiguration
641         https://bugs.webkit.org/show_bug.cgi?id=187252
642
643         Reviewed by Dan Bernstein.
644
645         Clean up after <rdar://problem/15256572>.
646
647         * UIProcess/API/Cocoa/WKProcessGroup.mm:
648         (-[WKProcessGroup initWithInjectedBundleURL:]):
649         * UIProcess/API/Cocoa/WKProcessPool.mm:
650         (-[WKProcessPool _initWithConfiguration:]):
651
652 2018-07-02  Zan Dobersek  <zdobersek@igalia.com>
653
654         REGRESSION(r233381): Double WebResourceLoadStatisticsStore destructor invocation
655         https://bugs.webkit.org/show_bug.cgi?id=187247
656
657         Reviewed by Chris Dumez.
658
659         * UIProcess/WebResourceLoadStatisticsStore.cpp:
660         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
661         Don't call postTask() to dispatch this task, as that keeps a reference
662         to this WebResourceLoadStatisticsStore object and thus causes problems
663         when invoked from the destructor in the form of a second destructor
664         invocation that ends up crashing the process. Blocking nature of this
665         call should be enough to avoid WebResourceLoadStatisticsStore lifetime
666         issues.
667
668 2018-07-02  Per Arne Vollan  <pvollan@apple.com>
669
670         Delete display link when closing page or the WebContent process has crashed.
671         https://bugs.webkit.org/show_bug.cgi?id=186895
672
673         Reviewed by Brent Fulgham.
674
675         If there is a running display link in the UI process, there is no need to keep it around if the
676         page is being closed or the WebContent process has crashed.
677
678         * UIProcess/WebPageProxy.cpp:
679         (WebKit::WebPageProxy::close):
680         (WebKit::WebPageProxy::resetStateAfterProcessExited):
681
682 2018-06-23  Darin Adler  <darin@apple.com>
683
684         [Cocoa] Improve ARC compatibility of more code in JavaScriptCore
685         https://bugs.webkit.org/show_bug.cgi?id=186973
686
687         Reviewed by Dan Bernstein.
688
689         * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
690         (WebKit::XPCServiceInitializerDelegate::hasEntitlement): Use WTF::hasEntitlement.
691
692         * Shared/mac/SandboxUtilities.h: Removed connectedProcessHasEntitlement since
693         we can now use WTF::hasEntitlement instead.
694         * Shared/mac/SandboxUtilities.mm: Ditto.
695
696         * StorageProcess/ios/StorageProcessIOS.mm:
697         (WebKit::StorageProcess::parentProcessHasServiceWorkerEntitlement): Use
698         WTF::hasEntitlement.
699         * WebProcess/WebPage/ios/WebPageIOS.mm:
700         (WebKit::WebPage::parentProcessHasServiceWorkerEntitlement): Ditto.
701
702 2018-06-30  David Kilzer  <ddkilzer@apple.com>
703
704         Fix clang static analyzer warnings: Garbage return value
705         <https://webkit.org/b/187224>
706
707         Reviewed by Eric Carlson.
708
709         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
710         (WebKit::WebPlatformStrategies::changeCount):
711         (WebKit::WebPlatformStrategies::addTypes):
712         (WebKit::WebPlatformStrategies::setTypes):
713         (WebKit::WebPlatformStrategies::setBufferForType):
714         (WebKit::WebPlatformStrategies::setPathnamesForType):
715         (WebKit::WebPlatformStrategies::setStringForType):
716         (WebKit::WebPlatformStrategies::getNumberOfFiles):
717         (WebKit::WebPlatformStrategies::getPasteboardItemsCount):
718         (WebKit::WebPlatformStrategies::writeCustomData):
719         * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
720         (WebKit::WebEditorClient::substitutionsPanelIsShowing):
721         - Use brace initialization for local variables.
722
723 2018-06-30  Michael Catanzaro  <mcatanzaro@igalia.com>
724
725         Unreviewed, add missing PLATFORM(COCOA) guard after r233207
726         https://bugs.webkit.org/show_bug.cgi?id=186788
727         <rdar://problem/41094167>
728
729         * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
730         (WKBundleExtendClassesForParameterCoder):
731
732 2018-06-30  Dan Bernstein  <mitz@apple.com>
733
734         Added a missing availability attribute.
735
736         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h:
737
738 2018-06-29  John Wilander  <wilander@apple.com>
739
740         Resource Load Statistics: Make network process calls only for the process pool that the page belongs to
741         https://bugs.webkit.org/show_bug.cgi?id=187206
742         <rdar://problem/41659160>
743
744         Reviewed by Chris Dumez.
745
746         Instead of iterating over all process pools, we should resolve which
747         process pool the page belongs to and call the network process only for
748         that pool. This is especially important since we use WTFMove for the
749         completion handlers.
750
751         This patch also renames "callback" to "completionHandler" for
752         the functions touched.
753
754         A FIXME comment is added to WebsiteDataStore::getAllStorageAccessEntries()
755         where we currently don't have a page ID to do the lookup with.
756
757         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
758         (WebKit::WebsiteDataStore::updatePrevalentDomainsToPartitionOrBlockCookies):
759         (WebKit::WebsiteDataStore::hasStorageAccessForFrameHandler):
760         (WebKit::WebsiteDataStore::getAllStorageAccessEntries):
761         (WebKit::WebsiteDataStore::grantStorageAccessHandler):
762         (WebKit::WebsiteDataStore::hasStorageAccess):
763         (WebKit::WebsiteDataStore::requestStorageAccess):
764         (WebKit::WebsiteDataStore::grantStorageAccess):
765
766 2018-06-29  Chris Dumez  <cdumez@apple.com>
767
768         Add utility methods to WebResourceLoadStatisticsStore to hop back and forth between threads
769         https://bugs.webkit.org/show_bug.cgi?id=187200
770
771         Reviewed by Brent Fulgham.
772
773         Add utility methods to WebResourceLoadStatisticsStore to hop back and forth between threads,
774         in order the simplify the code a little bit.
775
776         * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
777         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
778         * UIProcess/WebResourceLoadStatisticsStore.cpp:
779         (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
780         (WebKit::WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
781         (WebKit::WebResourceLoadStatisticsStore::setShouldSubmitTelemetry):
782         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
783         (WebKit::WebResourceLoadStatisticsStore::postTask):
784         (WebKit::WebResourceLoadStatisticsStore::postTaskReply):
785         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
786         (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
787         (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
788         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
789         (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess):
790         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
791         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener):
792         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
793         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
794         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
795         (WebKit::WebResourceLoadStatisticsStore::logFrameNavigation):
796         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
797         (WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction):
798         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
799         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
800         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
801         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
802         (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
803         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
804         (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource):
805         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder):
806         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo):
807         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
808         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
809         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
810         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
811         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
812         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
813         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom):
814         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo):
815         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom):
816         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate):
817         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
818         (WebKit::WebResourceLoadStatisticsStore::scheduleClearPartitioningStateForDomains):
819         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningStateReset):
820         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemory):
821         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
822         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
823         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
824         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
825         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
826         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
827         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
828         (WebKit::WebResourceLoadStatisticsStore::resetParametersToDefaultValues):
829         * UIProcess/WebResourceLoadStatisticsStore.h:
830
831 2018-06-29  Aditya Keerthi  <akeerthi@apple.com>
832
833         [macOS] Do not crash if there is an attempt to copy a file URL to the clipboard
834         https://bugs.webkit.org/show_bug.cgi?id=187183
835
836         Reviewed by Wenson Hsieh.
837
838         r210683 introduced logic to prevent file URLs from being copied to the clipboard
839         in unexpected cases. The current logic always crashes the WebProcess if
840         webProcessProxy->checkURLReceivedFromWebProcess returns false. Instead of
841         crashing, we can fail silently and not copy anything to the clipboard.
842
843         * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
844         (WebKit::WebPasteboardProxy::setPasteboardPathnamesForType): Removed call to markCurrentlyDispatchedMessageAsInvalid() which was causing the process to crash.
845
846 2018-06-29  Chris Dumez  <cdumez@apple.com>
847
848         Regression(r233359): Caused ITP tests to be flaky
849         https://bugs.webkit.org/show_bug.cgi?id=187189
850
851         Reviewed by Youenn Fablet.
852
853         r233359 started using m_resolvedConfiguration.resourceLoadStatisticsDirectory instead of
854         m_configuration.resourceLoadStatisticsDirectory for the ITP path. This is consistent
855         with what we do for other database paths so that things like '~' in paths get resolved.
856
857         This introduced flakiness because the resourceLoadStatisticsDirectory was never getting
858         resolved and m_resolvedConfiguration.resourceLoadStatisticsDirectory was not set.
859         Update the WebsiteDataStore so that m_resolvedConfiguration.resourceLoadStatisticsDirectory
860         properly gets set to the resolved version of m_configuration.resourceLoadStatisticsDirectory.
861
862         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
863         (WebKit::WebsiteDataStore::resolveDirectoriesIfNecessary):
864         (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):
865
866 2018-06-29  John Wilander  <wilander@apple.com>
867
868         Resource Load Statistics: Don't create a WebResourceLoadStatisticsStore for ephemeral sessions
869         https://bugs.webkit.org/show_bug.cgi?id=187154
870         <rdar://problem/41487250>
871
872         Reviewed by Brent Fulgham and Chris Dumez.
873
874         Most of the changes in this patch remove the boolean parameter for tracking
875         ephemeral sessions and the IsReadOnly enum.
876
877         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
878         (-[WKWebsiteDataStore _setResourceLoadStatisticsTestingCallback:]):
879             Now returns early for ephemeral sessions.
880         * UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
881         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
882         (WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk):
883         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
884         * UIProcess/ResourceLoadStatisticsPersistentStorage.h:
885         * UIProcess/WebResourceLoadStatisticsStore.cpp:
886         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
887         * UIProcess/WebResourceLoadStatisticsStore.h:
888         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
889         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
890             Now returns early for ephemeral sessions.
891         (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):
892
893 2018-06-29  Chris Dumez  <cdumez@apple.com>
894
895         Stop using lambdas for WebResourceLoadStatisticsStore to interact with its WebsiteDataStore
896         https://bugs.webkit.org/show_bug.cgi?id=187165
897
898         Reviewed by Brent Fulgham.
899
900         Stop using lambdas for WebResourceLoadStatisticsStore to interact with its WebsiteDataStore. Instead,
901         WebResourceLoadStatisticsStore now holds a weak pointer to its WebsiteDataStore and is able to call
902         methods on it directly. Reducing the indirection makes the code less complex and more understandable.
903
904         * UIProcess/WebResourceLoadStatisticsStore.cpp:
905         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
906         (WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler):
907         (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
908         (WebKit::WebResourceLoadStatisticsStore::removeAllStorageAccess):
909         (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToPartitionOrBlockCookiesHandler):
910         (WebKit::WebResourceLoadStatisticsStore::callRemoveDomainsHandler):
911         * UIProcess/WebResourceLoadStatisticsStore.h:
912         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
913         (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):
914
915 2018-06-29  Miguel Gomez  <magomez@igalia.com>
916
917         [WPE] Some frames are dropped when using rAF to animate an element
918         https://bugs.webkit.org/show_bug.cgi?id=187175
919
920         Always call renderNextFrame in ThreadedCompositor::requestDisplayRefreshMonitorUpdate()
921         so we have to process any pending layer flush request.
922
923         Reviewed by Žan Doberšek.
924
925         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
926         (WebKit::ThreadedCompositor::handleDisplayRefreshMonitorUpdate):
927
928 2018-06-28  Chris Dumez  <cdumez@apple.com>
929
930         Make sure the WebResourceLoadStatisticsStore gets destroyed on the main thread
931         https://bugs.webkit.org/show_bug.cgi?id=187143
932
933         Reviewed by Youenn Fablet.
934
935         Have WebResourceLoadStatisticsStore subclass ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main>
936         instead of IPC::Connection::WorkQueueMessageReceiver. This makes sure that the WebResourceLoadStatisticsStore
937         objects get destroyed on the main thread, even if the last ref was held by a background thread.
938
939         Also, methods called by IPC are now called on the main thread instead of the background queue. I think it is clearer for all
940         of WebResourceLoadStatisticsStore usage to be on the main thread. Expensive work is still done on the background queue, inside
941         the persistent / memory store classes.
942
943         * UIProcess/WebResourceLoadStatisticsStore.cpp:
944         (WebKit::WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore):
945         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
946         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
947         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener):
948         (WebKit::WebResourceLoadStatisticsStore::processWillOpenConnection):
949         (WebKit::WebResourceLoadStatisticsStore::processDidCloseConnection):
950         * UIProcess/WebResourceLoadStatisticsStore.h:
951
952 2018-06-28  Jiewen Tan  <jiewen_tan@apple.com>
953
954         Add nullptr check for xpc_connection_t in AuthenticationManager::initializeConnection
955         https://bugs.webkit.org/show_bug.cgi?id=187110
956         <rdar://problem/41536815>
957
958         Reviewed by Brent Fulgham.
959
960         In some rare cases as shown by crash tracers that the passed xpc_connection_t object could be nullptr,
961         and xpc_connection_set_event_handler won't do the nullptr check on its parameters. Therefore, we should
962         do it by ourselves.
963
964         * Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:
965         (WebKit::AuthenticationManager::initializeConnection):
966         * UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm:
967         (WebKit::AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc const):
968
969 2018-06-28  Wenson Hsieh  <wenson_hsieh@apple.com>
970
971         [iOS] DataTransfer.getData always returns the empty string when dropping text
972         https://bugs.webkit.org/show_bug.cgi?id=187130
973         <rdar://problem/41014117>
974
975         Reviewed by Ryosuke Niwa.
976
977         Add plumbing to grab information for each item in the pasteboard. See WebCore ChangeLog for more detail.
978
979         * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
980         (WebKit::WebPasteboardProxy::allPasteboardItemInfo):
981         * UIProcess/WebPasteboardProxy.h:
982         * UIProcess/WebPasteboardProxy.messages.in:
983         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
984         (WebKit::WebPlatformStrategies::allPasteboardItemInfo):
985         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
986
987 2018-06-28  Youenn Fablet  <youenn@apple.com>
988
989         Early return when handling fetch event in case service worker origin does not match origin of a subresource load
990         https://bugs.webkit.org/show_bug.cgi?id=187153
991         <rdar://problem/41329832>
992
993         Reviewed by Chris Dumez.
994
995         Stop crashing the service worker process in case a subresource load origin is not matching a service worker origin.
996         Instead, just return early so that the load will be handled by the network process.
997
998         Keep crashing in case a navigation load is not matching its service worker origin.
999         Add more logging to help with the debugging.
1000
1001         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
1002         (WebKit::logValidFetchError):
1003         (WebKit::isValidFetch):
1004         (WebKit::WebSWContextManagerConnection::startFetch):
1005
1006 2018-06-28  Jeremy Jones  <jeremyj@apple.com>
1007
1008         Fullscreen exits when placeholder is removed then added during a single runloop.
1009         https://bugs.webkit.org/show_bug.cgi?id=187079
1010
1011         Reviewed by Jer Noble.
1012
1013         Instead of closing fullscreen as soon as the placeholder is removed from the view hierarchy,
1014         give the placeholder until the next runloop to be re-added to the view hierarchy.
1015
1016         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
1017         (-[WKFullScreenWindowController placeholderWillMoveToSuperview:]):
1018
1019 2018-06-28  Youenn Fablet  <youenn@apple.com>
1020
1021         Handle the case of registerMDNSNameCallback called several times
1022         https://bugs.webkit.org/show_bug.cgi?id=187150
1023         <rdar://problem/41329832>
1024
1025         Reviewed by Eric Carlson.
1026
1027         This is a speculative fix on the basis that registerMDNSNameCallback may be called several times.
1028         In that case, we would have freed the context after the first call and would reuse it for the second call.
1029
1030         Instead, keep a map of pending requests and pass to registerMDNSNameCallback an identifier to that map.
1031         If the map has no value for that identifier, return early.
1032
1033         * NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
1034         (WebKit::NetworkMDNSRegister::~NetworkMDNSRegister):
1035         (WebKit::pendingRegistrationRequests):
1036         (WebKit::registerMDNSNameCallback):
1037         (WebKit::NetworkMDNSRegister::clearPendingRequests):
1038         (WebKit::NetworkMDNSRegister::registerMDNSName):
1039         * NetworkProcess/webrtc/NetworkMDNSRegister.h:
1040         (): Deleted.
1041
1042 2018-06-28  Chris Dumez  <cdumez@apple.com>
1043
1044         Unreviewed attempt to fix Win Cairo build after r233310.
1045
1046         * UIProcess/WebResourceLoadStatisticsStore.h:
1047
1048 2018-06-28  Chris Dumez  <cdumez@apple.com>
1049
1050         Unreviewed attempt to fix Win Cairo build after r233310.
1051
1052         * UIProcess/WebResourceLoadStatisticsStore.h:
1053
1054 2018-06-28  Chris Dumez  <cdumez@apple.com>
1055
1056         Split memory store logic out of WebResourceLoadStatisticsStore to clarify threading model
1057         https://bugs.webkit.org/show_bug.cgi?id=187055
1058         <rdar://problem/41584026>
1059
1060         Unreviewed, temporarily disable main thread assertion added to flushAndDestroyPersistentStore()
1061         in r233310, until Bug 187143 is fixed.
1062
1063         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1064         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
1065
1066 2018-06-28  Youenn Fablet  <youenn@apple.com>
1067
1068         Add sandbox to microdone plugin
1069         https://bugs.webkit.org/show_bug.cgi?id=187149
1070         rdar://problem/41538057
1071
1072         Reviewed by Brent Fulgham.
1073
1074         * Resources/PlugInSandboxProfiles/cn.microdone.cmb.safari: Added.
1075         * WebKit.xcodeproj/project.pbxproj:
1076
1077 2018-06-28  Brian Burg  <bburg@apple.com>
1078
1079         Web Inspector: REGRESSION(r223770): "Open Link" context menu action on a linkified URL doesn't work
1080         https://bugs.webkit.org/show_bug.cgi?id=187146
1081         <rdar://problem/41369591>
1082
1083         Reviewed by Joseph Pecoraro.
1084
1085         When Web Inspector's page receives a navigation request, it's supposed to redirect any
1086         non-Inspector navigations to be loaded in the inspected page. When I refactored to use
1087         modern a policy delegate, the one line that redirects the loads was left out.
1088
1089         No new tests, because inspector tests can't navigate the inspector or inspected pages.
1090
1091         * UIProcess/mac/WKInspectorViewController.mm:
1092         (-[WKInspectorViewController webView:decidePolicyForNavigationAction:decisionHandler:]):
1093
1094 2018-06-28  Jeremy Jones  <jeremyj@apple.com>
1095
1096         Crash when _topConstraint is null in element fullscreen.
1097         https://bugs.webkit.org/show_bug.cgi?id=187075
1098
1099         Reviewed by Eric Carlson.
1100
1101         NSArray can't contain a null pointer, so check for null before creating an array from a pointer.
1102         Use the recommended +deactivateConstraints: instead of -removeConstraints:.
1103
1104         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
1105         (-[WKFullScreenViewController showUI]):
1106         (-[WKFullScreenViewController hideUI]):
1107
1108 2018-06-28  Chris Dumez  <cdumez@apple.com>
1109
1110         Split memory store logic out of WebResourceLoadStatisticsStore to clarify threading model
1111         https://bugs.webkit.org/show_bug.cgi?id=187055
1112         <rdar://problem/41584026>
1113
1114         Reviewed by Brent Fulgham.
1115
1116         Split memory store logic out of WebResourceLoadStatisticsStore and into a ResourceLoadStatisticsMemoryStore class
1117         to clarify the threading model. Previously, some of the methods of the WebResourceLoadStatisticsStore had to be
1118         called on the main thread and some of them on the background queue, which was confusing and error prone. Now,
1119         all WebResourceLoadStatisticsStore methods (except for IPC ones which will be addressed in a follow-up) are called
1120         on the main thread. The ResourceLoadStatisticsMemoryStore objects is constructed / used and destroyed on the
1121         background queue, similarly to the ResourceLoadStatisticsPersistentStore. The WebResourceLoadStatisticsStore
1122         objects merely proxies calls from WebKit to those persistent / memory stores and takes care of hopping back and
1123         forth between the background thread and the work queue.
1124
1125         While spliting code code, I found several instances where we were calling completion handlers on the wrong thread.
1126         I fixed those in this patch now that the model is clearer.
1127
1128         We can likely clean up (organize the code a bit better) in a follow-up). This patch takes care of splitting the
1129         code as it was. Code that was called on the background queue was moved to ResourceLoadStatisticsMemoryStore class
1130         and code that was called on the main thread stays in WebResourceLoadStatisticsStore.
1131
1132         * CMakeLists.txt:
1133         * UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm: Renamed from Source/WebKit/UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm.
1134         (WebKit::ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded):
1135         * UIProcess/ResourceLoadStatisticsMemoryStore.cpp: Added.
1136         (WebKit::appendWithDelimiter):
1137         (WebKit::OperatingDate::fromWallTime):
1138         (WebKit::OperatingDate::today):
1139         (WebKit::OperatingDate::secondsSinceEpoch const):
1140         (WebKit::OperatingDate::operator== const):
1141         (WebKit::OperatingDate::operator< const):
1142         (WebKit::OperatingDate::operator<= const):
1143         (WebKit::OperatingDate::OperatingDate):
1144         (WebKit::mergeOperatingDates):
1145         (WebKit::pruneResources):
1146         (WebKit::computeImportance):
1147         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
1148         (WebKit::ResourceLoadStatisticsMemoryStore::~ResourceLoadStatisticsMemoryStore):
1149         (WebKit::ResourceLoadStatisticsMemoryStore::setPersistentStorage):
1150         (WebKit::ResourceLoadStatisticsMemoryStore::calculateAndSubmitTelemetry):
1151         (WebKit::ResourceLoadStatisticsMemoryStore::setNotifyPagesWhenDataRecordsWereScanned):
1152         (WebKit::ResourceLoadStatisticsMemoryStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
1153         (WebKit::ResourceLoadStatisticsMemoryStore::setShouldSubmitTelemetry):
1154         (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords):
1155         (WebKit::ResourceLoadStatisticsMemoryStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain):
1156         (WebKit::ResourceLoadStatisticsMemoryStore::markAsPrevalentIfHasRedirectedToPrevalent):
1157         (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords):
1158         (WebKit::ResourceLoadStatisticsMemoryStore::hasStorageAccess):
1159         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
1160         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener):
1161         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccess):
1162         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
1163         (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData):
1164         (WebKit::ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode):
1165         (WebKit::ResourceLoadStatisticsMemoryStore::scheduleStatisticsProcessingRequestIfNecessary):
1166         (WebKit::ResourceLoadStatisticsMemoryStore::cancelPendingStatisticsProcessingRequest):
1167         (WebKit::ResourceLoadStatisticsMemoryStore::logFrameNavigation):
1168         (WebKit::ResourceLoadStatisticsMemoryStore::logUserInteraction):
1169         (WebKit::ResourceLoadStatisticsMemoryStore::logNonRecentUserInteraction):
1170         (WebKit::ResourceLoadStatisticsMemoryStore::clearUserInteraction):
1171         (WebKit::ResourceLoadStatisticsMemoryStore::hasHadUserInteraction):
1172         (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResource):
1173         (WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentResource const):
1174         (WebKit::ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource const):
1175         (WebKit::ResourceLoadStatisticsMemoryStore::isRegisteredAsSubFrameUnder):
1176         (WebKit::ResourceLoadStatisticsMemoryStore::isRegisteredAsRedirectingTo):
1177         (WebKit::ResourceLoadStatisticsMemoryStore::clearPrevalentResource):
1178         (WebKit::ResourceLoadStatisticsMemoryStore::setGrandfathered):
1179         (WebKit::ResourceLoadStatisticsMemoryStore::isGrandfathered const):
1180         (WebKit::ResourceLoadStatisticsMemoryStore::setSubframeUnderTopFrameOrigin):
1181         (WebKit::ResourceLoadStatisticsMemoryStore::setSubresourceUnderTopFrameOrigin):
1182         (WebKit::ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectTo):
1183         (WebKit::ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectFrom):
1184         (WebKit::ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectTo):
1185         (WebKit::ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectFrom):
1186         (WebKit::ResourceLoadStatisticsMemoryStore::setTimeToLiveUserInteraction):
1187         (WebKit::ResourceLoadStatisticsMemoryStore::setTimeToLiveCookiePartitionFree):
1188         (WebKit::ResourceLoadStatisticsMemoryStore::setMinimumTimeBetweenDataRecordsRemoval):
1189         (WebKit::ResourceLoadStatisticsMemoryStore::setGrandfatheringTime):
1190         (WebKit::ResourceLoadStatisticsMemoryStore::shouldRemoveDataRecords const):
1191         (WebKit::ResourceLoadStatisticsMemoryStore::setDataRecordsBeingRemoved):
1192         (WebKit::ResourceLoadStatisticsMemoryStore::ensureResourceStatisticsForPrimaryDomain):
1193         (WebKit::ResourceLoadStatisticsMemoryStore::createEncoderFromData const):
1194         (WebKit::ResourceLoadStatisticsMemoryStore::mergeWithDataFromDecoder):
1195         (WebKit::ResourceLoadStatisticsMemoryStore::clear):
1196         (WebKit::ResourceLoadStatisticsMemoryStore::wasAccessedAsFirstPartyDueToUserInteraction):
1197         (WebKit::ResourceLoadStatisticsMemoryStore::mergeStatistics):
1198         (WebKit::ResourceLoadStatisticsMemoryStore::shouldPartitionCookies):
1199         (WebKit::ResourceLoadStatisticsMemoryStore::shouldBlockCookies):
1200         (WebKit::ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt):
1201         (WebKit::ResourceLoadStatisticsMemoryStore::updateCookiePartitioning):
1202         (WebKit::ResourceLoadStatisticsMemoryStore::updateCookiePartitioningForDomains):
1203         (WebKit::ResourceLoadStatisticsMemoryStore::clearPartitioningStateForDomains):
1204         (WebKit::ResourceLoadStatisticsMemoryStore::resetCookiePartitioningState):
1205         (WebKit::ResourceLoadStatisticsMemoryStore::processStatistics const):
1206         (WebKit::ResourceLoadStatisticsMemoryStore::hasHadUnexpiredRecentUserInteraction const):
1207         (WebKit::ResourceLoadStatisticsMemoryStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
1208         (WebKit::ResourceLoadStatisticsMemoryStore::includeTodayAsOperatingDateIfNecessary):
1209         (WebKit::ResourceLoadStatisticsMemoryStore::hasStatisticsExpired const):
1210         (WebKit::ResourceLoadStatisticsMemoryStore::setMaxStatisticsEntries):
1211         (WebKit::ResourceLoadStatisticsMemoryStore::setPruneEntriesDownTo):
1212         (WebKit::ResourceLoadStatisticsMemoryStore::pruneStatisticsIfNeeded):
1213         (WebKit::ResourceLoadStatisticsMemoryStore::resetParametersToDefaultValues):
1214         (WebKit::ResourceLoadStatisticsMemoryStore::logTestingEvent):
1215         (WebKit::ResourceLoadStatisticsMemoryStore::setLastSeen):
1216         (WebKit::ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource):
1217         (WebKit::ResourceLoadStatisticsMemoryStore::removeAllStorageAccess):
1218         * UIProcess/ResourceLoadStatisticsMemoryStore.h: Added.
1219         (WebKit::ResourceLoadStatisticsMemoryStore::isEmpty const):
1220         (WebKit::ResourceLoadStatisticsMemoryStore::setStorageAccessPromptsEnabled):
1221         (WebKit::ResourceLoadStatisticsMemoryStore::setDebugLogggingEnabled):
1222         * UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
1223         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
1224         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk):
1225         (WebKit::ResourceLoadStatisticsPersistentStorage::monitorDirectoryForNewStatistics):
1226         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
1227         * UIProcess/ResourceLoadStatisticsPersistentStorage.h:
1228         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1229         (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
1230         (WebKit::WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
1231         (WebKit::WebResourceLoadStatisticsStore::setShouldSubmitTelemetry):
1232         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1233         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
1234         (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
1235         (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
1236         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
1237         (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess):
1238         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
1239         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener):
1240         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
1241         (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
1242         (WebKit::WebResourceLoadStatisticsStore::removeAllStorageAccess):
1243         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
1244         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
1245         (WebKit::WebResourceLoadStatisticsStore::logFrameNavigation):
1246         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
1247         (WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction):
1248         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
1249         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
1250         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
1251         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
1252         (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
1253         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
1254         (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource):
1255         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder):
1256         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo):
1257         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
1258         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
1259         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
1260         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
1261         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
1262         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
1263         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom):
1264         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo):
1265         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom):
1266         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate):
1267         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
1268         (WebKit::WebResourceLoadStatisticsStore::scheduleClearPartitioningStateForDomains):
1269         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningStateReset):
1270         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemory):
1271         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
1272         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1273         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
1274         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
1275         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
1276         (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToPartitionOrBlockCookiesHandler):
1277         (WebKit::WebResourceLoadStatisticsStore::callRemoveDomainsHandler):
1278         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
1279         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
1280         (WebKit::WebResourceLoadStatisticsStore::resetParametersToDefaultValues):
1281         (WebKit::WebResourceLoadStatisticsStore::logTestingEvent):
1282         * UIProcess/WebResourceLoadStatisticsStore.h:
1283         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
1284         (WebKit::sortedPrevalentResourceTelemetry):
1285         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
1286         * UIProcess/WebResourceLoadStatisticsTelemetry.h:
1287         * WebKit.xcodeproj/project.pbxproj:
1288
1289 2018-06-28  Michael Catanzaro  <mcatanzaro@igalia.com>
1290
1291         [GTK] ASSERTION FAILED: !HashTranslator::equal(KeyTraits::emptyValue(), key) when dragging file into webview
1292         https://bugs.webkit.org/show_bug.cgi?id=175602
1293
1294         Reviewed by Carlos Garcia Campos.
1295
1296         We check using the GdkDragContext to ensure the DroppingContext is still alive (present in
1297         m_droppingContexts), but access it via the pointer to the DroppingContext that could be
1298         dangling. This happens on every drag. I can't actually reproduce the original assertion
1299         since I'm currently working with an asan build, but I imagine it's probably the same issue
1300         that I'm fixing here.
1301
1302         * UIProcess/gtk/DragAndDropHandler.cpp:
1303         (WebKit::DragAndDropHandler::dragLeave):
1304
1305 2018-06-27  Timothy Hatcher  <timothy@apple.com>
1306
1307         Don't expose new semantic -apple-system color keywords on iOS.
1308         https://bugs.webkit.org/show_bug.cgi?id=187080
1309         rdar://problem/41505699
1310
1311         Reviewed by Tim Horton.
1312
1313         * DerivedSources.make: Use gnu++14, since gnu++17 is giving errors on macOS 10.12.
1314
1315 2018-06-27  Megan Gardner  <megan_gardner@apple.com>
1316
1317         Fix IBeam issues with iPad apps on Mac
1318         https://bugs.webkit.org/show_bug.cgi?id=186900
1319
1320         Reviewed by Wenson Hsieh.
1321
1322         * Shared/ios/InteractionInformationAtPosition.h:
1323         * Shared/ios/InteractionInformationAtPosition.mm:
1324         (WebKit::InteractionInformationAtPosition::encode const):
1325         (WebKit::InteractionInformationAtPosition::decode):
1326
1327         Add functionality to determine what a caret rect should be, but as it is
1328         expensive, it should only be done for this platform.
1329         
1330         * Shared/ios/InteractionInformationRequest.cpp:
1331         (WebKit::InteractionInformationRequest::isApproximateForRequest):
1332         * Shared/ios/InteractionInformationRequest.h:
1333
1334         As there is no way to premptively request information on hover, we need to use 
1335         the last cached information, but only if it is close to the point we are about
1336         to request information for. So having a way to determine if a point is very close
1337         to a previous point is a good idea.
1338
1339         * UIProcess/ios/WKContentViewInteraction.mm:
1340         (-[WKContentView _currentPositionInformationIsApproximateForRequest:]):
1341         (-[WKContentView closestPositionToPoint:]):
1342
1343         UIKit is using this function to determine if we should show an Ibeam or not.
1344         So we need to implement it, at least for this platform. 
1345
1346         * WebProcess/WebPage/ios/WebPageIOS.mm:
1347         (WebKit::WebPage::getPositionInformation):
1348
1349         Pass up the calculated caret rect, but only for iPad apps on Mac.
1350
1351 2018-06-27  Yusuke Suzuki  <utatane.tea@gmail.com>
1352
1353         [GTK][WPE] Use LazyNeverDestroyed<XErrorTrapper> to remove static initializers
1354         https://bugs.webkit.org/show_bug.cgi?id=187089
1355
1356         Reviewed by Michael Catanzaro.
1357
1358         Use LazyNeverDestroyed<XErrorTrapper> instead of global std::unique_ptr<XErrorTrapper>.
1359         Since this variable's exit time destructor is not important in this code, using
1360         LazyNeverDestroyed<XErrorTrapper> is fine. This removes the last static initializer
1361         of libwebkit2gtk.so.
1362
1363         * PluginProcess/unix/PluginProcessMainUnix.cpp:
1364
1365 2018-06-27  Youenn Fablet  <youenn@apple.com>
1366
1367         Add a sandbox profile for some additional bank plugins
1368         https://bugs.webkit.org/show_bug.cgi?id=187105
1369
1370         Reviewed by Brent Fulgham.
1371
1372         * Resources/PlugInSandboxProfiles/cfca.com.npCryptoKit.CGB.MAC.sb: Added.
1373         * Resources/PlugInSandboxProfiles/cfca.com.npP11CertEnroll.MAC.CGB.sb: Added.
1374         * Resources/PlugInSandboxProfiles/com.apple.BocomSubmitCtrl.sb: Added.
1375         * Resources/PlugInSandboxProfiles/com.apple.NPSafeInput.sb: Added.
1376         * Resources/PlugInSandboxProfiles/com.apple.NPSafeSubmit.sb: Added.
1377         * Resources/PlugInSandboxProfiles/com.cfca.npSecEditCtl.MAC.BOC.plugin.sb: Added.
1378         * Resources/PlugInSandboxProfiles/com.cmbchina.CMBSecurity.sb: Added.
1379         * Resources/PlugInSandboxProfiles/com.ftsafe.NPAPI-Core-Safe-SoftKeybaord.plugin.rfc1034identifier.sb: Added.
1380         * WebKit.xcodeproj/project.pbxproj:
1381
1382 2018-06-27  Youenn Fablet  <youenn@apple.com>
1383
1384         NetworkLoadChecker should not need to hard ref NetworkConnectionToWebProcess
1385         https://bugs.webkit.org/show_bug.cgi?id=186551
1386
1387         Reviewed by Daniel Bates.
1388
1389         Removed the need for NetworkLoadChecker to reference a NetworkConnectionToWebProcess.
1390         Instead a CSP client is given to NetworkLoadChecker when needed.
1391
1392         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
1393         (WebKit::NetworkConnectionToWebProcess::loadPing):
1394         * NetworkProcess/NetworkLoadChecker.cpp:
1395         (WebKit::NetworkLoadChecker::NetworkLoadChecker):
1396         (WebKit::NetworkLoadChecker::check):
1397         (WebKit::NetworkLoadChecker::checkRedirection):
1398         (WebKit::NetworkLoadChecker::checkRequest):
1399         (WebKit::NetworkLoadChecker::contentSecurityPolicy):
1400         (WebKit::NetworkLoadChecker::addConsoleMessage): Deleted.
1401         (WebKit::NetworkLoadChecker::sendCSPViolationReport): Deleted.
1402         (WebKit::NetworkLoadChecker::enqueueSecurityPolicyViolationEvent): Deleted.
1403         * NetworkProcess/NetworkLoadChecker.h:
1404         * NetworkProcess/NetworkResourceLoader.cpp:
1405         (WebKit::NetworkResourceLoader::start):
1406         (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
1407         * NetworkProcess/PingLoad.cpp:
1408         (WebKit::PingLoad::PingLoad):
1409         (WebKit::PingLoad::willPerformHTTPRedirection):
1410         * NetworkProcess/PingLoad.h:
1411
1412 2018-06-27  Stephan Szabo  <stephan.szabo@sony.com>
1413
1414         [Wincairo] Add support for context menus to non-legacy minibrowser
1415         https://bugs.webkit.org/show_bug.cgi?id=186815.
1416
1417         Reviewed by Ryosuke Niwa.
1418
1419         * UIProcess/WebPageProxy.h:
1420         * UIProcess/win/PageClientImpl.cpp:
1421         (WebKit::PageClientImpl::viewWidget):
1422         * UIProcess/win/PageClientImpl.h:
1423         * UIProcess/win/WebContextMenuProxyWin.cpp:
1424         (WebKit::WebContextMenuProxyWin::show):
1425         (WebKit::createMenu):
1426         (WebKit::createMenuItem):
1427         (WebKit::populate):
1428         (WebKit::WebContextMenuProxyWin::showContextMenuWithItems):
1429         (WebKit::WebContextMenuProxyWin::WebContextMenuProxyWin):
1430         (WebKit::WebContextMenuProxyWin::~WebContextMenuProxyWin):
1431         * UIProcess/win/WebContextMenuProxyWin.h:
1432         * UIProcess/win/WebPageProxyWin.cpp:
1433         (WebKit::WebPageProxy::viewWidget):
1434         * UIProcess/win/WebView.cpp:
1435         (WebKit::WebView::wndProc):
1436         (WebKit::WebView::onMenuCommand):
1437         * UIProcess/win/WebView.h:
1438
1439 2018-06-27  Youenn Fablet  <youenn@apple.com>
1440
1441         Disable content blockers in NetworkLoadChecker except for ping loads
1442         https://bugs.webkit.org/show_bug.cgi?id=187083
1443         <rdar://problem/41440083>
1444
1445         Reviewed by Chris Dumez.
1446
1447         * NetworkProcess/NetworkLoadChecker.cpp:
1448         (WebKit::NetworkLoadChecker::processContentExtensionRulesForLoad):
1449         * NetworkProcess/NetworkLoadChecker.h:
1450         (WebKit::NetworkLoadChecker::enableContentExtensionsCheck):
1451         * NetworkProcess/PingLoad.cpp:
1452
1453 2018-06-27  Simon Fraser  <simon.fraser@apple.com>
1454
1455         https://hackernoon.com/ uses lots of layer backing store
1456         https://bugs.webkit.org/show_bug.cgi?id=186909
1457         rdar://problem/40257540
1458
1459         Reviewed by Tim Horton.
1460         
1461         PlatformCALayerRemote was actually holding onto backing stores for layers with
1462         backing store detached, which could increase memory use. When told that backing stores
1463         are not attached, explicitly throw away the backing, and re-create it (via setNeedsDisplay)
1464         when attached. This is now similar to what PlatformLayerCACocoa does.
1465
1466         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
1467         (WebKit::PlatformCALayerRemote::setNeedsDisplayInRect):
1468         (WebKit::PlatformCALayerRemote::setNeedsDisplay):
1469         (WebKit::PlatformCALayerRemote::hasContents const):
1470         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
1471
1472 2018-06-27  Jonathan Bedard  <jbedard@apple.com>
1473
1474         Enable WebKit iOS 12 build
1475         https://bugs.webkit.org/show_bug.cgi?id=187024
1476         <rdar://problem/39759057>
1477
1478         Reviewed by David Kilzer.
1479
1480         * Platform/spi/ios/PDFKitSPI.h: Added PDFKit SPI.
1481         * Platform/spi/ios/UIKitSPI.h: Add new UIKit SPI and UICompositingMode enumeration.
1482         * UIProcess/ios/WKPDFView.mm: Use PDFKitSPI header.
1483         * UIProcess/ios/WKSystemPreviewView.mm: Use CoreGraphicsSPI.h.
1484         * UIProcess/ios/fullscreen/WKFullscreenStackView.mm: Use QuartzCoreSPI.h.
1485
1486 2018-06-27  Timothy Horton  <timothy_horton@apple.com>
1487
1488         CSS Animation Triggers is not an experimental feature, should be globally off by default
1489
1490         Reviewed by Dean Jackson.
1491
1492         * Shared/WebPreferences.yaml:
1493
1494 2018-06-27  Timothy Horton  <timothy_horton@apple.com>
1495
1496         Promote the Secure Context API feature from experimental-yet-on-by-default to always-on
1497
1498         Reviewed by Dan Bates.
1499
1500         * Shared/WebPreferences.yaml:
1501         Secure Context API is on by default, it's not experimental anymore.
1502
1503 2018-06-27  Timothy Horton  <timothy_horton@apple.com>
1504
1505         Make Link Preload an on-by-default feature
1506         https://bugs.webkit.org/show_bug.cgi?id=187104
1507
1508         Reviewed by Ryosuke Niwa.
1509
1510         * Shared/WebPreferences.yaml:
1511         This should be on, not experimental. It already shipped on in the past.
1512
1513 2018-06-27  Chris Dumez  <cdumez@apple.com>
1514
1515         Regression(r233208): Completion handler does not get called on GTK port
1516         https://bugs.webkit.org/show_bug.cgi?id=187099
1517
1518         Reviewed by Antti Koivisto.
1519
1520         Make sure UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler's completion handler
1521         gets called on non-COCOA ports.
1522
1523         * UIProcess/WebResourceLoadStatisticsStore.h:
1524
1525 2018-06-27  Tim Horton  <timothy_horton@apple.com>
1526
1527         When trying to print a very long email on iOS, the print preview is blank
1528         https://bugs.webkit.org/show_bug.cgi?id=187077
1529         <rdar://problem/41107013>
1530
1531         Reviewed by Timothy Hatcher.
1532
1533         * UIProcess/ios/WebPageProxyIOS.mm:
1534         (WebKit::WebPageProxy::computePagesForPrintingAndDrawToPDF):
1535         ChildProcessProxy::sendSync has a (surprising) default timeout of 1 second,
1536         (as opposed to Connection::sendSync's default timeout of ∞ seconds).
1537         The printing path already waits ∞ seconds for the final PDF, but currently
1538         uses the default 1 second timeout for page count computation. If page
1539         count computation takes more than 1 second, the preview will be blank.
1540         Since the print preview is generated asynchronously, we really want
1541         to wait until it's done, and not give up after 1 second.
1542
1543 2018-06-26  Wenson Hsieh  <wenson_hsieh@apple.com>
1544
1545         [iPad apps on macOS] Unable to interact with video elements that have started playing
1546         https://bugs.webkit.org/show_bug.cgi?id=187073
1547         <rdar://problem/40591107>
1548
1549         Reviewed by Tim Horton.
1550
1551         On iOS, we currently force remote hosting contexts to be non-interactive by passing in `kCAContextIgnoresHitTest`
1552         when creating the CAContext. However, this flag is not respected by CoreAnimation when running iOS apps on macOS.
1553         This means all HID events dispatched over a video that has been played (which causes WebKit to insert a
1554         CALayerHost-backed WKRemoteView in the view hierarchy) will be routed to the context ID of the video's CAContext
1555         rather than the context ID of the key window containing the WKWebView.
1556
1557         This subsequently causes all gesture recognizers (hover, touch, tap, long press) to fail recognition when
1558         running iOS apps on macOS. To address this, we set a flag on WKRemoteView's CALayerHost to prevent hit-testing
1559         to the remote layer. This allows us to avoid routing HID events to the wrong context, and instead target the
1560         main UIWindow.
1561
1562         Manually verified that click, touch, and mouseenter/mouseleave events are dispatched when interacting over a
1563         video element.
1564
1565         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
1566         (-[WKRemoteView initWithFrame:contextID:]):
1567
1568 2018-06-26  Commit Queue  <commit-queue@webkit.org>
1569
1570         Unreviewed, rolling out r233232.
1571         https://bugs.webkit.org/show_bug.cgi?id=187081
1572
1573         "This is breaking launching some plugins" (Requested by youenn
1574         on #webkit).
1575
1576         Reverted changeset:
1577
1578         "Remove quarantine for Webex plugin"
1579         https://bugs.webkit.org/show_bug.cgi?id=187050
1580         https://trac.webkit.org/changeset/233232
1581
1582 2018-06-26  Timothy Horton  <timothy_horton@apple.com>
1583
1584         Rearrange some WebPreferences; move two experimental prefs into the experimental section
1585
1586         * Shared/WebPreferences.yaml:
1587
1588 2018-06-26  Chris Dumez  <cdumez@apple.com>
1589
1590         Deal better with the network process crashing on startup
1591         https://bugs.webkit.org/show_bug.cgi?id=187065
1592         <rdar://problem/41451622>
1593
1594         Reviewed by Geoffrey Garen.
1595
1596         When a network process crashes on startup, we would not attempt to relaunch it. If there were web
1597         processes waiting for a connection to this network process, we would send them an invalid connection
1598         identifier which would cause them to forcefully crash.
1599
1600         Instead, we now apply the same policy whether a network process crashes on startup or later:
1601         - We attempt to relaunch the network process
1602         - If there were pending connections from WebContent processes, we ask the new Network process instead.
1603
1604         As a result, WebContent processes no longer crash in this case. Instead, they wait for a valid
1605         connection to the network process.
1606
1607         * UIProcess/API/Cocoa/WKProcessPool.mm:
1608         (-[WKProcessPool _makeNextNetworkProcessLaunchFailForTesting]):
1609         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
1610         * UIProcess/Network/NetworkProcessProxy.cpp:
1611         (WebKit::NetworkProcessProxy::getLaunchOptions):
1612         (WebKit::NetworkProcessProxy::didFinishLaunching):
1613         * UIProcess/Network/NetworkProcessProxy.h:
1614         * UIProcess/WebProcessPool.cpp:
1615         (WebKit::WebProcessPool::networkProcessCrashed):
1616         * UIProcess/WebProcessPool.h:
1617
1618 2018-06-26  Daniel Bates  <dabates@apple.com>
1619
1620         REGRESSION (r231479): Unable to buy Odeon cinema tickets in STP (bogus 'X-Frame-Options' to 'SAMEORIGIN')
1621         https://bugs.webkit.org/show_bug.cgi?id=186090
1622         <rdar://problem/40692595>
1623
1624         Reviewed by Andy Estes.
1625
1626         Fixes an issue where a page P delivered with "X-Frame-Options: SAMEORIGIN" loaded in a sub-
1627         frame would be blocked if we were redirected to it in response to the cross-origin POST
1628         request regardless of whether P is same-origin with its parent document.
1629
1630         * NetworkProcess/NetworkResourceLoader.cpp:
1631         (WebKit::NetworkResourceLoader::shouldInterruptLoadForXFrameOptions): Compare the origin
1632         of the top frame's document as opposed to the source origin. The latter represents the
1633         origin of the document that initiated the navigation, which can be cross-origin, and
1634         should not be considered when applying "X-Frame-Options: SAMEORIGIN". This check exists
1635         as a performance optimization to avoid traversing over all frame ancestors only to find
1636         out that the innermost frame (the one that made this request) is cross-origin with the
1637         top-most frame.
1638         * NetworkProcess/NetworkResourceLoader.h:
1639         * WebProcess/Network/WebLoaderStrategy.cpp:
1640         (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): Exclude the origin of the
1641         frame that is making the load request from the list of ancestor origins. This makes the
1642         X-Frame-Options algorithm in WebKit2 match the logic we do in FrameLoader::shouldInterruptLoadForXFrameOptions().
1643
1644 2018-06-26  Youenn Fablet  <youenn@apple.com>
1645
1646         Remove quarantine for Webex plugin
1647         https://bugs.webkit.org/show_bug.cgi?id=187050
1648         rdar://problem/41478189
1649
1650         Reviewed by Brent Fulgham.
1651
1652         Update the Plugin Info.plist to not do quarantine of downloaded files by default.
1653         Update PluginProcess implementation to reenable quarantine for all plug-ins except cisco webex plug-in.
1654
1655         * PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist:
1656         * PluginProcess/PluginProcess.h:
1657         * PluginProcess/mac/PluginProcessMac.mm:
1658         (WebKit::PluginProcess::shouldOverrideQuarantine):
1659         * Shared/ChildProcess.h:
1660         (WebKit::ChildProcess::shouldOverrideQuarantine):
1661         * Shared/mac/ChildProcessMac.mm:
1662         (WebKit::ChildProcess::initializeSandbox):
1663
1664 2018-06-26  Jeremy Jones  <jeremyj@apple.com>
1665
1666         Ensure element fullscreen animation is always visible.
1667         https://bugs.webkit.org/show_bug.cgi?id=187068
1668         rdar://problem/36187369
1669
1670         Reviewed by Eric Carlson.
1671
1672         The fullscreen animation is important for communicating to users that they are no longer in inline mode.
1673         If fullscreen animation's inline rect is not visible, animate from a point in the middle of the screen.
1674
1675         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
1676         (WebKit::safeInlineRect):
1677         (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]):
1678         (-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]):
1679
1680 2018-06-26  Youenn Fablet  <youenn@apple.com>
1681
1682         Add a sandbox profile for com.google.o1dbrowserplugin plugin
1683         https://bugs.webkit.org/show_bug.cgi?id=187067
1684
1685         Reviewed by Brent Fulgham.
1686
1687         * Resources/PlugInSandboxProfiles/com.google.o1dbrowserplugin.sb: Added.
1688         * WebKit.xcodeproj/project.pbxproj:
1689
1690 2018-06-26  Tim Horton  <timothy_horton@apple.com>
1691
1692         Promote two more experimental features to traditional features
1693         https://bugs.webkit.org/show_bug.cgi?id=187063
1694
1695         Reviewed by Dean Jackson.
1696
1697         * Shared/WebPreferences.yaml:
1698         Promote some shipped/default-on features to non-experimental.
1699
1700 2018-06-26  Jiewen Tan  <jiewen_tan@apple.com>
1701
1702         Rollout macOS sandbox change in r232276
1703         https://bugs.webkit.org/show_bug.cgi?id=186904
1704         <rdar://problem/41350969>
1705
1706         Reviewed by Brent Fulgham.
1707
1708         * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
1709
1710 2018-06-26  Aditya Keerthi  <akeerthi@apple.com>
1711
1712         Tap highlight displayed when tapping a field that is already focussed
1713         https://bugs.webkit.org/show_bug.cgi?id=187004
1714         <rdar://problem/41428008>
1715         Reviewed by Tim Horton.
1716
1717         In the case where fast-clicking is enabled, _singleTapCommited: could be invoked
1718         before the tap highlight request, causing _potentialTapInProgress to be set to NO.
1719         This results in the early return for preventing multiple tap highlights on an
1720         assisted node to be skipped. Since a tap highlight should never be shown for an
1721         input field that is already focussed, _potentialTapInProgress can be removed from
1722         the early return condition.
1723
1724         * UIProcess/ios/WKContentViewInteraction.mm:
1725         (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]):
1726
1727 2018-06-26  Timothy Horton  <timothy_horton@apple.com>
1728
1729         Rearrange some WebPreferences; move two non-experimental prefs out of the experimental section
1730
1731         * Shared/WebPreferences.yaml:
1732
1733 2018-06-26  Tim Horton  <timothy_horton@apple.com>
1734
1735         Promote some experimental features to traditional features
1736         https://bugs.webkit.org/show_bug.cgi?id=187047
1737
1738         Reviewed by Simon Fraser.
1739
1740         * Shared/WebPreferences.yaml:
1741         Reindent.
1742         Promote some shipped/default-on features to non-experimental.
1743
1744 2018-06-26  Eric Carlson  <eric.carlson@apple.com>
1745
1746         [Mac] AirPlay picker uses incorrect theme in Dark mode
1747         https://bugs.webkit.org/show_bug.cgi?id=187054
1748         <rdar://problem/41291093>
1749
1750         Reviewed by Timothy Hatcher.
1751
1752         * UIProcess/WebPageProxy.cpp:
1753         (WebKit::WebPageProxy::showPlaybackTargetPicker): Pass m_defaultAppearance.
1754
1755 2018-06-26  Chris Dumez  <cdumez@apple.com>
1756
1757         Resource Load Statistics: Make WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains() wait for the network process before calling its callback
1758         https://bugs.webkit.org/show_bug.cgi?id=186903
1759         <rdar://problem/41350182>
1760
1761         Reviewed by Brady Eidson.
1762
1763         Follow-up fix after r233180 to address an API test crash. We need to keep the
1764         NetworkProcessProxy alive during the async updatePrevalentDomainsToPartitionOrBlockCookies
1765         request to make sure it completes.
1766
1767         * UIProcess/Network/NetworkProcessProxy.cpp:
1768         (WebKit::NetworkProcessProxy::updatePrevalentDomainsToPartitionOrBlockCookies):
1769
1770 2018-06-26  Brent Fulgham  <bfulgham@apple.com>
1771
1772         Provide a way for Injected Bundles to indicate classes approved for NSSecureCoding
1773         https://bugs.webkit.org/show_bug.cgi?id=186788
1774         <rdar://problem/41094167>
1775
1776         Reviewed by Chris Dumez.
1777
1778         InjectedBundles support a mechanism to serialize data between the UIProcess and the
1779         WebContent process hosting the bundle. In some cases, we want to be able to serialize
1780         a custom data object that is not part of WebKit's native data types.
1781
1782         After switching to strict NSSecureCoding, WebKit clients attempting to serialize these
1783         custom objects trigger a failure.
1784
1785         This patch makes it possible for the InjectedBundle author to specify one (or more) data
1786         classes that are allowed to be serialized between the two processes.
1787         
1788         * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
1789         (WKBundleExtendClassesForParameterCoder): Added.
1790         * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
1791         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.h:
1792         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm:
1793         (createWKArray): Added.
1794         (-[WKWebProcessPlugInController extendClassesForParameterCoder:]): Added.
1795         * WebProcess/InjectedBundle/InjectedBundle.h:
1796         * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
1797         (WebKit::InjectedBundle::extendClassesForParameterCoder): Added.
1798         (WebKit::InjectedBundle::classesForCoder): New helper function.
1799         (WebKit::InjectedBundle::setBundleParameter): Modified to use the new set of valid
1800         classes for NSSecureCoding.
1801
1802 2018-06-26  Eric Carlson  <eric.carlson@apple.com>
1803
1804         Enable mock capture devices on the iOS simulator
1805         https://bugs.webkit.org/show_bug.cgi?id=186846
1806         <rdar://problem/41289134>
1807
1808         Reviewed by Youenn Fablet.
1809
1810         * Shared/WebPreferences.yaml: Use DEFAULT_MOCK_CAPTURE_DEVICES_ENABLED.
1811         * Shared/WebPreferencesDefaultValues.h: Define DEFAULT_MOCK_CAPTURE_DEVICES_ENABLED, set to
1812         true in the iOS simulator only.
1813
1814 2018-06-26  Fujii Hironori  <Hironori.Fujii@sony.com>
1815
1816         [Win] 'deref': is not a member of 'WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains::<lambda_9d761a6dc12d95db7fa2d6f3f5aa26fa>'
1817         https://bugs.webkit.org/show_bug.cgi?id=187035
1818
1819         Unreviewed build fix.
1820
1821         MSVC can't compile the code using `this` in a generalized lambda
1822         capture in another lambda.
1823
1824         In this case, there is no need to copy `protectedThis` for the
1825         inner lambda. Move `protectedThis` of the outer lambda to the
1826         inner as well as `completionHandler`.
1827
1828         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1829         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
1830         Moved `protectedThis` from the outer lambda to the inner.
1831         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
1832         Ditto.
1833
1834 2018-06-26  Miguel Gomez  <magomez@igalia.com>
1835
1836         [GTK] Many webpages can crash the browser in WebCore::CoordinatedGraphicsLayer::transformedVisibleRect
1837         https://bugs.webkit.org/show_bug.cgi?id=179304
1838
1839         Reviewed by Michael Catanzaro.
1840
1841         Add a way to attach to the CompositingCoordinator layers that were not created by it.
1842
1843         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
1844         (WebKit::CompositingCoordinator::attachLayer):
1845         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
1846
1847 2018-06-25  Tim Horton  <timothy_horton@apple.com>
1848
1849         WKThumbnailView fallback background is blindingly bright in Dark Mode
1850         https://bugs.webkit.org/show_bug.cgi?id=187017
1851         <rdar://problem/41036209>
1852
1853         Reviewed by Simon Fraser.
1854
1855         * UIProcess/API/Cocoa/_WKThumbnailView.mm:
1856         (-[_WKThumbnailView initWithFrame:]):
1857         (-[_WKThumbnailView wantsUpdateLayer]):
1858         (-[_WKThumbnailView updateLayer]):
1859         Use a semantic color for the WKThumbnailView background color
1860         instead of flat white.
1861
1862 2018-06-25  John Wilander  <wilander@apple.com>
1863
1864         Resource Load Statistics: Make WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains() wait for the network process before calling its callback
1865         https://bugs.webkit.org/show_bug.cgi?id=186903
1866         <rdar://problem/41350182>
1867
1868         Reviewed by Chris Dumez.
1869
1870         This patch stores the callback sent to
1871         WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains(),
1872         sets up a context ID, and sends that ID to the network process when
1873         asking it to update cookie partitioning and blocking. The network
1874         process then tells the UI process when it's done, at which point the
1875         callback is called.
1876
1877         This change is meant to address layout test flakiness.
1878
1879         * NetworkProcess/NetworkProcess.cpp:
1880         (WebKit::NetworkProcess::updatePrevalentDomainsToPartitionOrBlockCookies):
1881         * NetworkProcess/NetworkProcess.h:
1882         * NetworkProcess/NetworkProcess.messages.in:
1883         * UIProcess/Network/NetworkProcessProxy.cpp:
1884         (WebKit::NetworkProcessProxy::updatePrevalentDomainsToPartitionOrBlockCookies):
1885         (WebKit::NetworkProcessProxy::didUpdatePartitionOrBlockCookies):
1886         * UIProcess/Network/NetworkProcessProxy.h:
1887         * UIProcess/Network/NetworkProcessProxy.messages.in:
1888         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1889         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
1890         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
1891         * UIProcess/WebResourceLoadStatisticsStore.h:
1892         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1893         (WebKit::WebsiteDataStore::updatePrevalentDomainsToPartitionOrBlockCookies):
1894         (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):
1895         * UIProcess/WebsiteData/WebsiteDataStore.h:
1896
1897 2018-06-25  Brent Fulgham  <bfulgham@apple.com>
1898
1899         Allow access to APTDevice in iOS WebContent process
1900         https://bugs.webkit.org/show_bug.cgi?id=187021
1901         <rdar://problem/41339769>
1902
1903         Reviewed by Youenn Fablet.
1904
1905         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
1906
1907 2018-06-25  Keith Rollin  <krollin@apple.com>
1908         Unreviewed, rolling out r233087.
1909
1910         Causes 5% Mac PLT regression.
1911
1912         Reverted changeset:
1913
1914         "Recalc styles every time defaultAppearance changes."
1915         https://bugs.webkit.org/show_bug.cgi?id=186866
1916         https://trac.webkit.org/changeset/233087
1917
1918 2018-06-25  Youenn Fablet  <youenn@apple.com>
1919
1920         Add a sandbox profile to Hangout plug-in
1921         https://bugs.webkit.org/show_bug.cgi?id=187005
1922         <rdar://problem/41428391>
1923
1924         Reviewed by Brent Fulgham.
1925
1926         Add a sandbox profile so that this plug-in can be run when UIProcess is sandboxed.
1927
1928         * Resources/PlugInSandboxProfiles/com.google.googletalkbrowserplugin.sb: Added.
1929         * WebKit.xcodeproj/project.pbxproj:
1930
1931 2018-06-25  Youenn Fablet  <youenn@apple.com>
1932
1933         NetworkLoadChecker should not check CORS for 304 responses triggered by WebProcess revalidation
1934         https://bugs.webkit.org/show_bug.cgi?id=186939
1935         <rdar://problem/40941725>
1936
1937         Reviewed by Chris Dumez.
1938
1939         * NetworkProcess/NetworkLoadChecker.cpp:
1940         (WebKit::NetworkLoadChecker::validateResponse):
1941
1942 2018-06-25  Keith Rollin  <krollin@apple.com>
1943
1944         Adjust UNEXPORTED_SYMBOL_LDFLAGS for LTO
1945         https://bugs.webkit.org/show_bug.cgi?id=186949
1946         <rdar://problem/41386438>
1947
1948         Reviewed by David Kilzer.
1949
1950         When building with LTO, WebKit's
1951         'check-for-weak-vtables-and-externals' script reports weak external
1952         symbols:
1953
1954         ERROR: WebKit has a weak external symbol in it (.../OpenSource/WebKitBuild/Release/WebKit.framework/Versions/A/WebKit)
1955         ERROR: A weak external symbol is generated when a symbol is defined in multiple compilation units and is also marked as being exported from the library.
1956         ERROR: A common cause of weak external symbols is when an inline function is listed in the linker export file.
1957         ERROR: symbol __ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_istreamIcS2_EE
1958         ERROR: symbol __ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_14basic_iostreamIcS2_EE
1959         ERROR: symbol __ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE16_NS_13basic_ostreamIcS2_EE
1960         ERROR: symbol __ZTTNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
1961         ERROR: symbol __ZTVNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEEE
1962         ERROR: symbol __ZTVNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
1963         Command /bin/sh failed with exit code 1
1964
1965         Address these by adding those symbols to UNEXPORTED_SYMBOL_LDFLAGS in
1966         WebKit.xcconfig.
1967
1968         * Configurations/WebKit.xcconfig:
1969
1970 2018-06-25  Chris Dumez  <cdumez@apple.com>
1971
1972         Make sure API::IconLoadingClient::getLoadDecisionForIcon()'s completion handler gets called
1973         https://bugs.webkit.org/show_bug.cgi?id=187007
1974         <rdar://problem/41293989>
1975
1976         Reviewed by Brady Eidson.
1977
1978         Make sure API::IconLoadingClient::getLoadDecisionForIcon()'s completion handler gets called by
1979         switching its type to WTF::CompletionHandler instead of WTF::Function. This also has the benefit
1980         of destroying our captured objects when the completion handler gets called by the client on the
1981         main thread instead of whatever thread the ObjC block gets released on.
1982
1983         * UIProcess/API/APIIconLoadingClient.h:
1984         (API::IconLoadingClient::getLoadDecisionForIcon):
1985         * UIProcess/API/glib/WebKitIconLoadingClient.cpp:
1986         * UIProcess/API/mac/WKView.mm:
1987         (-[WKView maybeInstallIconLoadingClient]):
1988         * UIProcess/Cocoa/IconLoadingDelegate.h:
1989         * UIProcess/Cocoa/IconLoadingDelegate.mm:
1990         (WebKit::IconLoadingDelegate::IconLoadingClient::getLoadDecisionForIcon):
1991
1992 2018-06-25  Youenn Fablet  <youenn@apple.com>
1993
1994         Add API to control mock media devices
1995         https://bugs.webkit.org/show_bug.cgi?id=186958
1996
1997         Reviewed by Eric Carlson.
1998
1999         Add API to clear, set, remove and reset mock media devices.
2000         The mock media center of UIProcess and all WebProcesses are updated.
2001
2002         * CMakeLists.txt:
2003         * UIProcess/API/C/WKMockMediaDevice.cpp: Added.
2004         (typeFromString):
2005         (WKAddMockMediaDevice):
2006         (WKClearMockMediaDevices):
2007         (WKRemoveMockMediaDevice):
2008         (WKResetMockMediaDevices):
2009         * UIProcess/API/C/WKMockMediaDevice.h: Added.
2010         * UIProcess/WebProcessPool.cpp:
2011         (WebKit::WebProcessPool::addMockMediaDevice):
2012         (WebKit::WebProcessPool::clearMockMediaDevices):
2013         (WebKit::WebProcessPool::removeMockMediaDevice):
2014         (WebKit::WebProcessPool::resetMockMediaDevices):
2015         * UIProcess/WebProcessPool.h:
2016         * WebKit.xcodeproj/project.pbxproj:
2017         * WebProcess/WebProcess.cpp:
2018         (WebKit::WebProcess::addMockMediaDevice):
2019         (WebKit::WebProcess::clearMockMediaDevices):
2020         (WebKit::WebProcess::removeMockMediaDevice):
2021         (WebKit::WebProcess::resetMockMediaDevices):
2022         * WebProcess/WebProcess.h:
2023         * WebProcess/WebProcess.messages.in:
2024
2025 2018-06-25  Wenson Hsieh  <wenson_hsieh@apple.com>
2026
2027         [iPad apps on macOS] Click events are broken in WKWebView
2028         https://bugs.webkit.org/show_bug.cgi?id=186964
2029         <rdar://problem/41369145>
2030
2031         Reviewed by Tim Horton.
2032
2033         Tapping in WKWebView currently does not dispatch click events to the page. This is because the long press loupe
2034         gesture (in the text interaction assistant) has a delay of 0 when running iOS apps on macOS, but on iOS, it's
2035         0.5. The zero delay on macOS means that the loupe gesture will be recognized before the synthetic click gesture;
2036         this, in turn, causes the synthetic click gesture to be excluded by the loupe gesture. To address this, we
2037         simply allow the click and loupe gesture to recognize simultaneously.
2038
2039         Additionally, a new hover gesture was added recently to handle macOS cursor types when hovering over selectable
2040         text. This patch also allows other gestures to recognize alongside hover gestures, which matches macOS behavior.
2041
2042         We don't have the capacity to write automated tests for this yet; I manually tested text selection, editing in
2043         some text form controls, as well as clicking on links, buttons, and other elements with click event handlers.
2044
2045         * UIProcess/ios/WKContentViewInteraction.mm:
2046         (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
2047
2048 2018-06-23  Brian Burg  <bburg@apple.com>
2049
2050         [Mac] Web Automation: include correct key code with synthesized NSEvents used for keystrokes
2051         https://bugs.webkit.org/show_bug.cgi?id=186937
2052
2053         Reviewed by Timothy Hatcher.
2054
2055         In some cases, a missing keyCode for an ASCII letter/number can cause synthesized
2056         NSEvents to not be converted into a key equivalent action like copy: or paste:.
2057
2058         * UIProcess/Automation/mac/WebAutomationSessionMac.mm:
2059         Drive by, always initialize keyCode.
2060
2061         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
2062         (WebKit::keyCodeForCharKey): Compute the keyCode as defined by HLTB headers.
2063         This only needs to be computed for characters with physical keys, excluding the
2064         number pad and some traditional virtual keys that do not usually have glyphs.
2065
2066 2018-06-24  Michael Catanzaro  <mcatanzaro@igalia.com>
2067
2068         Unreviewed, fix GTK debug build after r233131
2069         https://bugs.webkit.org/show_bug.cgi?id=186899
2070         <rdar://problem/38222248>
2071
2072         This assertion was intended to be removed.
2073
2074         * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
2075         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
2076
2077 2018-06-21  Brian Burg  <bburg@apple.com>
2078
2079         Web Automation: key actions should support multiple pressed virtual keys
2080         https://bugs.webkit.org/show_bug.cgi?id=186899
2081         <rdar://problem/38222248>
2082
2083         Reviewed by Timothy Hatcher.
2084
2085         This patch changes the protocol to allow multiple virtual keys per input source state.
2086         Chords like Cmd-Shift-A and Shift-F12 must be represented this way as they are encoded
2087         in the VirtualKey enum rather than as an ASCII char.
2088
2089         * UIProcess/Automation/Automation.json:
2090         * UIProcess/Automation/SimulatedInputDispatcher.h:
2091         * UIProcess/Automation/SimulatedInputDispatcher.cpp:
2092         (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
2093         * UIProcess/Automation/WebAutomationSession.cpp:
2094         (WebKit::WebAutomationSession::simulateKeyboardInteraction):
2095         (WebKit::WebAutomationSession::performKeyboardInteractions):
2096         (WebKit::WebAutomationSession::performInteractionSequence):
2097
2098         * UIProcess/Automation/WebAutomationSession.h:
2099         * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
2100         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
2101         * UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
2102         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
2103         * UIProcess/Automation/mac/WebAutomationSessionMac.mm:
2104         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
2105         Also clean up the signature of WebAutomationSession::platformSimulateKeyboardInteraction
2106         to use a variant instead of mutually exclusive optional values with different types.
2107
2108 2018-06-23  Yusuke Suzuki  <utatane.tea@gmail.com>
2109
2110         [WTF] Add user-defined literal for ASCIILiteral
2111         https://bugs.webkit.org/show_bug.cgi?id=186839
2112
2113         Reviewed by Darin Adler.
2114
2115         * NetworkProcess/NetworkCORSPreflightChecker.cpp:
2116         (WebKit::NetworkCORSPreflightChecker::willPerformHTTPRedirection):
2117         (WebKit::NetworkCORSPreflightChecker::didReceiveChallenge):
2118         (WebKit::NetworkCORSPreflightChecker::wasBlocked):
2119         (WebKit::NetworkCORSPreflightChecker::cannotShowURL):
2120         * NetworkProcess/NetworkDataTaskBlob.cpp:
2121         (WebKit::NetworkDataTaskBlob::suggestedFilename const):
2122         * NetworkProcess/NetworkLoadChecker.cpp:
2123         (WebKit::NetworkLoadChecker::checkRedirection):
2124         (WebKit::NetworkLoadChecker::checkRequest):
2125         * NetworkProcess/NetworkResourceLoader.cpp:
2126         (WebKit::NetworkResourceLoader::continueWillSendRequest):
2127         * NetworkProcess/PingLoad.cpp:
2128         (WebKit::PingLoad::willPerformHTTPRedirection):
2129         (WebKit::PingLoad::didReceiveChallenge):
2130         (WebKit::PingLoad::timeoutTimerFired):
2131         * NetworkProcess/PreconnectTask.cpp:
2132         (WebKit::PreconnectTask::PreconnectTask):
2133         * NetworkProcess/cache/CacheStorageEngine.cpp:
2134         (WebKit::CacheStorage::Engine::initialize):
2135         * NetworkProcess/cache/CacheStorageEngineCache.cpp:
2136         (WebKit::CacheStorage::Cache::toRecordInformation):
2137         * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
2138         (WebKit::CacheStorage::cachesListFilename):
2139         (WebKit::CacheStorage::cachesOriginFilename):
2140         * NetworkProcess/cache/NetworkCacheStatistics.cpp:
2141         (WebKit::NetworkCache::Statistics::initialize):
2142         (WebKit::NetworkCache::Statistics::bootstrapFromNetworkCache):
2143         (WebKit::NetworkCache::Statistics::queryWasEverRequested):
2144         (WebKit::NetworkCache::Statistics::clear):
2145         (WebKit::NetworkCache::Statistics::addHashesToDatabase):
2146         (WebKit::NetworkCache::Statistics::addStoreDecisionsToDatabase):
2147         * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
2148         (WebKit::XPCServiceInitializer):
2149         * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
2150         (WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
2151         * Shared/Plugins/Netscape/PluginInformation.cpp:
2152         (WebKit::pluginInformationBundleIdentifierKey):
2153         (WebKit::pluginInformationBundleVersionKey):
2154         (WebKit::pluginInformationBundleShortVersionKey):
2155         (WebKit::pluginInformationPathKey):
2156         (WebKit::pluginInformationDisplayNameKey):
2157         (WebKit::pluginInformationDefaultLoadPolicyKey):
2158         (WebKit::pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey):
2159         (WebKit::pluginInformationHasSandboxProfileKey):
2160         (WebKit::pluginInformationFrameURLKey):
2161         (WebKit::pluginInformationMIMETypeKey):
2162         (WebKit::pluginInformationPageURLKey):
2163         (WebKit::pluginInformationPluginspageAttributeURLKey):
2164         (WebKit::pluginInformationPluginURLKey):
2165         (WebKit::plugInInformationReplacementObscuredKey):
2166         * Shared/ios/WebIOSEventFactory.mm:
2167         (WebIOSEventFactory::createWebKeyboardEvent):
2168         * Shared/linux/WebMemorySamplerLinux.cpp:
2169         (WebKit::WebMemorySampler::sampleWebKit const):
2170         * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
2171         (debuggableTypeString):
2172         * UIProcess/API/glib/WebKitWebContext.cpp:
2173         (webkit_web_context_set_preferred_languages):
2174         * UIProcess/Automation/WebAutomationSession.cpp:
2175         (WebKit::WebAutomationSession::setWindowFrameOfBrowsingContext):
2176         (WebKit::WebAutomationSession::addSingleCookie):
2177         (WebKit::WebAutomationSession::setSessionPermissions):
2178         (WebKit::WebAutomationSession::performMouseInteraction):
2179         (WebKit::WebAutomationSession::performKeyboardInteractions):
2180         (WebKit::WebAutomationSession::performInteractionSequence):
2181         * UIProcess/Automation/WebAutomationSession.h:
2182         * UIProcess/ChildProcessProxy.cpp:
2183         (WebKit::ChildProcessProxy::getLaunchOptions):
2184         * UIProcess/Cocoa/DownloadClient.mm:
2185         (WebKit::DownloadClient::didStart):
2186         * UIProcess/Cocoa/WebViewImpl.mm:
2187         (WebKit::selectorExceptionMap):
2188         * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp:
2189         (WebKit::WebCredentialsMessengerProxy::makeCredential):
2190         (WebKit::WebCredentialsMessengerProxy::getAssertion):
2191         * UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
2192         (WebKit::PluginInfoStore::pluginsDirectories):
2193         * UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
2194         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
2195         * UIProcess/ServiceWorkerProcessProxy.cpp:
2196         (WebKit::ServiceWorkerProcessProxy::getLaunchOptions):
2197         (WebKit::ServiceWorkerProcessProxy::didReceiveAuthenticationChallenge):
2198         * UIProcess/UserMediaProcessManager.cpp:
2199         (WebKit::UserMediaProcessManager::willCreateMediaStream):
2200         (WebKit::UserMediaProcessManager::endedCaptureSession):
2201         * UIProcess/WebBackForwardList.cpp:
2202         (WebKit::WebBackForwardList::goToItem):
2203         * UIProcess/WebPageProxy.cpp:
2204         (WebKit::WebPageProxy::loadFile):
2205         (WebKit::WebPageProxy::loadHTMLString):
2206         (WebKit::WebPageProxy::loadPlainTextString):
2207         (WebKit::WebPageProxy::loadWebArchiveData):
2208         (WebKit::WebPageProxy::savePDFToFileInDownloadsFolder):
2209         * UIProcess/WebProcessProxy.cpp:
2210         (WebKit::WebProcessProxy::getLaunchOptions):
2211         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2212         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
2213         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
2214         (WebKit::notifyPages):
2215         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
2216         * UIProcess/ios/WKContentViewInteraction.mm:
2217         (-[WKContentView copyForWebView:]):
2218         (-[WKContentView cutForWebView:]):
2219         (-[WKContentView pasteForWebView:]):
2220         (-[WKContentView selectAllForWebView:]):
2221         (-[WKContentView deleteBackward]):
2222         (-[WKContentView _interpretKeyEvent:isCharEvent:]):
2223         * UIProcess/ios/WKLegacyPDFView.mm:
2224         (-[WKLegacyPDFView _URLForLinkAnnotation:]):
2225         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
2226         (WebKit::WebAutomationSessionProxy::elementForNodeHandle):
2227         (WebKit::WebAutomationSessionProxy::didClearWindowObjectForFrame):
2228         (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):
2229         * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
2230         (WebKit::WebIDBConnectionToServer::connectionToServerLost):
2231         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp:
2232         (webkit_dom_document_get_ready_state):
2233         * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
2234         (WebKit::uniqueWorldName):
2235         * WebProcess/MediaCache/WebMediaKeyStorageManager.cpp:
2236         (WebKit::WebMediaKeyStorageManager::getMediaKeyOrigins):
2237         * WebProcess/Plugins/PDF/PDFPlugin.mm:
2238         (WebKit::PDFPlugin::pluginInfo):
2239         * WebProcess/Storage/ServiceWorkerClientFetch.cpp:
2240         (WebKit::ServiceWorkerClientFetch::validateResponse):
2241         (WebKit::ServiceWorkerClientFetch::didReceiveResponse):
2242         * WebProcess/WebCoreSupport/WebContextMenuClient.cpp:
2243         (WebKit::WebContextMenuClient::searchWithGoogle):
2244         * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
2245         (WebKit::WebInspectorClient::showPaintRect):
2246         * WebProcess/WebPage/RemoteWebInspectorUI.cpp:
2247         (WebKit::RemoteWebInspectorUI::initialize):
2248         (WebKit::RemoteWebInspectorUI::didSave):
2249         (WebKit::RemoteWebInspectorUI::didAppend):
2250         (WebKit::RemoteWebInspectorUI::frontendLoaded):
2251         * WebProcess/WebPage/WebInspector.cpp:
2252         (WebKit::WebInspector::openInNewTab):
2253         * WebProcess/WebPage/WebInspectorUI.cpp:
2254         (WebKit::WebInspectorUI::setDockSide):
2255         (WebKit::WebInspectorUI::setDockingUnavailable):
2256         (WebKit::WebInspectorUI::setIsVisible):
2257         (WebKit::WebInspectorUI::showConsole):
2258         (WebKit::WebInspectorUI::showResources):
2259         (WebKit::WebInspectorUI::showTimelines):
2260         (WebKit::WebInspectorUI::showMainResourceForFrame):
2261         (WebKit::WebInspectorUI::startPageProfiling):
2262         (WebKit::WebInspectorUI::stopPageProfiling):
2263         (WebKit::WebInspectorUI::startElementSelection):
2264         (WebKit::WebInspectorUI::stopElementSelection):
2265         (WebKit::WebInspectorUI::didSave):
2266         (WebKit::WebInspectorUI::didAppend):
2267         * WebProcess/WebPage/WebPage.cpp:
2268         (WebKit::WebPage::loadStringImpl):
2269         (WebKit::WebPage::loadAlternateHTMLString):
2270         * WebProcess/WebPage/ios/WebPageIOS.mm:
2271         (WebKit::computeAutocorrectionContext):
2272         * WebProcess/WebProcess.cpp:
2273         (WebKit::getWebCoreMemoryCacheStatistics):
2274         (WebKit::WebProcess::getWebCoreStatistics):
2275         * WebProcess/cocoa/WebProcessCocoa.mm:
2276         (WebKit::WebProcess::initializeProcessName):
2277
2278 2018-06-22  Chris Dumez  <cdumez@apple.com>
2279
2280         Regression(r230211): Crash under WebInspectorClient::~WebInspectorClient()
2281         https://bugs.webkit.org/show_bug.cgi?id=186950
2282         <rdar://problem/40602069>
2283
2284         Reviewed by Darin Adler.
2285
2286         Re-introduce null-check that was accidentally dropped in r230211.
2287
2288         * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
2289         (WebKit::WebInspectorClient::~WebInspectorClient):
2290
2291 2018-06-22  Timothy Hatcher  <timothy@apple.com>
2292
2293         Corner of two scroll bars is white with dark mode enabled.
2294         https://bugs.webkit.org/show_bug.cgi?id=186819
2295         rdar://problem/40434350
2296
2297         Reviewed by Tim Horton.
2298
2299         * UIProcess/mac/WKPrintingView.mm:
2300         (-[WKPrintingView drawRect:]): Added LocalDefaultSystemAppearance.
2301         * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
2302         (WebKit::InjectedBundleRangeHandle::renderedImage): Ditto.
2303         * WebProcess/Plugins/PDF/PDFPlugin.mm:
2304         (WebKit::PDFPlugin::paintControlForLayerInContext): Ditto. Dropped ScrollView argument.
2305         * WebProcess/WebPage/WebPage.cpp:
2306         (WebKit::WebPage::drawRect): Added LocalDefaultSystemAppearance.
2307
2308 2018-06-22  Tim Horton  <timothy_horton@apple.com>
2309
2310         Make it possible to add a border around loading or failed-to-load images
2311         https://bugs.webkit.org/show_bug.cgi?id=186614
2312         <rdar://problem/39050152>
2313
2314         Reviewed by Zalan Bujtas.
2315
2316         * Shared/WebPreferences.yaml:
2317         * UIProcess/API/Cocoa/WKWebView.mm:
2318         (-[WKWebView _initializeWithConfiguration:]):
2319         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
2320         (-[WKWebViewConfiguration init]):
2321         (-[WKWebViewConfiguration copyWithZone:]):
2322         (-[WKWebViewConfiguration _setColorFilterEnabled:]):
2323         (-[WKWebViewConfiguration _incompleteImageBorderEnabled]):
2324         (-[WKWebViewConfiguration _setIncompleteImageBorderEnabled:]):
2325         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
2326         Plumb the setting to WebKit2.
2327
2328 2018-06-22  Brady Eidson  <beidson@apple.com>
2329
2330         WKURLSchemeHandler doesn't handle sync XHR.
2331         <rdar://problem/40955884> and https://bugs.webkit.org/show_bug.cgi?id=186902
2332
2333         Reviewed by Chris Dumez.
2334
2335         This patch allows WebProcesses to block on sync loads to a custom scheme,
2336         and teaches WebURLSchemeTasks how to buffer up data and the response if 
2337         operating synchronously.
2338
2339         * Shared/WebErrors.cpp:
2340         (WebKit::failedCustomProtocolSyncLoad):
2341         * Shared/WebErrors.h:
2342
2343         * UIProcess/WebPageProxy.cpp:
2344         (WebKit::WebPageProxy::startURLSchemeTask):
2345         (WebKit::WebPageProxy::loadSynchronousURLSchemeTask):
2346         * UIProcess/WebPageProxy.h:
2347         * UIProcess/WebPageProxy.messages.in:
2348
2349         * UIProcess/WebURLSchemeHandler.cpp:
2350         (WebKit::WebURLSchemeHandler::startTask):
2351         * UIProcess/WebURLSchemeHandler.h:
2352
2353         * UIProcess/WebURLSchemeTask.cpp:
2354         (WebKit::WebURLSchemeTask::create):
2355         (WebKit::WebURLSchemeTask::WebURLSchemeTask):
2356         (WebKit::WebURLSchemeTask::didPerformRedirection):
2357         (WebKit::WebURLSchemeTask::didReceiveResponse):
2358         (WebKit::WebURLSchemeTask::didReceiveData):
2359         (WebKit::WebURLSchemeTask::didComplete):
2360         (WebKit::WebURLSchemeTask::pageDestroyed):
2361         (WebKit::WebURLSchemeTask::stop):
2362         * UIProcess/WebURLSchemeTask.h:
2363         (WebKit::WebURLSchemeTask::isSync const):
2364
2365         * WebProcess/Network/WebLoaderStrategy.cpp:
2366         (WebKit::WebLoaderStrategy::tryLoadingSynchronouslyUsingURLSchemeHandler):
2367         (WebKit::WebLoaderStrategy::loadResourceSynchronously):
2368         * WebProcess/Network/WebLoaderStrategy.h:
2369
2370         * WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp:
2371         (WebKit::WebURLSchemeHandlerProxy::loadSynchronously):
2372         * WebProcess/WebPage/WebURLSchemeHandlerProxy.h:
2373
2374 2018-06-22  Chris Dumez  <cdumez@apple.com>
2375
2376         Implement IPC throttling to keep the main thread responsive when a process misbehaves
2377         https://bugs.webkit.org/show_bug.cgi?id=186607
2378         <rdar://problem/41073205>
2379
2380         Reviewed by Geoff Garen and Brady Eidson.
2381
2382         Implement IPC throttling to keep the main thread responsive when a process misbehaves.
2383         Instead of doing one main runloop dispatch per incoming message, we now do a single
2384         runloop dispatch and process incoming messages in batch. We put a limit on the number
2385         of messages to be processed in a batch (600). If the queue is larger that this limit,
2386         we'll schedule a 0-timer to process remaining messages, giving the main runloop a chance
2387         to process other events. Additionally, if an IPC connection keeps hitting this maximum
2388         batch size limit, we implement back off and we'll further decrease the number of messages
2389         we process in each batch (going as low as 60). This keeps Safari responsive enough to
2390         allow the user to close the bad tab (even on older devices such as iPhone 5s).
2391
2392         Finally, if the incoming message queue becomes too large (50000), we go one step further
2393         and kill the IPC connection in order to maintain performance / battery life.
2394
2395         Every time we apply throttling or terminate a connection due to throttling, we do a
2396         RELEASE_LOG_ERROR() with useful information in order to help diagnose potential issues
2397         in the future.
2398
2399         For now, incoming IPC messages throttling is only enabled on the UIProcess' connections
2400         to the WebProcesses.
2401
2402         * Platform/IPC/Connection.cpp:
2403         (IPC::Connection::Connection):
2404         (IPC::Connection::enqueueIncomingMessage):
2405         (IPC::Connection::MessagesThrottler::MessagesThrottler):
2406         (IPC::Connection::MessagesThrottler::scheduleMessagesDispatch):
2407         (IPC::Connection::MessagesThrottler::numberOfMessagesToProcess):
2408         (IPC::Connection::dispatchIncomingMessages):
2409         * Platform/IPC/Connection.h:
2410         * Platform/IPC/mac/ConnectionMac.mm:
2411         (IPC::Connection::kill):
2412
2413 2018-06-22  Sihui Liu  <sihui_liu@apple.com>
2414
2415         REGRESSION (r231850): Cookie file cannot be read or written by network process
2416         https://bugs.webkit.org/show_bug.cgi?id=186806
2417         <rdar://problem/41113791>
2418
2419         Unreviewed. Fix failure after r233084 by adding missing initialization.
2420
2421         * UIProcess/WebProcessPool.cpp:
2422         (WebKit::WebProcessPool::ensureNetworkProcess):
2423
2424 2018-06-22  Jer Noble  <jer.noble@apple.com>
2425
2426         [Fullscreen] Home indicator should show and hide with status bar
2427         https://bugs.webkit.org/show_bug.cgi?id=186942
2428         <rdar://problem/41302190>
2429
2430         Reviewed by Tim Horton.
2431
2432         * UIProcess/ios/fullscreen/WKFullScreenViewController.h:
2433         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
2434         (-[WKFullScreenViewController showUI]):
2435         (-[WKFullScreenViewController hideUI]):
2436         (-[WKFullScreenViewController setPrefersHomeIndicatorAutoHidden:]):
2437
2438 2018-06-22  Jer Noble  <jer.noble@apple.com>
2439
2440         [Fullscreen] Add a pinch-to-exit gesture
2441         https://bugs.webkit.org/show_bug.cgi?id=186821
2442
2443         Reviewed by Tim Horton.
2444
2445         Add a pinch gesture recognizer that overrides the pan gesture recognizer when active. Hide the
2446         WKFullscreenViewController's controls while a dismiss gesture is active.
2447
2448         * UIProcess/ios/fullscreen/WKFullScreenViewController.h:
2449         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
2450         (-[WKFullScreenViewController setAnimating:]):
2451         (-[WKFullScreenViewController prefersStatusBarHidden]):
2452         (-[WKFullScreenViewController gestureRecognizer:shouldReceiveTouch:]):
2453         (-[WKFullScreenViewController _touchDetected:]):
2454         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
2455         (-[WKFullscreenAnimationController context]):
2456         (-[WKFullscreenAnimationController updateWithProgress:scale:translation:anchor:]):
2457         (-[WKFullScreenInteractiveTransition animator]):
2458         (-[WKFullScreenInteractiveTransition updateInteractiveTransition:withScale:andTranslation:]):
2459         (-[WKFullScreenWindowController enterFullScreen]):
2460         (-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]):
2461         (-[WKFullScreenWindowController interactionControllerForDismissal:]):
2462         (-[WKFullScreenWindowController _startToDismissFullscreenChanged:]):
2463         (-[WKFullScreenWindowController _dismissFullscreenViewController]):
2464         (-[WKFullScreenWindowController _interactiveDismissChanged:]):
2465         (-[WKFullScreenWindowController _interactivePinchDismissChanged:]):
2466
2467 2018-06-22  Brian Burg  <bburg@apple.com>
2468
2469         [Cocoa] REGRESSION(W3C): actions for key equivalents are not respected
2470         https://bugs.webkit.org/show_bug.cgi?id=186936
2471
2472         Reviewed by Timothy Hatcher.
2473
2474         * UIProcess/Automation/WebAutomationSession.cpp:
2475         (WebKit::WebAutomationSession::isSimulatingUserInteraction const):
2476         This erroneously reported false unless there was both a mouse and key interaction
2477         being dispatched, which is not possible in the current serial event simulation model.
2478         As a result, Safari could not tell whether the action came from a simulated event
2479         or the user, and thus rejected all key equivalents like Cmd-A,V,C,X.
2480
2481 2018-06-22  Jer Noble  <jer.noble@apple.com>
2482
2483         [Fullscreen] Exit fullscreen when opening a new tab
2484         https://bugs.webkit.org/show_bug.cgi?id=186826
2485         <rdar://problem/40853211>
2486
2487         Reviewed by Brent Fulgham.
2488
2489         Make the fullscreen placeholder view a custom UIView, and exit fullscreen when the
2490         placeholder is removed from its superview.
2491
2492         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
2493         (-[WKFullScreenPlaceholderView willMoveToSuperview:]):
2494         (-[WKFullScreenWindowController enterFullScreen]):
2495         (-[WKFullScreenWindowController _completedExitFullScreen]):
2496         (-[WKFullScreenWindowController placeholderWillMoveToSuperview:]):
2497         (-[WKFullScreenWindowController _exitFullscreenImmediately]):
2498
2499 2018-06-22  Timothy Horton  <timothy_horton@apple.com>
2500
2501         Fix the build after r233089
2502
2503         * UIProcess/API/Cocoa/WKPreferences.mm:
2504         (-[WKPreferences _setColorFilterEnabled:]):
2505         (-[WKPreferences _colorFilterEnabled]):
2506
2507 2018-06-22  Chris Dumez  <cdumez@apple.com>
2508
2509         Crash under WebResourceLoadStatisticsStore::mergeStatistics(WTF::Vector<WebCore::ResourceLoadStatistics, 0ul, WTF::CrashOnOverflow, 16ul>&&)
2510         https://bugs.webkit.org/show_bug.cgi?id=186905
2511         <rdar://problem/41266775>
2512
2513         Reviewed by Brent Fulgham.
2514
2515         I believe the crash was caused by the WebResourceLoadStatisticsStore object being dead
2516         when mergeStatistics() is called. In particular, the crash was happening when the
2517         ResourceLoadStatisticsPersistentStorage's FileMonitor would detect a file change and
2518         we would re-sync statistics from the disk. The FileMonitor's lambda function was
2519         capturing |this| without ref'ing it, and the FileMonitor monitors the disk and
2520         calls the lambda on the background queue, while it gets destroyed on the main thread.
2521
2522         To make lifetime management less complex, the following changes were made:
2523         - The ResourceLoadStatisticsPersistentStorage object is now always constructed / used
2524           and destroyed on the background queue. We no longer have to worry about being on
2525           the right thread in a given method.
2526         - Now that ResourceLoadStatisticsPersistentStorage is always used from the background
2527           queue and no longer needs to be thread-safe, drop its ref() / deref() methods and
2528           use weak pointers instead to make sure the ResourceLoadStatisticsPersistentStorage
2529           is still alive when a lamdba gets called on the background queue.
2530         - For write scheduling use WorkQueue::dispatchAfter() and a WeakPtr instead of a
2531           RunLoop::Timer. This is more convenient to use as the RunLoop::Timer has to be used
2532           on the main thread.
2533
2534         * UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
2535         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
2536         (WebKit::ResourceLoadStatisticsPersistentStorage::~ResourceLoadStatisticsPersistentStorage):
2537         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk):
2538         (WebKit::ResourceLoadStatisticsPersistentStorage::monitorDirectoryForNewStatistics):
2539         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
2540         * UIProcess/ResourceLoadStatisticsPersistentStorage.h:
2541         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2542         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
2543         (WebKit::WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore):
2544         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
2545         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2546         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
2547         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
2548         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
2549         * UIProcess/WebResourceLoadStatisticsStore.h:
2550
2551 2018-06-21  Jer Noble  <jer.noble@apple.com>
2552
2553         CRASH in WebCore::VideoFullscreenInterfaceMac::~VideoFullscreenInterfaceMac()
2554         https://bugs.webkit.org/show_bug.cgi?id=186892
2555
2556         Reviewed by Eric Carlson.
2557
2558         Protect against m_contentMap being mutated while its contents are being invalidated
2559         by moving the map into a local variable and iterating over it instead.
2560
2561         * UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
2562         (WebKit::PlaybackSessionManagerProxy::invalidate):
2563         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
2564         (WebKit::VideoFullscreenManagerProxy::invalidate):
2565
2566 2018-06-22  Luming Yin  <luming_yin@apple.com>
2567
2568         Expose colorFilterEnabled SPI in WKPreferencesPrivate.h
2569         https://bugs.webkit.org/show_bug.cgi?id=186935
2570         <rdar://problem/41109387>
2571
2572         Reviewed by Tim Horton.
2573
2574         * UIProcess/API/Cocoa/WKPreferences.mm:
2575         (-[WKPreferences _setColorFilterEnabled:]):
2576         (-[WKPreferences _colorFilterEnabled]):
2577         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
2578
2579 2018-06-22  Timothy Hatcher  <timothy@apple.com>
2580
2581         Recalc styles every time defaultAppearance changes.
2582         https://bugs.webkit.org/show_bug.cgi?id=186866
2583         rdar://problem/41309805
2584
2585         Reviewed by Tim Horton.
2586
2587         * UIProcess/WebPageProxy.cpp:
2588         (WebKit::WebPageProxy::setDefaultAppearance):
2589         * WebProcess/WebPage/WebPage.cpp:
2590         (WebKit::WebPage::setDefaultAppearance):
2591
2592 2018-06-22  Sihui Liu  <sihui_liu@apple.com>
2593
2594         REGRESSION (r231850): Cookie file cannot be read or written by network process
2595         https://bugs.webkit.org/show_bug.cgi?id=186806
2596         <rdar://problem/41113791>
2597
2598         Reviewed by Geoffrey Garen.
2599
2600         Add defaultSessionPendingCookies to NetworkProcessCreationParameters, so pending cookies of default session 
2601         can be added right after default session is set. This improves the fix r231850 as it does not send additional 
2602         message and avoids the regression.
2603
2604         * NetworkProcess/NetworkProcess.cpp:
2605         (WebKit::NetworkProcess::initializeNetworkProcess):
2606         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2607         (WebKit::NetworkProcessCreationParameters::encode const):
2608         (WebKit::NetworkProcessCreationParameters::decode):
2609         * NetworkProcess/NetworkProcessCreationParameters.h:
2610         * NetworkProcess/mac/RemoteNetworkingContext.mm:
2611         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
2612         * UIProcess/Network/NetworkProcessProxy.cpp:
2613         (WebKit::NetworkProcessProxy::NetworkProcessProxy):
2614         * UIProcess/WebProcessPool.cpp:
2615         (WebKit::WebProcessPool::ensureNetworkProcess):
2616
2617 2018-06-22  Brent Fulgham  <bfulgham@apple.com>
2618
2619         [iOS Debug] Multiple resourceLoadStatistics redirect tests are flaky timeouts
2620         https://bugs.webkit.org/show_bug.cgi?id=183216
2621         <rdar://problem/37992317>
2622
2623         Reviewed by Chris Dumez.
2624
2625         Improve consistency of test results by make sure that completion handlers written to run
2626         on the main thread are only called on the main thread. Add additional assertions to help
2627         catch any cases where this invariant is not being honored.
2628
2629         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2630         (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): Use Completion handler and assert
2631         we are on the right thread.
2632         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): Ditto.
2633         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess): Ditto.
2634         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction): Ditto.
2635         (WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction): Ditto.
2636         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction): Ditto.
2637         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction): Ditto.
2638         (WebKit::WebResourceLoadStatisticsStore::setLastSeen): Ditto.
2639         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): Ditto.
2640         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource): Ditto.
2641         (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource): Ditto.
2642         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder): Ditto.
2643         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo): Ditto.
2644         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource): Ditto.
2645         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered): Ditto.
2646         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered): Ditto.
2647         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): Ditto.
2648         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): Ditto.
2649         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): Ditto.
2650         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): Ditto.
2651         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): Ditto.
2652         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): Ditto.
2653         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate): 
2654         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
2655         (WebKit::WebResourceLoadStatisticsStore::scheduleClearPartitioningStateForDomains):
2656         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningStateReset):
2657         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent): Update to perform callbacks
2658         on the main thread (as intended). This function was doing them on a work queue.
2659         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning): Ditto.
2660         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains): Ditto.
2661         (WebKit::WebResourceLoadStatisticsStore::clearPartitioningStateForDomains): Ditto.
2662         * UIProcess/WebResourceLoadStatisticsStore.h:
2663
2664 2018-06-22  Michael Catanzaro  <mcatanzaro@igalia.com>
2665
2666         REGRESSION(r230950): [GTK] WebKit::CoordinatedBackingStoreTile::setBackBuffer(): WebKitWebProcess killed by SIGSEGV (ASSERTION FAILED: it != m_tiles.end())
2667         https://bugs.webkit.org/show_bug.cgi?id=186206
2668
2669         Unreviewed manual rollout of r230950
2670
2671         * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
2672         (WebKit::layerShouldHaveBackingStore):
2673
2674 2018-06-20  Darin Adler  <darin@apple.com>
2675
2676         [Cocoa] Use the isDirectory: variants of NSURL methods more to eliminate unnecessary file system activity
2677         https://bugs.webkit.org/show_bug.cgi?id=186875
2678
2679         Reviewed by Anders Carlsson.
2680
2681         * UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
2682         (API::WebsiteDataStore::tempDirectoryFileSystemRepresentation): Use isDirectory:YES to create a URL
2683         to the temporary directory.
2684         * UIProcess/Cocoa/WebViewImpl.mm:
2685         (WebKit::WebViewImpl::namesOfPromisedFilesDroppedAtDestination): Use isDirectory:NO to create a URL
2686         pointing to the write location.
2687         * UIProcess/WebStorage/ios/LocalStorageDatabaseTrackerIOS.mm:
2688         (WebKit::LocalStorageDatabaseTracker::platformMaybeExcludeFromBackup const): Use isDirectory:YES to
2689         create a URL for the local storage directory.
2690         * UIProcess/ios/ResourceLoadStatisticsPersistentStorageIOS.mm:
2691         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup const): Use isDirectory:NO to
2692         create a URL for the storage directory.
2693         * UIProcess/ios/WKContentViewInteraction.mm:
2694         (-[WKContentView _prepareToDragPromisedBlob:]): Use isDirectory:NO to create a URL for the temporary
2695         file location.
2696         * UIProcess/ios/forms/WKFileUploadPanel.mm:
2697         (-[WKFileUploadPanel _uploadItemForImageData:imageName:successBlock:failureBlock:]): Use isDirectory:NO
2698         to create a URL for the image file to upload.
2699         * UIProcess/mac/WebInspectorProxyMac.mm:
2700         (WebKit::WebInspectorProxy::inspectorPageURL): Use isDirectory:NO to create a URL for the HTML file.
2701         (WebKit::WebInspectorProxy::inspectorTestPageURL): Ditto.
2702         (WebKit::WebInspectorProxy::inspectorBaseURL): Ditto.
2703         * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
2704         (WebKit::WebChromeClient::createIconForFiles): Use isDirectory:NO to create a URL for the image file.
2705         * WebProcess/WebPage/mac/WebInspectorUIMac.mm:
2706         (WebKit::webInspectorUILocalizedStringsURL): Use isDirectory:NO to create a URL for the localized
2707         strings file.
2708
2709 2018-06-21  Chris Dumez  <cdumez@apple.com>
2710
2711         Unreviewed, rolling out r232995.
2712
2713         Seems to have caused flakiness
2714
2715         Reverted changeset:
2716
2717         "Implement IPC throttling to keep the main thread responsive
2718         when a process misbehaves"
2719         https://bugs.webkit.org/show_bug.cgi?id=186607
2720         https://trac.webkit.org/changeset/232995
2721
2722 2018-06-15  Jer Noble  <jer.noble@apple.com>
2723
2724         Address fullscreen api CSS env feedback
2725         https://bugs.webkit.org/show_bug.cgi?id=186684
2726
2727         Reviewed by Simon Fraser.
2728
2729         + Update the phishing alert text to be more explicit about the specific threats
2730           phishing sites represent.
2731         + Make the top inset static, rather than dynamic.
2732         + Add bottom, left, and right insets for completeness.
2733         + Set the fullscreen animation duration as well as delay.
2734         + Notify the page when the controls show and hide.
2735
2736         * UIProcess/WebFullScreenManagerProxy.cpp:
2737         (WebKit::WebFullScreenManagerProxy::setFullscreenInsets):
2738         (WebKit::WebFullScreenManagerProxy::setFullscreenAutoHideTiming):
2739         (WebKit::WebFullScreenManagerProxy::setFullscreenControlsHidden):
2740         (WebKit::WebFullScreenManagerProxy::setFullscreenInsetTop): Deleted.
2741         (WebKit::WebFullScreenManagerProxy::setFullscreenAutoHideDelay): Deleted.
2742         * UIProcess/WebFullScreenManagerProxy.h:
2743         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
2744         (-[WKFullScreenViewController showUI]):
2745         (-[WKFullScreenViewController hideUI]):
2746         (-[WKFullScreenViewController viewWillAppear:]):
2747         (-[WKFullScreenViewController _effectiveFullscreenInsets]):
2748         (-[WKFullScreenViewController _updateWebViewFullscreenInsets]):
2749         (-[WKFullScreenViewController _showPhishingAlert]):
2750         (-[WKFullScreenViewController _effectiveFullscreenInsetTop]): Deleted.
2751         * WebProcess/FullScreen/WebFullScreenManager.cpp:
2752         (WebKit::WebFullScreenManager::didExitFullScreen):
2753         (WebKit::WebFullScreenManager::setFullscreenInsets):
2754         (WebKit::WebFullScreenManager::setFullscreenAutoHideTiming):
2755         (WebKit::WebFullScreenManager::setFullscreenControlsHidden):
2756         (WebKit::WebFullScreenManager::setFullscreenInsetTop): Deleted.
2757         (WebKit::WebFullScreenManager::setFullscreenAutoHideDelay): Deleted.
2758         * WebProcess/FullScreen/WebFullScreenManager.h:
2759         * WebProcess/FullScreen/WebFullScreenManager.messages.in:
2760
2761 2018-06-21  Commit Queue  <commit-queue@webkit.org>
2762
2763         Unreviewed, rolling out r232884.
2764         https://bugs.webkit.org/show_bug.cgi?id=186891
2765
2766         "Introduced assertion failure in ~DisplayRefreshMonitorMac()."
2767         (Requested by perarne on #webkit).
2768
2769         Reverted changeset:
2770
2771         "DisplayRefreshMonitorMac should hold a weak pointer to
2772         WebPage."
2773         https://bugs.webkit.org/show_bug.cgi?id=186683
2774         https://trac.webkit.org/changeset/232884
2775
2776 2018-06-21  Jer Noble  <jer.noble@apple.com>
2777
2778         [Fullscreen] Page sometimes ends up with an incorrect zoom level after entering fullscreen
2779         https://bugs.webkit.org/show_bug.cgi?id=186822
2780
2781         Reviewed by Simon Fraser.
2782
2783         Set the minimum zoom, maximum zoom, zoom bouncing, and user scalability settings of the
2784         WKWebView's UIScrollView upon entering fullscreen, and restore those same settings upon
2785         exit. Override the viewport arguments upon entering fullscreen, restore them upon exit.
2786
2787         * Platform/IPC/ArgumentCoder.h:
2788         * Shared/WebCoreArgumentCoders.cpp:
2789         (IPC::ArgumentCoder<ViewportArguments>::decode):
2790         * Shared/WebCoreArgumentCoders.h:
2791         * UIProcess/WebPageProxy.h:
2792         (WebKit::WebPageProxy::forceAlwaysUserScalable const):
2793         * UIProcess/ios/WebPageProxyIOS.mm:
2794         (WebKit::WebPageProxy::setOverrideViewportArguments):
2795         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
2796         (WebKit::WKWebViewState::applyTo):
2797         (WebKit::WKWebViewState::store):
2798         (-[WKFullScreenWindowController enterFullScreen]):
2799         (-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]):
2800         * WebProcess/WebPage/WebPage.h:
2801         (WebKit::WebPage::forceAlwaysUserScalable const):
2802         * WebProcess/WebPage/WebPage.messages.in:
2803         * WebProcess/WebPage/ios/WebPageIOS.mm:
2804         (WebKit::WebPage::setOverrideViewportArguments):
2805
2806 2018-06-21  Jer Noble  <jer.noble@apple.com>
2807
2808         [Fullscreen] Use secondary glyph style for fullscreen controls
2809         https://bugs.webkit.org/show_bug.cgi?id=186862
2810         <rdar://problem/41212210>
2811
2812         Reviewed by Tim Horton.
2813
2814         Adopt AVBackgroundView, and use its predefined enums to set the material and tint styles for
2815         the fullscreen controls.
2816
2817         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
2818         (-[WKFullScreenViewController loadView]):
2819         * UIProcess/ios/fullscreen/WKFullscreenStackView.h:
2820         * UIProcess/ios/fullscreen/WKFullscreenStackView.mm:
2821         (-[WKFullscreenStackView init]):
2822         (-[WKFullscreenStackView dealloc]):
2823         (-[WKFullscreenStackView addArrangedSubview:applyingMaterialStyle:tintEffectStyle:]):
2824         (-[WKFullscreenStackView layoutSubviews]):
2825         (+[WKFullscreenStackView baseEffects]): Deleted.
2826         (+[WKFullscreenStackView configureView:forTintEffectWithColor:filterType:]): Deleted.
2827         (+[WKFullscreenStackView configureView:withBackgroundFillOfColor:opacity:filter:]): Deleted.
2828         (+[WKFullscreenStackView secondaryMaterialOverlayView]): Deleted.
2829         (+[WKFullscreenStackView applyPrimaryGlyphTintToView:]): Deleted.
2830         (+[WKFullscreenStackView applySecondaryGlyphTintToView:]): Deleted.
2831         (-[WKFullscreenStackView initWithArrangedSubviews:axis:]): Deleted.
2832         (-[WKFullscreenStackView setTargetViewForSecondaryMaterialOverlay:]): Deleted.
2833         (-[WKFullscreenStackView contentView]): Deleted.
2834         (-[WKFullscreenStackView _setArrangedSubviews:axis:]): Deleted.
2835         (-[WKFullscreenStackView setBounds:]): Deleted.
2836         (-[WKFullscreenStackView updateConstraints]): Deleted.
2837
2838 2018-06-21  Jer Noble  <jer.noble@apple.com>
2839
2840         [Fullscreen] Suspend page (and pause video) while phishing warning is presented
2841         https://bugs.webkit.org/show_bug.cgi?id=186856
2842         <rdar://problem/41212444>
2843
2844         Reviewed by Tim Horton.
2845
2846         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
2847         (-[WKFullScreenViewController _showPhishingAlert]):
2848
2849 2018-06-21  David Fenton  <david_fenton@apple.com>
2850
2851         Unreviewed, rolling out r232989.
2852
2853         Causes API regressions on macOS
2854
2855         Reverted changeset:
2856
2857         "REGRESSION (r231850): Cookie file cannot be read or written
2858         by network process"
2859         https://bugs.webkit.org/show_bug.cgi?id=186806
2860         https://trac.webkit.org/changeset/232989
2861
2862 2018-06-21  Zan Dobersek  <zdobersek@igalia.com>
2863
2864         [GTK] WebDriver: allow applying host-specific TLS certificates for automated sessions
2865         https://bugs.webkit.org/show_bug.cgi?id=186884
2866
2867         Reviewed by Carlos Garcia Campos.
2868
2869         * UIProcess/API/glib/WebKitAutomationSession.cpp:
2870         (webkitAutomationSessionCreate): Handle any host-certificate pair that's
2871         been set for this session, creating a GTlsCertificate object through
2872         loading from the specified certificate path and marking that certificate
2873         as allowed for the specified host through the
2874         webkit_web_context_allow_tls_certificate_for_host() API.
2875
2876 2018-06-21  Chris Dumez  <cdumez@apple.com>
2877
2878         Regression(r226990) : Crash under WebCore::Page::applicationWillResignActive
2879         https://bugs.webkit.org/show_bug.cgi?id=186850
2880         <rdar://problem/37394469>
2881
2882         Reviewed by Eric Carlson.
2883
2884         Make sure m_page is not null before calling applicationWillResignActive(). m_page
2885         gets nulled out when WebPage::close() is called. The crash trace seems to indicate
2886         we're calling applicationWillResignActive() on a Page that is dead since we crash
2887         accessing Page::mainFrame().
2888
2889         * WebProcess/WebPage/ios/WebPageIOS.mm:
2890         (WebKit::WebPage::applicationWillResignActive):
2891
2892 2018-06-21  Fujii Hironori  <Hironori.Fujii@sony.com>
2893
2894         [GTK] http/tests/misc/bubble-drag-events.html crashes
2895         https://bugs.webkit.org/show_bug.cgi?id=182352
2896
2897         Reviewed by Carlos Garcia Campos.
2898
2899         PingLoad::didFinish was called twice if it is used with
2900         NetworkDataTaskSoup. PingLoad is not a ref-counted object. It is
2901         destructed when PingLoad::didFinish is called.
2902
2903         PingLoad::didReceiveChallenge calls the ChallengeCompletionHandler
2904         with AuthenticationChallengeDisposition::Cancel to cancel the
2905         challenge and calls PingLoad::didFinish.
2906
2907         NetworkDataTaskSoup::continueAuthenticate calls
2908         didReceiveChallenge with a ChallengeCompletionHandler which calls
2909         didCompleteWithError. PingLoad::didCompleteWithError calls
2910         PingLoad::didFinish.
2911
2912         didCompleteWithError callback should not be called in the
2913         ChallengeCompletionHandler.
2914
2915         * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
2916         (WebKit::NetworkDataTaskSoup::continueAuthenticate): Do not call
2917         didFail() in the ChallengeCompletionHandler. Call
2918         invalidateAndCancel() instead.
2919
2920 2018-06-20  Wenson Hsieh  <wenson_hsieh@apple.com>
2921
2922         [WebKit on watchOS] Fixed position elements sometimes flicker when scrolling
2923         https://bugs.webkit.org/show_bug.cgi?id=186860
2924         <rdar://problem/39953563>
2925
2926         Reviewed by Tim Horton.
2927
2928         Remove conditional guards that are no longer necessary, now that the oldest iOS version our builders support is
2929         iOS 11. Conditionalizing this logic only for iOS 11+ meant that on watchOS, we're always falling down the path
2930         where we don't schedule a visible content rect update until the next runloop, which makes it possible for a
2931         remote layer tree transaction to arrive and cause us to update the scrolling tree with stale viewport geometry.
2932
2933         Test: WKScrollViewTests.PositionFixedLayerAfterScrolling
2934
2935         * UIProcess/API/Cocoa/WKWebView.mm:
2936         (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
2937
2938 2018-06-20  Megan Gardner  <megan_gardner@apple.com>
2939
2940         Restrict Selection in contenteditable the extent of that contenteditable
2941         https://bugs.webkit.org/show_bug.cgi?id=186792
2942
2943         Reviewed by Wenson Hsieh.
2944
2945         We have not been checking to make sure that when we make a selection that it is restricted to 
2946         a single content editable on iOS. There is functionality to ensure this on mac, so it has been
2947         exposed and utilized for restricting the extent of a selection.
2948
2949         * WebProcess/WebPage/ios/WebPageIOS.mm:
2950         (WebKit::WebPage::updateSelectionWithTouches):
2951
2952 2018-06-19  Dean Jackson  <dino@apple.com>
2953
2954         Blank viewer comes up and then auto-dismisses when device is not connected to Internet
2955         https://bugs.webkit.org/show_bug.cgi?id=186825
2956         <rdar://problem/40294170>
2957
2958         Reviewed by Tim Horton.
2959
2960         Handle the case where the network load fails, and send that
2961         error onto QuickLook.
2962
2963         * UIProcess/Cocoa/DownloadClient.mm:
2964         (WebKit::DownloadClient::didReceiveResponse): Check for success.
2965         (WebKit::DownloadClient::processDidCrash): Cancel in the case of a crash.
2966         (WebKit::DownloadClient::didFail): Propagate the error onto QuickLook.
2967         * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
2968         (-[_WKPreviewControllerDataSource failWithError:]): New method that calls
2969         the completion handler with the error data.
2970         (WebKit::SystemPreviewController::fail): New API method.
2971         * UIProcess/SystemPreviewController.h:
2972
2973 2018-06-19  Chris Dumez  <cdumez@apple.com>
2974
2975         Implement IPC throttling to keep the main thread responsive when a process misbehaves
2976         https://bugs.webkit.org/show_bug.cgi?id=186607
2977         <rdar://problem/41073205>
2978
2979         Reviewed by Geoffrey Garen.
2980
2981         Implement IPC throttling to keep the main thread responsive when a process misbehaves.
2982         Instead of doing one main runloop dispatch per incoming message, we now do a single
2983         runloop dispatch and process incoming messages in batch. We put a limit on the number
2984         of messages to be processed in a batch (600). If the queue is larger that this limit,
2985         we'll schedule a 0-timer to process remaining messages, giving the main runloop a chance
2986         to process other events. Additionally, if an IPC connection keeps hitting this maximum
2987         batch size limit, we implement back off and we'll further decrease the number of messages
2988         we process in each batch (going as low as 60). This keeps Safari responsive enough to
2989         allow the user to close the bad tab (even on older devices such as iPhone 5s).
2990
2991         Finally, if the incoming message queue becomes too large (50000), we go one step further
2992         and kill the IPC connection in order to maintain performance / battery life.
2993
2994         Every time we apply throttling or terminate a connection due to throttling, we do a
2995         RELEASE_LOG_ERROR() with useful information in order to help diagnose potential issues
2996         in the future.
2997
2998         * Platform/IPC/Connection.cpp:
2999         (IPC::Connection::Connection):
3000         (IPC::Connection::enqueueIncomingMessage):
3001         (IPC::Connection::MessagesThrottler::MessagesThrottler):
3002         (IPC::Connection::MessagesThrottler::scheduleMessagesDispatch):
3003         (IPC::Connection::MessagesThrottler::numberOfMessagesToProcess):
3004         (IPC::Connection::dispatchIncomingMessages):
3005         * Platform/IPC/Connection.h:
3006         * Platform/IPC/mac/ConnectionMac.mm:
3007         (IPC::Connection::kill):
3008
3009 2018-06-18  Jiewen Tan  <jiewen_tan@apple.com>
3010
3011         Make SecItemShim to not send return value for SecItemAdd
3012         https://bugs.webkit.org/show_bug.cgi?id=186789
3013         <rdar://problem/40892596>
3014
3015         Reviewed by Brent Fulgham.
3016
3017         Return value of SecItemAdd is often ignored. Even if it isn't, we don't have the ability to serialize SecKeychainItemRef.
3018         Otherwise, it would go through the weird route of serializing SecKeychainItemRef by asking Keychain for its persistent
3019         reference. This route contradicts the purpose of SecItemShim, which is to proxy all Keychain operations to UIProcess.
3020
3021         Also, this patch removes the release assertion on encode(Encoder&, SecAccessControlRef) and decode(Decoder&, RetainPtr<SecAccessControlRef>&)
3022         as they don't query Keychain.
3023
3024         * Shared/cf/ArgumentCodersCF.cpp:
3025         (IPC::encode):
3026         (IPC::decode):
3027         * Shared/mac/SecItemShim.cpp:
3028         (WebKit::sendSecItemRequest):
3029         (WebKit::webSecItemAdd):
3030         * UIProcess/mac/SecItemShimProxy.cpp:
3031         (WebKit::SecItemShimProxy::secItemRequest):
3032         * UIProcess/mac/SecItemShimProxy.h:
3033         * UIProcess/mac/SecItemShimProxy.messages.in:
3034
3035 2018-06-19  Sihui Liu  <sihui_liu@apple.com>
3036
3037         REGRESSION (r231850): Cookie file cannot be read or written by network process
3038         https://bugs.webkit.org/show_bug.cgi?id=186806
3039         <rdar://problem/41113791>
3040
3041         Reviewed by Geoffrey Garen.
3042
3043         Default websiteDataStore may be added wrongly to network process before default session was 
3044         set, as messages were asynchronous, so the cookie storage could be improperly set.   
3045
3046         * NetworkProcess/NetworkProcess.cpp:
3047         (WebKit::NetworkProcess::initializeNetworkProcess):
3048         * NetworkProcess/NetworkProcessCreationParameters.cpp:
3049         (WebKit::NetworkProcessCreationParameters::encode const):
3050         (WebKit::NetworkProcessCreationParameters::decode):
3051         * NetworkProcess/NetworkProcessCreationParameters.h:
3052         * NetworkProcess/mac/RemoteNetworkingContext.mm:
3053         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
3054         * UIProcess/WebProcessPool.cpp:
3055         (WebKit::WebProcessPool::ensureNetworkProcess):
3056
3057 2018-06-19  Don Olmstead  <don.olmstead@sony.com>
3058
3059         Use getCurrentProcessID over getpid
3060         https://bugs.webkit.org/show_bug.cgi?id=186813
3061
3062         Reviewed by Alex Christensen.
3063
3064         * Shared/WebMemorySampler.cpp:
3065         (WebKit::WebMemorySampler::initializeTimers):
3066         (WebKit::WebMemorySampler::stop):
3067         (WebKit::WebMemorySampler::writeHeaders):
3068         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
3069         (WebKit::WebSWContextManagerConnection::installServiceWorker):
3070
3071 2018-06-19  Don Olmstead  <don.olmstead@sony.com>
3072
3073         WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations does not invoke callback when Service Workers disabled
3074         https://bugs.webkit.org/show_bug.cgi?id=186809
3075
3076         Reviewed by Chris Dumez.
3077
3078         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
3079         (WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations):
3080
3081 2018-06-19  Wenson Hsieh  <wenson_hsieh@apple.com>
3082
3083         [WebKit on watchOS] Vend username text content type when using scribble in login fields
3084         https://bugs.webkit.org/show_bug.cgi?id=186791
3085         <rdar://problem/41226935>
3086
3087         Reviewed by Beth Dakin.
3088
3089         Vend additional context to Quickboard when focusing an element that is likely to be a username field.
3090
3091         Test: fast/forms/watchos/username-text-content-type.html
3092
3093         * Shared/AssistedNodeInformation.cpp:
3094         (WebKit::AssistedNodeInformation::encode const):
3095         (WebKit::AssistedNodeInformation::decode):
3096         * Shared/AssistedNodeInformation.h:
3097
3098         Add a new flag to tell the UI process when the currently focused element is an autofillable username input
3099         field (using existing app autofill heuristics).
3100
3101         * UIProcess/API/Cocoa/WKWebView.mm:
3102         (-[WKWebView textContentTypeForTesting]):
3103         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
3104
3105         Add new testing SPI to grab the computed text content type for the focused element.
3106
3107         * UIProcess/ios/WKContentViewInteraction.h:
3108         * UIProcess/ios/WKContentViewInteraction.mm:
3109         (contentTypeFromFieldName):
3110
3111         If `autocomplete="username"` is specified, return a username text content type. This was not originally added in
3112         r197626 because UITextContentTypeUsername was only introduced later, in iOS 11.
3113
3114         (-[WKContentView textContentTypeForListViewController:]):
3115         (-[WKContentView textContentTypeForTesting]):
3116         * WebProcess/WebPage/ios/WebPageIOS.mm:
3117         (WebKit::WebPage::getAssistedNodeInformation):
3118
3119 2018-06-19  Chris Dumez  <cdumez@apple.com>
3120
3121         Unreviewed, rolling out r232947.
3122
3123         Caused an API test to time out
3124
3125         Reverted changeset:
3126
3127         "Implement IPC throttling to keep the main thread responsive
3128         when a process misbehaves"
3129         https://bugs.webkit.org/show_bug.cgi?id=186607
3130         https://trac.webkit.org/changeset/232947
3131
3132 2018-06-19  Chris Dumez  <cdumez@apple.com>
3133
3134         HTTPHeaderMap wastes 226KB of HashTable capacity on cnn.com
3135         https://bugs.webkit.org/show_bug.cgi?id=186735
3136         <rdar://problem/41189164>
3137
3138         Reviewed by Geoffrey Garen.
3139
3140         * NetworkProcess/cache/NetworkCacheCoders.cpp:
3141         (WTF::Persistence::Coder<WebCore::HTTPHeaderMap>::decode):
3142
3143 2018-06-19  Youenn Fablet  <youenn@apple.com>
3144
3145         Network Preflights do not show in WebInspector after moving CORS checks to NetworkProcess
3146         https://bugs.webkit.org/show_bug.cgi?id=186312
3147         <rdar://problem/40495434>
3148
3149         Reviewed by Chris Dumez.
3150
3151         Add buffering of all request/response of a given load, including redirections and preflights.
3152         This buffering is switched on/off by a boolean which is switched on in case Web Inspector is launched.
3153
3154         Buffering is done in NetworkLoadChecker.
3155         We add ways to retrieve preflight information from NetworkCORSPreflightChecker.
3156
3157         Implement LoaderStrategy new methods through sync IPC.
3158
3159         * NetworkProcess/NetworkCORSPreflightChecker.cpp:
3160         (WebKit::NetworkCORSPreflightChecker::NetworkCORSPreflightChecker):
3161         (WebKit::NetworkCORSPreflightChecker::startPreflight):
3162         (WebKit::NetworkCORSPreflightChecker::willPerformHTTPRedirection):
3163         (WebKit::NetworkCORSPreflightChecker::didReceiveResponseNetworkSession):
3164         (WebKit::NetworkCORSPreflightChecker::didCompleteWithError):
3165         (WebKit::NetworkCORSPreflightChecker::takeInformation):
3166         * NetworkProcess/NetworkCORSPreflightChecker.h:
3167         * NetworkProcess/NetworkConnectionToWebProcess.h:
3168         (WebKit::NetworkConnectionToWebProcess::takeNetworkLoadInformationRequest):
3169         (WebKit::NetworkConnectionToWebProcess::takeNetworkLoadIntermediateInformation):
3170         (WebKit::NetworkConnectionToWebProcess::addNetworkLoadInformation):
3171         (WebKit::NetworkConnectionToWebProcess::addNetworkLoadInformationMetrics):
3172         (WebKit::NetworkConnectionToWebProcess::addNetworkLoadInformationResponse): Deleted.
3173         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
3174         * NetworkProcess/NetworkLoadChecker.cpp:
3175         (WebKit::NetworkLoadChecker::NetworkLoadChecker):
3176         (WebKit::NetworkLoadChecker::check):
3177         (WebKit::NetworkLoadChecker::checkRedirection):
3178         (WebKit::NetworkLoadChecker::checkResponse):
3179         (WebKit::NetworkLoadChecker::checkCORSRequestWithPreflight):
3180         (WebKit::NetworkLoadChecker::storeRedirection):
3181         * NetworkProcess/NetworkLoadChecker.h:
3182         (WebKit::NetworkLoadChecker::takeNetworkLoadInformation):
3183         * NetworkProcess/NetworkResourceLoader.cpp:
3184         (WebKit::NetworkResourceLoader::didReceiveResponse):
3185         (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
3186         (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
3187         * NetworkProcess/PingLoad.cpp:
3188         (WebKit::PingLoad::PingLoad):
3189         * Scripts/webkit/messages.py:
3190         * WebProcess/Network/WebLoaderStrategy.cpp:
3191         (WebKit::WebLoaderStrategy::intermediateLoadInformationFromResourceLoadIdentifier):
3192         * WebProcess/Network/WebLoaderStrategy.h:
3193
3194 2018-06-19  Brent Fulgham  <bfulgham@apple.com>
3195
3196         MAP_JIT is not present for minimal simulator builds
3197         https://bugs.webkit.org/show_bug.cgi?id=186608
3198
3199         Reviewed by Darin Adler.
3200
3201         * Configurations/WebContent-iOS-minimalsimulator.entitlements:
3202
3203 2018-06-18  John Wilander  <wilander@apple.com>
3204
3205         Resource Load Statistics: Make sure to call callbacks even if there is no store (test infrastructure)
3206         https://bugs.webkit.org/show_bug.cgi?id=186777
3207         <rdar://problem/41216181>
3208
3209         Reviewed by Chris Dumez.
3210
3211         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
3212         (WKWebsiteDataStoreStatisticsUpdateCookiePartitioning):
3213         (WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost):
3214         (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore):
3215         (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
3216
3217 2018-06-18  Chris Dumez  <cdumez@apple.com>
3218
3219         Crash under WebProcessPool::networkProcessFailedToLaunch():
3220         https://bugs.webkit.org/show_bug.cgi?id=186784
3221         <rdar://problem/33535377>
3222
3223         Reviewed by Brady Eidson.
3224
3225         * UIProcess/API/Cocoa/WKProcessPool.mm:
3226         (+[WKProcessPool _allProcessPoolsForTesting]):
3227         Add SPI to retrieve all WebProcessPool for testing purposes.
3228
3229         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
3230         * UIProcess/Network/NetworkProcessProxy.cpp:
3231         (WebKit::NetworkProcessProxy::clearCallbackStates):
3232         Make iteration over completion handlers robust against completion handlers
3233         getting removed while we iterate.
3234
3235         (WebKit::NetworkProcessProxy::didClose):
3236         Ref the WebProcessPool (which keeps the NetworkProcessProxy alive too)
3237         as several calls within this method might cause the WebProcessPool /
3238         NetworkProcessProxy to get destroyed.
3239
3240 2018-06-18  Chris Dumez  <cdumez@apple.com>
3241
3242         Implement IPC throttling to keep the main thread responsive when a process misbehaves
3243         https://bugs.webkit.org/show_bug.cgi?id=186607
3244
3245         Reviewed by Geoffrey Garen.
3246
3247         Implement IPC throttling to keep the main thread responsive when a process misbehaves.
3248         Instead of doing one main runloop dispatch per incoming message, we now do a single
3249         runloop dispatch and process incoming messages in batch. We put a limit on the number
3250         of messages to be processed in a batch (600). If the queue is larger that this limit,
3251         we'll schedule a 0-timer to process remaining messages, giving the main runloop a chance
3252         to process other events. Additionally, if an IPC connection keeps hitting this maximum
3253         batch size limit, we implement back off and we'll further decrease the number of messages
3254         we process in each batch (going as low as 60). This keeps Safari responsive enough to
3255         allow the user to close the bad tab (even on older devices such as iPhone 5s).
3256
3257         Finally, if the incoming message queue becomes too large (50000), we go one step further
3258         and kill the IPC connection in order to maintain performance / battery life.
3259
3260         Every time we apply throttling or terminate a connection due to throttling, we do a
3261         RELEASE_LOG_ERROR() with useful information in order to help diagnose potential issues
3262         in the future.
3263
3264         * Platform/IPC/Connection.cpp:
3265         (IPC::Connection::Connection):
3266         (IPC::Connection::enqueueIncomingMessage):
3267         (IPC::Connection::MessagesThrottler::MessagesThrottler):
3268         (IPC::Connection::MessagesThrottler::scheduleMessagesDispatch):
3269         (IPC::Connection::MessagesThrottler::numberOfMessagesToProcess):
3270         (IPC::Connection::dispatchIncomingMessages):
3271         * Platform/IPC/Connection.h:
3272         * Platform/IPC/mac/ConnectionMac.mm:
3273         (IPC::Connection::kill):
3274
3275 2018-06-18  Jiewen Tan  <jiewen_tan@apple.com>
3276
3277         Add a graceful exit for AuthenticationManager::initializeConnection
3278         https://bugs.webkit.org/show_bug.cgi?id=186632
3279         <rdar://problem/41041033>
3280
3281         Reviewed by Brent Fulgham.
3282
3283         Add a graceful exit for AuthenticationManager::initializeConnection when the provided IPC connection
3284         is null or the underlying xpc connection is null.
3285
3286         * Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:
3287         (WebKit::AuthenticationManager::initializeConnection):
3288
3289 2018-06-18  Youenn Fablet  <youenn@apple.com>
3290
3291         Validate Cross-Origin-Resource-Policy for resources cached in the MemoryCache
3292         https://bugs.webkit.org/show_bug.cgi?id=186639
3293         <rdar://problem/41106984>
3294
3295         Reviewed by Geoffrey Garen.
3296
3297         Make use of WebCore method to check CORP.
3298
3299         * NetworkProcess/NetworkLoadChecker.cpp:
3300         (WebKit::NetworkLoadChecker::validateResponse):
3301         * NetworkProcess/NetworkLoadChecker.h:
3302
3303 2018-06-18  Karl Leplat  <karl.leplat_ext@softathome.com>
3304
3305         [Threaded paintingEngine] Fix rendering glitches
3306         https://bugs.webkit.org/show_bug.cgi?id=186764
3307
3308         Reviewed by Žan Doberšek.
3309
3310         * Shared/CoordinatedGraphics/CoordinatedBackingStore.cpp:
3311         (WebKit::CoordinatedBackingStoreTile::swapBuffers):
3312         We call Nicosia::Buffer function waitUntilPaintingComplete()
3313         in order to synchronize of using Nicosia:buffer between MainThread
3314         and ThreadedCompositor.
3315
3316
3317 2018-06-17  Chris Dumez  <cdumez@apple.com>
3318
3319         Crash under SuspendedPageProxy::~SuspendedPageProxy()
3320         https://bugs.webkit.org/show_bug.cgi?id=186688
3321         <rdar://problem/41060769>
3322
3323         Reviewed by Darin Adler.
3324
3325         Ref the WebProcessProxy before calling suspendedPageWasDestroyed() on it as this
3326         might cause the WebProcessProxy / WebProcessPool to get destroyed otherwise, and
3327         we would crash trying to call unregisterSuspendedPageProxy() on the WebProcessPool
3328         on the next line.
3329
3330         * UIProcess/SuspendedPageProxy.cpp:
3331         (WebKit::SuspendedPageProxy::~SuspendedPageProxy):
3332
3333 2018-06-17  Wenson Hsieh  <wenson_hsieh@apple.com>
3334
3335         [WebKit on watchOS] Upstream watchOS source additions to OpenSource (Part 3)
3336         https://bugs.webkit.org/show_bug.cgi?id=186442
3337         <rdar://problem/40879364>
3338
3339         Reviewed by Darin Adler.
3340
3341         Rename a category referencing "Extra zoom mode".
3342
3343         * UIProcess/ios/WKContentViewInteraction.mm:
3344
3345 2018-06-12  Darin Adler  <darin@apple.com>
3346
3347         [Cocoa] Make some RetainPtr refinements to get more ready for ARC
3348         https://bugs.webkit.org/show_bug.cgi?id=186526
3349
3350         Reviewed by Anders Carlsson.
3351
3352         * Platform/cf/ModuleCF.cpp:
3353         (WebKit::Module::load): Use move assignment instead of adoptCF/leakRef.
3354
3355         * Shared/Cocoa/WKNSURLExtras.mm:
3356         (+[NSURL _web_URLWithWTFString:]): Cast to NSURL * instead of doing the autorelease
3357         here, since the NSURL * operator already does what we want.
3358         (+[NSURL _web_URLWithWTFString:relativeToURL:]): Ditto.
3359
3360         * UIProcess/ios/WKContentView.mm:
3361         (-[WKContentView _wk_printedDocument]): Get rid of incorrect use of
3362         RetainPtr::autorelease. We don't want to null out _printedDocument each time this
3363         function is called.
3364
3365         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
3366         (collectIcons): Get rid of unnecessary use of RetainPtr::autorelease in a function
3367         that returns a RetainPtr.
3368
3369 2018-06-15  Chris Dumez  <cdumez@apple.com>
3370
3371         Add API test coverage for SW RegistrationDatabase destruction and fix issues found by the test
3372         https://bugs.webkit.org/show_bug.cgi?id=186681
3373
3374         Reviewed by Brady Eidson.
3375
3376         Make sure StorageProcess::unregisterSWServerConnection() does not unnecessarily
3377         create a SWServer. Otherwise, we were in quick session destroying the SWServer
3378         and then re-constructing it for the same sessionID, merely to try ot unregister
3379         a SWServerConnection.
3380
3381         * StorageProcess/StorageProcess.cpp:
3382         (WebKit::StorageProcess::existingSWOriginStoreForSession const):
3383         (WebKit::StorageProcess::unregisterSWServerConnection):
3384         * StorageProcess/StorageProcess.h:
3385
3386 2018-06-15  Basuke Suzuki  <Basuke.Suzuki@sony.com>
3387
3388         [WinCairo] Move unrelated features of WorkQueueWin into IPC::Connection
3389         https://bugs.webkit.org/show_bug.cgi?id=186582
3390
3391         Add EventListener private class to handle signaled tasks for I/O.
3392         Originally they were in WTF::WorkQueueWin, but those features were not related
3393         to WorkQueue and only used in IPC::ConnectionWin. Moved logic is more specialized
3394         than old generalized logic. That was unneeded generalization.
3395
3396         Reviewed by Brent Fulgham.
3397
3398         * Platform/IPC/Connection.h:
3399         (IPC::Connection::EventListener::state):
3400         * Platform/IPC/win/ConnectionWin.cpp:
3401         (IPC::Connection::platformInitialize):
3402         (IPC::Connection::platformInvalidate):
3403         (IPC::Connection::readEventHandler):
3404         (IPC::Connection::writeEventHandler):
3405         (IPC::Connection::invokeReadEventHandler):
3406         (IPC::Connection::invokeWriteEventHandler):
3407         (IPC::Connection::open):
3408         (IPC::Connection::sendOutgoingMessage):
3409         (IPC::Connection::EventListener::open):
3410         (IPC::Connection::EventListener::callback):
3411         (IPC::Connection::EventListener::close):
3412
3413 2018-06-15  Brady Eidson  <beidson@apple.com>
3414
3415         Crash in both StorageProcess and UIProcess when using custom WKWebsiteDataStores for data management.
3416         <rdar://problem/41019893> and https://bugs.webkit.org/show_bug.cgi?id=186682
3417
3418         Reviewed by Chris Dumez.
3419
3420         * UIProcess/Storage/StorageProcessProxy.cpp:
3421         (WebKit::StorageProcessProxy::didClose): Protect this and the process pool as the cleanup that follows
3422           might cause either to get destroyed.
3423
3424         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3425         (WebKit::WebsiteDataStore::fetchDataAndApply): Protect the operating WebsiteDataStore while async operations
3426           are in flight. Otherwise if the data store is destroyed, the SessionIDs for those operations will get
3427           destroyed before they complete.
3428         (WebKit::WebsiteDataStore::removeData): Ditto.
3429
3430 2018-06-15  Per Arne Vollan  <pvollan@apple.com>
3431
3432         Unreviewed build fix after r232634.
3433
3434         * WebProcess/WebPage/DrawingArea.h:
3435         * WebProcess/WebPage/DrawingArea.messages.in:
3436
3437 2018-06-15  Per Arne Vollan  <pvollan@apple.com>
3438
3439         DisplayRefreshMonitorMac should hold a weak pointer to WebPage.
3440         https://bugs.webkit.org/show_bug.cgi?id=186683
3441
3442         Reviewed by Brent Fulgham.
3443
3444         Instead of DisplayRefreshMonitorMac having a RefPtr to WebPage, it should have a weak pointer.
3445         Having a RefPtr could in theory create reference cycles. This potential problem has not been
3446         observed in practice, but it is safer to use a weak pointer.
3447
3448         * WebProcess/WebPage/WebPage.h:
3449         * WebProcess/WebPage/mac/DrawingAreaMac.cpp:
3450         (WebKit::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
3451         (WebKit::DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac):
3452         (WebKit::DisplayRefreshMonitorMac::requestRefreshCallback):
3453
3454 2018-06-15  Carlos Alberto Lopez Perez  <clopez@igalia.com>
3455
3456         [GTK][WKE] Disable memory pressure handling when running layout tests (WTR)
3457         https://bugs.webkit.org/show_bug.cgi?id=186663
3458
3459         Reviewed by Michael Catanzaro.
3460
3461         r196943 added a mechanism to disable the memory pressure handling
3462         on Mac. This patch enables using that mechanism also for GTK/WPE.
3463         To do that the environment variable WEBKIT_DISABLE_MEMORY_PRESSURE_MONITOR
3464         should bet set to 1.
3465         We want to use this on the layout tests to avoid flaky tests caused
3466         by accumulated leaks on the WebProcess by different tests.
3467
3468         * UIProcess/gtk/WebProcessPoolGtk.cpp:
3469         (WebKit::WebProcessPool::platformInitializeWebProcess):
3470         * UIProcess/wpe/WebProcessPoolWPE.cpp:
3471         (WebKit::WebProcessPool::platformInitializeWebProcess):
3472
3473 2018-06-15  Per Arne Vollan  <pvollan@apple.com>
3474
3475         Rollout r231818, as it introduced regression on tickets.com.
3476         https://bugs.webkit.org/show_bug.cgi?id=186675
3477
3478         Unreviewed, rolling out.
3479
3480         * UIProcess/WebPageProxy.cpp:
3481         (WebKit::WebPageProxy::dispatchActivityStateChange):
3482         * UIProcess/mac/DisplayLink.cpp:
3483         (WebKit::DisplayLink::pause): Deleted.
3484         (WebKit::DisplayLink::resume): Deleted.
3485         * UIProcess/mac/DisplayLink.h:
3486
3487 2018-06-15  Thibault Saunier  <tsaunier@igalia.com>
3488
3489         [GTK][WPE]: Avoid using uninitialized launchOptions in getLaunchOptions
3490         https://bugs.webkit.org/show_bug.cgi?id=185611
3491
3492         Reviewed by Chris Dumez.
3493
3494         Otherwise we might segfault.
3495
3496         * UIProcess/Plugins/PluginProcessProxy.cpp:
3497         (WebKit::PluginProcessProxy::getLaunchOptions):