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