[CMake] Create targets before WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS is called
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2017-07-17  Konstantin Tokarev  <annulen@yandex.ru>
2
3         [CMake] Create targets before WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS is called
4         https://bugs.webkit.org/show_bug.cgi?id=174557
5
6         Reviewed by Michael Catanzaro.
7
8         * CMakeLists.txt:
9
10 2017-07-17  Carlos Garcia Campos  <cgarcia@igalia.com>
11
12         Web Automation: link and partial link queries don't work if the link contains formatting tags
13         https://bugs.webkit.org/show_bug.cgi?id=174498
14
15         Reviewed by Brian Burg.
16
17         So, for example, if we find links with text "Foo" and there's a link like <a href=""><bA>Foo</b></a> we fail
18         with no such element error. This causes test test_Link_With_Formatting_Tags to fail.
19
20         * UIProcess/Automation/atoms/FindNodes.js:
21         (switch): Use descendant-or-self::text() instead of just text() in the links xpath expressions.
22
23 2017-07-16  Carlos Garcia Campos  <cgarcia@igalia.com>
24
25         Web Automation: FindNodes should throw an error in case of invalid strategy
26         https://bugs.webkit.org/show_bug.cgi?id=174497
27
28         Reviewed by Brian Burg.
29
30         We are currently returning null or empty list. According to the spec in 12.2 Find Element and 12.3 Find
31         Elements, step 4: "If location strategy is not present as a keyword in the table of location strategies, return
32         error with error code invalid argument.".
33         https://www.w3.org/TR/webdriver/#find-element.
34
35         This is causing test test_should_throw_an_error_if_user_passes_in_invalid_by_when_find_elements to fail.
36
37         * UIProcess/Automation/atoms/FindNodes.js:
38         (switch): Throw an error in case of unknown strategy.
39         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
40         (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Handle InvalidParameter exceptions.
41
42 2017-07-16  Brady Eidson  <beidson@apple.com>
43
44         Crash when a WKHTTPCookieStore outlives its owning WKWebsiteDataStore.
45         <rdar://problem/33341730> and https://bugs.webkit.org/show_bug.cgi?id=174574
46
47         Reviewed by Tim Horton.
48
49         Instead of holding a weak reference to its owning API::WebsiteDataStore,
50         API::HTTPCookieStore can hold a strong reference to the owner's implementation
51         WebKit::WebsiteDataStore.
52         
53         * UIProcess/API/APIHTTPCookieStore.cpp:
54         (API::HTTPCookieStore::HTTPCookieStore):
55         (API::HTTPCookieStore::cookies):
56         (API::HTTPCookieStore::setCookie):
57         (API::HTTPCookieStore::deleteCookie):
58         (API::HTTPCookieStore::registerObserver):
59         (API::HTTPCookieStore::unregisterObserver):
60         (API::HTTPCookieStore::cookieManagerDestroyed):
61         (API::HTTPCookieStore::registerForNewProcessPoolNotifications):
62         * UIProcess/API/APIHTTPCookieStore.h:
63
64 2017-07-15  Brady Eidson  <beidson@apple.com>
65
66         Make sure all CFHTTPCookieStorageRefs we create are scheduled.
67         <rdar://problem/33221110> and https://bugs.webkit.org/show_bug.cgi?id=174513
68
69         Reviewed by Tim Horton.
70
71         Whenever we create a CFHTTPCookieStorage from identifying data it is unscheduled.
72         We need to schedule it on the appropriate RunLoop.
73         
74         This patch also cleans up the creation of the identifying data itself.
75         
76         * NetworkProcess/mac/RemoteNetworkingContext.mm:
77         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
78
79         * Shared/cf/CookieStorageUtilsCF.h: Added.
80         * Shared/cf/CookieStorageUtilsCF.mm: Added.
81         (WebKit::cookieStorageFromIdentifyingData):
82         (WebKit::identifyingDataFromCookieStorage):
83
84         * Shared/mac/ChildProcessMac.mm:
85         (WebKit::ChildProcess::setSharedHTTPCookieStorage):
86
87         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
88         (WebKit::WebProcessPool::platformInitializeWebProcess):
89         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
90
91         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
92         (WebKit::WebsiteDataStore::parameters):
93
94         * WebKit.xcodeproj/project.pbxproj:
95
96         * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
97         (WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession):
98
99 2017-07-15  Wenson Hsieh  <wenson_hsieh@apple.com>
100
101         [iOS WK2] Presenting an action sheet on an image map prevents selection UI from updating
102         https://bugs.webkit.org/show_bug.cgi?id=174539
103         <rdar://problem/33307395>
104
105         Reviewed by Darin Adler.
106
107         Small tweak to avoid presenting at the element rect or text rect if the interaction information failed to
108         capture valid bounds for the element. We instead fall back to presenting at the touch location. This addresses
109         problems when presenting the action sheet popover on image maps on iPad, where GetPositionInformation fails to
110         capture correct data about for the <area>.
111
112         * UIProcess/ios/WKActionSheetAssistant.mm:
113         (presentationStyleForView):
114
115 2017-07-14  Jonathan Bedard  <jbedard@apple.com>
116
117         Add iOS 11 SPI
118         https://bugs.webkit.org/show_bug.cgi?id=174430
119         <rdar://problem/33269288>
120
121         Reviewed by Tim Horton.
122
123         * Platform/spi/ios/UIKitSPI.h: Add drag-and-drop SPI for iOS 11.
124         * UIProcess/ios/WKContentViewInteraction.mm: Move UIKit SPI to UIKitSPI.h.
125
126 2017-07-14  Jeff Miller  <jeffm@apple.com>
127
128         -[WKWebProcessBundleParameters setParametersForKeyWithDictionary:] passing wrong parameters to -setParameter:forKey
129         https://bugs.webkit.org/show_bug.cgi?id=174524
130
131         Reviewed by Sam Weinig.
132
133         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessBundleParameters.mm:
134         (-[WKWebProcessBundleParameters setParametersForKeyWithDictionary:]):
135         Pass the dictionary key and value in the correct order.
136
137 2017-07-14  Brent Fulgham  <bfulgham@apple.com>
138
139         Monitor directory for new statistics files after a delete operation
140         https://bugs.webkit.org/show_bug.cgi?id=174521
141         <rdar://problem/33322189>
142
143         Reviewed by Chris Dumez.
144
145         Create a FileMonitor to watch the data directory when the statistics file is
146         deleted by an external process. If it sees the file get created externally, merge
147         those data into the in-memory store.
148
149         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp:
150         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk): Added.
151         (WebKit::ResourceLoadStatisticsPersistentStorage::monitorDirectoryForNewStatistics):
152         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h:
153
154 2017-07-14  Matt Lewis  <jlewis3@apple.com>
155
156         Unreviewed, rolling out r219516.
157
158         This caused an API failure on macOS.
159
160         Reverted changeset:
161
162         "Make sure all CFHTTPCookieStorageRefs we create are
163         scheduled."
164         https://bugs.webkit.org/show_bug.cgi?id=174513
165         http://trac.webkit.org/changeset/219516
166
167 2017-07-14  Daniel Bates  <dabates@apple.com>
168
169         REGRESSION (r219013): Compute source frame info for frameless document
170         https://bugs.webkit.org/show_bug.cgi?id=174385
171         <rdar://problem/33217736>
172
173         Reviewed by Brady Eidson.
174
175         Fixes an issue where we would crash in WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction()
176         when computing the frame info for a now-frameless document. One way this can happen is when the frame
177         that contains the document that initiated the navigation is removed from the page.
178
179         * UIProcess/WebPageProxy.cpp:
180         (WebKit::WebPageProxy::decidePolicyForNavigationAction): Check that we have a valid page ID before
181         looking up the WebPage object corresponding to it.
182         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
183         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): Compute a FrameInfoData
184         object from the source document directly as opposed to using WebFrame::info() as the latter requires
185         that we have a valid WebCore frame and the source document may not have a frame.
186
187 2017-07-14  Jer Noble  <jer.noble@apple.com>
188
189         Allow clients to override their own hardware media requirements where no fallback media exists.
190         https://bugs.webkit.org/show_bug.cgi?id=174426
191         <rdar://problem/32537704>
192
193         Reviewed by Eric Carlson.
194
195         Add a new WKWebViewConfiguration property, as well as a new WKPreferences function, both to control
196         WebCore's new allowMediaContentTypesRequiringHardwareSupportAsFallback setting.
197
198         * Shared/WebPreferencesDefinitions.h:
199         * UIProcess/API/C/WKPreferences.cpp:
200         (WKPreferencesGetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
201         (WKPreferencesSetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
202         * UIProcess/API/C/WKPreferencesRef.h:
203         * UIProcess/API/Cocoa/WKWebView.mm:
204         (-[WKWebView _initializeWithConfiguration:]):
205         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
206         (-[WKWebViewConfiguration init]):
207         (-[WKWebViewConfiguration copyWithZone:]):
208         (-[WKWebViewConfiguration _setAllowMediaContentTypesRequiringHardwareSupportAsFallback:]):
209         (-[WKWebViewConfiguration _allowMediaContentTypesRequiringHardwareSupportAsFallback]):
210         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
211         * WebProcess/WebPage/WebPage.cpp:
212         (WebKit::WebPage::updatePreferences):
213
214 2017-07-14  Chris Dumez  <cdumez@apple.com>
215
216         Possible crash under NetworkSocketStream::didFailSocketStream()
217         https://bugs.webkit.org/show_bug.cgi?id=174526
218         <rdar://problem/32831441>
219
220         Reviewed by Brent Fulgham.
221
222         For robustness, initialize the SocketStreamHandleImpl after the other
223         data members. We are passing |this| to the SocketStreamHandleImpl when
224         constructing it so it is unsafe to have uninitialized data members
225         at this point.
226
227         * NetworkProcess/NetworkSocketStream.cpp:
228         (WebKit::NetworkSocketStream::NetworkSocketStream):
229         * NetworkProcess/NetworkSocketStream.h:
230
231 2017-07-14  Michael Catanzaro  <mcatanzaro@igalia.com>
232
233         [CMake] Unclear distinction between WebKitHelpers and WebKitMacros
234         https://bugs.webkit.org/show_bug.cgi?id=153189
235
236         Reviewed by Antonio Gomes.
237
238         New location for macros that are exclusively needed here.
239
240         * CMakeLists.txt:
241
242 2017-07-14  Brady Eidson  <beidson@apple.com>
243
244         Make sure all CFHTTPCookieStorageRefs we create are scheduled.
245         <rdar://problem/33221110> and https://bugs.webkit.org/show_bug.cgi?id=174513
246
247         Reviewed by Tim Horton.
248
249         Whenever we create a CFHTTPCookieStorage from identifying data it is unscheduled.
250         We need to schedule it on a RunLoop.
251         
252         This patch also cleans up the creation of the identifying data itself.
253         
254         * NetworkProcess/mac/RemoteNetworkingContext.mm:
255         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
256         
257         * Shared/cf/CookieStorageUtilsCF.cpp: Added.
258         (WebKit::cookieStorageFromIdentifyingData):
259         (WebKit::identifyingDataFromCookieStorage):
260         * Shared/cf/CookieStorageUtilsCF.h: Added.
261         
262         * Shared/mac/ChildProcessMac.mm:
263         (WebKit::ChildProcess::setSharedHTTPCookieStorage):
264         
265         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
266         (WebKit::WebProcessPool::platformInitializeWebProcess):
267         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
268         
269         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
270         (WebKit::WebsiteDataStore::parameters):
271         
272         * WebKit.xcodeproj/project.pbxproj:
273         
274         * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
275         (WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession):
276
277 2017-07-14  Chris Dumez  <cdumez@apple.com>
278
279         Potential null-dereference under NetworkRTCProvider::resolvedName()
280         https://bugs.webkit.org/show_bug.cgi?id=174507
281         <rdar://problem/32597868>
282
283         Reviewed by Youenn Fablet.
284
285         NetworkRTCProvider::resolvedName() could do a null dereference of m_connection
286         because m_connection is nullified in NetworkRTCProvider::close() but resolvers
287         were only closed later on in the NetworkRTCProvider destructor.
288
289         To address the issue, we now stop DNS resolvers earlier, in NetworkRTCProvider::close().
290         Also fix unsafe modification of m_resolvers HashMap when iterating over it.
291
292         * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
293         (WebKit::NetworkRTCProvider::~NetworkRTCProvider):
294         (WebKit::NetworkRTCProvider::close):
295         (WebKit::NetworkRTCProvider::Resolver::~Resolver):
296         (WebKit::NetworkRTCProvider::stopResolver):
297
298 2017-07-14  Youenn Fablet  <youenn@apple.com>
299
300         Report CoreAudioCaptureSource failure in case shared unit stops working properly
301         https://bugs.webkit.org/show_bug.cgi?id=174494
302
303         Reviewed by Eric Carlson.
304
305         In case of capture failure, send a CaptureFailure message so that the
306         correct behavior happens in the Web process.
307
308         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
309         * WebProcess/cocoa/UserMediaCaptureManager.cpp:
310         (WebKit::UserMediaCaptureManager::captureFailed):
311         * WebProcess/cocoa/UserMediaCaptureManager.h:
312         * WebProcess/cocoa/UserMediaCaptureManager.messages.in:
313
314 2017-07-13  Chris Dumez  <cdumez@apple.com>
315
316         Better deal with changes to the ResourceLoadStatisticsStore file on disk
317         https://bugs.webkit.org/show_bug.cgi?id=174487
318
319         Reviewed by Brent Fulgham.
320
321         Rename WebResourceLoadStatisticsStore's resetDataFromDecoder() to mergeWithDataFromDecoder()
322         and update it so that it actual merges the data from the disk with the one we have in memory,
323         instead of replacing it. This avoid data loss.
324
325         We leverage the existing WebResourceLoadStatisticsStore::mergeStatistics() to merge the
326         statistics.
327
328         To faciliate merging the operating dates, they are now represented as OperatingDate objects
329         instead of WallTime objects. OperatingDate only include date precision, no time information.
330         As a result, the merge 2 vectors of OperatingDate objects, we can:
331         1. Merge the 2 sorted vectors (using std::merge())
332         2. Get rid of duplicates (easy because of date-level precision)
333         3. Drop old dates until the vector has at most 30 items.
334
335         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp:
336         (WebKit::ResourceLoadStatisticsPersistentStorage::refreshMemoryStoreFromDisk):
337         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
338         * UIProcess/WebResourceLoadStatisticsStore.cpp:
339         (WebKit::OperatingDate::fromWallTime):
340         (WebKit::OperatingDate::today):
341         (WebKit::OperatingDate::secondsSinceEpoch):
342         (WebKit::OperatingDate::operator==):
343         (WebKit::OperatingDate::operator<):
344         (WebKit::OperatingDate::operator<=):
345         (WebKit::OperatingDate::OperatingDate):
346         (WebKit::mergeOperatingDates):
347         (WebKit::WebResourceLoadStatisticsStore::createEncoderFromData):
348         (WebKit::WebResourceLoadStatisticsStore::mergeWithDataFromDecoder):
349         (WebKit::WebResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
350         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
351         * UIProcess/WebResourceLoadStatisticsStore.h:
352
353 2017-07-13  Dan Bernstein  <mitz@apple.com>
354
355         Removed empty project directories left behind after the rename
356
357         * WebKit2.xcodeproj: Removed.
358
359 2017-07-13  Matthew Hanson  <matthew_hanson@apple.com>
360
361         Fix the cMake builds (GTK and WPE.)
362         https://bugs.webkit.org/show_bug.cgi?id=174164
363         rdar://problem/33137595
364
365         Reviewed by Dan Bernstein.
366
367         * Scripts/generate-forwarding-headers.pl:
368         (collectFrameworkHeaderPaths):
369         (createForwardingHeadersForFramework):
370
371 2017-07-13  Matthew Hanson  <matthew_hanson@apple.com>
372
373         Rename WebKit2.xcodeproj to WebKit.xcodeproj.
374         https://bugs.webkit.org/show_bug.cgi?id=174164
375         rdar://problem/33137595
376
377         Reviewed by Dan Bernstein.
378
379         * WebKit.xcodeproj/project.pbxproj: Renamed from Source/WebKit/WebKit2.xcodeproj/project.pbxproj.
380
381 2017-07-13  Matthew Hanson  <matthew_hanson@apple.com>
382
383         Update tools and configurations after renaming Source/WebKit2 to Source/WebKit.
384         https://bugs.webkit.org/show_bug.cgi?id=174164
385         rdar://problem/33137595
386
387         Reviewed by Dan Bernstein.
388
389         * PlatformGTK.cmake:
390         * Shared/API/c/wpe/WebKit.h:
391
392 2017-07-13  Michael Catanzaro  <mcatanzaro@igalia.com>
393
394         Fix compiler warnings when building with GCC 7
395         https://bugs.webkit.org/show_bug.cgi?id=174463
396
397         Reviewed by Darin Adler.
398
399         * Platform/IPC/unix/ConnectionUnix.cpp:
400         (IPC::Connection::sendOutputMessage):
401
402 2017-07-13  Chris Dumez  <cdumez@apple.com>
403
404         Moved filesystem code out of WebResourceLoadStatisticsStore class
405         https://bugs.webkit.org/show_bug.cgi?id=174435
406
407         Reviewed by Brent Fulgham.
408
409         Moved filesystem code out of WebResourceLoadStatisticsStore class and into
410         a new ResourceLoadStatisticsPersistentStorage class to decrease complexity.
411
412         * CMakeLists.txt:
413         * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
414         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp: Added.
415         (WebKit::hasFileChangedSince):
416         (WebKit::createDecoderForFile):
417         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
418         (WebKit::ResourceLoadStatisticsPersistentStorage::~ResourceLoadStatisticsPersistentStorage):
419         (WebKit::ResourceLoadStatisticsPersistentStorage::storageDirectoryPath):
420         (WebKit::ResourceLoadStatisticsPersistentStorage::resourceLogFilePath):
421         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk):
422         (WebKit::ResourceLoadStatisticsPersistentStorage::stopMonitoringDisk):
423         (WebKit::ResourceLoadStatisticsPersistentStorage::refreshMemoryStoreFromDisk):
424         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
425         (WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk):
426         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
427         (WebKit::ResourceLoadStatisticsPersistentStorage::clear):
428         (WebKit::ResourceLoadStatisticsPersistentStorage::finishAllPendingWorkSynchronously):
429         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
430         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h: Added.
431         * UIProcess/Storage/ios/ResourceLoadStatisticsPersistentStorageIOS.mm: Added.
432         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
433         * UIProcess/WebResourceLoadStatisticsStore.cpp:
434         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
435         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
436         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
437         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
438         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
439         (WebKit::WebResourceLoadStatisticsStore::resetDataFromDecoder):
440         * UIProcess/WebResourceLoadStatisticsStore.h:
441         * WebKit2.xcodeproj/project.pbxproj:
442
443 2017-07-13  Chris Dumez  <cdumez@apple.com>
444
445         Unreviewed, rolling out r219453.
446
447         Seems to cause some crashes on the bots
448
449         Reverted changeset:
450
451         "Moved filesystem code out of WebResourceLoadStatisticsStore
452         class"
453         https://bugs.webkit.org/show_bug.cgi?id=174435
454         http://trac.webkit.org/changeset/219453
455
456 2017-07-13  Jeremy Jones  <jeremyj@apple.com>
457
458         Fix style. Use #pragma once in VideoFullscreen and PlaybackSession headers.
459         https://bugs.webkit.org/show_bug.cgi?id=174448
460
461         Reviewed by Eric Carlson.
462
463         No behavior change.
464
465         * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
466         * WebProcess/cocoa/WebVideoFullscreenManager.h:
467
468 2017-07-13  Jeremy Jones  <jeremyj@apple.com>
469
470         Style fix. Replace strongThis with protectedThis.
471         https://bugs.webkit.org/show_bug.cgi?id=174444
472
473         Reviewed by Eric Carlson.
474
475         Rename, no behavior change.
476
477         * WebProcess/cocoa/WebVideoFullscreenManager.mm:
478         (WebKit::WebVideoFullscreenManager::didSetupFullscreen):
479         (WebKit::WebVideoFullscreenManager::didEnterFullscreen):
480         (WebKit::WebVideoFullscreenManager::didExitFullscreen):
481         (WebKit::WebVideoFullscreenManager::didCleanupFullscreen):
482
483 2017-07-13  Chris Dumez  <cdumez@apple.com>
484
485         Moved filesystem code out of WebResourceLoadStatisticsStore class
486         https://bugs.webkit.org/show_bug.cgi?id=174435
487
488         Reviewed by Brent Fulgham.
489
490         Moved filesystem code out of WebResourceLoadStatisticsStore class and into
491         a new ResourceLoadStatisticsPersistentStorage class to decrease complexity.
492
493         * CMakeLists.txt:
494         * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
495         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp: Added.
496         (WebKit::hasFileChangedSince):
497         (WebKit::createDecoderForFile):
498         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
499         (WebKit::ResourceLoadStatisticsPersistentStorage::~ResourceLoadStatisticsPersistentStorage):
500         (WebKit::ResourceLoadStatisticsPersistentStorage::storageDirectoryPath):
501         (WebKit::ResourceLoadStatisticsPersistentStorage::resourceLogFilePath):
502         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk):
503         (WebKit::ResourceLoadStatisticsPersistentStorage::stopMonitoringDisk):
504         (WebKit::ResourceLoadStatisticsPersistentStorage::refreshMemoryStoreFromDisk):
505         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
506         (WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk):
507         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
508         (WebKit::ResourceLoadStatisticsPersistentStorage::clear):
509         (WebKit::ResourceLoadStatisticsPersistentStorage::finishAllPendingWorkSynchronously):
510         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
511         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h: Added.
512         * UIProcess/Storage/ios/ResourceLoadStatisticsPersistentStorageIOS.mm: Added.
513         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
514         * UIProcess/WebResourceLoadStatisticsStore.cpp:
515         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
516         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
517         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
518         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
519         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
520         (WebKit::WebResourceLoadStatisticsStore::resetDataFromDecoder):
521         * UIProcess/WebResourceLoadStatisticsStore.h:
522         * WebKit2.xcodeproj/project.pbxproj:
523
524 2017-07-12  Carlos Garcia Campos  <cgarcia@igalia.com>
525
526         Web Automation: evaluateJavaScriptFunction should start the callback timeout after the function is applied
527         https://bugs.webkit.org/show_bug.cgi?id=174421
528
529         Reviewed by Brian Burg.
530
531         This is causing selenium test testShouldNotTimeoutIfScriptCallsbackInsideAZeroTimeout to fail, because
532         JavaScriptTimeout error is generated unexpectedly. When no script timeout is specified, 0 is used by default,
533         which means we do a setTimeout with 0 and then the script does another setTimeout with 0, but ours is dispatched
534         before and reportTimeoutError is called. We should start our timeout after applying the function, and only if
535         the result hasn't been reported yet.
536
537         * WebProcess/Automation/WebAutomationSessionProxy.js:
538         (let.AutomationSessionProxy.prototype.evaluateJavaScriptFunction):
539
540 2017-07-12  Wenson Hsieh  <wenson_hsieh@apple.com>
541
542         [iOS DnD] [WK2] Add SPI to enable, disable, or follow default behavior for DnD on a WKWebView
543         https://bugs.webkit.org/show_bug.cgi?id=174440
544         <rdar://problem/33272627>
545
546         Reviewed by Beth Dakin.
547
548         Adds a new _dragInteractionPolicy property to WKWebView, which an internal client may use to always allow
549         dragging out of the web view (_WKDragInteractionPolicyAlwaysEnable), never allow
550         (_WKDragInteractionPolicyAlwaysDisable) or just use the default device-dependent behavior
551         (_WKDragInteractionPolicyDefault).
552
553         Also removes an extraneous class from WKContentViewInteraction.mm that is no longer used anywhere.
554
555         * UIProcess/API/Cocoa/WKWebView.mm:
556         (-[WKWebView _initializeWithConfiguration:]):
557
558         Set _dragInteractionPolicy to _WKDragInteractionPolicyDefault upon initialization.
559
560         (-[WKWebView _dragInteractionPolicy]):
561         (-[WKWebView _setDragInteractionPolicy:]):
562         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
563         * UIProcess/ios/WKContentViewInteraction.h:
564         * UIProcess/ios/WKContentViewInteraction.mm:
565         (shouldEnableDragInteractionForPolicy):
566         (-[WKContentView _didChangeDragInteractionPolicy]):
567
568         Called by the WKWebView when its _dragInteractionPolicy changes. The content view updates its
569         UIDragInteraction's -enabled property here in response.
570
571         (-[WKContentView setupDataInteractionDelegates]):
572
573 2017-07-12  Said Abou-Hallawa  <sabouhallawa@apple.com>
574
575         Async image decoding for large images should be disabled by default
576         https://bugs.webkit.org/show_bug.cgi?id=174432
577
578         Reviewed by Simon Fraser.
579
580         -- Replace every reference to GraphicsLayerPaintFlags::Snapshotting by
581            GraphicsLayerPaintFlags::None and every GraphicsLayerPaintFlags::None
582            by AllowAsyncImageDecoding.
583         -- Replace setting the bit PaintBehaviorSnapshotting in an existing PaintBehavoir 
584            by resetting the bit PaintBehaviorAllowAsyncImageDecoding.
585
586         * Shared/mac/RemoteLayerBackingStore.mm:
587         (WebKit::RemoteLayerBackingStore::drawInContext):
588         * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
589         (WebKit::imageForRect):
590         * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
591         (WebKit::InjectedBundleRangeHandle::renderedImage):
592
593 2017-07-12  Eric Carlson  <eric.carlson@apple.com>
594
595         [MediaStream] a capture source failure should end the MediaStreamTrack
596         https://bugs.webkit.org/show_bug.cgi?id=174375
597
598         Reviewed by Youenn Fablet.
599
600         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
601         (WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged): Consolidate start/end.
602         (WebKit::UserMediaPermissionRequestManagerProxy::startedCaptureSession): Deleted.
603         (WebKit::UserMediaPermissionRequestManagerProxy::endedCaptureSession): Deleted.
604         * UIProcess/UserMediaPermissionRequestManagerProxy.h:
605
606         * UIProcess/WebPageProxy.cpp:
607         (WebKit::WebPageProxy::isPlayingMediaDidChange): Call captureStateChanged if the capture 
608         state changes. Consider interrupted flags.
609
610 2017-07-12  Daniel Bates  <dabates@apple.com>
611
612         NavigationAction should track whether the navigation was initiated by the main frame
613         https://bugs.webkit.org/show_bug.cgi?id=174386
614         <rdar://problem/33245267>
615
616         Reviewed by Brady Eidson.
617
618         * WebProcess/WebPage/WebInspector.cpp:
619         (WebKit::WebInspector::openInNewTab): Pass whether the load was initiated by the main frame
620         when instantiating the NavigationAction.
621
622 2017-07-12  Daniel Bates  <dabates@apple.com>
623
624         Rename NavigationInitiatedByMainFrame to InitiatedByMainFrame
625         https://bugs.webkit.org/show_bug.cgi?id=174427
626
627         Rubber-stamped by Brady Eidson.
628
629         * WebProcess/Plugins/PluginView.cpp:
630         (WebKit::PluginView::loadURL):
631         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
632         (WebKit::WebFrameLoaderClient::dispatchCreatePage):
633         * WebProcess/WebPage/WebInspector.cpp:
634         (WebKit::WebInspector::openInNewTab):
635
636 2017-07-12  Matt Lewis  <jlewis3@apple.com>
637
638         Unreviewed, rolling out r219401.
639
640         This revision rolled out the previous patch, but after talking
641         with reviewer, a rebaseline is what was needed.Rolling back in
642         before rebaseline.
643
644         Reverted changeset:
645
646         "Unreviewed, rolling out r219379."
647         https://bugs.webkit.org/show_bug.cgi?id=174400
648         http://trac.webkit.org/changeset/219401
649
650 2017-07-12  Daniel Bates  <dabates@apple.com>
651
652         Update description of Secure Contexts experimental flag
653         https://bugs.webkit.org/show_bug.cgi?id=174401
654
655         Reviewed by Simon Fraser.
656
657         Change the description of the Secure Contexts experimental flag from "isSecureContext attribute"
658         to "Secure Contexts API".
659
660         * Shared/WebPreferencesDefinitions.h:
661
662 2017-07-12  Matt Lewis  <jlewis3@apple.com>
663
664         Unreviewed, rolling out r219379.
665
666         This revision caused a consistent failure in the test
667         fast/dom/Window/property-access-on-cached-window-after-frame-
668         removed.html.
669
670         Reverted changeset:
671
672         "Remove NAVIGATOR_HWCONCURRENCY"
673         https://bugs.webkit.org/show_bug.cgi?id=174400
674         http://trac.webkit.org/changeset/219379
675
676 2017-07-12  Zan Dobersek  <zdobersek@igalia.com>
677
678         [WPE] Use libepoxy
679         https://bugs.webkit.org/show_bug.cgi?id=172104
680
681         Reviewed by Michael Catanzaro.
682
683         * PlatformWPE.cmake: Drop the EGL_INCLUDE_DIRS compilation flags.
684         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
685         Include <epoxy/gl.h> when compiling with libepoxy usage enabled.
686
687 2017-07-12  Carlos Garcia Campos  <cgarcia@igalia.com>
688
689         Web Automation: upstream safaridriver's JavaScript atom implementations
690         https://bugs.webkit.org/show_bug.cgi?id=172060
691         <rdar://problem/32168187>
692
693         Reviewed by Brian Burg.
694
695         * UIProcess/Automation/atoms/ElementAttribute.js: Added.
696         * UIProcess/Automation/atoms/ElementDisplayed.js: Added.
697         * UIProcess/Automation/atoms/FindNodes.js: Added.
698         * UIProcess/Automation/atoms/FormElementClear.js: Added.
699         * UIProcess/Automation/atoms/FormSubmit.js: Added.
700
701 2017-07-11  Dean Jackson  <dino@apple.com>
702
703         Remove NAVIGATOR_HWCONCURRENCY
704         https://bugs.webkit.org/show_bug.cgi?id=174400
705
706         Reviewed by Sam Weinig.
707
708         * Configurations/FeatureDefines.xcconfig:
709
710 2017-07-11  Ansh Shukla  <ansh_shukla@apple.com>
711
712         WKWindowFeatures needs to expose scrollbar, fullscreen, and dialog configuration properties
713         https://bugs.webkit.org/show_bug.cgi?id=174239
714
715         Reviewed by Brady Eidson.
716
717         Add a new private header to expose getters for window feature properties already available
718         in the TFB APIWindowFeatures class. These properties are necessary for Safari to adopt more
719         modern API.
720
721         * UIProcess/API/Cocoa/WKWindowFeatures.mm:
722         (-[WKWindowFeatures _locationBarVisibility]):
723         (-[WKWindowFeatures _scrollbarsVisibility]):
724         (-[WKWindowFeatures _fullscreenDisplay]):
725         (-[WKWindowFeatures _dialogDisplay]):
726         * UIProcess/API/Cocoa/WKWindowFeaturesInternal.h: Expose some window features as read-only
727         properties.
728         * UIProcess/API/Cocoa/WKWindowFeaturesPrivate.h:
729         * WebKit2.xcodeproj/project.pbxproj:
730
731 2017-07-11  Chris Dumez  <cdumez@apple.com>
732
733         Avoid duplicating default parameter values in [WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]
734         https://bugs.webkit.org/show_bug.cgi?id=174402
735
736         Reviewed by Brent Fulgham.
737
738         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
739         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
740         * UIProcess/WebResourceLoadStatisticsStore.cpp:
741         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
742         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
743         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
744         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
745         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
746         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
747         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
748         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
749         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
750         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
751         (WebKit::WebResourceLoadStatisticsStore::shouldPartitionCookies):
752         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
753         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
754         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
755         (WebKit::WebResourceLoadStatisticsStore::pruneStatisticsIfNeeded):
756         (WebKit::WebResourceLoadStatisticsStore::resetParametersToDefaultValues):
757         * UIProcess/WebResourceLoadStatisticsStore.h:
758
759 2017-07-11  Dean Jackson  <dino@apple.com>
760
761         Rolling out r219372.
762
763         * Configurations/FeatureDefines.xcconfig:
764
765 2017-07-11  Dean Jackson  <dino@apple.com>
766
767         Remove NAVIGATOR_HWCONCURRENCY
768         https://bugs.webkit.org/show_bug.cgi?id=174400
769
770         Reviewed by Sam Weinig.
771
772         * Configurations/FeatureDefines.xcconfig:
773
774 2017-07-11  Dean Jackson  <dino@apple.com>
775
776         Viewport fit experimental feature should be always on by default
777         https://bugs.webkit.org/show_bug.cgi?id=174398
778         <rdar://problem/33248920>
779
780         Reviewed by Simon Fraser.
781
782         Even though this is experimental, it should be enabled by default, and
783         not follow the value of DEFAULT_EXPERIMENTAL_FEATURES_ENABLED.
784
785         * Shared/WebPreferencesDefinitions.h:
786
787 2017-07-11  Adrian Perez de Castro  <aperez@igalia.com>
788
789         Fix typo: ContentRuleListStore::nonLegacyDdefaultStore()
790         https://bugs.webkit.org/show_bug.cgi?id=174387
791
792         Reviewed by Michael Catanzaro.
793
794         Rename nonLegacyDdefaultStore() to nonLegacyDefaultStore().
795
796         * UIProcess/API/APIContentRuleListStore.cpp:
797         (API::ContentRuleListStore::nonLegacyDefaultStore):
798         (API::ContentRuleListStore::defaultStore):
799         * UIProcess/API/APIContentRuleListStore.h:
800
801 2017-07-11  Chris Dumez  <cdumez@apple.com>
802
803         Simplify primary domain lambda captures in WebResourceLoadStatisticsStore
804         https://bugs.webkit.org/show_bug.cgi?id=174381
805
806         Reviewed by Brent Fulgham.
807
808         * UIProcess/WebResourceLoadStatisticsStore.cpp:
809         (WebKit::isolatedPrimaryDomain):
810         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
811         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
812         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
813         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
814         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
815         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
816         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
817         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
818         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
819         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
820         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
821         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
822         (WebKit::primaryDomain): Deleted.
823
824 2017-07-11  Timothy Hatcher  <timothy@hatcher.name>
825
826         Fix a build failure in WebDragClient when !PLATFORM(COCOA) && !PLATFORM(GTK).
827         https://bugs.webkit.org/show_bug.cgi?id=174372
828
829         Reviewed by Beth Dakin.
830
831         * WebProcess/WebCoreSupport/WebDragClient.cpp:
832         (WebKit::WebDragClient::didConcludeEditDrag): Added empty method.
833
834 2017-07-11  Brent Fulgham  <bfulgham@apple.com>
835
836         Reset cookie partitioning state after network process crashes
837         https://bugs.webkit.org/show_bug.cgi?id=174306
838         <rdar://problem/33171605>
839
840         Reviewed by Chris Dumez.
841
842         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
843         (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler): Move cookie
844         partioning state code to helper function.
845         (WebKit::ResourceLoadStatisticsStore::resetPartitionCookiesState): Added.
846         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
847         * UIProcess/WebProcessPool.cpp:
848         (WebKit::WebProcessPool::ensureNetworkProcess): Inform the statistics store that
849         the network process crashed.
850         (WebKit::WebProcessPool::terminateNetworkProcess): Mark network process as crashed.
851         * UIProcess/WebResourceLoadStatisticsStore.cpp:
852         (WebKit::WebResourceLoadStatisticsStore::networkProcessDidCrash): Reset the cookie
853         partitioning state after a crash.
854         * UIProcess/WebResourceLoadStatisticsStore.h:
855         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
856         (WebKit::WebsiteDataStore::notifyResourceLoadStatisticsNetworkProcessDidCrash): Relay
857         information to the statistics store.
858         * UIProcess/WebsiteData/WebsiteDataStore.h:
859
860 2017-07-11  Timothy Hatcher  <timothy@hatcher.name>
861
862         Fix broken build when !ENABLE(INDEXED_DATABASE)
863         https://bugs.webkit.org/show_bug.cgi?id=174370
864
865         Reviewed by Alex Christensen.
866
867         * UIProcess/WebProcessPool.cpp:
868         (WebKit::WebProcessPool::pageAddedToProcess):
869
870 2017-07-11  Youenn Fablet  <youenn@apple.com>
871
872         Changing the web page muted state for playing audio should not disable other tabs capture
873         https://bugs.webkit.org/show_bug.cgi?id=174349
874
875         Unreviewed.
876
877         * UIProcess/WebPageProxy.cpp:
878         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage): Fixes non MEDIA_STREAM builds.
879
880 2017-07-11  Wenson Hsieh  <wenson_hsieh@apple.com>
881
882         Address post-review feedback after http://trac.webkit.org/r219310
883         https://bugs.webkit.org/show_bug.cgi?id=174300
884         <rdar://problem/33030639>
885
886         Reviewed by Simon Fraser.
887
888         Removes plumbing introduced in r219310 for telling WKContentView when the user has finished panning or zooming.
889         This was previously used to reset allowing asynchronous touch event after preventing the web touch events
890         gesture recognizer from firing.
891
892         However, a far simpler (and much less fragile) solution is to just set _canSendTouchEventsAsynchronously to NO
893         at the beginning of the gesture, before the first `touchstart` event is dispatched. This way, we always ensure
894         that _canSendTouchEventsAsynchronously is NO when beginning to process a touch event. This approach is correct
895         because the only place where we query _canSendTouchEventsAsynchronously is in -_webTouchEventsRecognized:, where
896         (when we are beginning a new gesture) we are guaranteed that -gestureRecognizer:shouldIgnoreWebTouchWithEvent:
897         has already been called and _canSendTouchEventsAsynchronously is NO.
898
899         Confirmed that the LayoutTests added in r219310 still pass.
900
901         * UIProcess/API/Cocoa/WKWebView.mm:
902         (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
903         (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
904         * UIProcess/PageClient.h:
905         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
906         * UIProcess/Scrolling/RemoteScrollingTree.cpp:
907         (WebKit::RemoteScrollingTree::scrollingTreeNodeDidEndPanGesture): Deleted.
908         * UIProcess/Scrolling/RemoteScrollingTree.h:
909         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
910         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
911         (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
912         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewDidEndPanGesture): Deleted.
913         * UIProcess/WebPageProxy.h:
914         * UIProcess/ios/PageClientImplIOS.h:
915         * UIProcess/ios/PageClientImplIOS.mm:
916         (WebKit::PageClientImpl::overflowScrollViewDidEndPanGesture): Deleted.
917         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
918         (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidEndPanGesture): Deleted.
919         * UIProcess/ios/WKContentViewInteraction.h:
920         * UIProcess/ios/WKContentViewInteraction.mm:
921         (-[WKContentView gestureRecognizer:shouldIgnoreWebTouchWithEvent:]):
922         (-[WKContentView scrollViewDidEndPanOrPinchGesture]): Deleted.
923         * UIProcess/ios/WebPageProxyIOS.mm:
924         (WebKit::WebPageProxy::overflowScrollViewDidEndPanGesture): Deleted.
925
926 2017-07-11  Brent Fulgham  <bfulgham@apple.com>
927
928         Unreviewed clean-up after r219323
929
930         Simplify algorithm slightly based on a suggestion Chris Dumez made in the review.
931
932         * UIProcess/WebResourceLoadStatisticsStore.cpp:
933         (WebKit::pruneResources): Don't create a second variable to track the pruning operation.
934
935 2017-07-11  Alex Christensen  <achristensen@webkit.org>
936
937         SharedBuffer::size should return a size_t
938         https://bugs.webkit.org/show_bug.cgi?id=174328
939
940         Reviewed by Andreas Kling.
941
942         * UIProcess/WebResourceLoadStatisticsStore.cpp:
943         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
944
945 2017-07-11  Youenn Fablet  <youenn@apple.com>
946
947         We should do ICE candidate filtering at the Document level
948         https://bugs.webkit.org/show_bug.cgi?id=173861
949         <rdar://problem/33122058>
950
951         Reviewed by Eric Carlson.
952
953         Removing ICE candidate filtering handling at UIProcess level.
954         ICE candidate filtering is now disabled at UserMediaRequest level.
955         WebPage forwards the ICE candidate filtering option to the page so as to set
956         the default option correctly for every document of the page.
957
958         * UIProcess/UserMediaProcessManager.cpp:
959         (WebKit::UserMediaProcessManager::willCreateMediaStream):
960         (WebKit::UserMediaProcessManager::endedCaptureSession):
961         * WebProcess/WebPage/WebPage.cpp:
962         (WebKit::WebPage::disableICECandidateFiltering):
963         (WebKit::WebPage::enableICECandidateFiltering):
964
965 2017-07-11  Youenn Fablet  <youenn@apple.com>
966
967         Changing the web page muted state for playing audio should not disable other tabs capture
968         https://bugs.webkit.org/show_bug.cgi?id=174349
969         rdar://problem/33223988
970
971         Reviewed by Eric Carlson.
972
973         Make sure to mute capturing streams of any other tab if the current tab will start capturing or will unmute existing capturing streams.
974         Manually tested by having a tab doing capture and another tab playing a video.
975         Muting or unmuting the tab playing video should not change the capture tab.
976
977         * UIProcess/WebPageProxy.cpp:
978         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage):
979         (WebKit::WebPageProxy::setMuted):
980         * UIProcess/WebPageProxy.h:
981         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage):
982
983 2017-07-11  Youenn Fablet  <youenn@apple.com>
984
985         NetworkProcess should close listening WebRTC sockets when being suspended
986         https://bugs.webkit.org/show_bug.cgi?id=174270
987         rdar://problem/33139844
988
989         Reviewed by Chris Dumez.
990
991         To prevent potential spinning of the NetworkProcess, NetworkProcess will now close listening sockets when being notified that it will be suspended.
992         When the network process is being suspended, it will stop creating listening sockets, until it resumes.
993         Future additional efforts might be to improve select/cancel so that we can stop listening sockets at resume time,
994         or to reimplement part of the stack using CFStream.
995
996         Tested through manual testing by going to a website doing WebRTC, homing out so that the network process is suspended and reopening Safari.
997
998         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
999         (WebKit::NetworkConnectionToWebProcess::cleanupForSuspension):
1000         Proxying call to clean for suspension to rtc provider so that it will
1001         close listening sockets.
1002         (WebKit::NetworkConnectionToWebProcess::resumeFromSuspension): Authorizing back listening sockets.
1003         * NetworkProcess/NetworkConnectionToWebProcess.h:
1004         (WebKit::NetworkConnectionToWebProcess::cleanupForSuspension):
1005         Clean-up is done asynchronously as it can happen in background threads.
1006         Hence why passing a callback as parameter.
1007         * NetworkProcess/NetworkProcess.cpp:
1008         (WebKit::NetworkProcess::notifyProcessReadyToSuspend): Helper routine
1009         to notify UI process that network process clean up is done.
1010         (WebKit::TaskCounter::TaskCounter): Helper class to call notifyProcessReadyToSuspend when sded.
1011         (WebKit::TaskCounter::~TaskCounter):
1012         (WebKit::NetworkProcess::actualPrepareToSuspend): Doing the clean-up for each connection that needs it.
1013         Making sure to notify UI process of clean-up being completed once all connections are cleaned.
1014         (WebKit::NetworkProcess::processWillSuspendImminently):
1015         (WebKit::NetworkProcess::prepareToSuspend):
1016         (WebKit::NetworkProcess::processDidResume): Reenable listening sockets.
1017         * NetworkProcess/NetworkProcess.h:
1018         * NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
1019         (WebKit::LibWebRTCSocketClient::LibWebRTCSocketClient):
1020         * NetworkProcess/webrtc/LibWebRTCSocketClient.h: Adding type getter and making close public.
1021         Used by NetworkRTCProvider to identifiy listening sockets and close them.
1022         * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
1023         (WebKit::NetworkRTCProvider::closeListeningSockets): We close the webrtc socket
1024         and we also notify the Web Process that the socket is closed so that it can take actions to recreate some if needed.
1025         (WebKit::NetworkRTCProvider::finishClosingListeningSockets):
1026         * NetworkProcess/webrtc/NetworkRTCProvider.h:
1027         (WebKit::NetworkRTCProvider::authorizeListeningSockets): Authorize creation of listening sockets.
1028
1029 2017-07-10  Brent Fulgham  <bfulgham@apple.com>
1030
1031         Resource Load Statistics: Prune statistics in orders of importance
1032         https://bugs.webkit.org/show_bug.cgi?id=174215
1033         <rdar://problem/33164403>
1034
1035         Unreviewed test correction.
1036
1037         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1038         (WebKit::pruneResources): The revised algorithm did not update the remaining
1039         count to be pruned, causing a test failure.
1040
1041 2017-07-10  John Wilander  <wilander@apple.com>
1042
1043         Resource Load Statistics: Prune statistics in orders of importance
1044         https://bugs.webkit.org/show_bug.cgi?id=174215
1045         <rdar://problem/33164403>
1046
1047         Reviewed by Chris Dumez.
1048
1049         New functionality. Prunes statistics in this order:
1050         1. Non-prevalent resources without user interaction.
1051         2. Prevalent resources without user interaction.
1052         3. Non-prevalent resources with user interaction.
1053         4. Prevalent resources with user interaction.
1054
1055         * Shared/WebCoreArgumentCoders.cpp:
1056         (IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
1057         (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
1058             Added timestamp field lastSeen.
1059         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1060         (-[WKWebsiteDataStore _resourceLoadStatisticsSetLastSeen:forHost:]):
1061         (-[WKWebsiteDataStore _resourceLoadStatisticsSetMaxStatisticsEntries:]):
1062         (-[WKWebsiteDataStore _resourceLoadStatisticsSetPruneEntriesDownTo:]):
1063         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
1064             Test infrastructure.
1065         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
1066         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1067         (WebKit::ResourceLoadStatisticsStore::setMaxStatisticsEntries):
1068             Test infrastructure.
1069         (WebKit::ResourceLoadStatisticsStore::setPruneEntriesDownTo):
1070             Test infrastructure.
1071         (WebKit::sortAndPrune):
1072             Convenience function.
1073         (WebKit::ResourceLoadStatisticsStore::pruneStatisticsIfNeeded):
1074             The new pruning function.
1075         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1076         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1077         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
1078             Now calls ResourceLoadStatisticsStore::pruneStatisticsIfNeeded().
1079         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
1080             Test infrastructure.
1081         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
1082             Test infrastructure.
1083         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
1084             Test infrastructure.
1085         * UIProcess/WebResourceLoadStatisticsStore.h:
1086
1087 2017-07-10  Dean Jackson  <dino@apple.com>
1088
1089         const() experimental feature should always be on by default
1090         https://bugs.webkit.org/show_bug.cgi?id=174341
1091         <rdar://problem/33228603>
1092
1093         Reviewed by Simon Fraser.
1094
1095         Even though this is experimental, it should be enabled by default, and
1096         not follow the value of DEFAULT_EXPERIMENTAL_FEATURES_ENABLED.
1097
1098         * Shared/WebPreferencesDefinitions.h:
1099
1100 2017-07-10  Chris Dumez  <cdumez@apple.com>
1101
1102         [iOS] _didCommitLayerTree should avoid calling [scrollView setZoomScale] unnecessarily
1103         https://bugs.webkit.org/show_bug.cgi?id=174326
1104         <rdar://problem/33150490>
1105
1106         Reviewed by Simon Fraser.
1107
1108         Only call [scrollView setZoomScale] if the new zoom scale is actually different to
1109         avoid doing unnecessary work in UIKit.
1110
1111         * UIProcess/API/Cocoa/WKWebView.mm:
1112         (-[WKWebView _didCommitLayerTree:]):
1113
1114 2017-07-10  Chris Dumez  <cdumez@apple.com>
1115
1116         Merge ResourceLoadStatisticsStore into WebResourceLoadStatisticsStore
1117         https://bugs.webkit.org/show_bug.cgi?id=174203
1118
1119         Reviewed by Brent Fulgham.
1120
1121         Merge ResourceLoadStatisticsStore into WebResourceLoadStatisticsStore. The 2 classes
1122         have a similar purpose and there is no clean separation between the 2. It makes more
1123         sense to have a single store class for resource load statistics.
1124
1125         If we want to simplify the WebResourceLoadStatisticsStore class, I think it'd make
1126         more sense to split the file system I/O code out. This code adds quite a bit of
1127         complexity.
1128
1129         * CMakeLists.txt:
1130         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1131         (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]):
1132         (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]):
1133         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore]):
1134         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:]):
1135         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
1136         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp: Removed.
1137         * UIProcess/Storage/ResourceLoadStatisticsStore.h: Removed.
1138         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1139         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1140         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
1141         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
1142         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
1143         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
1144         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
1145         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
1146         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
1147         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
1148         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
1149         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
1150         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
1151         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
1152         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
1153         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
1154         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
1155         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
1156         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
1157         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
1158         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
1159         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
1160         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
1161         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate):
1162         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
1163         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemory):
1164         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
1165         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1166         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
1167         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
1168         (WebKit::WebResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
1169         (WebKit::WebResourceLoadStatisticsStore::createEncoderFromData):
1170         (WebKit::WebResourceLoadStatisticsStore::populateFromDecoder):
1171         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
1172         (WebKit::WebResourceLoadStatisticsStore::mergeStatistics):
1173         (WebKit::WebResourceLoadStatisticsStore::shouldPartitionCookies):
1174         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
1175         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
1176         (WebKit::WebResourceLoadStatisticsStore::processStatistics):
1177         (WebKit::WebResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction):
1178         (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
1179         (WebKit::WebResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
1180         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
1181         * UIProcess/WebResourceLoadStatisticsStore.h:
1182         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
1183         (WebKit::sortedPrevalentResourceTelemetry):
1184         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
1185         * UIProcess/WebResourceLoadStatisticsTelemetry.h:
1186         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1187         (WebKit::WebsiteDataStore::removeData):
1188         * WebKit2.xcodeproj/project.pbxproj:
1189
1190 2017-07-10  Wenson Hsieh  <wenson_hsieh@apple.com>
1191
1192         [WK2] Ignore touch events that interrupt platform-driven momentum scrolling
1193         https://bugs.webkit.org/show_bug.cgi?id=174300
1194         <rdar://problem/33030639>
1195
1196         Reviewed by Simon Fraser.
1197
1198         Adds support for immediately failing WKContentView's UIWebTouchEventsGestureRecognizer if any touch interrupts
1199         scroll view deceleration. Covered by 3 new LayoutTests (see Source/WebCore/ChangeLog).
1200
1201         * Platform/spi/ios/UIKitSPI.h:
1202         * UIProcess/API/Cocoa/WKWebView.mm:
1203         (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
1204         (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
1205         * UIProcess/PageClient.h:
1206         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
1207         * UIProcess/Scrolling/RemoteScrollingTree.cpp:
1208         (WebKit::RemoteScrollingTree::scrollingTreeNodeDidEndPanGesture):
1209         * UIProcess/Scrolling/RemoteScrollingTree.h:
1210         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
1211         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
1212         (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
1213         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewDidEndPanGesture):
1214
1215         Adds plumbing in the UI process to alert the WKContentView when scroll view dragging has ended in an overflow
1216         momentum scrolling region (tracked by an overflow scrolling tree node). This parallels UI process plumbing for
1217         ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewWillStartPanGesture.
1218
1219         * UIProcess/WebPageProxy.h:
1220         * UIProcess/ios/PageClientImplIOS.h:
1221         * UIProcess/ios/PageClientImplIOS.mm:
1222         (WebKit::PageClientImpl::overflowScrollViewDidEndPanGesture):
1223         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
1224         (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidEndPanGesture):
1225         * UIProcess/ios/WKContentViewInteraction.h:
1226         * UIProcess/ios/WKContentViewInteraction.mm:
1227         (-[WKContentView scrollViewDidEndPanOrPinchGesture]):
1228
1229         When the dragging phase of a scroll gesture ends, ensure that _canSendTouchEventsAsynchronously is reset to NO.
1230         When touches are not being prevented, this flag is set to YES in -scrollViewWillStartPanOrPinchGesture: and
1231         normally reset to NO in -_webTouchEventsRecognized: after all touch points have been released. However, in the
1232         case where we've prematurely failed the web touch events gesture recognizer after -touchesBegan:,
1233         -_webTouchEventsRecognized: will not be called again in a state where all touches have been released. Thus, we
1234         also need to bookend the place where we begin allowing async touch event dispatch in
1235         -scrollViewWillStartPanOrPinchGesture by disallowing async touch event dispatch in
1236         -scrollViewDidEndPanOrPinchGesture.
1237
1238         This has no impact in the normal case where the user scrolls without momentum, since
1239         -scrollViewDidEndPanOrPinchGesture will fire after async touch events have already been disallowed in
1240         -_webTouchEventsRecognized:, and in the case where the page prevents default on touches, scrolling doesn't
1241         happen anyways, so neither scrollViewWillStartPanOrPinchGesture nor scrollViewDidEndPanOrPinchGesture will be
1242         invoked.
1243
1244         (-[WKContentView gestureRecognizer:shouldIgnoreWebTouchWithEvent:]):
1245
1246         Implements a new SPI hook in UIKit. This serves an identical purpose as -shouldIgnoreWebTouch, but additionally
1247         passes the triggering UIEvent, as well as the gesture recognizer itself (following standard convention for
1248         Objective C delegate methods). Here, we return YES in the case where one or more of the touches recognized by
1249         the gesture is currently interrupting scroll deceleration.
1250
1251         * UIProcess/ios/WebPageProxyIOS.mm:
1252         (WebKit::WebPageProxy::overflowScrollViewDidEndPanGesture):
1253
1254 2017-07-10  Brent Fulgham  <bfulgham@apple.com>
1255
1256         [WK2][macOS] Allow access to com.apple.cfnetwork.cfnetworkagent in the Network Process
1257         https://bugs.webkit.org/show_bug.cgi?id=174320
1258         <rdar://problem/33191856>
1259
1260         Reviewed by Geoffrey Garen.
1261
1262         * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
1263
1264 2017-07-10  Megan Gardner  <megan_gardner@apple.com>
1265
1266         Add location to NavigationActionData
1267         https://bugs.webkit.org/show_bug.cgi?id=174233
1268         <rdar://problem/29165518>
1269
1270         Reviewed by Simon Fraser.
1271         
1272         Add the root view location of a tap to a NavigationAction to vend to Safari.
1273
1274         * Shared/NavigationActionData.cpp:
1275         (WebKit::NavigationActionData::encode):
1276         (WebKit::NavigationActionData::decode):
1277         * Shared/NavigationActionData.h:
1278         * UIProcess/API/APINavigationAction.h:
1279         * UIProcess/API/Cocoa/WKNavigationAction.mm:
1280         (-[WKNavigationAction description]):
1281         (-[WKNavigationAction _clickLocationInRootViewCoordinates]):
1282         * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
1283         * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
1284         (WebKit::clickLocationInRootViewCoordinatesForMouseEvent):
1285         (WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinatesForNavigationAction):
1286         (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
1287         * WebProcess/InjectedBundle/InjectedBundleNavigationAction.h:
1288         (WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinates):
1289         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
1290         (WebKit::WebChromeClient::createWindow):
1291         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1292         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
1293         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
1294
1295 2017-07-03  Brian Burg  <bburg@apple.com>
1296
1297         Web Replay: remove some unused code
1298         https://bugs.webkit.org/show_bug.cgi?id=173903
1299
1300         Rubber-stamped by Joseph Pecoraro.
1301
1302         * Configurations/FeatureDefines.xcconfig:
1303         * WebProcess/WebPage/WebPage.cpp:
1304         (WebKit::WebPage::tryClose):
1305         (WebKit::WebPage::loadRequest):
1306         (WebKit::WebPage::stopLoadingFrame):
1307         (WebKit::WebPage::stopLoading):
1308         (WebKit::WebPage::reload):
1309         (WebKit::WebPage::contextMenuAtPointInWindow):
1310         (WebKit::handleContextMenuEvent):
1311         (WebKit::handleMouseEvent):
1312         (WebKit::handleWheelEvent):
1313         (WebKit::handleKeyEvent):
1314         (WebKit::WebPage::scroll):
1315         (WebKit::WebPage::logicalScroll):
1316
1317 2017-07-10  Chris Dumez  <cdumez@apple.com>
1318
1319         Further WebResourceLoadStatisticsStore / ResourceLoadStatisticsStore clean up
1320         https://bugs.webkit.org/show_bug.cgi?id=174301
1321
1322         Reviewed by Brent Fulgham.
1323
1324         General clean up and various simplifications / optimizations to WebResourceLoadStatisticsStore
1325         and ResourceLoadStatisticsStore classes.
1326
1327         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1328         (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]):
1329         (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]):
1330         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
1331         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1332         (WebKit::ResourceLoadStatisticsStore::create):
1333         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
1334         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
1335         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
1336         (WebKit::ResourceLoadStatisticsStore::populateFromDecoder):
1337         (WebKit::ResourceLoadStatisticsStore::clearInMemory):
1338         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
1339         (WebKit::ResourceLoadStatisticsStore::updateCookiePartitioning):
1340         (WebKit::ResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
1341         (WebKit::ResourceLoadStatisticsStore::processStatistics):
1342         (WebKit::ResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction):
1343         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
1344         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1345         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1346         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1347         (WebKit::WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore):
1348         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
1349         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
1350         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
1351         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
1352         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
1353         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
1354         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
1355         (WebKit::WebResourceLoadStatisticsStore::resourceLogFilePath):
1356         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
1357         (WebKit::WebResourceLoadStatisticsStore::scheduleOrWriteStoreToDisk):
1358         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
1359         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
1360         (WebKit::WebResourceLoadStatisticsStore::platformExcludeFromBackup):
1361         (WebKit::WebResourceLoadStatisticsStore::createDecoderFromDisk):
1362         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
1363         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
1364         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
1365         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
1366         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
1367         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
1368         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
1369         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
1370         (WebKit::WebResourceLoadStatisticsStore::setDataRecordsBeingRemoved):
1371         * UIProcess/WebResourceLoadStatisticsStore.h:
1372         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
1373         (WebKit::sortedPrevalentResourceTelemetry):
1374         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
1375         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1376         (WebKit::WebsiteDataStore::updateCookiePartitioningForTopPrivatelyOwnedDomains):
1377         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
1378         * UIProcess/WebsiteData/WebsiteDataStore.h:
1379
1380 2017-07-10  Michael Catanzaro  <mcatanzaro@igalia.com>
1381
1382         [SOUP] Remove WebKitSoupCookieJarSqlite
1383         https://bugs.webkit.org/show_bug.cgi?id=174310
1384
1385         Reviewed by Carlos Garcia Campos.
1386
1387         It seems WebKitSoupCookieJarSqlite uses exactly the same database format as the upstream
1388         SoupCookieJarDb class. WebKitSoupCookieJarSqlite is a copy of SoupCookieJarSqlite that uses
1389         WebCore's SQLite wrapper and WTF stuff. WebKitSoupCookieJarSqlite exists only because
1390         SoupCookieJarDb is relatively new, and the older SoupCookieJarSqlite class existed only in
1391         libsoup-gnome rather than libsoup proper. The advantage of continuing to use our
1392         WebKitSoupCookieJarSqlite class, besides that we already know it works, is that it utilizes
1393         the same SQLiteDatabase class that is used elsewhere in WebKit. But that's not really any
1394         reason to keep the class around, when SoupCookieJarDb does exactly the same thing. It was
1395         introduced in libsoup 2.42 and that is already our minimum required version, so we can
1396         switch now.
1397
1398         This passes a quick sanity-check of Epiphany's cookies dialog and also TestCookieManager.
1399
1400         * PlatformGTK.cmake:
1401         * PlatformWPE.cmake:
1402         * WebProcess/Cookies/soup/WebCookieManagerSoup.cpp:
1403         (WebKit::WebCookieManager::setCookiePersistentStorage):
1404         * WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.cpp: Removed.
1405         * WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.h: Removed.
1406
1407 2017-07-10  Myles C. Maxfield  <mmaxfield@apple.com>
1408
1409         REGRESSION(r213590): UI process updates the visible content rects more often than it did in iOS 10
1410         https://bugs.webkit.org/show_bug.cgi?id=174282
1411         <rdar://problem/33144344>
1412
1413         Reviewed by Simon Fraser.
1414
1415         In r213590, we accidentally refactored -[WKWebView _didCommitLayerTree:] to call _scheduleVisibleContentRectUpdate
1416         more often. Instead, this should be triggered from inside the "if" statements. 
1417
1418         No tests because there is no behavior change. Performance change is tested in MotionMark.
1419
1420         * UIProcess/API/Cocoa/WKWebView.mm:
1421         (-[WKWebView _isShowingVideoPictureInPicture]):
1422         (-[WKWebView _initializeWithConfiguration:]):
1423         (-[WKWebView goBack]):
1424         (-[WKWebView _didCommitLayerTree:]):
1425         (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
1426         (-[WKWebView _zoomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]):
1427         (-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
1428         (-[WKWebView scrollViewDidScroll:]):
1429         (-[WKWebView _visibleContentRect]):
1430         (-[WKWebView _frameOrBoundsChanged]):
1431         (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
1432         (-[WKWebView _updateVisibleContentRects]):
1433         (-[WKWebView _navigationGestureDidBegin]):
1434         (-[WKWebView _reloadWithoutContentBlockers]):
1435         (-[WKWebView _reloadExpiredOnly]):
1436         (-[WKWebView _setObscuredInsets:]):
1437         (-[WKWebView _setUnobscuredSafeAreaInsets:]):
1438         (-[WKWebView _endAnimatedResize]):
1439         (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
1440         (-[WKWebView _clearOverrideLayoutParameters]):
1441         (-[WKWebView _requestActivatedElementAtPosition:completionBlock:]):
1442         (-[WKWebView _propertiesOfLayerWithID:]):
1443
1444 2017-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
1445
1446         [SOUP] SoupCookieJar is never released (resulting in sqlite temp files lying around)
1447         https://bugs.webkit.org/show_bug.cgi?id=166029
1448
1449         Reviewed by Michael Catanzaro.
1450
1451         Clear the SoupNetworkSession and cookie storage after the main loop quits.
1452
1453         * NetworkProcess/soup/NetworkProcessMainSoup.cpp:
1454         (WebKit::NetworkProcessMainUnix):
1455
1456 2017-07-10  Wenson Hsieh  <wenson_hsieh@apple.com>
1457
1458         [WK2] Action sheets for links fail to present in WebKit2 PDF view
1459         https://bugs.webkit.org/show_bug.cgi?id=174307
1460         <rdar://problem/31412128>
1461
1462         Reviewed by Tim Horton.
1463
1464         Currently, presenting an action sheet for a link always uses the WKActionSheetPresentAtClosestIndicatorRect
1465         codepath, which requires text indicator data for the link. However, when showing an action sheet for a link via
1466         WKPDFView, a text indicator for the link is not included, so the popover rect ends up being an empty rect at the
1467         origin, which causes us to bail from presenting the popover.
1468
1469         To address this, we tweak our heuristic for determining which action sheet presentation style to use, so that we
1470         only use the closest indicator rect for a link if the text indicator data is also present (otherwise, we fall
1471         back to using the element rect). All other behavior is the same.
1472
1473         * UIProcess/ios/WKActionSheetAssistant.mm:
1474         (-[WKActionSheetAssistant showImageSheet]):
1475         (presentationStyleForView):
1476
1477         Refactor _shouldPresentAtTouchLocationForElementRect into presentationStyleForView, a static function that
1478         returns a WKActionSheetPresentationStyle.
1479
1480         (-[WKActionSheetAssistant showLinkSheet]):
1481         (-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]): Deleted.
1482
1483 2017-07-09  Brady Eidson  <beidson@apple.com>
1484
1485         Remove some obsolete WebKitVersionChecks.
1486         https://bugs.webkit.org/show_bug.cgi?id=174294
1487
1488         Reviewed by Dan Bernstein.
1489
1490         * WebProcess/WebPage/WebPage.cpp:
1491         (WebKit::WebPage::updatePreferences):
1492
1493 2017-07-08  Chris Dumez  <cdumez@apple.com>
1494
1495         Simplify WebResourceLoadStatisticsStore / ResourceLoadStatisticsStore
1496         https://bugs.webkit.org/show_bug.cgi?id=174290
1497
1498         Reviewed by Brent Fulgham.
1499
1500         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1501         (-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]):
1502         (-[WKWebsiteDataStore _resourceLoadStatisticsSubmitTelemetry]):
1503         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
1504         Rename a couple of functions in the Cocoa SPI for clarity and to match the name
1505         of their internal implementation.
1506
1507         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1508         (WebKit::ResourceLoadStatisticsStore::create):
1509         (WebKit::ResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
1510         Stylistic changes.
1511
1512         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
1513         Make const.
1514
1515         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
1516         Use HashMap::add() instead of HashMap::set(). There is not supposed to have any duplicate
1517         keys so add() is sufficient and more efficient.
1518
1519         (WebKit::ResourceLoadStatisticsStore::clearInMemoryAndPersistent): Removed.
1520         clearInMemoryAndPersistent() was only called from WebResourceLoadStatisticsStore and
1521         the m_deletePersistentStoreHandler / m_grandfatherExistingWebsiteDataHandler were both
1522         set by the WebResourceLoadStatisticsStore as well. Therefore, we don't really need this
1523         function, WebResourceLoadStatisticsStore now calls ResourceLoadStatisticsStore::clearInMemory()
1524         instead and takes care of doing what the m_deletePersistentStoreHandler /
1525         m_grandfatherExistingWebsiteDataHandler handlers were doing on its side.
1526
1527         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
1528         Pass Vector as rvalue reference, as a preparation for a future optimization. Added FIXME
1529         comment about the optimization.
1530
1531         (WebKit::ResourceLoadStatisticsStore::setNotificationCallback): Removed.
1532         (WebKit::ResourceLoadStatisticsStore::setGrandfatherExistingWebsiteDataCallback): Removed.
1533         (WebKit::ResourceLoadStatisticsStore::setDeletePersistentStoreCallback): Removed.
1534         (WebKit::ResourceLoadStatisticsStore::setFireTelemetryCallback): Removed.
1535         Drop those callback setters. WebResourceLoadStatisticsStore is the only client of
1536         ResourceLoadStatisticsStore and those callbacks were always called as a result of
1537         an operation requested by the WebResourceLoadStatisticsStore. Therefore, those are
1538         not needed. WebResourceLoadStatisticsStore can take care of doing what those
1539         callbacks were doing on its side.
1540
1541         (WebKit::ResourceLoadStatisticsStore::processStatistics):
1542         Pass parameter by const reference since we clearly do not intend to transfer ownership of it.
1543
1544         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
1545         (WebKit::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
1546         (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
1547         Stylistic changes.
1548
1549         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords): Removed.
1550         (WebKit::ResourceLoadStatisticsStore::dataRecordsBeingRemoved): Removed.
1551         (WebKit::ResourceLoadStatisticsStore::dataRecordsWereRemoved): Removed.
1552         Those were moved to WebResourceLoadStatisticsStore since they do not require
1553         any access to the statistics, and are only used by WebResourceLoadStatisticsStore.
1554
1555         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1556
1557         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1558         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1559         Store registering most callbacks on the coreStore. Instead, the logic of those
1560         callbacks is now inlined in the few methods in WebResourceLoadStatisticsStore
1561         that were causing these callbacks to be called.
1562
1563         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
1564         Access some methods on WebResourceLoadStatisticsStore instead of the coreStore
1565         since those were moved.
1566
1567         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
1568         Drop unnecessary mutable for lambda.
1569
1570         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
1571         Pass parameter as rvalue reference as a preparation for a future optimization.
1572
1573         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsFileChangedSinceLastSync):
1574         Make const.
1575
1576         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
1577         Add assertion to make sure this is called on the main thread.
1578
1579         (WebKit::WebResourceLoadStatisticsStore::fireDataModificationHandler): Removed.
1580         This was dispatching to a background queue to call fireDataModificationHandler()
1581         on the ResourceLoadStatisticsStore. The coreStore would then dispatch back on the
1582         main thread to call the WebResourceLoadStatisticsStore's modification handler.
1583         This modification handler was merely calling processStatisticsAndDataRecords().
1584         Therefore, callers of WebResourceLoadStatisticsStore::fireDataModificationHandler()
1585         can call WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() directly
1586         instead.
1587
1588         (WebKit::WebResourceLoadStatisticsStore::fireTelemetryHandler): Removed.
1589         This was calling ResourceLoadStatisticsStore::fireTelemetryHandler(), which was
1590         calling back WebResourceLoadStatisticsStore's fireTelemetryHandler. The handler
1591         in question was merely calling submitTelemetry(). Therefore, callers of
1592         WebResourceLoadStatisticsStore::fireTelemetryHandler() can call
1593         WebResourceLoadStatisticsStore::submitTelemetry() directly instead.
1594
1595         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
1596         Call ResourceLoadStatisticsStore::clearInMemory() instead of clearInMemoryAndPersistent(),
1597         which was removed. ResourceLoadStatisticsStore::clearInMemoryAndPersistent() was calling
1598         clearInMemory() and then 2 of WebResourceLoadStatisticsStore's handlers. Instead, we now
1599         call the functions that those handlers were calling directly, thus eliminating the need
1600         for those handlers.
1601
1602         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
1603         Set m_minimumTimeBetweenDataRecordsRemoval directly as it is now store on this class
1604         instead of the coreStore.
1605
1606         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
1607         (WebKit::WebResourceLoadStatisticsStore::dataRecordsBeingRemoved):
1608         (WebKit::WebResourceLoadStatisticsStore::dataRecordsWereRemoved):
1609         Those were merely moved from the ResourceLoadStatisticsStore.
1610
1611         * UIProcess/WebResourceLoadStatisticsStore.h:
1612
1613         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
1614         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
1615         Check for sortedPrevalentResources.isEmpty() instead of checking if the size
1616         if less than minimumPrevalentResourcesForTelemetry.
1617         ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry() either returns
1618         an empty vector or a vector with more than minimumPrevalentResourcesForTelemetry
1619         items. Therefore, there is no need to expose minimumPrevalentResourcesForTelemetry.
1620
1621 2017-07-08  Yusuke Suzuki  <utatane.tea@gmail.com>
1622
1623         Drop NOSNIFF compile flag
1624         https://bugs.webkit.org/show_bug.cgi?id=174289
1625
1626         Reviewed by Michael Catanzaro.
1627
1628         * Configurations/FeatureDefines.xcconfig:
1629
1630 2017-07-07  Chris Dumez  <cdumez@apple.com>
1631
1632         [WK2] Use a rolling 30-day uptime for processing statistics
1633         https://bugs.webkit.org/show_bug.cgi?id=174235
1634         <rdar://problem/33164381>
1635
1636         Reviewed by Brent Fulgham.
1637
1638         Follow-up fix for r219274 because it caused this test to time out:
1639         http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
1640
1641         The test sets TimeToLiveUserInteraction to 0 so our implementation cannot use
1642         0 as magic value to see if it was set. Instead, use std::optional.
1643
1644         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1645         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
1646         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1647         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1648         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired):
1649         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1650         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1651         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1652         * UIProcess/WebResourceLoadStatisticsStore.h:
1653
1654 2017-07-07  Brent Fulgham  <bfulgham@apple.com>
1655
1656         [WK2] Use a rolling 30-day uptime for processing statistics
1657         https://bugs.webkit.org/show_bug.cgi?id=174235
1658         <rdar://problem/33164381>
1659
1660         Reviewed by Chris Dumez.
1661
1662         * UIProcess/API/Cocoa/WKWebsiteDataStore.cpp:
1663         (WebKit::WKWebsiteDataStore::_resourceLoadStatisticsResetToConsistentState): Initialize time-to-live to zero by default.
1664         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1665         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData): Write out vector
1666         of operating dates.
1667         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder): Read in vector of
1668         operating dates.
1669         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction): Check new
1670         convenience method.
1671         (WebKit::ResourceLoadStatisticsStore::markTodayAsOperatingDate): Added.
1672         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired): Added.
1673         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1674         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1675         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded): When reading
1676         a new data file, update the current operating date (if needed).
1677         (WebKit::WebResourceLoadStatisticsStore::handleDailyTasks): Roll uptime dates as
1678         needed, then handle telemetry.
1679         * UIProcess/WebResourceLoadStatisticsStore.h:
1680
1681 2017-07-07  Wenson Hsieh  <wenson_hsieh@apple.com>
1682
1683         [iOS DnD] For cross-app drags, 'drop' event handlers are never invoked if dataTransfer.dropEffect is not set while dragging
1684         https://bugs.webkit.org/show_bug.cgi?id=174219
1685         <rdar://problem/32083177>
1686
1687         Reviewed by Ryosuke Niwa.
1688
1689         Tweak some testing SPI to return a drop operation flag instead of whether or not the drop operation was not
1690         UIDropOperationCancel.
1691
1692         * UIProcess/API/Cocoa/WKWebView.mm:
1693         (-[WKWebView _simulateDataInteractionUpdated:]):
1694         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1695         * UIProcess/ios/WKContentViewInteraction.h:
1696         * UIProcess/ios/WKContentViewInteraction.mm:
1697         (-[WKContentView _simulateDataInteractionUpdated:]):
1698
1699 2017-07-07  Commit Queue  <commit-queue@webkit.org>
1700
1701         Unreviewed, rolling out r219238, r219239, and r219241.
1702         https://bugs.webkit.org/show_bug.cgi?id=174265
1703
1704         "fast/workers/dedicated-worker-lifecycle.html is flaky"
1705         (Requested by yusukesuzuki on #webkit).
1706
1707         Reverted changesets:
1708
1709         "[WTF] Implement WTF::ThreadGroup"
1710         https://bugs.webkit.org/show_bug.cgi?id=174081
1711         http://trac.webkit.org/changeset/219238
1712
1713         "Unreviewed, build fix after r219238"
1714         https://bugs.webkit.org/show_bug.cgi?id=174081
1715         http://trac.webkit.org/changeset/219239
1716
1717         "Unreviewed, CLoop build fix after r219238"
1718         https://bugs.webkit.org/show_bug.cgi?id=174081
1719         http://trac.webkit.org/changeset/219241
1720
1721 2017-07-07  Antti Koivisto  <antti@apple.com>
1722
1723         WKWebSiteDataStore.removeDataOfTypes should wait until disk cache files are actually removed before invoking completion handler
1724         https://bugs.webkit.org/show_bug.cgi?id=174224
1725         <rdar://problem/33067545>
1726
1727         Reviewed by Sam Weinig.
1728
1729         Currently we dispatch file deletion operations to a background queue and call the completion
1730         handler without waiting for the I/O to complete.
1731
1732         * NetworkProcess/NetworkProcess.cpp:
1733         (WebKit::clearDiskCacheEntries):
1734
1735             Call a new version of NetworkCache::remove() for bulk deletion.
1736             Note that it is fine to call this with an empty vector.
1737
1738         * NetworkProcess/cache/NetworkCache.cpp:
1739         (WebKit::NetworkCache::Cache::remove):
1740
1741             Bulk deletion with a completion handler.
1742
1743         (WebKit::NetworkCache::Cache::deleteFiles): Added.
1744
1745             Factor to a helper function.
1746
1747         * NetworkProcess/cache/NetworkCache.h:
1748         * NetworkProcess/cache/NetworkCacheStorage.cpp:
1749         (WebKit::NetworkCache::Storage::remove):
1750
1751             Remove files for all the provided keys in a queue and invoke the completion handler in the main thread when done.
1752
1753         * NetworkProcess/cache/NetworkCacheStorage.h:
1754
1755 2017-07-06  Chris Dumez  <cdumez@apple.com>
1756
1757         Fix bad usage of static variables in ResourceLoadStatisticsStore
1758         https://bugs.webkit.org/show_bug.cgi?id=174237
1759
1760         Reviewed by Brent Fulgham.
1761
1762         Fix bad usage of static variables in ResourceLoadStatisticsStore. Those can be set via
1763         member functions on ResourceLoadStatisticsStore so they should be data members. The
1764         API to set them is associated to a particular store and there can in theory be several
1765         stores.
1766
1767         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1768         (WebKit::ResourceLoadStatisticsStore::shouldPartitionCookies):
1769         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
1770         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
1771         (WebKit::ResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
1772         (WebKit::ResourceLoadStatisticsStore::setGrandfatheringTime):
1773         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
1774         (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
1775         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
1776         (WebKit::shouldPartitionCookies): Deleted.
1777         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1778
1779 2017-07-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1780
1781         [WTF] Implement WTF::ThreadGroup
1782         https://bugs.webkit.org/show_bug.cgi?id=174081
1783
1784         Reviewed by Mark Lam.
1785
1786         * Shared/AsyncRequest.h:
1787         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
1788
1789 2017-07-06  Chris Dumez  <cdumez@apple.com>
1790
1791         Drop unused ResourceLoadStatistics members
1792         https://bugs.webkit.org/show_bug.cgi?id=174226
1793
1794         Reviewed by Brent Fulgham.
1795
1796         * Shared/WebCoreArgumentCoders.cpp:
1797         (IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
1798         (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
1799         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1800         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
1801
1802 2017-07-06  Wenson Hsieh  <wenson_hsieh@apple.com>
1803
1804         Unreviewed, fix the internal iOS 11 build
1805
1806         It turns out, our internal bots are still on an older version of the iOS 11 SDK that's missing _UIDataOwner in
1807         <UIKit/NSItemProvider+UIKitAdditions_Private.h>. To ensure that we can build on both current and slightly older
1808         versions of the iOS 11 SDK, fall back to using NSInteger instead of _UIDataOwner.
1809
1810         * Platform/spi/ios/UIKitSPI.h:
1811         * UIProcess/ios/WKContentViewInteraction.mm:
1812         (-[WKContentView _dragInteraction:dataOwnerForSession:]):
1813         (-[WKContentView _dropInteraction:dataOwnerForSession:]):
1814
1815 2017-07-06  Wenson Hsieh  <wenson_hsieh@apple.com>
1816
1817         [iOS DnD] [WK2] Add delegate hooks for specifying the data owner for a drag or drop session
1818         https://bugs.webkit.org/show_bug.cgi?id=174139
1819         <rdar://problem/33126212>
1820
1821         Reviewed by Beth Dakin.
1822
1823         Add hooks to query the UI delegate for a _UIDataOwner on both drag and drop sides.
1824
1825         * Platform/spi/ios/UIKitSPI.h:
1826         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
1827         * UIProcess/ios/WKContentViewInteraction.mm:
1828         (-[WKContentView _dragInteraction:dataOwnerForSession:]):
1829         (-[WKContentView _dropInteraction:dataOwnerForSession:]):
1830
1831 2017-07-06  Brent Fulgham  <bfulgham@apple.com>
1832
1833         [WK2] ResourceLoadStatistics should batch its writes
1834         https://bugs.webkit.org/show_bug.cgi?id=174111
1835         <rdar://problem/33115894>
1836
1837         Reviewed by Chris Dumez.
1838
1839         Revise the data writing operation to only write on a specific interval (currently
1840         set to 5 minutes).
1841
1842         Also make 'writeStoreToDisk' simpler to use by moving the deleting (before write) and
1843         creating (after write) of the FileMonitor into the method, rather than requiring this
1844         knowledge in multiple places.
1845
1846         Make sure that we write our statistics file out before exiting so that we do not
1847         lose any data if we exit before the five-minute window has elapsed.
1848
1849         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
1850         (WebKit::ResourceLoadStatisticsStore::setWritePersistentStoreCallback): Deleted.
1851         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1852         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords): Remove the stop
1853         and start monitoring into 'writeStoreToDisk'. Also check if enough time has elapsed since
1854         the last write to commit to disk.
1855         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver): Remove the
1856         stop and start monitoring into 'writeStoreToDisk'.
1857         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk): Add the stop and start monitoring
1858         commands here, so callers don't have to know to do so.
1859
1860 2017-07-06  Chris Dumez  <cdumez@apple.com>
1861
1862         FileMonitor should not be ref counted
1863         https://bugs.webkit.org/show_bug.cgi?id=174166
1864
1865         Reviewed by Brent Fulgham.
1866
1867         Update code using FileMonitor to reflect API change.
1868
1869         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1870         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
1871         (WebKit::WebResourceLoadStatisticsStore::stopMonitoringStatisticsStorage):
1872         * UIProcess/WebResourceLoadStatisticsStore.h:
1873
1874 2017-07-06  Matt Rajca  <mrajca@apple.com>
1875
1876         Fix build with VIDEO support disabled.
1877         https://bugs.webkit.org/show_bug.cgi?id=174217
1878
1879         Unreviewed build fix.
1880
1881         * WebProcess/WebPage/WebPage.cpp:
1882         (WebKit::WebPage::updateWebsitePolicies):
1883
1884 2017-07-06  Chris Dumez  <cdumez@apple.com>
1885
1886         Crash under WebResourceLoadStatisticsStore::persistentStoragePath(WTF::String const&)
1887         https://bugs.webkit.org/show_bug.cgi?id=174205
1888         <rdar://problem/33093552>
1889
1890         Reviewed by Brent Fulgham.
1891
1892         Make sure we isolateCopy() m_statisticsStoragePath before using it from the background
1893         thread.
1894
1895         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1896         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
1897         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
1898         (WebKit::WebResourceLoadStatisticsStore::resourceLogFilePath):
1899         (WebKit::WebResourceLoadStatisticsStore::statisticsFilePath):
1900         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
1901         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
1902         (WebKit::WebResourceLoadStatisticsStore::deleteStoreFromDisk):
1903         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
1904         (WebKit::WebResourceLoadStatisticsStore::syncWithExistingStatisticsStorageIfNeeded):
1905         (WebKit::WebResourceLoadStatisticsStore::persistentStoragePath): Deleted.
1906         * UIProcess/WebResourceLoadStatisticsStore.h:
1907
1908 2017-07-06  Alex Christensen  <achristensen@webkit.org>
1909
1910         Fix CFURLRequestRef serialization after r207330
1911         https://bugs.webkit.org/show_bug.cgi?id=163332
1912
1913         * Shared/mac/WebCoreArgumentCodersMac.mm:
1914         (IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
1915         The CFURLConnection code was not updated.
1916         We did not catch this because nobody uses the WebKit2 CFURLConnection code, but I need to use it to debug something.
1917
1918 2017-07-06  Chris Dumez  <cdumez@apple.com>
1919
1920         Move ResourceLoadObserver notification throttling logic from WebProcess class to ResourceLoadObserver
1921         https://bugs.webkit.org/show_bug.cgi?id=174194
1922
1923         Reviewed by Brent Fulgham.
1924
1925         Move ResourceLoadObserver notification throttling logic from WebProcess class to
1926         ResourceLoadObserver. This makes more sense and decreases the complexity of the
1927         WebProcess class.
1928
1929         * WebProcess/WebProcess.cpp:
1930         (WebKit::m_webSQLiteDatabaseTracker):
1931         (WebKit::WebProcess::statisticsChangedTimerFired): Deleted.
1932         * WebProcess/WebProcess.h:
1933
1934 2017-07-06  Chris Dumez  <cdumez@apple.com>
1935
1936         WebResourceLoadStatisticsStore should only be constructed when the feature is enabled
1937         https://bugs.webkit.org/show_bug.cgi?id=174189
1938
1939         Reviewed by Brent Fulgham.
1940
1941         Delay the construction of the WebResourceLoadStatisticsStore until the feature gets
1942         enabled via WebsiteDataStore::setResourceLoadStatisticsEnabled(). Previously, we would
1943         always construct a store and then have a boolean on the store to indicate if it is
1944         enabled or not.
1945
1946         Also simplify the initialization process of the WebResourceLoadStatisticsStore, we
1947         used to have:
1948         1. WebResourceLoadStatisticsStore constructor
1949         2. WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver()
1950         3. WebResourceLoadStatisticsStore::setResourceLoadStatisticsEnabled(true)
1951
1952         All 3 steps are now taken care of by the WebResourceLoadStatisticsStore constructor.
1953
1954         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1955         (WebKit::WebProcessPool::platformInitialize):
1956         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1957         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1958         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
1959         * UIProcess/WebResourceLoadStatisticsStore.h:
1960         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1961         (WebKit::WebsiteDataStore::platformInitialize):
1962         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1963         (WebKit::WebsiteDataStore::WebsiteDataStore):
1964         (WebKit::WebsiteDataStore::resourceLoadStatisticsEnabled):
1965         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
1966         * UIProcess/WebsiteData/WebsiteDataStore.h:
1967         (WebKit::WebsiteDataStore::resourceLoadStatistics):
1968         * UIProcess/wpe/WebProcessPoolWPE.cpp:
1969         (WebKit::WebProcessPool::platformInitialize):
1970
1971 2017-07-06  Claudio Saavedra  <csaavedra@igalia.com>
1972
1973         [GTK] It should process MouseMoved events when the parent window is not active
1974         https://bugs.webkit.org/show_bug.cgi?id=116691
1975
1976         Reviewed by Michael Catanzaro.
1977
1978         From reading the comments in the related code, only in Safari it
1979         is desired that MouseMoved events are not processed when the
1980         parent window is not active. In other ports, in particular those
1981         targeting Linux, these events should be processed for consistency
1982         with other browsers.
1983
1984         * UIProcess/WebPageProxy.cpp:
1985         (WebKit::WebPageProxy::setCursor):
1986         * UIProcess/mac/PageClientImpl.mm:
1987         (WebKit::PageClientImpl::setCursor):
1988         * WebProcess/WebPage/WebPage.cpp:
1989         (WebKit::handleMouseEvent):
1990         (WebKit::WebPage::mouseEvent):  No need to always pass a boolean
1991         parameter that is only checked for one type of event. Do the check
1992         internally in handleMouseEvent() only when needed and only in Cocoa.
1993
1994 2017-07-05  Don Olmstead  <don.olmstead@sony.com>
1995
1996         [WTF] Move SoftLinking.h into WTF
1997         https://bugs.webkit.org/show_bug.cgi?id=174000
1998
1999         Reviewed by Alex Christensen.
2000
2001         * Platform/mac/StringUtilities.mm:
2002         * Platform/spi/ios/ManagedConfigurationSPI.h:
2003         * Shared/Cocoa/DataDetectionResult.mm:
2004         * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
2005         * Shared/ios/InteractionInformationAtPosition.mm:
2006         * Shared/ios/WebIconUtilities.mm:
2007         * Shared/mac/CookieStorageShim.mm:
2008         * Shared/mac/WebCoreArgumentCodersMac.mm:
2009         * UIProcess/API/Cocoa/_WKElementAction.mm:
2010         * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
2011         * UIProcess/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
2012         * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
2013         * UIProcess/Cocoa/UIDelegate.mm:
2014         * UIProcess/Cocoa/WebViewImpl.mm:
2015         * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
2016         * UIProcess/ios/WKActionSheetAssistant.mm:
2017         * UIProcess/ios/WKContentViewInteraction.mm:
2018         * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
2019         * UIProcess/ios/forms/WKFileUploadPanel.mm:
2020         * UIProcess/mac/WKImmediateActionController.mm:
2021         * UIProcess/mac/WebInspectorProxyMac.mm:
2022         * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
2023         * WebProcess/WebPage/mac/WebInspectorUIMac.mm:
2024         * WebProcess/cocoa/WebProcessCocoa.mm:
2025
2026 2017-07-05  Brady Eidson  <beidson@apple.com>
2027
2028         Allow navigations in subframes to get a ShouldOpenExternalURLsPolicy of "ShouldAllow".
2029         <rdar://problem/22485589> and https://bugs.webkit.org/show_bug.cgi?id=174178
2030
2031         Reviewed by Alex Christensen.
2032
2033         Adopt to the new constructor for FrameLoadRequest.
2034
2035         * WebProcess/Plugins/PluginView.cpp:
2036         (WebKit::PluginView::loadURL):
2037         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2038         (WebKit::WebFrameLoaderClient::dispatchCreatePage):
2039         * WebProcess/WebPage/WebInspector.cpp:
2040         (WebKit::WebInspector::openInNewTab):
2041
2042 2017-07-05  Ryosuke Niwa  <rniwa@webkit.org>
2043
2044         Remove unnecessary forward declartions now that we include Foundation.h
2045
2046         * UIProcess/API/Cocoa/WKContentRuleListStore.h:
2047
2048 2017-07-05  Ryosuke Niwa  <rniwa@webkit.org>
2049
2050         Make WebKit's public headers on Mac and iOS C++ module safe
2051         https://bugs.webkit.org/show_bug.cgi?id=174175
2052
2053         Reviewed by Alex Christensen.
2054
2055         Fixed the header files.
2056
2057         * UIProcess/API/Cocoa/WKContentRuleList.h:
2058         * UIProcess/API/Cocoa/WKContentRuleListStore.h:
2059         * UIProcess/API/Cocoa/WKUIDelegate.h:
2060
2061 2017-07-05  Chris Dumez  <cdumez@apple.com>
2062
2063         [WK2] WebsiteDataStore::setResourceLoadStatisticsEnabled() updates processPools the store is not associated with
2064         https://bugs.webkit.org/show_bug.cgi?id=174174
2065
2066         Reviewed by Brent Fulgham.
2067
2068         WebsiteDataStore::setResourceLoadStatisticsEnabled() updates processPools the store is not associated with.
2069         Fix this by iterating over WebsiteDataStore::processPools() instead of WebProcessPool::allProcessPools().
2070
2071         Also rename shouldPartitionCookiesForTopPrivatelyOwnedDomains methods / IPC messages to
2072         updateCookiePartitioningForTopPrivatelyOwnedDomains since this is a setter, not a getter.
2073
2074         Finally, drop ShouldPartitionCookiesForTopPrivatelyOwnedDomains IPC message to the NetworkProcessProxy
2075         as well as corresponding methods as those appear to be unused.
2076
2077         * NetworkProcess/NetworkProcess.cpp:
2078         (WebKit::NetworkProcess::updateCookiePartitioningForTopPrivatelyOwnedDomains):
2079         (WebKit::NetworkProcess::shouldPartitionCookiesForTopPrivatelyOwnedDomains): Deleted.
2080         * NetworkProcess/NetworkProcess.h:
2081         * NetworkProcess/NetworkProcess.messages.in:
2082         * UIProcess/Network/NetworkProcessProxy.cpp:
2083         (WebKit::NetworkProcessProxy::shouldPartitionCookiesForTopPrivatelyOwnedDomains): Deleted.
2084         * UIProcess/Network/NetworkProcessProxy.h:
2085         * UIProcess/Network/NetworkProcessProxy.messages.in:
2086         * UIProcess/WebProcessPool.cpp:
2087         (WebKit::WebProcessPool::setResourceLoadStatisticsEnabled):
2088         * UIProcess/WebProcessPool.h:
2089         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2090         (WebKit::WebsiteDataStore::updateCookiePartitioningForTopPrivatelyOwnedDomains):
2091         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
2092         (WebKit::WebsiteDataStore::registerSharedResourceLoadObserver):
2093         (WebKit::WebsiteDataStore::shouldPartitionCookiesForTopPrivatelyOwnedDomains): Deleted.
2094         * UIProcess/WebsiteData/WebsiteDataStore.h:
2095
2096 2017-07-05  Tim Horton  <timothy_horton@apple.com>
2097
2098         Async Image Decoding: Image flashes away briefly when tapping on tab in iPad tab picker
2099         https://bugs.webkit.org/show_bug.cgi?id=174173
2100         <rdar://problem/32431952>
2101
2102         Reviewed by Geoffrey Garen.
2103
2104         * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
2105         (WebKit::RemoteLayerTreeDrawingArea::addTransactionCallbackID):
2106         When a client uses e.g. doAfterNextPresentationUpdate (or internally,
2107         dispatchAfterEnsuringDrawing), they're doing so in the hopes that the
2108         callback is called after the page is well-painted -- for example, to
2109         remove a snapshot (in the tab picker case, as well as for navigation
2110         gestures), or to *take* a snapshot. In all of these cases, it is
2111         preferable to do a synchronous decode, to ensure that the image does
2112         not flash away temporarily.
2113
2114         Use the existing mechanism that was implemented for the synchronous
2115         activity state change flush to also force synchronous image decoding
2116         any time there is a post-commit transaction callback.
2117
2118 2017-07-05  Wenson Hsieh  <wenson_hsieh@apple.com>
2119
2120         [iOS DnD] [WK2] 3D touch fails to recognize when UIDragInteraction is enabled on phone
2121         https://bugs.webkit.org/show_bug.cgi?id=174171
2122         <rdar://problem/32956929>
2123
2124         Reviewed by Tim Horton.
2125
2126         By default, UIKit defers all competing long press gesture recognizers if dragging is enabled. However, this
2127         would cause 3D touch to be prevented, due to UIKit asking us whether or not we can proceed with the 3D touch
2128         gesture in -_interactionShouldBeginFromPreviewItemController:forPosition:, while the highlight long press
2129         gesture recognizer is being deferred. To address this, we use SPI on UIDragInteraction to allow the highlight
2130         long press gesture recognizer to recognize alongside the drag lift gesture. We then (already) manually cancel
2131         the highlight long press gesture in _dragInteraction:prepareForSession:completion:.
2132
2133         * UIProcess/ios/WKContentViewInteraction.mm:
2134         (-[WKContentView _dragInteraction:shouldDelayCompetingGestureRecognizer:]):
2135
2136 2017-07-03  Myles C. Maxfield  <mmaxfield@apple.com>
2137
2138         Remove copy of ICU headers from WebKit
2139         https://bugs.webkit.org/show_bug.cgi?id=116407
2140
2141         Reviewed by Alex Christensen.
2142
2143         * Configurations/BaseTarget.xcconfig:
2144
2145 2017-07-05  Chris Dumez  <cdumez@apple.com>
2146
2147         Regression(r218821): Bad cast to WebKit::DiagnosticLoggingClient in WKWebView's _setDiagnosticLoggingDelegate
2148         https://bugs.webkit.org/show_bug.cgi?id=174163
2149         <rdar://problem/33067518>
2150
2151         Reviewed by Alex Christensen.
2152
2153         After r218821, WebPageProxy::setDiagnosticLoggingClient() would no longer set the client in
2154         private session. This is an issue because there is code in WKWebView which expects the
2155         DiagnosticLoggingClient to be set and of a specific type. This would lead to bad casts in
2156         WKWebView's _diagnosticLoggingDelegate / _setDiagnosticLoggingDelegate.
2157
2158         To avoid the issue, we now unconditionally update the client in
2159         WebPageProxy::setDiagnosticLoggingClient(). Instead, we implement the logic for disabling
2160         logging in private session in the logging methods themselves, via the
2161         WebPageProxy::effectiveDiagnosticLoggingClient() helper instead.
2162
2163         I also added null checks in WKWebView's _diagnosticLoggingDelegate /
2164         _setDiagnosticLoggingDelegate. Even though the WKWebView sets itself as the diagnostic
2165         logging client, WebPageProxy::diagnosticLoggingClient() can still return null after
2166         calling WebPageProxy::close(). Previously, we would have done a bad cast if the WKWebView's
2167         client would have used this API after calling 'close' as well.
2168
2169         * UIProcess/API/APIDiagnosticLoggingClient.h:
2170         * UIProcess/API/Cocoa/WKWebView.mm:
2171         (-[WKWebView _diagnosticLoggingDelegate]):
2172         (-[WKWebView _setDiagnosticLoggingDelegate:]):
2173         * UIProcess/WebPageProxy.cpp:
2174         (WebKit::WebPageProxy::WebPageProxy):
2175         (WebKit::WebPageProxy::setDiagnosticLoggingClient):
2176         (WebKit::WebPageProxy::close):
2177         (WebKit::WebPageProxy::effectiveDiagnosticLoggingClient):
2178         (WebKit::WebPageProxy::logDiagnosticMessage):
2179         (WebKit::WebPageProxy::logDiagnosticMessageWithResult):
2180         (WebKit::WebPageProxy::logDiagnosticMessageWithValue):
2181         (WebKit::WebPageProxy::logDiagnosticMessageWithEnhancedPrivacy):
2182         * UIProcess/WebPageProxy.h:
2183         (WebKit::WebPageProxy::diagnosticLoggingClient):
2184
2185 2017-07-05  Daniel Bates  <dabates@apple.com>
2186
2187         Do not pass API::FrameInfo for source frame or clear out page of target frame on
2188         API navigation
2189         https://bugs.webkit.org/show_bug.cgi?id=174170
2190         <rdar://problem/33140328>
2191
2192         Reviewed by Brady Eidson.
2193
2194         As a step towards making it straightforward for an embedding client to determine whether
2195         a WebPageProxy::decidePolicyForNavigationAction() callback was initiated from API we
2196         should not pass frame info for the source frame and should not nullify the page pointer
2197         in the target frame info.
2198
2199         Currently we always pass frame info for the source frame and nullify the page pointer
2200         in both the source frame info and target frame info if the navigation was initiated from
2201         API. This seems subtle and error prone. Instead we should not pass frame info for
2202         the source frame and not nullify the page pointer in the target frame info as a step
2203         towards making using this API less error-prone.
2204
2205         * UIProcess/WebPageProxy.cpp:
2206         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
2207
2208 2017-07-05  Chris Dumez  <cdumez@apple.com>
2209
2210         Add a few more WebKit2 owners
2211         https://bugs.webkit.org/show_bug.cgi?id=174169
2212
2213         Reviewed by Brady Eidson.
2214
2215         * Owners:
2216
2217 2017-07-05  Brent Fulgham  <bfulgham@apple.com>
2218
2219         [WK2] Prevent ResourceLoadStatistics from triggering a cascade of read/write events
2220         https://bugs.webkit.org/show_bug.cgi?id=174062\
2221         <rdar://problem/33086744>
2222
2223         Reviewed by Chris Dumez.
2224
2225         ResourceLoadStatistics was triggering periods of high CPU use due to a cascade of read/write
2226         operations:
2227         (1) The 'makeRefPtr' call in FileMonitor::startMonitoring was capturing a reference to itself, preventing
2228             the FileMonitor from being destroyed. This caused the file modification handler to fire in response
2229             to our own write events, creating a ridiculous read/write cycle. This problem was addressed in
2230             the short term by stopping the file monitor in WebResourceLoadStatisticsStore::stopMonitoringStatisticsStorage,
2231             rather than relying on the destructor to shut things down. This will be improved in a
2232             subsequent patch.
2233         (2) 'syncWithExistingStatisticsStorageIfNeeded' was creating a FileMonitor during the write operation,
2234             which exacerbated the chain of read/writes already present due to the self-reference described above.
2235         (3) Because VNODE dispatch sources are low level, they do not offer a means of filtering out operations
2236             triggered by the current process. To avoid this, I added code to track the file modification time, so
2237             that we don't bother reading a file that holds data that is older than the in-memory data, even though
2238             we receive a file modification dispatch. Writes seem to trigger a chain of notification events in rapid
2239             succession. Once we've responded to the first of these events, we don't need to to further reads until
2240             the data on disk changes again.    
2241
2242         We also shouldn't allow the ResourceLoadStatistics worker thread to consume high CPU resources. Run it
2243         as utility QoS, avoiding using the CPU when other work is going on.
2244
2245         Drive-by fix: The closure in setWritePersistentStoreCallback() should stop monitoring before writing
2246         data, and should start monitoring after the write completes.
2247
2248         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2249         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore): Run our worker queue
2250         as a utility-level process.
2251         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver): Stop checking for
2252         updates before writing, and begin checking again once the write is complete.
2253         (WebKit::WebResourceLoadStatisticsStore::statisticsFileModificationTime): Added.
2254         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded): Avoid reading the file if it
2255         was last modified on (or before) the time we last read the file.
2256         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk): Ditto.
2257         (WebKit::WebResourceLoadStatisticsStore::stopMonitoringStatisticsStorage): Explicitly stop file
2258         monitoring so that the active file modification handler will terminate.
2259         (WebKit::WebResourceLoadStatisticsStore::syncWithExistingStatisticsStorageIfNeeded): Do not begin
2260         monitoring the file after syncing, since this is only used as part of an ongoing write operation.
2261
2262 2017-07-05  Jonathan Bedard  <jbedard@apple.com>
2263
2264         Add WebKitPrivateFrameworkStubs for iOS 11
2265         https://bugs.webkit.org/show_bug.cgi?id=173988
2266
2267         Reviewed by David Kilzer.
2268
2269         * Configurations/BaseTarget.xcconfig: iphoneos and iphonesimulator should use the
2270         same directory for private framework stubs.
2271
2272 2017-07-05  Andy Estes  <aestes@apple.com>
2273
2274         [iOS] WKActionSheetAssistants can outlive their host views
2275         https://bugs.webkit.org/show_bug.cgi?id=174160
2276         <rdar://problem/20638607>
2277
2278         Reviewed by Tim Horton.
2279
2280         WKActionSheetAssistant keeps a raw pointer to its host UIView, and nothing clears it when
2281         the host view is deallocated. If the assistant outlives the view, we can end up accessing a
2282         pointer to a deallocated UIView and crashing.
2283
2284         I don't know how to reproduce such a crash, but this patch guards against it by doing the
2285         following:
2286
2287         1. Make _view a WeakObjCPtr in WKActionSheetAssistant to ensure it gets set to nil when the
2288            UIView is deallocated.
2289         2. Call -[WKActionSheetAssistant cleanupSheet] when a WKContentView or WKPDFView is
2290            deallocated, or when the Web process crashes. This will ensure the action sheet is
2291            dismissed and prevent the user from tapping on an action that's no longer valid.
2292
2293         * UIProcess/ios/WKActionSheetAssistant.mm:
2294         (-[WKActionSheetAssistant superviewForSheet]):
2295         (-[WKActionSheetAssistant _presentationRectForSheetGivenPoint:inHostView:]):
2296         (-[WKActionSheetAssistant presentationRectForElementUsingClosestIndicatedRect]):
2297         (-[WKActionSheetAssistant presentationRectForIndicatedElement]):
2298         (-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]):
2299         * UIProcess/ios/WKContentViewInteraction.mm:
2300         (-[WKContentView cleanupInteraction]):
2301         * UIProcess/ios/WKPDFView.mm:
2302         (-[WKPDFView dealloc]):
2303
2304 2017-07-05  Frederic Wang  <fwang@igalia.com>
2305
2306         Move ScrolledContentsLayer property to ScrollingStateScrollingNode
2307         https://bugs.webkit.org/show_bug.cgi?id=174134
2308
2309         Reviewed by Simon Fraser.
2310
2311         * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
2312         (ArgumentCoder<ScrollingStateScrollingNode>::encode): Add encoding for scrolled contents
2313         layer.
2314         (ArgumentCoder<ScrollingStateFrameScrollingNode>::encode): Remove encoding for scrolled
2315         contents layer.
2316         (ArgumentCoder<ScrollingStateOverflowScrollingNode>::encode): Ditto.
2317         (ArgumentCoder<ScrollingStateScrollingNode>::decode): Add decoding for scrolled contents
2318         layer.
2319         (ArgumentCoder<ScrollingStateFrameScrollingNode>::decode): Remove decoding for scrolled
2320         contents layer.
2321         (ArgumentCoder<ScrollingStateOverflowScrollingNode>::decode): Ditto.
2322         (WebKit::dump): Move dumping of scrolled contents layer from overflow/frame nodes to
2323         scrolling node.
2324         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
2325         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers): Adjust enum value to use
2326         ScrollingStateScrollingNode::ScrolledContentsLayer.
2327         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
2328         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::commitStateBeforeChildren): Ditto.
2329         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
2330         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers): Ditto.
2331
2332 2017-07-05  Ada Chan  <adachan@apple.com>
2333
2334         Fix crash in UIKit: +[UIViewController _viewControllerForFullScreenPresentationFromView:]
2335         https://bugs.webkit.org/show_bug.cgi?id=174143
2336         <rdar://problem/28384582>
2337
2338         Reviewed by Wenson Hsieh.
2339
2340         In -[WKActionSheet willRotate], we can't guarantee that the action sheet belongs
2341         in a window, and passing nil to +[UIViewController _viewControllerForFullScreenPresentationFromView:]
2342         throws an exception. To fix this, bail early if the result from -hostViewForSheet is nil.
2343
2344         * UIProcess/ios/WKActionSheet.mm:
2345         (-[WKActionSheet willRotate]):
2346
2347 2017-07-05  Eric Carlson  <eric.carlson@apple.com>
2348
2349         [MediaStream] Protect request and web view during gUM client callback
2350         https://bugs.webkit.org/show_bug.cgi?id=174096
2351         <rdar://problem/32833102>
2352
2353         Reviewed by Youenn Fablet.
2354
2355         Retain the message and WebView during asynchronous calls so they won't be 
2356         released if a navigation happens during a call to the UA for getUserMedia 
2357         or enumerateMediaDevices.
2358
2359         * UIProcess/Cocoa/UIDelegate.mm:
2360         (WebKit::requestUserMediaAuthorizationForDevices):
2361         (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):
2362         (WebKit::UIDelegate::UIClient::checkUserMediaPermissionForOrigin):
2363
2364 2017-07-05  Matt Lewis  <jlewis3@apple.com>
2365
2366         Unreviewed, rolling out r219128.
2367
2368         Spoke with engineer who originally submitted, Patch for APi
2369         test to follow.
2370
2371         Reverted changeset:
2372
2373         "Unreviewed, rolling out r219070."
2374         https://bugs.webkit.org/show_bug.cgi?id=174082
2375         http://trac.webkit.org/changeset/219128
2376
2377 2017-07-05  Matt Lewis  <jlewis3@apple.com>
2378
2379         Unreviewed, rolling out r219070.
2380
2381         This revision caused consistent failures of the API test
2382         UIPasteboardTests.DoNotPastePlainTextAsURL on iOS.
2383
2384         Reverted changeset:
2385
2386         "Pasting single words copied to UIPasteboard inserts URLs in
2387         editable areas"
2388         https://bugs.webkit.org/show_bug.cgi?id=174082
2389         http://trac.webkit.org/changeset/219070
2390
2391 2017-07-05  Zan Dobersek  <zdobersek@igalia.com>
2392
2393         [GLib] Incorrect <glib/gi18n.h> include in WebKitWebsiteData
2394         https://bugs.webkit.org/show_bug.cgi?id=174093
2395
2396         Reviewed by Michael Catanzaro.
2397
2398         * UIProcess/API/glib/WebKitWebsiteData.cpp: Include <glib/gi18n-lib.h>
2399         rather than <glib/gi18n.h>, since the former has to be included in a
2400         library while the latter should only be included in a standalone application.
2401
2402 2017-07-04  Joseph Pecoraro  <pecoraro@apple.com>
2403
2404         Cleanup some StringBuilder use
2405         https://bugs.webkit.org/show_bug.cgi?id=174118
2406
2407         Reviewed by Andreas Kling.
2408
2409         * NetworkProcess/capture/NetworkCaptureManager.cpp:
2410         (WebKit::NetworkCapture::Manager::hashToPath):
2411         * UIProcess/WebPageProxy.cpp:
2412
2413 2017-07-03  Wenson Hsieh  <wenson_hsieh@apple.com>
2414
2415         [iOS DnD] [WK2] Callout bar should reappear after dragging ends for a text selection
2416         https://bugs.webkit.org/show_bug.cgi?id=174116
2417         <rdar://problem/33017845>
2418
2419         Reviewed by Ryosuke Niwa.
2420
2421         -willStartScrollingOverflow -didEndScrollingOverflow are helper methods on both the UIWKTextInteractionAssistant
2422         and UIWebSelectionAssistant that handle hiding selection and callout bar UI during overflow scrolling and making
2423         it reappear after scrolling ends. However, these hooks do not contain logic specific to scrolling, and simply
2424         tell the inner UIWebSelectionView to either show or hide and are safe to invoke outside of the context of
2425         scrolling.
2426
2427         This patch invokes these hooks when beginning a drag on a selection, and when a dragging ends, if it called
2428         -willStartScrollingOverflow to begin with. We should rename these in the future to be something along the lines
2429         of -hideSelectionViewAndControls and -showSelectionViewAndControls, respectively, and adopt these new names in
2430         WebKit. We also move logic to hide the callout out of -itemsForBeginningSession: and into
2431         -willAnimateLiftWithAnimator:, when the lift actually begins.
2432
2433         * UIProcess/ios/WKContentViewInteraction.h:
2434         * UIProcess/ios/WKContentViewInteraction.mm:
2435         (-[WKContentView cleanUpDragSourceSessionState]):
2436         (-[WKContentView _restoreCalloutBarIfNeeded]):
2437         (-[WKContentView dragInteraction:itemsForBeginningSession:]):
2438         (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]):
2439         (-[WKContentView dragInteraction:session:didEndWithOperation:]):
2440
2441 2017-07-03  Matt Rajca  <mrajca@apple.com>
2442
2443         Add/remove appropriate media element behavior restrictions when updateWebsitePolicies is called
2444         https://bugs.webkit.org/show_bug.cgi?id=174103
2445
2446         Reviewed by Alex Christensen.
2447
2448         Currently, when -[WKWebView evaluateJavaScript:completionHandler:] is invoked, we end up simulating
2449         a user gesture unconditionally. This is not desireable for some tests, so I added a private variant
2450         of this method that takes a boolean that is ultimately passed to `executeScript` for the
2451         `forceUserGesture` parameter (instead of unconditionally passing `true`).
2452
2453         * UIProcess/API/C/WKPage.cpp:
2454         (WKPageRunJavaScriptInMainFrame):
2455         * UIProcess/API/Cocoa/WKWebView.mm:
2456         (-[WKWebView evaluateJavaScript:completionHandler:]):
2457         (-[WKWebView _evaluateJavaScript:forceUserGesture:completionHandler:]):
2458         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2459         * UIProcess/WebPageProxy.cpp:
2460         (WebKit::WebPageProxy::runJavaScriptInMainFrame):
2461         * UIProcess/WebPageProxy.h:
2462         * WebProcess/WebPage/WebPage.cpp:
2463         (WebKit::WebPage::runJavaScriptInMainFrame):
2464         (WebKit::WebPage::updateWebsitePolicies): Update behavior restrictions on any existing media elements.
2465         * WebProcess/WebPage/WebPage.h:
2466         * WebProcess/WebPage/WebPage.messages.in:
2467
2468 2017-07-03  Matt Lewis  <jlewis3@apple.com>
2469
2470         Unreviewed, rolling out r219103.
2471
2472         Caused multiple build failures.
2473
2474         Reverted changeset:
2475
2476         "Remove copy of ICU headers from WebKit"
2477         https://bugs.webkit.org/show_bug.cgi?id=116407
2478         http://trac.webkit.org/changeset/219103
2479
2480 2017-07-03  Myles C. Maxfield  <mmaxfield@apple.com>
2481
2482         Remove copy of ICU headers from WebKit
2483         https://bugs.webkit.org/show_bug.cgi?id=116407
2484
2485         Reviewed by Alex Christensen.
2486
2487         Use WTF's copy of ICU headers.
2488
2489         * Configurations/BaseTarget.xcconfig:
2490
2491 2017-07-03  Brady Eidson  <beidson@apple.com>
2492
2493         Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
2494         https://bugs.webkit.org/show_bug.cgi?id=174073
2495
2496         Reviewed by Andy Estes.
2497
2498         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2499         (WebKit::WebFrameLoaderClient::getLoadDecisionForIcons):
2500         (WebKit::WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
2501         (WebKit::WebFrameLoaderClient::registerForIconNotification): Deleted.
2502         (WebKit::WebFrameLoaderClient::getLoadDecisionForIcon): Deleted.
2503         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
2504
2505 2017-07-03  Sam Weinig  <sam@webkit.org>
2506
2507         [WebIDL] Remove more unnecessary uses of the preprocessor in idl files
2508         https://bugs.webkit.org/show_bug.cgi?id=174083
2509
2510         Reviewed by Alex Christensen.
2511
2512         * Configurations/FeatureDefines.xcconfig:
2513         Add ENABLE_NAVIGATOR_STANDALONE.
2514
2515 2017-07-03  Matt Lewis  <jlewis3@apple.com>
2516
2517         Unreviewed, rolling out r219083.
2518
2519         The revision caused an API failure on all testing platforms.
2520
2521         Reverted changeset:
2522
2523         "[MediaStream] Protect request and web view during gUM client
2524         callback"
2525         https://bugs.webkit.org/show_bug.cgi?id=174096
2526         http://trac.webkit.org/changeset/219083
2527
2528 2017-07-03  Ryosuke Niwa  <rniwa@webkit.org>
2529
2530         WebContent processes crash when the network process crashes with pending connection requests
2531         https://bugs.webkit.org/show_bug.cgi?id=174065
2532         <rdar://problem/30359835>
2533
2534         Reviewed by Tim Horton.
2535
2536         The bug was caused by the UI process clearing away pending network connection requests whenever the existing
2537         network process crashed. This resulted in WebContent process killing itself inside ensureNetworkProcessConnection.
2538
2539         Fixed the bug by re-launching a new network process when this happens. We don't try to re-launch a new process
2540         if the previous attempt to launch a network process had failed.
2541
2542         This patch splits NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch into networkProcessFailedToLaunch
2543         and networkProcessCrashed to differentiate those two cases, and invoke the respective callbacks in WebProcessPool.
2544
2545         * UIProcess/API/Cocoa/WKProcessPool.mm:
2546         (-[WKProcessPool _networkProcessIdentifier]): Added.
2547         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
2548         * UIProcess/Network/NetworkProcessProxy.cpp:
2549         (WebKit::NetworkProcessProxy::networkProcessCrashed): Added.
2550         (WebKit::NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch): Split into the two following functions.
2551         (WebKit::NetworkProcessProxy::networkProcessFailedToLaunch): Extracted from networkProcessCrashedOrFailedToLaunch.
2552         (WebKit::NetworkProcessProxy::clearCallbackStates): Extracted from networkProcessCrashedOrFailedToLaunch
2553         (WebKit::NetworkProcessProxy::didClose): Call networkProcessCrashed.
2554         (WebKit::NetworkProcessProxy::didFinishLaunching): Call networkProcessFailedToLaunch.
2555         * UIProcess/Network/NetworkProcessProxy.h:
2556         * UIProcess/WebProcessPool.cpp:
2557         (WebKit::WebProcessPool::networkProcessCrashed): Start a new network process when there are pending connection
2558         requests the crached network failed to fullfil.
2559         (WebKit::WebProcessPool::networkProcessFailedToLaunch):
2560         * UIProcess/WebProcessPool.h:
2561
2562 2017-07-03  Eric Carlson  <eric.carlson@apple.com>
2563
2564         [MediaStream] Protect request and web view during gUM client callback
2565         https://bugs.webkit.org/show_bug.cgi?id=174096
2566         <rdar://problem/32833102>
2567
2568         Reviewed by Youenn Fablet.
2569
2570         Retain the message and WebView during asynchronous calls so they won't be 
2571         released if a navigation happens during a call to the UA for getUserMedia 
2572         or enumerateMediaDevices.
2573
2574         * UIProcess/Cocoa/UIDelegate.mm:
2575         (WebKit::requestUserMediaAuthorizationForDevices):
2576         (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):
2577         (WebKit::UIDelegate::UIClient::checkUserMediaPermissionForOrigin):
2578
2579 2017-07-03  Andy Estes  <aestes@apple.com>
2580
2581         [Xcode] Add an experimental setting to build with ccache
2582         https://bugs.webkit.org/show_bug.cgi?id=173875
2583
2584         Reviewed by Tim Horton.
2585
2586         * Configurations/DebugRelease.xcconfig: Included ccache.xcconfig.
2587
2588 2017-07-03  Chris Dumez  <cdumez@apple.com>
2589
2590         Drop ResourceLoadStatisticsStore's statisticsLock
2591         https://bugs.webkit.org/show_bug.cgi?id=174080
2592
2593         Reviewed by Brent Fulgham.
2594
2595         Drop ResourceLoadStatisticsStore's statisticsLock. It added complexity and was only needed
2596         do that the SPI exposed to WebKitTestRunner would query the store synchronously from the
2597         main thread. Instead, I made the SPI asynchronous and make sure we always access the store
2598         from the same background thread. As a result, there is no longer any need for locking.
2599
2600         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2601         (-[WKWebsiteDataStore _resourceLoadStatisticsIsPrevalentResource:completionHandler:]):
2602         (-[WKWebsiteDataStore _resourceLoadStatisticsHadUserInteraction:completionHandler:]):
2603         (-[WKWebsiteDataStore _resourceLoadStatisticsIsGrandfathered:completionHandler:]):
2604         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
2605         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
2606         (WebKit::ResourceLoadStatisticsStore::isPrevalentResource):
2607         (WebKit::ResourceLoadStatisticsStore::isGrandFathered):
2608         (WebKit::ResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
2609         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
2610         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
2611         (WebKit::ResourceLoadStatisticsStore::clearInMemory):
2612         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
2613         (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
2614         (WebKit::ResourceLoadStatisticsStore::processStatistics):
2615         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
2616         (WebKit::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
2617         (WebKit::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
2618         (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
2619         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
2620         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2621         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2622         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
2623         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
2624         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryData):
2625         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
2626         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
2627         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
2628         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
2629         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
2630         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
2631         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
2632         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
2633         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
2634         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
2635         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
2636         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
2637         * UIProcess/WebResourceLoadStatisticsStore.h:
2638
2639 2017-07-03  Wenson Hsieh  <wenson_hsieh@apple.com>
2640
2641         Pasting single words copied to UIPasteboard inserts URLs in editable areas
2642         https://bugs.webkit.org/show_bug.cgi?id=174082
2643         <rdar://problem/33046992>
2644
2645         Reviewed by Tim Horton.
2646
2647         Add a hook to WKPreferences to allow programatic pasting.
2648
2649         * UIProcess/API/Cocoa/WKPreferences.mm:
2650         (-[WKPreferences _setDOMPasteAllowed:]):
2651         (-[WKPreferences _domPasteAllowed]):
2652         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
2653
2654 2017-07-03  Zan Dobersek  <zdobersek@igalia.com>
2655
2656         Unreviewed GTK+ and WPE build fix when building with GCC 4.9.
2657
2658         * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
2659         (WebKit::CoordinatedLayerTreeHost::renderNextFrame): Don't use brace-list
2660         initialization to override the m_forceRepaintAsync struct. Instead, manually
2661         assign the OptionalCallbackID() value to the m_forceRepaintAsync.callbackID
2662         member variable, and override the m_forceRepaintAsync.needsFreshFlush member
2663         variable with `false`.
2664
2665 2017-07-03  Zan Dobersek  <zdobersek@igalia.com>
2666
2667         [ThreadedCompositor] Update and retrieve scene attributes under a Lock
2668         https://bugs.webkit.org/show_bug.cgi?id=173762
2669
2670         Reviewed by Carlos Garcia Campos.
2671
2672         Instead of dispatching separate tasks on the composition run loop, update
2673         various scene attributes by locking a common lock object and updating the
2674         appropriate attribute.
2675
2676         In ThreadedCompositor::renderLayerTree(), where these attributes are used
2677         in scene composition, the lock is again obtained and the attributes copied
2678         into local variables, releasing the lock afterwards. The attribute values
2679         in local copies are then used for that renderLayerTree() invocation.
2680
2681         This approach is more efficient than dispatching separate tasks that can
2682         race against renderLayerTree() dispatches.
2683
2684         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
2685         (WebKit::ThreadedCompositor::ThreadedCompositor):
2686         (WebKit::m_displayRefreshMonitor):
2687         (WebKit::ThreadedCompositor::setScaleFactor):
2688         (WebKit::ThreadedCompositor::setScrollPosition):
2689         (WebKit::ThreadedCompositor::setViewportSize):
2690         (WebKit::ThreadedCompositor::setDrawsBackground):
2691         (WebKit::ThreadedCompositor::renderLayerTree):
2692         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
2693
2694 2017-07-01  Dan Bernstein  <mitz@apple.com>
2695
2696         [iOS] Remove code only needed when building for iOS 9.x
2697         https://bugs.webkit.org/show_bug.cgi?id=174068
2698
2699         Reviewed by Tim Horton.
2700
2701         * Configurations/FeatureDefines.xcconfig:
2702         * Configurations/WebKit.xcconfig:
2703         * Platform/spi/ios/UIKitSPI.h:
2704         * UIProcess/API/Cocoa/WKWebView.mm:
2705         (-[WKWebView dealloc]):
2706         * UIProcess/ios/WKContentViewInteraction.mm:
2707         (-[WKFormInputSession setSuggestions:]):
2708         (-[WKFormInputSession invalidate]):
2709         (-[WKContentView insertTextSuggestion:]):
2710         (contentTypeFromFieldName):
2711         (-[WKContentView textInputTraits]):
2712         (-[WKContentView _dataForPreviewItemController:atPosition:type:]):
2713         * WebProcess/WebPage/ios/WebPageIOS.mm:
2714         (WebKit::WebPage::getPositionInformation):
2715         * config.h:
2716
2717 2017-07-01  Brady Eidson  <beidson@apple.com>
2718
2719         When setting a custom cookie storage location on a WKWebsiteDataStore, cookies aren't actually removed.
2720         <rdar://problem/32410662> and https://bugs.webkit.org/show_bug.cgi?id=174035
2721
2722         Reviewed by Alex Christensen.
2723
2724         * UIProcess/API/Cocoa/WKProcessPool.mm:
2725         (-[WKProcessPool _terminateNetworkProcess]):
2726         * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
2727         
2728         * UIProcess/WebProcessPool.cpp:
2729         (WebKit::WebProcessPool::ensureNetworkProcess): Take an optional WebsiteDataStore. If one is passed in,
2730           send it to either the existing or new network process.
2731         * UIProcess/WebProcessPool.h:
2732         
2733         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
2734         (WebKit::WebsiteDataStore::parameters): Resolve paths first.
2735
2736         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2737         (WebKit::WebsiteDataStore::fetchDataAndApply):
2738         (WebKit::WebsiteDataStore::removeData):
2739
2740 2017-07-01  Ryosuke Niwa  <rniwa@webkit.org>
2741
2742         Frame.h doesn't need to include FrameLoader.h, IntRect.h, and NavigationScheduler.h
2743         https://bugs.webkit.org/show_bug.cgi?id=174004
2744
2745         Reviewed by Simon Fraser.
2746
2747         * WebProcess/Plugins/WebPluginInfoProvider.cpp:
2748         * WebProcess/WebPage/WebInspector.cpp:
2749
2750 2017-07-01  Dan Bernstein  <mitz@apple.com>
2751
2752         [macOS] Remove code only needed when building for OS X Yosemite
2753         https://bugs.webkit.org/show_bug.cgi?id=174067
2754
2755         Reviewed by Tim Horton.
2756
2757         * Configurations/Base.xcconfig:
2758         * Configurations/BaseTarget.xcconfig:
2759         * Configurations/BaseXPCService.xcconfig:
2760         * Configurations/DebugRelease.xcconfig:
2761         * Configurations/FeatureDefines.xcconfig:
2762         * Configurations/NetworkService.xcconfig:
2763         * Configurations/PluginService.32.xcconfig:
2764         * Configurations/PluginService.64.xcconfig:
2765         * Configurations/Version.xcconfig:
2766         * Configurations/WebContentService.xcconfig:
2767         * Configurations/WebKit.xcconfig:
2768         * DatabaseProcess/mac/com.apple.WebKit.Databases.sb.in:
2769         * NetworkProcess/EntryPoint/mac/XPCService/NetworkService/Info-OSX-10.9-10.10.plist: Removed.
2770         * NetworkProcess/NetworkProcessCreationParameters.cpp:
2771         (WebKit::NetworkProcessCreationParameters::encode):
2772         (WebKit::NetworkProcessCreationParameters::decode):
2773         * NetworkProcess/NetworkProcessCreationParameters.h:
2774         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
2775         (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
2776         * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
2777         * Platform/IPC/Connection.h:
2778         * Platform/IPC/mac/ConnectionMac.mm:
2779         (IPC::Connection::platformInvalidate):
2780         (IPC::Connection::platformInitialize):
2781         (IPC::Connection::open):
2782         (IPC::Connection::exceptionSourceEventHandler): Deleted.
2783         (IPC::Connection::setShouldCloseConnectionOnMachExceptions): Deleted.
2784         * Platform/mac/LayerHostingContext.h:
2785         * Platform/mac/LayerHostingContext.mm:
2786         (WebKit::LayerHostingContext::createFencePort):
2787         * PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64-10.9-10.10.Info.plist: Removed.
2788         * PluginProcess/mac/PluginControllerProxyMac.mm:
2789         (WebKit::PluginControllerProxy::updateLayerHostingContext):
2790         * PluginProcess/mac/PluginProcessShim.mm:
2791         * PluginProcess/mac/com.apple.WebKit.plugin-common.sb.in:
2792         * Shared/ChildProcess.h:
2793         * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
2794         (WebKit::getPluginInfoFromPropertyLists):
2795         (WebKit::NetscapePluginModule::getPluginInfo):
2796         (WebKit::contentsOfPropertyListAtURL): Deleted.
2797         (WebKit::getMIMETypesFromPluginBundle): Deleted.
2798         * Shared/Plugins/PluginProcessCreationParameters.cpp:
2799         (WebKit::PluginProcessCreationParameters::encode):
2800         (WebKit::PluginProcessCreationParameters::decode):
2801         * Shared/Plugins/PluginProcessCreationParameters.h:
2802         * Shared/WebProcessCreationParameters.cpp:
2803         (WebKit::WebProcessCreationParameters::encode):
2804         (WebKit::WebProcessCreationParameters::decode):
2805         * Shared/WebProcessCreationParameters.h:
2806         * Shared/mac/ChildProcessMac.mm:
2807         (WebKit::ChildProcess::setSharedHTTPCookieStorage):
2808         * UIProcess/API/C/WKPage.cpp:
2809         (WKPageSetPageUIClient):
2810         (fixUpBotchedPageUIClient): Deleted.
2811         * UIProcess/ChildProcessProxy.cpp:
2812         (WebKit::ChildProcessProxy::didFinishLaunching):
2813         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
2814         (WebKit::WebProcessPool::platformInitializeWebProcess):
2815         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
2816         (WebKit::WebProcessPool::resetHSTSHostsAddedAfterDate):
2817         * UIProcess/Cocoa/WebViewImpl.h:
2818         * UIProcess/Cocoa/WebViewImpl.mm:
2819         (WebKit::WebViewImpl::updateLayer):
2820         (WebKit::WebViewImpl::startWindowDrag):
2821         * UIProcess/DrawingAreaProxy.h:
2822         (WebKit::DrawingAreaProxy::waitForPossibleGeometryUpdate): Deleted.
2823         * UIProcess/Plugins/PluginProcessProxy.cpp:
2824         (WebKit::PluginProcessProxy::didFinishLaunching):
2825         * UIProcess/Plugins/PluginProcessProxy.h:
2826         * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
2827         (WebKit::PluginProcessProxy::platformInitializePluginProcess):
2828         (WebKit::PluginProcessProxy::createPropertyListFile): Deleted.
2829         * UIProcess/WebPageProxy.cpp:
2830         (WebKit::WebPageProxy::setTopContentInset):
2831         * UIProcess/mac/PageClientImpl.mm:
2832         (WebKit::PageClientImpl::rootViewToWindow):
2833         (WebKit::PageClientImpl::startWindowDrag):
2834         * UIProcess/mac/RemoteWebInspectorProxyMac.mm:
2835         (WebKit::RemoteWebInspectorProxy::platformStartWindowDrag):
2836         * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
2837         * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
2838         (WebKit::TiledCoreAnimationDrawingAreaProxy::createFence):
2839         (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate): Deleted.
2840         * UIProcess/mac/WebInspectorProxyMac.mm:
2841         (WebKit::WebInspectorProxy::createFrontendWindow):
2842         (WebKit::WebInspectorProxy::platformStartWindowDrag):
2843         * UIProcess/mac/WebPopupMenuProxyMac.mm:
2844         (WebKit::WebPopupMenuProxyMac::showPopupMenu):
2845         * WebKit2.xcodeproj/project.pbxproj:
2846         * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX-10.9-10.10.plist: Removed.
2847         * WebProcess/WebPage/WebPage.cpp:
2848         * WebProcess/WebPage/WebPage.h:
2849         * WebProcess/WebPage/WebPage.messages.in:
2850         * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
2851         (WebKit::addAnimationToLayer):
2852         * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
2853         (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
2854         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
2855         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
2856         (WebKit::TiledCoreAnimationDrawingArea::updateGeometry):
2857         * WebProcess/cocoa/WebProcessCocoa.mm:
2858         (WebKit::WebProcess::platformInitializeWebProcess):
2859         * WebProcess/com.apple.WebProcess.sb.in:
2860
2861 2017-07-01  Chris Dumez  <cdumez@apple.com>
2862
2863         Replace ResourceLoadStatisticsStore C API with Cocoa SPI
2864         https://bugs.webkit.org/show_bug.cgi?id=174060
2865
2866         Reviewed by Brent Fulgham.
2867
2868         Replace ResourceLoadStatisticsStore C API by Cocoa SPI. The new Cocoa SPI is on
2869         WKWebsiteDataStore, which allows us to get rid of the WebResourceLoadStatisticsManager
2870         singleton as the SPI can now interact directly with the WebResourceLoadStatisticsStore.
2871
2872         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp: Removed.
2873         * UIProcess/API/C/WKResourceLoadStatisticsManager.h: Removed.
2874         Drop old C API.
2875
2876         * UIProcess/WebResourceLoadStatisticsManager.cpp: Removed.
2877         * UIProcess/WebResourceLoadStatisticsManager.h: Removed.
2878         Drop WebResourceLoadStatisticsManager singleton which was only required by the
2879         C API. This is because the C API was global, rather than working on a specific
2880         store.
2881
2882         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2883         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
2884         Add new Cocoa SPI on WKWebsiteDataStore. This is only used for testing.
2885
2886         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2887         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
2888         Stop registering the store with the WebResourceLoadStatisticsManager singleton,
2889         as this singleton is gone.
2890
2891         * UIProcess/WebsiteData/WebsiteDataStore.h:
2892         (WebKit::WebsiteDataStore::resourceLoadStatistics):
2893         Add new getter to retrieve the WebResourceLoadStatisticsStore from the
2894         WebsiteDataStore. This is needed by the new Cocoa SPI.
2895
2896         * WebKit2.xcodeproj/project.pbxproj:
2897         Drop some files.
2898
2899 2017-06-30  Megan Gardner  <megan_gardner@apple.com>
2900
2901         Unreviewed mac build fix.
2902
2903         * UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
2904         * UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
2905
2906 2017-06-30  Megan Gardner  <megan_gardner@apple.com>
2907
2908         Add API to get WKActivatedElementInfo
2909         https://bugs.webkit.org/show_bug.cgi?id=174001
2910         <rdar://problem/29165518>
2911         
2912         Adding a way to get a WKActivatedElementInfo for a point on a WKWebView.
2913
2914         Reviewed by Tim Horton.
2915
2916         * UIProcess/API/Cocoa/WKWebView.mm:
2917         (-[WKWebView requestActivatedElementAtPosition:completionBlock:]):
2918         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2919         * UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
2920         (+[_WKActivatedElementInfo infoWithType:withInteractionInformationAtPosition:]):
2921         (-[_WKActivatedElementInfo infoWithType:withInteractionInformationAtPosition:]):
2922         * UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
2923
2924 2017-06-30  Tim Horton  <timothy_horton@apple.com>
2925
2926         Use API instead of SPI for content inset adjustment behavior
2927         https://bugs.webkit.org/show_bug.cgi?id=174050
2928
2929         Reviewed by Sam Weinig.
2930
2931         * Platform/spi/ios/UIKitSPI.h:
2932         * UIProcess/ios/WKScrollView.mm:
2933         (-[WKScrollView initWithFrame:]):
2934         (-[WKScrollView setContentInsetAdjustmentBehavior:]):
2935         (-[WKScrollView _setContentInsetAdjustmentBehaviorInternal:]):
2936         (-[WKScrollView _setContentInsetAdjustmentBehavior:]): Deleted.
2937         Switch over to the API. The old SPI calls the API internally, so our
2938         override will now cover all callers.
2939
2940 2017-06-30  Chris Dumez  <cdumez@apple.com>
2941
2942         Move store logic from WebResourceLoadStatisticsManager to WebResourceLoadStatisticsStore
2943         https://bugs.webkit.org/show_bug.cgi?id=174038
2944
2945         Reviewed by Brent Fulgham.
2946
2947         Move store logic from WebResourceLoadStatisticsManager to WebResourceLoadStatisticsStore.
2948         WebResourceLoadStatisticsManager is now essentially a proxy to the
2949         WebResourceLoadStatisticsStore to support the current C API.
2950
2951         In a follow-up, I plan to to replace the C API with a Cocoa SPI which works on a
2952         WebResourceLoadStatisticsStore directly instead of requiring a
2953         WebResourceLoadStatisticsManager singleton.
2954
2955         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
2956         (WKResourceLoadStatisticsManagerSetMinimumTimeBetweenDataRecordsRemoval):
2957         (WKResourceLoadStatisticsManagerResetToConsistentState):
2958         * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
2959         * UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm: Removed.
2960         * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
2961         (WebKit::WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):
2962         * UIProcess/WebResourceLoadStatisticsManager.cpp:
2963         (WebKit::WebResourceLoadStatisticsManager::WebResourceLoadStatisticsManager):
2964         (WebKit::WebResourceLoadStatisticsManager::~WebResourceLoadStatisticsManager):
2965         (WebKit::WebResourceLoadStatisticsManager::setStatisticsStore):
2966         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryStore):
2967         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
2968         (WebKit::WebResourceLoadStatisticsManager::logUserInteraction):
2969         (WebKit::WebResourceLoadStatisticsManager::clearUserInteraction):
2970         (WebKit::WebResourceLoadStatisticsManager::hasHadUserInteraction):
2971         (WebKit::WebResourceLoadStatisticsManager::setPrevalentResource):
2972         (WebKit::WebResourceLoadStatisticsManager::isPrevalentResource):
2973         (WebKit::WebResourceLoadStatisticsManager::clearPrevalentResource):
2974         (WebKit::WebResourceLoadStatisticsManager::setGrandfathered):
2975         (WebKit::WebResourceLoadStatisticsManager::isGrandfathered):
2976         (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
2977         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
2978         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
2979         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
2980         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
2981         (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweenDataRecordsRemoval):
2982         (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
2983         (WebKit::WebResourceLoadStatisticsManager::fireDataModificationHandler):
2984         (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
2985         (WebKit::WebResourceLoadStatisticsManager::fireTelemetryHandler):
2986         * UIProcess/WebResourceLoadStatisticsManager.h:
2987         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2988         (WebKit::primaryDomain):
2989         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
2990         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
2991         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
2992         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
2993         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
2994         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
2995         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
2996         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
2997         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
2998         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
2999         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
3000         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
3001         (WebKit::WebResourceLoadStatisticsStore::fireDataModificationHandler):
3002         (WebKit::WebResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
3003         (WebKit::WebResourceLoadStatisticsStore::fireTelemetryHandler):
3004         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
3005         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
3006         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
3007         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
3008         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
3009         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
3010         * UIProcess/WebResourceLoadStatisticsStore.h:
3011         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3012         (WebKit::WebsiteDataStore::removeData):
3013         * WebKit2.xcodeproj/project.pbxproj:
3014
3015 2017-06-30  John Wilander  <wilander@apple.com>
3016
3017         [WK2] Resource load statistics code is spamming the WebProcess with a test-only message 
3018         https://bugs.webkit.org/show_bug.cgi?id=174048
3019         <rdar://problem/33062376>
3020
3021         Reviewed by Brent Fulgham.
3022
3023         Fix the telemetry data message send so that it is not generated during normal operations.
3024         This is only meant to be used by WebKitTestRunner.
3025
3026         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
3027         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit): 
3028
3029 2017-06-30  Daniel Bates  <dabates@apple.com>
3030
3031         Attempt to fix the WPE build following <https://trac.webkit.org/changeset/219013>
3032         (https://bugs.webkit.org/show_bug.cgi?id=165160)
3033
3034         Update the prototype of UIClient::createNewPage() to take a API::FrameInfo& instead of
3035         a WebFrameProxy* and a const WebCore::SecurityOriginData&.
3036
3037         * UIProcess/API/glib/WebKitUIClient.cpp:
3038
3039 2017-06-30  Alex Christensen  <achristensen@webkit.org>
3040
3041         Stop soft linking with CFNetwork
3042         https://bugs.webkit.org/show_bug.cgi?id=174029
3043
3044         Reviewed by Jer Noble.
3045
3046         * Shared/mac/CookieStorageShim.mm:
3047
3048 2017-06-30  Daniel Bates  <dabates@apple.com>
3049
3050         API::FrameInfo should know the web page that contains the frame; add API property webView to WKFrameInfo
3051         https://bugs.webkit.org/show_bug.cgi?id=165160
3052         <rdar://problem/29451999>
3053
3054         Reviewed by Brady Eidson.
3055
3056         Expose a property on WKFrameInfo to retrieve the WKWebView of the web page that contains the
3057         frame. This will allow an embedding client to know the web view that initiated the navigation
3058         request as well as differentiate between a navigation initiated by web content from one
3059         initiated via API.
3060
3061         The majority of this change is passing the document D that initiated the targeted navigation
3062         or called window.open() through the loading machinery to the FrameLoaderClient. The changes
3063         to pass this information to the FrameLoaderClient when creating a new window are straightforward.
3064         For targeted navigation, the WebKit2 FrameLoaderClient implementation now computes the info
3065         for the originating frame regardless of the navigation type (NavigationAction::type()).
3066         (Currently we only compute the originating frame for hyperlink activated navigations,
3067         form submissions, and form resubmissions). The WebProcess computes the page ID of the page
3068         that contains the originating frame and sends that to the UIProcess so that it can create
3069         an API::FrameInfo for the originating frame and associate the page that contains the frame,
3070         if the navigation was triggered by web content. If the navigation was triggered by API
3071         (e.g. -[WKWebView goBack]) then the created API::FrameInfo does not have an associated page
3072         so that an embedding client can distinguish between a navigation initiated by web content
3073         from a navigation that it initiated via API depending on whether API::FrameInfo::page() is
3074         nullptr. We expose property webView on the Mac and iOS API class WKFrameInfo to return the
3075         WKWebView corresponding to API::FrameInfo::page().
3076
3077         A small change that this patch makes is to have the WebProcess compute the originating frame
3078         info (call WebFrame::info()) and send it over to the UIProcess as opposed to sending the frame
3079         ID of the originating frame and having the UIProcess compute the frame info from it. We do this
3080         because the UIProcess may not be able to compute the frame info for the originating frame if
3081         the window that it was contained in was closed between the time the WebProcess sent the frame
3082         ID to the UIProcess and the UIProcess received it.
3083
3084         * UIProcess/API/APIFrameInfo.cpp:
3085         (API::FrameInfo::create):
3086         (API::FrameInfo::FrameInfo):
3087         (API::FrameInfo::clearPage):
3088         * UIProcess/API/APIFrameInfo.h:
3089         * UIProcess/API/APIUIClient.h:
3090         (API::UIClient::createNewPage):
3091         (API::UIClient::createNewPageAsync):
3092         * UIProcess/API/C/WKPage.cpp:
3093         (WKPageSetPageUIClient):
3094         * UIProcess/API/Cocoa/WKFrameInfo.h:
3095         * UIProcess/API/Cocoa/WKFrameInfo.mm:
3096         (-[WKFrameInfo description]):
3097         (-[WKFrameInfo webView]):
3098         * UIProcess/API/Cocoa/WKUserContentController.mm:
3099         * UIProcess/Cocoa/UIDelegate.h:
3100         * UIProcess/Cocoa/UIDelegate.mm:
3101         (WebKit::UIDelegate::UIClient::createNewPageCommon):
3102         (WebKit::UIDelegate::UIClient::createNewPage):
3103         (WebKit::UIDelegate::UIClient::createNewPageAsync):
3104         * UIProcess/WebPageProxy.cpp:
3105         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
3106         (WebKit::WebPageProxy::createNewPage):
3107         * UIProcess/WebPageProxy.h:
3108         * UIProcess/WebPageProxy.messages.in:
3109         * WebProcess/Plugins/PluginView.cpp:
3110         (WebKit::PluginView::loadURL):
3111         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
3112         (WebKit::WebChromeClient::createWindow):
3113         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
3114         (WebKit::WebFrameLoaderClient::dispatchCreatePage):
3115         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
3116         * WebProcess/WebPage/WebInspector.cpp:
3117         (WebKit::WebInspector::openInNewTab):
3118
3119 2017-06-29  Jer Noble  <jer.noble@apple.com>
3120
3121         Make Legacy EME API controlled by RuntimeEnabled setting.
3122         https://bugs.webkit.org/show_bug.cgi?id=173994
3123
3124         Reviewed by Sam Weinig.
3125
3126         Add a new WKWebViewConfiguration property, as well as a new WKPreferences function, both able to control
3127         WebCore's new RuntimeEnabledFeature setting for the Legacy EME API.
3128
3129         * Configurations/FeatureDefines.xcconfig:
3130         * Shared/WebPreferencesDefinitions.h:
3131         * UIProcess/API/C/WKPreferences.cpp:
3132         (WKPreferencesGetLegacyEncryptedMediaAPIEnabled):
3133         (WKPreferencesSetLegacyEncryptedMediaAPIEnabled):
3134         * UIProcess/API/C/WKPreferencesRef.h:
3135         * UIProcess/API/Cocoa/WKWebView.mm:
3136         (-[WKWebView _initializeWithConfiguration:]):
3137         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
3138         (-[WKWebViewConfiguration init]):
3139         (-[WKWebViewConfiguration copyWithZone:]):
3140         (-[WKWebViewConfiguration _setLegacyEncryptedMediaAPIEnabled:]):
3141         (-[WKWebViewConfiguration _legacyEncryptedMediaAPIEnabled]):
3142         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
3143         * WebProcess/WebPage/WebPage.cpp:
3144         (WebKit::WebPage::updatePreferences):
3145
3146 2017-06-30  Jer Noble  <jer.noble@apple.com>
3147
3148         REGRESSION (r218757): Touch Bar's media scrubber timeline runs from 00:00 to 00:00 and has no playhead
3149         https://bugs.webkit.org/show_bug.cgi?id=174032
3150
3151         Reviewed by Eric Carlson.
3152
3153         Fix a copypasta error where durationChange notifications were changing the value of muted.
3154
3155         * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:
3156         (WebKit::WebPlaybackSessionManagerProxy::durationChanged):
3157
3158 2017-06-30  Chris Dumez  <cdumez@apple.com>
3159
3160         Move ResourceLoadStatisticsStore to WebKit2/UIProcess
3161         https://bugs.webkit.org/show_bug.cgi?id=174033
3162
3163         Reviewed by Brent Fulgham.
3164
3165         Move ResourceLoadStatisticsStore to WebKit2/UIProcess since it is only
3166         used in the WebKit2 UIProcess.
3167
3168         * CMakeLists.txt:
3169         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.cpp.
3170         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
3171         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
3172         (WebKit::ResourceLoadStatisticsStore::clearInMemory):
3173         (WebKit::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
3174         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
3175         (WebKit::ResourceLoadStatisticsStore::fireDataModificationHandler):
3176         (WebKit::ResourceLoadStatisticsStore::fireTelemetryHandler):
3177         (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
3178         (WebKit::ResourceLoadStatisticsStore::processStatistics):
3179         (WebKit::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
3180         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
3181         (WebKit::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
3182         (WebKit::ResourceLoadStatisticsStore::dataRecordsWereRemoved):
3183         (WebKit::ResourceLoadStatisticsStore::statisticsLock):
3184         * UIProcess/Storage/ResourceLoadStatisticsStore.h: Renamed from Source/WebCore/loader/ResourceLoadStatisticsStore.h.
3185         * UIProcess/WebResourceLoadStatisticsManager.cpp:
3186         (WebKit::primaryDomain):
3187         * UIProcess/WebResourceLoadStatisticsManager.h:
3188         * UIProcess/WebResourceLoadStatisticsStore.h:
3189         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
3190         * UIProcess/WebResourceLoadStatisticsTelemetry.h:
3191         * WebKit2.xcodeproj/project.pbxproj:
3192
3193 2017-06-30  Ryosuke Niwa  <rniwa@webkit.org>
3194
3195         Ran sort-Xcode-project-file.
3196
3197         * WebKit2.xcodeproj/project.pbxproj:
3198
3199 2017-06-30  Chris Dumez  <cdumez@apple.com>
3200
3201         ResourceLoadObserver does not need a ResourceLoadStatisticsStore
3202         https://bugs.webkit.org/show_bug.cgi?id=174013
3203
3204         Reviewed by Brent Fulgham.
3205
3206         ResourceLoadObserver does not need a ResourceLoadStatisticsStore. ResourceLoadStatisticsStore is too complicated for its needs.
3207         ResourceLoadStatisticsStore can then be moved to WebKit2/UIProcess in a follow-up.
3208
3209         * WebProcess/WebProcess.cpp:
3210         (WebKit::m_webSQLiteDatabaseTracker):
3211         (WebKit::WebProcess::statisticsChangedTimerFired):
3212         * WebProcess/WebProcess.h:
3213
3214 2017-06-30  Brent Fulgham  <bfulgham@apple.com>
3215
3216         [WK2][iOS][macOS] Update XPC services process launch dictionary
3217         https://bugs.webkit.org/show_bug.cgi?id=173995
3218         <rdar://problem/32797264>
3219
3220         Reviewed by Alex Christensen.
3221
3222         Update the WebProcess and Plugin Process XPC launch dictionaries to activate
3223         improved ALSR features when launching.
3224
3225         * PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist:
3226         * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist:
3227         * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-iOS.plist:
3228
3229 2017-06-30  Chris Dumez  <cdumez@apple.com>
3230
3231         Merge WebResourceLoadStatisticsManager and WebResourceLoadObserver
3232         https://bugs.webkit.org/show_bug.cgi?id=174008
3233
3234         Reviewed by Brent Fulgham.
3235
3236         Merge WebResourceLoadStatisticsManager and WebResourceLoadObserver. One was basically
3237         a proxy to the other.
3238
3239         * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
3240         (WKResourceLoadStatisticsManagerSetPrevalentResource):
3241         (WKResourceLoadStatisticsManagerIsPrevalentResource):
3242         (WKResourceLoadStatisticsManagerSetHasHadUserInteraction):
3243         (WKResourceLoadStatisticsManagerIsHasHadUserInteraction):
3244         (WKResourceLoadStatisticsManagerSetGrandfathered):
3245         (WKResourceLoadStatisticsManagerIsGrandfathered):
3246         (WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
3247         (WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
3248         (WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
3249         (WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction):
3250         (WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
3251         (WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval):
3252         (WKResourceLoadStatisticsManagerSetGrandfatheringTime):
3253         (WKResourceLoadStatisticsManagerFireDataModificationHandler):
3254         (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler):
3255         (WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandlerForOneDomain):
3256         (WKResourceLoadStatisticsManagerFireTelemetryHandler):
3257         (WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned):
3258         (WKResourceLoadStatisticsManagerSetShouldClassifyResourcesBeforeDataRecordsRemoval):
3259         (WKResourceLoadStatisticsManagerSetNotifyPagesWhenTelemetryWasCaptured):
3260         (WKResourceLoadStatisticsManagerSetShouldSubmitTelemetry):
3261         (WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore):
3262         (WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStoreModifiedSinceHours):
3263         (WKResourceLoadStatisticsManagerResetToConsistentState):
3264         * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
3265         * UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm:
3266         (WebKit::WebResourceLoadStatisticsManager::registerUserDefaultsIfNeeded):
3267         * UIProcess/WebResourceLoadObserver.cpp: Removed.
3268         * UIProcess/WebResourceLoadObserver.h: Removed.
3269         * UIProcess/WebResourceLoadStatisticsManager.cpp:
3270         (WebKit::primaryDomain):
3271         (WebKit::WebResourceLoadStatisticsManager::shared):
3272         (WebKit::WebResourceLoadStatisticsManager::setStatisticsStore):
3273         (WebKit::WebResourceLoadStatisticsManager::setStatisticsQueue):
3274         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryStore):
3275         (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
3276         (WebKit::WebResourceLoadStatisticsManager::logUserInteraction):
3277         (WebKit::WebResourceLoadStatisticsManager::clearUserInteraction):
3278         (WebKit::WebResourceLoadStatisticsManager::hasHadUserInteraction):
3279         (WebKit::WebResourceLoadStatisticsManager::setPrevalentResource):
3280         (WebKit::WebResourceLoadStatisticsManager::isPrevalentResource):
3281         (WebKit::WebResourceLoadStatisticsManager::clearPrevalentResource):
3282         (WebKit::WebResourceLoadStatisticsManager::setGrandfathered):
3283         (WebKit::WebResourceLoadStatisticsManager::isGrandfathered):
3284         (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
3285         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
3286         (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
3287         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
3288         (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
3289         (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
3290         (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
3291         (WebKit::WebResourceLoadStatisticsManager::fireDataModificationHandler):
3292         (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
3293         (WebKit::WebResourceLoadStatisticsManager::fireTelemetryHandler):
3294         * UIProcess/WebResourceLoadStatisticsManager.h:
3295         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3296         (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
3297         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3298         (WebKit::WebsiteDataStore::removeData):
3299         * WebKit2.xcodeproj/project.pbxproj:
3300
3301 2017-06-30  Wenson Hsieh  <wenson_hsieh@apple.com>
3302
3303         [iOS DnD] Drag caret rect is incorrectly computed when dropping in editable content in iframes
3304         https://bugs.webkit.org/show_bug.cgi?id=174017
3305         <rdar://problem/32959782>
3306
3307         Reviewed by Simon Fraser.
3308
3309         Send the drag caret rect in root view coordinates over to the UI process.
3310
3311         * UIProcess/API/Cocoa/WKWebView.mm:
3312         (-[WKWebView _dragCaretRect]):
3313         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
3314
3315         Add basic test plumbing to fetch the current drag caret rect.
3316
3317         * WebProcess/WebPage/WebPage.cpp:
3318         (WebKit::WebPage::performDragControllerAction):
3319
3320 2017-06-30  Youenn Fablet  <youenn@apple.com>
3321
3322         Support PeerConnectionStates::BundlePolicy::MaxBundle when setting rtc configuration
3323         https://bugs.webkit.org/show_bug.cgi?id=169389
3324
3325         Reviewed by Alex Christensen.
3326
3327         * fast/mediastream/RTCPeerConnection-getConfiguration-expected.txt:
3328
3329 2017-06-29  Ryosuke Niwa  <rniwa@webkit.org>
3330
3331         Assert that callback ID is not 0 or -1 during encoding and decoding
3332         https://bugs.webkit.org/show_bug.cgi?id=173803
3333
3334         Reviewed by Brady Eidson.
3335
3336         To diagnosing the hang inside Safari (<rdar://problem/32841256>), add assertions for the callback ID
3337         to be not 0 or -1 during encoding and decoding of IPC messages since the latest analysis seems to
3338         indicate the hang is caused by the hash map getting corrupted by the insertion of 0 (empty value).
3339
3340         Wrapped the uint64_t in CallbackID and OptionalCallbackID to add assertions.
3341
3342         * NetworkProcess/soup/NetworkProcessSoup.cpp:
3343         (WebKit::NetworkProcess::platformInitializeNetworkProcess):
3344         * Shared/CallbackID.h: Added.
3345         (WebKit::CallbackID::CallbackID):
3346         (WebKit::CallbackID::operator==):
3347         (WebKit::CallbackID::toInteger):
3348         (WebKit::CallbackID::isValid):
3349         (WebKit::CallbackID::isValidCallbackID): A callback ID is valid when it's neither 0 nor -1.
3350         (WebKit::CallbackID::fromInteger): Create a CallbackID object from potentially unsafe value.
3351         (WebKit::CallbackID::generateID): Generates the next callback ID. Moved from CallbackBase.
3352         (WebKit::CallbackID::encode): Added. Assert that it's neither 0 nor -1.
3353         (WebKit::CallbackID::decode): Ditto.
3354         (WTF::CallbackIDHash::hash):
3355         (WTF::CallbackIDHash::equal):
3356         (WTF::HashTraits<WebKit::CallbackID>::emptyValue):
3357         (WTF::HashTraits<WebKit::CallbackID>::constructDeletedValue):
3358         (WTF::HashTraits<WebKit::CallbackID>::isDeletedValue):
3359         * Shared/OptionalCallbackID.h: Added. Unlike CallbackID, callback ID here can be 0.
3360         (WebKit::OptionalCallbackID::OptionalCallbackID):
3361         (WebKit::OptionalCallbackID::toInteger):
3362         (WebKit::OptionalCallbackID::callbackID): Returns a valid CallbackID object. The caller of
3363         this function must have verified that the ID is neither 0 or -1 before calling this function.
3364         (WebKit::OptionalCallbackID::operator bool):
3365         (WebKit::OptionalCallbackID::isValid):
3366         (WebKit::OptionalCallbackID::isValidCallbackID):
3367         (WebKit::OptionalCallbackID::encode): Since OptionalCallbackID can be 0, only assert that it's not -1.
3368         (WebKit::OptionalCallbackID::decode): Ditto.
3369         * Shared/mac/RemoteLayerTreeTransaction.h:
3370         * Shared/mac/RemoteLayerTreeTransaction.h:
3371         * UIProcess/GenericCallback.h:
3372         (WebKit::CallbackBase::callbackID): Returns a CallbackID object instead of uint64_t.
3373         (WebKit::CallbackBase::CallbackBase):
3374         (WebKit::CallbackBase::generateCallbackID): Deleted.
3375         (WebKit::CallbackMap::put): Returns a callback ID. Also added a version that doesn't take activity token
3376         as used in WebCookieManagerProxy
3377         (WebKit::CallbackMap::take): Takes a callback ID.
3378         * UIProcess/WebCookieManagerProxy.cpp: Updated the code as callback maps are merged.
3379         (WebKit::WebCookieManagerProxy::processPoolDestroyed):
3380         (WebKit::WebCookieManagerProxy::processDidClose):
3381         (WebKit::WebCookieManagerProxy::getHostnamesWithCookies):
3382         (WebKit::WebCookieManagerProxy::didGetHostnamesWithCookies):
3383         (WebKit::WebCookieManagerProxy::deleteCookie):
3384         (WebKit::WebCookieManagerProxy::deleteAllCookiesModifiedSince):
3385         (WebKit::WebCookieManagerProxy::setCookie):
3386         (WebKit::WebCookieManagerProxy::setCookies):
3387         (WebKit::WebCookieManagerProxy::getAllCookies):
3388         (WebKit::WebCookieManagerProxy::getCookies):
3389         (WebKit::WebCookieManagerProxy::didSetCookies):
3390         (WebKit::WebCookieManagerProxy::didGetCookies):
3391         (WebKit::WebCookieManagerProxy::didDeleteCookies):
3392         (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
3393         (WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy):
3394         (WebKit::WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy):
3395         (WebKit::WebCookieManagerProxy::didSetHTTPCookieAcceptPolicy):
3396         * UIProcess/WebCookieManagerProxy.h:
3397         * UIProcess/WebCookieManagerProxy.messages.in:
3398         * UIProcess/WebPageProxy.cpp:
3399         (WebKit::WebPageProxy::setInitialFocus):
3400         (WebKit::WebPageProxy::validateCommand):
3401         (WebKit::WebPageProxy::runJavaScriptInMainFrame):
3402         (WebKit::WebPageProxy::getRenderTreeExternalRepresentation):
3403         (WebKit::WebPageProxy::getSourceForFrame):
3404         (WebKit::WebPageProxy::getContentsAsString):
3405         (WebKit::WebPageProxy::getBytecodeProfile):
3406         (WebKit::WebPageProxy::getSamplingProfilerOutput):
3407         (WebKit::WebPageProxy::getContentsAsMHTMLData):
3408         (WebKit::WebPageProxy::getSelectionOrContentsAsString):
3409         (WebKit::WebPageProxy::getSelectionAsWebArchiveData):
3410         (WebKit::WebPageProxy::getMainResourceDataOfFrame):
3411         (WebKit::WebPageProxy::getResourceDataFromFrame):
3412         (WebKit::WebPageProxy::getWebArchiveOfFrame):
3413         (WebKit::WebPageProxy::forceRepaint):
3414         (WebKit::WebPageProxy::clearLoadDependentCallbacks):
3415    &nb