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