aec37d30372aa3c0cc060dce6e30fa5ce815bd5c
[WebKit.git] / Source / WebKit2 / ChangeLog
1 2017-07-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2
3         Web Automation: evaluateJavaScriptFunction should start the callback timeout after the function is applied
4         https://bugs.webkit.org/show_bug.cgi?id=174421
5
6         Reviewed by Brian Burg.
7
8         This is causing selenium test testShouldNotTimeoutIfScriptCallsbackInsideAZeroTimeout to fail, because
9         JavaScriptTimeout error is generated unexpectedly. When no script timeout is specified, 0 is used by default,
10         which means we do a setTimeout with 0 and then the script does another setTimeout with 0, but ours is dispatched
11         before and reportTimeoutError is called. We should start our timeout after applying the function, and only if
12         the result hasn't been reported yet.
13
14         * WebProcess/Automation/WebAutomationSessionProxy.js:
15         (let.AutomationSessionProxy.prototype.evaluateJavaScriptFunction):
16
17 2017-07-12  Wenson Hsieh  <wenson_hsieh@apple.com>
18
19         [iOS DnD] [WK2] Add SPI to enable, disable, or follow default behavior for DnD on a WKWebView
20         https://bugs.webkit.org/show_bug.cgi?id=174440
21         <rdar://problem/33272627>
22
23         Reviewed by Beth Dakin.
24
25         Adds a new _dragInteractionPolicy property to WKWebView, which an internal client may use to always allow
26         dragging out of the web view (_WKDragInteractionPolicyAlwaysEnable), never allow
27         (_WKDragInteractionPolicyAlwaysDisable) or just use the default device-dependent behavior
28         (_WKDragInteractionPolicyDefault).
29
30         Also removes an extraneous class from WKContentViewInteraction.mm that is no longer used anywhere.
31
32         * UIProcess/API/Cocoa/WKWebView.mm:
33         (-[WKWebView _initializeWithConfiguration:]):
34
35         Set _dragInteractionPolicy to _WKDragInteractionPolicyDefault upon initialization.
36
37         (-[WKWebView _dragInteractionPolicy]):
38         (-[WKWebView _setDragInteractionPolicy:]):
39         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
40         * UIProcess/ios/WKContentViewInteraction.h:
41         * UIProcess/ios/WKContentViewInteraction.mm:
42         (shouldEnableDragInteractionForPolicy):
43         (-[WKContentView _didChangeDragInteractionPolicy]):
44
45         Called by the WKWebView when its _dragInteractionPolicy changes. The content view updates its
46         UIDragInteraction's -enabled property here in response.
47
48         (-[WKContentView setupDataInteractionDelegates]):
49
50 2017-07-12  Said Abou-Hallawa  <sabouhallawa@apple.com>
51
52         Async image decoding for large images should be disabled by default
53         https://bugs.webkit.org/show_bug.cgi?id=174432
54
55         Reviewed by Simon Fraser.
56
57         -- Replace every reference to GraphicsLayerPaintFlags::Snapshotting by
58            GraphicsLayerPaintFlags::None and every GraphicsLayerPaintFlags::None
59            by AllowAsyncImageDecoding.
60         -- Replace setting the bit PaintBehaviorSnapshotting in an existing PaintBehavoir 
61            by resetting the bit PaintBehaviorAllowAsyncImageDecoding.
62
63         * Shared/mac/RemoteLayerBackingStore.mm:
64         (WebKit::RemoteLayerBackingStore::drawInContext):
65         * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
66         (WebKit::imageForRect):
67         * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
68         (WebKit::InjectedBundleRangeHandle::renderedImage):
69
70 2017-07-12  Eric Carlson  <eric.carlson@apple.com>
71
72         [MediaStream] a capture source failure should end the MediaStreamTrack
73         https://bugs.webkit.org/show_bug.cgi?id=174375
74
75         Reviewed by Youenn Fablet.
76
77         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
78         (WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged): Consolidate start/end.
79         (WebKit::UserMediaPermissionRequestManagerProxy::startedCaptureSession): Deleted.
80         (WebKit::UserMediaPermissionRequestManagerProxy::endedCaptureSession): Deleted.
81         * UIProcess/UserMediaPermissionRequestManagerProxy.h:
82
83         * UIProcess/WebPageProxy.cpp:
84         (WebKit::WebPageProxy::isPlayingMediaDidChange): Call captureStateChanged if the capture 
85         state changes. Consider interrupted flags.
86
87 2017-07-12  Daniel Bates  <dabates@apple.com>
88
89         NavigationAction should track whether the navigation was initiated by the main frame
90         https://bugs.webkit.org/show_bug.cgi?id=174386
91         <rdar://problem/33245267>
92
93         Reviewed by Brady Eidson.
94
95         * WebProcess/WebPage/WebInspector.cpp:
96         (WebKit::WebInspector::openInNewTab): Pass whether the load was initiated by the main frame
97         when instantiating the NavigationAction.
98
99 2017-07-12  Daniel Bates  <dabates@apple.com>
100
101         Rename NavigationInitiatedByMainFrame to InitiatedByMainFrame
102         https://bugs.webkit.org/show_bug.cgi?id=174427
103
104         Rubber-stamped by Brady Eidson.
105
106         * WebProcess/Plugins/PluginView.cpp:
107         (WebKit::PluginView::loadURL):
108         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
109         (WebKit::WebFrameLoaderClient::dispatchCreatePage):
110         * WebProcess/WebPage/WebInspector.cpp:
111         (WebKit::WebInspector::openInNewTab):
112
113 2017-07-12  Matt Lewis  <jlewis3@apple.com>
114
115         Unreviewed, rolling out r219401.
116
117         This revision rolled out the previous patch, but after talking
118         with reviewer, a rebaseline is what was needed.Rolling back in
119         before rebaseline.
120
121         Reverted changeset:
122
123         "Unreviewed, rolling out r219379."
124         https://bugs.webkit.org/show_bug.cgi?id=174400
125         http://trac.webkit.org/changeset/219401
126
127 2017-07-12  Daniel Bates  <dabates@apple.com>
128
129         Update description of Secure Contexts experimental flag
130         https://bugs.webkit.org/show_bug.cgi?id=174401
131
132         Reviewed by Simon Fraser.
133
134         Change the description of the Secure Contexts experimental flag from "isSecureContext attribute"
135         to "Secure Contexts API".
136
137         * Shared/WebPreferencesDefinitions.h:
138
139 2017-07-12  Matt Lewis  <jlewis3@apple.com>
140
141         Unreviewed, rolling out r219379.
142
143         This revision caused a consistent failure in the test
144         fast/dom/Window/property-access-on-cached-window-after-frame-
145         removed.html.
146
147         Reverted changeset:
148
149         "Remove NAVIGATOR_HWCONCURRENCY"
150         https://bugs.webkit.org/show_bug.cgi?id=174400
151         http://trac.webkit.org/changeset/219379
152
153 2017-07-12  Zan Dobersek  <zdobersek@igalia.com>
154
155         [WPE] Use libepoxy
156         https://bugs.webkit.org/show_bug.cgi?id=172104
157
158         Reviewed by Michael Catanzaro.
159
160         * PlatformWPE.cmake: Drop the EGL_INCLUDE_DIRS compilation flags.
161         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
162         Include <epoxy/gl.h> when compiling with libepoxy usage enabled.
163
164 2017-07-12  Carlos Garcia Campos  <cgarcia@igalia.com>
165
166         Web Automation: upstream safaridriver's JavaScript atom implementations
167         https://bugs.webkit.org/show_bug.cgi?id=172060
168         <rdar://problem/32168187>
169
170         Reviewed by Brian Burg.
171
172         * UIProcess/Automation/atoms/ElementAttribute.js: Added.
173         * UIProcess/Automation/atoms/ElementDisplayed.js: Added.
174         * UIProcess/Automation/atoms/FindNodes.js: Added.
175         * UIProcess/Automation/atoms/FormElementClear.js: Added.
176         * UIProcess/Automation/atoms/FormSubmit.js: Added.
177
178 2017-07-11  Dean Jackson  <dino@apple.com>
179
180         Remove NAVIGATOR_HWCONCURRENCY
181         https://bugs.webkit.org/show_bug.cgi?id=174400
182
183         Reviewed by Sam Weinig.
184
185         * Configurations/FeatureDefines.xcconfig:
186
187 2017-07-11  Ansh Shukla  <ansh_shukla@apple.com>
188
189         WKWindowFeatures needs to expose scrollbar, fullscreen, and dialog configuration properties
190         https://bugs.webkit.org/show_bug.cgi?id=174239
191
192         Reviewed by Brady Eidson.
193
194         Add a new private header to expose getters for window feature properties already available
195         in the TFB APIWindowFeatures class. These properties are necessary for Safari to adopt more
196         modern API.
197
198         * UIProcess/API/Cocoa/WKWindowFeatures.mm:
199         (-[WKWindowFeatures _locationBarVisibility]):
200         (-[WKWindowFeatures _scrollbarsVisibility]):
201         (-[WKWindowFeatures _fullscreenDisplay]):
202         (-[WKWindowFeatures _dialogDisplay]):
203         * UIProcess/API/Cocoa/WKWindowFeaturesInternal.h: Expose some window features as read-only
204         properties.
205         * UIProcess/API/Cocoa/WKWindowFeaturesPrivate.h:
206         * WebKit2.xcodeproj/project.pbxproj:
207
208 2017-07-11  Chris Dumez  <cdumez@apple.com>
209
210         Avoid duplicating default parameter values in [WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]
211         https://bugs.webkit.org/show_bug.cgi?id=174402
212
213         Reviewed by Brent Fulgham.
214
215         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
216         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
217         * UIProcess/WebResourceLoadStatisticsStore.cpp:
218         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
219         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
220         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
221         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
222         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
223         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
224         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
225         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
226         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
227         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
228         (WebKit::WebResourceLoadStatisticsStore::shouldPartitionCookies):
229         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
230         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
231         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
232         (WebKit::WebResourceLoadStatisticsStore::pruneStatisticsIfNeeded):
233         (WebKit::WebResourceLoadStatisticsStore::resetParametersToDefaultValues):
234         * UIProcess/WebResourceLoadStatisticsStore.h:
235
236 2017-07-11  Dean Jackson  <dino@apple.com>
237
238         Rolling out r219372.
239
240         * Configurations/FeatureDefines.xcconfig:
241
242 2017-07-11  Dean Jackson  <dino@apple.com>
243
244         Remove NAVIGATOR_HWCONCURRENCY
245         https://bugs.webkit.org/show_bug.cgi?id=174400
246
247         Reviewed by Sam Weinig.
248
249         * Configurations/FeatureDefines.xcconfig:
250
251 2017-07-11  Dean Jackson  <dino@apple.com>
252
253         Viewport fit experimental feature should be always on by default
254         https://bugs.webkit.org/show_bug.cgi?id=174398
255         <rdar://problem/33248920>
256
257         Reviewed by Simon Fraser.
258
259         Even though this is experimental, it should be enabled by default, and
260         not follow the value of DEFAULT_EXPERIMENTAL_FEATURES_ENABLED.
261
262         * Shared/WebPreferencesDefinitions.h:
263
264 2017-07-11  Adrian Perez de Castro  <aperez@igalia.com>
265
266         Fix typo: ContentRuleListStore::nonLegacyDdefaultStore()
267         https://bugs.webkit.org/show_bug.cgi?id=174387
268
269         Reviewed by Michael Catanzaro.
270
271         Rename nonLegacyDdefaultStore() to nonLegacyDefaultStore().
272
273         * UIProcess/API/APIContentRuleListStore.cpp:
274         (API::ContentRuleListStore::nonLegacyDefaultStore):
275         (API::ContentRuleListStore::defaultStore):
276         * UIProcess/API/APIContentRuleListStore.h:
277
278 2017-07-11  Chris Dumez  <cdumez@apple.com>
279
280         Simplify primary domain lambda captures in WebResourceLoadStatisticsStore
281         https://bugs.webkit.org/show_bug.cgi?id=174381
282
283         Reviewed by Brent Fulgham.
284
285         * UIProcess/WebResourceLoadStatisticsStore.cpp:
286         (WebKit::isolatedPrimaryDomain):
287         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
288         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
289         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
290         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
291         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
292         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
293         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
294         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
295         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
296         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
297         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
298         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
299         (WebKit::primaryDomain): Deleted.
300
301 2017-07-11  Timothy Hatcher  <timothy@hatcher.name>
302
303         Fix a build failure in WebDragClient when !PLATFORM(COCOA) && !PLATFORM(GTK).
304         https://bugs.webkit.org/show_bug.cgi?id=174372
305
306         Reviewed by Beth Dakin.
307
308         * WebProcess/WebCoreSupport/WebDragClient.cpp:
309         (WebKit::WebDragClient::didConcludeEditDrag): Added empty method.
310
311 2017-07-11  Brent Fulgham  <bfulgham@apple.com>
312
313         Reset cookie partitioning state after network process crashes
314         https://bugs.webkit.org/show_bug.cgi?id=174306
315         <rdar://problem/33171605>
316
317         Reviewed by Chris Dumez.
318
319         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
320         (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler): Move cookie
321         partioning state code to helper function.
322         (WebKit::ResourceLoadStatisticsStore::resetPartitionCookiesState): Added.
323         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
324         * UIProcess/WebProcessPool.cpp:
325         (WebKit::WebProcessPool::ensureNetworkProcess): Inform the statistics store that
326         the network process crashed.
327         (WebKit::WebProcessPool::terminateNetworkProcess): Mark network process as crashed.
328         * UIProcess/WebResourceLoadStatisticsStore.cpp:
329         (WebKit::WebResourceLoadStatisticsStore::networkProcessDidCrash): Reset the cookie
330         partitioning state after a crash.
331         * UIProcess/WebResourceLoadStatisticsStore.h:
332         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
333         (WebKit::WebsiteDataStore::notifyResourceLoadStatisticsNetworkProcessDidCrash): Relay
334         information to the statistics store.
335         * UIProcess/WebsiteData/WebsiteDataStore.h:
336
337 2017-07-11  Timothy Hatcher  <timothy@hatcher.name>
338
339         Fix broken build when !ENABLE(INDEXED_DATABASE)
340         https://bugs.webkit.org/show_bug.cgi?id=174370
341
342         Reviewed by Alex Christensen.
343
344         * UIProcess/WebProcessPool.cpp:
345         (WebKit::WebProcessPool::pageAddedToProcess):
346
347 2017-07-11  Youenn Fablet  <youenn@apple.com>
348
349         Changing the web page muted state for playing audio should not disable other tabs capture
350         https://bugs.webkit.org/show_bug.cgi?id=174349
351
352         Unreviewed.
353
354         * UIProcess/WebPageProxy.cpp:
355         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage): Fixes non MEDIA_STREAM builds.
356
357 2017-07-11  Wenson Hsieh  <wenson_hsieh@apple.com>
358
359         Address post-review feedback after http://trac.webkit.org/r219310
360         https://bugs.webkit.org/show_bug.cgi?id=174300
361         <rdar://problem/33030639>
362
363         Reviewed by Simon Fraser.
364
365         Removes plumbing introduced in r219310 for telling WKContentView when the user has finished panning or zooming.
366         This was previously used to reset allowing asynchronous touch event after preventing the web touch events
367         gesture recognizer from firing.
368
369         However, a far simpler (and much less fragile) solution is to just set _canSendTouchEventsAsynchronously to NO
370         at the beginning of the gesture, before the first `touchstart` event is dispatched. This way, we always ensure
371         that _canSendTouchEventsAsynchronously is NO when beginning to process a touch event. This approach is correct
372         because the only place where we query _canSendTouchEventsAsynchronously is in -_webTouchEventsRecognized:, where
373         (when we are beginning a new gesture) we are guaranteed that -gestureRecognizer:shouldIgnoreWebTouchWithEvent:
374         has already been called and _canSendTouchEventsAsynchronously is NO.
375
376         Confirmed that the LayoutTests added in r219310 still pass.
377
378         * UIProcess/API/Cocoa/WKWebView.mm:
379         (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
380         (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
381         * UIProcess/PageClient.h:
382         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
383         * UIProcess/Scrolling/RemoteScrollingTree.cpp:
384         (WebKit::RemoteScrollingTree::scrollingTreeNodeDidEndPanGesture): Deleted.
385         * UIProcess/Scrolling/RemoteScrollingTree.h:
386         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
387         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
388         (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
389         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewDidEndPanGesture): Deleted.
390         * UIProcess/WebPageProxy.h:
391         * UIProcess/ios/PageClientImplIOS.h:
392         * UIProcess/ios/PageClientImplIOS.mm:
393         (WebKit::PageClientImpl::overflowScrollViewDidEndPanGesture): Deleted.
394         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
395         (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidEndPanGesture): Deleted.
396         * UIProcess/ios/WKContentViewInteraction.h:
397         * UIProcess/ios/WKContentViewInteraction.mm:
398         (-[WKContentView gestureRecognizer:shouldIgnoreWebTouchWithEvent:]):
399         (-[WKContentView scrollViewDidEndPanOrPinchGesture]): Deleted.
400         * UIProcess/ios/WebPageProxyIOS.mm:
401         (WebKit::WebPageProxy::overflowScrollViewDidEndPanGesture): Deleted.
402
403 2017-07-11  Brent Fulgham  <bfulgham@apple.com>
404
405         Unreviewed clean-up after r219323
406
407         Simplify algorithm slightly based on a suggestion Chris Dumez made in the review.
408
409         * UIProcess/WebResourceLoadStatisticsStore.cpp:
410         (WebKit::pruneResources): Don't create a second variable to track the pruning operation.
411
412 2017-07-11  Alex Christensen  <achristensen@webkit.org>
413
414         SharedBuffer::size should return a size_t
415         https://bugs.webkit.org/show_bug.cgi?id=174328
416
417         Reviewed by Andreas Kling.
418
419         * UIProcess/WebResourceLoadStatisticsStore.cpp:
420         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
421
422 2017-07-11  Youenn Fablet  <youenn@apple.com>
423
424         We should do ICE candidate filtering at the Document level
425         https://bugs.webkit.org/show_bug.cgi?id=173861
426         <rdar://problem/33122058>
427
428         Reviewed by Eric Carlson.
429
430         Removing ICE candidate filtering handling at UIProcess level.
431         ICE candidate filtering is now disabled at UserMediaRequest level.
432         WebPage forwards the ICE candidate filtering option to the page so as to set
433         the default option correctly for every document of the page.
434
435         * UIProcess/UserMediaProcessManager.cpp:
436         (WebKit::UserMediaProcessManager::willCreateMediaStream):
437         (WebKit::UserMediaProcessManager::endedCaptureSession):
438         * WebProcess/WebPage/WebPage.cpp:
439         (WebKit::WebPage::disableICECandidateFiltering):
440         (WebKit::WebPage::enableICECandidateFiltering):
441
442 2017-07-11  Youenn Fablet  <youenn@apple.com>
443
444         Changing the web page muted state for playing audio should not disable other tabs capture
445         https://bugs.webkit.org/show_bug.cgi?id=174349
446         rdar://problem/33223988
447
448         Reviewed by Eric Carlson.
449
450         Make sure to mute capturing streams of any other tab if the current tab will start capturing or will unmute existing capturing streams.
451         Manually tested by having a tab doing capture and another tab playing a video.
452         Muting or unmuting the tab playing video should not change the capture tab.
453
454         * UIProcess/WebPageProxy.cpp:
455         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage):
456         (WebKit::WebPageProxy::setMuted):
457         * UIProcess/WebPageProxy.h:
458         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage):
459
460 2017-07-11  Youenn Fablet  <youenn@apple.com>
461
462         NetworkProcess should close listening WebRTC sockets when being suspended
463         https://bugs.webkit.org/show_bug.cgi?id=174270
464         rdar://problem/33139844
465
466         Reviewed by Chris Dumez.
467
468         To prevent potential spinning of the NetworkProcess, NetworkProcess will now close listening sockets when being notified that it will be suspended.
469         When the network process is being suspended, it will stop creating listening sockets, until it resumes.
470         Future additional efforts might be to improve select/cancel so that we can stop listening sockets at resume time,
471         or to reimplement part of the stack using CFStream.
472
473         Tested through manual testing by going to a website doing WebRTC, homing out so that the network process is suspended and reopening Safari.
474
475         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
476         (WebKit::NetworkConnectionToWebProcess::cleanupForSuspension):
477         Proxying call to clean for suspension to rtc provider so that it will
478         close listening sockets.
479         (WebKit::NetworkConnectionToWebProcess::resumeFromSuspension): Authorizing back listening sockets.
480         * NetworkProcess/NetworkConnectionToWebProcess.h:
481         (WebKit::NetworkConnectionToWebProcess::cleanupForSuspension):
482         Clean-up is done asynchronously as it can happen in background threads.
483         Hence why passing a callback as parameter.
484         * NetworkProcess/NetworkProcess.cpp:
485         (WebKit::NetworkProcess::notifyProcessReadyToSuspend): Helper routine
486         to notify UI process that network process clean up is done.
487         (WebKit::TaskCounter::TaskCounter): Helper class to call notifyProcessReadyToSuspend when sded.
488         (WebKit::TaskCounter::~TaskCounter):
489         (WebKit::NetworkProcess::actualPrepareToSuspend): Doing the clean-up for each connection that needs it.
490         Making sure to notify UI process of clean-up being completed once all connections are cleaned.
491         (WebKit::NetworkProcess::processWillSuspendImminently):
492         (WebKit::NetworkProcess::prepareToSuspend):
493         (WebKit::NetworkProcess::processDidResume): Reenable listening sockets.
494         * NetworkProcess/NetworkProcess.h:
495         * NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
496         (WebKit::LibWebRTCSocketClient::LibWebRTCSocketClient):
497         * NetworkProcess/webrtc/LibWebRTCSocketClient.h: Adding type getter and making close public.
498         Used by NetworkRTCProvider to identifiy listening sockets and close them.
499         * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
500         (WebKit::NetworkRTCProvider::closeListeningSockets): We close the webrtc socket
501         and we also notify the Web Process that the socket is closed so that it can take actions to recreate some if needed.
502         (WebKit::NetworkRTCProvider::finishClosingListeningSockets):
503         * NetworkProcess/webrtc/NetworkRTCProvider.h:
504         (WebKit::NetworkRTCProvider::authorizeListeningSockets): Authorize creation of listening sockets.
505
506 2017-07-10  Brent Fulgham  <bfulgham@apple.com>
507
508         Resource Load Statistics: Prune statistics in orders of importance
509         https://bugs.webkit.org/show_bug.cgi?id=174215
510         <rdar://problem/33164403>
511
512         Unreviewed test correction.
513
514         * UIProcess/WebResourceLoadStatisticsStore.cpp:
515         (WebKit::pruneResources): The revised algorithm did not update the remaining
516         count to be pruned, causing a test failure.
517
518 2017-07-10  John Wilander  <wilander@apple.com>
519
520         Resource Load Statistics: Prune statistics in orders of importance
521         https://bugs.webkit.org/show_bug.cgi?id=174215
522         <rdar://problem/33164403>
523
524         Reviewed by Chris Dumez.
525
526         New functionality. Prunes statistics in this order:
527         1. Non-prevalent resources without user interaction.
528         2. Prevalent resources without user interaction.
529         3. Non-prevalent resources with user interaction.
530         4. Prevalent resources with user interaction.
531
532         * Shared/WebCoreArgumentCoders.cpp:
533         (IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
534         (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
535             Added timestamp field lastSeen.
536         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
537         (-[WKWebsiteDataStore _resourceLoadStatisticsSetLastSeen:forHost:]):
538         (-[WKWebsiteDataStore _resourceLoadStatisticsSetMaxStatisticsEntries:]):
539         (-[WKWebsiteDataStore _resourceLoadStatisticsSetPruneEntriesDownTo:]):
540         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
541             Test infrastructure.
542         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
543         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
544         (WebKit::ResourceLoadStatisticsStore::setMaxStatisticsEntries):
545             Test infrastructure.
546         (WebKit::ResourceLoadStatisticsStore::setPruneEntriesDownTo):
547             Test infrastructure.
548         (WebKit::sortAndPrune):
549             Convenience function.
550         (WebKit::ResourceLoadStatisticsStore::pruneStatisticsIfNeeded):
551             The new pruning function.
552         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
553         * UIProcess/WebResourceLoadStatisticsStore.cpp:
554         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
555             Now calls ResourceLoadStatisticsStore::pruneStatisticsIfNeeded().
556         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
557             Test infrastructure.
558         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
559             Test infrastructure.
560         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
561             Test infrastructure.
562         * UIProcess/WebResourceLoadStatisticsStore.h:
563
564 2017-07-10  Dean Jackson  <dino@apple.com>
565
566         const() experimental feature should always be on by default
567         https://bugs.webkit.org/show_bug.cgi?id=174341
568         <rdar://problem/33228603>
569
570         Reviewed by Simon Fraser.
571
572         Even though this is experimental, it should be enabled by default, and
573         not follow the value of DEFAULT_EXPERIMENTAL_FEATURES_ENABLED.
574
575         * Shared/WebPreferencesDefinitions.h:
576
577 2017-07-10  Chris Dumez  <cdumez@apple.com>
578
579         [iOS] _didCommitLayerTree should avoid calling [scrollView setZoomScale] unnecessarily
580         https://bugs.webkit.org/show_bug.cgi?id=174326
581         <rdar://problem/33150490>
582
583         Reviewed by Simon Fraser.
584
585         Only call [scrollView setZoomScale] if the new zoom scale is actually different to
586         avoid doing unnecessary work in UIKit.
587
588         * UIProcess/API/Cocoa/WKWebView.mm:
589         (-[WKWebView _didCommitLayerTree:]):
590
591 2017-07-10  Chris Dumez  <cdumez@apple.com>
592
593         Merge ResourceLoadStatisticsStore into WebResourceLoadStatisticsStore
594         https://bugs.webkit.org/show_bug.cgi?id=174203
595
596         Reviewed by Brent Fulgham.
597
598         Merge ResourceLoadStatisticsStore into WebResourceLoadStatisticsStore. The 2 classes
599         have a similar purpose and there is no clean separation between the 2. It makes more
600         sense to have a single store class for resource load statistics.
601
602         If we want to simplify the WebResourceLoadStatisticsStore class, I think it'd make
603         more sense to split the file system I/O code out. This code adds quite a bit of
604         complexity.
605
606         * CMakeLists.txt:
607         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
608         (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]):
609         (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]):
610         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore]):
611         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:]):
612         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
613         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp: Removed.
614         * UIProcess/Storage/ResourceLoadStatisticsStore.h: Removed.
615         * UIProcess/WebResourceLoadStatisticsStore.cpp:
616         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
617         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
618         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
619         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
620         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
621         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
622         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
623         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
624         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
625         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
626         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
627         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
628         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
629         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
630         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
631         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
632         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
633         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
634         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
635         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
636         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
637         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
638         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate):
639         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
640         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemory):
641         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
642         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
643         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
644         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
645         (WebKit::WebResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
646         (WebKit::WebResourceLoadStatisticsStore::createEncoderFromData):
647         (WebKit::WebResourceLoadStatisticsStore::populateFromDecoder):
648         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
649         (WebKit::WebResourceLoadStatisticsStore::mergeStatistics):
650         (WebKit::WebResourceLoadStatisticsStore::shouldPartitionCookies):
651         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
652         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
653         (WebKit::WebResourceLoadStatisticsStore::processStatistics):
654         (WebKit::WebResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction):
655         (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
656         (WebKit::WebResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
657         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
658         * UIProcess/WebResourceLoadStatisticsStore.h:
659         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
660         (WebKit::sortedPrevalentResourceTelemetry):
661         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
662         * UIProcess/WebResourceLoadStatisticsTelemetry.h:
663         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
664         (WebKit::WebsiteDataStore::removeData):
665         * WebKit2.xcodeproj/project.pbxproj:
666
667 2017-07-10  Wenson Hsieh  <wenson_hsieh@apple.com>
668
669         [WK2] Ignore touch events that interrupt platform-driven momentum scrolling
670         https://bugs.webkit.org/show_bug.cgi?id=174300
671         <rdar://problem/33030639>
672
673         Reviewed by Simon Fraser.
674
675         Adds support for immediately failing WKContentView's UIWebTouchEventsGestureRecognizer if any touch interrupts
676         scroll view deceleration. Covered by 3 new LayoutTests (see Source/WebCore/ChangeLog).
677
678         * Platform/spi/ios/UIKitSPI.h:
679         * UIProcess/API/Cocoa/WKWebView.mm:
680         (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
681         (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
682         * UIProcess/PageClient.h:
683         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
684         * UIProcess/Scrolling/RemoteScrollingTree.cpp:
685         (WebKit::RemoteScrollingTree::scrollingTreeNodeDidEndPanGesture):
686         * UIProcess/Scrolling/RemoteScrollingTree.h:
687         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
688         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
689         (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
690         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewDidEndPanGesture):
691
692         Adds plumbing in the UI process to alert the WKContentView when scroll view dragging has ended in an overflow
693         momentum scrolling region (tracked by an overflow scrolling tree node). This parallels UI process plumbing for
694         ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewWillStartPanGesture.
695
696         * UIProcess/WebPageProxy.h:
697         * UIProcess/ios/PageClientImplIOS.h:
698         * UIProcess/ios/PageClientImplIOS.mm:
699         (WebKit::PageClientImpl::overflowScrollViewDidEndPanGesture):
700         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
701         (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidEndPanGesture):
702         * UIProcess/ios/WKContentViewInteraction.h:
703         * UIProcess/ios/WKContentViewInteraction.mm:
704         (-[WKContentView scrollViewDidEndPanOrPinchGesture]):
705
706         When the dragging phase of a scroll gesture ends, ensure that _canSendTouchEventsAsynchronously is reset to NO.
707         When touches are not being prevented, this flag is set to YES in -scrollViewWillStartPanOrPinchGesture: and
708         normally reset to NO in -_webTouchEventsRecognized: after all touch points have been released. However, in the
709         case where we've prematurely failed the web touch events gesture recognizer after -touchesBegan:,
710         -_webTouchEventsRecognized: will not be called again in a state where all touches have been released. Thus, we
711         also need to bookend the place where we begin allowing async touch event dispatch in
712         -scrollViewWillStartPanOrPinchGesture by disallowing async touch event dispatch in
713         -scrollViewDidEndPanOrPinchGesture.
714
715         This has no impact in the normal case where the user scrolls without momentum, since
716         -scrollViewDidEndPanOrPinchGesture will fire after async touch events have already been disallowed in
717         -_webTouchEventsRecognized:, and in the case where the page prevents default on touches, scrolling doesn't
718         happen anyways, so neither scrollViewWillStartPanOrPinchGesture nor scrollViewDidEndPanOrPinchGesture will be
719         invoked.
720
721         (-[WKContentView gestureRecognizer:shouldIgnoreWebTouchWithEvent:]):
722
723         Implements a new SPI hook in UIKit. This serves an identical purpose as -shouldIgnoreWebTouch, but additionally
724         passes the triggering UIEvent, as well as the gesture recognizer itself (following standard convention for
725         Objective C delegate methods). Here, we return YES in the case where one or more of the touches recognized by
726         the gesture is currently interrupting scroll deceleration.
727
728         * UIProcess/ios/WebPageProxyIOS.mm:
729         (WebKit::WebPageProxy::overflowScrollViewDidEndPanGesture):
730
731 2017-07-10  Brent Fulgham  <bfulgham@apple.com>
732
733         [WK2][macOS] Allow access to com.apple.cfnetwork.cfnetworkagent in the Network Process
734         https://bugs.webkit.org/show_bug.cgi?id=174320
735         <rdar://problem/33191856>
736
737         Reviewed by Geoffrey Garen.
738
739         * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
740
741 2017-07-10  Megan Gardner  <megan_gardner@apple.com>
742
743         Add location to NavigationActionData
744         https://bugs.webkit.org/show_bug.cgi?id=174233
745         <rdar://problem/29165518>
746
747         Reviewed by Simon Fraser.
748         
749         Add the root view location of a tap to a NavigationAction to vend to Safari.
750
751         * Shared/NavigationActionData.cpp:
752         (WebKit::NavigationActionData::encode):
753         (WebKit::NavigationActionData::decode):
754         * Shared/NavigationActionData.h:
755         * UIProcess/API/APINavigationAction.h:
756         * UIProcess/API/Cocoa/WKNavigationAction.mm:
757         (-[WKNavigationAction description]):
758         (-[WKNavigationAction _clickLocationInRootViewCoordinates]):
759         * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
760         * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
761         (WebKit::clickLocationInRootViewCoordinatesForMouseEvent):
762         (WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinatesForNavigationAction):
763         (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
764         * WebProcess/InjectedBundle/InjectedBundleNavigationAction.h:
765         (WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinates):
766         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
767         (WebKit::WebChromeClient::createWindow):
768         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
769         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
770         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
771
772 2017-07-03  Brian Burg  <bburg@apple.com>
773
774         Web Replay: remove some unused code
775         https://bugs.webkit.org/show_bug.cgi?id=173903
776
777         Rubber-stamped by Joseph Pecoraro.
778
779         * Configurations/FeatureDefines.xcconfig:
780         * WebProcess/WebPage/WebPage.cpp:
781         (WebKit::WebPage::tryClose):
782         (WebKit::WebPage::loadRequest):
783         (WebKit::WebPage::stopLoadingFrame):
784         (WebKit::WebPage::stopLoading):
785         (WebKit::WebPage::reload):
786         (WebKit::WebPage::contextMenuAtPointInWindow):
787         (WebKit::handleContextMenuEvent):
788         (WebKit::handleMouseEvent):
789         (WebKit::handleWheelEvent):
790         (WebKit::handleKeyEvent):
791         (WebKit::WebPage::scroll):
792         (WebKit::WebPage::logicalScroll):
793
794 2017-07-10  Chris Dumez  <cdumez@apple.com>
795
796         Further WebResourceLoadStatisticsStore / ResourceLoadStatisticsStore clean up
797         https://bugs.webkit.org/show_bug.cgi?id=174301
798
799         Reviewed by Brent Fulgham.
800
801         General clean up and various simplifications / optimizations to WebResourceLoadStatisticsStore
802         and ResourceLoadStatisticsStore classes.
803
804         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
805         (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]):
806         (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]):
807         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
808         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
809         (WebKit::ResourceLoadStatisticsStore::create):
810         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
811         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
812         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
813         (WebKit::ResourceLoadStatisticsStore::populateFromDecoder):
814         (WebKit::ResourceLoadStatisticsStore::clearInMemory):
815         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
816         (WebKit::ResourceLoadStatisticsStore::updateCookiePartitioning):
817         (WebKit::ResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
818         (WebKit::ResourceLoadStatisticsStore::processStatistics):
819         (WebKit::ResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction):
820         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
821         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
822         * UIProcess/WebResourceLoadStatisticsStore.cpp:
823         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
824         (WebKit::WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore):
825         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
826         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
827         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
828         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
829         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
830         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
831         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
832         (WebKit::WebResourceLoadStatisticsStore::resourceLogFilePath):
833         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
834         (WebKit::WebResourceLoadStatisticsStore::scheduleOrWriteStoreToDisk):
835         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
836         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
837         (WebKit::WebResourceLoadStatisticsStore::platformExcludeFromBackup):
838         (WebKit::WebResourceLoadStatisticsStore::createDecoderFromDisk):
839         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
840         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
841         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
842         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
843         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
844         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
845         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
846         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
847         (WebKit::WebResourceLoadStatisticsStore::setDataRecordsBeingRemoved):
848         * UIProcess/WebResourceLoadStatisticsStore.h:
849         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
850         (WebKit::sortedPrevalentResourceTelemetry):
851         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
852         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
853         (WebKit::WebsiteDataStore::updateCookiePartitioningForTopPrivatelyOwnedDomains):
854         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
855         * UIProcess/WebsiteData/WebsiteDataStore.h:
856
857 2017-07-10  Michael Catanzaro  <mcatanzaro@igalia.com>
858
859         [SOUP] Remove WebKitSoupCookieJarSqlite
860         https://bugs.webkit.org/show_bug.cgi?id=174310
861
862         Reviewed by Carlos Garcia Campos.
863
864         It seems WebKitSoupCookieJarSqlite uses exactly the same database format as the upstream
865         SoupCookieJarDb class. WebKitSoupCookieJarSqlite is a copy of SoupCookieJarSqlite that uses
866         WebCore's SQLite wrapper and WTF stuff. WebKitSoupCookieJarSqlite exists only because
867         SoupCookieJarDb is relatively new, and the older SoupCookieJarSqlite class existed only in
868         libsoup-gnome rather than libsoup proper. The advantage of continuing to use our
869         WebKitSoupCookieJarSqlite class, besides that we already know it works, is that it utilizes
870         the same SQLiteDatabase class that is used elsewhere in WebKit. But that's not really any
871         reason to keep the class around, when SoupCookieJarDb does exactly the same thing. It was
872         introduced in libsoup 2.42 and that is already our minimum required version, so we can
873         switch now.
874
875         This passes a quick sanity-check of Epiphany's cookies dialog and also TestCookieManager.
876
877         * PlatformGTK.cmake:
878         * PlatformWPE.cmake:
879         * WebProcess/Cookies/soup/WebCookieManagerSoup.cpp:
880         (WebKit::WebCookieManager::setCookiePersistentStorage):
881         * WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.cpp: Removed.
882         * WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.h: Removed.
883
884 2017-07-10  Myles C. Maxfield  <mmaxfield@apple.com>
885
886         REGRESSION(r213590): UI process updates the visible content rects more often than it did in iOS 10
887         https://bugs.webkit.org/show_bug.cgi?id=174282
888         <rdar://problem/33144344>
889
890         Reviewed by Simon Fraser.
891
892         In r213590, we accidentally refactored -[WKWebView _didCommitLayerTree:] to call _scheduleVisibleContentRectUpdate
893         more often. Instead, this should be triggered from inside the "if" statements. 
894
895         No tests because there is no behavior change. Performance change is tested in MotionMark.
896
897         * UIProcess/API/Cocoa/WKWebView.mm:
898         (-[WKWebView _isShowingVideoPictureInPicture]):
899         (-[WKWebView _initializeWithConfiguration:]):
900         (-[WKWebView goBack]):
901         (-[WKWebView _didCommitLayerTree:]):
902         (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
903         (-[WKWebView _zoomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]):
904         (-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
905         (-[WKWebView scrollViewDidScroll:]):
906         (-[WKWebView _visibleContentRect]):
907         (-[WKWebView _frameOrBoundsChanged]):
908         (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
909         (-[WKWebView _updateVisibleContentRects]):
910         (-[WKWebView _navigationGestureDidBegin]):
911         (-[WKWebView _reloadWithoutContentBlockers]):
912         (-[WKWebView _reloadExpiredOnly]):
913         (-[WKWebView _setObscuredInsets:]):
914         (-[WKWebView _setUnobscuredSafeAreaInsets:]):
915         (-[WKWebView _endAnimatedResize]):
916         (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
917         (-[WKWebView _clearOverrideLayoutParameters]):
918         (-[WKWebView _requestActivatedElementAtPosition:completionBlock:]):
919         (-[WKWebView _propertiesOfLayerWithID:]):
920
921 2017-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
922
923         [SOUP] SoupCookieJar is never released (resulting in sqlite temp files lying around)
924         https://bugs.webkit.org/show_bug.cgi?id=166029
925
926         Reviewed by Michael Catanzaro.
927
928         Clear the SoupNetworkSession and cookie storage after the main loop quits.
929
930         * NetworkProcess/soup/NetworkProcessMainSoup.cpp:
931         (WebKit::NetworkProcessMainUnix):
932
933 2017-07-10  Wenson Hsieh  <wenson_hsieh@apple.com>
934
935         [WK2] Action sheets for links fail to present in WebKit2 PDF view
936         https://bugs.webkit.org/show_bug.cgi?id=174307
937         <rdar://problem/31412128>
938
939         Reviewed by Tim Horton.
940
941         Currently, presenting an action sheet for a link always uses the WKActionSheetPresentAtClosestIndicatorRect
942         codepath, which requires text indicator data for the link. However, when showing an action sheet for a link via
943         WKPDFView, a text indicator for the link is not included, so the popover rect ends up being an empty rect at the
944         origin, which causes us to bail from presenting the popover.
945
946         To address this, we tweak our heuristic for determining which action sheet presentation style to use, so that we
947         only use the closest indicator rect for a link if the text indicator data is also present (otherwise, we fall
948         back to using the element rect). All other behavior is the same.
949
950         * UIProcess/ios/WKActionSheetAssistant.mm:
951         (-[WKActionSheetAssistant showImageSheet]):
952         (presentationStyleForView):
953
954         Refactor _shouldPresentAtTouchLocationForElementRect into presentationStyleForView, a static function that
955         returns a WKActionSheetPresentationStyle.
956
957         (-[WKActionSheetAssistant showLinkSheet]):
958         (-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]): Deleted.
959
960 2017-07-09  Brady Eidson  <beidson@apple.com>
961
962         Remove some obsolete WebKitVersionChecks.
963         https://bugs.webkit.org/show_bug.cgi?id=174294
964
965         Reviewed by Dan Bernstein.
966
967         * WebProcess/WebPage/WebPage.cpp:
968         (WebKit::WebPage::updatePreferences):
969
970 2017-07-08  Chris Dumez  <cdumez@apple.com>
971
972         Simplify WebResourceLoadStatisticsStore / ResourceLoadStatisticsStore
973         https://bugs.webkit.org/show_bug.cgi?id=174290
974
975         Reviewed by Brent Fulgham.
976
977         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
978         (-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]):
979         (-[WKWebsiteDataStore _resourceLoadStatisticsSubmitTelemetry]):
980         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
981         Rename a couple of functions in the Cocoa SPI for clarity and to match the name
982         of their internal implementation.
983
984         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
985         (WebKit::ResourceLoadStatisticsStore::create):
986         (WebKit::ResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
987         Stylistic changes.
988
989         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
990         Make const.
991
992         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
993         Use HashMap::add() instead of HashMap::set(). There is not supposed to have any duplicate
994         keys so add() is sufficient and more efficient.
995
996         (WebKit::ResourceLoadStatisticsStore::clearInMemoryAndPersistent): Removed.
997         clearInMemoryAndPersistent() was only called from WebResourceLoadStatisticsStore and
998         the m_deletePersistentStoreHandler / m_grandfatherExistingWebsiteDataHandler were both
999         set by the WebResourceLoadStatisticsStore as well. Therefore, we don't really need this
1000         function, WebResourceLoadStatisticsStore now calls ResourceLoadStatisticsStore::clearInMemory()
1001         instead and takes care of doing what the m_deletePersistentStoreHandler /
1002         m_grandfatherExistingWebsiteDataHandler handlers were doing on its side.
1003
1004         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
1005         Pass Vector as rvalue reference, as a preparation for a future optimization. Added FIXME
1006         comment about the optimization.
1007
1008         (WebKit::ResourceLoadStatisticsStore::setNotificationCallback): Removed.
1009         (WebKit::ResourceLoadStatisticsStore::setGrandfatherExistingWebsiteDataCallback): Removed.
1010         (WebKit::ResourceLoadStatisticsStore::setDeletePersistentStoreCallback): Removed.
1011         (WebKit::ResourceLoadStatisticsStore::setFireTelemetryCallback): Removed.
1012         Drop those callback setters. WebResourceLoadStatisticsStore is the only client of
1013         ResourceLoadStatisticsStore and those callbacks were always called as a result of
1014         an operation requested by the WebResourceLoadStatisticsStore. Therefore, those are
1015         not needed. WebResourceLoadStatisticsStore can take care of doing what those
1016         callbacks were doing on its side.
1017
1018         (WebKit::ResourceLoadStatisticsStore::processStatistics):
1019         Pass parameter by const reference since we clearly do not intend to transfer ownership of it.
1020
1021         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
1022         (WebKit::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
1023         (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
1024         Stylistic changes.
1025
1026         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords): Removed.
1027         (WebKit::ResourceLoadStatisticsStore::dataRecordsBeingRemoved): Removed.
1028         (WebKit::ResourceLoadStatisticsStore::dataRecordsWereRemoved): Removed.
1029         Those were moved to WebResourceLoadStatisticsStore since they do not require
1030         any access to the statistics, and are only used by WebResourceLoadStatisticsStore.
1031
1032         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1033
1034         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1035         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1036         Store registering most callbacks on the coreStore. Instead, the logic of those
1037         callbacks is now inlined in the few methods in WebResourceLoadStatisticsStore
1038         that were causing these callbacks to be called.
1039
1040         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
1041         Access some methods on WebResourceLoadStatisticsStore instead of the coreStore
1042         since those were moved.
1043
1044         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
1045         Drop unnecessary mutable for lambda.
1046
1047         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
1048         Pass parameter as rvalue reference as a preparation for a future optimization.
1049
1050         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsFileChangedSinceLastSync):
1051         Make const.
1052
1053         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
1054         Add assertion to make sure this is called on the main thread.
1055
1056         (WebKit::WebResourceLoadStatisticsStore::fireDataModificationHandler): Removed.
1057         This was dispatching to a background queue to call fireDataModificationHandler()
1058         on the ResourceLoadStatisticsStore. The coreStore would then dispatch back on the
1059         main thread to call the WebResourceLoadStatisticsStore's modification handler.
1060         This modification handler was merely calling processStatisticsAndDataRecords().
1061         Therefore, callers of WebResourceLoadStatisticsStore::fireDataModificationHandler()
1062         can call WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() directly
1063         instead.
1064
1065         (WebKit::WebResourceLoadStatisticsStore::fireTelemetryHandler): Removed.
1066         This was calling ResourceLoadStatisticsStore::fireTelemetryHandler(), which was
1067         calling back WebResourceLoadStatisticsStore's fireTelemetryHandler. The handler
1068         in question was merely calling submitTelemetry(). Therefore, callers of
1069         WebResourceLoadStatisticsStore::fireTelemetryHandler() can call
1070         WebResourceLoadStatisticsStore::submitTelemetry() directly instead.
1071
1072         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
1073         Call ResourceLoadStatisticsStore::clearInMemory() instead of clearInMemoryAndPersistent(),
1074         which was removed. ResourceLoadStatisticsStore::clearInMemoryAndPersistent() was calling
1075         clearInMemory() and then 2 of WebResourceLoadStatisticsStore's handlers. Instead, we now
1076         call the functions that those handlers were calling directly, thus eliminating the need
1077         for those handlers.
1078
1079         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
1080         Set m_minimumTimeBetweenDataRecordsRemoval directly as it is now store on this class
1081         instead of the coreStore.
1082
1083         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
1084         (WebKit::WebResourceLoadStatisticsStore::dataRecordsBeingRemoved):
1085         (WebKit::WebResourceLoadStatisticsStore::dataRecordsWereRemoved):
1086         Those were merely moved from the ResourceLoadStatisticsStore.
1087
1088         * UIProcess/WebResourceLoadStatisticsStore.h:
1089
1090         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
1091         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
1092         Check for sortedPrevalentResources.isEmpty() instead of checking if the size
1093         if less than minimumPrevalentResourcesForTelemetry.
1094         ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry() either returns
1095         an empty vector or a vector with more than minimumPrevalentResourcesForTelemetry
1096         items. Therefore, there is no need to expose minimumPrevalentResourcesForTelemetry.
1097
1098 2017-07-08  Yusuke Suzuki  <utatane.tea@gmail.com>
1099
1100         Drop NOSNIFF compile flag
1101         https://bugs.webkit.org/show_bug.cgi?id=174289
1102
1103         Reviewed by Michael Catanzaro.
1104
1105         * Configurations/FeatureDefines.xcconfig:
1106
1107 2017-07-07  Chris Dumez  <cdumez@apple.com>
1108
1109         [WK2] Use a rolling 30-day uptime for processing statistics
1110         https://bugs.webkit.org/show_bug.cgi?id=174235
1111         <rdar://problem/33164381>
1112
1113         Reviewed by Brent Fulgham.
1114
1115         Follow-up fix for r219274 because it caused this test to time out:
1116         http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
1117
1118         The test sets TimeToLiveUserInteraction to 0 so our implementation cannot use
1119         0 as magic value to see if it was set. Instead, use std::optional.
1120
1121         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1122         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
1123         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1124         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1125         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired):
1126         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1127         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1128         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1129         * UIProcess/WebResourceLoadStatisticsStore.h:
1130
1131 2017-07-07  Brent Fulgham  <bfulgham@apple.com>
1132
1133         [WK2] Use a rolling 30-day uptime for processing statistics
1134         https://bugs.webkit.org/show_bug.cgi?id=174235
1135         <rdar://problem/33164381>
1136
1137         Reviewed by Chris Dumez.
1138
1139         * UIProcess/API/Cocoa/WKWebsiteDataStore.cpp:
1140         (WebKit::WKWebsiteDataStore::_resourceLoadStatisticsResetToConsistentState): Initialize time-to-live to zero by default.
1141         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1142         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData): Write out vector
1143         of operating dates.
1144         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder): Read in vector of
1145         operating dates.
1146         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction): Check new
1147         convenience method.
1148         (WebKit::ResourceLoadStatisticsStore::markTodayAsOperatingDate): Added.
1149         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired): Added.
1150         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1151         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1152         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded): When reading
1153         a new data file, update the current operating date (if needed).
1154         (WebKit::WebResourceLoadStatisticsStore::handleDailyTasks): Roll uptime dates as
1155         needed, then handle telemetry.
1156         * UIProcess/WebResourceLoadStatisticsStore.h:
1157
1158 2017-07-07  Wenson Hsieh  <wenson_hsieh@apple.com>
1159
1160         [iOS DnD] For cross-app drags, 'drop' event handlers are never invoked if dataTransfer.dropEffect is not set while dragging
1161         https://bugs.webkit.org/show_bug.cgi?id=174219
1162         <rdar://problem/32083177>
1163
1164         Reviewed by Ryosuke Niwa.
1165
1166         Tweak some testing SPI to return a drop operation flag instead of whether or not the drop operation was not
1167         UIDropOperationCancel.
1168
1169         * UIProcess/API/Cocoa/WKWebView.mm:
1170         (-[WKWebView _simulateDataInteractionUpdated:]):
1171         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1172         * UIProcess/ios/WKContentViewInteraction.h:
1173         * UIProcess/ios/WKContentViewInteraction.mm:
1174         (-[WKContentView _simulateDataInteractionUpdated:]):
1175
1176 2017-07-07  Commit Queue  <commit-queue@webkit.org>
1177
1178         Unreviewed, rolling out r219238, r219239, and r219241.
1179         https://bugs.webkit.org/show_bug.cgi?id=174265
1180
1181         "fast/workers/dedicated-worker-lifecycle.html is flaky"
1182         (Requested by yusukesuzuki on #webkit).
1183
1184         Reverted changesets:
1185
1186         "[WTF] Implement WTF::ThreadGroup"
1187         https://bugs.webkit.org/show_bug.cgi?id=174081
1188         http://trac.webkit.org/changeset/219238
1189
1190         "Unreviewed, build fix after r219238"
1191         https://bugs.webkit.org/show_bug.cgi?id=174081
1192         http://trac.webkit.org/changeset/219239
1193
1194         "Unreviewed, CLoop build fix after r219238"
1195         https://bugs.webkit.org/show_bug.cgi?id=174081
1196         http://trac.webkit.org/changeset/219241
1197
1198 2017-07-07  Antti Koivisto  <antti@apple.com>
1199
1200         WKWebSiteDataStore.removeDataOfTypes should wait until disk cache files are actually removed before invoking completion handler
1201         https://bugs.webkit.org/show_bug.cgi?id=174224
1202         <rdar://problem/33067545>
1203
1204         Reviewed by Sam Weinig.
1205
1206         Currently we dispatch file deletion operations to a background queue and call the completion
1207         handler without waiting for the I/O to complete.
1208
1209         * NetworkProcess/NetworkProcess.cpp:
1210         (WebKit::clearDiskCacheEntries):
1211
1212             Call a new version of NetworkCache::remove() for bulk deletion.
1213             Note that it is fine to call this with an empty vector.
1214
1215         * NetworkProcess/cache/NetworkCache.cpp:
1216         (WebKit::NetworkCache::Cache::remove):
1217
1218             Bulk deletion with a completion handler.
1219
1220         (WebKit::NetworkCache::Cache::deleteFiles): Added.
1221
1222             Factor to a helper function.
1223
1224         * NetworkProcess/cache/NetworkCache.h:
1225         * NetworkProcess/cache/NetworkCacheStorage.cpp:
1226         (WebKit::NetworkCache::Storage::remove):
1227
1228             Remove files for all the provided keys in a queue and invoke the completion handler in the main thread when done.
1229
1230         * NetworkProcess/cache/NetworkCacheStorage.h:
1231
1232 2017-07-06  Chris Dumez  <cdumez@apple.com>
1233
1234         Fix bad usage of static variables in ResourceLoadStatisticsStore
1235         https://bugs.webkit.org/show_bug.cgi?id=174237
1236
1237         Reviewed by Brent Fulgham.
1238
1239         Fix bad usage of static variables in ResourceLoadStatisticsStore. Those can be set via
1240         member functions on ResourceLoadStatisticsStore so they should be data members. The
1241         API to set them is associated to a particular store and there can in theory be several
1242         stores.
1243
1244         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1245         (WebKit::ResourceLoadStatisticsStore::shouldPartitionCookies):
1246         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1247         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
1248         (WebKit::ResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
1249         (WebKit::ResourceLoadStatisticsStore::setGrandfatheringTime):
1250         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
1251         (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
1252         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
1253         (WebKit::shouldPartitionCookies): Deleted.
1254         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1255
1256 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1257
1258         [WTF] Implement WTF::ThreadGroup
1259         https://bugs.webkit.org/show_bug.cgi?id=174081
1260
1261         Reviewed by Mark Lam.
1262
1263         * Shared/AsyncRequest.h:
1264         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1265
1266 2017-07-06  Chris Dumez  <cdumez@apple.com>
1267
1268         Drop unused ResourceLoadStatistics members
1269         https://bugs.webkit.org/show_bug.cgi?id=174226
1270
1271         Reviewed by Brent Fulgham.
1272
1273         * Shared/WebCoreArgumentCoders.cpp:
1274         (IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
1275         (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
1276         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1277         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
1278
1279 2017-07-06  Wenson Hsieh  <wenson_hsieh@apple.com>
1280
1281         Unreviewed, fix the internal iOS 11 build
1282
1283         It turns out, our internal bots are still on an older version of the iOS 11 SDK that's missing _UIDataOwner in
1284         <UIKit/NSItemProvider+UIKitAdditions_Private.h>. To ensure that we can build on both current and slightly older
1285         versions of the iOS 11 SDK, fall back to using NSInteger instead of _UIDataOwner.
1286
1287         * Platform/spi/ios/UIKitSPI.h:
1288         * UIProcess/ios/WKContentViewInteraction.mm:
1289         (-[WKContentView _dragInteraction:dataOwnerForSession:]):
1290         (-[WKContentView _dropInteraction:dataOwnerForSession:]):
1291
1292 2017-07-06  Wenson Hsieh  <wenson_hsieh@apple.com>
1293
1294         [iOS DnD] [WK2] Add delegate hooks for specifying the data owner for a drag or drop session
1295         https://bugs.webkit.org/show_bug.cgi?id=174139
1296         <rdar://problem/33126212>
1297
1298         Reviewed by Beth Dakin.
1299
1300         Add hooks to query the UI delegate for a _UIDataOwner on both drag and drop sides.
1301
1302         * Platform/spi/ios/UIKitSPI.h:
1303         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
1304         * UIProcess/ios/WKContentViewInteraction.mm:
1305         (-[WKContentView _dragInteraction:dataOwnerForSession:]):
1306         (-[WKContentView _dropInteraction:dataOwnerForSession:]):
1307
1308 2017-07-06  Brent Fulgham  <bfulgham@apple.com>
1309
1310         [WK2] ResourceLoadStatistics should batch its writes
1311         https://bugs.webkit.org/show_bug.cgi?id=174111
1312         <rdar://problem/33115894>
1313
1314         Reviewed by Chris Dumez.
1315
1316         Revise the data writing operation to only write on a specific interval (currently
1317         set to 5 minutes).
1318
1319         Also make 'writeStoreToDisk' simpler to use by moving the deleting (before write) and
1320         creating (after write) of the FileMonitor into the method, rather than requiring this
1321         knowledge in multiple places.
1322
1323         Make sure that we write our statistics file out before exiting so that we do not
1324         lose any data if we exit before the five-minute window has elapsed.
1325
1326         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1327         (WebKit::ResourceLoadStatisticsStore::setWritePersistentStoreCallback): Deleted.
1328         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1329         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords): Remove the stop
1330         and start monitoring into 'writeStoreToDisk'. Also check if enough time has elapsed since
1331         the last write to commit to disk.
1332         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver): Remove the
1333         stop and start monitoring into 'writeStoreToDisk'.
1334         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk): Add the stop and start monitoring
1335         commands here, so callers don't have to know to do so.
1336
1337 2017-07-06  Chris Dumez  <cdumez@apple.com>
1338
1339         FileMonitor should not be ref counted
1340         https://bugs.webkit.org/show_bug.cgi?id=174166
1341
1342         Reviewed by Brent Fulgham.
1343
1344         Update code using FileMonitor to reflect API change.
1345
1346         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1347         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
1348         (WebKit::WebResourceLoadStatisticsStore::stopMonitoringStatisticsStorage):
1349         * UIProcess/WebResourceLoadStatisticsStore.h:
1350
1351 2017-07-06  Matt Rajca  <mrajca@apple.com>
1352
1353         Fix build with VIDEO support disabled.
1354         https://bugs.webkit.org/show_bug.cgi?id=174217
1355
1356         Unreviewed build fix.
1357
1358         * WebProcess/WebPage/WebPage.cpp:
1359         (WebKit::WebPage::updateWebsitePolicies):
1360
1361 2017-07-06  Chris Dumez  <cdumez@apple.com>
1362
1363         Crash under WebResourceLoadStatisticsStore::persistentStoragePath(WTF::String const&)
1364         https://bugs.webkit.org/show_bug.cgi?id=174205
1365         <rdar://problem/33093552>
1366
1367         Reviewed by Brent Fulgham.
1368
1369         Make sure we isolateCopy() m_statisticsStoragePath before using it from the background
1370         thread.
1371
1372         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1373         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
1374         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
1375         (WebKit::WebResourceLoadStatisticsStore::resourceLogFilePath):
1376         (WebKit::WebResourceLoadStatisticsStore::statisticsFilePath):
1377         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
1378         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
1379         (WebKit::WebResourceLoadStatisticsStore::deleteStoreFromDisk):
1380         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
1381         (WebKit::WebResourceLoadStatisticsStore::syncWithExistingStatisticsStorageIfNeeded):
1382         (WebKit::WebResourceLoadStatisticsStore::persistentStoragePath): Deleted.
1383         * UIProcess/WebResourceLoadStatisticsStore.h:
1384
1385 2017-07-06  Alex Christensen  <achristensen@webkit.org>
1386
1387         Fix CFURLRequestRef serialization after r207330
1388         https://bugs.webkit.org/show_bug.cgi?id=163332
1389
1390         * Shared/mac/WebCoreArgumentCodersMac.mm:
1391         (IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
1392         The CFURLConnection code was not updated.
1393         We did not catch this because nobody uses the WebKit2 CFURLConnection code, but I need to use it to debug something.
1394
1395 2017-07-06  Chris Dumez  <cdumez@apple.com>
1396
1397         Move ResourceLoadObserver notification throttling logic from WebProcess class to ResourceLoadObserver
1398         https://bugs.webkit.org/show_bug.cgi?id=174194
1399
1400         Reviewed by Brent Fulgham.
1401
1402         Move ResourceLoadObserver notification throttling logic from WebProcess class to
1403         ResourceLoadObserver. This makes more sense and decreases the complexity of the
1404         WebProcess class.
1405
1406         * WebProcess/WebProcess.cpp:
1407         (WebKit::m_webSQLiteDatabaseTracker):
1408         (WebKit::WebProcess::statisticsChangedTimerFired): Deleted.
1409         * WebProcess/WebProcess.h:
1410
1411 2017-07-06  Chris Dumez  <cdumez@apple.com>
1412
1413         WebResourceLoadStatisticsStore should only be constructed when the feature is enabled
1414         https://bugs.webkit.org/show_bug.cgi?id=174189
1415
1416         Reviewed by Brent Fulgham.
1417
1418         Delay the construction of the WebResourceLoadStatisticsStore until the feature gets
1419         enabled via WebsiteDataStore::setResourceLoadStatisticsEnabled(). Previously, we would
1420         always construct a store and then have a boolean on the store to indicate if it is
1421         enabled or not.
1422
1423         Also simplify the initialization process of the WebResourceLoadStatisticsStore, we
1424         used to have:
1425         1. WebResourceLoadStatisticsStore constructor
1426         2. WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver()
1427         3. WebResourceLoadStatisticsStore::setResourceLoadStatisticsEnabled(true)
1428
1429         All 3 steps are now taken care of by the WebResourceLoadStatisticsStore constructor.
1430
1431         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1432         (WebKit::WebProcessPool::platformInitialize):
1433         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1434         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1435         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
1436         * UIProcess/WebResourceLoadStatisticsStore.h:
1437         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1438         (WebKit::WebsiteDataStore::platformInitialize):
1439         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1440         (WebKit::WebsiteDataStore::WebsiteDataStore):
1441         (WebKit::WebsiteDataStore::resourceLoadStatisticsEnabled):
1442         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
1443         * UIProcess/WebsiteData/WebsiteDataStore.h:
1444         (WebKit::WebsiteDataStore::resourceLoadStatistics):
1445         * UIProcess/wpe/WebProcessPoolWPE.cpp:
1446         (WebKit::WebProcessPool::platformInitialize):
1447
1448 2017-07-06  Claudio Saavedra  <csaavedra@igalia.com>
1449
1450         [GTK] It should process MouseMoved events when the parent window is not active
1451         https://bugs.webkit.org/show_bug.cgi?id=116691
1452
1453         Reviewed by Michael Catanzaro.
1454
1455         From reading the comments in the related code, only in Safari it
1456         is desired that MouseMoved events are not processed when the
1457         parent window is not active. In other ports, in particular those
1458         targeting Linux, these events should be processed for consistency
1459         with other browsers.
1460
1461         * UIProcess/WebPageProxy.cpp:
1462         (WebKit::WebPageProxy::setCursor):
1463         * UIProcess/mac/PageClientImpl.mm:
1464         (WebKit::PageClientImpl::setCursor):
1465         * WebProcess/WebPage/WebPage.cpp:
1466         (WebKit::handleMouseEvent):
1467         (WebKit::WebPage::mouseEvent):  No need to always pass a boolean
1468         parameter that is only checked for one type of event. Do the check
1469         internally in handleMouseEvent() only when needed and only in Cocoa.
1470
1471 2017-07-05  Don Olmstead  <don.olmstead@sony.com>
1472
1473         [WTF] Move SoftLinking.h into WTF
1474         https://bugs.webkit.org/show_bug.cgi?id=174000
1475
1476         Reviewed by Alex Christensen.
1477
1478         * Platform/mac/StringUtilities.mm:
1479         * Platform/spi/ios/ManagedConfigurationSPI.h:
1480         * Shared/Cocoa/DataDetectionResult.mm:
1481         * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
1482         * Shared/ios/InteractionInformationAtPosition.mm:
1483         * Shared/ios/WebIconUtilities.mm:
1484         * Shared/mac/CookieStorageShim.mm:
1485         * Shared/mac/WebCoreArgumentCodersMac.mm:
1486         * UIProcess/API/Cocoa/_WKElementAction.mm:
1487         * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
1488         * UIProcess/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
1489         * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
1490         * UIProcess/Cocoa/UIDelegate.mm:
1491         * UIProcess/Cocoa/WebViewImpl.mm:
1492         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
1493         * UIProcess/ios/WKActionSheetAssistant.mm:
1494         * UIProcess/ios/WKContentViewInteraction.mm:
1495         * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
1496         * UIProcess/ios/forms/WKFileUploadPanel.mm:
1497         * UIProcess/mac/WKImmediateActionController.mm:
1498         * UIProcess/mac/WebInspectorProxyMac.mm:
1499         * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
1500         * WebProcess/WebPage/mac/WebInspectorUIMac.mm:
1501         * WebProcess/cocoa/WebProcessCocoa.mm:
1502
1503 2017-07-05  Brady Eidson  <beidson@apple.com>
1504
1505         Allow navigations in subframes to get a ShouldOpenExternalURLsPolicy of "ShouldAllow".
1506         <rdar://problem/22485589> and https://bugs.webkit.org/show_bug.cgi?id=174178
1507
1508         Reviewed by Alex Christensen.
1509
1510         Adopt to the new constructor for FrameLoadRequest.
1511
1512         * WebProcess/Plugins/PluginView.cpp:
1513         (WebKit::PluginView::loadURL):
1514         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1515         (WebKit::WebFrameLoaderClient::dispatchCreatePage):
1516         * WebProcess/WebPage/WebInspector.cpp:
1517         (WebKit::WebInspector::openInNewTab):
1518
1519 2017-07-05  Ryosuke Niwa  <rniwa@webkit.org>
1520
1521         Remove unnecessary forward declartions now that we include Foundation.h
1522
1523         * UIProcess/API/Cocoa/WKContentRuleListStore.h:
1524
1525 2017-07-05  Ryosuke Niwa  <rniwa@webkit.org>
1526
1527         Make WebKit's public headers on Mac and iOS C++ module safe
1528         https://bugs.webkit.org/show_bug.cgi?id=174175
1529
1530         Reviewed by Alex Christensen.
1531
1532         Fixed the header files.
1533
1534         * UIProcess/API/Cocoa/WKContentRuleList.h:
1535         * UIProcess/API/Cocoa/WKContentRuleListStore.h:
1536         * UIProcess/API/Cocoa/WKUIDelegate.h:
1537
1538 2017-07-05  Chris Dumez  <cdumez@apple.com>
1539
1540         [WK2] WebsiteDataStore::setResourceLoadStatisticsEnabled() updates processPools the store is not associated with
1541         https://bugs.webkit.org/show_bug.cgi?id=174174
1542
1543         Reviewed by Brent Fulgham.
1544
1545         WebsiteDataStore::setResourceLoadStatisticsEnabled() updates processPools the store is not associated with.
1546         Fix this by iterating over WebsiteDataStore::processPools() instead of WebProcessPool::allProcessPools().
1547
1548         Also rename shouldPartitionCookiesForTopPrivatelyOwnedDomains methods / IPC messages to
1549         updateCookiePartitioningForTopPrivatelyOwnedDomains since this is a setter, not a getter.
1550
1551         Finally, drop ShouldPartitionCookiesForTopPrivatelyOwnedDomains IPC message to the NetworkProcessProxy
1552         as well as corresponding methods as those appear to be unused.
1553
1554         * NetworkProcess/NetworkProcess.cpp:
1555         (WebKit::NetworkProcess::updateCookiePartitioningForTopPrivatelyOwnedDomains):
1556         (WebKit::NetworkProcess::shouldPartitionCookiesForTopPrivatelyOwnedDomains): Deleted.
1557         * NetworkProcess/NetworkProcess.h:
1558         * NetworkProcess/NetworkProcess.messages.in:
1559         * UIProcess/Network/NetworkProcessProxy.cpp:
1560         (WebKit::NetworkProcessProxy::shouldPartitionCookiesForTopPrivatelyOwnedDomains): Deleted.
1561         * UIProcess/Network/NetworkProcessProxy.h:
1562         * UIProcess/Network/NetworkProcessProxy.messages.in:
1563         * UIProcess/WebProcessPool.cpp:
1564         (WebKit::WebProcessPool::setResourceLoadStatisticsEnabled):
1565         * UIProcess/WebProcessPool.h:
1566         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1567         (WebKit::WebsiteDataStore::updateCookiePartitioningForTopPrivatelyOwnedDomains):
1568         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
1569         (WebKit::WebsiteDataStore::registerSharedResourceLoadObserver):
1570         (WebKit::WebsiteDataStore::shouldPartitionCookiesForTopPrivatelyOwnedDomains): Deleted.
1571         * UIProcess/WebsiteData/WebsiteDataStore.h:
1572
1573 2017-07-05  Tim Horton  <timothy_horton@apple.com>
1574
1575         Async Image Decoding: Image flashes away briefly when tapping on tab in iPad tab picker
1576         https://bugs.webkit.org/show_bug.cgi?id=174173
1577         <rdar://problem/32431952>
1578
1579         Reviewed by Geoffrey Garen.
1580
1581         * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
1582         (WebKit::RemoteLayerTreeDrawingArea::addTransactionCallbackID):
1583         When a client uses e.g. doAfterNextPresentationUpdate (or internally,
1584         dispatchAfterEnsuringDrawing), they're doing so in the hopes that the
1585         callback is called after the page is well-painted -- for example, to
1586         remove a snapshot (in the tab picker case, as well as for navigation
1587         gestures), or to *take* a snapshot. In all of these cases, it is
1588         preferable to do a synchronous decode, to ensure that the image does
1589         not flash away temporarily.
1590
1591         Use the existing mechanism that was implemented for the synchronous
1592         activity state change flush to also force synchronous image decoding
1593         any time there is a post-commit transaction callback.
1594
1595 2017-07-05  Wenson Hsieh  <wenson_hsieh@apple.com>
1596
1597         [iOS DnD] [WK2] 3D touch fails to recognize when UIDragInteraction is enabled on phone
1598         https://bugs.webkit.org/show_bug.cgi?id=174171
1599         <rdar://problem/32956929>
1600
1601         Reviewed by Tim Horton.
1602
1603         By default, UIKit defers all competing long press gesture recognizers if dragging is enabled. However, this
1604         would cause 3D touch to be prevented, due to UIKit asking us whether or not we can proceed with the 3D touch
1605         gesture in -_interactionShouldBeginFromPreviewItemController:forPosition:, while the highlight long press
1606         gesture recognizer is being deferred. To address this, we use SPI on UIDragInteraction to allow the highlight
1607         long press gesture recognizer to recognize alongside the drag lift gesture. We then (already) manually cancel
1608         the highlight long press gesture in _dragInteraction:prepareForSession:completion:.
1609
1610         * UIProcess/ios/WKContentViewInteraction.mm:
1611         (-[WKContentView _dragInteraction:shouldDelayCompetingGestureRecognizer:]):
1612
1613 2017-07-03  Myles C. Maxfield  <mmaxfield@apple.com>
1614
1615         Remove copy of ICU headers from WebKit
1616         https://bugs.webkit.org/show_bug.cgi?id=116407
1617
1618         Reviewed by Alex Christensen.
1619
1620         * Configurations/BaseTarget.xcconfig:
1621
1622 2017-07-05  Chris Dumez  <cdumez@apple.com>
1623
1624         Regression(r218821): Bad cast to WebKit::DiagnosticLoggingClient in WKWebView's _setDiagnosticLoggingDelegate
1625         https://bugs.webkit.org/show_bug.cgi?id=174163
1626         <rdar://problem/33067518>
1627
1628         Reviewed by Alex Christensen.
1629
1630         After r218821, WebPageProxy::setDiagnosticLoggingClient() would no longer set the client in
1631         private session. This is an issue because there is code in WKWebView which expects the
1632         DiagnosticLoggingClient to be set and of a specific type. This would lead to bad casts in
1633         WKWebView's _diagnosticLoggingDelegate / _setDiagnosticLoggingDelegate.
1634
1635         To avoid the issue, we now unconditionally update the client in
1636         WebPageProxy::setDiagnosticLoggingClient(). Instead, we implement the logic for disabling
1637         logging in private session in the logging methods themselves, via the
1638         WebPageProxy::effectiveDiagnosticLoggingClient() helper instead.
1639
1640         I also added null checks in WKWebView's _diagnosticLoggingDelegate /
1641         _setDiagnosticLoggingDelegate. Even though the WKWebView sets itself as the diagnostic
1642         logging client, WebPageProxy::diagnosticLoggingClient() can still return null after
1643         calling WebPageProxy::close(). Previously, we would have done a bad cast if the WKWebView's
1644         client would have used this API after calling 'close' as well.
1645
1646         * UIProcess/API/APIDiagnosticLoggingClient.h:
1647         * UIProcess/API/Cocoa/WKWebView.mm:
1648         (-[WKWebView _diagnosticLoggingDelegate]):
1649         (-[WKWebView _setDiagnosticLoggingDelegate:]):
1650         * UIProcess/WebPageProxy.cpp:
1651         (WebKit::WebPageProxy::WebPageProxy):
1652         (WebKit::WebPageProxy::setDiagnosticLoggingClient):
1653         (WebKit::WebPageProxy::close):
1654         (WebKit::WebPageProxy::effectiveDiagnosticLoggingClient):
1655         (WebKit::WebPageProxy::logDiagnosticMessage):
1656         (WebKit::WebPageProxy::logDiagnosticMessageWithResult):
1657         (WebKit::WebPageProxy::logDiagnosticMessageWithValue):
1658         (WebKit::WebPageProxy::logDiagnosticMessageWithEnhancedPrivacy):
1659         * UIProcess/WebPageProxy.h:
1660         (WebKit::WebPageProxy::diagnosticLoggingClient):
1661
1662 2017-07-05  Daniel Bates  <dabates@apple.com>
1663
1664         Do not pass API::FrameInfo for source frame or clear out page of target frame on
1665         API navigation
1666         https://bugs.webkit.org/show_bug.cgi?id=174170
1667         <rdar://problem/33140328>
1668
1669         Reviewed by Brady Eidson.
1670
1671         As a step towards making it straightforward for an embedding client to determine whether
1672         a WebPageProxy::decidePolicyForNavigationAction() callback was initiated from API we
1673         should not pass frame info for the source frame and should not nullify the page pointer
1674         in the target frame info.
1675
1676         Currently we always pass frame info for the source frame and nullify the page pointer
1677         in both the source frame info and target frame info if the navigation was initiated from
1678         API. This seems subtle and error prone. Instead we should not pass frame info for
1679         the source frame and not nullify the page pointer in the target frame info as a step
1680         towards making using this API less error-prone.
1681
1682         * UIProcess/WebPageProxy.cpp:
1683         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
1684
1685 2017-07-05  Chris Dumez  <cdumez@apple.com>
1686
1687         Add a few more WebKit2 owners
1688         https://bugs.webkit.org/show_bug.cgi?id=174169
1689
1690         Reviewed by Brady Eidson.
1691
1692         * Owners:
1693
1694 2017-07-05  Brent Fulgham  <bfulgham@apple.com>
1695
1696         [WK2] Prevent ResourceLoadStatistics from triggering a cascade of read/write events
1697         https://bugs.webkit.org/show_bug.cgi?id=174062\
1698         <rdar://problem/33086744>
1699
1700         Reviewed by Chris Dumez.
1701
1702         ResourceLoadStatistics was triggering periods of high CPU use due to a cascade of read/write
1703         operations:
1704         (1) The 'makeRefPtr' call in FileMonitor::startMonitoring was capturing a reference to itself, preventing
1705             the FileMonitor from being destroyed. This caused the file modification handler to fire in response
1706             to our own write events, creating a ridiculous read/write cycle. This problem was addressed in
1707             the short term by stopping the file monitor in WebResourceLoadStatisticsStore::stopMonitoringStatisticsStorage,
1708             rather than relying on the destructor to shut things down. This will be improved in a
1709             subsequent patch.
1710         (2) 'syncWithExistingStatisticsStorageIfNeeded' was creating a FileMonitor during the write operation,
1711             which exacerbated the chain of read/writes already present due to the self-reference described above.
1712         (3) Because VNODE dispatch sources are low level, they do not offer a means of filtering out operations
1713             triggered by the current process. To avoid this, I added code to track the file modification time, so
1714             that we don't bother reading a file that holds data that is older than the in-memory data, even though
1715             we receive a file modification dispatch. Writes seem to trigger a chain of notification events in rapid
1716             succession. Once we've responded to the first of these events, we don't need to to further reads until
1717             the data on disk changes again.    
1718
1719         We also shouldn't allow the ResourceLoadStatistics worker thread to consume high CPU resources. Run it
1720         as utility QoS, avoiding using the CPU when other work is going on.
1721
1722         Drive-by fix: The closure in setWritePersistentStoreCallback() should stop monitoring before writing
1723         data, and should start monitoring after the write completes.
1724
1725         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1726         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore): Run our worker queue
1727         as a utility-level process.
1728         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver): Stop checking for
1729         updates before writing, and begin checking again once the write is complete.
1730         (WebKit::WebResourceLoadStatisticsStore::statisticsFileModificationTime): Added.
1731         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded): Avoid reading the file if it
1732         was last modified on (or before) the time we last read the file.
1733         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk): Ditto.
1734         (WebKit::WebResourceLoadStatisticsStore::stopMonitoringStatisticsStorage): Explicitly stop file
1735         monitoring so that the active file modification handler will terminate.
1736         (WebKit::WebResourceLoadStatisticsStore::syncWithExistingStatisticsStorageIfNeeded): Do not begin
1737         monitoring the file after syncing, since this is only used as part of an ongoing write operation.
1738
1739 2017-07-05  Jonathan Bedard  <jbedard@apple.com>
1740
1741         Add WebKitPrivateFrameworkStubs for iOS 11
1742         https://bugs.webkit.org/show_bug.cgi?id=173988
1743
1744         Reviewed by David Kilzer.
1745
1746         * Configurations/BaseTarget.xcconfig: iphoneos and iphonesimulator should use the
1747         same directory for private framework stubs.
1748
1749 2017-07-05  Andy Estes  <aestes@apple.com>
1750
1751         [iOS] WKActionSheetAssistants can outlive their host views
1752         https://bugs.webkit.org/show_bug.cgi?id=174160
1753         <rdar://problem/20638607>
1754
1755         Reviewed by Tim Horton.
1756
1757         WKActionSheetAssistant keeps a raw pointer to its host UIView, and nothing clears it when
1758         the host view is deallocated. If the assistant outlives the view, we can end up accessing a
1759         pointer to a deallocated UIView and crashing.
1760
1761         I don't know how to reproduce such a crash, but this patch guards against it by doing the
1762         following:
1763
1764         1. Make _view a WeakObjCPtr in WKActionSheetAssistant to ensure it gets set to nil when the
1765            UIView is deallocated.
1766         2. Call -[WKActionSheetAssistant cleanupSheet] when a WKContentView or WKPDFView is
1767            deallocated, or when the Web process crashes. This will ensure the action sheet is
1768            dismissed and prevent the user from tapping on an action that's no longer valid.
1769
1770         * UIProcess/ios/WKActionSheetAssistant.mm:
1771         (-[WKActionSheetAssistant superviewForSheet]):
1772         (-[WKActionSheetAssistant _presentationRectForSheetGivenPoint:inHostView:]):
1773         (-[WKActionSheetAssistant presentationRectForElementUsingClosestIndicatedRect]):
1774         (-[WKActionSheetAssistant presentationRectForIndicatedElement]):
1775         (-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]):
1776         * UIProcess/ios/WKContentViewInteraction.mm:
1777         (-[WKContentView cleanupInteraction]):
1778         * UIProcess/ios/WKPDFView.mm:
1779         (-[WKPDFView dealloc]):
1780
1781 2017-07-05  Frederic Wang  <fwang@igalia.com>
1782
1783         Move ScrolledContentsLayer property to ScrollingStateScrollingNode
1784         https://bugs.webkit.org/show_bug.cgi?id=174134
1785
1786         Reviewed by Simon Fraser.
1787
1788         * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
1789         (ArgumentCoder<ScrollingStateScrollingNode>::encode): Add encoding for scrolled contents
1790         layer.
1791         (ArgumentCoder<ScrollingStateFrameScrollingNode>::encode): Remove encoding for scrolled
1792         contents layer.
1793         (ArgumentCoder<ScrollingStateOverflowScrollingNode>::encode): Ditto.
1794         (ArgumentCoder<ScrollingStateScrollingNode>::decode): Add decoding for scrolled contents
1795         layer.
1796         (ArgumentCoder<ScrollingStateFrameScrollingNode>::decode): Remove decoding for scrolled
1797         contents layer.
1798         (ArgumentCoder<ScrollingStateOverflowScrollingNode>::decode): Ditto.
1799         (WebKit::dump): Move dumping of scrolled contents layer from overflow/frame nodes to
1800         scrolling node.
1801         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
1802         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers): Adjust enum value to use
1803         ScrollingStateScrollingNode::ScrolledContentsLayer.
1804         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
1805         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::commitStateBeforeChildren): Ditto.
1806         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
1807         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers): Ditto.
1808
1809 2017-07-05  Ada Chan  <adachan@apple.com>
1810
1811         Fix crash in UIKit: +[UIViewController _viewControllerForFullScreenPresentationFromView:]
1812         https://bugs.webkit.org/show_bug.cgi?id=174143
1813         <rdar://problem/28384582>
1814
1815         Reviewed by Wenson Hsieh.
1816
1817         In -[WKActionSheet willRotate], we can't guarantee that the action sheet belongs
1818         in a window, and passing nil to +[UIViewController _viewControllerForFullScreenPresentationFromView:]
1819         throws an exception. To fix this, bail early if the result from -hostViewForSheet is nil.
1820
1821         * UIProcess/ios/WKActionSheet.mm:
1822         (-[WKActionSheet willRotate]):
1823
1824 2017-07-05  Eric Carlson  <eric.carlson@apple.com>
1825
1826         [MediaStream] Protect request and web view during gUM client callback
1827         https://bugs.webkit.org/show_bug.cgi?id=174096
1828         <rdar://problem/32833102>
1829
1830         Reviewed by Youenn Fablet.
1831
1832         Retain the message and WebView during asynchronous calls so they won't be 
1833         released if a navigation happens during a call to the UA for getUserMedia 
1834         or enumerateMediaDevices.
1835
1836         * UIProcess/Cocoa/UIDelegate.mm:
1837         (WebKit::requestUserMediaAuthorizationForDevices):
1838         (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):
1839         (WebKit::UIDelegate::UIClient::checkUserMediaPermissionForOrigin):
1840
1841 2017-07-05  Matt Lewis  <jlewis3@apple.com>
1842
1843         Unreviewed, rolling out r219128.
1844
1845         Spoke with engineer who originally submitted, Patch for APi
1846         test to follow.
1847
1848         Reverted changeset:
1849
1850         "Unreviewed, rolling out r219070."
1851         https://bugs.webkit.org/show_bug.cgi?id=174082
1852         http://trac.webkit.org/changeset/219128
1853
1854 2017-07-05  Matt Lewis  <jlewis3@apple.com>
1855
1856         Unreviewed, rolling out r219070.
1857
1858         This revision caused consistent failures of the API test
1859         UIPasteboardTests.DoNotPastePlainTextAsURL on iOS.
1860
1861         Reverted changeset:
1862
1863         "Pasting single words copied to UIPasteboard inserts URLs in
1864         editable areas"
1865         https://bugs.webkit.org/show_bug.cgi?id=174082
1866         http://trac.webkit.org/changeset/219070
1867
1868 2017-07-05  Zan Dobersek  <zdobersek@igalia.com>
1869
1870         [GLib] Incorrect <glib/gi18n.h> include in WebKitWebsiteData
1871         https://bugs.webkit.org/show_bug.cgi?id=174093
1872
1873         Reviewed by Michael Catanzaro.
1874
1875         * UIProcess/API/glib/WebKitWebsiteData.cpp: Include <glib/gi18n-lib.h>
1876         rather than <glib/gi18n.h>, since the former has to be included in a
1877         library while the latter should only be included in a standalone application.
1878
1879 2017-07-04  Joseph Pecoraro  <pecoraro@apple.com>
1880
1881         Cleanup some StringBuilder use
1882         https://bugs.webkit.org/show_bug.cgi?id=174118
1883
1884         Reviewed by Andreas Kling.
1885
1886         * NetworkProcess/capture/NetworkCaptureManager.cpp:
1887         (WebKit::NetworkCapture::Manager::hashToPath):
1888         * UIProcess/WebPageProxy.cpp:
1889
1890 2017-07-03  Wenson Hsieh  <wenson_hsieh@apple.com>
1891
1892         [iOS DnD] [WK2] Callout bar should reappear after dragging ends for a text selection
1893         https://bugs.webkit.org/show_bug.cgi?id=174116
1894         <rdar://problem/33017845>
1895
1896         Reviewed by Ryosuke Niwa.
1897
1898         -willStartScrollingOverflow -didEndScrollingOverflow are helper methods on both the UIWKTextInteractionAssistant
1899         and UIWebSelectionAssistant that handle hiding selection and callout bar UI during overflow scrolling and making
1900         it reappear after scrolling ends. However, these hooks do not contain logic specific to scrolling, and simply
1901         tell the inner UIWebSelectionView to either show or hide and are safe to invoke outside of the context of
1902         scrolling.
1903
1904         This patch invokes these hooks when beginning a drag on a selection, and when a dragging ends, if it called
1905         -willStartScrollingOverflow to begin with. We should rename these in the future to be something along the lines
1906         of -hideSelectionViewAndControls and -showSelectionViewAndControls, respectively, and adopt these new names in
1907         WebKit. We also move logic to hide the callout out of -itemsForBeginningSession: and into
1908         -willAnimateLiftWithAnimator:, when the lift actually begins.
1909
1910         * UIProcess/ios/WKContentViewInteraction.h:
1911         * UIProcess/ios/WKContentViewInteraction.mm:
1912         (-[WKContentView cleanUpDragSourceSessionState]):
1913         (-[WKContentView _restoreCalloutBarIfNeeded]):
1914         (-[WKContentView dragInteraction:itemsForBeginningSession:]):
1915         (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
1916         (-[WKContentView dragInteraction:session:didEndWithOperation:]):
1917
1918 2017-07-03  Matt Rajca  <mrajca@apple.com>
1919
1920         Add/remove appropriate media element behavior restrictions when updateWebsitePolicies is called
1921         https://bugs.webkit.org/show_bug.cgi?id=174103
1922
1923         Reviewed by Alex Christensen.
1924
1925         Currently, when -[WKWebView evaluateJavaScript:completionHandler:] is invoked, we end up simulating
1926         a user gesture unconditionally. This is not desireable for some tests, so I added a private variant
1927         of this method that takes a boolean that is ultimately passed to `executeScript` for the
1928         `forceUserGesture` parameter (instead of unconditionally passing `true`).
1929
1930         * UIProcess/API/C/WKPage.cpp:
1931         (WKPageRunJavaScriptInMainFrame):
1932         * UIProcess/API/Cocoa/WKWebView.mm:
1933         (-[WKWebView evaluateJavaScript:completionHandler:]):
1934         (-[WKWebView _evaluateJavaScript:forceUserGesture:completionHandler:]):
1935         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1936         * UIProcess/WebPageProxy.cpp:
1937         (WebKit::WebPageProxy::runJavaScriptInMainFrame):
1938         * UIProcess/WebPageProxy.h:
1939         * WebProcess/WebPage/WebPage.cpp:
1940         (WebKit::WebPage::runJavaScriptInMainFrame):
1941         (WebKit::WebPage::updateWebsitePolicies): Update behavior restrictions on any existing media elements.
1942         * WebProcess/WebPage/WebPage.h:
1943         * WebProcess/WebPage/WebPage.messages.in:
1944
1945 2017-07-03  Matt Lewis  <jlewis3@apple.com>
1946
1947         Unreviewed, rolling out r219103.
1948
1949         Caused multiple build failures.
1950
1951         Reverted changeset:
1952
1953         "Remove copy of ICU headers from WebKit"
1954         https://bugs.webkit.org/show_bug.cgi?id=116407
1955         http://trac.webkit.org/changeset/219103
1956
1957 2017-07-03  Myles C. Maxfield  <mmaxfield@apple.com>
1958
1959         Remove copy of ICU headers from WebKit
1960         https://bugs.webkit.org/show_bug.cgi?id=116407
1961
1962         Reviewed by Alex Christensen.
1963
1964         Use WTF's copy of ICU headers.
1965
1966         * Configurations/BaseTarget.xcconfig:
1967
1968 2017-07-03  Brady Eidson  <beidson@apple.com>
1969
1970         Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
1971         https://bugs.webkit.org/show_bug.cgi?id=174073
1972
1973         Reviewed by Andy Estes.
1974
1975         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1976         (WebKit::WebFrameLoaderClient::getLoadDecisionForIcons):
1977         (WebKit::WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
1978         (WebKit::WebFrameLoaderClient::registerForIconNotification): Deleted.
1979         (WebKit::WebFrameLoaderClient::getLoadDecisionForIcon): Deleted.
1980         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
1981
1982 2017-07-03  Sam Weinig  <sam@webkit.org>
1983
1984         [WebIDL] Remove more unnecessary uses of the preprocessor in idl files
1985         https://bugs.webkit.org/show_bug.cgi?id=174083
1986
1987         Reviewed by Alex Christensen.
1988
1989         * Configurations/FeatureDefines.xcconfig:
1990         Add ENABLE_NAVIGATOR_STANDALONE.
1991
1992 2017-07-03  Matt Lewis  <jlewis3@apple.com>
1993
1994         Unreviewed, rolling out r219083.
1995
1996         The revision caused an API failure on all testing platforms.
1997
1998         Reverted changeset:
1999
2000         "[MediaStream] Protect request and web view during gUM client
2001         callback"
2002         https://bugs.webkit.org/show_bug.cgi?id=174096
2003         http://trac.webkit.org/changeset/219083
2004
2005 2017-07-03  Ryosuke Niwa  <rniwa@webkit.org>
2006
2007         WebContent processes crash when the network process crashes with pending connection requests
2008         https://bugs.webkit.org/show_bug.cgi?id=174065
2009         <rdar://problem/30359835>
2010
2011         Reviewed by Tim Horton.
2012
2013         The bug was caused by the UI process clearing away pending network connection requests whenever the existing
2014         network process crashed. This resulted in WebContent process killing itself inside ensureNetworkProcessConnection.
2015
2016         Fixed the bug by re-launching a new network process when this happens. We don't try to re-launch a new process
2017         if the previous attempt to launch a network process had failed.
2018
2019         This patch splits NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch into networkProcessFailedToLaunch
2020         and networkProcessCrashed to differentiate those two cases, and invoke the respective callbacks in WebProcessPool.
2021
2022         * UIProcess/API/Cocoa/WKProcessPool.mm:
2023         (-[WKProcessPool _networkProcessIdentifier]): Added.
2024         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
2025         * UIProcess/Network/NetworkProcessProxy.cpp:
2026         (WebKit::NetworkProcessProxy::networkProcessCrashed): Added.
2027         (WebKit::NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch): Split into the two following functions.
2028         (WebKit::NetworkProcessProxy::networkProcessFailedToLaunch): Extracted from networkProcessCrashedOrFailedToLaunch.
2029         (WebKit::NetworkProcessProxy::clearCallbackStates): Extracted from networkProcessCrashedOrFailedToLaunch
2030         (WebKit::NetworkProcessProxy::didClose): Call networkProcessCrashed.
2031         (WebKit::NetworkProcessProxy::didFinishLaunching): Call networkProcessFailedToLaunch.
2032         * UIProcess/Network/NetworkProcessProxy.h:
2033         * UIProcess/WebProcessPool.cpp:
2034         (WebKit::WebProcessPool::networkProcessCrashed): Start a new network process when there are pending connection
2035         requests the crached network failed to fullfil.
2036         (WebKit::WebProcessPool::networkProcessFailedToLaunch):
2037         * UIProcess/WebProcessPool.h:
2038
2039 2017-07-03  Eric Carlson  <eric.carlson@apple.com>
2040
2041         [MediaStream] Protect request and web view during gUM client callback
2042         https://bugs.webkit.org/show_bug.cgi?id=174096
2043         <rdar://problem/32833102>
2044
2045         Reviewed by Youenn Fablet.
2046
2047         Retain the message and WebView during asynchronous calls so they won't be 
2048         released if a navigation happens during a call to the UA for getUserMedia 
2049         or enumerateMediaDevices.
2050
2051         * UIProcess/Cocoa/UIDelegate.mm:
2052         (WebKit::requestUserMediaAuthorizationForDevices):
2053         (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):
2054         (WebKit::UIDelegate::UIClient::checkUserMediaPermissionForOrigin):
2055
2056 2017-07-03  Andy Estes  <aestes@apple.com>
2057
2058         [Xcode] Add an experimental setting to build with ccache
2059         https://bugs.webkit.org/show_bug.cgi?id=173875
2060
2061         Reviewed by Tim Horton.
2062
2063         * Configurations/DebugRelease.xcconfig: Included ccache.xcconfig.
2064
2065 2017-07-03  Chris Dumez  <cdumez@apple.com>
2066
2067         Drop ResourceLoadStatisticsStore's statisticsLock
2068         https://bugs.webkit.org/show_bug.cgi?id=174080
2069
2070         Reviewed by Brent Fulgham.
2071
2072         Drop ResourceLoadStatisticsStore's statisticsLock. It added complexity and was only needed
2073         do that the SPI exposed to WebKitTestRunner would query the store synchronously from the
2074         main thread. Instead, I made the SPI asynchronous and make sure we always access the store
2075         from the same background thread. As a result, there is no longer any need for locking.
2076
2077         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2078         (-[WKWebsiteDataStore _resourceLoadStatisticsIsPrevalentResource:completionHandler:]):
2079         (-[WKWebsiteDataStore _resourceLoadStatisticsHadUserInteraction:completionHandler:]):
2080         (-[WKWebsiteDataStore _resourceLoadStatisticsIsGrandfathered:completionHandler:]):
2081         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
2082         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
2083         (WebKit::ResourceLoadStatisticsStore::isPrevalentResource):
2084         (WebKit::ResourceLoadStatisticsStore::isGrandFathered):
2085         (WebKit::ResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
2086         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
2087         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
2088         (WebKit::ResourceLoadStatisticsStore::clearInMemory):
2089         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
2090         (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
2091         (WebKit::ResourceLoadStatisticsStore::processStatistics):
2092         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
2093         (WebKit::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
2094         (WebKit::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
2095         (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
2096         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
2097         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2098         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2099         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
2100         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
2101         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryData):
2102         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
2103         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
2104         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
2105         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
2106         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
2107         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
2108         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
2109         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
2110         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
2111         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
2112         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
2113         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
2114         * UIProcess/WebResourceLoadStatisticsStore.h:
2115
2116 2017-07-03  Wenson Hsieh  <wenson_hsieh@apple.com>
2117
2118         Pasting single words copied to UIPasteboard inserts URLs in editable areas
2119         https://bugs.webkit.org/show_bug.cgi?id=174082
2120         <rdar://problem/33046992>
2121
2122         Reviewed by Tim Horton.
2123
2124         Add a hook to WKPreferences to allow programatic pasting.
2125
2126         * UIProcess/API/Cocoa/WKPreferences.mm:
2127         (-[WKPreferences _setDOMPasteAllowed:]):
2128         (-[WKPreferences _domPasteAllowed]):
2129         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
2130
2131 2017-07-03  Zan Dobersek  <zdobersek@igalia.com>
2132
2133         Unreviewed GTK+ and WPE build fix when building with GCC 4.9.
2134
2135         * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
2136         (WebKit::CoordinatedLayerTreeHost::renderNextFrame): Don't use brace-list
2137         initialization to override the m_forceRepaintAsync struct. Instead, manually
2138         assign the OptionalCallbackID() value to the m_forceRepaintAsync.callbackID
2139         member variable, and override the m_forceRepaintAsync.needsFreshFlush member
2140         variable with `false`.
2141
2142 2017-07-03  Zan Dobersek  <zdobersek@igalia.com>
2143
2144         [ThreadedCompositor] Update and retrieve scene attributes under a Lock
2145         https://bugs.webkit.org/show_bug.cgi?id=173762
2146
2147         Reviewed by Carlos Garcia Campos.
2148
2149         Instead of dispatching separate tasks on the composition run loop, update
2150         various scene attributes by locking a common lock object and updating the
2151         appropriate attribute.
2152
2153         In ThreadedCompositor::renderLayerTree(), where these attributes are used
2154         in scene composition, the lock is again obtained and the attributes copied
2155         into local variables, releasing the lock afterwards. The attribute values
2156         in local copies are then used for that renderLayerTree() invocation.
2157
2158         This approach is more efficient than dispatching separate tasks that can
2159         race against renderLayerTree() dispatches.
2160
2161         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
2162         (WebKit::ThreadedCompositor::ThreadedCompositor):
2163         (WebKit::m_displayRefreshMonitor):
2164         (WebKit::ThreadedCompositor::setScaleFactor):
2165         (WebKit::ThreadedCompositor::setScrollPosition):
2166         (WebKit::ThreadedCompositor::setViewportSize):
2167         (WebKit::ThreadedCompositor::setDrawsBackground):
2168         (WebKit::ThreadedCompositor::renderLayerTree):
2169         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
2170
2171 2017-07-01  Dan Bernstein  <mitz@apple.com>
2172
2173         [iOS] Remove code only needed when building for iOS 9.x
2174         https://bugs.webkit.org/show_bug.cgi?id=174068
2175
2176         Reviewed by Tim Horton.
2177
2178         * Configurations/FeatureDefines.xcconfig:
2179         * Configurations/WebKit.xcconfig:
2180         * Platform/spi/ios/UIKitSPI.h:
2181         * UIProcess/API/Cocoa/WKWebView.mm:
2182         (-[WKWebView dealloc]):
2183         * UIProcess/ios/WKContentViewInteraction.mm:
2184         (-[WKFormInputSession setSuggestions:]):
2185         (-[WKFormInputSession invalidate]):
2186         (-[WKContentView insertTextSuggestion:]):
2187         (contentTypeFromFieldName):
2188         (-[WKContentView textInputTraits]):
2189         (-[WKContentView _dataForPreviewItemController:atPosition:type:]):
2190         * WebProcess/WebPage/ios/WebPageIOS.mm:
2191         (WebKit::WebPage::getPositionInformation):
2192         * config.h:
2193
2194 2017-07-01  Brady Eidson  <beidson@apple.com>
2195
2196         When setting a custom cookie storage location on a WKWebsiteDataStore, cookies aren't actually removed.
2197         <rdar://problem/32410662> and https://bugs.webkit.org/show_bug.cgi?id=174035
2198
2199         Reviewed by Alex Christensen.
2200
2201         * UIProcess/API/Cocoa/WKProcessPool.mm:
2202         (-[WKProcessPool _terminateNetworkProcess]):
2203         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
2204         
2205         * UIProcess/WebProcessPool.cpp:
2206         (WebKit::WebProcessPool::ensureNetworkProcess): Take an optional WebsiteDataStore. If one is passed in,
2207           send it to either the existing or new network process.
2208         * UIProcess/WebProcessPool.h:
2209         
2210         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
2211         (WebKit::WebsiteDataStore::parameters): Resolve paths first.
2212
2213         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2214         (WebKit::WebsiteDataStore::fetchDataAndApply):
2215         (WebKit::WebsiteDataStore::removeData):
2216
2217 2017-07-01  Ryosuke Niwa  <rniwa@webkit.org>
2218
2219         Frame.h doesn't need to include FrameLoader.h, IntRect.h, and NavigationScheduler.h
2220         https://bugs.webkit.org/show_bug.cgi?id=174004
2221
2222         Reviewed by Simon Fraser.
2223
2224         * WebProcess/Plugins/WebPluginInfoProvider.cpp:
2225         * WebProcess/WebPage/WebInspector.cpp:
2226
2227 2017-07-01  Dan Bernstein  <mitz@apple.com>
2228
2229         [macOS] Remove code only needed when building for OS X Yosemite
2230         https://bugs.webkit.org/show_bug.cgi?id=174067
2231
2232         Reviewed by Tim Horton.
2233
2234         * Configurations/Base.xcconfig:
2235         * Configurations/BaseTarget.xcconfig:
2236         * Configurations/BaseXPCService.xcconfig:
2237         * Configurations/DebugRelease.xcconfig:
2238         * Configurations/FeatureDefines.xcconfig:
2239         * Configurations/NetworkService.xcconfig:
2240         * Configurations/PluginService.32.xcconfig:
2241         * Configurations/PluginService.64.xcconfig:
2242         * Configurations/Version.xcconfig:
2243         * Configurations/WebContentService.xcconfig:
2244         * Configurations/WebKit.xcconfig:
2245         * DatabaseProcess/mac/com.apple.WebKit.Databases.sb.in:
2246         * NetworkProcess/EntryPoint/mac/XPCService/NetworkService/Info-OSX-10.9-10.10.plist: Removed.
2247         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2248         (WebKit::NetworkProcessCreationParameters::encode):
2249         (WebKit::NetworkProcessCreationParameters::decode):
2250         * NetworkProcess/NetworkProcessCreationParameters.h:
2251         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
2252         (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
2253         * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
2254         * Platform/IPC/Connection.h:
2255         * Platform/IPC/mac/ConnectionMac.mm:
2256         (IPC::Connection::platformInvalidate):
2257         (IPC::Connection::platformInitialize):
2258         (IPC::Connection::open):
2259         (IPC::Connection::exceptionSourceEventHandler): Deleted.
2260         (IPC::Connection::setShouldCloseConnectionOnMachExceptions): Deleted.
2261         * Platform/mac/LayerHostingContext.h:
2262         * Platform/mac/LayerHostingContext.mm:
2263         (WebKit::LayerHostingContext::createFencePort):
2264         * PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64-10.9-10.10.Info.plist: Removed.
2265         * PluginProcess/mac/PluginControllerProxyMac.mm:
2266         (WebKit::PluginControllerProxy::updateLayerHostingContext):
2267         * PluginProcess/mac/PluginProcessShim.mm:
2268         * PluginProcess/mac/com.apple.WebKit.plugin-common.sb.in:
2269         * Shared/ChildProcess.h:
2270         * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
2271         (WebKit::getPluginInfoFromPropertyLists):
2272         (WebKit::NetscapePluginModule::getPluginInfo):
2273         (WebKit::contentsOfPropertyListAtURL): Deleted.
2274         (WebKit::getMIMETypesFromPluginBundle): Deleted.
2275         * Shared/Plugins/PluginProcessCreationParameters.cpp:
2276         (WebKit::PluginProcessCreationParameters::encode):
2277         (WebKit::PluginProcessCreationParameters::decode):
2278         * Shared/Plugins/PluginProcessCreationParameters.h:
2279         * Shared/WebProcessCreationParameters.cpp:
2280         (WebKit::WebProcessCreationParameters::encode):
2281         (WebKit::WebProcessCreationParameters::decode):
2282         * Shared/WebProcessCreationParameters.h:
2283         * Shared/mac/ChildProcessMac.mm:
2284         (WebKit::ChildProcess::setSharedHTTPCookieStorage):
2285         * UIProcess/API/C/WKPage.cpp:
2286         (WKPageSetPageUIClient):
2287         (fixUpBotchedPageUIClient): Deleted.
2288         * UIProcess/ChildProcessProxy.cpp:
2289         (WebKit::ChildProcessProxy::didFinishLaunching):
2290         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2291         (WebKit::WebProcessPool::platformInitializeWebProcess):
2292         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
2293         (WebKit::WebProcessPool::resetHSTSHostsAddedAfterDate):
2294         * UIProcess/Cocoa/WebViewImpl.h:
2295         * UIProcess/Cocoa/WebViewImpl.mm:
2296         (WebKit::WebViewImpl::updateLayer):
2297         (WebKit::WebViewImpl::startWindowDrag):
2298         * UIProcess/DrawingAreaProxy.h:
2299         (WebKit::DrawingAreaProxy::waitForPossibleGeometryUpdate): Deleted.
2300         * UIProcess/Plugins/PluginProcessProxy.cpp:
2301         (WebKit::PluginProcessProxy::didFinishLaunching):
2302         * UIProcess/Plugins/PluginProcessProxy.h:
2303         * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
2304         (WebKit::PluginProcessProxy::platformInitializePluginProcess):
2305         (WebKit::PluginProcessProxy::createPropertyListFile): Deleted.
2306         * UIProcess/WebPageProxy.cpp:
2307         (WebKit::WebPageProxy::setTopContentInset):
2308         * UIProcess/mac/PageClientImpl.mm:
2309         (WebKit::PageClientImpl::rootViewToWindow):
2310         (WebKit::PageClientImpl::startWindowDrag):
2311         * UIProcess/mac/RemoteWebInspectorProxyMac.mm:
2312         (WebKit::RemoteWebInspectorProxy::platformStartWindowDrag):
2313         * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
2314         * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
2315         (WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
2316         (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate): Deleted.
2317         * UIProcess/mac/WebInspectorProxyMac.mm:
2318         (WebKit::WebInspectorProxy::createFrontendWindow):
2319         (WebKit::WebInspectorProxy::platformStartWindowDrag):
2320         * UIProcess/mac/WebPopupMenuProxyMac.mm:
2321         (WebKit::WebPopupMenuProxyMac::showPopupMenu):
2322         * WebKit2.xcodeproj/project.pbxproj:
2323         * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX-10.9-10.10.plist: Removed.
2324         * WebProcess/WebPage/WebPage.cpp:
2325         * WebProcess/WebPage/WebPage.h:
2326         * WebProcess/WebPage/WebPage.messages.in:
2327         * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
2328         (WebKit::addAnimationToLayer):
2329         * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
2330         (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
2331         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
2332         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
2333         (WebKit::TiledCoreAnimationDrawingArea::updateGeometry):
2334         * WebProcess/cocoa/WebProcessCocoa.mm:
2335         (WebKit::WebProcess::platformInitializeWebProcess):
2336         * WebProcess/com.apple.WebProcess.sb.in:
2337
2338 2017-07-01  Chris Dumez  <cdumez@apple.com>
2339
2340         Replace ResourceLoadStatisticsStore C API with Cocoa SPI
2341         https://bugs.webkit.org/show_bug.cgi?id=174060
2342
2343         Reviewed by Brent Fulgham.
2344
2345         Replace ResourceLoadStatisticsStore C API by Cocoa SPI. The new Cocoa SPI is on
2346         WKWebsiteDataStore, which allows us to get rid of the WebResourceLoadStatisticsManager
2347         singleton as the SPI can now interact directly with the WebResourceLoadStatisticsStore.
2348
2349         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp: Removed.
2350         * UIProcess/API/C/WKResourceLoadStatisticsManager.h: Removed.
2351         Drop old C API.
2352
2353         * UIProcess/WebResourceLoadStatisticsManager.cpp: Removed.
2354         * UIProcess/WebResourceLoadStatisticsManager.h: Removed.
2355         Drop WebResourceLoadStatisticsManager singleton which was only required by the
2356         C API. This is because the C API was global, rather than working on a specific
2357         store.
2358
2359         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2360         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
2361         Add new Cocoa SPI on WKWebsiteDataStore. This is only used for testing.
2362
2363         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2364         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
2365         Stop registering the store with the WebResourceLoadStatisticsManager singleton,
2366         as this singleton is gone.
2367
2368         * UIProcess/WebsiteData/WebsiteDataStore.h:
2369         (WebKit::WebsiteDataStore::resourceLoadStatistics):
2370         Add new getter to retrieve the WebResourceLoadStatisticsStore from the
2371         WebsiteDataStore. This is needed by the new Cocoa SPI.
2372
2373         * WebKit2.xcodeproj/project.pbxproj:
2374         Drop some files.
2375
2376 2017-06-30  Megan Gardner  <megan_gardner@apple.com>
2377
2378         Unreviewed mac build fix.
2379
2380         * UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
2381         * UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
2382
2383 2017-06-30  Megan Gardner  <megan_gardner@apple.com>
2384
2385         Add API to get WKActivatedElementInfo
2386         https://bugs.webkit.org/show_bug.cgi?id=174001
2387         <rdar://problem/29165518>
2388         
2389         Adding a way to get a WKActivatedElementInfo for a point on a WKWebView.
2390
2391         Reviewed by Tim Horton.
2392
2393         * UIProcess/API/Cocoa/WKWebView.mm:
2394         (-[WKWebView requestActivatedElementAtPosition:completionBlock:]):
2395         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2396         * UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
2397         (+[_WKActivatedElementInfo infoWithType:withInteractionInformationAtPosition:]):
2398         (-[_WKActivatedElementInfo infoWithType:withInteractionInformationAtPosition:]):
2399         * UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
2400
2401 2017-06-30  Tim Horton  <timothy_horton@apple.com>
2402
2403         Use API instead of SPI for content inset adjustment behavior
2404         https://bugs.webkit.org/show_bug.cgi?id=174050
2405
2406         Reviewed by Sam Weinig.
2407
2408         * Platform/spi/ios/UIKitSPI.h:
2409         * UIProcess/ios/WKScrollView.mm:
2410         (-[WKScrollView initWithFrame:]):
2411         (-[WKScrollView setContentInsetAdjustmentBehavior:]):
2412         (-[WKScrollView _setContentInsetAdjustmentBehaviorInternal:]):
2413         (-[WKScrollView _setContentInsetAdjustmentBehavior:]): Deleted.
2414         Switch over to the API. The old SPI calls the API internally, so our
2415         override will now cover all callers.
2416
2417 2017-06-30  Chris Dumez  <cdumez@apple.com>
2418
2419         Move store logic from WebResourceLoadStatisticsManager to WebResourceLoadStatisticsStore
2420         https://bugs.webkit.org/show_bug.cgi?id=174038
2421
2422         Reviewed by Brent Fulgham.
2423
2424         Move store logic from WebResourceLoadStatisticsManager to WebResourceLoadStatisticsStore.
2425         WebResourceLoadStatisticsManager is now essentially a proxy to the
2426         WebResourceLoadStatisticsStore to support the current C API.
2427
2428         In a follow-up, I plan to to replace the C API with a Cocoa SPI which works on a
2429         WebResourceLoadStatisticsStore directly instead of requiring a
2430         WebResourceLoadStatisticsManager singleton.
2431
2432         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
2433         (WKResourceLoadStatisticsManagerSetMinimumTimeBetweenDataRecordsRemoval):
2434         (WKResourceLoadStatisticsManagerResetToConsistentState):
2435         * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
2436         * UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm: Removed.
2437         * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
2438         (WebKit::WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):
2439         * UIProcess/WebResourceLoadStatisticsManager.cpp:
2440         (WebKit::WebResourceLoadStatisticsManager::WebResourceLoadStatisticsManager):
2441         (WebKit::WebResourceLoadStatisticsManager::~WebResourceLoadStatisticsManager):
2442         (WebKit::WebResourceLoadStatisticsManager::setStatisticsStore):
2443         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryStore):
2444         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
2445         (WebKit::WebResourceLoadStatisticsManager::logUserInteraction):
2446         (WebKit::WebResourceLoadStatisticsManager::clearUserInteraction):
2447         (WebKit::WebResourceLoadStatisticsManager::hasHadUserInteraction):
2448         (WebKit::WebResourceLoadStatisticsManager::setPrevalentResource):
2449         (WebKit::WebResourceLoadStatisticsManager::isPrevalentResource):
2450         (WebKit::WebResourceLoadStatisticsManager::clearPrevalentResource):
2451         (WebKit::WebResourceLoadStatisticsManager::setGrandfathered):
2452         (WebKit::WebResourceLoadStatisticsManager::isGrandfathered):
2453         (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
2454         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
2455         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
2456         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
2457         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
2458         (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweenDataRecordsRemoval):
2459         (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
2460         (WebKit::WebResourceLoadStatisticsManager::fireDataModificationHandler):
2461         (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
2462         (WebKit::WebResourceLoadStatisticsManager::fireTelemetryHandler):
2463         * UIProcess/WebResourceLoadStatisticsManager.h:
2464         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2465         (WebKit::primaryDomain):
2466         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
2467         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
2468         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
2469         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
2470         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
2471         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
2472         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
2473         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
2474         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
2475         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
2476         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
2477         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
2478         (WebKit::WebResourceLoadStatisticsStore::fireDataModificationHandler):
2479         (WebKit::WebResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
2480         (WebKit::WebResourceLoadStatisticsStore::fireTelemetryHandler):
2481         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
2482         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
2483         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
2484         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
2485         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
2486         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
2487         * UIProcess/WebResourceLoadStatisticsStore.h:
2488         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2489         (WebKit::WebsiteDataStore::removeData):
2490         * WebKit2.xcodeproj/project.pbxproj:
2491
2492 2017-06-30  John Wilander  <wilander@apple.com>
2493
2494         [WK2] Resource load statistics code is spamming the WebProcess with a test-only message 
2495         https://bugs.webkit.org/show_bug.cgi?id=174048
2496         <rdar://problem/33062376>
2497
2498         Reviewed by Brent Fulgham.
2499
2500         Fix the telemetry data message send so that it is not generated during normal operations.
2501         This is only meant to be used by WebKitTestRunner.
2502
2503         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
2504         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit): 
2505
2506 2017-06-30  Daniel Bates  <dabates@apple.com>
2507
2508         Attempt to fix the WPE build following <https://trac.webkit.org/changeset/219013>
2509         (https://bugs.webkit.org/show_bug.cgi?id=165160)
2510
2511         Update the prototype of UIClient::createNewPage() to take a API::FrameInfo& instead of
2512         a WebFrameProxy* and a const WebCore::SecurityOriginData&.
2513
2514         * UIProcess/API/glib/WebKitUIClient.cpp:
2515
2516 2017-06-30  Alex Christensen  <achristensen@webkit.org>
2517
2518         Stop soft linking with CFNetwork
2519         https://bugs.webkit.org/show_bug.cgi?id=174029
2520
2521         Reviewed by Jer Noble.
2522
2523         * Shared/mac/CookieStorageShim.mm:
2524
2525 2017-06-30  Daniel Bates  <dabates@apple.com>
2526
2527         API::FrameInfo should know the web page that contains the frame; add API property webView to WKFrameInfo
2528         https://bugs.webkit.org/show_bug.cgi?id=165160
2529         <rdar://problem/29451999>
2530
2531         Reviewed by Brady Eidson.
2532
2533         Expose a property on WKFrameInfo to retrieve the WKWebView of the web page that contains the
2534         frame. This will allow an embedding client to know the web view that initiated the navigation
2535         request as well as differentiate between a navigation initiated by web content from one
2536         initiated via API.
2537
2538         The majority of this change is passing the document D that initiated the targeted navigation
2539         or called window.open() through the loading machinery to the FrameLoaderClient. The changes
2540         to pass this information to the FrameLoaderClient when creating a new window are straightforward.
2541         For targeted navigation, the WebKit2 FrameLoaderClient implementation now computes the info
2542         for the originating frame regardless of the navigation type (NavigationAction::type()).
2543         (Currently we only compute the originating frame for hyperlink activated navigations,
2544         form submissions, and form resubmissions). The WebProcess computes the page ID of the page
2545         that contains the originating frame and sends that to the UIProcess so that it can create
2546         an API::FrameInfo for the originating frame and associate the page that contains the frame,
2547         if the navigation was triggered by web content. If the navigation was triggered by API
2548         (e.g. -[WKWebView goBack]) then the created API::FrameInfo does not have an associated page
2549         so that an embedding client can distinguish between a navigation initiated by web content
2550         from a navigation that it initiated via API depending on whether API::FrameInfo::page() is
2551         nullptr. We expose property webView on the Mac and iOS API class WKFrameInfo to return the
2552         WKWebView corresponding to API::FrameInfo::page().
2553
2554         A small change that this patch makes is to have the WebProcess compute the originating frame
2555         info (call WebFrame::info()) and send it over to the UIProcess as opposed to sending the frame
2556         ID of the originating frame and having the UIProcess compute the frame info from it. We do this
2557         because the UIProcess may not be able to compute the frame info for the originating frame if
2558         the window that it was contained in was closed between the time the WebProcess sent the frame
2559         ID to the UIProcess and the UIProcess received it.
2560
2561         * UIProcess/API/APIFrameInfo.cpp:
2562         (API::FrameInfo::create):
2563         (API::FrameInfo::FrameInfo):
2564         (API::FrameInfo::clearPage):
2565         * UIProcess/API/APIFrameInfo.h:
2566         * UIProcess/API/APIUIClient.h:
2567         (API::UIClient::createNewPage):
2568         (API::UIClient::createNewPageAsync):
2569         * UIProcess/API/C/WKPage.cpp:
2570         (WKPageSetPageUIClient):
2571         * UIProcess/API/Cocoa/WKFrameInfo.h:
2572         * UIProcess/API/Cocoa/WKFrameInfo.mm:
2573         (-[WKFrameInfo description]):
2574         (-[WKFrameInfo webView]):
2575         * UIProcess/API/Cocoa/WKUserContentController.mm:
2576         * UIProcess/Cocoa/UIDelegate.h:
2577         * UIProcess/Cocoa/UIDelegate.mm:
2578         (WebKit::UIDelegate::UIClient::createNewPageCommon):
2579         (WebKit::UIDelegate::UIClient::createNewPage):
2580         (WebKit::UIDelegate::UIClient::createNewPageAsync):
2581         * UIProcess/WebPageProxy.cpp:
2582         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
2583         (WebKit::WebPageProxy::createNewPage):
2584         * UIProcess/WebPageProxy.h:
2585         * UIProcess/WebPageProxy.messages.in:
2586         * WebProcess/Plugins/PluginView.cpp:
2587         (WebKit::PluginView::loadURL):
2588         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
2589         (WebKit::WebChromeClient::createWindow):
2590         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2591         (WebKit::WebFrameLoaderClient::dispatchCreatePage):
2592         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
2593         * WebProcess/WebPage/WebInspector.cpp:
2594         (WebKit::WebInspector::openInNewTab):
2595
2596 2017-06-29  Jer Noble  <jer.noble@apple.com>
2597
2598         Make Legacy EME API controlled by RuntimeEnabled setting.
2599         https://bugs.webkit.org/show_bug.cgi?id=173994
2600
2601         Reviewed by Sam Weinig.
2602
2603         Add a new WKWebViewConfiguration property, as well as a new WKPreferences function, both able to control
2604         WebCore's new RuntimeEnabledFeature setting for the Legacy EME API.
2605
2606         * Configurations/FeatureDefines.xcconfig:
2607         * Shared/WebPreferencesDefinitions.h:
2608         * UIProcess/API/C/WKPreferences.cpp:
2609         (WKPreferencesGetLegacyEncryptedMediaAPIEnabled):
2610         (WKPreferencesSetLegacyEncryptedMediaAPIEnabled):
2611         * UIProcess/API/C/WKPreferencesRef.h:
2612         * UIProcess/API/Cocoa/WKWebView.mm:
2613         (-[WKWebView _initializeWithConfiguration:]):
2614         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
2615         (-[WKWebViewConfiguration init]):
2616         (-[WKWebViewConfiguration copyWithZone:]):
2617         (-[WKWebViewConfiguration _setLegacyEncryptedMediaAPIEnabled:]):
2618         (-[WKWebViewConfiguration _legacyEncryptedMediaAPIEnabled]):
2619         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
2620         * WebProcess/WebPage/WebPage.cpp:
2621         (WebKit::WebPage::updatePreferences):
2622
2623 2017-06-30  Jer Noble  <jer.noble@apple.com>
2624
2625         REGRESSION (r218757): Touch Bar's media scrubber timeline runs from 00:00 to 00:00 and has no playhead
2626         https://bugs.webkit.org/show_bug.cgi?id=174032
2627
2628         Reviewed by Eric Carlson.
2629
2630         Fix a copypasta error where durationChange notifications were changing the value of muted.
2631
2632         * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:
2633         (WebKit::WebPlaybackSessionManagerProxy::durationChanged):
2634
2635 2017-06-30  Chris Dumez  <cdumez@apple.com>
2636
2637         Move ResourceLoadStatisticsStore to WebKit2/UIProcess
2638         https://bugs.webkit.org/show_bug.cgi?id=174033
2639
2640         Reviewed by Brent Fulgham.
2641
2642         Move ResourceLoadStatisticsStore to WebKit2/UIProcess since it is only
2643         used in the WebKit2 UIProcess.
2644
2645         * CMakeLists.txt:
2646         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.cpp.
2647         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
2648         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
2649         (WebKit::ResourceLoadStatisticsStore::clearInMemory):
2650         (WebKit::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
2651         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
2652         (WebKit::ResourceLoadStatisticsStore::fireDataModificationHandler):
2653         (WebKit::ResourceLoadStatisticsStore::fireTelemetryHandler):
2654         (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
2655         (WebKit::ResourceLoadStatisticsStore::processStatistics):
2656         (WebKit::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
2657         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
2658         (WebKit::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
2659         (WebKit::ResourceLoadStatisticsStore::dataRecordsWereRemoved):
2660         (WebKit::ResourceLoadStatisticsStore::statisticsLock):
2661         * UIProcess/Storage/ResourceLoadStatisticsStore.h: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.h.
2662         * UIProcess/WebResourceLoadStatisticsManager.cpp:
2663         (WebKit::primaryDomain):
2664         * UIProcess/WebResourceLoadStatisticsManager.h:
2665         * UIProcess/WebResourceLoadStatisticsStore.h:
2666         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
2667         * UIProcess/WebResourceLoadStatisticsTelemetry.h:
2668         * WebKit2.xcodeproj/project.pbxproj:
2669
2670 2017-06-30  Ryosuke Niwa  <rniwa@webkit.org>
2671
2672         Ran sort-Xcode-project-file.
2673
2674         * WebKit2.xcodeproj/project.pbxproj:
2675
2676 2017-06-30  Chris Dumez  <cdumez@apple.com>
2677
2678         ResourceLoadObserver does not need a ResourceLoadStatisticsStore
2679         https://bugs.webkit.org/show_bug.cgi?id=174013
2680
2681         Reviewed by Brent Fulgham.
2682
2683         ResourceLoadObserver does not need a ResourceLoadStatisticsStore. ResourceLoadStatisticsStore is too complicated for its needs.
2684         ResourceLoadStatisticsStore can then be moved to WebKit2/UIProcess in a follow-up.
2685
2686         * WebProcess/WebProcess.cpp:
2687         (WebKit::m_webSQLiteDatabaseTracker):
2688         (WebKit::WebProcess::statisticsChangedTimerFired):
2689         * WebProcess/WebProcess.h:
2690
2691 2017-06-30  Brent Fulgham  <bfulgham@apple.com>
2692
2693         [WK2][iOS][macOS] Update XPC services process launch dictionary
2694         https://bugs.webkit.org/show_bug.cgi?id=173995
2695         <rdar://problem/32797264>
2696
2697         Reviewed by Alex Christensen.
2698
2699         Update the WebProcess and Plugin Process XPC launch dictionaries to activate
2700         improved ALSR features when launching.
2701
2702         * PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist:
2703         * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist:
2704         * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist:
2705
2706 2017-06-30  Chris Dumez  <cdumez@apple.com>
2707
2708         Merge WebResourceLoadStatisticsManager and WebResourceLoadObserver
2709         https://bugs.webkit.org/show_bug.cgi?id=174008
2710
2711         Reviewed by Brent Fulgham.
2712
2713         Merge WebResourceLoadStatisticsManager and WebResourceLoadObserver. One was basically
2714         a proxy to the other.
2715
2716         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
2717         (WKResourceLoadStatisticsManagerSetPrevalentResource):
2718         (WKResourceLoadStatisticsManagerIsPrevalentResource):
2719         (WKResourceLoadStatisticsManagerSetHasHadUserInteraction):
2720         (WKResourceLoadStatisticsManagerIsHasHadUserInteraction):
2721         (WKResourceLoadStatisticsManagerSetGrandfathered):
2722         (WKResourceLoadStatisticsManagerIsGrandfathered):
2723         (WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
2724         (WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
2725         (WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
2726         (WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction):
2727         (WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
2728         (WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval):
2729         (WKResourceLoadStatisticsManagerSetGrandfatheringTime):
2730         (WKResourceLoadStatisticsManagerFireDataModificationHandler):
2731         (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler):
2732         (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain):
2733         (WKResourceLoadStatisticsManagerFireTelemetryHandler):
2734         (WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned):
2735         (WKResourceLoadStatisticsManagerSetShouldClassifyResourcesBeforeDataRecordsRemoval):
2736         (WKResourceLoadStatisticsManagerSetNotifyPagesWhenTelemetryWasCaptured):
2737         (WKResourceLoadStatisticsManagerSetShouldSubmitTelemetry):
2738         (WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore):
2739         (WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStoreModifiedSinceHours):
2740         (WKResourceLoadStatisticsManagerResetToConsistentState):
2741         * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
2742         * UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm:
2743         (WebKit::WebResourceLoadStatisticsManager::registerUserDefaultsIfNeeded):
2744         * UIProcess/WebResourceLoadObserver.cpp: Removed.
2745         * UIProcess/WebResourceLoadObserver.h: Removed.
2746         * UIProcess/WebResourceLoadStatisticsManager.cpp:
2747         (WebKit::primaryDomain):
2748         (WebKit::WebResourceLoadStatisticsManager::shared):
2749         (WebKit::WebResourceLoadStatisticsManager::setStatisticsStore):
2750         (WebKit::WebResourceLoadStatisticsManager::setStatisticsQueue):
2751         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryStore):
2752         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
2753         (WebKit::WebResourceLoadStatisticsManager::logUserInteraction):
2754         (WebKit::WebResourceLoadStatisticsManager::clearUserInteraction):
2755         (WebKit::WebResourceLoadStatisticsManager::hasHadUserInteraction):
2756         (WebKit::WebResourceLoadStatisticsManager::setPrevalentResource):
2757         (WebKit::WebResourceLoadStatisticsManager::isPrevalentResource):
2758         (WebKit::WebResourceLoadStatisticsManager::clearPrevalentResource):
2759         (WebKit::WebResourceLoadStatisticsManager::setGrandfathered):
2760         (WebKit::WebResourceLoadStatisticsManager::isGrandfathered):
2761         (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
2762         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
2763         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
2764         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
2765         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
2766         (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
2767         (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
2768         (WebKit::WebResourceLoadStatisticsManager::fireDataModificationHandler):
2769         (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
2770         (WebKit::WebResourceLoadStatisticsManager::fireTelemetryHandler):
2771         * UIProcess/WebResourceLoadStatisticsManager.h:
2772         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2773         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
2774         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2775         (WebKit::WebsiteDataStore::removeData):
2776         * WebKit2.xcodeproj/project.pbxproj:
2777
2778 2017-06-30  Wenson Hsieh  <wenson_hsieh@apple.com>
2779
2780         [iOS DnD] Drag caret rect is incorrectly computed when dropping in editable content in iframes
2781         https://bugs.webkit.org/show_bug.cgi?id=174017
2782         <rdar://problem/32959782>
2783
2784         Reviewed by Simon Fraser.
2785
2786         Send the drag caret rect in root view coordinates over to the UI process.
2787
2788         * UIProcess/API/Cocoa/WKWebView.mm:
2789         (-[WKWebView _dragCaretRect]):
2790         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2791
2792         Add basic test plumbing to fetch the current drag caret rect.
2793
2794         * WebProcess/WebPage/WebPage.cpp:
2795         (WebKit::WebPage::performDragControllerAction):
2796
2797 2017-06-30  Youenn Fablet  <youenn@apple.com>
2798
2799         Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration
2800         https://bugs.webkit.org/show_bug.cgi?id=169389
2801
2802         Reviewed by Alex Christensen.
2803
2804         * fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt:
2805
2806 2017-06-29  Ryosuke Niwa  <rniwa@webkit.org>
2807
2808         Assert that callback ID is not 0 or -1 during encoding and decoding
2809         https://bugs.webkit.org/show_bug.cgi?id=173803
2810
2811         Reviewed by Brady Eidson.
2812
2813         To diagnosing the hang inside Safari (<rdar://problem/32841256>), add assertions for the callback ID
2814         to be not 0 or -1 during encoding and decoding of IPC messages since the latest analysis seems to
2815         indicate the hang is caused by the hash map getting corrupted by the insertion of 0 (empty value).
2816
2817         Wrapped the uint64_t in CallbackID and OptionalCallbackID to add assertions.
2818
2819         * NetworkProcess/soup/NetworkProcessSoup.cpp:
2820         (WebKit::NetworkProcess::platformInitializeNetworkProcess):
2821         * Shared/CallbackID.h: Added.
2822         (WebKit::CallbackID::CallbackID):
2823         (WebKit::CallbackID::operator==):
2824         (WebKit::CallbackID::toInteger):
2825         (WebKit::CallbackID::isValid):
2826         (WebKit::CallbackID::isValidCallbackID): A callback ID is valid when it's neither 0 nor -1.
2827         (WebKit::CallbackID::fromInteger): Create a CallbackID object from potentially unsafe value.
2828         (WebKit::CallbackID::generateID): Generates the next callback ID. Moved from CallbackBase.
2829         (WebKit::CallbackID::encode): Added. Assert that it's neither 0 nor -1.
2830         (WebKit::CallbackID::decode): Ditto.
2831         (WTF::CallbackIDHash::hash):
2832         (WTF::CallbackIDHash::equal):
2833         (WTF::HashTraits<WebKit::CallbackID>::emptyValue):
2834         (WTF::HashTraits<WebKit::CallbackID>::constructDeletedValue):
2835         (WTF::HashTraits<WebKit::CallbackID>::isDeletedValue):
2836         * Shared/OptionalCallbackID.h: Added. Unlike CallbackID, callback ID here can be 0.
2837         (WebKit::OptionalCallbackID::OptionalCallbackID):
2838         (WebKit::OptionalCallbackID::toInteger):
2839         (WebKit::OptionalCallbackID::callbackID): Returns a valid CallbackID object. The caller of
2840         this function must have verified that the ID is neither 0 or -1 before calling this function.
2841         (WebKit::OptionalCallbackID::operator bool):
2842         (WebKit::OptionalCallbackID::isValid):
2843         (WebKit::OptionalCallbackID::isValidCallbackID):
2844         (WebKit::OptionalCallbackID::encode): Since OptionalCallbackID can be 0, only assert that it's not -1.
2845         (WebKit::OptionalCallbackID::decode): Ditto.
2846         * Shared/mac/RemoteLayerTreeTransaction.h:
2847         * Shared/mac/RemoteLayerTreeTransaction.h:
2848         * UIProcess/GenericCallback.h:
2849         (WebKit::CallbackBase::callbackID): Returns a CallbackID object instead of uint64_t.
2850         (WebKit::CallbackBase::CallbackBase):
2851         (WebKit::CallbackBase::generateCallbackID): Deleted.
2852         (WebKit::CallbackMap::put): Returns a callback ID. Also added a version that doesn't take activity token
2853         as used in WebCookieManagerProxy
2854         (WebKit::CallbackMap::take): Takes a callback ID.
2855         * UIProcess/WebCookieManagerProxy.cpp: Updated the code as callback maps are merged.
2856         (WebKit::WebCookieManagerProxy::processPoolDestroyed):
2857         (WebKit::WebCookieManagerProxy::processDidClose):
2858         (WebKit::WebCookieManagerProxy::getHostnamesWithCookies):
2859         (WebKit::WebCookieManagerProxy::didGetHostnamesWithCookies):
2860         (WebKit::WebCookieManagerProxy::deleteCookie):
2861         (WebKit::WebCookieManagerProxy::deleteAllCookiesModifiedSince):
2862         (WebKit::WebCookieManagerProxy::setCookie):
2863         (WebKit::WebCookieManagerProxy::setCookies):
2864         (WebKit::WebCookieManagerProxy::getAllCookies):
2865         (WebKit::WebCookieManagerProxy::getCookies):
2866         (WebKit::WebCookieManagerProxy::didSetCookies):
2867         (WebKit::WebCookieManagerProxy::didGetCookies):
2868         (WebKit::WebCookieManagerProxy::didDeleteCookies):
2869         (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
2870         (WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy):
2871         (WebKit::WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy):
2872         (WebKit::WebCookieManagerProxy::didSetHTTPCookieAcceptPolicy):
2873         * UIProcess/WebCookieManagerProxy.h:
2874         * UIProcess/WebCookieManagerProxy.messages.in:
2875         * UIProcess/WebPageProxy.cpp:
2876         (WebKit::WebPageProxy::setInitialFocus):
2877         (WebKit::WebPageProxy::validateCommand):
2878         (WebKit::WebPageProxy::runJavaScriptInMainFrame):
2879         (WebKit::WebPageProxy::getRenderTreeExternalRepresentation):
2880         (WebKit::WebPageProxy::getSourceForFrame):
2881         (WebKit::WebPageProxy::getContentsAsString):
2882         (WebKit::WebPageProxy::getBytecodeProfile):
2883         (WebKit::WebPageProxy::getSamplingProfilerOutput):
2884         (WebKit::WebPageProxy::getContentsAsMHTMLData):
2885         (WebKit::WebPageProxy::getSelectionOrContentsAsString):
2886         (WebKit::WebPageProxy::getSelectionAsWebArchiveData):
2887         (WebKit::WebPageProxy::getMainResourceDataOfFrame):
2888         (WebKit::WebPageProxy::getResourceDataFromFrame):
2889         (WebKit::WebPageProxy::getWebArchiveOfFrame):
2890         (WebKit::WebPageProxy::forceRepaint):
2891         (WebKit::WebPageProxy::clearLoadDependentCallbacks):
2892         (WebKit::WebPageProxy::voidCallback):
2893         (WebKit::WebPageProxy::dataCallback):
2894         (WebKit::WebPageProxy::imageCallback):
2895         (WebKit::WebPageProxy::stringCallback):
2896         (WebKit::WebPageProxy::invalidateStringCallback):
2897         (WebKit::WebPageProxy::scriptValueCallback):
2898         (WebKit::WebPageProxy::computedPagesCallback):
2899         (WebKit::WebPageProxy::validateCommandCallback):
2900         (WebKit::WebPageProxy::unsignedCallback):
2901         (WebKit::WebPageProxy::editingRangeCallback):
2902         (WebKit::WebPageProxy::machSendRightCallback):
2903         (WebKit::WebPageProxy::rectForCharacterRangeCallback):
2904         (WebKit::WebPageProxy::printFinishedCallback):
2905         (WebKit::WebPageProxy::computePagesForPrinting):
2906         (WebKit::WebPageProxy::drawRectToImage):
2907         (WebKit::WebPageProxy::drawPagesToPDF):
2908         (WebKit::WebPageProxy::drawPagesForPrinting):
2909         (WebKit::WebPageProxy::getMarkedRangeAsync):
2910         (WebKit::WebPageProxy::getSelectedRangeAsync):
2911         (WebKit::WebPageProxy::characterIndexForPointAsync):
2912         (WebKit::WebPageProxy::firstRectForCharacterRangeAsync):
2913         (WebKit::WebPageProxy::takeSnapshot):
2914         (WebKit::WebPageProxy::installActivityStateChangeCompletionHandler):
2915         (WebKit::WebPageProxy::getLoadDecisionForIcon):
2916         (WebKit::WebPageProxy::finishedLoadingIcon):
2917         * UIProcess/WebPageProxy.h:
2918         * UIProcess/WebPageProxy.messages.in:
2919         * UIProcess/ios/WebPageProxyIOS.mm:
2920         (WebKit::WebPageProxy::gestureCallback):
2921         (WebKit::WebPageProxy::touchesCallback):
2922         (WebKit::WebPageProxy::autocorrectionDataCallback):
2923         (WebKit::WebPageProxy::selectionContextCallback):
2924         (WebKit::WebPageProxy::autocorrectionContextCallback):
2925         (WebKit::WebPageProxy::selectionRectsCallback):
2926         (WebKit::WebPageProxy::selectWithGesture):
2927         (WebKit::WebPageProxy::updateSelectionWithTouches):
2928         (WebKit::WebPageProxy::requestAutocorrectionData):
2929         (WebKit::WebPageProxy::applyAutocorrection):
2930         (WebKit::WebPageProxy::executeEditCommand):
2931         (WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
2932         (WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
2933         (WebKit::WebPageProxy::moveSelectionAtBoundaryWithDirection):
2934         (WebKit::WebPageProxy::selectPositionAtPoint):
2935         (WebKit::WebPageProxy::beginSelectionInDirection):
2936         (WebKit::WebPageProxy::updateSelectionWithExtentPoint):
2937         (WebKit::WebPageProxy::updateSelectionWithExtentPointAndBoundary):
2938         (WebKit::WebPageProxy::requestDictationContext):
2939         (WebKit::WebPageProxy::requestAutocorrectionContext):
2940         (WebKit::WebPageProxy::getSelectionContext):
2941         (WebKit::WebPageProxy::selectWithTwoTouches):
2942         (WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
2943         (WebKit::WebPageProxy::requestRectsAtSelectionOffsetWithText):
2944         (WebKit::WebPageProxy::moveSelectionByOffset):
2945         (WebKit::WebPageProxy::focusNextAssistedNode):
2946         (WebKit::WebPageProxy::computePagesForPrintingAndDrawToPDF):
2947         (WebKit::WebPageProxy::drawToPDFCallback):
2948         * UIProcess/mac/WKPrintingView.mm:
2949         (-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]):
2950         (-[WKPrintingView _askPageToComputePageRects]):
2951         (-[WKPrintingView _drawPreview:]):
2952         * UIProcess/mac/WebPageProxyMac.mm:
2953         (WebKit::WebPageProxy::attributedSubstringForCharacterRangeAsync):
2954         (WebKit::WebPageProxy::attributedStringForCharacterRangeCallback):
2955         (WebKit::WebPageProxy::fontAtSelection):
2956         (WebKit::WebPageProxy::fontAtSelectionCallback):
2957         * WebKit2.xcodeproj/project.pbxproj:
2958         * WebProcess/Cookies/WebCookieManager.cpp:
2959         (WebKit::WebCookieManager::getHostnamesWithCookies):
2960         (WebKit::WebCookieManager::deleteCookie):
2961         (WebKit::WebCookieManager::deleteAllCookiesModifiedSince):
2962         (WebKit::WebCookieManager::getAllCookies):
2963         (WebKit::WebCookieManager::getCookies):
2964         (WebKit::WebCookieManager::setCookie):
2965         (WebKit::WebCookieManager::setCookies):
2966         (WebKit::WebCookieManager::setHTTPCookieAcceptPolicy):
2967         (WebKit::WebCookieManager::getHTTPCookieAcceptPolicy):
2968         * WebProcess/Cookies/WebCookieManager.h:
2969         * WebProcess/Cookies/WebCookieManager.messages.in:
2970         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2971         (WebKit::WebFrameLoaderClient::getLoadDecisionForIcon):
2972         (WebKit::WebFrameLoaderClient::finishedLoadingIcon):
2973         * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
2974         (WebKit::AcceleratedDrawingArea::forceRepaintAsync):
2975         (WebKit::AcceleratedDrawingArea::activityStateDidChange):
2976         * WebProcess/WebPage/AcceleratedDrawingArea.h:
2977         * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
2978         (WebKit::CoordinatedLayerTreeHost::forceRepaintAsync):
2979         (WebKit::CoordinatedLayerTreeHost::renderNextFrame):
2980         * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
2981         * WebProcess/WebPage/DrawingArea.h:
2982         (WebKit::DrawingArea::forceRepaintAsync):
2983         (WebKit::DrawingArea::activityStateDidChange):
2984         (WebKit::DrawingArea::addTransactionCallbackID):
2985         * WebProcess/WebPage/DrawingArea.messages.in:
2986         * WebProcess/WebPage/LayerTreeHost.h:
2987         (WebKit::LayerTreeHost::forceRepaintAsync):
2988         * WebProcess/WebPage/WebPage.cpp:
2989         (WebKit::WebPage::reinitializeWebPage):
2990         (WebKit::WebPage::takeSnapshot):
2991         (WebKit::WebPage::validateCommand):
2992         (WebKit::WebPage::setInitialFocus):
2993         (WebKit::WebPage::setActivityState):
2994         (WebKit::WebPage::runJavaScriptInMainFrame):
2995         (WebKit::WebPage::getContentsAsString):
2996         (WebKit::WebPage::getContentsAsMHTMLData):
2997         (WebKit::WebPage::getRenderTreeExternalRepresentation):
2998         (WebKit::WebPage::getSelectionAsWebArchiveData):
2999         (WebKit::WebPage::getSelectionOrContentsAsString):
3000         (WebKit::WebPage::getSourceForFrame):
3001         (WebKit::WebPage::getMainResourceDataOfFrame):
3002         (WebKit::WebPage::getResourceDataFromFrame):
3003         (WebKit::WebPage::getWebArchiveOfFrame):
3004         (WebKit::WebPage::forceRepaint):
3005         (WebKit::WebPage::computePagesForPrinting):
3006         (WebKit::WebPage::drawRectToImage):
3007         (WebKit::WebPage::drawPagesToPDF):
3008         (WebKit::WebPage::drawPagesForPrinting):
3009         (WebKit::WebPage::didFinishPrintOperation):
3010         (WebKit::WebPage::getMarkedRangeAsync):
3011         (WebKit::WebPage::getSelectedRangeAsync):
3012         (WebKit::WebPage::characterIndexForPointAsync):
3013         (WebKit::WebPage::firstRectForCharacterRangeAsync):
3014         (WebKit::WebPage::getBytecodeProfile):
3015         (WebKit::WebPage::getSamplingProfilerOutput):
3016         (WebKit::WebPage::didGetLoadDecisionForIcon):
3017         * WebProcess/WebPage/WebPage.h:
3018         * WebProcess/WebPage/WebPage.messages.in:
3019         * WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
3020         (WebKit::WebPrintOperationGtk::WebPrintOperationGtk):
3021         * WebProcess/WebPage/gtk/WebPrintOperationGtk.h:
3022         * WebProcess/WebPage/ios/WebPageIOS.mm:
3023         (WebKit::WebPage::getSelectionContext):
3024         (WebKit::WebPage::selectWithGesture):
3025         (WebKit::WebPage::updateSelectionWithTouches):
3026         (WebKit::WebPage::selectWithTwoTouches):
3027         (WebKit::WebPage::moveSelectionByOffset):
3028         (WebKit::WebPage::getRectsForGranularityWithSelectionOffset):
3029         (WebKit::WebPage::getRectsAtSelectionOffsetWithText):
3030         (WebKit::WebPage::selectPositionAtPoint):
3031         (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
3032         (WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
3033         (WebKit::WebPage::selectTextWithGranularityAtPoint):
3034         (WebKit::WebPage::beginSelectionInDirection):
3035         (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
3036         (WebKit::WebPage::updateSelectionWithExtentPoint):
3037         (WebKit::WebPage::requestDictationContext):
3038         (WebKit::WebPage::requestAutocorrectionData):
3039         (WebKit::WebPage::applyAutocorrection):
3040         (WebKit::WebPage::executeEditCommandWithCallback):
3041         (WebKit::WebPage::requestAutocorrectionContext):
3042         (WebKit::WebPage::focusNextAssistedNode):
3043         (WebKit::WebPage::computePagesForPrintingAndDrawToPDF):
3044         * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
3045         * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
3046         (WebKit::RemoteLayerTreeDrawingArea::activityStateDidChange):
3047         (WebKit::RemoteLayerTreeDrawingArea::addTransactionCallbackID):
3048         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
3049         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
3050         (WebKit::TiledCoreAnimationDrawingArea::forceRepaintAsync):
3051         (WebKit::TiledCoreAnimationDrawingArea::activityStateDidChange):
3052         (WebKit::TiledCoreAnimationDrawingArea::didUpdateActivityStateTimerFired):
3053         * WebProcess/WebPage/mac/WebPageMac.mm:
3054         (WebKit::WebPage::attributedSubstringForCharacterRangeAsync):
3055         (WebKit::WebPage::fontAtSelection):
3056
3057 2017-06-29  Andy Estes  <aestes@apple.com>
3058
3059         [iOS] Don't confuse coordinate spaces when computing the size of PDF snapshots
3060         https://bugs.webkit.org/show_bug.cgi?id=173996
3061         <rdar://problem/32961028>
3062
3063         Reviewed by Tim Horton.
3064
3065         When computing the printing rect for PDF snapshots, we were getting the width the
3066         WKContentView's bounds and the height from the WKScrollView's contentSize. These sizes are
3067         in different coordinate spaces, leading to incorrect clipping on sites that have a non-1
3068         scale factor.
3069
3070         Fix this by using the WKContentView's bounds for both width and height.
3071
3072         * UIProcess/ios/WKContentView.mm:
3073         (-[WKContentView _wk_pageCountForPrintFormatter:]):
3074
3075 2017-06-29  Matt Lewis  <jlewis3@apple.com>
3076
3077         Unreviewed, rolling out r218903.
3078
3079         This patch and its fix cause immediate flakiness on all WK2
3080         testers
3081
3082         Reverted changeset:
3083
3084         "Support PeerConnectionStates::BundlePolicy::MaxBundle when
3085         setting rtc configuration"
3086         https://bugs.webkit.org/show_bug.cgi?id=169389
3087         http://trac.webkit.org/changeset/218903
3088
3089 2017-06-29  Chris Dumez  <cdumez@apple.com>
3090
3091         Split ResourceLoadObserver into 2 classes: one for WebCore and one for the UIProcess
3092         https://bugs.webkit.org/show_bug.cgi?id=173990
3093
3094         Reviewed by Brent Fulgham.
3095
3096         Split ResourceLoadObserver into 2 classes: one for WebCore and one for the UIProcess.
3097         They really have different API and there is therefore close to no code duplication.
3098
3099         * CMakeLists.txt:
3100         * UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm:
3101         (WebKit::WebResourceLoadStatisticsManager::registerUserDefaultsIfNeeded):
3102         * UIProcess/WebResourceLoadObserver.cpp: Added.
3103         (WebKit::primaryDomain):
3104         (WebKit::WebResourceLoadObserver::sharedObserver):
3105         (WebKit::WebResourceLoadObserver::setStatisticsStore):
3106         (WebKit::WebResourceLoadObserver::setStatisticsQueue):
3107         (WebKit::WebResourceLoadObserver::clearInMemoryStore):
3108         (WebKit::WebResourceLoadObserver::clearInMemoryAndPersistentStore):
3109         (WebKit::WebResourceLoadObserver::logUserInteraction):
3110         (WebKit::WebResourceLoadObserver::clearUserInteraction):
3111         (WebKit::WebResourceLoadObserver::hasHadUserInteraction):
3112         (WebKit::WebResourceLoadObserver::setPrevalentResource):
3113         (WebKit::WebResourceLoadObserver::isPrevalentResource):
3114         (WebKit::WebResourceLoadObserver::clearPrevalentResource):
3115         (WebKit::WebResourceLoadObserver::setGrandfathered):
3116         (WebKit::WebResourceLoadObserver::isGrandfathered):
3117         (WebKit::WebResourceLoadObserver::setSubframeUnderTopFrameOrigin):
3118         (WebKit::WebResourceLoadObserver::setSubresourceUnderTopFrameOrigin):
3119         (WebKit::WebResourceLoadObserver::setSubresourceUniqueRedirectTo):
3120         (WebKit::WebResourceLoadObserver::setTimeToLiveUserInteraction):
3121         (WebKit::WebResourceLoadObserver::setTimeToLiveCookiePartitionFree):
3122         (WebKit::WebResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval):
3123         (WebKit::WebResourceLoadObserver::setGrandfatheringTime):
3124         (WebKit::WebResourceLoadObserver::fireDataModificationHandler):
3125         (WebKit::WebResourceLoadObserver::fireShouldPartitionCookiesHandler):
3126         (WebKit::WebResourceLoadObserver::fireTelemetryHandler):
3127         * UIProcess/WebResourceLoadObserver.h: Added.
3128         * UIProcess/WebResourceLoadStatisticsManager.cpp:
3129         (WebKit::WebResourceLoadStatisticsManager::setPrevalentResource):
3130         (WebKit::WebResourceLoadStatisticsManager::isPrevalentResource):
3131         (WebKit::WebResourceLoadStatisticsManager::setHasHadUserInteraction):
3132         (WebKit::WebResourceLoadStatisticsManager::hasHadUserInteraction):
3133         (WebKit::WebResourceLoadStatisticsManager::setGrandfathered):
3134         (WebKit::WebResourceLoadStatisticsManager::isGrandfathered):
3135         (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
3136         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
3137         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
3138         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
3139         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
3140         (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
3141         (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
3142         (WebKit::WebResourceLoadStatisticsManager::fireDataModificationHandler):
3143         (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
3144         (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandlerForOneDomain):
3145         (WebKit::WebResourceLoadStatisticsManager::fireTelemetryHandler):
3146         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
3147         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStoreModifiedSinceHours):
3148         (WebKit::WebResourceLoadStatisticsManager::resetToConsistentState):
3149         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3150         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
3151         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3152         (WebKit::WebsiteDataStore::removeData):
3153         * WebKit2.xcodeproj/project.pbxproj:
3154
3155 2017-06-29  Sam Weinig  <sam@webkit.org>
3156
3157         [WebIDL] Remove custom binding for UserMessageHandlersNamespace
3158         https://bugs.webkit.org/show_bug.cgi?id=173956
3159
3160         Reviewed by Darin Adler.
3161
3162         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp:
3163         (webkit_dom_dom_window_webkit_message_handlers_post_message):
3164         Update for name change.
3165
3166 2017-06-29  John Wilander  <wilander@apple.com>
3167
3168         Fix for intermittent Layout Test fail http/tests/loading/resourceLoadStatistics/telemetry-generation.html
3169         https://bugs.webkit.org/show_bug.cgi?id=173940
3170         <rdar://problem/33018125>
3171
3172         Reviewed by Brent Fulgham.
3173
3174         This change allows the TestController to turn off
3175         regular resource load statistics telemetry submission
3176         and to manually control when telemetry is calculated
3177         and submitted.
3178
3179         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
3180         (WKResourceLoadStatisticsManagerSetShouldSubmitTelemetry):
3181             New test infrastructure.
3182         * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
3183         * UIProcess/WebResourceLoadStatisticsManager.cpp:
3184         (WebKit::WebResourceLoadStatisticsManager::setShouldSubmitTelemetry):
3185             New test infrastructure.
3186         * UIProcess/WebResourceLoadStatisticsManager.h:
3187         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3188         (WebKit::WebResourceLoadStatisticsStore::setShouldSubmitTelemetry):
3189             New test infrastructure.
3190         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
3191             The test function now calls
3192             WebResourceLoadStatisticsStore::submitTelemetry() directly
3193             instead of firing the timer.
3194         (WebKit::WebResourceLoadStatisticsStore::telemetryTimerFired):
3195             Now checks whether it should submit telemetry or not.
3196         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
3197             Split out so that the test code doesn't have to fire the timer.
3198         * UIProcess/WebResourceLoadStatisticsStore.h:
3199         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
3200         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
3201             Now doesn't submit if it's executed by test code.
3202
3203 2017-06-29  Chris Dumez  <cdumez@apple.com>
3204
3205         Slight clean up of WebResourceLoadStatisticsStore
3206         https://bugs.webkit.org/show_bug.cgi?id=173976
3207
3208         Reviewed by Brent Fulgham.
3209
3210         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3211         (WebKit::dataTypesToRemove):
3212         (WebKit::WebResourceLoadStatisticsStore::classifyResource):
3213         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
3214         (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsEnabled):
3215         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
3216         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
3217         (WebKit::WebResourceLoadStatisticsStore::stopMonitoringStatisticsStorage):
3218         (WebKit::initializeDataTypesToRemove): Deleted.
3219         * UIProcess/WebResourceLoadStatisticsStore.h:
3220         (WebKit::WebResourceLoadStatisticsStore::coreStore): Deleted.
3221
3222 2017-06-29  Alex Christensen  <achristensen@webkit.org>
3223
3224         WKContentRuleLists with if-top-url or unless-top-url should run regex against entire top URL
3225         https://bugs.webkit.org/show_bug.cgi?id=173980
3226
3227         Reviewed by Tim Horton.
3228
3229         if-top-url and unless-top-url were broken inside WebKit2 apps.  This fixes them and adds a test.
3230         ContentExtension::populateConditionCacheIfNeeded was calling WebCompiledContentRuleList::conditionsApplyOnlyToDomain
3231         but m_data.conditionsApplyOnlyToDomainOffset was always 0 instead of ConditionsApplyOnlyToDomainOffset because 
3232         it wasn't being encoded and decoded when telling the WebProcess about the content rule list.  This was causing us
3233         to use whatever was at offset 0 in the file instead of the correct value stored in the file to determine
3234         whether to run regular expressions against the entire top URL for if-top-url or unless-top-url or against
3235         just the domain for if-top-domain or unless-top-domain.  Luckily, offset 0 in the file is always 
3236         ContentRuleListStore::CurrentContentRuleListFileVersion, so it was deterministic and easy to debug.
3237
3238         I should have added a LayoutTest with r213669 to verify correct behavior in an actual WKWebView,
3239         but I didn't because it wouldn't have caught regressions since the contentextension tests are
3240         marked as flaky since r206914, but once that is fixed the new test http/tests/contentextensions/top-url.html
3241         will verify that this feature is behaving correctly.  It failed before this change and passes after.
3242
3243         * Shared/WebCompiledContentRuleListData.cpp:
3244         (WebKit::WebCompiledContentRuleListData::encode):
3245         (WebKit::WebCompiledContentRuleListData::decode):
3246
3247 2017-06-29  Chris Dumez  <cdumez@apple.com>
3248
3249         statistics.mostRecentUserInteraction should be of type WallTime
3250         https://bugs.webkit.org/show_bug.cgi?id=173974
3251
3252         Reviewed by Brent Fulgham.
3253
3254         statistics.mostRecentUserInteraction should be of type WallTime for clarity.
3255
3256         * Shared/WebCoreArgumentCoders.cpp:
3257         (IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
3258         (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
3259
3260 2017-06-29  Wenson Hsieh  <wenson_hsieh@apple.com>
3261
3262         Replace staging-prefixed UIKit drag and drop delegate methods with their public SDK versions
3263         https://bugs.webkit.org/show_bug.cgi?id=173959
3264
3265         Reviewed by Sam Weinig.
3266
3267         Remove references to _api_-prefixed UIDragInteractionDelegate and UIDropInteractionDelegate methods,
3268         and replace them with their counterparts in the public SDK.
3269
3270         * UIProcess/ios/WKContentViewInteraction.mm:
3271         (-[WKContentView dragInteraction:previewForLiftingItem:session:]):
3272         (-[WKContentView dragInteraction:session:didEndWithOperation:]):
3273         (-[WKContentView dragInteraction:item:willAnimateCancelWithAnimator:]):
3274         (-[WKContentView dropInteraction:sessionDidEnter:]):
3275         (-[WKContentView dropInteraction:sessionDidUpdate:]):
3276         (-[WKContentView _simulateDataInteractionEntered:]):
3277         (-[WKContentView _simulateDataInteractionUpdated:]):
3278         (-[WKContentView _simulateDataInteractionSessionDidEnd:]):
3279         (-[WKContentView _api_dragInteraction:previewForLiftingItem:session:]): Deleted.
3280         (-[WKContentView _api_dragInteraction:session:didEndWithOperation:]): Deleted.
3281         (-[WKContentView _api_dragInteraction:item:willAnimateCancelWithAnimator:]): Deleted.
3282         (-[WKContentView _api_dropInteraction:sessionDidEnter:]): Deleted.
3283         (-[WKContentView _api_dropInteraction:sessionDidUpdate:]): Deleted.
3284
3285 2017-06-29  Carlos Garcia Campos  <cgarcia@igalia.com>
3286
3287         Unreviewed. Fix GTK+ unit tests crashing after r218922.
3288
3289         We need to check if icon database exists and is open now on dispose and API entry points.
3290
3291         * UIProcess/API/glib/WebKitFaviconDatabase.cpp:
3292         (webkitFaviconDatabaseDispose):
3293         (webkit_favicon_database_get_favicon_uri):
3294         (webkit_favicon_database_clear):
3295
3296 2017-06-29  Carlos Garcia Campos  <cgarcia@igalia.com>
3297
3298         [GTK][WPE] Implement API::IconLoadingClient and rework WebKitFaviconDatabase to use IconDatabase directly
3299         https://bugs.webkit.org/show_bug.cgi?id=173877
3300
3301         Reviewed by Brady Eidson.
3302
3303         This way IconDatabase and its related classes can be removed from WebCore, as well as the WebKit2 implementation
3304         and C API. For now I've copied IconDatabase from WebCore to WebKit2 under the glib API directory, adding the
3305         related classes as private inside IconDatabase, and removing some methods that are not used by the GLib API.
3306
3307         * PlatformGTK.cmake:
3308         * UIProcess/API/glib/IconDatabase.cpp: Added.
3309         (WebKit::urlForLogging):
3310         (WebKit::defaultClient):
3311         (WebKit::IconDatabase::IconRecord::IconRecord):
3312         (WebKit::IconDatabase::IconRecord::~IconRecord):
3313         (WebKit::IconDatabase::IconRecord::image):
3314         (WebKit::IconDatabase::IconRecord::setImageData):
3315         (WebKit::IconDatabase::IconRecord::loadImageFromResource):
3316         (WebKit::IconDatabase::IconRecord::imageDataStatus):
3317         (WebKit::IconDatabase::IconRecord::snapshot):
3318         (WebKit::IconDatabase::PageURLRecord::PageURLRecord):
3319         (WebKit::IconDatabase::PageURLRecord::~PageURLRecord):
3320         (WebKit::IconDatabase::PageURLRecord::setIconRecord):
3321         (WebKit::IconDatabase::PageURLRecord::snapshot):
3322         (WebKit::IconDatabase::setClient):
3323         (WebKit::IconDatabase::open):
3324         (WebKit::IconDatabase::close):
3325         (WebKit::IconDatabase::removeAllIcons):
3326         (WebKit::documentCanHaveIcon):
3327         (WebKit::IconDatabase::synchronousIconForPageURL):
3328         (WebKit::IconDatabase::synchronousIconURLForPageURL):
3329         (WebKit::IconDatabase::retainIconForPageURL):
3330         (WebKit::IconDatabase::performRetainIconForPageURL):
3331         (WebKit::IconDatabase::releaseIconForPageURL):
3332         (WebKit::IconDatabase::performReleaseIconForPageURL):
3333         (WebKit::IconDatabase::setIconDataForIconURL):
3334         (WebKit::IconDatabase::setIconURLForPageURL):
3335         (WebKit::IconDatabase::synchronousLoadDecisionForIconURL):
3336         (WebKit::IconDatabase::synchronousIconDataKnownForIconURL):
3337         (WebKit::IconDatabase::setEnabled):
3338         (WebKit::IconDatabase::isEnabled):
3339         (WebKit::IconDatabase::setPrivateBrowsingEnabled):
3340         (WebKit::IconDatabase::isPrivateBrowsingEnabled):
3341         (WebKit::IconDatabase::delayDatabaseCleanup):
3342         (WebKit::IconDatabase::allowDatabaseCleanup):
3343         (WebKit::IconDatabase::checkIntegrityBeforeOpening):
3344         (WebKit::IconDatabase::IconDatabase):
3345         (WebKit::IconDatabase::~IconDatabase):
3346         (WebKit::IconDatabase::wakeSyncThread):
3347         (WebKit::IconDatabase::scheduleOrDeferSyncTimer):
3348         (WebKit::IconDatabase::syncTimerFired):
3349         (WebKit::IconDatabase::isOpen):
3350         (WebKit::IconDatabase::isOpenBesidesMainThreadCallbacks):
3351         (WebKit::IconDatabase::databasePath):
3352         (WebKit::IconDatabase::defaultDatabaseFilename):
3353         (WebKit::IconDatabase::getOrCreateIconRecord):
3354         (WebKit::IconDatabase::getOrCreatePageURLRecord):
3355         (WebKit::IconDatabase::shouldStopThreadActivity):
3356         (WebKit::IconDatabase::iconDatabaseSyncThread):
3357         (WebKit::databaseVersionNumber):
3358         (WebKit::isValidDatabase):
3359         (WebKit::createDatabaseTables):
3360         (WebKit::IconDatabase::performOpenInitialization):
3361         (WebKit::IconDatabase::checkIntegrity):
3362         (WebKit::IconDatabase::performURLImport):
3363         (WebKit::IconDatabase::syncThreadMainLoop):
3364         (WebKit::IconDatabase::performPendingRetainAndReleaseOperations):
3365         (WebKit::IconDatabase::readFromDatabase):
3366         (WebKit::IconDatabase::writeToDatabase):
3367         (WebKit::IconDatabase::pruneUnretainedIcons):
3368         (WebKit::IconDatabase::checkForDanglingPageURLs):
3369         (WebKit::IconDatabase::removeAllIconsOnThread):
3370         (WebKit::IconDatabase::deleteAllPreparedStatements):
3371         (WebKit::IconDatabase::cleanupSyncThread):
3372         (WebKit::readySQLiteStatement):
3373         (WebKit::IconDatabase::setIconURLForPageURLInSQLDatabase):
3374         (WebKit::IconDatabase::setIconIDForPageURLInSQLDatabase):
3375         (WebKit::IconDatabase::removePageURLFromSQLDatabase):
3376         (WebKit::IconDatabase::getIconIDForIconURLFromSQLDatabase):
3377         (WebKit::IconDatabase::addIconURLToSQLDatabase):
3378         (WebKit::IconDatabase::getImageDataForIconURLFromSQLDatabase):
3379         (WebKit::IconDatabase::removeIconFromSQLDatabase):
3380         (WebKit::IconDatabase::writeIconSnapshotToSQLDatabase):
3381         (WebKit::IconDatabase::checkClosedAfterMainThreadCallback):
3382         (WebKit::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread):
3383         (WebKit::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread):
3384         (WebKit::IconDatabase::dispatchDidRemoveAllIconsOnMainThread):
3385         (WebKit::IconDatabase::dispatchDidFinishURLImportOnMainThread):
3386         * UIProcess/API/glib/IconDatabase.h: Added.
3387         (WebKit::IconDatabaseClient::didImportIconURLForPageURL):
3388         (WebKit::IconDatabaseClient::didImportIconDataForPageURL):
3389         (WebKit::IconDatabaseClient::didChangeIconForPageURL):
3390         (WebKit::IconDatabaseClient::didRemoveAllIcons):
3391         (WebKit::IconDatabaseClient::didFinishURLImport):
3392         (WebKit::IconDatabaseClient::didClose):
3393         (WebKit::IconDatabase::IconSnapshot::IconSnapshot):
3394         (WebKit::IconDatabase::IconSnapshot::iconURL):
3395         (WebKit::IconDatabase::IconSnapshot::timestamp):
3396         (WebKit::IconDatabase::IconSnapshot::data):
3397         (WebKit::IconDatabase::IconRecord::create):
3398         (WebKit::IconDatabase::IconRecord::getTimestamp):
3399         (WebKit::IconDatabase::IconRecord::setTimestamp):
3400         (WebKit::IconDatabase::IconRecord::iconURL):
3401         (WebKit::IconDatabase::IconRecord::retainingPageURLs):
3402         (WebKit::IconDatabase::PageURLSnapshot::PageURLSnapshot):
3403         (WebKit::IconDatabase::PageURLSnapshot::pageURL):
3404         (WebKit::IconDatabase::PageURLSnapshot::iconURL):
3405         (WebKit::IconDatabase::PageURLRecord::url):
3406         (WebKit::IconDatabase::PageURLRecord::iconRecord):
3407         (WebKit::IconDatabase::PageURLRecord::retain):
3408         (WebKit::IconDatabase::PageURLRecord::release):
3409         (WebKit::IconDatabase::PageURLRecord::retainCount):
3410         * UIProcess/API/glib/WebKitFaviconDatabase.cpp:
3411         (_WebKitFaviconDatabasePrivate::~_WebKitFaviconDatabasePrivate):
3412         (getIconSurfaceSynchronously):
3413         (webkitFaviconDatabaseSetIconURLForPageURL):
3414         (webkitFaviconDatabaseCreate):
3415         (webkitFaviconDatabaseOpen):
3416         (webkitFaviconDatabaseIsOpen):
3417         (webkitFaviconDatabaseSetPrivateBrowsingEnabled):
3418         (webkitFaviconDatabaseGetLoadDecisionForIcon):
3419         (webkitFaviconDatabaseSetIconForPageURL):
3420         (webkit_favicon_database_get_favicon):
3421         (webkit_favicon_database_get_favicon_uri):
3422         * UIProcess/API/glib/WebKitFaviconDatabasePrivate.h:
3423         * UIProcess/API/glib/WebKitIconLoadingClient.cpp: Added.
3424         (IconLoadingClient::IconLoadingClient):
3425         (attachIconLoadingClientToView):
3426         * UIProcess/API/glib/WebKitIconLoadingClient.h: Copied from Source/WebKit2/UIProcess/API/glib/WebKitFaviconDatabasePrivate.h.
3427         * UIProcess/API/glib/WebKitWebContext.cpp:
3428         (ensureFaviconDatabase):
3429         (webkitWebContextEnableIconDatabasePrivateBrowsingIfNeeded):
3430         (webkitWebContextDisableIconDatabasePrivateBrowsingIfNeeded):
3431         (webkit_web_context_set_favicon_database_directory):
3432         * UIProcess/API/glib/WebKitWebView.cpp:
3433         (webkitWebViewConstructed):
3434         (webkitWebViewGetLoadDecisionForIcon):
3435         (webkitWebViewSetIcon):
3436         * UIProcess/API/glib/WebKitWebViewPrivate.h:
3437
3438 2017-06-28  Tim Horton  <timothy_horton@apple.com>
3439
3440         MobileSafari was constantly using 10-15% CPU viewing a PDF
3441         https://bugs.webkit.org/show_bug.cgi?id=173944
3442         <rdar://problem/33039910>
3443
3444         Reviewed by Simon Fraser.
3445
3446         * UIProcess/API/Cocoa/WKWebView.mm:
3447         (-[WKWebView _doAfterNextStablePresentationUpdate:]):
3448         (-[WKWebView _doAfterNextPresentationUpdate:]):
3449         (-[WKWebView _doAfterNextPresentationUpdateWithoutWaitingForPainting:]):
3450         Bail early and just dispatch_async the completion block if we are using a custom
3451         content view; these methods are very specific to the implementation of WKContentView
3452         and don't make sense with custom content views.
3453
3454         doAfterNextStablePresentationUpdate is particularly egregious because, since
3455         we will never call the stable update callbacks (because we bail from didCommitLayerTree
3456         if we aren't using WKContentView), it will keep calling doAfterNextPresentationUpdate
3457         over and over again.
3458
3459 2017-06-28  Brent Fulgham  <bfulgham@apple.com>
3460
3461         [WK2][macOS][iOS] Don't request microphone access for clients that don't need it.
3462         https://bugs.webkit.org/show_bug.cgi?id=173948
3463         <rdar://problem/32103275>
3464
3465         Reviewed by Eric Carlson.
3466
3467         Don't bother requesting a sandbox extension to access the microphone for any clients
3468         on the Cocoa platform that are not Safari. Other clients don't have the necessary
3469         system entitlements, and always fail leading to annoying SandboxViolation reports.
3470
3471         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
3472         (WebKit::WebProcessPool::platformInitializeWebProcess): 
3473
3474 2017-06-29  Zalan Bujtas  <zalan@apple.com>
3475
3476         Move RenderEmbeddedObject::isReplacementObscured to HTMLPlugInElement
3477         https://bugs.webkit.org/show_bug.cgi?id=173802
3478         <rdar://problem/32884389>
3479
3480         Reviewed by Simon Fraser.
3481
3482         * WebProcess/WebPage/WebPage.cpp:
3483         (WebKit::WebPage::createPlugin):
3484
3485 2017-06-28  Ryosuke Niwa  <rniwa@webkit.org>
3486
3487         REGRESSION (r218842): com.apple.WebKit crash in WebKit::ProcessLauncher::launchProcess
3488         https://bugs.webkit.org/show_bug.cgi?id=173950
3489
3490         Reviewed by Chris Dumez.
3491
3492         Added a null check as m_xpcConnection could be nullptr here in the case platformInvalidate had been called.
3493
3494         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
3495         (WebKit::ProcessLauncher::launchProcess):
3496
3497 2017-06-28  Youenn Fablet  <youenn@apple.com>
3498
3499         Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration
3500         https://bugs.webkit.org/show_bug.cgi?id=169389
3501
3502         Reviewed by Alex Christensen.
3503
3504         Updating according new WebCore LIbWebRTCProvider API.
3505
3506         * WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
3507         (WebKit::LibWebRTCProvider::createPeerConnection):
3508         * WebProcess/Network/webrtc/LibWebRTCProvider.h:
3509
3510 2017-06-28  Chris Dumez  <cdumez@apple.com>
3511
3512         [iOS] Allow WKWebView clients to play audio in the background
3513         https://bugs.webkit.org/show_bug.cgi?id=173932
3514         <rdar://problem/32851547>
3515
3516         Reviewed by Ryosuke Niwa.
3517
3518         Allow WKWebView clients (such as MobileSafari) to play audio in the background
3519         by taking a process assertion whenever a WebPage is audible.
3520
3521         * UIProcess/WebPageProxy.cpp:
3522         (WebKit::WebPageProxy::updateThrottleState):
3523
3524 2017-06-28  Brent Fulgham  <bfulgham@apple.com>
3525
3526         Teach ResourceLoadStatistics to recognize changes in the file system
3527         https://bugs.webkit.org/show_bug.cgi?id=173800
3528         <rdar://problem/32937842>
3529
3530         Reviewed by Chris Dumez.
3531
3532         We want to support the case where multiple UI processes choose to share the same
3533         statistics file. To support this, update the ResourceLoadStatistics logic to be aware
3534         that the statistics data file might change underneath it, and to take appropriate
3535         action when it does.
3536
3537         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3538         (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsEnabled): When we enable
3539         the statistics, read in the data and then watch for changes.
3540         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver): Add a
3541         'delete data' handler to remove the file on disk, not just write an empty store.
3542         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded): Use ASCIILiteral.
3543         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk): Convenience function.
3544         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk): Sync with any on-disk
3545         storage before writing out.
3546         (WebKit::openAndLockFile): Convenience function.
3547         (WebKit::closeAndUnlockFile): Ditto.
3548         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk): Revise to lock file (on
3549         platforms that support it) before writing to disk.
3550         (WebKit::WebResourceLoadStatisticsStore::deleteStoreFromDisk): Added convenience function.
3551         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryData): Ditto.
3552         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage): Create a
3553         file system monitor to watch for file changes.
3554         (WebKit::WebResourceLoadStatisticsStore::syncWithExistingStatisticsStorageIfNeeded): Added
3555         convenience function.
3556         (WebKit::WebResourceLoadStatisticsStore::createDecoderFromDisk): Revise to read data
3557         directly so we can control file locking.
3558         * UIProcess/WebResourceLoadStatisticsStore.h:
3559
3560 2017-06-28  Wenson Hsieh  <wenson_hsieh@apple.com>
3561
3562         Followup to r218885: adjust for further UIKit SPI changes
3563         https://bugs.webkit.org/show_bug.cgi?id=173927
3564         <rdar://problem/33020792>
3565
3566         Reviewed by Tim Horton.
3567
3568         On ToT, UIKit now invokes -_dragInteraction:item:shouldDelaySetDownAnimationWithCompletion: before the
3569         completion block of -dragInteraction:willAnimateLiftWithAnimator:session: is called. This means we now need to
3570         store the completion block in -shouldDelaySetDownAnimationWithCompletion: and wait until the UIDragAnimating
3571         completion block in -willAnimateCancelWithAnimator: before invoking it.
3572
3573         * UIProcess/ios/WKContentViewInteraction.h:
3574         * UIProcess/ios/WKContentViewInteraction.mm:
3575         (-[WKContentView cleanUpDragSourceSessionState]):
3576
3577         Ensure that the set-down completion block is invoked when a drag session ends (e.g., if the web content process
3578         crashes).
3579
3580         (-[WKContentView _dragInteraction:item:shouldDelaySetDownAnimationWithCompletion:]):
3581         (-[WKContentView _api_dragInteraction:item:willAnimateCancelWithAnimator:]):
3582
3583 2017-06-28  Wenson Hsieh  <wenson_hsieh@apple.com>
3584
3585         dropInteraction:sessionDidEnd: invokes dragEnded with a UIDragOperation rather than a WebCore::DragOperation
3586         https://bugs.webkit.org/show_bug.cgi?id=173935
3587
3588         Reviewed by Tim Horton.
3589
3590         Replaces a use of UIDragOperationNone with DragOperationNone.
3591         Currently, there is no change in behavior since these are currently the same value (0).
3592
3593         * UIProcess/ios/WKContentViewInteraction.mm:
3594         (-[WKContentView dropInteraction:sessionDidEnd:]):
3595
3596 2017-06-28  Alex Christensen  <achristensen@webkit.org>
3597
3598         WebsitePolicies given with navigation policy for redirects should apply to the provisional document
3599         https://bugs.webkit.org/show_bug.cgi?id=173886
3600         <rdar://problem/32543191>
3601
3602         Reviewed by Andy Estes.
3603         
3604         If, for example, we deny video autoplay for the initial request but allow it for the redirect destination
3605         location, the document should allow video autoplay.  We were putting these settings onto the wrong DocumentLoader.
3606         When a navigation policy is given to a response of a redirect location, we currently have the DocumentLoader
3607         for the loading document in the FrameLoader's provisionalDocumentLoader, not the documentLoader.
3608         
3609         Covered by a new API test.
3610
3611         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
3612         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
3613
3614 2017-06-28  Konstantin Tokarev  <annulen@yandex.ru>
3615
3616         [cmake] Improve configuration tests for librt and libatomic
3617         https://bugs.webkit.org/show_bug.cgi?id=173921
3618
3619         Reviewed by Michael Catanzaro.
3620
3621         1. Both tests are converted to use specialized CMake modules
3622         2. Both libraries are now linked only if they are really needed and usable
3623            by compiler
3624         3. librt is no more required to be detected by find_library(), which may fail
3625            in case of cross-compilation
3626         4. libatomic test moved to port-independent CMakeLists.txt
3627
3628         * CMakeLists.txt:
3629         * PlatformGTK.cmake:
3630
3631 2017-06-28  Alex Christensen  <achristensen@webkit.org>
3632
3633         Fix CMake build.
3634
3635         * PlatformMac.cmake:
3636
3637 2017-06-28  Wenson Hsieh  <wenson_hsieh@apple.com>
3638
3639         [iOS DnD] [WK2] Dragged content flashes after the preview sets down when cancelling a drag
3640         https://bugs.webkit.org/show_bug.cgi?id=173927
3641         <rdar://problem/33020792>
3642
3643         Reviewed by Tim Horton.
3644
3645         When a drag is cancelled, UIKit normally animates fly-back and set-down animations back-to-back. However, for
3646         WebKit2, we need to call out to the web process in order to trigger a repaint of the dragged content at normal
3647         opacity when the drag cancel animation completes. Thus, we can hook into UIKit SPI to split the cancellation
3648         animation into two discrete phases: the fly-back and the set-down (the latter of which may be deferred using a
3649         completion block).
3650
3651         To do this, we implement a new SPI hook, _dragInteraction:item:shouldDelaySetDownAnimationWithCompletion:, to
3652         indicate that the set-down should be deferred, and call the completion block after the next layer tree commit.
3653         Since -shouldDelaySetDownAnimationWithCompletion: is invoked after the UIDragAnimating completion block in
3654         -willAnimateCancelWithAnimator:, this layer tree commit is guaranteed to come after we've told the web process
3655         to repaint at full opacity.
3656
3657         This patch also accounts for additional changes in UIKit. Once -shouldDelaySetDownAnimationWithCompletion:
3658         becomes available, -sessionDidEnd: will no longer be invoked after a cancelled drag lift if the user did not
3659         begin moving. This means that our cleanup logic in -sessionDidEnd: will no longer be executed in this case,
3660         leaving the view with an inconsistent dragging state. To fix this, we need to implement
3661         -dragInteraction:willAnimateLiftWithAnimator:session: to perform drag session cleanup following a cancelled drag
3662         lift, for which the drag animator's final position will be UIViewAnimatingPositionStart.
3663
3664         * UIProcess/ios/WKContentViewInteraction.mm:
3665         (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
3666         (-[WKContentView _dragInteraction:item:shouldDelaySetDownAnimationWithCompletion:]):
3667
3668 2017-06-28  Chris Dumez  <cdumez@apple.com>
3669
3670         Avoid double thread dispatch in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()
3671         https://bugs.webkit.org/show_bug.cgi?id=173904
3672
3673         Reviewed by Brent Fulgham.
3674
3675         Avoid double thread dispatch in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains().
3676         It calls fetchData() which dispatches to the main queue, then fetchDataForTopPrivatelyControlledDomains()
3677         dispatches to the background queue. It should be possible to get fetchData() to dispatch directly
3678         on the right queue.
3679
3680         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3681         (WebKit::WebsiteDataStore::fetchData):
3682         (WebKit::WebsiteDataStore::fetchDataAndApply):
3683         (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains):
3684         * UIProcess/WebsiteData/WebsiteDataStore.h:
3685
3686 2017-06-27  Chris Dumez  <cdumez@apple.com>
3687
3688         [ResourceLoadStatistics] Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute
3689         https://bugs.webkit.org/show_bug.cgi?id=173895
3690         <rdar://problem/32984366>
3691
3692         Reviewed by Brent Fulgham.
3693
3694         Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute to save battery.
3695         Also port code to modern time types.
3696
3697         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
3698         (WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction):
3699         (WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
3700         (WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval):
3701         (WKResourceLoadStatisticsManagerSetGrandfatheringTime):
3702         * UIProcess/WebResourceLoadStatisticsManager.cpp:
3703         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
3704         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
3705         (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
3706         (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
3707         * UIProcess/WebResourceLoadStatisticsManager.h:
3708         * UIProcess/WebResourceLoadStatisticsStore.h:
3709
3710 2017-06-27  Chris Dumez  <cdumez@apple.com>
3711
3712         Port HysteresisActivity to Seconds type
3713         https://bugs.webkit.org/show_bug.cgi?id=173902
3714
3715         Reviewed by Simon Fraser.
3716
3717         * WebProcess/WebPage/WebPage.cpp:
3718         (WebKit::m_pageScrolledHysteresis):
3719
3720 2017-06-27  Chris Dumez  <cdumez@apple.com>
3721
3722         Move WebsiteDataRecord processing off-thread in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()
3723         https://bugs.webkit.org/show_bug.cgi?id=173882
3724         <rdar://problem/32984366>
3725
3726         Reviewed by Darin Adler.
3727
3728         Move WebsiteDataRecord processing off-thread in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()
3729         as we have data showing it is slow and hangs the UIProcess' main thread.
3730
3731         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3732         (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains):
3733
3734 2017-06-27  Brent Fulgham  <bfulgham@apple.com>
3735
3736         [WK2][macOS] Expand sandbox to allow access to the CoreMedia volume control endpoint
3737         https://bugs.webkit.org/show_bug.cgi?id=173898
3738         <rdar://problem/32930754>
3739
3740         Reviewed by Ryosuke Niwa.
3741
3742         * WebProcess/com.apple.WebProcess.sb.in:
3743
3744 2017-06-27  Wenson Hsieh  <wenson_hsieh@apple.com>
3745
3746         [iOS DnD] Support dragging out of contenteditable areas without a prior selection
3747         https://bugs.webkit.org/show_bug.cgi?id=173854
3748         <rdar://problem/32236827>
3749
3750         Reviewed by Ryosuke Niwa and Tim Horton.
3751
3752         Instead of allowing a drag to occur only if a position information request discovers a clickable node, remove
3753         the position information request entirely and just call into WebCore to try and begin the drag. Currently, the
3754         position information request serves two purposes:
3755         1. To adjust the hit-test location to account for nearby clickable nodes.
3756         2. To obtain information about the content being dragged.
3757
3758         The first requirement is fulfilled by performing the drag location adjustment in WebCore instead (see
3759         ChangeLogs for more detail). The second requirement is fulfilled by refactoring in
3760         https://bugs.webkit.org/show_bug.cgi?id=173832 to fold all information relevant to starting a drag into the
3761         DragItem struct, and then propagating the DragItem struct. The relevant information from the position
3762         information update is now populated when the UI process receives the drag start response.
3763
3764         * UIProcess/ios/WKContentViewInteraction.h:
3765         * UIProcess/ios/WKContentViewInteraction.mm:
3766         (-[WKContentView _startDrag:item:]):
3767         (-[WKContentView computeClientAndGlobalPointsForDropSession:outClientPoint:outGlobalPoint:]):
3768         (-[WKContentView _dragInteraction:prepareForSession:completion:]):
3769         (-[WKContentView _api_dropInteraction:sessionDidEnter:]):
3770         (-[WKContentView _api_dropInteraction:sessionDidUpdate:]):
3771         (positionInformationMayStartDataInteraction): Deleted.
3772
3773 2017-06-27  Chris Dumez  <cdumez@apple.com>
3774
3775         [iOS] Avoid taking / releasing process assertions too quickly due to database activity
3776         https://bugs.webkit.org/show_bug.cgi?id=173879
3777         <rdar://problem/32412701>
3778
3779         Reviewed by Antti Koivisto.
3780
3781         Specify an activity name when taking the process assertion to facilitate
3782         debugging in the future. It took me a while to figure out this assertion
3783         was the one that was too aggressive because it was anonymous.
3784
3785         * UIProcess/API/Cocoa/WKWebView.mm:
3786         (-[WKWebView _setUpSQLiteDatabaseTrackerClient]):
3787
3788 2017-06-27  Don Olmstead  <don.olmstead@sony.com>
3789
3790         [PAL] Add symbol export macros for PAL
3791         https://bugs.webkit.org/show_bug.cgi?id=171519
3792
3793         Reviewed by Konstantin Tokarev.
3794
3795         * config.h:
3796
3797 2017-06-27  Ryosuke Niwa  <rniwa@webkit.org>
3798
3799         ProcessLauncherMac could leak a xpc connection when the process had failed to launch
3800         https://bugs.webkit.org/show_bug.cgi?id=173865
3801
3802         Reviewed by Antti Koivisto.
3803
3804         Explicitly cancel the XPC connection even When the process launch had failed to avoid a leak.
3805
3806         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
3807         (WebKit::ProcessLauncher::launchProcess):
3808
3809 2017-06-27  John Wilander  <wilander@apple.com>
3810
3811         Resource Load Statistics: Add telemetry
3812         https://bugs.webkit.org/show_bug.cgi?id=173499
3813         <rdar://problem/32826094>
3814
3815         Reviewed by Brent Fulgham.
3816
3817         * PlatformGTK.cmake:
3818             Added UIProcess/WebResourceLoadStatisticsTelemetry.cpp
3819         * PlatformMac.cmake:
3820             Added UIProcess/WebResourceLoadStatisticsTelemetry.cpp
3821         * PlatformWPE.cmake:
3822             Added UIProcess/WebResourceLoadStatisticsTelemetry.cpp
3823         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
3824         (WKResourceLoadStatisticsManagerFireTelemetryHandler):
3825         (WKResourceLoadStatisticsManagerSetNotifyPagesWhenTelemetryWasCaptured):
3826             Test infrastructure.
3827         * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
3828         * UIProcess/WebProcessProxy.cpp:
3829         (WebKit::WebProcessProxy::notifyPageStatisticsTelemetryFinished):
3830             Test infrastructure.
3831         * UIProcess/WebProcessProxy.h:
3832         * UIProcess/WebResourceLoadStatisticsManager.cpp:
3833         (WebKit::WebResourceLoadStatisticsManager::fireTelemetryHandler):
3834         (WebKit::WebResourceLoadStatisticsManager::setNotifyPagesWhenTelemetryWasCaptured):
3835         (WebKit::WebResourceLoadStatisticsManager::resetToConsistentState):
3836             Test infrastructure.
3837         * UIProcess/WebResourceLoadStatisticsManager.h:
3838         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3839         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
3840             Configures a timer for telemetry capture. Fires 5 seconds after launch
3841             and then every 24 hours.
3842         (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
3843             Variable renamed notifyPages -> notifyPagesWhenDataRecordsWereScanned.
3844         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
3845             Variable renamed notifyPages -> notifyPagesWhenDataRecordsWereScanned.
3846         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
3847             Variable renamed notifyPages -> notifyPagesWhenDataRecordsWereScanned.
3848         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
3849             Variable renamed notifyPages -> notifyPagesWhenDataRecordsWereScanned.
3850         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
3851             Variable renamed notifyPages -> notifyPagesWhenDataRecordsWereScanned.
3852         (WebKit::WebResourceLoadStatisticsStore::telemetryTimerFired):
3853              Calls WebResourceLoadStatisticsTelemetry::calculateAndSubmit().
3854         * UIProcess/WebResourceLoadStatisticsStore.h:
3855         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp: Added.
3856         (WebKit::numberOfResourcesWithUserInteraction):
3857         (WebKit::median):
3858         (WebKit::nonEphemeralWebPageProxy):
3859         (WebKit::submitTopList):
3860         (WebKit::submitTopLists):
3861         (WebKit::notifyPages):
3862         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
3863         (WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured):
3864         * UIProcess/WebResourceLoadStatisticsTelemetry.h: Added.
3865         * WebKit2.xcodeproj/project.pbxproj:
3866
3867 2017-06-27  Ting-Wei Lan  <lantw44@gmail.com>
3868
3869         Add missing includes to fix compilation error on FreeBSD
3870         https://bugs.webkit.org/show_bug.cgi?id=172919
3871
3872         Reviewed by Mark Lam.
3873
3874         * UIProcess/API/C/WKContextPrivate.h:
3875         * UIProcess/API/C/WKPagePrivate.h:
3876         * UIProcess/ProcessAssertion.h:
3877
3878 2017-06-27  Wenson Hsieh  <wenson_hsieh@apple.com>
3879
3880         Refactor drag start codepaths to plumb a DragItem to client layers
3881         https://bugs.webkit.org/show_bug.cgi?id=173832
3882         Work towards <rdar://problem/32236827>
3883
3884         Reviewed by Ryosuke Niwa and Tim Horton.
3885
3886         Add support for serializing a DragItem over IPC. This encodes and decodes all members of DragItem except for the
3887         PasteboardWriterData and the DragImage's image. The DragItem is sent over to the UI process in
3888         WebDragClient::startDrag via the WebPageProxy::startDrag IPC message (renamed from WebPageProxy::setDragImage)
3889         which now takes a DragItem.
3890
3891         * UIProcess/Cocoa/WebPageProxyCocoa.mm:
3892         (WebKit::WebPageProxy::startDrag):
3893         (WebKit::WebPageProxy::setDragImage): Deleted.
3894         * UIProcess/PageClient.h:
3895         * UIProcess/WebPageProxy.h:
3896         * UIProcess/WebPageProxy.messages.in:
3897
3898         Rename SetDragImage to StartDrag and refactor to receive only a DragItem and shareable bitmap handle.
3899
3900         * UIProcess/ios/PageClientImplIOS.h:
3901         * UIProcess/ios/PageClientImplIOS.mm:
3902         (WebKit::PageClientImpl::startDrag):
3903         (WebKit::PageClientImpl::startDataInteractionWithImage): Deleted.
3904         * UIProcess/ios/WKContentViewInteraction.h:
3905         * UIProcess/ios/WKContentViewInteraction.mm:
3906         (-[WKContentView _startDrag:item:]):
3907         (-[WKContentView _startDataInteractionWithImage:withIndicatorData:atClientPosition:anchorPoint:action:]): Deleted.
3908
3909         Rename startDataInteractionWithImage to startDrag.
3910
3911         * UIProcess/mac/WebPageProxyMac.mm:
3912         (WebKit::WebPageProxy::startDrag):
3913         (WebKit::WebPageProxy::setDragImage): Deleted.
3914         * WebProcess/WebCoreSupport/WebDragClient.cpp:
3915         (WebKit::WebDragClient::startDrag):
3916         * WebProcess/WebCoreSupport/WebDragClient.h:
3917         * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
3918         (WebKit::WebDragClient::startDrag):
3919         * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
3920         (WebKit::WebDragClient::startDrag):
3921
3922 2017-06-27  Wenson Hsieh  <wenson_hsieh@apple.com>
3923
3924         [iOS DnD] [WK2] WKWebView does not handle drag sessions that exit and re-enter
3925         https://bugs.webkit.org/show_bug.cgi?id=173856
3926         <rdar://problem/32957100>
3927
3928         Reviewed by Ryosuke Niwa.
3929
3930         Upon exiting a WKContentView, the dropSession tracked by _dataInteractionState is not cleared out. If the drag
3931         session re-enters the WKWebView, a _different_ UIDropSession is sent to the drop delegate, causing us to bail
3932         from handling the session altogether in -dropInteraction:canHandleSession:. To fix this, we need to clear out
3933         the dropSession when the drag session exits the view.
3934
3935         * UIProcess/ios/WKContentViewInteraction.mm:
3936         (-[WKContentView dropInteraction:sessionDidExit:]):
3937
3938 2017-06-26  Chris Dumez  <cdumez@apple.com>
3939
3940         WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains() is inefficient
3941         https://bugs.webkit.org/show_bug.cgi?id=173850
3942
3943         Reviewed by Ryosuke Niwa.
3944
3945         Update WebsiteDataRecord::matchesTopPrivatelyControlledDomain() to rely on
3946         SecurityOriginData::host rather than SecurityOriginData::securityOrigin()->host().
3947         SecurityOriginData::securityOrigin() is expensive and it seems unnecessary to call
3948         it here since we already have the host.
3949
3950         Also update WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains() to return
3951         domains as a HashSet rather than a Vector to avoid having duplicate domains.
3952
3953         * UIProcess/WebProcessProxy.cpp:
3954         (WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
3955         * UIProcess/WebProcessProxy.h:
3956         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3957         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
3958         * UIProcess/WebsiteData/WebsiteDataRecord.cpp:
3959         (WebKit::WebsiteDataRecord::matchesTopPrivatelyControlledDomain):
3960         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3961         (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains):
3962         (WebKit::WebsiteDataStore::removeDataForTopPrivatelyControlledDomains):
3963         * UIProcess/WebsiteData/WebsiteDataStore.h:
3964
3965 2017-06-26  Jeremy Jones  <jeremyj@apple.com>
3966
3967         Invalidate WebVideoFullscreenManager when WebPage is destroyed.
3968         https://bugs.webkit.org/show_bug.cgi?id=173835
3969         rdar://problem/32969161
3970
3971         Reviewed by Jer Noble.
3972
3973         WebVideoFullscreenManager has a pointer to WebPage, and even null checks it in a few places,
3974         but the only place it is nulled out is in the destructor. This allows a dangling reference.
3975
3976         This changes invalidates that reference when WebPage is destructed and adds nullchecks
3977         or asserts throughout WebVideoFullscreenManager as appropriate.
3978
3979         * WebProcess/WebPage/WebPage.cpp:
3980         (WebKit::WebPage::~WebPage):
3981         * WebProcess/cocoa/WebVideoFullscreenManager.h:
3982         (WebKit::WebVideoFullscreenManager::invalidate):
3983         * WebProcess/cocoa/WebVideoFullscreenManager.mm:
3984         (WebKit::WebVideoFullscreenManager::~WebVideoFullscreenManager):
3985         (WebKit::WebVideoFullscreenManager::enterVideoFullscreenForVideoElement):
3986         (WebKit::WebVideoFullscreenManager::exitVideoFullscreenForVideoElement):
3987         (WebKit::WebVideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation):
3988         (WebKit::WebVideoFullscreenManager::hasVideoChanged):
3989         (WebKit::WebVideoFullscreenManager::videoDimensionsChanged):
3990         (WebKit::WebVideoFullscreenManager::didSetupFullscreen):
3991         (WebKit::WebVideoFullscreenManager::didEnterFullscreen):
3992         (WebKit::WebVideoFullscreenManager::didCleanupFullscreen):
3993         (WebKit::WebVideoFullscreenManager::fullscreenMayReturnToInline):
3994
3995 2017-06-26  Chris Dumez  <cdumez@apple.com>
3996
3997         Disable diagnostic logging in ephemeral sessions
3998         https://bugs.webkit.org/show_bug.cgi?id=173849
3999         <rdar://problem/32987341>
4000
4001         Reviewed by Geoffrey Garen.
4002
4003         * UIProcess/WebPageProxy.cpp:
4004         (WebKit::WebPageProxy::setDiagnosticLoggingClient):
4005         Construct a dummy logging client if the page's session is ephemeral.
4006
4007         (WebKit::WebPageProxy::logDiagnosticMessage):
4008         (WebKit::WebPageProxy::logDiagnosticMessageWithResult):
4009         (WebKit::WebPageProxy::logDiagnosticMessageWithValue):
4010         (WebKit::WebPageProxy::logDiagnosticMessageWithEnhancedPrivacy):
4011         Slight cleanup to make the code look a bit safer.
4012
4013 2017-06-26  Zan Dobersek  <zdobersek@igalia.com>
4014
4015         [GCrypt] Properly initialize libgcrypt before using it
4016         https://bugs.webkit.org/show_bug.cgi?id=173589
4017
4018         Reviewed by Michael Catanzaro.
4019
4020         Initialize libgcrypt in the Unix-specific main() entrypoint. This is early enough
4021         to ensure no other libgcrypt API function is invoked and to also ensure this is
4022         done in a thread-safe manner.
4023
4024         Initialization is initiated through the gcry_check_version() call. 16 kilobytes of
4025         secure memory is pre-allocated before we mark the initialization as complete, as
4026         recommended by the libgcrypt documentation.
4027
4028         * WebProcess/EntryPoint/unix/WebProcessMain.cpp:
4029         (main):
4030
4031 2017-06-26  Jeremy Jones  <jeremyj@apple.com>
4032
4033         When Mission Control closes fullscreen window, allow media element to update its state.
4034         https://bugs.webkit.org/show_bug.cgi?id=173671
4035         rdar://problem/32892671
4036
4037         Reviewed by Eric Carlson.
4038
4039         When Mission Control closes element fullscreen without an animation, we need to notify the
4040         media element that fullscreen has exited.
4041
4042         Without this change, the page still behaves like the element is in fullscreen.
4043
4044         * UIProcess/mac/WKFullScreenWindowController.mm:
4045