Use SandboxExtension::HandleArray when sending extensions for file uploads to the...
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2017-07-26  Brian Burg  <bburg@apple.com>
2
3         Use SandboxExtension::HandleArray when sending extensions for file uploads to the web process
4         https://bugs.webkit.org/show_bug.cgi?id=174828
5
6         Reviewed by Tim Horton.
7
8         In the previous change I forgot to hoist the HandleArray and message-send out of the
9         loop, so the code wasn't actually sending fewer messages. That's fixed now.
10
11         * UIProcess/WebPageProxy.cpp:
12         (WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
13         (WebKit::WebPageProxy::didChooseFilesForOpenPanel):
14
15 2017-07-26  Zan Dobersek  <zdobersek@igalia.com>
16
17         Unreviewed. Fix a compiler warning that springs up when
18         building the WPE port with Clang.
19
20         * UIProcess/API/wpe/ScrollGestureController.h:
21         Let ScrollGestureController be a class, and not a struct.
22         This fits the usual pattern, and also matches the forward
23         declaration used in WPE's PageClientImpl.h.
24
25 2017-07-26  Carlos Garcia Campos  <cgarcia@igalia.com>
26
27         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.17.5 release.
28
29         * gtk/NEWS: Add release notes for 2.17.5.
30
31 2017-07-25  Carlos Garcia Campos  <cgarcia@igalia.com>
32
33         Icon loader error on startup
34         https://bugs.webkit.org/show_bug.cgi?id=174787
35
36         Reviewed by Brady Eidson.
37
38         Ignore non HTTP favicons in glib API.
39
40         * UIProcess/API/glib/WebKitIconLoadingClient.cpp:
41
42 2017-07-25  Brady Eidson  <beidson@apple.com>
43
44         ResourceLoadStatistics grandfathering happens much too often.
45         <rdar://problem/32655834> and https://bugs.webkit.org/show_bug.cgi?id=174825
46
47         Reviewed by Chris Dumez.
48
49         The ResourceLoadStatistics grandfathering procedure happens too often.
50         - With an empty memory store, even though an empty memory store is a perfectly valid state.
51         - On each launch, even if grandfathering happened on the last launch - because grandfathering
52           data would not automatically be saved to disk.
53         - After clearing all website data, at which point no grandfathering can possibly be relevant
54           because there is no data to grandfather.
55
56         This patch fixes those cases and adds API tests to verify they remain fixed.
57
58         * Shared/WebsiteData/WebsiteDataType.h:
59
60         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
61         (+[WKWebsiteDataStore _allWebsiteDataTypesIncludingPrivate]): allWebsiteDataTypes, but even with the private ones.
62         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore]): If the types being cleared cover all of 
63           the types that ResourceLoadStatistics care about, don't grandfather afterwards.
64         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:]): Ditto.
65         (-[WKWebsiteDataStore _setResourceLoadStatisticsTestingCallback:]):
66         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
67
68         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp:
69         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk): Don't grandfather if the store read from 
70           disk is empty (as being empty is perfectly fine), and also log the event of "populated without grandfathering".
71         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h:
72
73         * UIProcess/WebProcessProxy.cpp:
74         (WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData):
75
76         * UIProcess/WebResourceLoadStatisticsStore.cpp:
77         (WebKit::WebResourceLoadStatisticsStore::monitoredDataTypes):
78         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
79         (WebKit::WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore):
80         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords): 
81         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData): Schedule a write right away so we don't re-grandfather
82           on next launch, and also log the grandfathering event.
83         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent): Takes a ShouldGrandfather flag
84           to tell whether or not data should be re-grandfathered after the store is cleared.
85         (WebKit::WebResourceLoadStatisticsStore::logTestingEvent): Log the event to the testing client.
86         (WebKit::dataTypesToRemove): Deleted.
87         * UIProcess/WebResourceLoadStatisticsStore.h:
88
89         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
90         (WebKit::WebsiteDataStore::removeData):
91         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
92         (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback): Handles enabling ResourceLoadStatistics both
93           with and without a testing callback.
94         * UIProcess/WebsiteData/WebsiteDataStore.h:
95
96 2017-07-25  Andy Estes  <aestes@apple.com>
97
98         [Apple Pay] Add "carteBancaire" as a supported payment network
99         https://bugs.webkit.org/show_bug.cgi?id=174841
100         <rdar://problem/31935596>
101
102         Reviewed by Alex Christensen.
103
104         * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
105         (WebKit::toSupportedNetwork):
106
107 2017-07-25  Brian Burg  <bburg@apple.com>
108
109         Use SandboxExtension::HandleArray when sending extensions for file uploads to the web process
110         https://bugs.webkit.org/show_bug.cgi?id=174828
111
112         Reviewed by Tim Horton.
113
114         Send all of the sandbox extension handles in a single message, rather than
115         one message per extension. Update message name and parameter types to match.
116
117         * UIProcess/WebPageProxy.cpp:
118         (WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
119         (WebKit::WebPageProxy::didChooseFilesForOpenPanel):
120         * WebProcess/WebPage/WebPage.cpp:
121         (WebKit::WebPage::extendSandboxForFilesFromOpenPanel):
122         (WebKit::WebPage::extendSandboxForFileFromOpenPanel): Deleted.
123         * WebProcess/WebPage/WebPage.h:
124         * WebProcess/WebPage/WebPage.messages.in:
125
126 2017-07-25  Alex Christensen  <achristensen@webkit.org>
127
128         Fix API tests after r219871.
129         https://bugs.webkit.org/show_bug.cgi?id=174807
130
131         WebKit2.OpenAndCloseWindowAsync and WebKit2.OpenAsyncWithNil API tests are fixed.
132
133         * UIProcess/WebPageProxy.cpp:
134         (WebKit::WebPageProxy::createNewPage):
135         createNewPageAsync or createNewPage should be called, not both.
136
137 2017-07-25  Said Abou-Hallawa  <sabouhallawa@apple.com>
138
139         Async image decoding for large images should be disabled after the first time a tile is painted
140         https://bugs.webkit.org/show_bug.cgi?id=174451
141         <rdar://problem/31246421>
142
143         Reviewed by Simon Fraser.
144
145         * Shared/mac/RemoteLayerBackingStore.mm:
146         (WebKit::RemoteLayerBackingStore::drawInContext):
147         * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
148         (WebKit::imageForRect):
149         * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
150         (WebKit::InjectedBundleRangeHandle::renderedImage):
151         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
152         (WebKit::CompositingCoordinator::paintContents):
153         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
154
155 2017-07-25  Brian Burg  <bburg@apple.com>
156
157         Web Automation: add support for uploading files
158         https://bugs.webkit.org/show_bug.cgi?id=174797
159         <rdar://problem/28485063>
160
161         Reviewed by Joseph Pecoraro.
162
163         The general strategy is to have automation clients set the list of files they want
164         to select ahead of time. Then, the client simulates a click on the <input type="file"> element.
165         When that causes WebPageProxy to ask the UI delegate to runOpenPanel, it instead
166         gives WebAutomationSession a chance to select files if the page is under control of
167         automation. WebAutomationSession validates its file list and selects the files if valid.
168
169         * CMakeLists.txt: Add frontend dispatcher files.
170         * DerivedSources.make:
171         Add frontend dispatcher code generator scripts as dependencies of the generated code.
172         Add generated frontend dispatcher files to the list of output files.
173
174         * UIProcess/Automation/Automation.json:
175         Add a command to set the canned list of files that should be selected when prompted.
176         If no files are selected, then the effect is as if the user had clicked "cancel" in
177         the file chooser dialog.
178
179         Add an event to signal to the WebDriver service that the file selection request has
180         been either fulfilled or cancelled. This event is necessary because otherwise remotes
181         cannot distinguish whether selecting the files failed for some reason, or if the
182         UIProcess has not yet selected the files and sent them to the web content process.
183         In either case, the input element's "files" attribute would return an empty FileList.
184
185         * UIProcess/Automation/WebAutomationSession.h:
186         * UIProcess/Automation/WebAutomationSession.cpp:
187         (WebKit::WebAutomationSession::WebAutomationSession):
188         Add the frontend dispatcher for Automation domain. This is named m_domainNotifier since
189         m_domainDispatcher is already being used for the backend command dispatcher.
190
191         (WebKit::WebAutomationSession::handleRunOpenPanel):
192         Validate that the files-to-select list has valid entries and select the files if so.
193         If anything goes wrong, pretend to cancel out of the file chooser. Either way, notify the
194         frontend with an event that the file chooser was dismissed due to selecting files or cancelling.
195         Automation protocol clients may implement additional strategies to further restrict
196         the conditions upon which local files can be uploaded.
197
198         (WebKit::WebAutomationSession::setFilesToSelectForFileUpload): Added.
199         Store the list of files as a vector of strings. The file list is always replaced.
200
201         * UIProcess/WebPageProxy.cpp:
202         (WebKit::WebPageProxy::runOpenPanel):
203         If the page is under automation, delegating the runOpenPanel is likely to hang
204         because WebDriver cannot interact directly with the file chooser dialog. Instead,
205         give WebAutomationSession a chance to select files and don't tell the delegate.
206
207         * WebKit.xcodeproj/project.pbxproj:
208         Add frontend dispatcher files to "Derived Sources" group.
209
210 2017-07-25  Alex Christensen  <achristensen@webkit.org>
211
212         Modernize NavigationAction code
213         https://bugs.webkit.org/show_bug.cgi?id=174807
214
215         Reviewed by Darin Adler.
216
217         Mostly just use more move semantics.
218
219         * Platform/IPC/HandleMessage.h:
220         (IPC::callMemberFunctionImpl):
221         * Shared/API/APIURLRequest.h:
222         * Shared/NavigationActionData.h:
223         * UIProcess/API/APINavigation.cpp:
224         (API::Navigation::Navigation):
225         * UIProcess/API/APINavigation.h:
226         (API::Navigation::create):
227         * UIProcess/API/APINavigationAction.h:
228         * UIProcess/API/APINavigationClient.h:
229         (API::NavigationClient::decidePolicyForNavigationAction):
230         * UIProcess/API/APIPolicyClient.h:
231         * UIProcess/API/APIUIClient.h:
232         (API::UIClient::createNewPage):
233         (API::UIClient::createNewPageAsync):
234         (API::UIClient::canCreateNewPageAsync):
235         * UIProcess/API/C/WKPage.cpp:
236         (WKPageLoadURLRequest):
237         (WKPageLoadURLRequestWithUserData):
238         (WKPageSetPageUIClient):
239         (WKPageSetPageNavigationClient):
240         * UIProcess/Cocoa/NavigationState.h:
241         * UIProcess/Cocoa/NavigationState.mm:
242         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
243         * UIProcess/Cocoa/UIDelegate.h:
244         * UIProcess/Cocoa/UIDelegate.mm:
245         (WebKit::UIDelegate::UIClient::createNewPageCommon):
246         (WebKit::UIDelegate::UIClient::createNewPage):
247         (WebKit::UIDelegate::UIClient::canCreateNewPageAsync):
248         (WebKit::UIDelegate::UIClient::createNewPageAsync):
249         * UIProcess/WebInspectorProxy.cpp:
250         (WebKit::decidePolicyForNavigationAction):
251         * UIProcess/WebNavigationState.cpp:
252         (WebKit::WebNavigationState::createLoadRequestNavigation):
253         * UIProcess/WebNavigationState.h:
254         * UIProcess/WebPageProxy.cpp:
255         (WebKit::WebPageProxy::loadRequest):
256         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
257         (WebKit::WebPageProxy::decidePolicyForNewWindowAction):
258         (WebKit::WebPageProxy::createNewPage):
259         * UIProcess/WebPageProxy.h:
260
261 2017-07-25  Carlos Garcia Campos  <cgarcia@igalia.com>
262
263         REGRESSION(r218629): [GTK] ASSERTION FAILED: m_eglDisplay == EGL_NO_DISPLAY in WebCore::PlatformDisplay::~PlatformDisplay
264         https://bugs.webkit.org/show_bug.cgi?id=174789
265
266         Reviewed by Žan Doberšek.
267
268         Before r218629, the wayland nested compositor display was a singleton created on demand by
269         AcceleratedSurfaceWayland, but now it's created unconditionally on web process creation when a valid display
270         name is received from the UI process. The side effect of this is that now the shared display is created after
271         the nested compositor display that is not a singleton anymore. The atexit used by PlatformDisplay to shutdown
272         egl display assumes that it will be registered by the shared display. Since we switched to on demand AC mode,
273         the shared display is only used in the web process when entering AC mode, that's why it only crashes when we
274         have entered AC at least once. We just need to ensure that the shared display is created before the nested
275         compositor display.
276
277         * WebProcess/gtk/WaylandCompositorDisplay.cpp:
278         (WebKit::WaylandCompositorDisplay::create): Check we are under wayland before creating the WaylandCompositorDisplay.
279
280 2017-07-24  Michael Catanzaro  <mcatanzaro@igalia.com>
281
282         [GTK] ASSERTION FAILED: client in WebKit::IconDatabase::setClient
283         https://bugs.webkit.org/show_bug.cgi?id=174788
284
285         Reviewed by Carlos Garcia Campos.
286
287         IconDatabase ensures that setClient is never called with nullptr, but WebKitFaviconDatabase
288         does exactly that. First, ensure it's safe to unset the client. Next, we can either remove
289         the assertions from setClient or else automatically unset the client in IconDatabase::close.
290         I opted to do both.
291
292         * UIProcess/API/glib/IconDatabase.cpp:
293         (WebKit::IconDatabase::close):
294         (WebKit::IconDatabase::setIconDataForIconURL):
295         (WebKit::IconDatabase::setIconURLForPageURL):
296         * UIProcess/API/glib/WebKitFaviconDatabase.cpp:
297         (_WebKitFaviconDatabasePrivate::~_WebKitFaviconDatabasePrivate): Deleted.
298         (webkitFaviconDatabaseDispose): Deleted.
299
300 2017-07-24  Michael Catanzaro  <mcatanzaro@igalia.com>
301
302         [GTK][WPE] Remove useless conditional in IconDatabase::setIconDataForIconURL
303         https://bugs.webkit.org/show_bug.cgi?id=174792
304
305         Reviewed by Carlos Garcia Campos.
306
307         We have in IconDatabase::setIconDataForIconURL some code in a conditional to check if it's
308         not being executed on the icon sync thread. But at the top of the function is an assertion
309         to ensure the code is never executed on the icon sync thread. The condition is therefore
310         useless and the code should be executed unconditionally.
311
312         * UIProcess/API/glib/IconDatabase.cpp:
313         (WebKit::IconDatabase::setIconDataForIconURL):
314
315 2017-07-24  Carlos Garcia Campos  <cgarcia@igalia.com>
316
317         [GTK] Icon database error and crash
318         https://bugs.webkit.org/show_bug.cgi?id=174760
319
320         Reviewed by Michael Catanzaro.
321
322         The crash is a debug ASSERT that happens when the IconRecord image is created in one thread and destroyed in
323         another one. IconDatabase creates and destroys IconRecord objects in both database and main thread. The
324         IconRecord is destroyed when the icon is no longer retained, and we only release icons when we fail to get the
325         image data (including pages that don't have a favicon). We can prevent this crash from happening if we ensure we
326         never create an Image for an IconRecord when the given image data is nullptr.
327
328         * UIProcess/API/glib/IconDatabase.cpp:
329         (WebKit::IconDatabase::IconRecord::setImageData):
330
331 2017-07-24  Chris Dumez  <cdumez@apple.com>
332
333         [WK2][Cocoa] Allow overriding the ITP data removal internal using a default
334         https://bugs.webkit.org/show_bug.cgi?id=174802
335         <rdar://problem/33497898>
336
337         Reviewed by Sam Weinig.
338
339         Allow overriding the ITP data removal internal using a default to facilitate testing.
340         Can be used like so:
341         defaults write -g ResourceLoadStatisticsMinimumTimeBetweenDataRecordsRemoval 60
342
343         Will cause us to write every 60 seconds instead of 3600.
344
345         * Shared/WebPreferencesDefinitions.h:
346         * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
347         (WebKit::WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):
348
349 2017-07-24  Simon Fraser  <simon.fraser@apple.com>
350
351         [iOS WK2] Crash under PageOverlayController::uninstallPageOverlay when doing multiple finds
352         https://bugs.webkit.org/show_bug.cgi?id=174806
353         rdar://problem/33501664
354
355         Reviewed by Tim Horton.
356         
357         Calling TextIndicator::createWithSelectionInFrame can trigger layout via VisibleSelection code,
358         which can re-enter FindController::updateFindIndicator which has by now removed m_findIndicatorOverlay
359         from pageOverlayController's map, but not deleted it. The second call to uninstallPageOverlay()
360         thus crashes at m_overlayGraphicsLayers.take(&overlay)->removeFromParent().
361         
362         Fix by nulling out m_findIndicatorOverlay as soon as we uninstall it.
363
364         * WebProcess/WebPage/ios/FindControllerIOS.mm:
365         (WebKit::FindController::updateFindIndicator):
366
367 2017-07-24  Chris Dumez  <cdumez@apple.com>
368
369         Fix lifetime management issue in ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore()
370         https://bugs.webkit.org/show_bug.cgi?id=174790
371
372         Reviewed by Brady Eidson.
373
374         Fix lifetime management issue in ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore().
375         WorkQueue::dispatchAfter() keeps the WorkQueue alive because its implementation keeps a strong ref to
376         |this|. As a result, the lambda passed to dispatchAfter(), which calls writeMemoryStoreToDisk(), can
377         get executed after the store is gone.
378
379         To address the issue, we now use a RunLoop::Timer to schedule the write, instead of a
380         WorkQueue::dispatchAfter() call. This way, we are guaranteed that the callback will not get called
381         after the store has been destroyed.
382
383         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp:
384         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
385         (WebKit::ResourceLoadStatisticsPersistentStorage::asyncWriteTimerFired):
386         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
387         (WebKit::ResourceLoadStatisticsPersistentStorage::finishAllPendingWorkSynchronously):
388         (WebKit::ResourceLoadStatisticsPersistentStorage::ref):
389         (WebKit::ResourceLoadStatisticsPersistentStorage::deref):
390         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h:
391
392 2017-07-24  Chris Dumez  <cdumez@apple.com>
393
394         Unreviewed, rolling out r219828.
395
396         Causes debug assertions to be hit on iOS
397
398         Reverted changeset:
399
400         "Fix lifetime management issue in
401         ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore()"
402         https://bugs.webkit.org/show_bug.cgi?id=174790
403         http://trac.webkit.org/changeset/219828
404
405 2017-07-24  Michael Catanzaro  <mcatanzaro@igalia.com>
406
407         [GTK][WPE] Stop using AutodrainedPool in IconDatabase
408         https://bugs.webkit.org/show_bug.cgi?id=174791
409
410         Reviewed by Alex Christensen.
411
412         AutodrainedPool seems to be some NS garbage collection thing that has no implementation on
413         other platforms. Now that IconDatabase is used only by GTK and WPE, we can stop using it.
414
415         * UIProcess/API/glib/IconDatabase.cpp:
416         (WebKit::IconDatabase::setIconDataForIconURL):
417         (WebKit::IconDatabase::setIconURLForPageURL):
418         (WebKit::IconDatabase::iconDatabaseSyncThread):
419         (WebKit::IconDatabase::performURLImport):
420         (WebKit::IconDatabase::readFromDatabase):
421
422 2017-07-24  Chris Dumez  <cdumez@apple.com>
423
424         Fix lifetime management issue in ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore()
425         https://bugs.webkit.org/show_bug.cgi?id=174790
426
427         Reviewed by Brady Eidson.
428
429         Fix lifetime management issue in ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore().
430         WorkQueue::dispatchAfter() keeps the WorkQueue alive because its implementation keeps a strong ref to
431         |this|. As a result, the lambda passed to dispatchAfter(), which calls writeMemoryStoreToDisk(), can
432         get executed after the store is gone.
433
434         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp:
435         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
436         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
437         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h:
438         (WebKit::ResourceLoadStatisticsPersistentStorage::createWeakPtr):
439
440 2017-07-23  Carlos Garcia Campos  <cgarcia@igalia.com>
441
442         Unreviewed. REGRESSION(r219713): [GTK][WPE] Fix default favicon database patch.
443
444         When nullptr is passed to webkit_web_context_set_favicon_database_directory() the default database directory was
445         taken from WebProcessPool::platformDefaultIconDatabasePath(), that has been removed in r219713 without properly
446         replacing it, now it uses an empty string. This causes that the current directory is used to create the favicon
447         database.
448
449         * UIProcess/API/glib/WebKitWebContext.cpp:
450         (webkit_web_context_set_favicon_database_directory): Use the default icon database directory instead of an empty
451         string when nullptr is passed.
452
453 2017-07-23  Wenson Hsieh  <wenson_hsieh@apple.com>
454
455         [iOS WK2] 5 DataInteractionTests are failing: observed selection rects after dropping don't match expected values
456         https://bugs.webkit.org/show_bug.cgi?id=174769
457         <rdar://problem/33478864>
458
459         Reviewed by Tim Horton.
460
461         Fixes several API tests in the DataInteractionTests suite. See Source/WebCore/ChangeLog for more details.
462
463         * WebProcess/WebPage/WebPage.cpp:
464         (WebKit::WebPage::performDragControllerAction):
465
466 2017-07-20  Carlos Garcia Campos  <cgarcia@igalia.com>
467
468         WebDriver: implement page load timeout
469         https://bugs.webkit.org/show_bug.cgi?id=174672
470
471         Reviewed by Brian Burg.
472
473         Always start a timer when waiting for a navigation to complete. When the timer fires, pending callbacks for
474         navigations are removed and invoked with a timeout error. If navigation completes before the timer is fired,
475         then the timer is stopped. All navigation commands now receive the page load strategy and timeout as optional
476         parameters, when not provided the default timeout (300 seconds) is used.
477
478         * UIProcess/Automation/Automation.json:
479         * UIProcess/Automation/WebAutomationSession.cpp:
480         (WebKit::WebAutomationSession::WebAutomationSession):
481         (WebKit::WebAutomationSession::waitForNavigationToComplete):
482         (WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage):
483         (WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame):
484         (WebKit::WebAutomationSession::loadTimerFired):
485         (WebKit::WebAutomationSession::navigateBrowsingContext):
486         (WebKit::WebAutomationSession::goBackInBrowsingContext):
487         (WebKit::WebAutomationSession::goForwardInBrowsingContext):
488         (WebKit::WebAutomationSession::reloadBrowsingContext):
489         (WebKit::WebAutomationSession::navigationOccurredForFrame):
490         * UIProcess/Automation/WebAutomationSession.h:
491
492 2017-07-23  Takuro Ashie  <ashie@clear-code.com>
493
494         [GTK] Correct a typo in the reference manual of WebKitWebInspector
495         https://bugs.webkit.org/show_bug.cgi?id=174767
496
497         Reviewed by Michael Catanzaro.
498
499         * UIProcess/API/gtk/WebKitWebInspector.cpp:
500
501 2017-07-23  Chris Dumez  <cdumez@apple.com>
502
503         Drop ExceptionCodeDescription class
504         https://bugs.webkit.org/show_bug.cgi?id=174757
505
506         Reviewed by Darin Adler.
507
508         Update GTK bindings to use new API on DOMException instead of
509         ExceptionCodeDescription.
510
511         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMAttr.cpp:
512         (webkit_dom_attr_dispatch_event):
513         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMBlob.cpp:
514         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCDATASection.cpp:
515         (webkit_dom_cdata_section_dispatch_event):
516         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSRule.cpp:
517         (webkit_dom_css_rule_set_css_text):
518         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSRuleList.cpp:
519         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleDeclaration.cpp:
520         (webkit_dom_css_style_declaration_set_property):
521         (webkit_dom_css_style_declaration_set_css_text):
522         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp:
523         (webkit_dom_css_style_sheet_insert_rule):
524         (webkit_dom_css_style_sheet_delete_rule):
525         (webkit_dom_css_style_sheet_add_rule):
526         (webkit_dom_css_style_sheet_remove_rule):
527         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSValue.cpp:
528         (webkit_dom_css_value_set_css_text):
529         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCharacterData.cpp:
530         (webkit_dom_character_data_dispatch_event):
531         (webkit_dom_character_data_insert_data):
532         (webkit_dom_character_data_delete_data):
533         (webkit_dom_character_data_replace_data):
534         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMClientRect.cpp:
535         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMClientRectList.cpp:
536         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMComment.cpp:
537         (webkit_dom_comment_dispatch_event):
538         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp:
539         (webkit_dom_dom_implementation_create_document_type):
540         (webkit_dom_dom_implementation_create_document):
541         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMSelection.cpp:
542         (webkit_dom_dom_selection_collapse_to_end):
543         (webkit_dom_dom_selection_collapse_to_start):
544         (webkit_dom_dom_selection_extend):
545         (webkit_dom_dom_selection_get_range_at):
546         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMTokenList.cpp:
547         (webkit_dom_dom_token_list_add):
548         (webkit_dom_dom_token_list_remove):
549         (webkit_dom_dom_token_list_toggle):
550         (webkit_dom_dom_token_list_replace):
551         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp:
552         (webkit_dom_dom_window_dispatch_event):
553         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDeprecated.cpp:
554         (webkit_dom_node_set_prefix):
555         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp:
556         (webkit_dom_document_dispatch_event):
557         (webkit_dom_document_create_element):
558         (webkit_dom_document_create_cdata_section):
559         (webkit_dom_document_create_processing_instruction):
560         (webkit_dom_document_create_attribute):
561         (webkit_dom_document_import_node):
562         (webkit_dom_document_create_element_ns):
563         (webkit_dom_document_create_attribute_ns):
564         (webkit_dom_document_adopt_node):
565         (webkit_dom_document_create_event):
566         (webkit_dom_document_create_expression):
567         (webkit_dom_document_evaluate):
568         (webkit_dom_document_query_selector):
569         (webkit_dom_document_query_selector_all):
570         (webkit_dom_document_set_xml_version):
571         (webkit_dom_document_set_cookie):
572         (webkit_dom_document_set_body):
573         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentFragment.cpp:
574         (webkit_dom_document_fragment_dispatch_event):
575         (webkit_dom_document_fragment_query_selector):
576         (webkit_dom_document_fragment_query_selector_all):
577         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentType.cpp:
578         (webkit_dom_document_type_dispatch_event):
579         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElement.cpp:
580         (webkit_dom_element_dispatch_event):
581         (webkit_dom_element_set_attribute):
582         (webkit_dom_element_set_attribute_node):
583         (webkit_dom_element_remove_attribute_node):
584         (webkit_dom_element_set_attribute_ns):
585         (webkit_dom_element_set_attribute_node_ns):
586         (webkit_dom_element_matches):
587         (webkit_dom_element_closest):
588         (webkit_dom_element_insert_adjacent_element):
589         (webkit_dom_element_insert_adjacent_html):
590         (webkit_dom_element_insert_adjacent_text):
591         (webkit_dom_element_remove):
592         (webkit_dom_element_query_selector):
593         (webkit_dom_element_query_selector_all):
594         (webkit_dom_element_set_inner_html):
595         (webkit_dom_element_set_outer_html):
596         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
597         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMFile.cpp:
598         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMFileList.cpp:
599         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLAnchorElement.cpp:
600         (webkit_dom_html_anchor_element_dispatch_event):
601         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLAppletElement.cpp:
602         (webkit_dom_html_applet_element_dispatch_event):
603         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLAreaElement.cpp:
604         (webkit_dom_html_area_element_dispatch_event):
605         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLBRElement.cpp:
606         (webkit_dom_html_br_element_dispatch_event):
607         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLBaseElement.cpp:
608         (webkit_dom_html_base_element_dispatch_event):
609         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLBodyElement.cpp:
610         (webkit_dom_html_body_element_dispatch_event):
611         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLButtonElement.cpp:
612         (webkit_dom_html_button_element_dispatch_event):
613         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLCanvasElement.cpp:
614         (webkit_dom_html_canvas_element_dispatch_event):
615         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLCollection.cpp:
616         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLDListElement.cpp:
617         (webkit_dom_html_d_list_element_dispatch_event):
618         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLDirectoryElement.cpp:
619         (webkit_dom_html_directory_element_dispatch_event):
620         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLDivElement.cpp:
621         (webkit_dom_html_div_element_dispatch_event):
622         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLDocument.cpp:
623         (webkit_dom_html_document_dispatch_event):
624         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLElement.cpp:
625         (webkit_dom_html_element_dispatch_event):
626         (webkit_dom_html_element_set_inner_text):
627         (webkit_dom_html_element_set_outer_text):
628         (webkit_dom_html_element_set_content_editable):
629         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLEmbedElement.cpp:
630         (webkit_dom_html_embed_element_dispatch_event):
631         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLFieldSetElement.cpp:
632         (webkit_dom_html_field_set_element_dispatch_event):
633         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLFontElement.cpp:
634         (webkit_dom_html_font_element_dispatch_event):
635         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLFormElement.cpp:
636         (webkit_dom_html_form_element_dispatch_event):
637         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLFrameElement.cpp:
638         (webkit_dom_html_frame_element_dispatch_event):
639         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLFrameSetElement.cpp:
640         (webkit_dom_html_frame_set_element_dispatch_event):
641         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLHRElement.cpp:
642         (webkit_dom_html_hr_element_dispatch_event):
643         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLHeadElement.cpp:
644         (webkit_dom_html_head_element_dispatch_event):
645         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLHeadingElement.cpp:
646         (webkit_dom_html_heading_element_dispatch_event):
647         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLHtmlElement.cpp:
648         (webkit_dom_html_html_element_dispatch_event):
649         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLIFrameElement.cpp:
650         (webkit_dom_html_iframe_element_dispatch_event):
651         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLImageElement.cpp:
652         (webkit_dom_html_image_element_dispatch_event):
653         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLInputElement.cpp:
654         (webkit_dom_html_input_element_dispatch_event):
655         (webkit_dom_html_input_element_set_max_length):
656         (webkit_dom_html_input_element_set_size):
657         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLLIElement.cpp:
658         (webkit_dom_html_li_element_dispatch_event):
659         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLLabelElement.cpp:
660         (webkit_dom_html_label_element_dispatch_event):
661         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLLegendElement.cpp:
662         (webkit_dom_html_legend_element_dispatch_event):
663         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLLinkElement.cpp:
664         (webkit_dom_html_link_element_dispatch_event):
665         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLMapElement.cpp:
666         (webkit_dom_html_map_element_dispatch_event):
667         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLMarqueeElement.cpp:
668         (webkit_dom_html_marquee_element_dispatch_event):
669         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLMenuElement.cpp:
670         (webkit_dom_html_menu_element_dispatch_event):
671         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLMetaElement.cpp:
672         (webkit_dom_html_meta_element_dispatch_event):
673         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLModElement.cpp:
674         (webkit_dom_html_mod_element_dispatch_event):
675         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLOListElement.cpp:
676         (webkit_dom_html_o_list_element_dispatch_event):
677         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLObjectElement.cpp:
678         (webkit_dom_html_object_element_dispatch_event):
679         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLOptGroupElement.cpp:
680         (webkit_dom_html_opt_group_element_dispatch_event):
681         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLOptionElement.cpp:
682         (webkit_dom_html_option_element_dispatch_event):
683         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLOptionsCollection.cpp:
684         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLParagraphElement.cpp:
685         (webkit_dom_html_paragraph_element_dispatch_event):
686         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLParamElement.cpp:
687         (webkit_dom_html_param_element_dispatch_event):
688         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLPreElement.cpp:
689         (webkit_dom_html_pre_element_dispatch_event):
690         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLQuoteElement.cpp:
691         (webkit_dom_html_quote_element_dispatch_event):
692         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLScriptElement.cpp:
693         (webkit_dom_html_script_element_dispatch_event):
694         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLSelectElement.cpp:
695         (webkit_dom_html_select_element_dispatch_event):
696         (webkit_dom_html_select_element_add):
697         (webkit_dom_html_select_element_set_length):
698         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLStyleElement.cpp:
699         (webkit_dom_html_style_element_dispatch_event):
700         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableCaptionElement.cpp:
701         (webkit_dom_html_table_caption_element_dispatch_event):
702         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableCellElement.cpp:
703         (webkit_dom_html_table_cell_element_dispatch_event):
704         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableColElement.cpp:
705         (webkit_dom_html_table_col_element_dispatch_event):
706         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableElement.cpp:
707         (webkit_dom_html_table_element_dispatch_event):
708         (webkit_dom_html_table_element_insert_row):
709         (webkit_dom_html_table_element_delete_row):
710         (webkit_dom_html_table_element_set_caption):
711         (webkit_dom_html_table_element_set_t_head):
712         (webkit_dom_html_table_element_set_t_foot):
713         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableRowElement.cpp:
714         (webkit_dom_html_table_row_element_dispatch_event):
715         (webkit_dom_html_table_row_element_insert_cell):
716         (webkit_dom_html_table_row_element_delete_cell):
717         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTableSectionElement.cpp:
718         (webkit_dom_html_table_section_element_dispatch_event):
719         (webkit_dom_html_table_section_element_insert_row):
720         (webkit_dom_html_table_section_element_delete_row):
721         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTextAreaElement.cpp:
722         (webkit_dom_html_text_area_element_dispatch_event):
723         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLTitleElement.cpp:
724         (webkit_dom_html_title_element_dispatch_event):
725         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLUListElement.cpp:
726         (webkit_dom_html_u_list_element_dispatch_event):
727         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMKeyboardEvent.cpp:
728         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMediaList.cpp:
729         (webkit_dom_media_list_delete_medium):
730         (webkit_dom_media_list_append_medium):
731         (webkit_dom_media_list_set_media_text):
732         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMMouseEvent.cpp:
733         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNamedNodeMap.cpp:
734         (webkit_dom_named_node_map_set_named_item):
735         (webkit_dom_named_node_map_remove_named_item):
736         (webkit_dom_named_node_map_remove_named_item_ns):
737         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNode.cpp:
738         (webkit_dom_node_dispatch_event):
739         (webkit_dom_node_insert_before):
740         (webkit_dom_node_replace_child):
741         (webkit_dom_node_remove_child):
742         (webkit_dom_node_append_child):
743         (webkit_dom_node_clone_node_with_error):
744         (webkit_dom_node_set_node_value):
745         (webkit_dom_node_set_text_content):
746         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNodeIterator.cpp:
747         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMNodeList.cpp:
748         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMProcessingInstruction.cpp:
749         (webkit_dom_processing_instruction_dispatch_event):
750         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMRange.cpp:
751         (webkit_dom_range_set_start):
752         (webkit_dom_range_set_end):
753         (webkit_dom_range_set_start_before):
754         (webkit_dom_range_set_start_after):
755         (webkit_dom_range_set_end_before):
756         (webkit_dom_range_set_end_after):
757         (webkit_dom_range_select_node):
758         (webkit_dom_range_select_node_contents):
759         (webkit_dom_range_compare_boundary_points):
760         (webkit_dom_range_delete_contents):
761         (webkit_dom_range_extract_contents):
762         (webkit_dom_range_clone_contents):
763         (webkit_dom_range_insert_node):
764         (webkit_dom_range_surround_contents):
765         (webkit_dom_range_create_contextual_fragment):
766         (webkit_dom_range_compare_node):
767         (webkit_dom_range_intersects_node):
768         (webkit_dom_range_compare_point):
769         (webkit_dom_range_is_point_in_range):
770         (webkit_dom_range_expand):
771         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMStyleSheet.cpp:
772         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMStyleSheetList.cpp:
773         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMText.cpp:
774         (webkit_dom_text_dispatch_event):
775         (webkit_dom_text_split_text):
776         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMTreeWalker.cpp:
777         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMUIEvent.cpp:
778         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMWheelEvent.cpp:
779         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp:
780         (webkit_dom_xpath_expression_evaluate):
781         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathResult.cpp:
782         (webkit_dom_xpath_result_iterate_next):
783         (webkit_dom_xpath_result_snapshot_item):
784         (webkit_dom_xpath_result_get_number_value):
785         (webkit_dom_xpath_result_get_boolean_value):
786         (webkit_dom_xpath_result_get_single_node_value):
787         (webkit_dom_xpath_result_get_snapshot_length):
788
789 2017-07-22  Wenson Hsieh  <wenson_hsieh@apple.com>
790
791         [iOS WK2] Remove _WKDraggableElementInfo and fold PositionInformationTests into WKRequestActivatedElementInfo
792         https://bugs.webkit.org/show_bug.cgi?id=174758
793
794         Reviewed by Dan Bernstein.
795
796         _WKDraggableElementInfo is no longer used in WebKit, so it should be removed. However, some of the scenarios
797         in PositionInformationTests that depend on _WKDraggableElementInfo are still useful to exercise: namely,
798         performing both synchronous and asynchronous position information updates while an async position information
799         update is in flight. This patch refactors these unit tests into 2 new unit tests in the existing
800         WKRequestActivatedElementInfo test suite.
801
802         * UIProcess/API/Cocoa/WKWebView.mm:
803         (-[WKWebView _draggableElementAtPosition:]): Deleted.
804         (-[WKWebView _requestDraggableElementAtPosition:completionBlock:]): Deleted.
805         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
806         * UIProcess/API/Cocoa/_WKDraggableElementInfo.h: Removed.
807         * UIProcess/API/Cocoa/_WKDraggableElementInfo.mm: Removed.
808         * UIProcess/API/Cocoa/_WKDraggableElementInfoInternal.h: Removed.
809         * UIProcess/ios/WKContentViewInteraction.mm:
810         * WebKit.xcodeproj/project.pbxproj:
811
812 2017-07-22  Wenson Hsieh  <wenson_hsieh@apple.com>
813
814         [Mac WK2] Fix null dereference in asynchronous NSTextInputClient methods when deallocating a WKWebView
815         https://bugs.webkit.org/show_bug.cgi?id=174751
816         <rdar://problem/33132405>
817
818         Reviewed by Darin Adler.
819
820         Tweaks -[WKWebView dealloc] to close the WebPageProxy at an earlier time, prior to destroying the WebViewImpl.
821         This fixes a NSTextInputClient crash in WKWebView when exercising the following scenario:
822
823         (1) Suppose that NSTextInputContext invokes an asynchronous text input query on WKWebView immediately before
824         WKWebView is deallocated, such that WebPageProxy's CallbackMap contains an NSTextInputContext callback at the
825         time that -[WKWebView dealloc] is called. Additionally, suppose that this callback from NSTextInputContext
826         invokes additional NSTextInputClient methods on the WKWebView that involve plumbing through to the WebViewImpl
827         (which is stored as _impl on the WKWebView).
828
829         (2) Observe that when calling [super dealloc] in [WKWebView dealloc], we will destroy the WebViewImpl as a
830         result of setting our unique pointer to _impl to be null. In ~WebViewImpl, we invoke WebPageProxy::close, which
831         in turn invokes WebPageProxy::resetState.
832
833         (3) WebPageProxy::resetState then calls m_callbacks.invalidate(error), which triggers all pending callbacks.
834         This invokes the block described in (1), which causes us to try and call back into WKWebView, invoking
835         NSTextInputClient methods. Without the fix in this patch, these methods currently assume that _impl is nonnull,
836         even though we've already cleared out the pointer in (2), so we segfault with a null dereference.
837
838         After this patch, we close the _page at an earlier time, such that the state is reset before the WebViewImpl
839         (and corresponding _impl unique_ptr in WKWebView) is torn down. This ensures that _impl will not be null for
840         callbacks invoked after beginning to deallocate the WKWebView.
841
842         Forcing this scenario in a custom AppKit root that triggers async NSTextInputClient methods immediately when a
843         WKWebView is being deallocated produces a crash with the same stack trace as what we observe in the radar, but
844         there are no known steps to actually reproduce this crash in shipping software.
845
846         * UIProcess/API/Cocoa/WKWebView.mm:
847         (-[WKWebView dealloc]):
848
849 2017-07-22  Chris Dumez  <cdumez@apple.com>
850
851         REGRESSION(r204565): WKObject is broken
852         https://bugs.webkit.org/show_bug.cgi?id=174736
853         <rdar://problem/33246169>
854
855         Reviewed by Dan Bernstein.
856
857         Revert r204565 as making WKObject a root class caused unexpected crashes.
858         Instead, we now have WKObject inherit from NSProxy (instead of previously
859         NSObject) and we forward calls to the target.
860
861         We also need to provide an implementation for private methods such as
862         isNSString__ to address the issue with NSStrings that r204565 was trying
863         to fix.
864
865         * Shared/Cocoa/APIObject.mm:
866         (API::Object::unwrap):
867         * Shared/Cocoa/WKObject.h:
868         * Shared/Cocoa/WKObject.mm:
869         (-[WKObject dealloc]):
870         (-[WKObject hash]):
871         (-[WKObject isKindOfClass:]):
872         (-[WKObject isMemberOfClass:]):
873         (-[WKObject respondsToSelector:]):
874         (-[WKObject conformsToProtocol:]):
875         (-[WKObject forwardingTargetForSelector:]):
876         (-[WKObject description]):
877         (-[WKObject debugDescription]):
878         (-[WKObject classForCoder]):
879         (-[WKObject classForKeyedArchiver]):
880         (-[WKObject _web_createTarget]):
881         (-[WKObject forwardInvocation:]):
882         (-[WKObject methodSignatureForSelector:]):
883         (-[WKObject isNSObject__]):
884         (-[WKObject isNSArray__]):
885         (-[WKObject isNSCFConstantString__]):
886         (-[WKObject isNSData__]):
887         (-[WKObject isNSDate__]):
888         (-[WKObject isNSDictionary__]):
889         (-[WKObject isNSNumber__]):
890         (-[WKObject isNSOrderedSet__]):
891         (-[WKObject isNSSet__]):
892         (-[WKObject isNSString__]):
893         (-[WKObject isNSTimeZone__]):
894         (-[WKObject isNSValue__]):
895
896 2017-07-21  Chris Dumez  <cdumez@apple.com>
897
898         Drop IDBDatabaseException class
899         https://bugs.webkit.org/show_bug.cgi?id=174743
900
901         Reviewed by Darin Adler.
902
903         * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
904         (WebKit::WebIDBConnectionToServer::connectionToServerLost):
905
906 2017-07-21  Brady Eidson  <beidson@apple.com>
907
908         Crash in many WebKit apps marking a connection invalid under Messages::NetworkProcessProxy::canAuthenticateAgainstProtectionSpace.
909         <rdar://problem/28822272> and https://bugs.webkit.org/show_bug.cgi?id=174729
910
911         Reviewed by Tim Horton.
912
913         Previously, when a NetworkLoad generated a "CanAuthenticateAgainstProtectionSpace" event, the message went from
914         Network process -> Web process -> UI process.
915
916         In that case, MESSAGE_CHECKing the validity of the frame in WebPageProxy made sense.
917
918         In r202511 we cut the WebProcess out of this and had Networking go straight to UI process.
919
920         As a result, the message check became invalid. The Networking process cannot possible know the validity of 
921         particular WebPage or WebFrame identifiers.
922
923         We simply need to validate the input in NetworkProcessProxy.
924
925         * UIProcess/Network/NetworkProcessProxy.cpp:
926         (WebKit::NetworkProcessProxy::canAuthenticateAgainstProtectionSpace): Validate both the page and frame ids before
927           passing the call along to the WebPageProxy. Also, if either of those validations fail, respond to the network process.
928
929 2017-07-21  Andy Estes  <aestes@apple.com>
930
931         [iOS] Adopt UIImagePickerControllerImageURL for photo uploads
932         https://bugs.webkit.org/show_bug.cgi?id=174723
933         <rdar://problem/33223962>
934
935         Reviewed by Joseph Pecoraro.
936
937         In iOS 11, use the URL provided by UIImagePickerControllerImageURL, if available, as the
938         file URL for photo uploads. Since we use the UIImagePickerController imageExportPreset of
939         UIImagePickerControllerImageURLExportPresetCompatible, UIKit will take care of converting
940         HEIF images to JPEG for us. For other types (GIF, JPEG, and PNG), it will preserve the
941         original format.
942
943         Since UIImagePickerController now provides GIF and PNG representations, we no longer need to
944         use PHImageManager to access the original assets. This patch removes the
945         PHAsset/PHImageManager code added in r185241.
946
947         * Platform/spi/ios/PhotosSPI.h: Removed.
948         * UIProcess/ios/forms/WKFileUploadPanel.mm:
949         (-[WKFileUploadPanel _uploadItemFromMediaInfo:successBlock:failureBlock:]):
950         (-[WKFileUploadPanel _uploadItemForImage:withAssetURL:successBlock:failureBlock:]): Deleted.
951         * WebKit.xcodeproj/project.pbxproj:
952
953 2017-07-21  Konstantin Tokarev  <annulen@yandex.ru>
954
955         [cmake][Mac] Unreviewed, fix linking WebKitSystemInterface
956
957         After r219560 link_directories() in PlatformXXX.cmake files does not
958         affect corresponding targets.
959
960         * PlatformMac.cmake:
961
962 2017-07-21  Andreas Kling  <akling@apple.com>
963
964         Use more references in event dispatch code
965         https://bugs.webkit.org/show_bug.cgi?id=174681
966
967         Reviewed by Geoffrey Garen.
968
969         * WebProcess/Plugins/PDF/PDFPluginAnnotation.h:
970         * WebProcess/Plugins/PDF/PDFPluginAnnotation.mm:
971         (WebKit::PDFPluginAnnotation::handleEvent):
972         (WebKit::PDFPluginAnnotation::PDFPluginAnnotationEventListener::handleEvent):
973         * WebProcess/Plugins/PDF/PDFPluginPasswordField.h:
974         * WebProcess/Plugins/PDF/PDFPluginPasswordField.mm:
975         (WebKit::PDFPluginPasswordField::handleEvent):
976         * WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h:
977         * WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:
978         (WebKit::PDFPluginTextAnnotation::handleEvent):
979         * WebProcess/Plugins/PluginView.cpp:
980         (WebKit::PluginView::createWebEvent):
981         (WebKit::PluginView::handleEvent):
982         * WebProcess/Plugins/PluginView.h:
983
984 2017-07-21  Chris Dumez  <cdumez@apple.com>
985
986         WebResourceLoadStatisticsStore::m_operatingDates is unsafely modified from several threads
987         https://bugs.webkit.org/show_bug.cgi?id=174721
988         <rdar://problem/33400343>
989
990         Reviewed by Brent Fulgham.
991
992         WebResourceLoadStatisticsStore::m_operatingDates is supposed to only be modified on
993         the background thread. However, WebResourceLoadStatisticsStore::performDailyTasks()
994         was mistakenly calling includeTodayAsOperatingDateIfNecessary() on the main thread,
995         which would modify m_operatingDates. This could lead to crashes such as the
996         one in <rdar://problem/33400343>, as the main thread may modify m_operatingDates
997         while we are interating over it on the background thread to save it to disk.
998
999         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1000         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
1001         (WebKit::WebResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
1002
1003 2017-07-21  Brady Eidson  <beidson@apple.com>
1004
1005         Get rid of WebCore IconDatabase code.
1006         https://bugs.webkit.org/show_bug.cgi?id=174700
1007
1008         Reviewed by Tim Horton.
1009
1010         * UIProcess/API/glib/WebKitWebContext.cpp:
1011         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1012         (WebKit::WebFrameLoaderClient::useIconLoadingClient): Deleted.
1013         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
1014
1015 2017-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
1016
1017         Web Automation: implicit navigations don't cause browsing context switch
1018         https://bugs.webkit.org/show_bug.cgi?id=174633
1019         <rdar://problem/33387797>
1020
1021         Reviewed by Brian Burg.
1022
1023         When a new page load replaces the current frameset, for example when a link in the current browser context has a
1024         _top target, there's no explicit context switch, so the web driver doesn't know that the current browsing
1025         context is no longer valid. Following commands will still be using the previous frame as the current browsing
1026         context, but they don't fail with no such frame because the frame is still alive in the page cache and
1027         referenced in the internal maps used in both UI and web processes. This causes test
1028         testShouldFocusOnTheReplacementWhenAFrameFollowsALinkToA_TopTargetedPage to fail, since it expects a no such
1029         frame exception. When a new page navigation happens we can simply remove references to frames from
1030         m_handleWebFrameMap in WebAutomationSession, because any existing frame reference in the map should be for a
1031         previous page. With this, before the next command is executed, waitForNavigationToComplete will be called and it
1032         will fail with no such frame, condition that is handled to switch to the top level browser context. The test
1033         still fails, because the find element command is called with the top level browsing context, returning no such
1034         element, instead of no such frame. This is consistent with Chrome.
1035
1036         * UIProcess/Automation/WebAutomationSession.cpp:
1037         (WebKit::WebAutomationSession::navigationOccurredForFrame): Clear the m_handleWebFrameMap when a new page load
1038         finished.
1039
1040 2017-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
1041
1042         WebDriver: wait until navigation is complete before running new commands and after a click
1043         https://bugs.webkit.org/show_bug.cgi?id=174670
1044
1045         Reviewed by Brian Burg.
1046
1047         Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
1048         complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
1049
1050         * UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
1051         * UIProcess/Automation/WebAutomationSession.cpp:
1052         (WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
1053         waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
1054         (WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
1055         and wait for it to complete if needed.
1056         (WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
1057         and wait for it to complete if needed.
1058         (WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
1059         (WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
1060         (WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
1061         (WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
1062         (WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
1063         all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
1064         * UIProcess/Automation/WebAutomationSession.h:
1065         * UIProcess/WebPageProxy.cpp:
1066         (WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
1067         (WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
1068         (WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
1069
1070 2017-07-20  Carlos Garcia Campos  <cgarcia@igalia.com>
1071
1072         Unreviewed. Remove WKIconDatabaseCairo.
1073
1074         * PlatformGTK.cmake:
1075         * PlatformWPE.cmake:
1076         * UIProcess/API/C/cairo/WKIconDatabaseCairo.cpp: Removed.
1077         * UIProcess/API/C/cairo/WKIconDatabaseCairo.h: Removed.
1078
1079 2017-07-20  Brady Eidson  <beidson@apple.com>
1080
1081         Get rid of IconDatabase related code in WebKit.
1082         https://bugs.webkit.org/show_bug.cgi?id=174693
1083
1084         Reviewed by Tim Horton.
1085
1086         This leaves the C-API class but guts it.
1087
1088         No explanations of the other changes are needed.
1089
1090         * CMakeLists.txt:
1091         * DerivedSources.make:
1092         * Shared/WebProcessCreationParameters.cpp:
1093         (WebKit::WebProcessCreationParameters::encode):
1094         (WebKit::WebProcessCreationParameters::decode):
1095         * Shared/WebProcessCreationParameters.h:
1096         * UIProcess/API/C/WKContext.cpp:
1097         (WKContextGetIconDatabase):
1098         (WKContextSetIconDatabasePath):
1099         * UIProcess/API/C/WKIconDatabase.cpp:
1100         (WKIconDatabaseSetIconDatabaseClient):
1101         (WKIconDatabaseRetainIconForURL):
1102         (WKIconDatabaseReleaseIconForURL):
1103         (WKIconDatabaseSetIconDataForIconURL):
1104         (WKIconDatabaseSetIconURLForPageURL):
1105         (WKIconDatabaseCopyIconURLForPageURL):
1106         (WKIconDatabaseCopyIconDataForPageURL):
1107         (WKIconDatabaseEnableDatabaseCleanup):
1108         (WKIconDatabaseRemoveAllIcons):
1109         (WKIconDatabaseCheckIntegrityBeforeOpening):
1110         (WKIconDatabaseClose):
1111         * UIProcess/API/C/cg/WKIconDatabaseCG.cpp:
1112         (WKIconDatabaseTryGetCGImageForURL):
1113         (WKIconDatabaseTryCopyCGImageArrayForURL):
1114         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1115         (WebKit::WebProcessPool::platformDefaultIconDatabasePath): Deleted.
1116         * UIProcess/WebIconDatabase.cpp: Removed.
1117         * UIProcess/WebIconDatabase.h:
1118         (WebKit::WebIconDatabase::clearProcessPool): Deleted.
1119         * UIProcess/WebIconDatabase.messages.in: Removed.
1120         * UIProcess/WebIconDatabaseClient.cpp: Removed.
1121         * UIProcess/WebIconDatabaseClient.h: Removed.
1122         * UIProcess/WebProcessPool.cpp:
1123         (WebKit::m_hiddenPageThrottlingTimer):
1124         (WebKit::WebProcessPool::~WebProcessPool):
1125         (WebKit::WebProcessPool::setAnyPageGroupMightHavePrivateBrowsingEnabled):
1126         (WebKit::WebProcessPool::createNewWebProcess):
1127         (WebKit::WebProcessPool::setIconDatabasePath): Deleted.
1128         (WebKit::WebProcessPool::iconDatabasePath): Deleted.
1129         * UIProcess/WebProcessPool.h:
1130         * UIProcess/WebProcessProxy.cpp:
1131         (WebKit::WebProcessProxy::processWillShutDown):
1132         (WebKit::WebProcessProxy::retainIconForPageURL): Deleted.
1133         (WebKit::WebProcessProxy::releaseIconForPageURL): Deleted.
1134         (WebKit::WebProcessProxy::releaseRemainingIconsForPageURLs): Deleted.
1135         * UIProcess/WebProcessProxy.h:
1136         * UIProcess/WebProcessProxy.messages.in:
1137         * UIProcess/gtk/WebProcessPoolGtk.cpp:
1138         (WebKit::WebProcessPool::platformDefaultIconDatabasePath): Deleted.
1139         * UIProcess/wpe/WebProcessPoolWPE.cpp:
1140         (WebKit::WebProcessPool::platformDefaultIconDatabasePath): Deleted.
1141         * WebKit.xcodeproj/project.pbxproj:
1142         * WebProcess/IconDatabase/WebIconDatabaseProxy.cpp: Removed.
1143         * WebProcess/IconDatabase/WebIconDatabaseProxy.h: Removed.
1144         * WebProcess/IconDatabase/WebIconDatabaseProxy.messages.in: Removed.
1145         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1146         * WebProcess/WebProcess.cpp:
1147         (WebKit::WebProcess::WebProcess):
1148         (WebKit::WebProcess::initializeWebProcess):
1149         (WebKit::WebProcess::getWebCoreStatistics):
1150         * WebProcess/WebProcess.h:
1151
1152 2017-07-20  David Quesada  <david_quesada@apple.com>
1153
1154         Add SPI to notify WKNavigationDelegate about client redirects
1155         https://bugs.webkit.org/show_bug.cgi?id=174680
1156         rdar://problem/33184886
1157
1158         Reviewed by Brady Eidson.
1159
1160         * UIProcess/API/APINavigationClient.h:
1161         (API::NavigationClient::didPerformClientRedirectForNavigation):
1162         Add a new virtual method for navigation clients to implement if they want to be informed
1163         when the page is initiating a navigation that is a client redirect.
1164
1165         * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
1166         Declare the new WKNavigationDelegate method -_webView:didPerformClientRedirectForNavigation:
1167
1168         * UIProcess/Cocoa/NavigationState.h:
1169         * UIProcess/Cocoa/NavigationState.mm:
1170         (WebKit::NavigationState::setNavigationDelegate):
1171         (WebKit::NavigationState::NavigationClient::didPerformClientRedirectForNavigation):
1172         Add a new method to NavigationState method to tell the WKNavigationDelegate when a
1173         client redirect happens.
1174
1175         * UIProcess/WebPageProxy.cpp:
1176         (WebKit::WebPageProxy::didPerformClientRedirectForLoadForFrame):
1177         * UIProcess/WebPageProxy.h:
1178         * UIProcess/WebPageProxy.messages.in:
1179         Allow the WebPageProxy to receive a message from the web process when a client redirect happens.
1180
1181         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1182         (WebKit::WebFrameLoaderClient::dispatchDidPerformClientRedirect):
1183         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
1184         Send this new message to the UI process on client redirects.
1185
1186 2017-07-20  Chris Dumez  <cdumez@apple.com>
1187
1188         Drop legacy XPathException type
1189         https://bugs.webkit.org/show_bug.cgi?id=174679
1190
1191         Reviewed by Sam Weinig.
1192
1193         Drop legacy XPathException type and use DOMException instead. Both Firefox and Chrome
1194         no longer expose XPathException.
1195
1196         * UIProcess/Automation/atoms/FindNodes.js:
1197         (tryToFindNode):
1198
1199 2017-07-20  Chris Dumez  <cdumez@apple.com>
1200
1201         Unreviewed, rolling out r219706.
1202
1203         Broke iOS build
1204
1205         Reverted changeset:
1206
1207         "Drop legacy XPathException type"
1208         https://bugs.webkit.org/show_bug.cgi?id=174679
1209         http://trac.webkit.org/changeset/219706
1210
1211 2017-07-20  Chris Dumez  <cdumez@apple.com>
1212
1213         Drop legacy XPathException type
1214         https://bugs.webkit.org/show_bug.cgi?id=174679
1215
1216         Reviewed by Sam Weinig.
1217
1218         Drop legacy XPathException type and use DOMException instead. Both Firefox and Chrome
1219         no longer expose XPathException.
1220
1221         * UIProcess/Automation/atoms/FindNodes.js:
1222         (tryToFindNode):
1223
1224 2017-07-20  Chris Dumez  <cdumez@apple.com>
1225
1226         Avoid unnecessary WorkQueue dispatch in WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
1227         https://bugs.webkit.org/show_bug.cgi?id=174686
1228
1229         Reviewed by Geoffrey Garen.
1230
1231         Avoid unnecessary WorkQueue dispatch in WebResourceLoadStatisticsStore::processStatisticsAndDataRecords(). The most common
1232         call site is already on the right thread.
1233
1234         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
1235         (-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]):
1236         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1237         (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
1238         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
1239         * UIProcess/WebResourceLoadStatisticsStore.h:
1240
1241 2017-07-20  Chris Dumez  <cdumez@apple.com>
1242
1243         Regression(ITP): May get frequently logged out of wsj.com
1244         https://bugs.webkit.org/show_bug.cgi?id=174661
1245         <rdar://problem/32343256>
1246
1247         Reviewed by Geoffrey Garen.
1248
1249         Bump statistics file version to blow away old statistics on disk since those do not
1250         take into account associated domains.
1251
1252         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1253
1254 2017-07-20  Chris Dumez  <cdumez@apple.com>
1255
1256         Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable
1257         https://bugs.webkit.org/show_bug.cgi?id=174660
1258
1259         Reviewed by Geoffrey Garen.
1260
1261         Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable.
1262         This essentially replaces a branch to figure out if the new size is less or greater than the
1263         current size by an assertion.
1264
1265         * Platform/IPC/ArgumentCoders.h:
1266         * UIProcess/Gamepad/UIGamepadProvider.cpp:
1267         (WebKit::UIGamepadProvider::platformGamepadConnected):
1268         * UIProcess/WebProcessPool.cpp:
1269         (WebKit::WebProcessPool::setInitialConnectedGamepads):
1270         * WebProcess/Network/WebLoaderStrategy.cpp:
1271         (WebKit::WebLoaderStrategy::loadResourceSynchronously):
1272         * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp:
1273         (WebKit::WebPasteboardOverrides::getDataForOverride):
1274         * WebProcess/WebPage/ios/WebPageIOS.mm:
1275         (WebKit::WebPage::requestAutocorrectionData):
1276
1277 2017-07-20  Chris Dumez  <cdumez@apple.com>
1278
1279         Regression(ITP): Can no longer log in on abc.go.com
1280         https://bugs.webkit.org/show_bug.cgi?id=174533
1281         <rdar://problem/33325881>
1282
1283         Reviewed by Geoffrey Garen.
1284
1285         Bump statistics database version to blow away any existing statistics. Without this, SSO providers
1286         for which we added a quirk may already be in the database and identified as trackers. The quirk
1287         merely prevents the specified SSO providers from being identified as trackers.
1288
1289         * UIProcess/WebResourceLoadStatisticsStore.cpp:
1290
1291 2017-07-19  Simon Fraser  <simon.fraser@apple.com>
1292
1293         getBoundingClientRects not updated for programmatic scrolls
1294         https://bugs.webkit.org/show_bug.cgi?id=174538
1295         rdar://problem/33049012
1296
1297         Reviewed by Tim Horton.
1298         
1299         Feed ViewportRectStability and ScrollingLayerPositionAction into reconcileScrollingState().
1300
1301         * WebProcess/WebPage/ios/WebPageIOS.mm:
1302         (WebKit::WebPage::updateVisibleContentRects):
1303
1304 2017-07-19  Brady Eidson  <beidson@apple.com>
1305
1306         iBooks sometimes crashes when closing a book.
1307         <rdar://problem/31180331> and https://bugs.webkit.org/show_bug.cgi?id=174658
1308
1309         Reviewed by Oliver Hunt.
1310
1311         - LegacyCustomProtocolManagerProxy should not reference a WebProcessPool directly.
1312         - LegacyCustomProtocolManagerProxy should invalidate in its destructor.
1313
1314         * UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.cpp:
1315         (WebKit::LegacyCustomProtocolManagerProxy::LegacyCustomProtocolManagerProxy):
1316         (WebKit::LegacyCustomProtocolManagerProxy::~LegacyCustomProtocolManagerProxy):
1317         (WebKit::LegacyCustomProtocolManagerProxy::startLoading):
1318         (WebKit::LegacyCustomProtocolManagerProxy::stopLoading):
1319         (WebKit::LegacyCustomProtocolManagerProxy::invalidate):
1320         (WebKit::LegacyCustomProtocolManagerProxy::wasRedirectedToRequest):
1321         (WebKit::LegacyCustomProtocolManagerProxy::didReceiveResponse):
1322         (WebKit::LegacyCustomProtocolManagerProxy::didLoadData):
1323         (WebKit::LegacyCustomProtocolManagerProxy::didFailWithError):
1324         (WebKit::LegacyCustomProtocolManagerProxy::didFinishLoading):
1325         (WebKit::LegacyCustomProtocolManagerProxy::processDidClose): Deleted.
1326         * UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.h:
1327
1328         * UIProcess/Network/NetworkProcessProxy.cpp:
1329         (WebKit::NetworkProcessProxy::NetworkProcessProxy):
1330         (WebKit::NetworkProcessProxy::didClose):
1331         * UIProcess/Network/NetworkProcessProxy.h:
1332         (WebKit::NetworkProcessProxy::processPool):
1333
1334 2017-07-19  Yusuke Suzuki  <utatane.tea@gmail.com>
1335
1336         [WTF] Implement WTF::ThreadGroup
1337         https://bugs.webkit.org/show_bug.cgi?id=174081
1338
1339         Reviewed by Mark Lam.
1340
1341         * Shared/AsyncRequest.h:
1342
1343 2017-07-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1344
1345         WebDriver: handle invalid selector errors
1346         https://bugs.webkit.org/show_bug.cgi?id=174619
1347
1348         Reviewed by Brian Burg.
1349
1350         We are currently handling only XPathException and only when it's an invalid expression. In the xpath case, the
1351         spec also says "If any item in result is not an element return an error with error code invalid selector.", so
1352         we should also handle TYPE_ERR (The expression could not be converted to return the specified type.). However,
1353         since the spec says "or other error", I think we can simplify this and simply throw InvalidSelector inside the
1354         catch, without checking any specific error. This is causing 14 failures in selenium tests.
1355
1356         §12. Element Retrieval. Step 6: If a DOMException, SyntaxError, XPathException, or other error occurs during the
1357         execution of the element location strategy, return error invalid selector.
1358         https://www.w3.org/TR/webdriver/#dfn-find
1359
1360         * UIProcess/Automation/Automation.json: Add InvalidSelector error.
1361         * UIProcess/Automation/atoms/FindNodes.js:
1362         (tryToFindNode): Raise InvalidSelector in case of error.
1363         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
1364         (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Handle InvalidSelector exceptions.
1365
1366 2017-07-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1367
1368         Web Automation: error details not passed to DidEvaluateJavaScriptFunction message when callback was not called before page unload
1369         https://bugs.webkit.org/show_bug.cgi?id=174624
1370
1371         Reviewed by Brian Burg.
1372
1373         There's a variable errorMessage, but it's unused.
1374
1375         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
1376         (WebKit::WebAutomationSessionProxy::didClearWindowObjectForFrame): Pass errorMessage instead of String() to DidEvaluateJavaScriptFunction.
1377
1378 2017-07-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1379
1380         Web Automation: evaluateJavaScriptFunction should always notify the web process before returning early
1381         https://bugs.webkit.org/show_bug.cgi?id=174623
1382
1383         Reviewed by Brian Burg.
1384
1385         It currently returns early if page, frame or scriptObject are nullptr, in which cases the UI process is not
1386         notified. This causes test testShouldNotBeAbleToDoAnythingTheFrameIsDeletedFromUnderUs to hang, because message
1387         DidEvaluateJavaScriptFunction is never sent when the given frame no longer exists. We should send
1388         DidEvaluateJavaScriptFunction with WindowNotFound in case of page is nullptr and FrameNotFound if the frame is
1389         nullptr. The scriptObject early return is actually wrong, because scriptObjectForFrame creates a new script if
1390         there's isn't one for the given frame.
1391
1392         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
1393         (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):
1394
1395 2017-07-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1396
1397         Web Automation: pending evaluate script callbacks are stored with the wrong frame ID when using the default main frame
1398         https://bugs.webkit.org/show_bug.cgi?id=174622
1399
1400         Reviewed by Brian Burg.
1401
1402         The frameHandle argument is optional in evaluateJavaScriptFunction(), when not provided we pass 0 to the web
1403         process. The proxy gets the web page main frame when received frame ID is 0, but the given frameID is
1404         still used as key of m_webFramePendingEvaluateJavaScriptCallbacksMap and also passed to the javascript function
1405         as argument. I think r203442 was actually a workaround to this bug, making it even more hidden. Both
1406         m_webFrameScriptObjectMap and m_webFramePendingEvaluateJavaScriptCallbacksMap should never have 0 as a
1407         key, since they always use a frame ID, and the frame identifier counter starts at 1. This is causing test
1408         testShouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError to hang, because when the page is unloaded
1409         and didClearWindowObjectForFrame is called, we try to get the pending callbacks of frame 1, but they were stored
1410         as frame 0 so DidEvaluateJavaScriptFunction message is never sent to the UI process.
1411
1412         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
1413         (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Use always the actual frameID from the WebFrame
1414         we are using.
1415         * WebProcess/Automation/WebAutomationSessionProxy.h: Do not allow 0 as a key of
1416         m_webFramePendingEvaluateJavaScriptCallbacksMap and m_webFrameScriptObjectMap.
1417
1418 2017-07-18  Andy Estes  <aestes@apple.com>
1419
1420         [Xcode] Enable CLANG_WARN_RANGE_LOOP_ANALYSIS
1421         https://bugs.webkit.org/show_bug.cgi?id=174631
1422
1423         Reviewed by Tim Horton.
1424
1425         * Configurations/Base.xcconfig:
1426         * Shared/API/APIArray.cpp:
1427         (API::Array::toStringVector):
1428         * UIProcess/Plugins/PlugInAutoStartProvider.cpp:
1429         (WebKit::PlugInAutoStartProvider::setAutoStartOriginsArray):
1430         * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
1431         (WebKit::WebUserContentControllerProxy::addProcess):
1432         (WebKit::WebUserContentControllerProxy::removeAllUserScripts):
1433         (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets):
1434         * UIProcess/ios/forms/WKFileUploadPanel.mm:
1435         (-[WKFileUploadPanel presentWithParameters:resultListener:]):
1436         * WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp:
1437         (WebKit::InjectedBundlePageEditorClient::getPasteboardDataForRange):
1438
1439 2017-07-18  Andy Estes  <aestes@apple.com>
1440
1441         [Xcode] Enable CLANG_WARN_OBJC_LITERAL_CONVERSION
1442         https://bugs.webkit.org/show_bug.cgi?id=174631
1443
1444         Reviewed by Sam Weinig.
1445
1446         * Configurations/Base.xcconfig:
1447
1448 2017-07-18  Andy Estes  <aestes@apple.com>
1449
1450         [Xcode] Enable CLANG_WARN_NON_LITERAL_NULL_CONVERSION
1451         https://bugs.webkit.org/show_bug.cgi?id=174631
1452
1453         Reviewed by Dan Bernstein.
1454
1455         * Configurations/Base.xcconfig:
1456
1457 2017-07-18  Matt Lewis  <jlewis3@apple.com>
1458
1459         Unreviewed, rolling out r219610.
1460
1461         This caused an api failure on all platforms for the test
1462         SnapshotImageLargeAsyncDecoding
1463
1464         Reverted changeset:
1465
1466         "Async image decoding for large images should be disabled
1467         after the first time a tile is painted"
1468         https://bugs.webkit.org/show_bug.cgi?id=174451
1469         http://trac.webkit.org/changeset/219610
1470
1471 2017-07-18  Andy Estes  <aestes@apple.com>
1472
1473         [Xcode] Enable CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING
1474         https://bugs.webkit.org/show_bug.cgi?id=174631
1475
1476         Reviewed by Darin Adler.
1477
1478         * Configurations/Base.xcconfig:
1479
1480 2017-07-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
1481
1482         Async image decoding for large images should be disabled after the first time a tile is painted
1483         https://bugs.webkit.org/show_bug.cgi?id=174451
1484
1485         Reviewed by Simon Fraser.
1486
1487         * Shared/mac/RemoteLayerBackingStore.mm:
1488         (WebKit::RemoteLayerBackingStore::drawInContext):
1489         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
1490         (WebKit::CompositingCoordinator::paintContents):
1491         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
1492
1493 2017-07-17  Carlos Garcia Campos  <cgarcia@igalia.com>
1494
1495         Web Automation: link and partial link queries don't work if text link contains trailing or leading whitespaces
1496         https://bugs.webkit.org/show_bug.cgi?id=174499
1497
1498         Reviewed by Brian Burg.
1499
1500         This is causing test test_Driver_Can_Get_Link_By_Link_Test_Ignoring_Trailing_Whitespace to fail.
1501
1502         * UIProcess/Automation/atoms/FindNodes.js:
1503         (switch): Use normalize-space() in in the links xpath expressions.
1504
1505 2017-07-17  Darin Adler  <darin@apple.com>
1506
1507         Improve use of NeverDestroyed
1508         https://bugs.webkit.org/show_bug.cgi?id=174348
1509
1510         Reviewed by Sam Weinig.
1511
1512         * DatabaseProcess/DatabaseProcess.h: Removed unneeded include of
1513         NeverDestroyed.h.
1514         * NetworkProcess/cache/NetworkCacheKey.cpp: Ditto.
1515
1516         * NetworkProcess/capture/NetworkCaptureManager.cpp: Moved include of
1517         NeverDestroyed.h here ...
1518         * NetworkProcess/capture/NetworkCaptureManager.h: ... from here.
1519
1520         * PluginProcess/PluginProcess.cpp: Moved include of NeverDestroyed.h
1521         here ...
1522         * PluginProcess/PluginProcess.h: ... from here.
1523
1524         * Shared/API/Cocoa/_WKRemoteObjectInterface.mm:
1525         (isContainerClass): Removed trivial inefficient use of
1526         LazyNeverDestroyed<HashSet> to check against two classes.
1527         Instead wrote out the boolean expression.
1528
1529         * Shared/mac/SecItemShim.cpp: Removed unneeded include of
1530         NeverDestroyed.h.
1531
1532         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1533         (WebKit::WebProcessPool::platformInitialize): Call
1534         installMemoryPressureHandler instead of WebMemoryPressureHandler::singleton.
1535
1536         * UIProcess/Gamepad/UIGamepadProvider.h: Removed unneeded include
1537         of NeverDestroyed.h.
1538
1539         * UIProcess/Plugins/PluginProcessManager.cpp: Moved include of
1540         NeverDestroyed.h here ...
1541         * UIProcess/Plugins/PluginProcessManager.h: ... from here.
1542
1543         * UIProcess/WebInspectorProxy.cpp: Removed unneeded include
1544         of NeverDestroyed.h.
1545
1546         * UIProcess/WebPageProxy.h: Added now-needed include of
1547         MediaPlaybackTargetContext.h.
1548
1549         * UIProcess/WebPasteboardProxy.cpp: Moved include of
1550         NeverDestroyed.h here ...
1551         * UIProcess/WebPasteboardProxy.h: ... from here.
1552
1553         * UIProcess/ios/WebMemoryPressureHandlerIOS.h: Removed the
1554         WebMemoryPressureHandler class from this header. Callers don't need to
1555         know if there is a class. They simply indicate when it's time to install
1556         the handler. Another way to put it is that this class had no functions
1557         other than the singleton function.
1558
1559         * UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
1560         (WebKit::installMemoryPressureHandler): Replaced the class with this function.
1561         It creates a dispatch source and then resumes it. To avoid having the source
1562         look like a leak, we keep it in a global variable.
1563
1564         * WebProcess/Gamepad/WebGamepadProvider.h: Include Forward.h instead of
1565         NeverDestroyed.h.
1566
1567         * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: Moved include of
1568         NeverDestroyed.h here ...
1569         * WebProcess/WebCoreSupport/WebPasteboardOverrides.h: ... from here.
1570
1571         * WebProcess/WebCoreSupport/WebPlatformStrategies.h: Removed unneeded
1572         include of NeverDestroyed.h.
1573
1574 2017-07-17  Timothy Horton  <timothy_horton@apple.com>
1575
1576         Page using safe area constant properties jumps to correct layout after resize
1577         https://bugs.webkit.org/show_bug.cgi?id=174598
1578         <rdar://problem/33364275>
1579
1580         Reviewed by Simon Fraser.
1581
1582         Test: fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html
1583
1584         * UIProcess/API/Cocoa/WKWebView.mm:
1585         (-[WKWebView _beginAnimatedResizeWithUpdates:]):
1586         * UIProcess/WebPageProxy.h:
1587         * UIProcess/ios/WebPageProxyIOS.mm:
1588         (WebKit::WebPageProxy::dynamicViewportSizeUpdate):
1589         * WebProcess/WebPage/WebPage.h:
1590         * WebProcess/WebPage/WebPage.messages.in:
1591         * WebProcess/WebPage/ios/WebPageIOS.mm:
1592         (WebKit::WebPage::dynamicViewportSizeUpdate):
1593         Plumb unobscured safe area insets through in the dynamicViewportSizeUpdate,
1594         like we do in VisibleContentRectUpdate (once again sad that these aren't
1595         more similar), so that it will be correct in the during-rotation snapshot,
1596         instead of only becoming correct in the first visible content rect update
1597         post-rotation.
1598
1599 2017-07-17  Chris Dumez  <cdumez@apple.com>
1600
1601         UserMediaPermissionRequestManagerProxy should not use WebCore::Timer
1602         https://bugs.webkit.org/show_bug.cgi?id=174599
1603         <rdar://problem/33362600>
1604
1605         Reviewed by Tim Horton.
1606
1607         UserMediaPermissionRequestManagerProxy should not use WebCore::Timer since it runs in the
1608         UIProcess. Switch to using RunLoop::Timer instead.
1609
1610         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
1611         (WebKit::UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy):
1612         * UIProcess/UserMediaPermissionRequestManagerProxy.h:
1613
1614 2017-07-17  Chris Dumez  <cdumez@apple.com>
1615
1616         NETWORK_SESSION does not need didReceiveAuthenticationChallenge(uint64_t, uint64_t, const AuthenticationChallenge&)
1617         https://bugs.webkit.org/show_bug.cgi?id=174595
1618
1619         Reviewed by Alex Christensen.
1620
1621         * Shared/Authentication/AuthenticationManager.cpp:
1622         (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
1623         * Shared/Authentication/AuthenticationManager.h:
1624
1625 2017-07-17  Wenson Hsieh  <wenson_hsieh@apple.com>
1626
1627         [iOS DnD] Web process uses too much memory when beginning a drag on a very large image
1628         https://bugs.webkit.org/show_bug.cgi?id=174585
1629         <rdar://problem/33302541>
1630
1631         Reviewed by Tim Horton.
1632
1633         Add IPC support for serializing/deserializing the size of an image written to the pasteboard. See WebCore
1634         ChangeLogs for more details.
1635
1636         * Shared/WebCoreArgumentCoders.cpp:
1637         (IPC::ArgumentCoder<PasteboardImage>::encode):
1638         (IPC::ArgumentCoder<PasteboardImage>::decode):
1639
1640 2017-07-17  Konstantin Tokarev  <annulen@yandex.ru>
1641
1642         Unreviewed attempt to fix Mac cmake build
1643
1644         * PlatformMac.cmake: Remove reference to file which is gone since r219025
1645
1646 2017-07-17  Michael Catanzaro  <mcatanzaro@igalia.com>
1647
1648         [CMake] Include most CMake modules from WebKitCommon.cmake
1649         https://bugs.webkit.org/show_bug.cgi?id=174546
1650
1651         Reviewed by Konstantin Tokarev.
1652
1653         * CMakeLists.txt:
1654
1655 2017-07-17  Michael Catanzaro  <mcatanzaro@igalia.com>
1656
1657         [CMake] Macros in WebKitMacros.cmake should be prefixed with WEBKIT_ namespace
1658         https://bugs.webkit.org/show_bug.cgi?id=174547
1659
1660         Reviewed by Alex Christensen.
1661
1662         * CMakeLists.txt:
1663
1664 2017-07-17  Alex Christensen  <achristensen@webkit.org>
1665
1666         Modernize content extension code
1667         https://bugs.webkit.org/show_bug.cgi?id=174588
1668
1669         Reviewed by Sam Weinig.
1670
1671         * WebProcess/UserContent/WebUserContentController.cpp:
1672         (WebKit::WebUserContentController::addContentRuleLists):
1673
1674 2017-07-17  Jeremy Jones  <jeremyj@apple.com>
1675
1676         Add video fullscreen transition logging.
1677         https://bugs.webkit.org/show_bug.cgi?id=174474
1678
1679         Reviewed by Jer Noble.
1680
1681         No functional change. Just adds logging.
1682
1683         * Platform/Logging.h:
1684         * WebProcess/cocoa/WebVideoFullscreenManager.mm:
1685         (WebKit::WebVideoFullscreenManager::enterVideoFullscreenForVideoElement):
1686         (WebKit::WebVideoFullscreenManager::exitVideoFullscreenForVideoElement):
1687         (WebKit::WebVideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation):
1688         (WebKit::WebVideoFullscreenManager::didSetupFullscreen):
1689         (WebKit::WebVideoFullscreenManager::didEnterFullscreen):
1690         (WebKit::WebVideoFullscreenManager::didExitFullscreen):
1691         (WebKit::WebVideoFullscreenManager::didCleanupFullscreen):
1692         (WebKit::WebVideoFullscreenManager::setVideoLayerFrameFenced):
1693
1694 2017-07-17  Konstantin Tokarev  <annulen@yandex.ru>
1695
1696         [CMake] Create targets before WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS is called
1697         https://bugs.webkit.org/show_bug.cgi?id=174557
1698
1699         Reviewed by Michael Catanzaro.
1700
1701         * CMakeLists.txt:
1702
1703 2017-07-17  Carlos Garcia Campos  <cgarcia@igalia.com>
1704
1705         Web Automation: link and partial link queries don't work if the link contains formatting tags
1706         https://bugs.webkit.org/show_bug.cgi?id=174498
1707
1708         Reviewed by Brian Burg.
1709
1710         So, for example, if we find links with text "Foo" and there's a link like <a href=""><bA>Foo</b></a> we fail
1711         with no such element error. This causes test test_Link_With_Formatting_Tags to fail.
1712
1713         * UIProcess/Automation/atoms/FindNodes.js:
1714         (switch): Use descendant-or-self::text() instead of just text() in the links xpath expressions.
1715
1716 2017-07-16  Carlos Garcia Campos  <cgarcia@igalia.com>
1717
1718         Web Automation: FindNodes should throw an error in case of invalid strategy
1719         https://bugs.webkit.org/show_bug.cgi?id=174497
1720
1721         Reviewed by Brian Burg.
1722
1723         We are currently returning null or empty list. According to the spec in 12.2 Find Element and 12.3 Find
1724         Elements, step 4: "If location strategy is not present as a keyword in the table of location strategies, return
1725         error with error code invalid argument.".
1726         https://www.w3.org/TR/webdriver/#find-element.
1727
1728         This is causing test test_should_throw_an_error_if_user_passes_in_invalid_by_when_find_elements to fail.
1729
1730         * UIProcess/Automation/atoms/FindNodes.js:
1731         (switch): Throw an error in case of unknown strategy.
1732         * WebProcess/Automation/WebAutomationSessionProxy.cpp:
1733         (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Handle InvalidParameter exceptions.
1734
1735 2017-07-16  Brady Eidson  <beidson@apple.com>
1736
1737         Crash when a WKHTTPCookieStore outlives its owning WKWebsiteDataStore.
1738         <rdar://problem/33341730> and https://bugs.webkit.org/show_bug.cgi?id=174574
1739
1740         Reviewed by Tim Horton.
1741
1742         Instead of holding a weak reference to its owning API::WebsiteDataStore,
1743         API::HTTPCookieStore can hold a strong reference to the owner's implementation
1744         WebKit::WebsiteDataStore.
1745         
1746         * UIProcess/API/APIHTTPCookieStore.cpp:
1747         (API::HTTPCookieStore::HTTPCookieStore):
1748         (API::HTTPCookieStore::cookies):
1749         (API::HTTPCookieStore::setCookie):
1750         (API::HTTPCookieStore::deleteCookie):
1751         (API::HTTPCookieStore::registerObserver):
1752         (API::HTTPCookieStore::unregisterObserver):
1753         (API::HTTPCookieStore::cookieManagerDestroyed):
1754         (API::HTTPCookieStore::registerForNewProcessPoolNotifications):
1755         * UIProcess/API/APIHTTPCookieStore.h:
1756
1757 2017-07-15  Brady Eidson  <beidson@apple.com>
1758
1759         Make sure all CFHTTPCookieStorageRefs we create are scheduled.
1760         <rdar://problem/33221110> and https://bugs.webkit.org/show_bug.cgi?id=174513
1761
1762         Reviewed by Tim Horton.
1763
1764         Whenever we create a CFHTTPCookieStorage from identifying data it is unscheduled.
1765         We need to schedule it on the appropriate RunLoop.
1766         
1767         This patch also cleans up the creation of the identifying data itself.
1768         
1769         * NetworkProcess/mac/RemoteNetworkingContext.mm:
1770         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
1771
1772         * Shared/cf/CookieStorageUtilsCF.h: Added.
1773         * Shared/cf/CookieStorageUtilsCF.mm: Added.
1774         (WebKit::cookieStorageFromIdentifyingData):
1775         (WebKit::identifyingDataFromCookieStorage):
1776
1777         * Shared/mac/ChildProcessMac.mm:
1778         (WebKit::ChildProcess::setSharedHTTPCookieStorage):
1779
1780         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1781         (WebKit::WebProcessPool::platformInitializeWebProcess):
1782         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
1783
1784         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1785         (WebKit::WebsiteDataStore::parameters):
1786
1787         * WebKit.xcodeproj/project.pbxproj:
1788
1789         * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
1790         (WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession):
1791
1792 2017-07-15  Wenson Hsieh  <wenson_hsieh@apple.com>
1793
1794         [iOS WK2] Presenting an action sheet on an image map prevents selection UI from updating
1795         https://bugs.webkit.org/show_bug.cgi?id=174539
1796         <rdar://problem/33307395>
1797
1798         Reviewed by Darin Adler.
1799
1800         Small tweak to avoid presenting at the element rect or text rect if the interaction information failed to
1801         capture valid bounds for the element. We instead fall back to presenting at the touch location. This addresses
1802         problems when presenting the action sheet popover on image maps on iPad, where GetPositionInformation fails to
1803         capture correct data about for the <area>.
1804
1805         * UIProcess/ios/WKActionSheetAssistant.mm:
1806         (presentationStyleForView):
1807
1808 2017-07-14  Jonathan Bedard  <jbedard@apple.com>
1809
1810         Add iOS 11 SPI
1811         https://bugs.webkit.org/show_bug.cgi?id=174430
1812         <rdar://problem/33269288>
1813
1814         Reviewed by Tim Horton.
1815
1816         * Platform/spi/ios/UIKitSPI.h: Add drag-and-drop SPI for iOS 11.
1817         * UIProcess/ios/WKContentViewInteraction.mm: Move UIKit SPI to UIKitSPI.h.
1818
1819 2017-07-14  Jeff Miller  <jeffm@apple.com>
1820
1821         -[WKWebProcessBundleParameters setParametersForKeyWithDictionary:] passing wrong parameters to -setParameter:forKey
1822         https://bugs.webkit.org/show_bug.cgi?id=174524
1823
1824         Reviewed by Sam Weinig.
1825
1826         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessBundleParameters.mm:
1827         (-[WKWebProcessBundleParameters setParametersForKeyWithDictionary:]):
1828         Pass the dictionary key and value in the correct order.
1829
1830 2017-07-14  Brent Fulgham  <bfulgham@apple.com>
1831
1832         Monitor directory for new statistics files after a delete operation
1833         https://bugs.webkit.org/show_bug.cgi?id=174521
1834         <rdar://problem/33322189>
1835
1836         Reviewed by Chris Dumez.
1837
1838         Create a FileMonitor to watch the data directory when the statistics file is
1839         deleted by an external process. If it sees the file get created externally, merge
1840         those data into the in-memory store.
1841
1842         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp:
1843         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk): Added.
1844         (WebKit::ResourceLoadStatisticsPersistentStorage::monitorDirectoryForNewStatistics):
1845         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h:
1846
1847 2017-07-14  Matt Lewis  <jlewis3@apple.com>
1848
1849         Unreviewed, rolling out r219516.
1850
1851         This caused an API failure on macOS.
1852
1853         Reverted changeset:
1854
1855         "Make sure all CFHTTPCookieStorageRefs we create are
1856         scheduled."
1857         https://bugs.webkit.org/show_bug.cgi?id=174513
1858         http://trac.webkit.org/changeset/219516
1859
1860 2017-07-14  Daniel Bates  <dabates@apple.com>
1861
1862         REGRESSION (r219013): Compute source frame info for frameless document
1863         https://bugs.webkit.org/show_bug.cgi?id=174385
1864         <rdar://problem/33217736>
1865
1866         Reviewed by Brady Eidson.
1867
1868         Fixes an issue where we would crash in WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction()
1869         when computing the frame info for a now-frameless document. One way this can happen is when the frame
1870         that contains the document that initiated the navigation is removed from the page.
1871
1872         * UIProcess/WebPageProxy.cpp:
1873         (WebKit::WebPageProxy::decidePolicyForNavigationAction): Check that we have a valid page ID before
1874         looking up the WebPage object corresponding to it.
1875         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1876         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): Compute a FrameInfoData
1877         object from the source document directly as opposed to using WebFrame::info() as the latter requires
1878         that we have a valid WebCore frame and the source document may not have a frame.
1879
1880 2017-07-14  Jer Noble  <jer.noble@apple.com>
1881
1882         Allow clients to override their own hardware media requirements where no fallback media exists.
1883         https://bugs.webkit.org/show_bug.cgi?id=174426
1884         <rdar://problem/32537704>
1885
1886         Reviewed by Eric Carlson.
1887
1888         Add a new WKWebViewConfiguration property, as well as a new WKPreferences function, both to control
1889         WebCore's new allowMediaContentTypesRequiringHardwareSupportAsFallback setting.
1890
1891         * Shared/WebPreferencesDefinitions.h:
1892         * UIProcess/API/C/WKPreferences.cpp:
1893         (WKPreferencesGetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
1894         (WKPreferencesSetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
1895         * UIProcess/API/C/WKPreferencesRef.h:
1896         * UIProcess/API/Cocoa/WKWebView.mm:
1897         (-[WKWebView _initializeWithConfiguration:]):
1898         * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
1899         (-[WKWebViewConfiguration init]):
1900         (-[WKWebViewConfiguration copyWithZone:]):
1901         (-[WKWebViewConfiguration _setAllowMediaContentTypesRequiringHardwareSupportAsFallback:]):
1902         (-[WKWebViewConfiguration _allowMediaContentTypesRequiringHardwareSupportAsFallback]):
1903         * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
1904         * WebProcess/WebPage/WebPage.cpp:
1905         (WebKit::WebPage::updatePreferences):
1906
1907 2017-07-14  Chris Dumez  <cdumez@apple.com>
1908
1909         Possible crash under NetworkSocketStream::didFailSocketStream()
1910         https://bugs.webkit.org/show_bug.cgi?id=174526
1911         <rdar://problem/32831441>
1912
1913         Reviewed by Brent Fulgham.
1914
1915         For robustness, initialize the SocketStreamHandleImpl after the other
1916         data members. We are passing |this| to the SocketStreamHandleImpl when
1917         constructing it so it is unsafe to have uninitialized data members
1918         at this point.
1919
1920         * NetworkProcess/NetworkSocketStream.cpp:
1921         (WebKit::NetworkSocketStream::NetworkSocketStream):
1922         * NetworkProcess/NetworkSocketStream.h:
1923
1924 2017-07-14  Michael Catanzaro  <mcatanzaro@igalia.com>
1925
1926         [CMake] Unclear distinction between WebKitHelpers and WebKitMacros
1927         https://bugs.webkit.org/show_bug.cgi?id=153189
1928
1929         Reviewed by Antonio Gomes.
1930
1931         New location for macros that are exclusively needed here.
1932
1933         * CMakeLists.txt:
1934
1935 2017-07-14  Brady Eidson  <beidson@apple.com>
1936
1937         Make sure all CFHTTPCookieStorageRefs we create are scheduled.
1938         <rdar://problem/33221110> and https://bugs.webkit.org/show_bug.cgi?id=174513
1939
1940         Reviewed by Tim Horton.
1941
1942         Whenever we create a CFHTTPCookieStorage from identifying data it is unscheduled.
1943         We need to schedule it on a RunLoop.
1944         
1945         This patch also cleans up the creation of the identifying data itself.
1946         
1947         * NetworkProcess/mac/RemoteNetworkingContext.mm:
1948         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
1949         
1950         * Shared/cf/CookieStorageUtilsCF.cpp: Added.
1951         (WebKit::cookieStorageFromIdentifyingData):
1952         (WebKit::identifyingDataFromCookieStorage):
1953         * Shared/cf/CookieStorageUtilsCF.h: Added.
1954         
1955         * Shared/mac/ChildProcessMac.mm:
1956         (WebKit::ChildProcess::setSharedHTTPCookieStorage):
1957         
1958         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1959         (WebKit::WebProcessPool::platformInitializeWebProcess):
1960         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
1961         
1962         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1963         (WebKit::WebsiteDataStore::parameters):
1964         
1965         * WebKit.xcodeproj/project.pbxproj:
1966         
1967         * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
1968         (WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession):
1969
1970 2017-07-14  Chris Dumez  <cdumez@apple.com>
1971
1972         Potential null-dereference under NetworkRTCProvider::resolvedName()
1973         https://bugs.webkit.org/show_bug.cgi?id=174507
1974         <rdar://problem/32597868>
1975
1976         Reviewed by Youenn Fablet.
1977
1978         NetworkRTCProvider::resolvedName() could do a null dereference of m_connection
1979         because m_connection is nullified in NetworkRTCProvider::close() but resolvers
1980         were only closed later on in the NetworkRTCProvider destructor.
1981
1982         To address the issue, we now stop DNS resolvers earlier, in NetworkRTCProvider::close().
1983         Also fix unsafe modification of m_resolvers HashMap when iterating over it.
1984
1985         * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
1986         (WebKit::NetworkRTCProvider::~NetworkRTCProvider):
1987         (WebKit::NetworkRTCProvider::close):
1988         (WebKit::NetworkRTCProvider::Resolver::~Resolver):
1989         (WebKit::NetworkRTCProvider::stopResolver):
1990
1991 2017-07-14  Youenn Fablet  <youenn@apple.com>
1992
1993         Report CoreAudioCaptureSource failure in case shared unit stops working properly
1994         https://bugs.webkit.org/show_bug.cgi?id=174494
1995
1996         Reviewed by Eric Carlson.
1997
1998         In case of capture failure, send a CaptureFailure message so that the
1999         correct behavior happens in the Web process.
2000
2001         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
2002         * WebProcess/cocoa/UserMediaCaptureManager.cpp:
2003         (WebKit::UserMediaCaptureManager::captureFailed):
2004         * WebProcess/cocoa/UserMediaCaptureManager.h:
2005         * WebProcess/cocoa/UserMediaCaptureManager.messages.in:
2006
2007 2017-07-13  Chris Dumez  <cdumez@apple.com>
2008
2009         Better deal with changes to the ResourceLoadStatisticsStore file on disk
2010         https://bugs.webkit.org/show_bug.cgi?id=174487
2011
2012         Reviewed by Brent Fulgham.
2013
2014         Rename WebResourceLoadStatisticsStore's resetDataFromDecoder() to mergeWithDataFromDecoder()
2015         and update it so that it actual merges the data from the disk with the one we have in memory,
2016         instead of replacing it. This avoid data loss.
2017
2018         We leverage the existing WebResourceLoadStatisticsStore::mergeStatistics() to merge the
2019         statistics.
2020
2021         To faciliate merging the operating dates, they are now represented as OperatingDate objects
2022         instead of WallTime objects. OperatingDate only include date precision, no time information.
2023         As a result, the merge 2 vectors of OperatingDate objects, we can:
2024         1. Merge the 2 sorted vectors (using std::merge())
2025         2. Get rid of duplicates (easy because of date-level precision)
2026         3. Drop old dates until the vector has at most 30 items.
2027
2028         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp:
2029         (WebKit::ResourceLoadStatisticsPersistentStorage::refreshMemoryStoreFromDisk):
2030         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
2031         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2032         (WebKit::OperatingDate::fromWallTime):
2033         (WebKit::OperatingDate::today):
2034         (WebKit::OperatingDate::secondsSinceEpoch):
2035         (WebKit::OperatingDate::operator==):
2036         (WebKit::OperatingDate::operator<):
2037         (WebKit::OperatingDate::operator<=):
2038         (WebKit::OperatingDate::OperatingDate):
2039         (WebKit::mergeOperatingDates):
2040         (WebKit::WebResourceLoadStatisticsStore::createEncoderFromData):
2041         (WebKit::WebResourceLoadStatisticsStore::mergeWithDataFromDecoder):
2042         (WebKit::WebResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
2043         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
2044         * UIProcess/WebResourceLoadStatisticsStore.h:
2045
2046 2017-07-13  Dan Bernstein  <mitz@apple.com>
2047
2048         Removed empty project directories left behind after the rename
2049
2050         * WebKit2.xcodeproj: Removed.
2051
2052 2017-07-13  Matthew Hanson  <matthew_hanson@apple.com>
2053
2054         Fix the cMake builds (GTK and WPE.)
2055         https://bugs.webkit.org/show_bug.cgi?id=174164
2056         rdar://problem/33137595
2057
2058         Reviewed by Dan Bernstein.
2059
2060         * Scripts/generate-forwarding-headers.pl:
2061         (collectFrameworkHeaderPaths):
2062         (createForwardingHeadersForFramework):
2063
2064 2017-07-13  Matthew Hanson  <matthew_hanson@apple.com>
2065
2066         Rename WebKit2.xcodeproj to WebKit.xcodeproj.
2067         https://bugs.webkit.org/show_bug.cgi?id=174164
2068         rdar://problem/33137595
2069
2070         Reviewed by Dan Bernstein.
2071
2072         * WebKit.xcodeproj/project.pbxproj: Renamed from Source/WebKit/WebKit2.xcodeproj/project.pbxproj.
2073
2074 2017-07-13  Matthew Hanson  <matthew_hanson@apple.com>
2075
2076         Update tools and configurations after renaming Source/WebKit2 to Source/WebKit.
2077         https://bugs.webkit.org/show_bug.cgi?id=174164
2078         rdar://problem/33137595
2079
2080         Reviewed by Dan Bernstein.
2081
2082         * PlatformGTK.cmake:
2083         * Shared/API/c/wpe/WebKit.h:
2084
2085 2017-07-13  Michael Catanzaro  <mcatanzaro@igalia.com>
2086
2087         Fix compiler warnings when building with GCC 7
2088         https://bugs.webkit.org/show_bug.cgi?id=174463
2089
2090         Reviewed by Darin Adler.
2091
2092         * Platform/IPC/unix/ConnectionUnix.cpp:
2093         (IPC::Connection::sendOutputMessage):
2094
2095 2017-07-13  Chris Dumez  <cdumez@apple.com>
2096
2097         Moved filesystem code out of WebResourceLoadStatisticsStore class
2098         https://bugs.webkit.org/show_bug.cgi?id=174435
2099
2100         Reviewed by Brent Fulgham.
2101
2102         Moved filesystem code out of WebResourceLoadStatisticsStore class and into
2103         a new ResourceLoadStatisticsPersistentStorage class to decrease complexity.
2104
2105         * CMakeLists.txt:
2106         * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
2107         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp: Added.
2108         (WebKit::hasFileChangedSince):
2109         (WebKit::createDecoderForFile):
2110         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
2111         (WebKit::ResourceLoadStatisticsPersistentStorage::~ResourceLoadStatisticsPersistentStorage):
2112         (WebKit::ResourceLoadStatisticsPersistentStorage::storageDirectoryPath):
2113         (WebKit::ResourceLoadStatisticsPersistentStorage::resourceLogFilePath):
2114         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk):
2115         (WebKit::ResourceLoadStatisticsPersistentStorage::stopMonitoringDisk):
2116         (WebKit::ResourceLoadStatisticsPersistentStorage::refreshMemoryStoreFromDisk):
2117         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
2118         (WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk):
2119         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
2120         (WebKit::ResourceLoadStatisticsPersistentStorage::clear):
2121         (WebKit::ResourceLoadStatisticsPersistentStorage::finishAllPendingWorkSynchronously):
2122         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
2123         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h: Added.
2124         * UIProcess/Storage/ios/ResourceLoadStatisticsPersistentStorageIOS.mm: Added.
2125         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
2126         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2127         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
2128         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2129         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
2130         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
2131         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
2132         (WebKit::WebResourceLoadStatisticsStore::resetDataFromDecoder):
2133         * UIProcess/WebResourceLoadStatisticsStore.h:
2134         * WebKit2.xcodeproj/project.pbxproj:
2135
2136 2017-07-13  Chris Dumez  <cdumez@apple.com>
2137
2138         Unreviewed, rolling out r219453.
2139
2140         Seems to cause some crashes on the bots
2141
2142         Reverted changeset:
2143
2144         "Moved filesystem code out of WebResourceLoadStatisticsStore
2145         class"
2146         https://bugs.webkit.org/show_bug.cgi?id=174435
2147         http://trac.webkit.org/changeset/219453
2148
2149 2017-07-13  Jeremy Jones  <jeremyj@apple.com>
2150
2151         Fix style. Use #pragma once in VideoFullscreen and PlaybackSession headers.
2152         https://bugs.webkit.org/show_bug.cgi?id=174448
2153
2154         Reviewed by Eric Carlson.
2155
2156         No behavior change.
2157
2158         * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
2159         * WebProcess/cocoa/WebVideoFullscreenManager.h:
2160
2161 2017-07-13  Jeremy Jones  <jeremyj@apple.com>
2162
2163         Style fix. Replace strongThis with protectedThis.
2164         https://bugs.webkit.org/show_bug.cgi?id=174444
2165
2166         Reviewed by Eric Carlson.
2167
2168         Rename, no behavior change.
2169
2170         * WebProcess/cocoa/WebVideoFullscreenManager.mm:
2171         (WebKit::WebVideoFullscreenManager::didSetupFullscreen):
2172         (WebKit::WebVideoFullscreenManager::didEnterFullscreen):
2173         (WebKit::WebVideoFullscreenManager::didExitFullscreen):
2174         (WebKit::WebVideoFullscreenManager::didCleanupFullscreen):
2175
2176 2017-07-13  Chris Dumez  <cdumez@apple.com>
2177
2178         Moved filesystem code out of WebResourceLoadStatisticsStore class
2179         https://bugs.webkit.org/show_bug.cgi?id=174435
2180
2181         Reviewed by Brent Fulgham.
2182
2183         Moved filesystem code out of WebResourceLoadStatisticsStore class and into
2184         a new ResourceLoadStatisticsPersistentStorage class to decrease complexity.
2185
2186         * CMakeLists.txt:
2187         * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
2188         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.cpp: Added.
2189         (WebKit::hasFileChangedSince):
2190         (WebKit::createDecoderForFile):
2191         (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage):
2192         (WebKit::ResourceLoadStatisticsPersistentStorage::~ResourceLoadStatisticsPersistentStorage):
2193         (WebKit::ResourceLoadStatisticsPersistentStorage::storageDirectoryPath):
2194         (WebKit::ResourceLoadStatisticsPersistentStorage::resourceLogFilePath):
2195         (WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk):
2196         (WebKit::ResourceLoadStatisticsPersistentStorage::stopMonitoringDisk):
2197         (WebKit::ResourceLoadStatisticsPersistentStorage::refreshMemoryStoreFromDisk):
2198         (WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
2199         (WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk):
2200         (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore):
2201         (WebKit::ResourceLoadStatisticsPersistentStorage::clear):
2202         (WebKit::ResourceLoadStatisticsPersistentStorage::finishAllPendingWorkSynchronously):
2203         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
2204         * UIProcess/Storage/ResourceLoadStatisticsPersistentStorage.h: Added.
2205         * UIProcess/Storage/ios/ResourceLoadStatisticsPersistentStorageIOS.mm: Added.
2206         (WebKit::ResourceLoadStatisticsPersistentStorage::excludeFromBackup):
2207         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2208         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
2209         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2210         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
2211         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
2212         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
2213         (WebKit::WebResourceLoadStatisticsStore::resetDataFromDecoder):
2214         * UIProcess/WebResourceLoadStatisticsStore.h:
2215         * WebKit2.xcodeproj/project.pbxproj:
2216
2217 2017-07-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2218
2219         Web Automation: evaluateJavaScriptFunction should start the callback timeout after the function is applied
2220         https://bugs.webkit.org/show_bug.cgi?id=174421
2221
2222         Reviewed by Brian Burg.
2223
2224         This is causing selenium test testShouldNotTimeoutIfScriptCallsbackInsideAZeroTimeout to fail, because
2225         JavaScriptTimeout error is generated unexpectedly. When no script timeout is specified, 0 is used by default,
2226         which means we do a setTimeout with 0 and then the script does another setTimeout with 0, but ours is dispatched
2227         before and reportTimeoutError is called. We should start our timeout after applying the function, and only if
2228         the result hasn't been reported yet.
2229
2230         * WebProcess/Automation/WebAutomationSessionProxy.js:
2231         (let.AutomationSessionProxy.prototype.evaluateJavaScriptFunction):
2232
2233 2017-07-12  Wenson Hsieh  <wenson_hsieh@apple.com>
2234
2235         [iOS DnD] [WK2] Add SPI to enable, disable, or follow default behavior for DnD on a WKWebView
2236         https://bugs.webkit.org/show_bug.cgi?id=174440
2237         <rdar://problem/33272627>
2238
2239         Reviewed by Beth Dakin.
2240
2241         Adds a new _dragInteractionPolicy property to WKWebView, which an internal client may use to always allow
2242         dragging out of the web view (_WKDragInteractionPolicyAlwaysEnable), never allow
2243         (_WKDragInteractionPolicyAlwaysDisable) or just use the default device-dependent behavior
2244         (_WKDragInteractionPolicyDefault).
2245
2246         Also removes an extraneous class from WKContentViewInteraction.mm that is no longer used anywhere.
2247
2248         * UIProcess/API/Cocoa/WKWebView.mm:
2249         (-[WKWebView _initializeWithConfiguration:]):
2250
2251         Set _dragInteractionPolicy to _WKDragInteractionPolicyDefault upon initialization.
2252
2253         (-[WKWebView _dragInteractionPolicy]):
2254         (-[WKWebView _setDragInteractionPolicy:]):
2255         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2256         * UIProcess/ios/WKContentViewInteraction.h:
2257         * UIProcess/ios/WKContentViewInteraction.mm:
2258         (shouldEnableDragInteractionForPolicy):
2259         (-[WKContentView _didChangeDragInteractionPolicy]):
2260
2261         Called by the WKWebView when its _dragInteractionPolicy changes. The content view updates its
2262         UIDragInteraction's -enabled property here in response.
2263
2264         (-[WKContentView setupDataInteractionDelegates]):
2265
2266 2017-07-12  Said Abou-Hallawa  <sabouhallawa@apple.com>
2267
2268         Async image decoding for large images should be disabled by default
2269         https://bugs.webkit.org/show_bug.cgi?id=174432
2270
2271         Reviewed by Simon Fraser.
2272
2273         -- Replace every reference to GraphicsLayerPaintFlags::Snapshotting by
2274            GraphicsLayerPaintFlags::None and every GraphicsLayerPaintFlags::None
2275            by AllowAsyncImageDecoding.
2276         -- Replace setting the bit PaintBehaviorSnapshotting in an existing PaintBehavoir 
2277            by resetting the bit PaintBehaviorAllowAsyncImageDecoding.
2278
2279         * Shared/mac/RemoteLayerBackingStore.mm:
2280         (WebKit::RemoteLayerBackingStore::drawInContext):
2281         * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
2282         (WebKit::imageForRect):
2283         * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
2284         (WebKit::InjectedBundleRangeHandle::renderedImage):
2285
2286 2017-07-12  Eric Carlson  <eric.carlson@apple.com>
2287
2288         [MediaStream] a capture source failure should end the MediaStreamTrack
2289         https://bugs.webkit.org/show_bug.cgi?id=174375
2290
2291         Reviewed by Youenn Fablet.
2292
2293         * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
2294         (WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged): Consolidate start/end.
2295         (WebKit::UserMediaPermissionRequestManagerProxy::startedCaptureSession): Deleted.
2296         (WebKit::UserMediaPermissionRequestManagerProxy::endedCaptureSession): Deleted.
2297         * UIProcess/UserMediaPermissionRequestManagerProxy.h:
2298
2299         * UIProcess/WebPageProxy.cpp:
2300         (WebKit::WebPageProxy::isPlayingMediaDidChange): Call captureStateChanged if the capture 
2301         state changes. Consider interrupted flags.
2302
2303 2017-07-12  Daniel Bates  <dabates@apple.com>
2304
2305         NavigationAction should track whether the navigation was initiated by the main frame
2306         https://bugs.webkit.org/show_bug.cgi?id=174386
2307         <rdar://problem/33245267>
2308
2309         Reviewed by Brady Eidson.
2310
2311         * WebProcess/WebPage/WebInspector.cpp:
2312         (WebKit::WebInspector::openInNewTab): Pass whether the load was initiated by the main frame
2313         when instantiating the NavigationAction.
2314
2315 2017-07-12  Daniel Bates  <dabates@apple.com>
2316
2317         Rename NavigationInitiatedByMainFrame to InitiatedByMainFrame
2318         https://bugs.webkit.org/show_bug.cgi?id=174427
2319
2320         Rubber-stamped by Brady Eidson.
2321
2322         * WebProcess/Plugins/PluginView.cpp:
2323         (WebKit::PluginView::loadURL):
2324         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2325         (WebKit::WebFrameLoaderClient::dispatchCreatePage):
2326         * WebProcess/WebPage/WebInspector.cpp:
2327         (WebKit::WebInspector::openInNewTab):
2328
2329 2017-07-12  Matt Lewis  <jlewis3@apple.com>
2330
2331         Unreviewed, rolling out r219401.
2332
2333         This revision rolled out the previous patch, but after talking
2334         with reviewer, a rebaseline is what was needed.Rolling back in
2335         before rebaseline.
2336
2337         Reverted changeset:
2338
2339         "Unreviewed, rolling out r219379."
2340         https://bugs.webkit.org/show_bug.cgi?id=174400
2341         http://trac.webkit.org/changeset/219401
2342
2343 2017-07-12  Daniel Bates  <dabates@apple.com>
2344
2345         Update description of Secure Contexts experimental flag
2346         https://bugs.webkit.org/show_bug.cgi?id=174401
2347
2348         Reviewed by Simon Fraser.
2349
2350         Change the description of the Secure Contexts experimental flag from "isSecureContext attribute"
2351         to "Secure Contexts API".
2352
2353         * Shared/WebPreferencesDefinitions.h:
2354
2355 2017-07-12  Matt Lewis  <jlewis3@apple.com>
2356
2357         Unreviewed, rolling out r219379.
2358
2359         This revision caused a consistent failure in the test
2360         fast/dom/Window/property-access-on-cached-window-after-frame-
2361         removed.html.
2362
2363         Reverted changeset:
2364
2365         "Remove NAVIGATOR_HWCONCURRENCY"
2366         https://bugs.webkit.org/show_bug.cgi?id=174400
2367         http://trac.webkit.org/changeset/219379
2368
2369 2017-07-12  Zan Dobersek  <zdobersek@igalia.com>
2370
2371         [WPE] Use libepoxy
2372         https://bugs.webkit.org/show_bug.cgi?id=172104
2373
2374         Reviewed by Michael Catanzaro.
2375
2376         * PlatformWPE.cmake: Drop the EGL_INCLUDE_DIRS compilation flags.
2377         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
2378         Include <epoxy/gl.h> when compiling with libepoxy usage enabled.
2379
2380 2017-07-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2381
2382         Web Automation: upstream safaridriver's JavaScript atom implementations
2383         https://bugs.webkit.org/show_bug.cgi?id=172060
2384         <rdar://problem/32168187>
2385
2386         Reviewed by Brian Burg.
2387
2388         * UIProcess/Automation/atoms/ElementAttribute.js: Added.
2389         * UIProcess/Automation/atoms/ElementDisplayed.js: Added.
2390         * UIProcess/Automation/atoms/FindNodes.js: Added.
2391         * UIProcess/Automation/atoms/FormElementClear.js: Added.
2392         * UIProcess/Automation/atoms/FormSubmit.js: Added.
2393
2394 2017-07-11  Dean Jackson  <dino@apple.com>
2395
2396         Remove NAVIGATOR_HWCONCURRENCY
2397         https://bugs.webkit.org/show_bug.cgi?id=174400
2398
2399         Reviewed by Sam Weinig.
2400
2401         * Configurations/FeatureDefines.xcconfig:
2402
2403 2017-07-11  Ansh Shukla  <ansh_shukla@apple.com>
2404
2405         WKWindowFeatures needs to expose scrollbar, fullscreen, and dialog configuration properties
2406         https://bugs.webkit.org/show_bug.cgi?id=174239
2407
2408         Reviewed by Brady Eidson.
2409
2410         Add a new private header to expose getters for window feature properties already available
2411         in the TFB APIWindowFeatures class. These properties are necessary for Safari to adopt more
2412         modern API.
2413
2414         * UIProcess/API/Cocoa/WKWindowFeatures.mm:
2415         (-[WKWindowFeatures _locationBarVisibility]):
2416         (-[WKWindowFeatures _scrollbarsVisibility]):
2417         (-[WKWindowFeatures _fullscreenDisplay]):
2418         (-[WKWindowFeatures _dialogDisplay]):
2419         * UIProcess/API/Cocoa/WKWindowFeaturesInternal.h: Expose some window features as read-only
2420         properties.
2421         * UIProcess/API/Cocoa/WKWindowFeaturesPrivate.h:
2422         * WebKit2.xcodeproj/project.pbxproj:
2423
2424 2017-07-11  Chris Dumez  <cdumez@apple.com>
2425
2426         Avoid duplicating default parameter values in [WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]
2427         https://bugs.webkit.org/show_bug.cgi?id=174402
2428
2429         Reviewed by Brent Fulgham.
2430
2431         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2432         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
2433         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2434         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
2435         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
2436         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2437         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
2438         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
2439         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
2440         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
2441         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
2442         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
2443         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
2444         (WebKit::WebResourceLoadStatisticsStore::shouldPartitionCookies):
2445         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
2446         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
2447         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
2448         (WebKit::WebResourceLoadStatisticsStore::pruneStatisticsIfNeeded):
2449         (WebKit::WebResourceLoadStatisticsStore::resetParametersToDefaultValues):
2450         * UIProcess/WebResourceLoadStatisticsStore.h:
2451
2452 2017-07-11  Dean Jackson  <dino@apple.com>
2453
2454         Rolling out r219372.
2455
2456         * Configurations/FeatureDefines.xcconfig:
2457
2458 2017-07-11  Dean Jackson  <dino@apple.com>
2459
2460         Remove NAVIGATOR_HWCONCURRENCY
2461         https://bugs.webkit.org/show_bug.cgi?id=174400
2462
2463         Reviewed by Sam Weinig.
2464
2465         * Configurations/FeatureDefines.xcconfig:
2466
2467 2017-07-11  Dean Jackson  <dino@apple.com>
2468
2469         Viewport fit experimental feature should be always on by default
2470         https://bugs.webkit.org/show_bug.cgi?id=174398
2471         <rdar://problem/33248920>
2472
2473         Reviewed by Simon Fraser.
2474
2475         Even though this is experimental, it should be enabled by default, and
2476         not follow the value of DEFAULT_EXPERIMENTAL_FEATURES_ENABLED.
2477
2478         * Shared/WebPreferencesDefinitions.h:
2479
2480 2017-07-11  Adrian Perez de Castro  <aperez@igalia.com>
2481
2482         Fix typo: ContentRuleListStore::nonLegacyDdefaultStore()
2483         https://bugs.webkit.org/show_bug.cgi?id=174387
2484
2485         Reviewed by Michael Catanzaro.
2486
2487         Rename nonLegacyDdefaultStore() to nonLegacyDefaultStore().
2488
2489         * UIProcess/API/APIContentRuleListStore.cpp:
2490         (API::ContentRuleListStore::nonLegacyDefaultStore):
2491         (API::ContentRuleListStore::defaultStore):
2492         * UIProcess/API/APIContentRuleListStore.h:
2493
2494 2017-07-11  Chris Dumez  <cdumez@apple.com>
2495
2496         Simplify primary domain lambda captures in WebResourceLoadStatisticsStore
2497         https://bugs.webkit.org/show_bug.cgi?id=174381
2498
2499         Reviewed by Brent Fulgham.
2500
2501         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2502         (WebKit::isolatedPrimaryDomain):
2503         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
2504         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
2505         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
2506         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
2507         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
2508         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
2509         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
2510         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
2511         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
2512         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
2513         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
2514         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
2515         (WebKit::primaryDomain): Deleted.
2516
2517 2017-07-11  Timothy Hatcher  <timothy@hatcher.name>
2518
2519         Fix a build failure in WebDragClient when !PLATFORM(COCOA) && !PLATFORM(GTK).
2520         https://bugs.webkit.org/show_bug.cgi?id=174372
2521
2522         Reviewed by Beth Dakin.
2523
2524         * WebProcess/WebCoreSupport/WebDragClient.cpp:
2525         (WebKit::WebDragClient::didConcludeEditDrag): Added empty method.
2526
2527 2017-07-11  Brent Fulgham  <bfulgham@apple.com>
2528
2529         Reset cookie partitioning state after network process crashes
2530         https://bugs.webkit.org/show_bug.cgi?id=174306
2531         <rdar://problem/33171605>
2532
2533         Reviewed by Chris Dumez.
2534
2535         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
2536         (WebKit::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler): Move cookie
2537         partioning state code to helper function.
2538         (WebKit::ResourceLoadStatisticsStore::resetPartitionCookiesState): Added.
2539         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
2540         * UIProcess/WebProcessPool.cpp:
2541         (WebKit::WebProcessPool::ensureNetworkProcess): Inform the statistics store that
2542         the network process crashed.
2543         (WebKit::WebProcessPool::terminateNetworkProcess): Mark network process as crashed.
2544         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2545         (WebKit::WebResourceLoadStatisticsStore::networkProcessDidCrash): Reset the cookie
2546         partitioning state after a crash.
2547         * UIProcess/WebResourceLoadStatisticsStore.h:
2548         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2549         (WebKit::WebsiteDataStore::notifyResourceLoadStatisticsNetworkProcessDidCrash): Relay
2550         information to the statistics store.
2551         * UIProcess/WebsiteData/WebsiteDataStore.h:
2552
2553 2017-07-11  Timothy Hatcher  <timothy@hatcher.name>
2554
2555         Fix broken build when !ENABLE(INDEXED_DATABASE)
2556         https://bugs.webkit.org/show_bug.cgi?id=174370
2557
2558         Reviewed by Alex Christensen.
2559
2560         * UIProcess/WebProcessPool.cpp:
2561         (WebKit::WebProcessPool::pageAddedToProcess):
2562
2563 2017-07-11  Youenn Fablet  <youenn@apple.com>
2564
2565         Changing the web page muted state for playing audio should not disable other tabs capture
2566         https://bugs.webkit.org/show_bug.cgi?id=174349
2567
2568         Unreviewed.
2569
2570         * UIProcess/WebPageProxy.cpp:
2571         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage): Fixes non MEDIA_STREAM builds.
2572
2573 2017-07-11  Wenson Hsieh  <wenson_hsieh@apple.com>
2574
2575         Address post-review feedback after http://trac.webkit.org/r219310
2576         https://bugs.webkit.org/show_bug.cgi?id=174300
2577         <rdar://problem/33030639>
2578
2579         Reviewed by Simon Fraser.
2580
2581         Removes plumbing introduced in r219310 for telling WKContentView when the user has finished panning or zooming.
2582         This was previously used to reset allowing asynchronous touch event after preventing the web touch events
2583         gesture recognizer from firing.
2584
2585         However, a far simpler (and much less fragile) solution is to just set _canSendTouchEventsAsynchronously to NO
2586         at the beginning of the gesture, before the first `touchstart` event is dispatched. This way, we always ensure
2587         that _canSendTouchEventsAsynchronously is NO when beginning to process a touch event. This approach is correct
2588         because the only place where we query _canSendTouchEventsAsynchronously is in -_webTouchEventsRecognized:, where
2589         (when we are beginning a new gesture) we are guaranteed that -gestureRecognizer:shouldIgnoreWebTouchWithEvent:
2590         has already been called and _canSendTouchEventsAsynchronously is NO.
2591
2592         Confirmed that the LayoutTests added in r219310 still pass.
2593
2594         * UIProcess/API/Cocoa/WKWebView.mm:
2595         (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
2596         (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
2597         * UIProcess/PageClient.h:
2598         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
2599         * UIProcess/Scrolling/RemoteScrollingTree.cpp:
2600         (WebKit::RemoteScrollingTree::scrollingTreeNodeDidEndPanGesture): Deleted.
2601         * UIProcess/Scrolling/RemoteScrollingTree.h:
2602         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
2603         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
2604         (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
2605         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewDidEndPanGesture): Deleted.
2606         * UIProcess/WebPageProxy.h:
2607         * UIProcess/ios/PageClientImplIOS.h:
2608         * UIProcess/ios/PageClientImplIOS.mm:
2609         (WebKit::PageClientImpl::overflowScrollViewDidEndPanGesture): Deleted.
2610         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
2611         (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidEndPanGesture): Deleted.
2612         * UIProcess/ios/WKContentViewInteraction.h:
2613         * UIProcess/ios/WKContentViewInteraction.mm:
2614         (-[WKContentView gestureRecognizer:shouldIgnoreWebTouchWithEvent:]):
2615         (-[WKContentView scrollViewDidEndPanOrPinchGesture]): Deleted.
2616         * UIProcess/ios/WebPageProxyIOS.mm:
2617         (WebKit::WebPageProxy::overflowScrollViewDidEndPanGesture): Deleted.
2618
2619 2017-07-11  Brent Fulgham  <bfulgham@apple.com>
2620
2621         Unreviewed clean-up after r219323
2622
2623         Simplify algorithm slightly based on a suggestion Chris Dumez made in the review.
2624
2625         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2626         (WebKit::pruneResources): Don't create a second variable to track the pruning operation.
2627
2628 2017-07-11  Alex Christensen  <achristensen@webkit.org>
2629
2630         SharedBuffer::size should return a size_t
2631         https://bugs.webkit.org/show_bug.cgi?id=174328
2632
2633         Reviewed by Andreas Kling.
2634
2635         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2636         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
2637
2638 2017-07-11  Youenn Fablet  <youenn@apple.com>
2639
2640         We should do ICE candidate filtering at the Document level
2641         https://bugs.webkit.org/show_bug.cgi?id=173861
2642         <rdar://problem/33122058>
2643
2644         Reviewed by Eric Carlson.
2645
2646         Removing ICE candidate filtering handling at UIProcess level.
2647         ICE candidate filtering is now disabled at UserMediaRequest level.
2648         WebPage forwards the ICE candidate filtering option to the page so as to set
2649         the default option correctly for every document of the page.
2650
2651         * UIProcess/UserMediaProcessManager.cpp:
2652         (WebKit::UserMediaProcessManager::willCreateMediaStream):
2653         (WebKit::UserMediaProcessManager::endedCaptureSession):
2654         * WebProcess/WebPage/WebPage.cpp:
2655         (WebKit::WebPage::disableICECandidateFiltering):
2656         (WebKit::WebPage::enableICECandidateFiltering):
2657
2658 2017-07-11  Youenn Fablet  <youenn@apple.com>
2659
2660         Changing the web page muted state for playing audio should not disable other tabs capture
2661         https://bugs.webkit.org/show_bug.cgi?id=174349
2662         rdar://problem/33223988
2663
2664         Reviewed by Eric Carlson.
2665
2666         Make sure to mute capturing streams of any other tab if the current tab will start capturing or will unmute existing capturing streams.
2667         Manually tested by having a tab doing capture and another tab playing a video.
2668         Muting or unmuting the tab playing video should not change the capture tab.
2669
2670         * UIProcess/WebPageProxy.cpp:
2671         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage):
2672         (WebKit::WebPageProxy::setMuted):
2673         * UIProcess/WebPageProxy.h:
2674         (WebKit::WebPageProxy::activateMediaStreamCaptureInPage):
2675
2676 2017-07-11  Youenn Fablet  <youenn@apple.com>
2677
2678         NetworkProcess should close listening WebRTC sockets when being suspended
2679         https://bugs.webkit.org/show_bug.cgi?id=174270
2680         rdar://problem/33139844
2681
2682         Reviewed by Chris Dumez.
2683
2684         To prevent potential spinning of the NetworkProcess, NetworkProcess will now close listening sockets when being notified that it will be suspended.
2685         When the network process is being suspended, it will stop creating listening sockets, until it resumes.
2686         Future additional efforts might be to improve select/cancel so that we can stop listening sockets at resume time,
2687         or to reimplement part of the stack using CFStream.
2688
2689         Tested through manual testing by going to a website doing WebRTC, homing out so that the network process is suspended and reopening Safari.
2690
2691         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
2692         (WebKit::NetworkConnectionToWebProcess::cleanupForSuspension):
2693         Proxying call to clean for suspension to rtc provider so that it will
2694         close listening sockets.
2695         (WebKit::NetworkConnectionToWebProcess::resumeFromSuspension): Authorizing back listening sockets.
2696         * NetworkProcess/NetworkConnectionToWebProcess.h:
2697         (WebKit::NetworkConnectionToWebProcess::cleanupForSuspension):
2698         Clean-up is done asynchronously as it can happen in background threads.
2699         Hence why passing a callback as parameter.
2700         * NetworkProcess/NetworkProcess.cpp:
2701         (WebKit::NetworkProcess::notifyProcessReadyToSuspend): Helper routine
2702         to notify UI process that network process clean up is done.
2703         (WebKit::TaskCounter::TaskCounter): Helper class to call notifyProcessReadyToSuspend when sded.
2704         (WebKit::TaskCounter::~TaskCounter):
2705         (WebKit::NetworkProcess::actualPrepareToSuspend): Doing the clean-up for each connection that needs it.
2706         Making sure to notify UI process of clean-up being completed once all connections are cleaned.
2707         (WebKit::NetworkProcess::processWillSuspendImminently):
2708         (WebKit::NetworkProcess::prepareToSuspend):
2709         (WebKit::NetworkProcess::processDidResume): Reenable listening sockets.
2710         * NetworkProcess/NetworkProcess.h:
2711         * NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
2712         (WebKit::LibWebRTCSocketClient::LibWebRTCSocketClient):
2713         * NetworkProcess/webrtc/LibWebRTCSocketClient.h: Adding type getter and making close public.
2714         Used by NetworkRTCProvider to identifiy listening sockets and close them.
2715         * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
2716         (WebKit::NetworkRTCProvider::closeListeningSockets): We close the webrtc socket
2717         and we also notify the Web Process that the socket is closed so that it can take actions to recreate some if needed.
2718         (WebKit::NetworkRTCProvider::finishClosingListeningSockets):
2719         * NetworkProcess/webrtc/NetworkRTCProvider.h:
2720         (WebKit::NetworkRTCProvider::authorizeListeningSockets): Authorize creation of listening sockets.
2721
2722 2017-07-10  Brent Fulgham  <bfulgham@apple.com>
2723
2724         Resource Load Statistics: Prune statistics in orders of importance
2725         https://bugs.webkit.org/show_bug.cgi?id=174215
2726         <rdar://problem/33164403>
2727
2728         Unreviewed test correction.
2729
2730         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2731         (WebKit::pruneResources): The revised algorithm did not update the remaining
2732         count to be pruned, causing a test failure.
2733
2734 2017-07-10  John Wilander  <wilander@apple.com>
2735
2736         Resource Load Statistics: Prune statistics in orders of importance
2737         https://bugs.webkit.org/show_bug.cgi?id=174215
2738         <rdar://problem/33164403>
2739
2740         Reviewed by Chris Dumez.
2741
2742         New functionality. Prunes statistics in this order:
2743         1. Non-prevalent resources without user interaction.
2744         2. Prevalent resources without user interaction.
2745         3. Non-prevalent resources with user interaction.
2746         4. Prevalent resources with user interaction.
2747
2748         * Shared/WebCoreArgumentCoders.cpp:
2749         (IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
2750         (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
2751             Added timestamp field lastSeen.
2752         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2753         (-[WKWebsiteDataStore _resourceLoadStatisticsSetLastSeen:forHost:]):
2754         (-[WKWebsiteDataStore _resourceLoadStatisticsSetMaxStatisticsEntries:]):
2755         (-[WKWebsiteDataStore _resourceLoadStatisticsSetPruneEntriesDownTo:]):
2756         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
2757             Test infrastructure.
2758         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
2759         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
2760         (WebKit::ResourceLoadStatisticsStore::setMaxStatisticsEntries):
2761             Test infrastructure.
2762         (WebKit::ResourceLoadStatisticsStore::setPruneEntriesDownTo):
2763             Test infrastructure.
2764         (WebKit::sortAndPrune):
2765             Convenience function.
2766         (WebKit::ResourceLoadStatisticsStore::pruneStatisticsIfNeeded):
2767             The new pruning function.
2768         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
2769         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2770         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2771             Now calls ResourceLoadStatisticsStore::pruneStatisticsIfNeeded().
2772         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
2773             Test infrastructure.
2774         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
2775             Test infrastructure.
2776         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
2777             Test infrastructure.
2778         * UIProcess/WebResourceLoadStatisticsStore.h:
2779
2780 2017-07-10  Dean Jackson  <dino@apple.com>
2781
2782         const() experimental feature should always be on by default
2783         https://bugs.webkit.org/show_bug.cgi?id=174341
2784         <rdar://problem/33228603>
2785
2786         Reviewed by Simon Fraser.
2787
2788         Even though this is experimental, it should be enabled by default, and
2789         not follow the value of DEFAULT_EXPERIMENTAL_FEATURES_ENABLED.
2790
2791         * Shared/WebPreferencesDefinitions.h:
2792
2793 2017-07-10  Chris Dumez  <cdumez@apple.com>
2794
2795         [iOS] _didCommitLayerTree should avoid calling [scrollView setZoomScale] unnecessarily
2796         https://bugs.webkit.org/show_bug.cgi?id=174326
2797         <rdar://problem/33150490>
2798
2799         Reviewed by Simon Fraser.
2800
2801         Only call [scrollView setZoomScale] if the new zoom scale is actually different to
2802         avoid doing unnecessary work in UIKit.
2803
2804         * UIProcess/API/Cocoa/WKWebView.mm:
2805         (-[WKWebView _didCommitLayerTree:]):
2806
2807 2017-07-10  Chris Dumez  <cdumez@apple.com>
2808
2809         Merge ResourceLoadStatisticsStore into WebResourceLoadStatisticsStore
2810         https://bugs.webkit.org/show_bug.cgi?id=174203
2811
2812         Reviewed by Brent Fulgham.
2813
2814         Merge ResourceLoadStatisticsStore into WebResourceLoadStatisticsStore. The 2 classes
2815         have a similar purpose and there is no clean separation between the 2. It makes more
2816         sense to have a single store class for resource load statistics.
2817
2818         If we want to simplify the WebResourceLoadStatisticsStore class, I think it'd make
2819         more sense to split the file system I/O code out. This code adds quite a bit of
2820         complexity.
2821
2822         * CMakeLists.txt:
2823         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2824         (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]):
2825         (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]):
2826         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStore]):
2827         (-[WKWebsiteDataStore _resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:]):
2828         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
2829         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp: Removed.
2830         * UIProcess/Storage/ResourceLoadStatisticsStore.h: Removed.
2831         * UIProcess/WebResourceLoadStatisticsStore.cpp:
2832         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
2833         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
2834         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
2835         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
2836         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
2837         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
2838         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
2839         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
2840         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
2841         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
2842         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
2843         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
2844         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
2845         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
2846         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
2847         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
2848         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
2849         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
2850         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
2851         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
2852         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
2853         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
2854         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate):
2855         (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
2856         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemory):
2857         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
2858         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
2859         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
2860         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
2861         (WebKit::WebResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
2862         (WebKit::WebResourceLoadStatisticsStore::createEncoderFromData):
2863         (WebKit::WebResourceLoadStatisticsStore::populateFromDecoder):
2864         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
2865         (WebKit::WebResourceLoadStatisticsStore::mergeStatistics):
2866         (WebKit::WebResourceLoadStatisticsStore::shouldPartitionCookies):
2867         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
2868         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
2869         (WebKit::WebResourceLoadStatisticsStore::processStatistics):
2870         (WebKit::WebResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction):
2871         (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
2872         (WebKit::WebResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
2873         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsExpired):
2874         * UIProcess/WebResourceLoadStatisticsStore.h:
2875         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
2876         (WebKit::sortedPrevalentResourceTelemetry):
2877         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
2878         * UIProcess/WebResourceLoadStatisticsTelemetry.h:
2879         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2880         (WebKit::WebsiteDataStore::removeData):
2881         * WebKit2.xcodeproj/project.pbxproj:
2882
2883 2017-07-10  Wenson Hsieh  <wenson_hsieh@apple.com>
2884
2885         [WK2] Ignore touch events that interrupt platform-driven momentum scrolling
2886         https://bugs.webkit.org/show_bug.cgi?id=174300
2887         <rdar://problem/33030639>
2888
2889         Reviewed by Simon Fraser.
2890
2891         Adds support for immediately failing WKContentView's UIWebTouchEventsGestureRecognizer if any touch interrupts
2892         scroll view deceleration. Covered by 3 new LayoutTests (see Source/WebCore/ChangeLog).
2893
2894         * Platform/spi/ios/UIKitSPI.h:
2895         * UIProcess/API/Cocoa/WKWebView.mm:
2896         (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
2897         (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
2898         * UIProcess/PageClient.h:
2899         * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
2900         * UIProcess/Scrolling/RemoteScrollingTree.cpp:
2901         (WebKit::RemoteScrollingTree::scrollingTreeNodeDidEndPanGesture):
2902         * UIProcess/Scrolling/RemoteScrollingTree.h:
2903         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
2904         * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
2905         (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
2906         (WebKit::ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewDidEndPanGesture):
2907
2908         Adds plumbing in the UI process to alert the WKContentView when scroll view dragging has ended in an overflow
2909         momentum scrolling region (tracked by an overflow scrolling tree node). This parallels UI process plumbing for
2910         ScrollingTreeOverflowScrollingNodeIOS::overflowScrollViewWillStartPanGesture.
2911
2912         * UIProcess/WebPageProxy.h:
2913         * UIProcess/ios/PageClientImplIOS.h:
2914         * UIProcess/ios/PageClientImplIOS.mm:
2915         (WebKit::PageClientImpl::overflowScrollViewDidEndPanGesture):
2916         * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
2917         (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidEndPanGesture):
2918         * UIProcess/ios/WKContentViewInteraction.h:
2919         * UIProcess/ios/WKContentViewInteraction.mm:
2920         (-[WKContentView scrollViewDidEndPanOrPinchGesture]):
2921
2922         When the dragging phase of a scroll gesture ends, ensure that _canSendTouchEventsAsynchronously is reset to NO.
2923         When touches are not being prevented, this flag is set to YES in -scrollViewWillStartPanOrPinchGesture: and
2924         normally reset to NO in -_webTouchEventsRecognized: after all touch points have been released. However, in the
2925         case where we've prematurely failed the web touch events gesture recognizer after -touchesBegan:,
2926         -_webTouchEventsRecognized: will not be called again in a state where all touches have been released. Thus, we
2927         also need to bookend the place where we begin allowing async touch event dispatch in
2928         -scrollViewWillStartPanOrPinchGesture by disallowing async touch event dispatch in
2929         -scrollViewDidEndPanOrPinchGesture.
2930
2931         This has no impact in the normal case where the user scrolls without momentum, since
2932         -scrollViewDidEndPanOrPinchGesture will fire after async touch events have already been disallowed in
2933         -_webTouchEventsRecognized:, and in the case where the page prevents default on touches, scrolling doesn't
2934         happen anyways, so neither scrollViewWillStartPanOrPinchGesture nor scrollViewDidEndPanOrPinchGesture will be
2935         invoked.
2936
2937         (-[WKContentView gestureRecognizer:shouldIgnoreWebTouchWithEvent:]):
2938
2939         Implements a new SPI hook in UIKit. This serves an identical purpose as -shouldIgnoreWebTouch, but additionally
2940         passes the triggering UIEvent, as well as the gesture recognizer itself (following standard convention for
2941         Objective C delegate methods). Here, we return YES in the case where one or more of the touches recognized by
2942         the gesture is currently interrupting scroll deceleration.
2943
2944         * UIProcess/ios/WebPageProxyIOS.mm:
2945         (WebKit::WebPageProxy::overflowScrollViewDidEndPanGesture):
2946
2947 2017-07-10  Brent Fulgham  <bfulgham@apple.com>
2948
2949         [WK2][macOS] Allow access to com.apple.cfnetwork.cfnetworkagent in the Network Process
2950         https://bugs.webkit.org/show_bug.cgi?id=174320
2951         <rdar://problem/33191856>
2952
2953         Reviewed by Geoffrey Garen.
2954
2955         * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
2956
2957 2017-07-10  Megan Gardner  <megan_gardner@apple.com>
2958
2959         Add location to NavigationActionData
2960         https://bugs.webkit.org/show_bug.cgi?id=174233
2961         <rdar://problem/29165518>
2962
2963         Reviewed by Simon Fraser.
2964         
2965         Add the root view location of a tap to a NavigationAction to vend to Safari.
2966
2967         * Shared/NavigationActionData.cpp:
2968         (WebKit::NavigationActionData::encode):
2969         (WebKit::NavigationActionData::decode):
2970         * Shared/NavigationActionData.h:
2971         * UIProcess/API/APINavigationAction.h:
2972         * UIProcess/API/Cocoa/WKNavigationAction.mm:
2973         (-[WKNavigationAction description]):
2974         (-[WKNavigationAction _clickLocationInRootViewCoordinates]):
2975         * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
2976         * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
2977         (WebKit::clickLocationInRootViewCoordinatesForMouseEvent):
2978         (WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinatesForNavigationAction):
2979         (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
2980         * WebProcess/InjectedBundle/InjectedBundleNavigationAction.h:
2981         (WebKit::InjectedBundleNavigationAction::clickLocationInRootViewCoordinates):
2982         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
2983         (WebKit::WebChromeClient::createWindow):
2984         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2985         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
2986         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
2987
2988 2017-07-03  Brian Burg  <bburg@apple.com>
2989
2990         Web Replay: remove some unused code
2991         https://bugs.webkit.org/show_bug.cgi?id=173903
2992
2993         Rubber-stamped by Joseph Pecoraro.
2994
2995         * Configurations/FeatureDefines.xcconfig:
2996         * WebProcess/WebPage/WebPage.cpp:
2997         (WebKit::WebPage::tryClose):
2998         (WebKit::WebPage::loadRequest):
2999         (WebKit::WebPage::stopLoadingFrame):
3000         (WebKit::WebPage::stopLoading):
3001         (WebKit::WebPage::reload):
3002         (WebKit::WebPage::contextMenuAtPointInWindow):
3003         (WebKit::handleContextMenuEvent):
3004         (WebKit::handleMouseEvent):
3005         (WebKit::handleWheelEvent):
3006         (WebKit::handleKeyEvent):
3007         (WebKit::WebPage::scroll):
3008         (WebKit::WebPage::logicalScroll):
3009
3010 2017-07-10  Chris Dumez  <cdumez@apple.com>
3011
3012         Further WebResourceLoadStatisticsStore / ResourceLoadStatisticsStore clean up
3013         https://bugs.webkit.org/show_bug.cgi?id=174301
3014
3015         Reviewed by Brent Fulgham.
3016
3017         General clean up and various simplifications / optimizations to WebResourceLoadStatisticsStore
3018         and ResourceLoadStatisticsStore classes.
3019
3020         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
3021         (-[WKWebsiteDataStore _resourceLoadStatisticsUpdateCookiePartitioning]):
3022         (-[WKWebsiteDataStore _resourceLoadStatisticsSetShouldPartitionCookies:forHost:]):
3023         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
3024         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
3025         (WebKit::ResourceLoadStatisticsStore::create):
3026         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
3027         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
3028         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
3029         (WebKit::ResourceLoadStatisticsStore::populateFromDecoder):
3030         (WebKit::ResourceLoadStatisticsStore::clearInMemory):
3031         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
3032         (WebKit::ResourceLoadStatisticsStore::updateCookiePartitioning):
3033         (WebKit::ResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
3034         (WebKit::ResourceLoadStatisticsStore::processStatistics):
3035         (WebKit::ResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction):
3036         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
3037         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
3038         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3039         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
3040         (WebKit::WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore):
3041         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
3042         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
3043         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
3044         (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
3045         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
3046         (WebKit::WebResourceLoadStatisticsStore::refreshFromDisk):
3047         (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate):
3048         (WebKit::WebResourceLoadStatisticsStore::resourceLogFilePath):
3049         (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
3050         (WebKit::WebResourceLoadStatisticsStore::scheduleOrWriteStoreToDisk):
3051         (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
3052         (WebKit::WebResourceLoadStatisticsStore::startMonitoringStatisticsStorage):
3053         (WebKit::WebResourceLoadStatisticsStore::platformExcludeFromBackup):
3054         (WebKit::WebResourceLoadStatisticsStore::createDecoderFromDisk):
3055         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
3056         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
3057         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
3058         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
3059         (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains):
3060         (WebKit::WebResourceLoadStatisticsStore::clearInMemory):
3061         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
3062         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
3063         (WebKit::WebResourceLoadStatisticsStore::setDataRecordsBeingRemoved):
3064         * UIProcess/WebResourceLoadStatisticsStore.h:
3065         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
3066         (WebKit::sortedPrevalentResourceTelemetry):
3067         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
3068         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
3069         (WebKit::WebsiteDataStore::updateCookiePartitioningForTopPrivatelyOwnedDomains):
3070         (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
3071         * UIProcess/WebsiteData/WebsiteDataStore.h:
3072
3073 2017-07-10  Michael Catanzaro  <mcatanzaro@igalia.com>
3074
3075         [SOUP] Remove WebKitSoupCookieJarSqlite
3076         https://bugs.webkit.org/show_bug.cgi?id=174310
3077
3078         Reviewed by Carlos Garcia Campos.
3079
3080         It seems WebKitSoupCookieJarSqlite uses exactly the same database format as the upstream
3081         SoupCookieJarDb class. WebKitSoupCookieJarSqlite is a copy of SoupCookieJarSqlite that uses
3082         WebCore's SQLite wrapper and WTF stuff. WebKitSoupCookieJarSqlite exists only because
3083         SoupCookieJarDb is relatively new, and the older SoupCookieJarSqlite class existed only in
3084         libsoup-gnome rather than libsoup proper. The advantage of continuing to use our
3085         WebKitSoupCookieJarSqlite class, besides that we already know it works, is that it utilizes
3086         the same SQLiteDatabase class that is used elsewhere in WebKit. But that's not really any
3087         reason to keep the class around, when SoupCookieJarDb does exactly the same thing. It was
3088         introduced in libsoup 2.42 and that is already our minimum required version, so we can
3089         switch now.
3090
3091         This passes a quick sanity-check of Epiphany's cookies dialog and also TestCookieManager.
3092
3093         * PlatformGTK.cmake:
3094         * PlatformWPE.cmake:
3095         * WebProcess/Cookies/soup/WebCookieManagerSoup.cpp:
3096         (WebKit::WebCookieManager::setCookiePersistentStorage):
3097         * WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.cpp: Removed.
3098         * WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.h: Removed.
3099
3100 2017-07-10  Myles C. Maxfield  <mmaxfield@apple.com>
3101
3102         REGRESSION(r213590): UI process updates the visible content rects more often than it did in iOS 10
3103         https://bugs.webkit.org/show_bug.cgi?id=174282
3104         <rdar://problem/33144344>
3105
3106         Reviewed by Simon Fraser.
3107
3108         In r213590, we accidentally refactored -[WKWebView _didCommitLayerTree:] to call _scheduleVisibleContentRectUpdate
3109         more often. Instead, this should be triggered from inside the "if" statements. 
3110
3111         No tests because there is no behavior change. Performance change is tested in MotionMark.
3112
3113         * UIProcess/API/Cocoa/WKWebView.mm:
3114         (-[WKWebView _isShowingVideoPictureInPicture]):
3115         (-[WKWebView _initializeWithConfiguration:]):
3116         (-[WKWebView goBack]):
3117         (-[WKWebView _didCommitLayerTree:]):
3118         (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
3119         (-[WKWebView _zoomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]):
3120         (-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
3121         (-[WKWebView scrollViewDidScroll:]):
3122         (-[WKWebView _visibleContentRect]):
3123         (-[WKWebView _frameOrBoundsChanged]):
3124         (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
3125         (-[WKWebView _updateVisibleContentRects]):
3126         (-[WKWebView _navigationGestureDidBegin]):
3127         (-[WKWebView _reloadWithoutContentBlockers]):
3128         (-[WKWebView _reloadExpiredOnly]):
3129         (-[WKWebView _setObscuredInsets:]):
3130         (-[WKWebView _setUnobscuredSafeAreaInsets:]):
3131         (-[WKWebView _endAnimatedResize]):
3132         (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
3133         (-[WKWebView _clearOverrideLayoutParameters]):
3134         (-[WKWebView _requestActivatedElementAtPosition:completionBlock:]):
3135         (-[WKWebView _propertiesOfLayerWithID:]):
3136
3137 2017-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
3138
3139         [SOUP] SoupCookieJar is never released (resulting in sqlite temp files lying around)
3140         https://bugs.webkit.org/show_bug.cgi?id=166029
3141
3142         Reviewed by Michael Catanzaro.
3143
3144         Clear the SoupNetworkSession and cookie storage after the main loop quits.
3145
3146         * NetworkProcess/soup/NetworkProcessMainSoup.cpp:
3147         (WebKit::NetworkProcessMainUnix):
3148
3149 2017-07-10  Wenson Hsieh  <wenson_hsieh@apple.com>
3150
3151         [WK2] Action sheets for links fail to present in WebKit2 PDF view
3152         https://bugs.webkit.org/show_bug.cgi?id=174307
3153         <rdar://problem/31412128>
3154
3155         Reviewed by Tim Horton.
3156
3157         Currently, presenting an action sheet for a link always uses the WKActionSheetPresentAtClosestIndicatorRect
3158         codepath, which requires text indicator data for the link. However, when showing an action sheet for a link via
3159         WKPDFView, a text indicator for the link is not included, so the popover rect ends up being an empty rect at the
3160         origin, which causes us to bail from presenting the popover.
3161
3162         To address this, we tweak our heuristic for determining which action sheet presentation style to use, so that we
3163         only use the closest indicator rect for a link if the text indicator data is also present (otherwise, we fall
3164         back to using the element rect). All other behavior is the same.
3165
3166         * UIProcess/ios/WKActionSheetAssistant.mm:
3167         (-[WKActionSheetAssistant showImageSheet]):
3168         (presentationStyleForView):
3169
3170         Refactor _shouldPresentAtTouchLocationForElementRect into presentationStyleForView, a static function that
3171         returns a WKActionSheetPresentationStyle.
3172
3173         (-[WKActionSheetAssistant showLinkSheet]):
3174         (-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]): Deleted.
3175
3176 2017-07-09  Brady Eidson  <beidson@apple.com>
3177
3178         Remove some obsolete WebKitVersionChecks.
3179         https://bugs.webkit.org/show_bug.cgi?id=174294
3180
3181         Reviewed by Dan Bernstein.
3182
3183         * WebProcess/WebPage/WebPage.cpp:
3184         (WebKit::WebPage::updatePreferences):
3185
3186 2017-07-08  Chris Dumez  <cdumez@apple.com>
3187
3188         Simplify WebResourceLoadStatisticsStore / ResourceLoadStatisticsStore
3189         https://bugs.webkit.org/show_bug.cgi?id=174290
3190
3191         Reviewed by Brent Fulgham.
3192
3193         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
3194         (-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]):
3195         (-[WKWebsiteDataStore _resourceLoadStatisticsSubmitTelemetry]):
3196         * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
3197         Rename a couple of functions in the Cocoa SPI for clarity and to match the name
3198         of their internal implementation.
3199
3200         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
3201         (WebKit::ResourceLoadStatisticsStore::create):
3202         (WebKit::ResourceLoadStatisticsStore::ensureResourceStatisticsForPrimaryDomain):
3203         Stylistic changes.
3204
3205         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData):
3206         Make const.
3207
3208         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder):
3209         Use HashMap::add() instead of HashMap::set(). There is not supposed to have any duplicate
3210         keys so add() is sufficient and more efficient.
3211
3212         (WebKit::ResourceLoadStatisticsStore::clearInMemoryAndPersistent): Removed.
3213         clearInMemoryAndPersistent() was only called from WebResourceLoadStatisticsStore and
3214         the m_deletePersistentStoreHandler / m_grandfatherExistingWebsiteDataHandler were both
3215         set by the WebResourceLoadStatisticsStore as well. Therefore, we don't really need this
3216         function, WebResourceLoadStatisticsStore now calls ResourceLoadStatisticsStore::clearInMemory()
3217         instead and takes care of doing what the m_deletePersistentStoreHandler /
3218         m_grandfatherExistingWebsiteDataHandler handlers were doing on its side.
3219
3220         (WebKit::ResourceLoadStatisticsStore::mergeStatistics):
3221         Pass Vector as rvalue reference, as a preparation for a future optimization. Added FIXME
3222         comment about the optimization.
3223
3224         (WebKit::ResourceLoadStatisticsStore::setNotificationCallback): Removed.
3225         (WebKit::ResourceLoadStatisticsStore::setGrandfatherExistingWebsiteDataCallback): Removed.
3226         (WebKit::ResourceLoadStatisticsStore::setDeletePersistentStoreCallback): Removed.
3227         (WebKit::ResourceLoadStatisticsStore::setFireTelemetryCallback): Removed.
3228         Drop those callback setters. WebResourceLoadStatisticsStore is the only client of
3229         ResourceLoadStatisticsStore and those callbacks were always called as a result of
3230         an operation requested by the WebResourceLoadStatisticsStore. Therefore, those are
3231         not needed. WebResourceLoadStatisticsStore can take care of doing what those
3232         callbacks were doing on its side.
3233
3234         (WebKit::ResourceLoadStatisticsStore::processStatistics):
3235         Pass parameter by const reference since we clearly do not intend to transfer ownership of it.
3236
3237         (WebKit::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
3238         (WebKit::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
3239         (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
3240         Stylistic changes.
3241
3242         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords): Removed.
3243         (WebKit::ResourceLoadStatisticsStore::dataRecordsBeingRemoved): Removed.
3244         (WebKit::ResourceLoadStatisticsStore::dataRecordsWereRemoved): Removed.
3245         Those were moved to WebResourceLoadStatisticsStore since they do not require
3246         any access to the statistics, and are only used by WebResourceLoadStatisticsStore.
3247
3248         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
3249
3250         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3251         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
3252         Store registering most callbacks on the coreStore. Instead, the logic of those
3253         callbacks is now inlined in the few methods in WebResourceLoadStatisticsStore
3254         that were causing these callbacks to be called.
3255
3256         (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
3257         Access some methods on WebResourceLoadStatisticsStore instead of the coreStore
3258         since those were moved.
3259
3260         (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
3261         Drop unnecessary mutable for lambda.
3262
3263         (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
3264         Pass parameter as rvalue reference as a preparation for a future optimization.
3265
3266         (WebKit::WebResourceLoadStatisticsStore::hasStatisticsFileChangedSinceLastSync):
3267         Make const.
3268
3269         (WebKit::WebResourceLoadStatisticsStore::submitTelemetry):
3270         Add assertion to make sure this is called on the main thread.
3271
3272         (WebKit::WebResourceLoadStatisticsStore::fireDataModificationHandler): Removed.
3273         This was dispatching to a background queue to call fireDataModificationHandler()
3274         on the ResourceLoadStatisticsStore. The coreStore would then dispatch back on the
3275         main thread to call the WebResourceLoadStatisticsStore's modification handler.
3276         This modification handler was merely calling processStatisticsAndDataRecords().
3277         Therefore, callers of WebResourceLoadStatisticsStore::fireDataModificationHandler()
3278         can call WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() directly
3279         instead.
3280
3281         (WebKit::WebResourceLoadStatisticsStore::fireTelemetryHandler): Removed.
3282         This was calling ResourceLoadStatisticsStore::fireTelemetryHandler(), which was
3283         calling back WebResourceLoadStatisticsStore's fireTelemetryHandler. The handler
3284         in question was merely calling submitTelemetry(). Therefore, callers of
3285         WebResourceLoadStatisticsStore::fireTelemetryHandler() can call
3286         WebResourceLoadStatisticsStore::submitTelemetry() directly instead.
3287
3288         (WebKit::WebResourceLoadStatisticsStore::clearInMemoryAndPersistent):
3289         Call ResourceLoadStatisticsStore::clearInMemory() instead of clearInMemoryAndPersistent(),
3290         which was removed. ResourceLoadStatisticsStore::clearInMemoryAndPersistent() was calling
3291         clearInMemory() and then 2 of WebResourceLoadStatisticsStore's handlers. Instead, we now
3292         call the functions that those handlers were calling directly, thus eliminating the need
3293         for those handlers.
3294
3295         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
3296         Set m_minimumTimeBetweenDataRecordsRemoval directly as it is now store on this class
3297         instead of the coreStore.
3298
3299         (WebKit::WebResourceLoadStatisticsStore::shouldRemoveDataRecords):
3300         (WebKit::WebResourceLoadStatisticsStore::dataRecordsBeingRemoved):
3301         (WebKit::WebResourceLoadStatisticsStore::dataRecordsWereRemoved):
3302         Those were merely moved from the ResourceLoadStatisticsStore.
3303
3304         * UIProcess/WebResourceLoadStatisticsStore.h:
3305
3306         * UIProcess/WebResourceLoadStatisticsTelemetry.cpp:
3307         (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
3308         Check for sortedPrevalentResources.isEmpty() instead of checking if the size
3309         if less than minimumPrevalentResourcesForTelemetry.
3310         ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry() either returns
3311         an empty vector or a vector with more than minimumPrevalentResourcesForTelemetry
3312         items. Therefore, there is no need to expose minimumPrevalentResourcesForTelemetry.
3313
3314 2017-07-08  Yusuke Suzuki  <utatane.tea@gmail.com>
3315
3316         Drop NOSNIFF compile flag
3317         https://bugs.webkit.org/show_bug.cgi?id=174289
3318
3319         Reviewed by Michael Catanzaro.
3320
3321         * Configurations/FeatureDefines.xcconfig:
3322
3323 2017-07-07  Chris Dumez  <cdumez@apple.com>
3324
3325         [WK2] Use a rolling 30-day uptime for processing statistics
3326         https://bugs.webkit.org/show_bug.cgi?id=174235
3327         <rdar://problem/33164381>
3328
3329         Reviewed by Brent Fulgham.
3330
3331         Follow-up fix for r219274 because it caused this test to time out:
3332         http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
3333
3334         The test sets TimeToLiveUserInteraction to 0 so our implementation cannot use
3335         0 as magic value to see if it was set. Instead, use std::optional.
3336
3337         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
3338         (-[WKWebsiteDataStore _resourceLoadStatisticsResetToConsistentState]):
3339         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
3340         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
3341         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired):
3342         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
3343         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3344         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
3345         * UIProcess/WebResourceLoadStatisticsStore.h:
3346
3347 2017-07-07  Brent Fulgham  <bfulgham@apple.com>
3348
3349         [WK2] Use a rolling 30-day uptime for processing statistics
3350         https://bugs.webkit.org/show_bug.cgi?id=174235
3351         <rdar://problem/33164381>
3352
3353         Reviewed by Chris Dumez.
3354
3355         * UIProcess/API/Cocoa/WKWebsiteDataStore.cpp:
3356         (WebKit::WKWebsiteDataStore::_resourceLoadStatisticsResetToConsistentState): Initialize time-to-live to zero by default.
3357         * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
3358         (WebKit::ResourceLoadStatisticsStore::createEncoderFromData): Write out vector
3359         of operating dates.
3360         (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder): Read in vector of
3361         operating dates.
3362         (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction): Check new
3363         convenience method.
3364         (WebKit::ResourceLoadStatisticsStore::markTodayAsOperatingDate): Added.
3365         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired): Added.
3366         * UIProcess/Storage/ResourceLoadStatisticsStore.h:
3367         * UIProcess/WebResourceLoadStatisticsStore.cpp:
3368         (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded): When reading
3369         a new data file, update the current operating date (if needed).
3370         (WebKit::WebResourceLoadStatisticsStore::handleDailyTasks): Roll uptime dates as
3371         needed, then handle telemetry.
3372         * UIProcess/WebResourceLoadStatisticsStore.h:
3373
3374 2017-07-07  Wenson Hsieh  <wenson_hsieh@apple.com>
3375
3376         [iOS DnD] For cross-app drags, 'drop' event handlers are never invoked if dataTransfer.dropEffect is not set while dragging
3377         https://bugs.webkit.org/show_bug.cgi?id=174219
3378         <rdar://problem/32083177>
3379
3380         Reviewed by Ryosuke Niwa.
3381
3382         Tweak some testing SPI to return a drop operation flag instead of whether or not the drop operation was not
3383         UIDropOperationCancel.
3384
3385         * UIProcess/API/Cocoa/WKWebView.mm:
3386         (-[WKWebView _simulateDataInteractionUpdated:]):
3387         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
3388         * UIProcess/ios/WKContentViewInteraction.h:
3389         * UIProcess/ios/WKContentViewInteraction.mm:
3390         (-[WKContentView _simulateDataInteractionUpdated:]):
3391
3392 2017-07-07  Commit Queue  <commit-queue@webkit.org>
3393
3394         Unreviewed, rolling out r219238, r219239, and r219241.
3395         https://bugs.webkit.org/show_bug.cgi?id=174265
3396
3397         "fast/workers/dedicated-worker-lifecycle.html is flaky"
3398         (Requested by yusukesuzuki on #webkit).
3399
3400         Reverted changesets:
3401
3402         "[WTF] Implement WTF::ThreadGroup"
3403         https://bugs.webkit.org/show_bug.cgi?id=174081
3404         http://trac.webkit.org/changeset/219238
3405
3406         "Unreviewed, build fix after r219238"
3407         https://bugs.webkit.org/show_bug.cgi?id=174081
3408         http://trac.webkit.org/changeset/219239
3409
3410         "Unreviewed, CLoop build fix after r219238"
3411         https://bugs.webkit.org/show_bug.cgi?id=174081
3412         http://trac.webkit.org/changeset/219241
3413
3414 2017-07-07  Antti Koivisto  <antti@apple.com>
3415
3416         WKWebSiteDataStore.removeDataOfTypes should wait until disk cache files are actually removed before invoking completion handler
3417         https://bugs.webkit.org/show_bug.cgi?id=174224