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