b9dfeef2ad587871b3b6291d2c43589fe806196a
[WebKit.git] / Source / WebKit / ChangeLog
1 2018-04-24  Jer Noble  <jer.noble@apple.com>
2
3         Don't add system framework paths to FRAMEWORK_SEARCH_PATHS
4         https://bugs.webkit.org/show_bug.cgi?id=184786
5
6         Reviewed by Tim Horton.
7
8         * Configurations/BaseTarget.xcconfig:
9         * DerivedSources.make:
10
11 2018-04-24  Ryan Haddad  <ryanhaddad@apple.com>
12
13         Unreviewed, rolling out r230938.
14
15         Introduced two ProcessSwap API test failures.
16
17         Reverted changeset:
18
19         "Keep around a pre-warmed process when doing process swap on
20         navigation"
21         https://bugs.webkit.org/show_bug.cgi?id=184765
22         https://trac.webkit.org/changeset/230938
23
24 2018-04-24  Zan Dobersek  <zdobersek@igalia.com>
25
26         [CoordGraphics] Remove dead fixed layer code
27         https://bugs.webkit.org/show_bug.cgi?id=184912
28
29         Reviewed by Michael Catanzaro.
30
31         Drop the unused fixed layer handling  code in CoordinatedGraphicsScene.
32         The m_fixedLayers container can be removed, along with the
33         adjustPositionForFixedLayers() method that operated on that container.
34
35         This was the only method that operated with the m_scrollPosition member
36         variable and the contentsPosition argument that's passed to the
37         CoordinatedGraphicsScene::paintToCurrentGLContext() method. Both of
38         these are removed, along with the scrollPosition attribute on the
39         CoordinatedGraphicsState struct.
40
41         * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
42         (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext):
43         (WebKit::CoordinatedGraphicsScene::setLayerState):
44         (WebKit::CoordinatedGraphicsScene::deleteLayer):
45         (WebKit::CoordinatedGraphicsScene::commitSceneState):
46         (WebKit::CoordinatedGraphicsScene::purgeGLResources):
47         (WebKit::CoordinatedGraphicsScene::adjustPositionForFixedLayers): Deleted.
48         * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
49         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
50         (WebKit::ThreadedCompositor::renderLayerTree):
51         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
52         (WebKit::CompositingCoordinator::flushPendingLayerChanges):
53
54 2018-04-24  Zan Dobersek  <zdobersek@igalia.com>
55
56         REGRESSION(r230950): Faulty commit sequencing in CoordinatedGraphicsScene
57         https://bugs.webkit.org/show_bug.cgi?id=184917
58
59         Reviewed by Michael Catanzaro.
60
61         After r230950, current animation state for a given layer is also taken
62         into account when determining whether or not the layer requires a
63         backing store. For that to work properly, all the animation state has
64         to be updated before the backing store work. This patch changes the
65         order of helper method invocations in
66         CoordinatedGraphicsScene::setLayerState() to address that.
67
68         * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
69         (WebKit::CoordinatedGraphicsScene::setLayerState):
70
71 2018-04-24  Zan Dobersek  <zdobersek@igalia.com>
72
73         [CoordGraphics] Remove unused fixed layout functionality
74         https://bugs.webkit.org/show_bug.cgi?id=184908
75
76         Reviewed by Carlos Garcia Campos.
77
78         Ports using the CoordinatedGraphics subsystem don't expose fixed layout
79         support. As such, we're able to remove a lot of unused code and
80         unnecessary USE(COORDINATED_GRAPHICS) special cases in generic sections
81         in both WebCore and WebKit.
82
83         Remove USE(COORDINATED_GRAPHICS) special-casing from the
84         WebPage::setUseFixedLayout() method. This is not possible to enable for
85         the GTK+ and WPE ports that use the CoordinatedGraphics subsytem via
86         API. Removing all this unlocks removing considerable amounts of dead
87         code and complexities in CoordinatedGraphics.
88
89         WebChromeClient::delegatedScrollRequested() method is removed, along
90         with the WebPage::pageDidRequestScroll() method that was only called
91         from there.
92
93         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
94         (WebKit::WebChromeClient::delegatedScrollRequested): Deleted.
95         * WebProcess/WebCoreSupport/WebChromeClient.h:
96         * WebProcess/WebPage/WebPage.cpp:
97         (WebKit::WebPage::setUseFixedLayout):
98         (WebKit::WebPage::pageDidRequestScroll): Deleted.
99         * WebProcess/WebPage/WebPage.h:
100
101 2018-04-24  Zan Dobersek  <zdobersek@igalia.com>
102
103         [CoordGraphics] Avoid painting backing stores for zero-opacity layers
104         https://bugs.webkit.org/show_bug.cgi?id=184143
105
106         Reviewed by Carlos Garcia Campos.
107
108         * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
109         (WebKit::layerShouldHaveBackingStore):
110         Mirror CoordinatedGraphicsLayer's backing store requirements.
111
112 2018-04-23  Daniel Bates  <dabates@apple.com>
113
114         Implement Same-Site cookies
115         https://bugs.webkit.org/show_bug.cgi?id=159464
116         <rdar://problem/27196358>
117
118         Reviewed by Brent Fulgham.
119
120         Pass the Same-Site info through the WebKit abstractions.
121
122         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
123         (WebKit::NetworkConnectionToWebProcess::cookiesForDOM):
124         (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM):
125         (WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue):
126         (WebKit::NetworkConnectionToWebProcess::getRawCookies):
127         * NetworkProcess/NetworkConnectionToWebProcess.h:
128         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
129         * NetworkProcess/NetworkResourceLoader.cpp:
130         (WebKit::NetworkResourceLoader::logCookieInformation const):
131         (WebKit::logBlockedCookieInformation):
132         (logCookieInformationInternal):
133         (NetworkResourceLoader::logCookieInformation):
134         * NetworkProcess/NetworkResourceLoader.h:
135         * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
136         (WebKit::NetworkCache::constructRevalidationRequest):
137         * NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
138         (WebKit::NetworkCache::SubresourceInfo::encode const):
139         (WebKit::NetworkCache::SubresourceInfo::decode):
140         (WebKit::NetworkCache::SubresourceInfo::SubresourceInfo):
141         * NetworkProcess/cache/NetworkCacheSubresourcesEntry.h:
142         (WebKit::NetworkCache::SubresourceInfo::isSameSite const):
143         (WebKit::NetworkCache::SubresourceInfo::isTopSite const): Returns false; subresources do not represent
144         a top-level navigation.
145         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
146         (WebKit::NetworkDataTaskCocoa::isThirdPartyRequest):
147         (WebKit::updateTaskWithFirstPartyForSameSiteCookies):
148         (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
149         (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
150         * UIProcess/WebProcessPool.cpp:
151         (WebKit::WebProcessPool::download):
152         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
153         (WebKit::WebPlatformStrategies::cookiesForDOM):
154         (WebKit::WebPlatformStrategies::setCookiesFromDOM):
155         (WebKit::WebPlatformStrategies::cookieRequestHeaderFieldValue):
156         (WebKit::WebPlatformStrategies::getRawCookies):
157         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
158
159 2018-04-23  Youenn Fablet  <youenn@apple.com>
160
161         Make WebLoaderStrategy send to NetworkResourceLoader necessary parameters to handle full loads in NetworkProcess
162         https://bugs.webkit.org/show_bug.cgi?id=184763
163
164         Reviewed by Chris Dumez.
165
166         Set all required NetworkResourceLoadParameters for asynchronous loads.
167         This includes preflight policy, CSP response headers, SecurityOrigin and content blockers identifier.
168
169         Update NetworkLoadChecker to handle preflight policy.
170         This is not needed right now since sync XHR and ping loads are using the default ConsiderPreflight policy.
171         But this will be needed for XHR/fetch/EventSource loads. 
172
173         * NetworkProcess/NetworkLoadChecker.cpp:
174         (WebKit::NetworkLoadChecker::NetworkLoadChecker):
175         (WebKit::NetworkLoadChecker::checkRedirection):
176         (WebKit::NetworkLoadChecker::validateResponse):
177         (WebKit::NetworkLoadChecker::checkCORSRequest):
178         * NetworkProcess/NetworkLoadChecker.h:
179         (WebKit::NetworkLoadChecker::create):
180         * NetworkProcess/NetworkResourceLoadParameters.cpp:
181         (WebKit::NetworkResourceLoadParameters::encode const):
182         (WebKit::NetworkResourceLoadParameters::decode):
183         * NetworkProcess/NetworkResourceLoadParameters.h:
184         * NetworkProcess/NetworkResourceLoader.cpp:
185         * NetworkProcess/PingLoad.cpp:
186         (WebKit::PingLoad::PingLoad):
187         * WebProcess/Network/WebLoaderStrategy.cpp:
188         (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
189
190 2018-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
191
192         [Extra zoom mode] REGRESSION(230860) Unable to change time input values using UI
193         https://bugs.webkit.org/show_bug.cgi?id=184901
194         <rdar://problem/39664797>
195
196         Reviewed by Tim Horton.
197
198         Fixes the bug by falling back to setting the value of the focused input element in the case where the selection
199         is not editable. Also adds plumbing to make time pickers testable in extra zoom mode.
200
201         * UIProcess/API/Cocoa/WKWebView.mm:
202         (-[WKWebView setTimePickerValueToHour:minute:]):
203         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
204         * UIProcess/ios/WKContentViewInteraction.h:
205         * UIProcess/ios/WKContentViewInteraction.mm:
206         (-[WKContentView setTimePickerValueToHour:minute:]):
207
208         Add plumbing to make it possible for WebKitTestRunner to simulate picking a time from the given hours and
209         minutes. This is currently only implemented for extra zoom mode, but may be implemented for UIKit's time picker
210         as well in the future by adjusting -[WKContentView setTimePickerValueToHour:minute:].
211
212         * WebProcess/WebPage/WebPage.cpp:
213         (WebKit::WebPage::setTextAsync):
214
215 2018-04-23  Saam Barati  <sbarati@apple.com>
216
217         Keep around a pre-warmed process when doing process swap on navigation
218         https://bugs.webkit.org/show_bug.cgi?id=184765
219
220         Reviewed by Ryosuke Niwa.
221
222         This patch makes it so that WebProcessPool prewarms a process when process
223         swap on navigation is turned on. When we do a process swap on navigation,
224         we first try to grab a prewarmed process before creating a new one.
225         
226         We try to be smart about when to create these processes. The initial heuristic
227         that this patch chooses is when we reach the DidFirstVisuallyNonEmptyLayout
228         layout milestone. We're going to try to improve on this heuristic in:
229         https://bugs.webkit.org/show_bug.cgi?id=184899
230         
231         This is a 40% progression on PLT with process swap on navigation turned on.
232
233         * UIProcess/ServiceWorkerProcessProxy.cpp:
234         (WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy):
235         * UIProcess/WebPageProxy.cpp:
236         (WebKit::WebPageProxy::notifyProcessPoolToPrewarm):
237         (WebKit::WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame):
238         * UIProcess/WebPageProxy.h:
239         * UIProcess/WebProcessPool.cpp:
240         (WebKit::WebProcessPool::createNewWebProcess):
241         (WebKit::WebProcessPool::tryTakePrewarmedProcess):
242         (WebKit::WebProcessPool::warmInitialProcess):
243         (WebKit::WebProcessPool::disconnectProcess):
244         (WebKit::WebProcessPool::createWebPage):
245         (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
246         (WebKit::WebProcessPool::processForNavigation):
247         * UIProcess/WebProcessPool.h:
248         * UIProcess/WebProcessProxy.cpp:
249         (WebKit::WebProcessProxy::create):
250         (WebKit::WebProcessProxy::WebProcessProxy):
251         (WebKit::m_isInPrewarmedPool):
252         (WebKit::m_userMediaCaptureManagerProxy): Deleted.
253         * UIProcess/WebProcessProxy.h:
254         (WebKit::WebProcessProxy::isInPrewarmedPool const):
255         (WebKit::WebProcessProxy::setIsInPrewarmedPool):
256
257 2018-04-23  Michael Catanzaro  <mcatanzaro@igalia.com>
258
259         [WPE][GTK] Remove WlUniquePtr<wl_display> footgun
260         https://bugs.webkit.org/show_bug.cgi?id=184405
261
262         Reviewed by Carlos Garcia Campos.
263
264         Switch to std::unique_ptr.
265
266         * UIProcess/gtk/WaylandCompositor.cpp:
267         (WebKit::WaylandCompositor::WaylandCompositor):
268         * UIProcess/gtk/WaylandCompositor.h:
269         (WebKit::WaylandCompositor::DisplayDeleter::operator()):
270
271 2018-04-23  Daniel Bates  <dabates@apple.com>
272
273         Attempt to fix the Apple Internal build following r230921
274         (https://bugs.webkit.org/show_bug.cgi?id=159464)
275
276         Forward declare some SPI. Add availability guard.
277
278         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
279
280 2018-04-23  Zalan Bujtas  <zalan@apple.com>
281
282         [LayoutFormattingContext] Initial commit.
283         https://bugs.webkit.org/show_bug.cgi?id=184896
284
285         Reviewed by Antti Koivisto.
286
287         * Configurations/FeatureDefines.xcconfig:
288
289 2018-04-23  Daniel Bates  <dabates@apple.com>
290
291         Implement Same-Site cookies
292         https://bugs.webkit.org/show_bug.cgi?id=159464
293         <rdar://problem/27196358>
294
295         Reviewed by Brent Fulgham.
296
297         Pass the Same-Site info through the WebKit abstractions.
298
299         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
300         (WebKit::NetworkConnectionToWebProcess::cookiesForDOM):
301         (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM):
302         (WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue):
303         (WebKit::NetworkConnectionToWebProcess::getRawCookies):
304         * NetworkProcess/NetworkConnectionToWebProcess.h:
305         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
306         * NetworkProcess/NetworkResourceLoader.cpp:
307         (WebKit::NetworkResourceLoader::logCookieInformation const):
308         (WebKit::logBlockedCookieInformation):
309         (logCookieInformationInternal):
310         (NetworkResourceLoader::logCookieInformation):
311         * NetworkProcess/NetworkResourceLoader.h:
312         * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
313         (WebKit::NetworkCache::constructRevalidationRequest):
314         * NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
315         (WebKit::NetworkCache::SubresourceInfo::encode const):
316         (WebKit::NetworkCache::SubresourceInfo::decode):
317         (WebKit::NetworkCache::SubresourceInfo::SubresourceInfo):
318         * NetworkProcess/cache/NetworkCacheSubresourcesEntry.h:
319         (WebKit::NetworkCache::SubresourceInfo::isSameSite const):
320         (WebKit::NetworkCache::SubresourceInfo::isTopSite const): Returns false; subresources do not represent
321         a top-level navigation.
322         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
323         (WebKit::NetworkDataTaskCocoa::isThirdPartyRequest):
324         (WebKit::updateTaskWithFirstPartyForSameSiteCookies):
325         (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
326         (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
327         * UIProcess/WebProcessPool.cpp:
328         (WebKit::WebProcessPool::download):
329         * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
330         (WebKit::WebPlatformStrategies::cookiesForDOM):
331         (WebKit::WebPlatformStrategies::setCookiesFromDOM):
332         (WebKit::WebPlatformStrategies::cookieRequestHeaderFieldValue):
333         (WebKit::WebPlatformStrategies::getRawCookies):
334         * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
335
336 2018-04-23  Chris Dumez  <cdumez@apple.com>
337
338         WebProcessProxy frequently re-takes a process assertion for the network process even though is already has one
339         https://bugs.webkit.org/show_bug.cgi?id=184889
340         <rdar://problem/38151530>
341
342         Reviewed by Brady Eidson.
343
344         In ProcessThrottler::updateAssertionNow(), if the new process assertion state is the same
345         as the existing one, then return early. Otherwise, we would end up calling WebProcessProxy::didSetAssertionState()
346         for the same assertion state, which would cause duplicate logging but also some unnecessary work.
347
348         * UIProcess/ProcessThrottler.cpp:
349         (WebKit::ProcessThrottler::updateAssertionNow):
350
351 2018-04-23  Zan Dobersek  <zdobersek@igalia.com>
352
353         [CoordGraphics] Remove unused trajectory cruft in CoordinatedLayerTreeHost, CoordinatedGraphicsLayer
354         https://bugs.webkit.org/show_bug.cgi?id=184881
355
356         Reviewed by Michael Catanzaro.
357
358         The CompositingCoordinator::setVisibleContentsRect() method is always
359         called with a (0,0) FloatPoint value as the trajectory vector parameter,
360         which is already the default value in TiledBackingStore where this ends
361         up. Removing this call chain also enables removing some unnecessary and
362         odd code in the CoordinatedGraphicsLayer class.
363
364         This doesn't yet touch the trajectory logic in the TiledBackingStore
365         class since it's not yet a given this won't be used in the future. But
366         if that will be necessary, hope is to not use it this way.
367
368         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
369         (WebKit::CompositingCoordinator::setVisibleContentsRect):
370         (WebKit::CompositingCoordinator::mainContentsLayer): Deleted.
371         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
372         * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
373         (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
374         * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
375         * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
376         (WebKit::ThreadedCoordinatedLayerTreeHost::didChangeViewport):
377
378 2018-04-23  Fujii Hironori  <Hironori.Fujii@sony.com>
379
380         [Win][WK2] REGRESSION(r230834) 'getpid': identifier not found
381         https://bugs.webkit.org/show_bug.cgi?id=184877
382
383         Reviewed by Yusuke Suzuki.
384
385         * WebProcess/WebPage/WebBackForwardListProxy.cpp:
386         (WebKit::WebBackForwardListProxy::addItem): Use WTF::getCurrentProcessID() instead of getpid().
387         * WebProcess/WebPage/WebPage.cpp:
388         (WebKit::WebPage::goToBackForwardItem): Ditto.
389
390 2018-04-23  Zan Dobersek  <zdobersek@igalia.com>
391
392         [TexMap] Drop RefCounted inheritance off of TextureMapperBackingStore
393         https://bugs.webkit.org/show_bug.cgi?id=184810
394
395         Reviewed by Carlos Garcia Campos.
396
397         CoordinatedBackingStore should inherit directly from RefCounted<> now
398         that TextureMapperBackingStore doesn't anymore.
399
400         * Shared/CoordinatedGraphics/CoordinatedBackingStore.h:
401         * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
402         (WebKit::CoordinatedGraphicsScene::createBackingStoreIfNeeded):
403
404 2018-04-22  Zan Dobersek  <zdobersek@igalia.com>
405
406         [CoordinatedGraphics] Unused contentsSize, coveredRect attributes in CoordinatedGraphicsState
407         https://bugs.webkit.org/show_bug.cgi?id=184811
408
409         Reviewed by Carlos Garcia Campos.
410
411         * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
412         (WebKit::CompositingCoordinator::flushPendingLayerChanges): Stop setting
413         the removed contentsSize and coveredRect attributes. These were only
414         ever set to the appropriate values, but were then never used anywhere.
415
416 2018-04-22  Matt Baker  <mattbaker@apple.com>
417
418         Web Inspector: WebInspectorProxy releases WKWebInspectorProxyObjCAdapter without removing corresponding observer
419         https://bugs.webkit.org/show_bug.cgi?id=184865
420         <rdar://problem/37764960>
421
422         Reviewed by Brian Burg.
423
424         Replace the early return removed in https://bugs.webkit.org/show_bug.cgi?id=177661,
425         so that WKWebInspectorProxyObjCAdapter and the view controller can be reused
426         when reopening the Inspector while the WebView is still alive.
427
428         * UIProcess/mac/WebInspectorProxyMac.mm:
429         (WebKit::WebInspectorProxy::platformCreateFrontendPage):
430
431 2018-04-22  Paul Knight  <pknight@apple.com>
432
433         Add -[WKInputDelegate _webView:decidePolicyForFocusedElement:] so clients can request default focusing behavior
434         https://bugs.webkit.org/show_bug.cgi?id=184844
435
436         Reviewed by Dan Bernstein.
437
438         If a client doesn't implement -[_WKInputDelegate _webView:focusShouldStartInputSession:] the default
439         focus behavior only brings up the keyboard if it's already onscreen, the interaction is user driven,
440         and other factors that even depend on what feature flags are enabled.
441
442         If a client implements _webView:focusShouldStartInputSession:, they don't have a good way to specifiy
443         they'd like to fall back to the default behavior. This makes it difficult for a client to use the
444         default in most cases, but sometimes allow programmatic focus from the page, for example.
445
446         Add a new delegate method -_webView:decidePolicyForFocusedElement: that returns a new enum type
447         _WKFocusStartsInputSessionPolicy. Clients can return _WKFocusStartsInputSessionPolicyAuto to request
448         the default behavior, or _WKFocusStartsInputSessionPolicyAllow / Disallow to directly control whether
449         the keyboard appears to assist the focused node.
450
451         * UIProcess/API/Cocoa/_WKInputDelegate.h:
452         * UIProcess/ios/WKContentViewInteraction.mm:
453         (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
454
455 2018-04-21  Jeremy Jones  <jeremyj@apple.com>
456
457         Disable backward and forward navigation swipes while in fullscreen.
458         https://bugs.webkit.org/show_bug.cgi?id=184656
459         rdar://problem/36057535
460
461         Reviewed by Tim Horton.
462
463         Disable navigation swipes while in fullscreen.
464
465         * UIProcess/Cocoa/ViewGestureController.cpp:
466         (WebKit::ViewGestureController::canSwipeInDirection const):
467
468 2018-04-21  Youenn Fablet  <youenn@apple.com>
469
470         Activate NetworkLoadChecker for media loads
471         https://bugs.webkit.org/show_bug.cgi?id=184841
472
473         Reviewed by Eric Carlson.
474
475         Instantiate a NetworkLoadChecker for NetworkResourceLoader for audio/video loads.
476
477         Move CORS checks for response after handling of 304 checks.
478         For 304 checks, we need to do the CORS checks on the validated cached response, not the 304 received response.
479
480         Updated ResourceError argument coder to explicitly pass the error type
481         as some errors created by NetworkLoadChecker would otherwise be received as General errors by WebProcess.
482         Updated platform data encoding of ResourceError accordingly.
483
484         All changes are covered by regular media loading layout tests.
485
486         * NetworkProcess/NetworkResourceLoader.cpp:
487         (WebKit::shouldUseNetworkLoadChecker):
488         (WebKit::NetworkResourceLoader::didReceiveResponse):
489         * Shared/WebCoreArgumentCoders.cpp:
490         (IPC::ArgumentCoder<ResourceError>::encode):
491         (IPC::ArgumentCoder<ResourceError>::decode):
492         * Shared/mac/WebCoreArgumentCodersMac.mm:
493         (IPC::ArgumentCoder<ResourceError>::encodePlatformData):
494         (IPC::ArgumentCoder<ResourceError>::decodePlatformData):
495         We need to set the type after decoding the NSError as ResourceError tries to guess the type from NSError data.
496         * Shared/soup/WebCoreArgumentCodersSoup.cpp:
497         (IPC::ArgumentCoder<ResourceError>::encodePlatformData):
498         (IPC::ArgumentCoder<ResourceError>::decodePlatformData):
499
500 2018-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
501
502         [SOUP] Do TLS error checking on GTlsConnection::accept-certificate
503         https://bugs.webkit.org/show_bug.cgi?id=184480
504
505         Reviewed by Michael Catanzaro.
506
507         Connect to GTlsConnection::accept-certificate signal instead of SoupMessage::notify::tls-errors to perform the
508         TLS errors check.
509
510         * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
511         (WebKit::NetworkDataTaskSoup::createRequest): Do not connect to SoupMessage::notify::tls-errors.
512         (WebKit::NetworkDataTaskSoup::tlsConnectionAcceptCertificateCallback): Call tlsConnectionAcceptCertificate() is
513         the task is still ongoing.
514         (WebKit::NetworkDataTaskSoup::tlsConnectionAcceptCertificate): Check TLS errors here.
515         (WebKit::NetworkDataTaskSoup::networkEventCallback): Pass the stream to networkEvent.
516         (WebKit::NetworkDataTaskSoup::networkEvent): Connect to GTlsConnection::accept-certificate.
517         * NetworkProcess/soup/NetworkDataTaskSoup.h:
518
519 2018-04-20  Timothy Hatcher  <timothy@apple.com>
520
521         NULL dereference crash sometimes under [super initWithCoder:] in WebView
522
523         https://bugs.webkit.org/show_bug.cgi?id=184851
524         rdar://problem/39611236
525
526         Reviewed by Tim Horton.
527
528         * UIProcess/API/Cocoa/WKWebView.mm:
529         (-[WKWebView _initializeWithConfiguration:]):
530         (-[WKWebView effectiveAppearanceDidChange]):
531         Added a null check and call the code later in initialization.
532
533 2018-04-20  Tim Horton  <timothy_horton@apple.com>
534
535         Adjust geolocation feature flag
536         https://bugs.webkit.org/show_bug.cgi?id=184856
537
538         Reviewed by Wenson Hsieh.
539
540         * Configurations/FeatureDefines.xcconfig:
541
542 2018-04-20  Chris Dumez  <cdumez@apple.com>
543
544         Unreviewed attempt to fix GTK build after r230867.
545
546         * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp:
547         (webkit_dom_dom_window_get_self):
548         (webkit_dom_dom_window_get_window):
549         (webkit_dom_dom_window_get_frames):
550         (webkit_dom_dom_window_get_opener):
551         (webkit_dom_dom_window_get_parent):
552         (webkit_dom_dom_window_get_top):
553
554 2018-04-20  Commit Queue  <commit-queue@webkit.org>
555
556         Unreviewed, rolling out r230873.
557         https://bugs.webkit.org/show_bug.cgi?id=184857
558
559         Broke the iOS build (Requested by cdumez on #webkit).
560
561         Reverted changeset:
562
563         "Disable backward and forward navigation swipes while in
564         fullscreen."
565         https://bugs.webkit.org/show_bug.cgi?id=184656
566         https://trac.webkit.org/changeset/230873
567
568 2018-04-20  Chris Dumez  <cdumez@apple.com>
569
570         REGRESSION (r229828): web view doesn’t update or respond to resizing until client calls policy decision handler
571         https://bugs.webkit.org/show_bug.cgi?id=184210
572         <rdar://problem/39072354>
573
574         Reviewed by Wenson Hsieh.
575
576         r229828 tried to have some API tests happy on iOS by freezing the layer tree
577         during the navigation policy decision. However, this is observable by the client
578         application and a regression from when the policy delegate was synchronous.
579
580         To address the issue, this patch reverts r229828 and instead updates the iOS
581         API tests to wait for the next presentation update after navigating
582         before interacting with the view.
583
584         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
585         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
586         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
587         (WebKit::WebFrameLoaderClient::cancelPolicyCheck):
588         (WebKit::WebFrameLoaderClient::provisionalLoadStarted):
589         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
590         * WebProcess/WebPage/WebPage.cpp:
591         * WebProcess/WebPage/WebPage.h:
592
593 2018-04-20  Brent Fulgham  <bfulgham@apple.com>
594
595         Limit cookie header access to Network process
596         https://bugs.webkit.org/show_bug.cgi?id=184764
597         <rdar://problem/36785285>
598
599         Reviewed by Youenn Fablet.
600
601         Revise the handling of cookie request headers so that we don't interact with them in the
602         WebContent process. They are only needed for interaction with the server and the network
603         process, so we should limit their scope to just the Network process.
604
605         Instead, we should handle a token that represents the cookie headers in the WebContent
606         process, which can be converted to the relevant cookie data in the network process when
607         needed.
608
609         * NetworkProcess/NetworkSocketStream.cpp:
610         (WebKit::NetworkSocketStream::sendHandshake):
611         * NetworkProcess/NetworkSocketStream.h:
612         * NetworkProcess/NetworkSocketStream.messages.in:
613         * WebProcess/Network/WebSocketStream.cpp:
614         (WebKit::WebSocketStream::networkProcessCrashed):
615         (WebKit::WebSocketStream::platformSendHandshake):
616         (WebKit::WebSocketStream::didSendHandshake):
617         * WebProcess/Network/WebSocketStream.h:
618         * WebProcess/Network/WebSocketStream.messages.in:
619
620 2018-04-20  Jeremy Jones  <jeremyj@apple.com>
621
622         Disable backward and forward navigation swipes while in fullscreen.
623         https://bugs.webkit.org/show_bug.cgi?id=184656
624         rdar://problem/36057535
625
626         Reviewed by Tim Horton.
627
628         Disable navigation swipes while in fullscreen.
629
630         * UIProcess/Cocoa/ViewGestureController.cpp:
631         (WebKit::ViewGestureController::canSwipeInDirection const):
632
633 2018-04-20  Jeremy Jones  <jeremyj@apple.com>
634
635         Element fullscreen, expose WKWebView _fullScreenPlaceholderView as iOS SPI
636         https://bugs.webkit.org/show_bug.cgi?id=184826
637         rdar://problem/39600825
638
639         Reviewed by Tim Horton.
640
641         Add _fullScreenPlaceholderView for iOS similar to the one for Mac.
642
643         * UIProcess/API/Cocoa/WKWebView.mm:
644         (-[WKWebView _fullScreenPlaceholderView]):
645         (-[WKWebView closeFullScreenWindowController]):
646         (-[WKWebView fullScreenPlaceholderView]): Deleted.
647         * UIProcess/API/Cocoa/WKWebViewInternal.h:
648         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
649         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.h:
650         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
651         (-[WKFullScreenWindowController webViewPlaceholder]):
652
653 2018-04-20  Wenson Hsieh  <wenson_hsieh@apple.com>
654
655         [Extra zoom mode] Injected bundle form client should be notified when editing text fields
656         https://bugs.webkit.org/show_bug.cgi?id=184822
657         <rdar://problem/38807319>
658
659         Reviewed by Tim Horton.
660
661         Fixes the bug by making a couple of tweaks: (1) don't use a separate codepath for inserting text in text inputs,
662         and (2) force a user typing gesture when inserting text using this codepath (i.e. WKTextInputListViewController).
663         Also adds plumbing to enable testing text entry with WKTextInputListViewController in extra zoom mode.
664
665         * UIProcess/API/Cocoa/WKWebView.mm:
666         (-[WKWebView _simulateTextEntered:]):
667         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
668
669         Introduce testing SPI to simulate text entry. Additionally, add a missing availability annotation around testing
670         SPI added in 2017 to help test drag and drop for iOS 11.
671
672         * UIProcess/ios/WKContentViewInteraction.h:
673         * UIProcess/ios/WKContentViewInteraction.mm:
674         (-[WKContentView _simulateTextEntered:]):
675         * WebProcess/WebPage/WebPage.cpp:
676         (WebKit::WebPage::setTextAsync):
677
678 2018-04-20  Jeremy Jones  <jeremyj@apple.com>
679
680         EnterFullscreen must update the minimum and maximum layout sizes.
681         https://bugs.webkit.org/show_bug.cgi?id=184828
682         rdar://problem/38435829
683
684         Reviewed by Jon Lee.
685
686         Without this, the WKWebView won't layout to the full size in fullscreen mode.
687
688         * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
689         (-[WKFullScreenWindowController enterFullScreen]):
690
691 2018-04-18  Jer Noble  <jer.noble@apple.com>
692
693         Don't put build products into WK_ALTERNATE_WEBKIT_SDK_PATH for engineering builds
694         https://bugs.webkit.org/show_bug.cgi?id=184762
695
696         Reviewed by Dan Bernstein.
697
698         * Configurations/BaseTarget.xcconfig:
699
700 2018-04-20  Youenn Fablet  <youenn@apple.com>
701
702         Refactor NetworkResourceLoader to check for m_networkLoadChecker presence before using it
703         https://bugs.webkit.org/show_bug.cgi?id=184755
704
705         Reviewed by Chris Dumez.
706
707         Make NetworkResourceLoader always use m_networkLoadChecker if there is one.
708         This is only used now for synchronous loads but will be used in the future for asynchronous loads as well.
709
710         Since we call didFail asynchronously to make sync/async handling more consistent,
711         We need to keep track of whether we will do clean-up twice.
712         A boolean is added for that purpose in NetworkResourceLoader.
713
714         There is a small change of behavior in the way we return an error.
715         Instead of returning a platformBadResponseError, we are now returning the error as computed by NetworkLoadChecker.
716         This allows getting some more error logging in the JS console.
717
718         * NetworkProcess/NetworkResourceLoader.cpp:
719         (WebKit::NetworkResourceLoader::didReceiveResponse):
720         (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
721         (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
722         (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
723         * NetworkProcess/NetworkResourceLoader.h:
724
725 2018-04-20  Timothy Hatcher  <timothy@apple.com>
726
727         Include missing files in WKContentViewInteraction.{mm,h}
728
729         https://bugs.webkit.org/show_bug.cgi?id=184832
730         rdar://problem/35377120
731
732         Reviewed by Wenson Hsieh.
733
734         Some WebDriver files were missing and should be included.
735
736         * UIProcess/ios/WKContentViewInteraction.h:
737         * UIProcess/ios/WKContentViewInteraction.mm:
738         (-[WKContentView setupInteraction]):
739         (-[WKContentView cleanupInteraction]):
740         (-[WKContentView _removeDefaultGestureRecognizers]):
741         (-[WKContentView _addDefaultGestureRecognizers]):
742
743 2018-04-20  Youenn Fablet  <youenn@apple.com>
744
745         WebPage sometimes incorrectly rules out PDF as a mime type that can be showed
746         https://bugs.webkit.org/show_bug.cgi?id=184369
747
748         Reviewed by Chris Dumez.
749
750         Use API to check for plugin availability for response at navigation time.
751
752         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
753         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
754         * WebProcess/WebPage/WebPage.cpp:
755         (WebKit::WebPage::canShowResponse const):
756         (WebKit::WebPage::canShowMIMEType const):
757         * WebProcess/WebPage/WebPage.h:
758
759 2018-04-20  Daniel Bates  <dabates@apple.com>
760
761         Remove Strong Password decoration when text field type changes
762         https://bugs.webkit.org/show_bug.cgi?id=184795
763         <rdar://problem/38325108>
764
765         Reviewed by Antti Koivisto.
766
767         Add injected bundle API and WebKit UI delegate SPI to notify the embedding client when the
768         Strong Password appearance of an HTML input element is resigned.
769
770         We add C SPI for Safari on Mac.
771
772         * UIProcess/API/APIUIClient.h:
773         (API::UIClient::didResignInputElementStrongPasswordAppearance):
774         * UIProcess/API/C/WKPage.cpp:
775         (WKPageSetPageUIClient):
776         * UIProcess/API/C/WKPageUIClient.h:
777         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
778         * UIProcess/Cocoa/UIDelegate.h:
779         * UIProcess/Cocoa/UIDelegate.mm:
780         (WebKit::UIDelegate::setDelegate):
781         (WebKit::UIDelegate::UIClient::didResignInputElementStrongPasswordAppearance):
782         * UIProcess/WebPageProxy.cpp:
783         (WebKit::WebPageProxy::didResignInputElementStrongPasswordAppearance):
784         * UIProcess/WebPageProxy.h:
785         * UIProcess/WebPageProxy.messages.in:
786         * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h:
787         (API::InjectedBundle::PageUIClient::didResignInputElementStrongPasswordAppearance):
788         * WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h:
789         * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
790         (WebKit::InjectedBundlePageUIClient::didResignInputElementStrongPasswordAppearance):
791         * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
792         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
793         (WebKit::WebChromeClient::inputElementDidResignStrongPasswordAppearance):
794         * WebProcess/WebCoreSupport/WebChromeClient.h:
795
796 2018-04-20  Megan Gardner  <megan_gardner@apple.com>
797
798         Fixes for failing tests associated with switching Text Selection Assistants
799         https://bugs.webkit.org/show_bug.cgi?id=184806
800         <rdar://problem/39367905>
801
802         Reviewed by Beth Dakin and Wenson Hsieh.
803         
804         The major fix is the disabling the double tap noneditable text selection gesture.
805         The other fixes are small tweaks that shouldn't even be run into with the fix to 
806         the double tap gesture, but they are incorrect, so I am taking the opportunity to 
807         fix them now, in case we run into them again.
808
809         * UIProcess/ios/WKContentViewInteraction.mm:
810         (-[WKContentView textInteractionGesture:shouldBeginAtPoint:]):
811         We should not be allowing a double tap text gestures in non-editable web content.
812         We didn't have one with the old assistant. Fortunately, this is easily disabled.
813         (-[WKContentView canPerformActionForWebView:withSender:]):
814         We should not allow the lookup action if we do not actually have a selection.
815         It is meaningless without one.
816         (-[WKContentView selectedTextRange]):
817         We should not return a selection to UIKit if all we have is caret selection
818         in non-editable content. We have this for selections on Mac, but UIKit does
819         not know how to properly handle this, and will have incorrect behavior if we 
820         return a valid selection.
821
822 2018-04-20  Timothy Hatcher  <timothy@apple.com>
823
824         WebEvent fails to convert synthetic WebMouseEvent for automation
825
826         https://bugs.webkit.org/show_bug.cgi?id=184824
827         rdar://problem/35377120
828
829         Reviewed by Brian Burg.
830
831         Add WebEvent conversions that existed in PlatformEventFactoryIOS for legacy WebKit,
832         but never got added in WebIOSEventFactory and NativeWebMouseEvent for modern WebKit.
833         This affected WebDriver, and some events not being deliverd to the page.
834
835         * Shared/NativeWebMouseEvent.h:
836         (WebKit::NativeWebMouseEvent::nativeEvent const):
837         * Shared/ios/NativeWebMouseEventIOS.mm: Added.
838         (WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
839         * Shared/ios/WebIOSEventFactory.h:
840         * Shared/ios/WebIOSEventFactory.mm:
841         (WebIOSEventFactory::createWebMouseEvent):
842         * WebKit.xcodeproj/project.pbxproj:
843
844 2018-04-20  Michael Catanzaro  <mcatanzaro@igalia.com>
845
846         Unreviewed, fix -Wformat warning
847
848         * UIProcess/WebPageProxy.cpp:
849         (WebKit::WebPageProxy::didFinishLoadForFrame):
850
851 2018-04-20  Youenn Fablet  <youenn@apple.com>
852
853         Make PluginData cache its web visible plugins
854         https://bugs.webkit.org/show_bug.cgi?id=184421
855
856         Reviewed by Chris Dumez.
857
858         Rename methods.
859         Pass an URL instead of relying on Page URL as the page URL
860         might not always be the URL we want to check against plugins.
861         In particular when navigation is on-going, we want to check the
862         plugins against the being navigated URL.
863
864         * WebProcess/Plugins/WebPluginInfoProvider.cpp:
865         (WebKit::WebPluginInfoProvider::pluginInfo):
866         (WebKit::WebPluginInfoProvider::webVisiblePluginInfo):
867         * WebProcess/Plugins/WebPluginInfoProvider.h:
868
869 2018-04-19  Carlos Garcia Campos  <cgarcia@igalia.com>
870
871         Unreviewed. Fix GTK+ build after r230830.
872
873         Add SimulatedInputDispatcher.cpp to the build.
874
875         * CMakeLists.txt:
876
877 2018-04-19  Brady Eidson  <beidson@apple.com>
878
879         Make back forward cache work with process swapping.
880         <rdar://problem/38676604> and https://bugs.webkit.org/show_bug.cgi?id=184793
881
882         Reviewed by Chris Dumez.
883
884         We previously saved old processes in "SuspendedPageProxy" objects.
885         Now we reuse them when going back or forward.
886
887         * Platform/Logging.h:
888
889         * Shared/WebBackForwardListItem.cpp:
890         (WebKit::WebBackForwardListItem::setSuspendedPage):
891         (WebKit::WebBackForwardListItem::loggingString):
892         * Shared/WebBackForwardListItem.h:
893         (WebKit::WebBackForwardListItem::suspendedPage const):
894
895         Teach Navigation objects their source WebBackForwardListItems:
896         * UIProcess/API/APINavigation.cpp:
897         (API::Navigation::Navigation):
898         (API::Navigation::loggingString const):
899         * UIProcess/API/APINavigation.h:
900         (API::Navigation::create):
901         (API::Navigation::targetItem const):
902         (API::Navigation::fromItem const):
903         (API::Navigation::backForwardListItem): Deleted.
904
905         * UIProcess/Cocoa/NavigationState.mm:
906         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
907
908         * UIProcess/SuspendedPageProxy.cpp:
909         (WebKit::messageNamesToIgnoreWhileSuspended):
910         (WebKit::SuspendedPageProxy::SuspendedPageProxy):
911         (WebKit::SuspendedPageProxy::~SuspendedPageProxy):
912         (WebKit::SuspendedPageProxy::webProcessDidClose):
913         (WebKit::SuspendedPageProxy::didReceiveMessage):
914         (WebKit::SuspendedPageProxy::loggingString const):
915         * UIProcess/SuspendedPageProxy.h:
916         (WebKit::SuspendedPageProxy::origin const):
917
918         * UIProcess/WebBackForwardList.cpp:
919         (WebKit::WebBackForwardList::WebBackForwardList):
920         (WebKit::WebBackForwardList::~WebBackForwardList):
921         (WebKit::WebBackForwardList::pageClosed):
922         (WebKit::WebBackForwardList::addItem):
923         (WebKit::WebBackForwardList::goToItem):
924         (WebKit::WebBackForwardList::removeAllItems):
925         (WebKit::WebBackForwardList::clear):
926         (WebKit::WebBackForwardList::restoreFromState):
927         (WebKit::WebBackForwardList::filteredItemStates const):
928         (WebKit::WebBackForwardList::itemStates const):
929         (WebKit::WebBackForwardList::loggingString):
930         * UIProcess/WebBackForwardList.h:
931
932         * UIProcess/WebNavigationState.cpp:
933         (WebKit::WebNavigationState::createLoadRequestNavigation):
934         (WebKit::WebNavigationState::createBackForwardNavigation):
935         * UIProcess/WebNavigationState.h:
936
937         * UIProcess/WebPageProxy.cpp:
938         (WebKit::WebPageProxy::reattachToWebProcess):
939         (WebKit::WebPageProxy::maybeCreateSuspendedPage):
940         (WebKit::WebPageProxy::reattachToWebProcessWithItem):
941         (WebKit::WebPageProxy::loadRequest):
942         (WebKit::WebPageProxy::loadFile):
943         (WebKit::WebPageProxy::goToBackForwardItem):
944         (WebKit::WebPageProxy::receivedPolicyDecision):
945         (WebKit::WebPageProxy::continueNavigationInNewProcess):
946         (WebKit::WebPageProxy::didCreateMainFrame):
947         (WebKit::WebPageProxy::didCreateSubframe):
948         (WebKit::WebPageProxy::didStartProvisionalLoadForFrame):
949         (WebKit::WebPageProxy::didFailProvisionalLoadForFrame):
950         (WebKit::WebPageProxy::didCommitLoadForFrame):
951         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
952         (WebKit::WebPageProxy::connectionWillOpen):
953         (WebKit::WebPageProxy::attachToProcessForNavigation): Deleted.
954         * UIProcess/WebPageProxy.h:
955
956         * UIProcess/WebProcessLifetimeTracker.cpp:
957         (WebKit::WebProcessLifetimeTracker::webPageEnteringWebProcess):
958         (WebKit::WebProcessLifetimeTracker::connectionWillOpen): Deleted.
959         * UIProcess/WebProcessLifetimeTracker.h:
960
961         * UIProcess/WebProcessPool.cpp:
962         (WebKit::WebProcessPool::processForNavigation):
963         (WebKit::WebProcessPool::registerSuspendedPageProxy):
964         (WebKit::WebProcessPool::unregisterSuspendedPageProxy):
965         * UIProcess/WebProcessPool.h:
966
967         * UIProcess/WebProcessProxy.cpp:
968         (WebKit::WebProcessProxy::suspendWebPageProxy):
969         (WebKit::WebProcessProxy::updateBackForwardItem):
970         (WebKit::WebProcessProxy::frameCreated):
971         * UIProcess/WebProcessProxy.h:
972
973         * WebProcess/WebPage/DrawingArea.h:
974         (WebKit::DrawingArea::attachDrawingArea):
975
976         * WebProcess/WebPage/WebBackForwardListProxy.cpp:
977         (WebKit::WebBackForwardListProxy::addItemFromUIProcess):
978         (WebKit::WebBackForwardListProxy::addItem):
979         * WebProcess/WebPage/WebBackForwardListProxy.h:
980
981         * WebProcess/WebPage/WebPage.cpp:
982         (WebKit::m_credentialsMessenger):
983         (WebKit::WebPage::reinitializeWebPage):
984         (WebKit::WebPage::goToBackForwardItem):
985         (WebKit::WebPage::restoreSessionInternal):
986         (WebKit::WebPage::restoreSession):
987         (WebKit::WebPage::updateBackForwardListForReattach):
988         * WebProcess/WebPage/WebPage.h:
989         * WebProcess/WebPage/WebPage.messages.in:
990
991         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
992         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
993         (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
994         (WebKit::TiledCoreAnimationDrawingArea::attachDrawingArea): Force a reattachment of the drawing
995           area from a resumed WebProcess to the UIProcess (to make the page cache work)
996
997 2018-04-19  Brian Burg  <bburg@apple.com>
998
999         Web Automation: add support for mouse/keyboard interaction sequences
1000         https://bugs.webkit.org/show_bug.cgi?id=184603
1001         <rdar://problem/39421839>
1002
1003         Reviewed by Timothy Hatcher.
1004
1005         Add new protocol methods and WebKit support for implementing the W3C Actions API.
1006         This is a generic command for sending low-level mouse, key, and touch events to
1007         test page behavior when performing drag-and-drop, gestures, or specific keydown/keyups.
1008
1009         To implement this functionality, this patch adds SimulatedInputDispatcher, a class
1010         for dispatching input events asynchronously. Similar to the WebDriver specification,
1011         this is designed as a keyframing API. Callers set up several "input sources" such
1012         as keyboard or mouse, and then specify the states of that input source over time. The
1013         dispatcher calculates diffs between the previous and current keyframes and generates
1014         the appropriate events that would happen if a user caused the state transition.
1015
1016         For example, if a mouse input source's state changes, the dispatcher sends synthetic mousemove,
1017         mousedown, or mouseup events depending on the pre- and post-state. This is uninteresting
1018         and overcomplicated for simple key and mouse presses, but it's really designed with an
1019         eye towards supporting mousemove interpolation and touch event interpolation in later patches.
1020
1021         The strategy for dispatching events depends on the input source type; right now, these
1022         map directly to the existing platformSimulate{Mouse, Keyboard}Interaction methods. In
1023         the future, the dispatch strategy may be elaborated for interpolated mousemove events.
1024
1025         This patch depends on support added in bug 184462.
1026
1027         No tests yet. When this command is hooked up to a driver, the code will be exercised by
1028         W3C actions test suite, which is fairly complex at this point relative to end-user code.
1029
1030         * UIProcess/Automation/Automation.json: Add new types and commands.
1031
1032         * UIProcess/Automation/SimulatedInputDispatcher.h: Added.
1033         (WebKit::SimulatedInputSourceState::emptyState):
1034         (WebKit::SimulatedInputSource::create):
1035         (WebKit::SimulatedInputSource::SimulatedInputSource):
1036         (WebKit::SimulatedInputDispatcher::Client::~Client):
1037         Add structs for input source, source state, and keyframe.
1038         The dispatcher's client interface is implemented by WebAutomationSession.
1039
1040         (WebKit::SimulatedInputDispatcher::create):
1041         * UIProcess/Automation/SimulatedInputDispatcher.cpp: Added.
1042         (WebKit::SimulatedInputKeyFrame::SimulatedInputKeyFrame):
1043         (WebKit::SimulatedInputKeyFrame::maximumDuration const):
1044         (WebKit::SimulatedInputKeyFrame::keyFrameFromStateOfInputSources):
1045         (WebKit::SimulatedInputKeyFrame::keyFrameToResetInputSources):
1046         (WebKit::SimulatedInputDispatcher::SimulatedInputDispatcher):
1047         (WebKit::SimulatedInputDispatcher::~SimulatedInputDispatcher):
1048         (WebKit::SimulatedInputDispatcher::isActive const):
1049         (WebKit::SimulatedInputDispatcher::keyFrameTransitionDurationTimerFired):
1050         (WebKit::SimulatedInputDispatcher::isKeyFrameTransitionComplete const):
1051         (WebKit::SimulatedInputDispatcher::transitionToNextKeyFrame):
1052         (WebKit::SimulatedInputDispatcher::transitionToNextInputSourceState):
1053         (WebKit::SimulatedInputDispatcher::transitionBetweenKeyFrames):
1054         (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
1055         (WebKit::SimulatedInputDispatcher::run):
1056         (WebKit::SimulatedInputDispatcher::cancel):
1057         (WebKit::SimulatedInputDispatcher::finishDispatching):
1058         The dispatcher handles one interaction at a time. The interaction is described
1059         by an array of keyframes, and each keyframe has an array of states. The dispatcher
1060         transitions between keyframes by sequentially and asynchronously emitting events
1061         that cause each input source state to transition as desired. Keyframe transitions
1062         are additionally gated by a "maximum duration" timer. Each step that the dispatcher
1063         executes is asynchronous, so the dispatcher keeps most state in members and uses
1064         error argument lambdas as completion handlers for various async things.
1065
1066         * UIProcess/Automation/WebAutomationSession.h:
1067         * UIProcess/Automation/WebAutomationSession.cpp:
1068         (WebKit::WebAutomationSession::WebAutomationSession):
1069         (WebKit::WebAutomationSession::inputDispatcherForPage):
1070         (WebKit::WebAutomationSession::inputSourceForType const):
1071         Add canonical input sources that are used to keep track of state across
1072         interaction sequences.
1073
1074         (WebKit::WebAutomationSession::isSimulatingUserInteraction const):
1075         (WebKit::WebAutomationSession::mouseEventsFlushedForPage):
1076         (WebKit::WebAutomationSession::keyboardEventsFlushedForPage):
1077         Remove m_simulatingUserInteraction since it can be computed based on other members.
1078
1079         (WebKit::WebAutomationSession::willClosePage):
1080         If the page is being torn down, stop the dispatcher if needed and cancel any
1081         callbacks waiting for mouse/key events to be retired.
1082
1083         (WebKit::WebAutomationSession::simulateMouseInteraction):
1084         (WebKit::WebAutomationSession::simulateKeyboardInteraction):
1085         Add easy-to-use async methods for simulating mouse and key events. These are
1086         hooked up to SimulatedInputDispatcher using async completion handlers.
1087
1088         (WebKit::protocolMouseButtonToWebMouseEventButton):
1089         (WebKit::WebAutomationSession::performMouseInteraction):
1090         (WebKit::WebAutomationSession::performKeyboardInteractions):
1091         Adjust some naming.
1092
1093         (WebKit::simulatedInputSourceTypeFromProtocolSourceType):
1094         (WebKit::WebAutomationSession::performInteractionSequence):
1095         (WebKit::WebAutomationSession::cancelInteractionSequence):
1096         Add command handlers for the new action commands in Automation protocol.
1097
1098         * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
1099         (WebKit::mouseButtonToGdkButton):
1100         (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
1101         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
1102         (WebKit::WebAutomationSession::platformSimulateKeyStroke): Deleted.
1103         * UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
1104         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
1105         (WebKit::WebAutomationSession::platformSimulateKeyStroke): Deleted.
1106         Rename the keyboard platform method to match the naming of the mouse platform method.
1107         Take advantage of the 'using' alias to make the tedious switches easier to read.
1108
1109         * UIProcess/Automation/mac/WebAutomationSessionMac.mm:
1110         (WebKit::WebAutomationSession::platformSimulateMouseInteraction):
1111         (WebKit::virtualKeyHasStickyModifier):
1112         (WebKit::keyCodeForVirtualKey):
1113         (WebKit::eventModifierFlagsForVirtualKey):
1114         (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
1115         (WebKit::WebAutomationSession::platformSimulateKeySequence):
1116         (WebKit::keyHasStickyModifier): Deleted.
1117         (WebKit::WebAutomationSession::platformSimulateKeyStroke): Deleted.
1118         Allow the keyboard simulation method to take a virtual key and unichar to better
1119         match how this is used by the Perform Actions command and its machinery.
1120
1121         * WebKit.xcodeproj/project.pbxproj:
1122
1123 2018-04-19  Jiewen Tan  <jiewen_tan@apple.com>
1124
1125         Remove access to keychain from the WebContent process
1126         https://bugs.webkit.org/show_bug.cgi?id=184428
1127         <rdar://problem/13150903>
1128
1129         Reviewed by Brent Fulgham.
1130
1131         Part 1.
1132
1133         Remove com.apple.identities from WebContent-iOS.entitlements, which is needed to encode/decode NSError’s userInfo[NSErrorClientCertificateChainKey]
1134         when the corresponding NSErorr is relayed through WebContent Process from Networking Process to UI Process after a HTTPS client certificate
1135         authentication is rejected becuase of bad certificates. This patch implements corresponding workarounds as well. The workaround works for mac, too.
1136
1137         Sadly, this change can only be tested manually at this moment. Please refer to the radar for testing steps.
1138
1139         * Configurations/WebContent-iOS.entitlements:
1140         * Shared/mac/WebCoreArgumentCodersMac.mm:
1141         (IPC::encodeNSError):
1142         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1143         (WebKit::WebProcessPool::platformInitialize):
1144
1145 2018-04-19  David Kilzer  <ddkilzer@apple.com>
1146
1147         Enable Objective-C weak references
1148         <https://webkit.org/b/184789>
1149         <rdar://problem/39571716>
1150
1151         Reviewed by Dan Bernstein.
1152
1153         * Configurations/Base.xcconfig:
1154         (CLANG_ENABLE_OBJC_WEAK): Enable.
1155
1156 2018-04-19  Youenn Fablet  <youenn@apple.com>
1157
1158         Web Inspector backend should get headers & cookies from network process separately from resource requests
1159         https://bugs.webkit.org/show_bug.cgi?id=184396
1160         <rdar://problem/38877384>
1161
1162         Reviewed by Brian Burg.
1163
1164         Add support for storing response and network metrics for every resource load.
1165         This is made conditional on inspector being activated.
1166         NetworkConnectionToWebProcess keeps a response and network metrics for every load.
1167         This is cleared when inspector is going away or when a web process requests
1168         the data.
1169
1170         WebLoaderStrategy gets this data through synchronous IPC.
1171         Synchronous IPC is a temporary implementation until Inspector code gets refactored.
1172
1173         Updated WebLoaderStrategy to pass the sourceOrigin for every NetworkResourceLoader.
1174         This activates additional sanitization based on cross origin status.
1175
1176         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
1177         (WebKit::NetworkConnectionToWebProcess::setCaptureExtraNetworkLoadMetricsEnabled):
1178         * NetworkProcess/NetworkConnectionToWebProcess.h:
1179         (WebKit::NetworkConnectionToWebProcess::takeNetworkLoadInformationResponse):
1180         (WebKit::NetworkConnectionToWebProcess::takeNetworkLoadInformationMetrics):
1181         (WebKit::NetworkConnectionToWebProcess::addNetworkLoadInformationResponse):
1182         (WebKit::NetworkConnectionToWebProcess::addNetworkLoadInformationMetrics):
1183         (WebKit::NetworkConnectionToWebProcess::removeNetworkLoadInformation):
1184         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
1185         * NetworkProcess/NetworkResourceLoader.cpp:
1186         (WebKit::NetworkResourceLoader::didReceiveResponse):
1187         (WebKit::NetworkResourceLoader::didFinishLoading):
1188         (WebKit::NetworkResourceLoader::didFailLoading):
1189         * WebProcess/Network/WebLoaderStrategy.cpp:
1190         (WebKit::WebLoaderStrategy::responseFromResourceLoadIdentifier):
1191         (WebKit::WebLoaderStrategy::networkMetricsFromResourceLoadIdentifier):
1192         * WebProcess/Network/WebLoaderStrategy.h:
1193         * WebProcess/Network/WebResourceLoader.cpp:
1194         (WebKit::WebResourceLoader::didReceiveResponse):
1195
1196 2018-04-19  Wenson Hsieh  <wenson_hsieh@apple.com>
1197
1198         [Extra zoom mode] Add a mechanism to extend the height of the layout viewport in extra zoom mode
1199         https://bugs.webkit.org/show_bug.cgi?id=184782
1200         <rdar://problem/38346712>
1201
1202         Reviewed by Tim Horton.
1203
1204         In extra zoom mode, at initial scale, fixed position elements may take up a large portion of the viewport. This
1205         leaves little room for non-fixed-position elements; to improve this experience, we introduce a mechanism to
1206         extend the height of the layout viewport. By default, the layout viewport size is determined by the FrameView's
1207         baseLayoutViewportSize, and passed into FrameView::computeUpdatedLayoutViewportRect in the client layer; in
1208         extra zoom mode, if the layout viewport is shorter than the document width, we try to double the height of the
1209         layout viewport and clamp to the document height if necessary.
1210
1211         * Shared/WebPreferences.yaml:
1212
1213         Add a new preference to determine the factor by which we should expand the height of the layout viewport. By
1214         default, this is 0 (no increase in layout viewport height); in extra zoom mode, this is 1, which means we'll
1215         increase the layout viewport's height by 1x the default height.
1216
1217         * Shared/WebPreferencesDefaultValues.h:
1218         * UIProcess/API/Cocoa/WKWebView.mm:
1219         (-[WKWebView activeMinimumLayoutSizes:]):
1220
1221         Fixes a bug when computing the active minimum layout size. If a minimum allowed layout width is specified, we
1222         clamp the active layout width (normally the view size) so that it is no less than the minimum allowed layout
1223         width. However, the height is currently unaffected, which causes FrameView::baseLayoutViewportSize to return a
1224         bogus size, where the width is scaled to 320px but the height isn't. Instead, we should scale the layout height
1225         to match the new width here.
1226
1227         * UIProcess/ios/WebPageProxyIOS.mm:
1228         (WebKit::WebPageProxy::computeCustomFixedPositionRect const):
1229
1230         Expand the base viewport layout size if necessary, given the expansion factor in WebPreferences.
1231
1232         * WebProcess/WebPage/WebPage.cpp:
1233         (WebKit::WebPage::updatePreferences):
1234         * WebProcess/WebPage/ios/WebPageIOS.mm:
1235         (WebKit::WebPage::dynamicViewportSizeUpdate):
1236
1237         Expand the base viewport layout size if necessary, given the expansion factor in Settings.
1238
1239 2018-04-19  Brian Burg  <bburg@apple.com>
1240
1241         Web Automation: simulated mouse interactions should not be done until associated DOM events have been dispatched
1242         https://bugs.webkit.org/show_bug.cgi?id=184462
1243         <rdar://problem/39323336>
1244
1245         Reviewed by Carlos Garcia Campos and Tim Horton.
1246
1247         Covered by existing layout tests and actions endpoints in WebDriver test suite.
1248
1249         In preparation for implementing the W3C WebDriver command "Perform Actions", we need a way to
1250         know when a simulated mouse event has been fully processed by WebProcess and it is okay to continue
1251         to dispatch more simulated events.
1252
1253         This patch makes mouse events go through a queue as they are delivered to WebPageProxy. The approach
1254         is very similar to how key events are handled. In the key event case, lots of WebEvents can come out
1255         of typing one keystroke, so these need to be queued up and retired one by one when the WebProcess has
1256         finished handling each event. In some mouse event cases---particularly fake mouse moves---there can
1257         also be more than one mouse event waiting to be handled by WebProcess.
1258
1259         In the past, these queued mouse events were tracked with several member variables as different
1260         use cases emerged. These are all replaced with ordinary deque operations, such as peeking or
1261         checking the queue length.
1262
1263         * Platform/Logging.h: Add logging channel for mouse events.
1264         * UIProcess/Automation/WebAutomationSession.cpp:
1265         (WebKit::AutomationCommandError::toProtocolString): Add type-safe helper class for command errors.
1266         In future patches we can hide knowledge of how this is sent over the protocol by relying more on
1267         the convenience constructors and .toProtocolString() method.
1268
1269         (WebKit::WebAutomationSession::willShowJavaScriptDialog):
1270         This section needs adjustments. Since performMouseInteraction now depends on key events being processed
1271         prior to returning from the command, we need to abort any key event callbacks that are pending if an
1272         alert pops up as a result of sending a mousedown event. Any mouse events that are still queued will
1273         be handled when the alert is dismissed and the nested run loop exits.
1274
1275         (WebKit::WebAutomationSession::mouseEventsFlushedForPage):
1276         (WebKit::WebAutomationSession::keyboardEventsFlushedForPage):
1277         Modernize this a bit. Don't spread knowledge about how commands are sent back out into event handling code.
1278         Our wrapper callbacks in performXXXInteraction handle the protocol-specific details of the response.
1279
1280         (WebKit::WebAutomationSession::performMouseInteraction):
1281         Add code similar to performKeyboardInteractions so that the command doesn't finish until the mouse
1282         event has been fully handled. Unlike keyboards, sometimes mouse interactions don't turn into WebEvents
1283         so we also need to handle the case where there is nothing to be waited on because hit testing did
1284         not return a target to deliver the event to.
1285
1286         (WebKit::WebAutomationSession::performKeyboardInteractions):
1287         Modernize a little bit to use generic callbacks rather than protocol-generated callbacks in the
1288         event waiting/handling code. Now it matches the types used for the mouse event case.
1289
1290         * UIProcess/Automation/WebAutomationSession.h:
1291         (WebKit::AutomationCommandError::AutomationCommandError):
1292         Add a helper struct to hold an enumerated error name and an optional free-form error message.
1293
1294         * UIProcess/WebPageProxy.h:
1295         * UIProcess/WebPageProxy.cpp:
1296         (WebKit::webMouseEventTypeString):
1297         (WebKit::webKeyboardEventTypeString):
1298         (WebKit::WebPageProxy::handleMouseEvent):
1299         (WebKit::WebPageProxy::processNextQueuedMouseEvent):
1300         Split the old method into handleMouseEvent (called by other code) and processNextQueuedMouseEvent.
1301         The latter sends the next mouse event to WebProcess, and can be triggered in didReceiveEvent
1302         if there are more mouse events to be sent to WebProcess.
1303
1304         (WebKit::WebPageProxy::isProcessingMouseEvents const): Added.
1305         (WebKit::WebPageProxy::currentlyProcessedMouseDownEvent): Reimplemented on top of the deque.
1306         (WebKit::WebPageProxy::didReceiveEvent):
1307         Unify the code paths for different mouse event types to all use the deque. They also will
1308         notify the automation session if there are no more mouse events to send (i.e., interaction is over).
1309
1310         (WebKit::WebPageProxy::resetStateAfterProcessExited): Add handling for new map.
1311
1312 2018-04-19  Andy Estes  <aestes@apple.com>
1313
1314         [iOS] Implement find-in-page in the new WKPDFView
1315         https://bugs.webkit.org/show_bug.cgi?id=184654
1316         <rdar://problem/39331654>
1317
1318         Reviewed by Tim Horton.
1319
1320         This is theoretically covered by existing WKPDFView API tests, but that's currently blocked
1321         by <rdar://problem/39475542>.
1322
1323         * UIProcess/ios/WKPDFView.mm:
1324         (stringCompareOptions):
1325
1326         Mapped _WKFindOptions to NSStringCompareOptions.
1327
1328         (-[WKPDFView _resetFind]):
1329
1330         Cancelled an in-progress search and reset the search state.
1331
1332         (-[WKPDFView _findString:withOptions:maxCount:completion:]):
1333
1334         Stored the completion block, find string, and max count, then called
1335         -[PDFHostViewController findString:withOptions:].
1336
1337         (-[WKPDFView web_countStringMatches:options:maxCount:]):
1338
1339         Called -_findString:withOptions:maxCount:completion: with a completion block that calls
1340         FindClient::didCountStringMatches() with _findStringCount.
1341
1342         (-[WKPDFView _computeFocusedSearchResultIndexWithOptions:didWrapAround:]):
1343
1344         Computed the focused search result index, taking _findStringCount and wrap-around into
1345         account. There are two interesting cases to mention here:
1346
1347         1. We can't change focus while a search is in progress, because we can't properly handle
1348         wrap-around without a _findStringCount. If a search is in progress, store the requested
1349         focus change in _focusedSearchResultPendingOffset, which will be applied once the search
1350         finishes.
1351
1352         2. If wrap-around is about to happen but the find options do not allow it, we need to call
1353         FindClient::didFailToFindString(). Handle this by returning NO, which will tell
1354         -_focusOnSearchResultWithOptions: to call didFailToFindString() if a search is not in
1355         progress.
1356
1357         (-[WKPDFView _focusOnSearchResultWithOptions:]):
1358
1359         If -_computeFocusedSearchResultIndexWithOptions:didWrapAround: failed while a search is in
1360         progress, just return early. Otherwise, call FindClient::didFailToFindString(). If
1361         computing the index did not fail, call -[PDFHostViewController focusOnSearchResultAtIndex:]
1362         to change focus and then call FindClient::didFindString() to inform the client.
1363
1364         (-[WKPDFView web_findString:options:maxCount:]):
1365
1366         If the find string is equal to _findString, change focus. Otherwise, start a new search.
1367
1368         (-[WKPDFView web_hideFindUI]):
1369
1370         Called -_resetFind.
1371
1372         (-[WKPDFView pdfHostViewController:findStringUpdate:done:]):
1373
1374         Stored the count in _findStringCount and called _findCompletion once the search is done.
1375
1376 2018-04-17  Filip Pizlo  <fpizlo@apple.com>
1377
1378         The InternalFunction hierarchy should be in IsoSubspaces
1379         https://bugs.webkit.org/show_bug.cgi?id=184721
1380
1381         Reviewed by Saam Barati.
1382
1383         * WebProcess/Plugins/Netscape/JSNPMethod.cpp:
1384         (WebKit::JSNPMethod::subspaceForImpl):
1385         * WebProcess/Plugins/Netscape/JSNPMethod.h:
1386         (WebKit::JSNPMethod::create): Deleted.
1387         (WebKit::JSNPMethod::npIdentifier const): Deleted.
1388         (WebKit::JSNPMethod::createStructure): Deleted.
1389         * WebProcess/Plugins/Netscape/JSNPObject.cpp:
1390         (WebKit::JSNPObject::subspaceForImpl):
1391         * WebProcess/Plugins/Netscape/JSNPObject.h:
1392         (WebKit::JSNPObject::create): Deleted.
1393         (WebKit::JSNPObject::npObject const): Deleted.
1394         (WebKit::JSNPObject::createStructure): Deleted.
1395
1396 2018-04-19  Brady Eidson  <beidson@apple.com>
1397
1398         Add globally-unique HistoryItem identifiers (and have WebKit2 adopt them).
1399         <rdar://problem/39533949> and https://bugs.webkit.org/show_bug.cgi?id=184750
1400
1401         Reviewed by Ryosuke Niwa.
1402
1403         With process swapping, the assumption that "back/forward items belong to a process" is invalid.
1404
1405         All HistoryItem/WebBackForwardListItems now need to be uniquely identified across all processes,
1406         no matter which process they originated from, so there will never be a collision in the UIProcess.
1407
1408         This allows us to:
1409         - Have the UIProcess to keep a single process-wide map of all WebBackForwardListItems
1410         - Get rid of the per-WebProcess WebBackForwardListItem map
1411         - Simplify a lot of WebBackForwardList(Proxy) code that no longer needs to keep that per-process
1412           map in sync
1413         - Get rid of a lot of other ancillary code
1414
1415         * Shared/SessionState.cpp:
1416         (WebKit::BackForwardListItemState::decode):
1417         * Shared/SessionState.h:
1418
1419         * Shared/WebBackForwardListItem.cpp:
1420         (WebKit::WebBackForwardListItem::WebBackForwardListItem):
1421         (WebKit::WebBackForwardListItem::~WebBackForwardListItem):
1422         (WebKit::WebBackForwardListItem::itemForID):
1423         (WebKit::WebBackForwardListItem::highestUsedItemID): Deleted.
1424         * Shared/WebBackForwardListItem.h:
1425         (WebKit::WebBackForwardListItem::itemID const):
1426
1427         * Shared/WebPageCreationParameters.cpp:
1428         (WebKit::WebPageCreationParameters::encode const):
1429         (WebKit::WebPageCreationParameters::decode):
1430         * Shared/WebPageCreationParameters.h:
1431
1432         * UIProcess/WebBackForwardList.cpp:
1433         (WebKit::WebBackForwardList::itemForID):
1434         (WebKit::WebBackForwardList::pageClosed):
1435         (WebKit::WebBackForwardList::addItem):
1436         (WebKit::WebBackForwardList::restoreFromState):
1437         (WebKit::generateWebBackForwardItemID): Deleted.
1438         * UIProcess/WebBackForwardList.h:
1439
1440         * UIProcess/WebPageProxy.cpp:
1441         (WebKit::WebPageProxy::maybeCreateSuspendedPage):
1442         (WebKit::WebPageProxy::initializeWebPage):
1443         (WebKit::WebPageProxy::willGoToBackForwardListItem):
1444         (WebKit::WebPageProxy::restoreFromSessionState):
1445         (WebKit::WebPageProxy::backForwardAddItem):
1446         (WebKit::WebPageProxy::backForwardGoToItem):
1447         (WebKit::WebPageProxy::backForwardItemAtIndex):
1448         (WebKit::WebPageProxy::creationParameters):
1449         (WebKit::WebPageProxy::backForwardRemovedItem):
1450         * UIProcess/WebPageProxy.h:
1451         * UIProcess/WebPageProxy.messages.in:
1452  
1453         * UIProcess/WebProcessPool.cpp: Explicitly set the UIProcess Process::Identifier so it starts
1454           at "1" and then the first child process starts at "2", etc etc.
1455
1456         * UIProcess/WebProcessProxy.cpp:
1457         (WebKit::WebProcessProxy::removeWebPage):
1458         (WebKit::WebProcessProxy::checkURLReceivedFromWebProcess):
1459         (WebKit::WebProcessProxy::updateBackForwardItem):
1460         (WebKit::WebProcessProxy::webBackForwardItem const): Deleted.
1461         (WebKit::WebProcessProxy::registerNewWebBackForwardListItem): Deleted.
1462         (WebKit::WebProcessProxy::removeBackForwardItem): Deleted.
1463         (WebKit::WebProcessProxy::addOrUpdateBackForwardItem): Deleted.
1464         * UIProcess/WebProcessProxy.h:
1465         * UIProcess/WebProcessProxy.messages.in:
1466
1467         * WebProcess/WebCoreSupport/SessionStateConversion.cpp:
1468         (WebKit::toBackForwardListItemState):
1469         (WebKit::applyFrameState):
1470         (WebKit::toHistoryItem):
1471         (WebKit::toPageState): Deleted.
1472         * WebProcess/WebCoreSupport/SessionStateConversion.h:
1473
1474         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1475         (WebKit::WebFrameLoaderClient::shouldGoToHistoryItem const):
1476
1477         * WebProcess/WebPage/WebBackForwardListProxy.cpp:
1478         (WebKit::WebBackForwardListProxy::addItemFromUIProcess):
1479         (WebKit::WK2NotifyHistoryItemChanged):
1480         (WebKit::WebBackForwardListProxy::itemForID):
1481         (WebKit::WebBackForwardListProxy::removeItem):
1482         (WebKit::WebBackForwardListProxy::addItem): Previously this was a two-step process of adding an item
1483           to the process and then associating it with the page. Now it's just directly adding it to the page,
1484           so we don't need to call updateBackForwardItem first.
1485         (WebKit::WebBackForwardListProxy::goToItem):
1486         (WebKit::WebBackForwardListProxy::itemAtIndex):
1487         (WebKit::WebBackForwardListProxy::close):
1488         (WebKit::historyItemToIDMap): Deleted.
1489         (WebKit::generateHistoryItemID): Deleted.
1490         (WebKit::WebBackForwardListProxy::setHighestItemIDFromUIProcess): Deleted.
1491         (WebKit::updateBackForwardItem): Deleted.
1492         (WebKit::WebBackForwardListProxy::idForItem): Deleted.
1493         * WebProcess/WebPage/WebBackForwardListProxy.h:
1494
1495         * WebProcess/WebPage/WebPage.cpp:
1496         (WebKit::m_credentialsMessenger):
1497         (WebKit::WebPage::goToBackForwardItem):
1498         (WebKit::WebPage::restoreSessionInternal):
1499         (WebKit::WebPage::didRemoveBackForwardItem):
1500         * WebProcess/WebPage/WebPage.h:
1501         * WebProcess/WebPage/WebPage.messages.in:
1502
1503 2018-04-19  Youenn Fablet  <youenn@apple.com>
1504
1505         NetworkProcess should use CSP/content blockers for sync XHR
1506         https://bugs.webkit.org/show_bug.cgi?id=184760
1507
1508         Reviewed by Chris Dumez.
1509
1510         Setting CSP/ContentBlockers parameters for sync XHR loads.
1511         * NetworkProcess/NetworkResourceLoader.cpp:
1512
1513 2018-04-19  Nan Wang  <n_wang@apple.com>
1514
1515         AX: AOM: respect the accessibility setting for dispatching the accessible events
1516         https://bugs.webkit.org/show_bug.cgi?id=184619
1517
1518         Reviewed by Ryosuke Niwa.
1519
1520         Linked libAccessibility on iOS and macOS to use the platform accessibility settings
1521         for allowing dispatching the accessibility events.
1522
1523         * Configurations/WebKit.xcconfig:
1524         * UIProcess/API/Cocoa/WKWebView.mm:
1525         (-[WKWebView _initializeWithConfiguration:]):
1526         (accessibilityEventsEnabledChangedCallback):
1527         (-[WKWebView _updateAccessibilityEventsEnabled]):
1528         * UIProcess/API/Cocoa/WKWebViewInternal.h:
1529         * UIProcess/WebPageProxy.cpp:
1530         (WebKit::WebPageProxy::updateAccessibilityEventsEnabled):
1531         * UIProcess/WebPageProxy.h:
1532         * WebProcess/WebPage/WebPage.cpp:
1533         (WebKit::WebPage::updateAccessibilityEventsEnabled):
1534         * WebProcess/WebPage/WebPage.h:
1535         * WebProcess/WebPage/WebPage.messages.in:
1536
1537 2018-04-18  Chris Dumez  <cdumez@apple.com>
1538
1539         Rename WindowProxyController to WindowProxy
1540         https://bugs.webkit.org/show_bug.cgi?id=184756
1541
1542         Reviewed by Sam Weinig.
1543
1544         Rename WindowProxyController to WindowProxy for clarity. When the IDL uses WindowProxy, the implementation
1545         needed use WindowProxyController type, which was a bit confusing.
1546
1547         * WebProcess/Plugins/PluginView.cpp:
1548         (WebKit::PluginView::windowScriptNPObject):
1549         * WebProcess/WebPage/WebPage.cpp:
1550         (WebKit::WebPage::frameBecameRemote):
1551
1552 2018-04-18  Youenn Fablet  <youenn@apple.com>
1553
1554         Allow SameOrigin credentials handling for synchronous XHR
1555         https://bugs.webkit.org/show_bug.cgi?id=184723
1556
1557         Reviewed by Alex Christensen.
1558
1559         In case of SameOrigin credentials, we need to stop the current load
1560         in case of cross origin redirection to restart a load with a different session.
1561         Covered by updated WK2 tests.
1562         Rebased WK1 tests since this is Wk1 only.
1563
1564         * NetworkProcess/NetworkResourceLoader.cpp:
1565         (WebKit::NetworkResourceLoader::startNetworkLoad):
1566         (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
1567         * NetworkProcess/NetworkResourceLoader.h:
1568
1569 2018-04-18  Chris Dumez  <cdumez@apple.com>
1570
1571         Set RemoteDOMWindow's initial opener
1572         https://bugs.webkit.org/show_bug.cgi?id=184716
1573
1574         Reviewed by Sam Weinig.
1575
1576         When a frame becomes remote, transfer the frame opener from the old
1577         frame to the new remote one.
1578
1579         * WebProcess/WebPage/WebPage.cpp:
1580         (WebKit::WebPage::frameBecameRemote):
1581
1582 2018-04-18  Youenn Fablet  <youenn@apple.com>
1583
1584         NetworkResourceLoader should not clean itself inside didReceiveResponse
1585         https://bugs.webkit.org/show_bug.cgi?id=184754
1586
1587         Reviewed by Chris Dumez.
1588
1589         Delay the cleanup to after the didReceiveResponse call so that NetworkLoad can terminate its work.
1590         Covered by XHR sync tests no longer crashing on GuardMalloc bots.
1591
1592         * NetworkProcess/NetworkResourceLoader.cpp:
1593         (WebKit::NetworkResourceLoader::didReceiveResponse):
1594
1595 2018-04-18  Jer Noble  <jer.noble@apple.com>
1596
1597         Fix rendering of WKRemoteView layers in the simulator
1598         https://bugs.webkit.org/show_bug.cgi?id=184752
1599
1600         Reviewed by Tim Horton.
1601
1602         * Platform/mac/LayerHostingContext.mm:
1603         (WebKit::LayerHostingContext::createForExternalHostingProcess):
1604
1605 2018-04-18  Jer Noble  <jer.noble@apple.com>
1606
1607         Fix entitlements and sandboxing for iphoneminimalsimulator
1608         https://bugs.webkit.org/show_bug.cgi?id=184692
1609
1610         Reviewed by Tim Horton.
1611
1612         Use the correct implementations for ChildProcess and NetworkProcess
1613         when building for iphoneminimalsimulator. Stub out imlementations
1614         which rely on methods not available in the iphoneminimalsimulator SDK.
1615
1616         * Configurations/Network-OSX.entitlements: Added.
1617         * Configurations/NetworkService.xcconfig:
1618         * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
1619         (WebKit::NetworkProcess::sourceApplicationAuditData const):
1620         * NetworkProcess/ios/NetworkProcessIOS.mm:
1621         * NetworkProcess/mac/NetworkProcessMac.mm:
1622         (WebKit::NetworkProcess::initializeProcessName):
1623         (WebKit::overrideSystemProxies):
1624         * Shared/ios/ChildProcessIOS.mm:
1625         (WebKit::ChildProcess::initializeSandbox):
1626         * Shared/mac/ChildProcessMac.mm:
1627         (WebKit::ChildProcess::setApplicationIsDaemon):
1628         (WebKit::enableSandboxStyleFileQuarantine):
1629         (WebKit::ChildProcess::initializeSandbox):
1630         (WebKit::ChildProcess::platformStopRunLoop):
1631         * Shared/mac/CodeSigning.mm:
1632         * WebKit.xcodeproj/project.pbxproj:
1633         * WebProcess/cocoa/WebProcessCocoa.mm:
1634         (WebKit::WebProcess::initializeSandbox):
1635
1636 2018-04-18  Commit Queue  <commit-queue@webkit.org>
1637
1638         Unreviewed, rolling out r230743.
1639         https://bugs.webkit.org/show_bug.cgi?id=184747
1640
1641         causes mouse clicks to not work on some platforms (Requested
1642         by brrian on #webkit).
1643
1644         Reverted changeset:
1645
1646         "Web Automation: simulated mouse interactions should not be
1647         done until associated DOM events have been dispatched"
1648         https://bugs.webkit.org/show_bug.cgi?id=184462
1649         https://trac.webkit.org/changeset/230743
1650
1651 2018-04-18  Brent Fulgham  <bfulgham@apple.com>
1652
1653         Avoid crash if ITP Debug mode is on, but ResourceLoadStatistics are not being used
1654         https://bugs.webkit.org/show_bug.cgi?id=184739
1655         <rdar://problem/39287964>
1656
1657         Reviewed by David Kilzer.
1658
1659         If a user has the ResourceLoadStatistics logic turned off, but has the ITP Debug experimental
1660         flag turned on, you can cause a crash.
1661
1662         This is because the WebsiteDataStore for the process doesn't bother creating a ResourceLoadStatisticsStore
1663         if the statistics machinery is not running. The ITP debug flag was being blindly set without checking
1664         if the statistics store exists or not, which can cause a crash.
1665
1666         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1667         (WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode): Check if the statistics store exists
1668         before calling functions on it.
1669
1670 2018-04-18  Paul Knight  <pknight@apple.com>
1671
1672         Add -[_WKInputDelegateDelegate willStartInputSession:] for clients that want to configure input session before assisting form node
1673         https://bugs.webkit.org/show_bug.cgi?id=184662
1674
1675         Reviewed by Beth Dakin.
1676
1677         Clients may wish to configure a WKInputSession before we start assisting
1678         a node. Add a -[_WKInputDelegateDelegate _webView:willStartInputSession:]
1679         callback.
1680
1681         For example, clients that wish to present a custom input view will want
1682         to configure the WKFormInputSession's customInputView before the
1683         keyboard is presented. Otherwise the standard keyboard will begin to
1684         animate and then the custom input view will swap in later.
1685
1686         * UIProcess/API/Cocoa/_WKInputDelegate.h:
1687         * UIProcess/ios/WKContentViewInteraction.mm:
1688         (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
1689             Call -_webView:willStartInputSession: before assisting the node.
1690             Only create the form session if the delegate implements either
1691             the willStart or didStartInputSession callbacks.
1692
1693 2018-04-18  Chris Dumez  <cdumez@apple.com>
1694
1695         Add support for converting a local window to a remote window
1696         https://bugs.webkit.org/show_bug.cgi?id=184515
1697         <rdar://problem/39011318>
1698
1699         Reviewed by Ryosuke Niwa.
1700
1701         Add initial support for process-swapping when navigating cross-origin as a result
1702         of a window.open(). The window object returned by window.open() is initially same
1703         origin and is for about:blank. The navigation cross-origin then happens and the
1704         JS wrappers for the window then point to a cross-origin window which is remote (i.e.
1705         hosted in another WebProcess).
1706
1707         The RemoteDOMWindow exposed to JS looks like a regular cross-origin Window with a few
1708         exceptions due to our incomplete implementation (e.g. w.location returns null) and
1709         most of its API is currently not functional. The RemoteDOMWindow API will be implemented
1710         in a follow-up by relying on IPC.
1711
1712         * UIProcess/API/APIProcessPoolConfiguration.cpp:
1713         (API::ProcessPoolConfiguration::copy):
1714         * UIProcess/API/APIProcessPoolConfiguration.h:
1715         * UIProcess/API/C/WKContextConfigurationRef.cpp:
1716         (WKContextConfigurationProcessSwapsOnWindowOpenWithOpener):
1717         (WKContextConfigurationSetProcessSwapsOnWindowOpenWithOpener):
1718         * UIProcess/API/C/WKContextConfigurationRef.h:
1719         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
1720         * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
1721         (-[_WKProcessPoolConfiguration setProcessSwapsOnWindowOpenWithOpener:]):
1722         (-[_WKProcessPoolConfiguration processSwapsOnWindowOpenWithOpener]):
1723         Add ProcessPool configuration flag to turn on processSwap on window.open(), even
1724         if there is an opener.
1725
1726         * UIProcess/WebPageProxy.cpp:
1727         (WebKit::WebPageProxy::continueNavigationInNewProcess):
1728         If the navigation was triggered via window.open(), then set up on handler for when
1729         a DOMWindow is constructed for the main frame in the new process.
1730
1731         (WebKit::WebPageProxy::didCreateWindow):
1732         When a Window is constructed for the main frame in a new process on process swap,
1733         notify the old process that its representation of the window should become remote
1734         and provide it with the Frame / Window identifiers it needs.
1735
1736         * UIProcess/WebPageProxy.h:
1737         * UIProcess/WebPageProxy.messages.in:
1738
1739         * UIProcess/WebProcessPool.cpp:
1740         (WebKit::WebProcessPool::processForNavigation):
1741         Do process swapping on cross-origin window.open() if the corresponding setting is
1742         enabled.
1743
1744         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
1745         (WebKit::WebFrameLoaderClient::didCreateWindow):
1746         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
1747
1748         * WebProcess/WebPage/WebPage.cpp:
1749         (WebKit::WebPage::frameBecameRemote):
1750         This is called when process swapping has happened due to a window.open() navigation
1751         cross-origin, when a Frame / Window has been constructed in the new process. We do
1752         the following:
1753         - Construct a RemoteFrame / RemoteWindow using the provided global identifiers to
1754           represent the Frame / Window in the new process.
1755         - We transfer the WindowProxies from the old Frame's WindowProxyController to the
1756           new RemoteFrame's WindowProxyController.
1757         - We update the window proxied by those WindowProxies to be the new RemoteWindow.
1758         - We detach the old Frame as it is now remote and represented by the new RemoteFrame
1759           object we constructed.
1760         - If the old frame was the main frame (always the case currently), we close the page
1761           as it is no longer needed. The new RemoteFrame is currently owned by the RemoteWindow
1762           which is kept alive by its JS wrappers.
1763
1764         * WebProcess/WebPage/WebPage.h:
1765         * WebProcess/WebPage/WebPage.messages.in:
1766
1767 2018-04-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1768
1769         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.21.1 release.
1770
1771         * gtk/NEWS: Add release notes for 2.21.1.
1772
1773 2018-04-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1774
1775         Unreviewed. Remove symbols from webkitglib-symbols.map.
1776
1777         Remove symbols not present in WebKit.
1778
1779         * webkitglib-symbols.map:
1780
1781 2018-04-18  Carlos Garcia Campos  <cgarcia@igalia.com>
1782
1783         Unreviewed. Add missing symbols to webkitglib-symbols.map.
1784
1785         Add symbols global in JSC and present in WebKit.
1786
1787         * webkitglib-symbols.map:
1788
1789 2018-04-18  Fujii Hironori  <Hironori.Fujii@sony.com>
1790
1791         [Win][WebKit] Implement InjectedBundleWin.cpp
1792         https://bugs.webkit.org/show_bug.cgi?id=184525
1793
1794         Reviewed by Konstantin Tokarev.
1795
1796         * WebProcess/InjectedBundle/win/InjectedBundleWin.cpp:
1797         (WebKit::InjectedBundle::initialize):
1798
1799 2018-04-17  Wenson Hsieh  <wenson_hsieh@apple.com>
1800
1801         [Extra zoom mode] Programmatically changing focus when an element already has focus is a confusing experience
1802         https://bugs.webkit.org/show_bug.cgi?id=184635
1803         <rdar://problem/39440642>
1804
1805         Reviewed by Tim Horton.
1806
1807         Currently on iOS, we allow element focus to present UI if the keyboard is already shown. In extra zoom mode,
1808         this would lead to a confusing experience when the focus form control overlay is disabled, since fullscreen
1809         input view controllers are swapped out from underneath the user. Currently, this also puts the UI process into a
1810         bad state where the focused form control overlay is active, but still hidden. This patch makes some tweaks to
1811         input view controller handling in the UI process to address these issues, and also adds WebKitTestRunner support
1812         for simulating interactions with select menus in extra zoom mode. See comments below for more detail.
1813
1814         Test: fast/events/extrazoom/change-focus-during-change-event.html
1815
1816         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
1817
1818         Add new SPI delegate hooks to notify the UI delegate when view controllers are presented or dismissed in extra
1819         zoom mode. See -presentViewControllerForCurrentAssistedNode and -dismissAllInputViewControllers.
1820
1821         * UIProcess/WebProcessProxy.cpp:
1822         (WebKit::WebProcessProxy::takeBackgroundActivityTokenForFullscreenInput):
1823         (WebKit::WebProcessProxy::releaseBackgroundActivityTokenForFullscreenInput):
1824
1825         See the comment below -dismissAllInputViewControllers.
1826
1827         * UIProcess/WebProcessProxy.h:
1828         * UIProcess/ios/WKContentViewInteraction.mm:
1829         (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
1830
1831         In extra zoom mode, when changing focus from one assisted node to another, only allow the second node to be
1832         assisted if the focused form control overlay is being shown. Otherwise, (i.e. when a fullscreen input view
1833         controller is being presented), don't allow focus to start an input session.
1834
1835         Additionally, make a minor tweak to allow the previous node to blur, even if we are not showing the keyboard for
1836         the new focused element. Without this adjustment, in the case where the page has programmatically focused
1837         another element while a fullscreen input view controller is presented, we'll show the old view controller for
1838         the new focused element.
1839
1840         (-[WKContentView presentViewControllerForCurrentAssistedNode]):
1841         (-[WKContentView dismissAllInputViewControllers:]):
1842
1843         Currently, when a fullscreen input view controller is presented, the web process gets backgrounded. This
1844         prevents event handlers from executing, which leads to strange behaviors in many cases (for instance: if we
1845         have a multiple select, and the "change" event handler blurs the select, the user may check or uncheck multiple
1846         items, but only the first change will actually take effect).
1847
1848         To fix this, we maintain a background activity token while presenting an input view controller.
1849
1850         (-[WKContentView focusedFormControlViewDidBeginEditing:]):
1851
1852         Start hiding the focused form overlay when re-presenting an input view controller. This allows us to bail from
1853         showing fullscreen input UI for another focused element if focus programmatically changes while the current
1854         fullscreen input view controller is presented, due to the -isHidden check in -_startAssistingNode:.
1855
1856         (-[WKContentView selectFormAccessoryPickerRow:]):
1857
1858         Simulate tapping a given row in select menu UI in extra zoom mode.
1859
1860 2018-04-17  Conrad Shultz  <conrad_shultz@apple.com>
1861
1862         WebKit::DisplayLink maintains a strong reference to WebPageProxy, creating a reference cycle
1863         https://bugs.webkit.org/show_bug.cgi?id=184718
1864
1865         Reviewed by Tim Horton.
1866
1867         It turns out that the m_webPageProxy back-reference in DisplayLink, which was creating a
1868         reference cycle, wasn't ever read, so we can just remove it.
1869
1870         * UIProcess/mac/DisplayLink.cpp:
1871         (WebKit::DisplayLink::DisplayLink):
1872         * UIProcess/mac/DisplayLink.h:
1873
1874 2018-04-17  Wenson Hsieh  <wenson_hsieh@apple.com>
1875
1876         [Extra zoom mode] Double tap to zoom should account for text legibility in extra zoom mode
1877         https://bugs.webkit.org/show_bug.cgi?id=184631
1878         <rdar://problem/39303706>
1879
1880         Reviewed by Tim Horton.
1881
1882         Implement the text legibility heuristic alluded to in r230506 by iterating through text runs in the document (up
1883         to a maximum of 200) and building a histogram of font sizes that appear in the document, where each tally
1884         represents a character.
1885
1886         The first and second text legibility zoom scales are then computed based on the zoom scales needed to
1887         make 50% and 90% of the text legible, respectively. Here, a zoom scale that makes text legible is such that the
1888         text would have an apparent font size of a hard-coded constant (currently, 12) after zooming. This means the
1889         first and second text legibility scales may end up being close to one another, or even the same (in the case
1890         where there is only a single font size in the entire document). In this case, we just snap the first scale to
1891         the second, so that double tapping will only toggle between two zoom scales. In another case where the document
1892         has no text (e.g. an image document), we just fall back to a zoom scale of 1.
1893
1894         Test: fast/events/extrazoom/double-tap-to-zoom-on-full-width-text.html
1895
1896         * WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
1897         (WebKit::ViewGestureGeometryCollector::computeTextLegibilityScales):
1898
1899 2018-04-17  Megan Gardner  <megan_gardner@apple.com>
1900
1901         Don't activate selection on become first responder
1902         https://bugs.webkit.org/show_bug.cgi?id=184719
1903
1904         Reviewed by Tim Horton.
1905         
1906         If we activate the selection immediately on becoming first responder, we cause the selection view to delete itself
1907         since it is not guaranteed to have selection rects immediately due to async/two process architecture. The selection
1908         is activated already when the selection rects change, so there is no reason to activate it now. This has likely worked
1909         in the past because this selection assistant was only for editable text, which would immediately set a caret, which 
1910         is a selection. Now that this is for non-editable text as well, activating the selection is problematic.
1911
1912         * UIProcess/ios/WKContentViewInteraction.mm:
1913         (-[WKContentView becomeFirstResponderForWebView]):
1914
1915 2018-04-11  Brian Burg  <bburg@apple.com>
1916
1917         Web Automation: simulated mouse interactions should not be done until associated DOM events have been dispatched
1918         https://bugs.webkit.org/show_bug.cgi?id=184462
1919         <rdar://problem/39323336>
1920
1921         Reviewed by Carlos Garcia Campos and Tim Horton.
1922
1923         Covered by existing layout tests and actions endpoints in WebDriver test suite.
1924
1925         In preparation for implementing the W3C WebDriver command "Perform Actions", we need a way to
1926         know when a simulated mouse event has been fully processed by WebProcess and it is okay to continue
1927         to dispatch more simulated events.
1928
1929         This patch makes mouse events go through a queue as they are delivered to WebPageProxy. The approach
1930         is very similar to how key events are handled. In the key event case, lots of WebEvents can come out
1931         of typing one keystroke, so these need to be queued up and retired one by one when the WebProcess has
1932         finished handling each event. In some mouse event cases---particularly fake mouse moves---there can
1933         also be more than one mouse event waiting to be handled by WebProcess.
1934
1935         In the past, these queued mouse events were tracked with several member variables as different
1936         use cases emerged. These are all replaced with ordinary deque operations, such as peeking or
1937         checking the queue length.
1938
1939         * Platform/Logging.h: Add logging channel for mouse events.
1940         * UIProcess/Automation/WebAutomationSession.cpp:
1941         (WebKit::AutomationCommandError::toProtocolString): Add type-safe helper class for command errors.
1942         In future patches we can hide knowledge of how this is sent over the protocol by relying more on
1943         the convenience constructors and .toProtocolString() method.
1944
1945         (WebKit::WebAutomationSession::willShowJavaScriptDialog):
1946         This section needs adjustments. Since performMouseInteraction now depends on key events being processed
1947         prior to returning from the command, we need to abort any key event callbacks that are pending if an
1948         alert pops up as a result of sending a mousedown event. Any mouse events that are still queued will
1949         be handled when the alert is dismissed and the nested run loop exits.
1950
1951         (WebKit::WebAutomationSession::mouseEventsFlushedForPage):
1952         (WebKit::WebAutomationSession::keyboardEventsFlushedForPage):
1953         Modernize this a bit. Don't spread knowledge about how commands are sent back out into event handling code.
1954         Our wrapper callbacks in performXXXInteraction handle the protocol-specific details of the response.
1955
1956         (WebKit::WebAutomationSession::performMouseInteraction):
1957         Add code similar to performKeyboardInteractions so that the command doesn't finish until the mouse
1958         event has been fully handled. Unlike keyboards, sometimes mouse interactions don't turn into WebEvents
1959         so we also need to handle the case where there is nothing to be waited on because hit testing did
1960         not return a target to deliver the event to.
1961
1962         (WebKit::WebAutomationSession::performKeyboardInteractions):
1963         Modernize a little bit to use generic callbacks rather than protocol-generated callbacks in the
1964         event waiting/handling code. Now it matches the types used for the mouse event case.
1965
1966         * UIProcess/Automation/WebAutomationSession.h:
1967         (WebKit::AutomationCommandError::AutomationCommandError):
1968         Add a helper struct to hold an enumerated error name and an optional free-form error message.
1969
1970         * UIProcess/WebPageProxy.h:
1971         * UIProcess/WebPageProxy.cpp:
1972         (WebKit::webMouseEventTypeString):
1973         (WebKit::webKeyboardEventTypeString):
1974         (WebKit::WebPageProxy::handleMouseEvent):
1975         (WebKit::WebPageProxy::processNextQueuedMouseEvent):
1976         Split the old method into handleMouseEvent (called by other code) and processNextQueuedMouseEvent.
1977         The latter sends the next mouse event to WebProcess, and can be triggered in didReceiveEvent
1978         if there are more mouse events to be sent to WebProcess.
1979
1980         (WebKit::WebPageProxy::isProcessingMouseEvents const): Added.
1981         (WebKit::WebPageProxy::currentlyProcessedMouseDownEvent): Reimplemented on top of the deque.
1982         (WebKit::WebPageProxy::didReceiveEvent):
1983         Unify the code paths for different mouse event types to all use the deque. They also will
1984         notify the automation session if there are no more mouse events to send (i.e., interaction is over).
1985
1986         (WebKit::WebPageProxy::resetStateAfterProcessExited): Add handling for new map.
1987
1988 2018-04-17  Adrian Perez de Castro  <aperez@igalia.com>
1989
1990         [GTK][WPE] Build failure due to presence of Avahi's <dns_sd.h> header
1991         https://bugs.webkit.org/show_bug.cgi?id=184711
1992
1993         Unreviewed build fix.
1994
1995         * NetworkProcess/webrtc/NetworkMDNSRegister.h: Set ENABLE_MDNS only for PLATFORM(COCOA).
1996
1997 2018-04-17  Jonathan Bedard  <jbedard@apple.com>
1998
1999         Unreviewed rollout of r230632. Regression in memory usage.
2000
2001         That bug tracked in https://bugs.webkit.org/show_bug.cgi?id=184569.
2002
2003         * Shared/WebPreferences.yaml:
2004
2005 2018-04-17  Timothy Hatcher  <timothy@apple.com>
2006
2007         Always use LayerContentsType::IOSurface in minimal simulator mode
2008         https://bugs.webkit.org/show_bug.cgi?id=184710
2009
2010         Reviewed by Simon Fraser.
2011
2012         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
2013         (WebKit::RemoteLayerTreeHost::updateLayerTree):
2014
2015 2018-04-17  Ryosuke Niwa  <rniwa@webkit.org>
2016
2017         Release assert in InjectedBundle::postSynchronousMessage
2018         https://bugs.webkit.org/show_bug.cgi?id=184683
2019
2020         Reviewed by Wenson Hsieh.
2021
2022         Some injected bundles sends sync message when it's not safe to execute scripts.
2023
2024         Use DoNotProcessIncomingMessagesWhenWaitingForSyncReply option in InjectedBundle::postSynchronousMessage
2025         to avoid processing incoming sync IPC messages so that we don't execute arbitrary scripts in those cases.
2026
2027         * WebProcess/InjectedBundle/InjectedBundle.cpp:
2028         (WebKit::InjectedBundle::postSynchronousMessage):
2029
2030 2018-04-17  Chris Dumez  <cdumez@apple.com>
2031
2032         REGRESSION (r229831): CMD-clicking an iCloud web app link unexpectedly opens that link in a new tab and the current tab
2033         https://bugs.webkit.org/show_bug.cgi?id=184678
2034         <rdar://problem/39422122>
2035
2036         Reviewed by Alex Christensen.
2037
2038         Re-introduce synchronous code path which existed pre-r229831 and use it for fragment navigations.
2039
2040         * UIProcess/WebPageProxy.cpp:
2041         (WebKit::WebPageProxy::receivedPolicyDecision):
2042         (WebKit::WebPageProxy::decidePolicyForNavigationActionSync):
2043         * UIProcess/WebPageProxy.h:
2044         * UIProcess/WebPageProxy.messages.in:
2045         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
2046         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
2047         * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
2048
2049 2018-04-17  Michael Catanzaro  <mcatanzaro@igalia.com>
2050
2051         [WPE][GTK] GObject introspection annotation fixes: BackForwardList, NetworkProxySettings
2052         https://bugs.webkit.org/show_bug.cgi?id=184658
2053
2054         Reviewed by Carlos Garcia Campos.
2055
2056         Thanks to Dylan Simon for recommending these annotation fixes.
2057
2058         * UIProcess/API/glib/WebKitBackForwardList.cpp:
2059         * UIProcess/API/glib/WebKitNetworkProxySettings.cpp:
2060
2061 2018-04-17  Brent Fulgham  <bfulgham@apple.com>
2062
2063         [macOS] Don't establish unneeded Dock connections (Follow-up)
2064         https://bugs.webkit.org/show_bug.cgi?id=184664
2065         <rdar://problem/16863698>
2066
2067         Reviewed by Per Arne Vollan.
2068
2069         Because the Plugin process is driven by NSApplication's run loop, we aren't
2070         setting the 'don't connect to the dock' setting early enough.
2071
2072         This patch sets the flag in XPCServiceMain for those services that
2073         are linked to AppKit.
2074
2075         * PluginProcess/mac/PluginProcessMac.mm:
2076         (WebKit::PluginProcess::platformInitializeProcess): Remove unneeded code.
2077         * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
2078         (main):
2079         * WebProcess/cocoa/WebProcessCocoa.mm:
2080         (WebKit::WebProcess::platformInitializeWebProcess): Remove unneeded code.
2081
2082 2018-04-17  Saam Barati  <sbarati@apple.com>
2083
2084         Add system trace points for process launch and for initializeWebProcess
2085         https://bugs.webkit.org/show_bug.cgi?id=184669
2086
2087         Reviewed by Simon Fraser.
2088
2089         * UIProcess/Launcher/ProcessLauncher.cpp:
2090         (WebKit::ProcessLauncher::ProcessLauncher):
2091         (WebKit::ProcessLauncher::didFinishLaunchingProcess):
2092         * WebProcess/WebProcess.cpp:
2093         (WebKit::WebProcess::initializeWebProcess):
2094
2095 2018-04-16  Timothy Hatcher  <timothy@apple.com>
2096
2097         Unreviewed 32-bit build fix for r230673.
2098
2099         https://bugs.webkit.org/show_bug.cgi?id=184657
2100         rdar://problem/39463307
2101
2102         * Configurations/PluginProcessShim.xcconfig: Use the correct names.
2103
2104 2018-04-16  Andy Estes  <aestes@apple.com>
2105
2106         [iOS] Enable WKPDFView by default
2107         https://bugs.webkit.org/show_bug.cgi?id=184675
2108         <rdar://problem/27885452>
2109
2110         Reviewed by Darin Adler.
2111
2112         * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
2113         (-[WKWebViewContentProviderRegistry init]):
2114
2115 2018-04-16  Brent Fulgham  <bfulgham@apple.com>
2116
2117         [macOS] Don't establish unneeded Dock connections
2118         https://bugs.webkit.org/show_bug.cgi?id=184664
2119         <rdar://problem/16863698>
2120
2121         Reviewed by Simon Fraser.
2122
2123         There is no reason for the WebContent or Plugin processes to interact with
2124         the Dock. We should tell AppKit that we don't want this connection, and to
2125         avoid creating such connections.
2126
2127         * PluginProcess/mac/PluginProcessMac.mm:
2128         (WebKit::PluginProcess::platformInitializeProcess): Tell NSApplication to
2129         not create a Dock connection.
2130         * WebProcess/cocoa/WebProcessCocoa.mm:
2131         (WebKit::WebProcess::platformInitializeWebProcess): Ditto.
2132
2133 2018-04-16  Megan Gardner  <megan_gardner@apple.com>
2134
2135         Switch to UIWKTextInteractionAssistant for non-editable text
2136         https://bugs.webkit.org/show_bug.cgi?id=182834
2137
2138         Reviewed by Beth Dakin.
2139         
2140         Switch to only using one assistant for text selection.
2141
2142         * UIProcess/ios/WKContentViewInteraction.mm:
2143         (-[WKContentView useSelectionAssistantWithGranularity:]):
2144
2145 2018-04-16  Youenn Fablet  <youenn@apple.com>
2146
2147         Use NetworkLoadChecker to handle synchronous HTTP loads
2148         https://bugs.webkit.org/show_bug.cgi?id=184240
2149
2150         Reviewed by Chris Dumez.
2151
2152         For every NetworkResourceLoader synchronous load, we create a NetworkLoadChecker.
2153         NetworkLoadChecker handles all security checks in that case.
2154         This allows supporting cross-origin loads for synchronous XHR.
2155
2156         Updated NetworkCORSPreflightChecker to return the result as a ResourceError.
2157         This is used to convey any error message from NetworkProcess to the JS console.
2158         Ensure NetworkCORSPreflightChecker computes correctly Access-Control-Request-Headers value
2159         by providing the headers set by the application plus Referrer/Origin.
2160
2161         * NetworkProcess/NetworkCORSPreflightChecker.cpp:
2162         (WebKit::NetworkCORSPreflightChecker::~NetworkCORSPreflightChecker):
2163         (WebKit::NetworkCORSPreflightChecker::willPerformHTTPRedirection):
2164         (WebKit::NetworkCORSPreflightChecker::didReceiveChallenge):
2165         (WebKit::NetworkCORSPreflightChecker::didCompleteWithError):
2166         (WebKit::NetworkCORSPreflightChecker::wasBlocked):
2167         (WebKit::NetworkCORSPreflightChecker::cannotShowURL):
2168         * NetworkProcess/NetworkLoadChecker.cpp:
2169         (WebKit::NetworkLoadChecker::checkCORSRequestWithPreflight):
2170         * NetworkProcess/NetworkResourceLoader.cpp:
2171         (WebKit::NetworkResourceLoader::NetworkResourceLoader):
2172         (WebKit::NetworkResourceLoader::retrieveCacheEntry):
2173         (WebKit::NetworkResourceLoader::didReceiveResponse):
2174         (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
2175         (WebKit::NetworkResourceLoader::continueWillSendRequest):
2176         (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
2177         (WebKit::NetworkResourceLoader::validateCacheEntry):
2178         * NetworkProcess/NetworkResourceLoader.h:
2179         * WebProcess/Network/WebLoaderStrategy.cpp:
2180         (WebKit::WebLoaderStrategy::loadResourceSynchronously):
2181         * WebProcess/Network/WebLoaderStrategy.h:
2182
2183 2018-04-16  Brian Burg  <bburg@apple.com>
2184
2185         [Cocoa] Web Automation: add SPI to terminate automation session and disconnect the remote end
2186         https://bugs.webkit.org/show_bug.cgi?id=184523
2187         <rdar://problem/39368599>
2188
2189         Reviewed by Simon Fraser.
2190
2191         When a user breaks the automation glass pane and chooses "Stop Session", there is no way
2192         for Safari to actually disconnect the remote connection using automation-related ObjC SPI.
2193         This can lead to sessions getting stuck and safaridriver is unable to request a new session.
2194
2195         Expose the -terminate method as SPI. This disconnects the remote connection and then notifies
2196         the session delegate that the remote disconnected. At that point, Safari can uninstall
2197         the session from the process pool and tear down other session state.
2198
2199         * UIProcess/API/Cocoa/_WKAutomationSession.h:
2200         * UIProcess/API/Cocoa/_WKAutomationSession.mm:
2201         (-[_WKAutomationSession terminate]):
2202
2203 2018-04-16  Timothy Hatcher  <timothy@apple.com>
2204
2205         Clean up OTHER_LDFLAGS for WebKit processes
2206         https://bugs.webkit.org/show_bug.cgi?id=184657
2207
2208         Reviewed by Jer Noble.
2209
2210         * Configurations/PluginProcessShim.xcconfig:
2211         * Configurations/PluginService.32.xcconfig:
2212         * Configurations/PluginService.64.xcconfig:
2213         * Configurations/WebContentService.xcconfig:
2214
2215 2018-04-15  Michael Catanzaro  <mcatanzaro@igalia.com>
2216
2217         [WPE] Install files needed for WebKitWebExtensions
2218         https://bugs.webkit.org/show_bug.cgi?id=179915
2219
2220         Reviewed by Žan Doberšek.
2221
2222         * PlatformWPE.cmake: Install pkg-config file, injected bundle, and API headers.
2223         * UIProcess/API/glib/WebKitWebContext.cpp: Load the injected bundle when installed.
2224         * wpe/wpe-web-extension.pc.in: Added.
2225
2226 2018-04-14  Carlos Eduardo Ramalho  <cadubentzen@gmail.com>
2227
2228         [GTK][WPE] Build is broken after r230640
2229         https://bugs.webkit.org/show_bug.cgi?id=184623
2230
2231         Reviewed by Žan Doberšek.
2232
2233         UIProcess/SuspendedPageProxy.cpp was not included to CMake build in r230640.
2234
2235         * CMakeLists.txt: Added UIProcess/SuspendedPageProxy.cpp to WebKit_SOURCES.
2236
2237 2018-04-13  Ryan Haddad  <ryanhaddad@apple.com>
2238
2239         Unreviewed, rolling out r230447.
2240
2241         Caused flaky selection test failures on iOS
2242
2243         Reverted changeset:
2244
2245         "Switch to UIWKTextInteractionAssistant for non-editable text"
2246         https://bugs.webkit.org/show_bug.cgi?id=182834
2247         https://trac.webkit.org/changeset/230447
2248
2249 2018-04-13  Chris Dumez  <cdumez@apple.com>
2250
2251         Split WindowProxy handling out of ScriptController and into a new class owned by AbstractFrame
2252         https://bugs.webkit.org/show_bug.cgi?id=184591
2253
2254         Reviewed by Sam Weinig.
2255
2256         Split WindowProxy handling out of ScriptController and into a new class owned by AbstractFrame.
2257         RemoteFrames do not need a ScriptController but do need to maintain WindowProxies.
2258         This is work towards fixing Bug 184515.
2259
2260         * WebProcess/Plugins/PluginView.cpp:
2261         (WebKit::PluginView::windowScriptNPObject):
2262
2263 2018-04-13  Brady Eidson  <beidson@apple.com>
2264
2265         Introduce SuspendedPageProxy to keep old web processes around after their WebPageProxy has been swapped to a new one.
2266         https://bugs.webkit.org/show_bug.cgi?id=184559
2267
2268         Reviewed by Alex Christensen.
2269
2270         Before this patch, when a WebPageProxy navigates and is swapped to a new process, the old process almost always goes away.
2271
2272         This is not desirable for a few reasons:
2273         1 - We can't keep the PageCache working for back/forward scenarios
2274         2 - We throw away a "foo.com" web process, meaning the next time we need to host a "foo.com" web page we have to launch
2275             and initialize a new web process.
2276
2277         This patch adds a SuspendedPageProxy object to keep around the old web process and to manage communication with it.
2278
2279         For now, a WebPageProxy keeps exactly one "suspended page" representing the most recently visited page and its process.
2280         Additionally, that process is never reused.
2281
2282         So no benefit is achieved with this patch, but it enables future benefits.
2283
2284         * Platform/Logging.h:
2285
2286         * Shared/WebBackForwardListItem.cpp:
2287         (WebKit::WebBackForwardListItem::setSuspendedPage):
2288         * Shared/WebBackForwardListItem.h:
2289
2290         New object to represent the state of a WebPageProxy in an old web process that is not currently hosting the view.
2291         * UIProcess/SuspendedPageProxy.cpp: Added.
2292         (WebKit::SuspendedPageProxy::SuspendedPageProxy):
2293         (WebKit::SuspendedPageProxy::~SuspendedPageProxy):
2294         (WebKit::SuspendedPageProxy::webProcessDidClose):
2295         (WebKit::SuspendedPageProxy::didFinishLoad):
2296         (WebKit::SuspendedPageProxy::didReceiveMessage):
2297         (WebKit::SuspendedPageProxy::loggingString const):
2298         * UIProcess/SuspendedPageProxy.h: Copied from Source/WebKit/Platform/Logging.h.
2299         (WebKit::SuspendedPageProxy::create):
2300         (WebKit::SuspendedPageProxy::page const):
2301         (WebKit::SuspendedPageProxy::process const):
2302         (WebKit::SuspendedPageProxy::item const):
2303         (WebKit::SuspendedPageProxy::finishedSuspending const):
2304
2305         * UIProcess/WebPageProxy.cpp:
2306         (WebKit::WebPageProxy::reattachToWebProcess):
2307         (WebKit::WebPageProxy::attachToProcessForNavigation):
2308         (WebKit::WebPageProxy::maybeCreateSuspendedPage):
2309         (WebKit::WebPageProxy::suspendedPageProcessClosed):
2310         (WebKit::WebPageProxy::receivedPolicyDecision):
2311         (WebKit::WebPageProxy::didFinishLoadForFrame):
2312         * UIProcess/WebPageProxy.h:
2313
2314         * UIProcess/WebProcessProxy.cpp:
2315         (WebKit::WebProcessProxy::suspendWebPageProxy):
2316         (WebKit::WebProcessProxy::suspendedPageWasDestroyed):
2317         (WebKit::WebProcessProxy::removeWebPage):
2318         (WebKit::WebProcessProxy::didReceiveMessage): Optionally pass WebPageProxy messages along to SuspendedPageProxy objects.
2319         (WebKit::WebProcessProxy::didClose):
2320         (WebKit::WebProcessProxy::maybeShutDown):
2321         (WebKit::WebProcessProxy::canTerminateChildProcess): Don't terminate child processes if they still have suspended pages.
2322         * UIProcess/WebProcessProxy.h:
2323
2324         * WebKit.xcodeproj/project.pbxproj:
2325
2326         * WebProcess/WebPage/WebPage.cpp:
2327         (WebKit::WebPage::setIsSuspended):
2328         * WebProcess/WebPage/WebPage.h:
2329         (WebKit::WebPage::isSuspended const): For now, used only by WebProcess::updateActivePages. Will have more uses soon.
2330         * WebProcess/WebPage/WebPage.messages.in:
2331
2332         * WebProcess/WebProcess.messages.in:
2333         * WebProcess/cocoa/WebProcessCocoa.mm:
2334         (WebKit::WebProcess::updateActivePages): Allow the UIProcess to request an update of the web processes user visible name.
2335
2336 2018-04-13  Daniel Bates  <dabates@apple.com>
2337
2338         Inline NetworkLoad::sharedWillSendRedirectedRequest() into NetworkLoad::willPerformHTTPRedirection()
2339         https://bugs.webkit.org/show_bug.cgi?id=184593
2340
2341         Reviewed by Alex Christensen.
2342
2343         Following the removal of the pre-Network Session code in r227364, NetworkLoad::sharedWillSendRedirectedRequest()
2344         is only referenced from NetworkLoad::willPerformHTTPRedirection(). We should inline its
2345         implementation into the NetworkLoad::willPerformHTTPRedirection(), remove a function call,
2346         and the cognitive load to follow such a function call when reading the code.
2347
2348         No functionality changed. So, no new tests.
2349
2350         * NetworkProcess/NetworkLoad.cpp:
2351         (WebKit::NetworkLoad::willPerformHTTPRedirection): Moved the implementation of NetworkLoad::sharedWillSendRedirectedRequest()
2352         into this function.
2353         (WebKit::NetworkLoad::sharedWillSendRedirectedRequest): Deleted. Moved its implementation
2354         into NetworkLoad::willPerformHTTPRedirection().
2355         * NetworkProcess/NetworkLoad.h:
2356
2357 2018-04-13  Daniel Bates  <dabates@apple.com>
2358
2359         Inline NetworkLoad::sharedDidReceiveResponse() into NetworkLoad::notifyDidReceiveResponse()
2360         https://bugs.webkit.org/show_bug.cgi?id=184592
2361
2362         Reviewed by Alex Christensen.
2363
2364         Following the removal of the pre-Network Session code in r227364, NetworkLoad::sharedDidReceiveResponse()
2365         is only referenced from NetworkLoad::notifyDidReceiveResponse(). We should inline its
2366         implementation into the NetworkLoad::notifyDidReceiveResponse(), remove a function
2367         call, and the cognitive load to follow such a function call when reading the code.
2368
2369         No functionality changed. So, no new tests.
2370
2371         * NetworkProcess/NetworkLoad.cpp:
2372         (WebKit::NetworkLoad::notifyDidReceiveResponse): Moved the implementation of NetworkLoad::sharedDidReceiveResponse()
2373         into this function.
2374         (WebKit::NetworkLoad::sharedDidReceiveResponse): Deleted. Moved its implementation into
2375         NetworkLoad::notifyDidReceiveResponse().
2376         * NetworkProcess/NetworkLoad.h:
2377
2378 2018-04-13  Brent Fulgham  <bfulgham@apple.com>
2379
2380         REGRESSION(r230468): Improper assertion firing under STP
2381         <rdar://problem/39411676>
2382
2383         Unreviewed, rolling out an improper assertion.
2384
2385         I added an assertion in Bug 184322 that should not have been added. I did not notice that this
2386         call stack was always used in builds where NSApp is still active. Builds where we stop relying
2387         on AppKit runloops uses a different code path to shut down.
2388
2389         * Shared/mac/ChildProcessMac.mm:
2390         (WebKit::ChildProcess::stopNSAppRunLoop):
2391
2392 2018-04-12  Antoine Quint  <graouts@apple.com>
2393
2394         [Web Animations] Turn CSS Animations and CSS Transitions as Web Animations on by default
2395         https://bugs.webkit.org/show_bug.cgi?id=184569
2396         <rdar://problem/38671301>
2397
2398         Reviewed by Jon Lee.
2399
2400         * Shared/WebPreferences.yaml:
2401
2402 2018-04-13  Xabier Rodriguez Calvar  <calvaris@igalia.com>
2403
2404         [GStreamer] Convert GStreamerUtilities in GStreamerCommon and include the GStreamer smart pointer traits
2405         https://bugs.webkit.org/show_bug.cgi?id=184533
2406
2407         Reviewed by Philippe Normand.
2408
2409         Renamed GStreamerUtilities* files into GStreamerCommon* and
2410         modified files including them accordingly. Include
2411         GRefPtrGStreamer.h and GUniquePtrGStreamer.h in GStreamerCommon.h
2412         to avoid problems destroying objects when those files are
2413         forgotten to be included.
2414
2415         * UIProcess/gtk/WebProcessPoolGtk.cpp:
2416         * UIProcess/wpe/WebProcessPoolWPE.cpp:
2417         * WebProcess/soup/WebProcessSoup.cpp:
2418
2419 2018-04-12  Beth Dakin  <bdakin@apple.com>
2420
2421         Fix the MOBILE_WIFI build
2422         https://bugs.webkit.org/show_bug.cgi?id=184571
2423         -and corresponding-
2424         <rdar://problem/39398181>
2425
2426         Reviewed by Jer Noble.
2427
2428         * config.h:
2429
2430 2018-04-12  Beth Dakin  <bdakin@apple.com>
2431
2432         Use -iframework to ensure that frameworks from user paths and system paths are 
2433         ordered appropriately
2434         https://bugs.webkit.org/show_bug.cgi?id=184557
2435         -and corresponding-
2436         rdar://problem/39386359
2437
2438         Reviewed by Dean Jackson.
2439
2440         * Configurations/WebKit.xcconfig:
2441
2442 2018-04-12  Wenson Hsieh  <wenson_hsieh@apple.com>
2443
2444         [Extra zoom mode] Suppress UI for inputs of type file in extra zoom mode
2445         https://bugs.webkit.org/show_bug.cgi?id=184556
2446         <rdar://problem/39062239>
2447
2448         Reviewed by Andy Estes.
2449
2450         When running in this mode, we don't have the facilities to present document picker UI. For now, just make this
2451         feature fail gracefully.
2452
2453         * UIProcess/ios/forms/WKFileUploadPanel.mm:
2454         (-[WKFileUploadPanel presentWithParameters:resultListener:]):
2455         (-[WKFileUploadPanel platformSupportsPickerViewController]):
2456
2457 2018-04-12  Megan Gardner  <megan_gardner@apple.com>
2458
2459         Remove block selection code
2460         https://bugs.webkit.org/show_bug.cgi?id=184470
2461
2462         Reviewed by Timothy Hatcher.
2463         
2464         Remove block selection code that isn't run and is currently not even used.
2465         Had to put this back in for a bug in the mid-year release, but we're past that
2466         so it's time for this to go away.
2467
2468         * Platform/spi/ios/UIKitSPI.h:
2469         * UIProcess/PageClient.h:
2470         * UIProcess/WebPageProxy.h:
2471         * UIProcess/WebPageProxy.messages.in:
2472         * UIProcess/ios/PageClientImplIOS.h:
2473         * UIProcess/ios/PageClientImplIOS.mm:
2474         (WebKit::PageClientImpl::stopAssistingNode):
2475         (WebKit::PageClientImpl::didUpdateBlockSelectionWithTouch): Deleted.
2476         * UIProcess/ios/WKContentViewInteraction.h:
2477         * UIProcess/ios/WKContentViewInteraction.mm:
2478         (toSelectionHandlePosition): Deleted.
2479         (-[WKContentView _didUpdateBlockSelectionWithTouch:withFlags:growThreshold:shrinkThreshold:]): Deleted.
2480         (-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:]): Deleted.
2481         (-[WKContentView changeBlockSelectionWithTouchAt:withSelectionTouch:forHandle:]): Deleted.
2482         * UIProcess/ios/WebPageProxyIOS.mm:
2483         (WebKit::WebPageProxy::saveImageToLibrary):
2484         (WebKit::WebPageProxy::updateBlockSelectionWithTouch): Deleted.
2485         (WebKit::WebPageProxy::didUpdateBlockSelectionWithTouch): Deleted.
2486         * WebProcess/WebPage/WebPage.h:
2487         * WebProcess/WebPage/WebPage.messages.in:
2488         * WebProcess/WebPage/ios/WebPageIOS.mm:
2489         (WebKit::rangeAtWordBoundaryForPosition):
2490         (WebKit::distanceBetweenRectsForPosition): Deleted.
2491         (WebKit::rectsEssentiallyTheSame): Deleted.
2492         (WebKit::unionDOMRanges): Deleted.
2493         (WebKit::computeEdgeCenter): Deleted.
2494         (WebKit::WebPage::expandedRangeFromHandle): Deleted.
2495         (WebKit::WebPage::contractedRangeFromHandle): Deleted.
2496         (WebKit::WebPage::computeExpandAndShrinkThresholdsForHandle): Deleted.
2497         (WebKit::WebPage::rangeForBlockAtPoint): Deleted.
2498         (WebKit::shouldExpand): Deleted.
2499         (WebKit::WebPage::changeBlockSelection): Deleted.
2500         (WebKit::WebPage::updateBlockSelectionWithTouch): Deleted.
2501         
2502 2018-04-12  Megan Gardner  <megan_gardner@apple.com>
2503
2504         Don't have selections get stuck in editable elements
2505         https://bugs.webkit.org/show_bug.cgi?id=184483
2506
2507         Reviewed by Timothy Hatcher.
2508         
2509         When selecting in editable elements, if the keyboard does not come up, which is not required,
2510         then the selections are stuck in that element. If you try and select something in web content,
2511         it will only select in the editable element. By clearing the assisted node when clearing a selection,
2512         it no longer sticks. Also, textSelectionAssistant should not be used as if we are currently editing. 
2513         Change it to the function we created for that purpose in a pervious patch.
2514
2515         * UIProcess/ios/WKContentViewInteraction.mm:
2516         (-[WKContentView clearSelection]):
2517         (-[WKContentView _isInteractingWithAssistedNode]):
2518
2519 2018-04-12  Michael Catanzaro  <mcatanzaro@igalia.com>
2520
2521         [WPE] Move libWPEWebInspectorResources.so to pkglibdir
2522         https://bugs.webkit.org/show_bug.cgi?id=184379
2523
2524         Reviewed by Žan Doberšek.
2525
2526         This is important to allow parallel installation.
2527
2528         * PlatformWPE.cmake:
2529
2530 2018-04-12  Michael Catanzaro  <mcatanzaro@igalia.com>
2531
2532         [WPE] Improve include hierarchy
2533         https://bugs.webkit.org/show_bug.cgi?id=184376
2534
2535         Reviewed by Žan Doberšek.
2536
2537         Install our headers under /usr/include/wpe-webkit-0.1/wpe instead of
2538         /usr/include/wpe-0.1/WPE/wpe. Too much WPE, not enough WebKit!
2539
2540         * PlatformWPE.cmake:
2541         * wpe/wpe-webkit.pc.in:
2542
2543 2018-04-11  Andy Estes  <aestes@apple.com>
2544
2545         [iOS] Add a mechanism for holding Wi-Fi assertions
2546         https://bugs.webkit.org/show_bug.cgi?id=184520
2547         <rdar://problem/39025726>
2548
2549         Reviewed by Sam Weinig.
2550
2551         Add plumbing for holding a Wi-Fi assertion on iOS as long as there are active
2552         network data tasks. This functionality is turned off by default right now.
2553
2554         * Configurations/Network-iOS.entitlements:
2555         * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
2556         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
2557         (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
2558         * NetworkProcess/cocoa/WiFiAssertionHolder.cpp: Added.
2559         (WebKit::ensureWiFiManagerClient): Create a global WiFiManagerClient when needed.
2560         (WebKit::WiFiAssertionHolder::WiFiAssertionHolder): If this is the first active
2561         Wi-Fi assertion holder, set the client's type to kWiFiClientTypeBackground.
2562         (WebKit::WiFiAssertionHolder::~WiFiAssertionHolder): If the last active Wi-Fi
2563         assertion holder is being destroyed, set the client's type back to
2564         kWiFiClientTypeNormal.
2565         * NetworkProcess/cocoa/WiFiAssertionHolder.h: Added.
2566         * Platform/Logging.h: Added a logging channel for Wi-Fi assertions.
2567         * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb:
2568         * WebKit.xcodeproj/project.pbxproj:
2569
2570 2018-04-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2571
2572         [GTK] Switch to use always complex text code path
2573         https://bugs.webkit.org/show_bug.cgi?id=183285
2574
2575         Reviewed by Michael Catanzaro.
2576
2577         Now that we have branched for 2.20, it's a good time to try using complex text path always. We can simply force
2578         it for GTK+ port and see how it works for the whole release cycle and if we don't notice any issues or
2579         performance regressions we release 2.22 with complex text path forced. A debug env variable is added to switch
2580         back to auto without having to recompile. After 2.22 is released we can make a final decision and remove the env
2581         variable.
2582
2583         * UIProcess/gtk/WebProcessPoolGtk.cpp:
2584         (WebKit::WebProcessPool::platformInitializeWebProcess): Force complex text code path unless
2585         WEBKIT_FORCE_COMPLEX_TEXT is present and set to 0.
2586
2587 2018-04-11  Zan Dobersek  <zdobersek@igalia.com>
2588
2589         [WPE] Make WebKitWebViewBackend object mandatory for webkit_web_view_new*() constructors
2590         https://bugs.webkit.org/show_bug.cgi?id=184513
2591
2592         Reviewed by Michael Catanzaro.
2593
2594         webkit_web_view_new*() constructors should always expect a non-null
2595         WebKitWebViewBackend object, forcing the user to specify how the
2596         wpe_view_backend object is managed for the WebKitWebView that's being
2597         created.
2598
2599         webkitWebViewBackendCreateDefault() and the default
2600         _WebKitWebViewBackend() constructor are removed. WPE-specific
2601         webkit_web_view_new*() entrypoints are updated to bail if the passed-in
2602         WebKitWebViewBackend object is null. Documentation is updated
2603         accordingly.
2604
2605         * UIProcess/API/glib/WebKitWebView.cpp:
2606         (webkitWebViewConstructed):
2607         * UIProcess/API/wpe/WebKitWebViewBackend.cpp:
2608         (webkitWebViewBackendCreateDefault): Deleted.
2609         * UIProcess/API/wpe/WebKitWebViewBackendPrivate.h:
2610         * UIProcess/API/wpe/WebKitWebViewWPE.cpp:
2611         (webkit_web_view_new):
2612         (webkit_web_view_new_with_context):
2613         (webkit_web_view_new_with_related_view):
2614         (webkit_web_view_new_with_settings):
2615         (webkit_web_view_new_with_user_content_manager):
2616
2617 2018-04-11  Fujii Hironori  <Hironori.Fujii@sony.com>
2618
2619         [curl][WebKit] Implement NetworkDataTaskCurl
2620         https://bugs.webkit.org/show_bug.cgi?id=184488
2621
2622         Reviewed by Alex Christensen.
2623
2624         * NetworkProcess/NetworkDataTask.cpp:
2625         (WebKit::NetworkDataTask::create):
2626         * NetworkProcess/curl/NetworkDataTaskCurl.cpp: Added.
2627         (WebKit::NetworkDataTaskCurl::NetworkDataTaskCurl):
2628         (WebKit::NetworkDataTaskCurl::~NetworkDataTaskCurl):
2629         (WebKit::NetworkDataTaskCurl::resume):
2630         (WebKit::NetworkDataTaskCurl::suspend):
2631         (WebKit::NetworkDataTaskCurl::cancel):
2632         (WebKit::NetworkDataTaskCurl::invalidateAndCancel):
2633         (WebKit::NetworkDataTaskCurl::state const):
2634         (WebKit::NetworkDataTaskCurl::createCurlRequest):
2635         (WebKit::NetworkDataTaskCurl::curlDidSendData):
2636         (WebKit::NetworkDataTaskCurl::curlDidReceiveResponse):
2637         (WebKit::NetworkDataTaskCurl::curlDidReceiveBuffer):
2638         (WebKit::NetworkDataTaskCurl::curlDidComplete):
2639         (WebKit::NetworkDataTaskCurl::curlDidFailWithError):
2640         (WebKit::NetworkDataTaskCurl::shouldRedirectAsGET):
2641         (WebKit::NetworkDataTaskCurl::willPerformHTTPRedirection):
2642         (WebKit::NetworkDataTaskCurl::tryHttpAuthentication):
2643         (WebKit::NetworkDataTaskCurl::restartWithCredential):
2644         (WebKit::NetworkDataTaskCurl::appendCookieHeader):
2645         (WebKit::NetworkDataTaskCurl::handleCookieHeaders):
2646         * NetworkProcess/curl/NetworkDataTaskCurl.h: Added.
2647         * PlatformWin.cmake:
2648
2649 2018-04-11  Wenson Hsieh  <wenson_hsieh@apple.com>
2650
2651         [Extra zoom mode] Support pushing input view controllers onto the navigation stack
2652         https://bugs.webkit.org/show_bug.cgi?id=184397
2653         <rdar://problem/39265294>
2654
2655         Reviewed by Timothy Hatcher.
2656
2657         Currently, all input view controllers in extra zoom mode are presented modally. However, the latest iteration of
2658         the HI specification depicts most of these view controllers (with the exception of time pickers) being presented
2659         and dismissed via navigation stack. Since WebKit's iOS API surface doesn't force clients to embed WKWebViews
2660         within a view controller with a corresponding UINavigationController, we cannot always guarantee that UI
2661         presented when focusing form controls in a web view will be pushed onto the navigation stack; as such, the
2662         approach taken in this patch will automatically allow WKWebView clients that already embed WKWebViews within a
2663         UINavigationController to hook into this behavior, with modal presentation as a fallback.
2664
2665         At a high level, this patch makes the following tweaks to implement this behavior:
2666
2667         1. Store the currently presented view controller using a single member variable
2668            (_presentedFullScreenInputViewController) instead of having one for each type. This makes bookkeepping around
2669            which view controller to present or dismiss much more straightforward.
2670
2671         2. Replace WKFocusedFormControlViewController with just WKFocusedFormControlView. This addresses problems with
2672            pushing an input view controller onto the navigation stack after presenting the focused form control view
2673            controller modally. Now, we'll only need to present or push one view controller on the navigation stack.
2674
2675         3. Remove -handleWheelEvent: forwarding to date and time pickers. Pushing date picker view controllers onto the
2676            navigation stack rather than presenting them modally means that we end up in a state where neither the
2677            WKContentView nor WKTimePickerViewController are first responder, which renders time pickers unusable.
2678            Instead, have the WKTimePickerViewController actually become first responder when presenting.
2679
2680         4. Lastly, and most importantly: change -presentViewControllerForCurrentAssistedNode and
2681            -dismissAllInputViewControllers to try and push onto a navigation stack if possible, and fall back to modal
2682            presentation.
2683
2684         * UIProcess/ios/WKContentViewInteraction.h:
2685
2686         Remove the separate member variables for each type of input view controller, and instead have one to keep track
2687         of the current (and only) presented input view controller.
2688
2689         * UIProcess/ios/WKContentViewInteraction.mm:
2690         (-[WKContentView _willStartScrollingOrZooming]):
2691         (-[WKContentView _didEndScrollingOrZooming]):
2692         (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
2693         (-[WKContentView _stopAssistingNode]):
2694
2695         Boilerplate renaming of _focusedFormControlViewController => _focusedFormControlView.
2696
2697         (-[WKContentView reloadContextViewForPresentedListViewController]):
2698
2699         Adjust for consolidation of the different input view controller member variables to a single member (see changes
2700         in WKContentViewInteraction.h).
2701
2702         (-[WKContentView addFocusedFormControlOverlay]):
2703         (-[WKContentView removeFocusedFormControlOverlay]):
2704         (-[WKContentView presentViewControllerForCurrentAssistedNode]):
2705         (-[WKContentView dismissAllInputViewControllers:]):
2706
2707         Add an `animated` argument. In the case where a different view controller was presented after presenting the
2708         input view controller, this allows us to dismiss the other view controller with animation, and directly reveal
2709         the web view or focus overlay underneath.
2710
2711         (-[WKContentView focusedFormControlViewDidSubmit:]):
2712         (-[WKContentView focusedFormControlViewDidCancel:]):
2713         (-[WKContentView focusedFormControlViewDidBeginEditing:]):
2714         (-[WKContentView rectForFocusedFormControlView:]):
2715         (-[WKContentView nextRectForFocusedFormControlView:]):
2716         (-[WKContentView previousRectForFocusedFormControlView:]):
2717         (-[WKContentView scrollViewForFocusedFormControlView:]):
2718         (-[WKContentView actionNameForFocusedFormControlView:]):
2719         (-[WKContentView focusedFormControlViewDidRequestNextNode:]):
2720         (-[WKContentView focusedFormControlViewDidRequestPreviousNode:]):
2721         (-[WKContentView hasNextNodeForFocusedFormControlView:]):
2722         (-[WKContentView hasPreviousNodeForFocusedFormControlView:]):
2723         (-[WKContentView focusedFormControllerDidUpdateSuggestions:]):
2724
2725         Boilerplate renaming of focus overlay delegate methods.
2726
2727         (-[WKContentView _wheelChangedWithEvent:]):
2728
2729         Remove event forwarding hacks for date and time inputs, now that they directly become first responder.
2730
2731         (-[WKContentView presentFocusedFormControlViewController:]): Deleted.
2732         (-[WKContentView dismissFocusedFormControlViewController:]): Deleted.
2733
2734         Renamed to -addFocusedFormControlOverlay and -removeFocusedFormControlOverlay.
2735
2736         (-[WKContentView dismissAllInputViewControllers]): Deleted.
2737         (-[WKContentView focusedFormControlControllerDidSubmit:]): Deleted.
2738         (-[WKContentView focusedFormControlControllerDidCancel:]): Deleted.
2739         (-[WKContentView focusedFormControlControllerDidBeginEditing:]): Deleted.
2740         (-[WKContentView rectForFocusedFormControlController:inCoordinateSpace:]): Deleted.
2741         (-[WKContentView nextRectForFocusedFormControlController:inCoordinateSpace:]): Deleted.
2742         (-[WKContentView previousRectForFocusedFormControlController:inCoordinateSpace:]): Deleted.
2743         (-[WKContentView scrollViewForFocusedFormControlController:]): Deleted.
2744         (-[WKContentView actionNameForFocusedFormControlController:]): Deleted.
2745         (-[WKContentView focusedFormControlControllerDidRequestNextNode:]): Deleted.
2746         (-[WKContentView focusedFormControlControllerDidRequestPreviousNode:]): Deleted.
2747         (-[WKContentView hasNextNodeForFocusedFormControlController:]): Deleted.
2748         (-[WKContentView hasPreviousNodeForFocusedFormControlController:]): Deleted.
2749         * UIProcess/ios/forms/WKFocusedFormControlViewController.h: Removed.
2750         * UIProcess/ios/forms/WKFocusedFormControlViewController.mm: Removed.
2751
2752         Completely remove WKFocusedFormControlViewController; instead, just directly place the focused form overlay in
2753         the WKWebView's hierarchy. In the case where we have a navigation stack to push to, we can no longer modally
2754         present the focused form overlay as a separate view controller using the UINavigationController, and then
2755         immediately push the input view controller on top of the navigation stack, since the navigation stack isn't
2756         updated until after the animation of the focused form overlay presentation is complete. Rather than hack around
2757         this limitation by dispatch_after-ing after presenting the overlay's view controller, we should just make the
2758         overlay a view. This also fixes the case where a client embedding a WKWebView that is smaller than the bounds of
2759         the screen will no longer see the entire screen dim when focusing an input, but instead, just the web content.
2760
2761         * WebKit.xcodeproj/project.pbxproj:
2762
2763 2018-04-11  Youenn Fablet  <youenn@apple.com>
2764
2765         Pass FetchOptions and SecurityOrigin as load parameters from WebProcess to NetworkProcess
2766         https://bugs.webkit.org/show_bug.cgi?id=184374
2767
2768         Reviewed by Chris Dumez.
2769
2770         Pass full FetchOptions parameters as part of NetworkResourceLoadParameters.
2771         This will allow handling redirection mode as well as credentials in case of cross origin redirections.
2772         In case of SameOrigin credentials and there is a redirection from same-origin to cross-origin,
2773         we will be able to stop using credentials without going to WebProcess.
2774
2775         To handle properly cross-origin checks, we have to be able to use SecurityOrigin as in WebProcess.
2776         We make WebProcess sends Origin Access White list information to NetworkProcess.
2777         This allows supporting the white list when doing loading in NetworkProcess.
2778         This only works consistently if all WebProcesses share the same whitelist.
2779
2780         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
2781         (WebKit::NetworkConnectionToWebProcess::loadPing):
2782         (WebKit::NetworkConnectionToWebProcess::addOriginAccessWhitelistEntry):
2783         (WebKit::NetworkConnectionToWebProcess::removeOriginAccessWhitelistEntry):
2784         (WebKit::NetworkConnectionToWebProcess::resetOriginAccessWhitelists):
2785         * NetworkProcess/NetworkConnectionToWebProcess.h:
2786         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
2787         * NetworkProcess/NetworkLoadChecker.cpp:
2788         (WebKit::NetworkLoadChecker::NetworkLoadChecker):
2789         (WebKit::NetworkLoadChecker::checkRedirection):
2790         (WebKit::NetworkLoadChecker::continueCheckingRequest):
2791         (WebKit::NetworkLoadChecker::checkCORSRequest):
2792         (WebKit::NetworkLoadChecker::checkCORSRedirectedRequest):
2793         (WebKit::NetworkLoadChecker::checkCORSRequestWithPreflight):
2794         (WebKit::NetworkLoadChecker::doesNotNeedCORSCheck const):
2795         * NetworkProcess/NetworkLoadChecker.h:
2796         (WebKit::NetworkLoadChecker::create):
2797         * NetworkProcess/NetworkResourceLoadParameters.cpp:
2798         (WebKit::NetworkResourceLoadParameters::encode const):
2799         (WebKit::NetworkResourceLoadParameters::decode):
2800         * NetworkProcess/NetworkResourceLoadParameters.h:
2801         * NetworkProcess/PingLoad.cpp:
2802         (WebKit::PingLoad::PingLoad):
2803         (WebKit::PingLoad::willPerformHTTPRedirection):
2804         * NetworkProcess/PingLoad.h:
2805         * WebProcess/InjectedBundle/InjectedBundle.cpp:
2806         (WebKit::InjectedBundle::addOriginAccessWhitelistEntry):
2807         (WebKit::InjectedBundle::removeOriginAccessWhitelistEntry):
2808         (WebKit::InjectedBundle::resetOriginAccessWhitelists):
2809         * WebProcess/Network/WebLoaderStrategy.cpp:
2810         (WebKit::WebLoaderStrategy::startPingLoad):
2811
2812 2018-04-11  Michael Catanzaro  <mcatanzaro@igalia.com>
2813
2814         [GTK] WaylandCompositorDisplay leaks its wl_display
2815         https://bugs.webkit.org/show_bug.cgi?id=184406
2816
2817         Reviewed by Carlos Garcia Campos.
2818
2819         Since we allocate our own wl_display here, need to chain up to the parent constructor
2820         passing NativeDisplayOwned::Yes, or it won't ever be released. Move the initialize call to
2821         the create function to ensure it's called after the constructor completes.
2822
2823         * WebProcess/gtk/WaylandCompositorDisplay.cpp:
2824         (WebKit::WaylandCompositorDisplay::create): Fix a log message (drive-by).
2825         (WebKit::WaylandCompositorDisplay::WaylandCompositorDisplay):
2826
2827 2018-04-11  Youenn Fablet  <youenn@apple.com>
2828
2829         Use more r-values in NetworkResourceLoader
2830         https://bugs.webkit.org/show_bug.cgi?id=184478
2831
2832         Reviewed by Chris Dumez.
2833
2834         Pass load parameters as r-values to remove some unneeded copies.
2835         Ditto for ResourceRequest inside NetworkResourceLoader.
2836
2837         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
2838         (WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad):
2839         (WebKit::NetworkConnectionToWebProcess::performSynchronousLoad):
2840         * NetworkProcess/NetworkConnectionToWebProcess.h:
2841         * NetworkProcess/NetworkResourceLoader.cpp:
2842         (WebKit::NetworkResourceLoader::NetworkResourceLoader):
2843         (WebKit::NetworkResourceLoader::start):
2844         (WebKit::NetworkResourceLoader::retrieveCacheEntry):
2845         (WebKit::NetworkResourceLoader::startNetworkLoad):
2846         (WebKit::NetworkResourceLoader::continueWillSendRequest):
2847         (WebKit::NetworkResourceLoader::validateCacheEntry):
2848         * NetworkProcess/NetworkResourceLoader.h:
2849
2850 2018-04-11  Wenson Hsieh  <wenson_hsieh@apple.com>
2851
2852         [Extra zoom mode] Missing label when focusing a <select> with a title attribute but no associated <label>
2853         https://bugs.webkit.org/show_bug.cgi?id=184352
2854         <rdar://problem/39237683>
2855
2856         Reviewed by Andy Estes.
2857
2858         Currently, AssistedNodeInformation only sends the `title` of input elements to the UI process. This means that
2859         any information requested in the UI process that is dependent on the `title` of the focused element is broken
2860         in the case of select elements. An existing example of this is the title of the table view controller used to
2861         present select menus on iPad.
2862
2863         To fix this, we simply send the `title` of the focused element across, as long as the focused element is an
2864         HTMLElement. This ensures that there's label text when focusing unlabeled select elements with titles in extra
2865         zoom mode, and also fixes a currenly broken codepath where we show the title of the select in the presented view
2866         controller's title.
2867
2868         Test: fast/forms/ios/ipad/select-with-title.html
2869
2870         * UIProcess/API/Cocoa/WKWebView.mm:
2871         (-[WKWebView selectFormPopoverTitle]):
2872         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
2873
2874         Add new testing SPI to fetch the title of the UITableViewController presented for the currently focused select
2875         element.
2876
2877         * UIProcess/ios/WKContentViewInteraction.h:
2878         * UIProcess/ios/WKContentViewInteraction.mm:
2879         (-[WKContentView selectFormPopoverTitle]):
2880         * UIProcess/ios/forms/WKFormSelectControl.h:
2881         * UIProcess/ios/forms/WKFormSelectControl.mm:
2882         (-[WKFormSelectControl selectFormPopoverTitle]):
2883         * UIProcess/ios/forms/WKFormSelectPopover.h:
2884         * UIProcess/ios/forms/WKFormSelectPopover.mm:
2885         (-[WKSelectPopover initWithView:hasGroups:]):
2886         (-[WKSelectPopover tableViewController]):
2887         * WebProcess/WebPage/ios/WebPageIOS.mm:
2888
2889         Always send the title across if the focused node is an HTMLElement.
2890
2891         (WebKit::WebPage::getAssistedNodeInformation):
2892
2893 2018-04-11  Ryan Haddad  <ryanhaddad@apple.com>
2894
2895         Unreviewed, rolling out r230508.
2896
2897         Breaks internal builds.
2898
2899         Reverted changeset:
2900
2901         "Remove block selection code"
2902         https://bugs.webkit.org/show_bug.cgi?id=184470
2903         https://trac.webkit.org/changeset/230508
2904
2905 2018-04-11  Antoine Quint  <graouts@apple.com>
2906
2907         [Web Animations] Turn Web Animations on by default
2908         https://bugs.webkit.org/show_bug.cgi?id=184491
2909
2910         Reviewed by Simon Fraser.
2911
2912         * Shared/WebPreferences.yaml:
2913
2914 2018-04-10  Brent Fulgham  <bfulgham@apple.com>
2915
2916         Unreviewed test fix after r230468
2917
2918         Roll out an assertion added in r230468 that should not be present
2919         until https://bugs.webkit.org/show_bug.cgi?id=184451 is landed.
2920
2921         * Shared/mac/HangDetectionDisablerMac.mm:
2922         (WebKit::setClientsMayIgnoreEvents):
2923
2924 2018-04-10  Brent Fulgham  <bfulgham@apple.com>
2925
2926         Unreviewed follow-up to r230468.
2927
2928         Switch some RELEASE_ASSERTs in hot codepaths to normal DEBUG asserts.
2929
2930         * UIProcess/mac/PageClientImplMac.mm:
2931         (WebKit::PageClientImpl::isViewWindowActive):
2932         (WebKit::PageClientImpl::setCursor):
2933
2934 2018-04-10  Fujii Hironori  <Hironori.Fujii@sony.com>
2935
2936         [Win] Add UserAgentWin.cpp
2937         https://bugs.webkit.org/show_bug.cgi?id=184438
2938
2939         Reviewed by Michael Catanzaro.
2940
2941         * WebProcess/WebPage/win/WebPageWin.cpp:
2942         (WebKit::WebPage::platformUserAgent const):
2943         Use WebCore::standardUserAgentForURL.
2944
2945 2018-04-10  Megan Gardner  <megan_gardner@apple.com>
2946
2947         Remove block selection code
2948         https://bugs.webkit.org/show_bug.cgi?id=184470
2949
2950         Reviewed by Timothy Hatcher.
2951         
2952         Remove block selection code that isn't run and is currently not even used.
2953         Had to put this back in for a bug in the mid-year release, but we're past that
2954         so it's time for this to go away.
2955
2956         * Platform/spi/ios/UIKitSPI.h:
2957         * UIProcess/PageClient.h:
2958         * UIProcess/WebPageProxy.h:
2959         * UIProcess/WebPageProxy.messages.in:
2960         * UIProcess/ios/PageClientImplIOS.h:
2961         * UIProcess/ios/PageClientImplIOS.mm:
2962         (WebKit::PageClientImpl::stopAssistingNode):
2963         (WebKit::PageClientImpl::didUpdateBlockSelectionWithTouch): Deleted.
2964         * UIProcess/ios/WKContentViewInteraction.h:
2965         * UIProcess/ios/WKContentViewInteraction.mm:
2966         (toSelectionHandlePosition): Deleted.
2967         (-[WKContentView _didUpdateBlockSelectionWithTouch:withFlags:growThreshold:shrinkThreshold:]): Deleted.
2968         (-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:]): Deleted.
2969         (-[WKContentView changeBlockSelectionWithTouchAt:withSelectionTouch:forHandle:]): Deleted.
2970         * UIProcess/ios/WebPageProxyIOS.mm:
2971         (WebKit::WebPageProxy::saveImageToLibrary):
2972         (WebKit::WebPageProxy::updateBlockSelectionWithTouch): Deleted.
2973         (WebKit::WebPageProxy::didUpdateBlockSelectionWithTouch): Deleted.
2974         * WebProcess/WebPage/WebPage.h:
2975         * WebProcess/WebPage/WebPage.messages.in:
2976         * WebProcess/WebPage/ios/WebPageIOS.mm:
2977         (WebKit::rangeAtWordBoundaryForPosition):
2978         (WebKit::distanceBetweenRectsForPosition): Deleted.
2979         (WebKit::rectsEssentiallyTheSame): Deleted.
2980         (WebKit::unionDOMRanges): Deleted.
2981         (WebKit::computeEdgeCenter): Deleted.
2982         (WebKit::WebPage::expandedRangeFromHandle): Deleted.
2983         (WebKit::WebPage::contractedRangeFromHandle): Deleted.
2984         (WebKit::WebPage::computeExpandAndShrinkThresholdsForHandle): Deleted.
2985         (WebKit::WebPage::rangeForBlockAtPoint): Deleted.
2986         (WebKit::shouldExpand): Deleted.
2987         (WebKit::WebPage::changeBlockSelection): Deleted.
2988         (WebKit::WebPage::updateBlockSelectionWithTouch): Deleted.
2989
2990 2018-04-10  Wenson Hsieh  <wenson_hsieh@apple.com>
2991
2992         [Extra zoom mode] Add a mechanism to zoom to fixed scales when double tapping in extra zoom mode
2993         https://bugs.webkit.org/show_bug.cgi?id=184435
2994         <rdar://problem/38726260>
2995
2996         Reviewed by Dean Jackson.
2997
2998         Adds support for an alternate codepath when computing a zoom rect when double tapping that doesn't take the hit-
2999         tested node into account, and instead cycles the zoom scale between 2 fixed values (in addition to the initial
3000         scale). In the next patch, these fixed scales will be determined by computing zoom scales needed to make most of
3001         the text on the page legible (i.e. the first text legibility zoom scale), and another to make all of the text on
3002         the page legible, with the exception of outliers (this is the second text legibility zoom scale).
3003
3004         See comments below for more detail.
3005
3006         * UIProcess/Cocoa/ViewGestureController.h:
3007         * UIProcess/Cocoa/ViewGestureController.messages.in:
3008         * UIProcess/ios/SmartMagnificationController.h:
3009         * UIProcess/ios/SmartMagnificationController.messages.in:
3010         * UIProcess/ios/SmartMagnificationController.mm:
3011         (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
3012         * UIProcess/mac/ViewGestureControllerMac.mm:
3013         (WebKit::ViewGestureController::didCollectGeometryForSmartMagnificationGesture):
3014         * WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
3015         (WebKit::ViewGestureGeometryCollector::dispatchDidCollectGeometryForSmartMagnificationGesture):
3016
3017         Rename the boolean `isReplacedElement` argument to `fitEntireRect` instead. The UI process only uses this on iOS
3018         to determine whether or not to fit the entire element rect to the viewport and add padding. This patch renames
3019         this variable because we are not zooming to a replaced element in the case where text legibility on the page
3020         (rather than element geometry) is being used to figure out the zoom scale, but we still want to fit the entire
3021         target rect to the viewport.
3022
3023         (WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):
3024
3025         If text legiblity zoom scaling is preferred, then compute first and second-level text legibility zoom scales to
3026         zoom to upon double tap (where the second zoom scale is greater than the first). To choose a target zoom
3027         scale, choose the lowest target zoom scale that is at least a small amount less than the current scale. If
3028         neither of the two scales fulfill this description, then zoom back out to the initial scale. This has the effect
3029         of consistently cycling between all three zoom scales as the user double taps.
3030
3031         (WebKit::ViewGestureGeometryCollector::computeTextLegibilityScales):
3032
3033         Introduce a new helper method that computes and caches target scales to zoom to when double tapping to zoom. If
3034         a cached pair of target scales is already present, it skips this computation and immediately returns it.
3035
3036         (WebKit::ViewGestureGeometryCollector::computeZoomInformationForNode):
3037         (WebKit::ViewGestureGeometryCollector::computeMinimumAndMaximumViewportScales const):
3038
3039         Factor out logic to compute min and max zoom scales into a separate helper, and call it from both
3040         computeZoomInformationForNode and computeTextLegibilityScales.
3041
3042         (WebKit::ViewGestureGeometryCollector::mainFrameDidLayout):
3043
3044         Invalidate cached text legibility scales when layout is triggered.
3045
3046         * WebProcess/WebPage/ViewGestureGeometryCollector.h:
3047         * WebProcess/WebPage/WebPage.cpp:
3048         (WebKit::WebPage::mainFrameDidLayout):
3049         * WebProcess/WebPage/WebPage.h:
3050         (WebKit::WebPage::viewportConfiguration const):
3051
3052         Expose WebPage's ViewportConfiguration as a const reference.
3053
3054         * WebProcess/WebPage/ios/WebPageIOS.mm:
3055         (WebKit::WebPage::platformPrefersTextLegibilityBasedZoomScaling const):
3056
3057         Adds a platform hook for opting into text-legibility-based zoom scaling instead of regular hit-testing-based
3058         zoom scaling heuristics.
3059
3060 2018-04-10  Wenson Hsieh  <wenson_hsieh@apple.com>
3061
3062         Fix availability annotations for _WKAttachment SPI
3063         https://bugs.webkit.org/show_bug.cgi?id=184473
3064         <rdar://problem/39319732>
3065
3066         Reviewed by Dan Bernstein.
3067
3068         _WKAttachmentInfo is available in WK_MAC_TBA and WK_IOS_TBA, but the SPI method -[_WKAttachment requestInfo:]
3069         is currently available in macOS 10.13.4 and iOS 11.3. Instead, the availability of this SPI should match the
3070         availability of the SPI object it depends on.
3071
3072         * UIProcess/API/Cocoa/_WKAttachment.h:
3073
3074 2018-04-10  Chris Dumez  <cdumez@apple.com>
3075
3076         Avoid constructing a service worker RegistrationStore for private sessions
3077         https://bugs.webkit.org/show_bug.cgi?id=184463
3078         <rdar://problem/36613948>
3079
3080         Reviewed by Youenn Fablet.
3081
3082         Avoid constructing a service worker RegistrationStore for private sessions since there
3083         is no need for persistence and the registrationDatabaseDirectory is the empty string in
3084         such cases.
3085
3086         * StorageProcess/StorageProcess.cpp:
3087         (WebKit::StorageProcess::initializeWebsiteDataStore):
3088
3089 2018-04-10  Andy Estes  <aestes@apple.com>
3090
3091         [iOS] Navigate to URL and page number annotations in WKPDFView
3092         https://bugs.webkit.org/show_bug.cgi?id=184410
3093
3094         Reviewed by Timothy Hatcher.
3095
3096         Implemented navigation to URL and page number (same-document) link annotations in PDFs.
3097
3098         * UIProcess/ios/WKPDFView.mm:
3099         (-[WKPDFView _scrollToURLFragment:]):
3100         (-[WKPDFView web_didSameDocumentNavigation:]):
3101         (-[WKPDFView pdfHostViewController:updatePageCount:]):
3102         (-[WKPDFView pdfHostViewController:goToURL:]):
3103         (-[WKPDFView pdfHostViewController:goToPageIndex:withViewFrustum:]):
3104
3105 2018-04-10  Andy Estes  <aestes@apple.com>
3106
3107         [iOS] WKPDFView should conform to _WKWebViewPrintProvider
3108         https://bugs.webkit.org/show_bug.cgi?id=184471
3109
3110         Reviewed by Dan Bernstein.
3111
3112         * UIProcess/API/Cocoa/WKWebView.mm:
3113         (-[WKWebView _printProvider]):
3114
3115         The print provider will always be either _contentView or _customContentView, but
3116         might not be _currentContentView.
3117
3118         * UIProcess/ios/WKPDFView.mm:
3119         (-[WKPDFView _wk_pageCountForPrintFormatter:]):
3120
3121         Asked _hostViewController for the page count, clamped to 1 if
3122         -[_WKWebViewPrintFormatter snapshotFirstPage] is YES.
3123
3124         (-[WKPDFView _wk_printedDocument]):
3125
3126         Created a CGPDFDocumentRef from _data and returned it.
3127
3128 2018-04-10  Youenn Fablet  <youenn@apple.com>
3129
3130         Beacon redirect responses should be CORS validated
3131         https://bugs.webkit.org/show_bug.cgi?id=184378
3132
3133         Reviewed by Chris Dumez.
3134
3135         Add CORS checks to any redirection response if mode is CORS.
3136         Update response tainting and redirected accordingly.
3137
3138         * NetworkProcess/NetworkLoadChecker.cpp:
3139         (WebKit::NetworkLoadChecker::checkRedirection):
3140         (WebKit::NetworkLoadChecker::validateResponse):
3141         * NetworkProcess/NetworkLoadChecker.h:
3142         * NetworkProcess/PingLoad.cpp:
3143         (WebKit::PingLoad::willPerformHTTPRedirection):
3144
3145 2018-04-10  Sihui Liu  <sihui_liu@apple.com>
3146
3147         Loading of multipart response was cancelled because of content policy set in WebFrameLoaderClient::dispatchDecidePolicyForResponse
3148         https://bugs.webkit.org/show_bug.cgi?id=184268
3149         <rdar://problem/39144446>
3150
3151         Reviewed by Chris Dumez.
3152
3153         Webpage for multipart stream responses failed to refresh because content policy was set to 
3154         be ignore when provisonalDocumentLoader was null and navigation ID could not be retrieved. 
3155         As loading should not stop in this case, we set navigation ID 0 and still ask for content 
3156         policy.
3157
3158         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
3159         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
3160
3161 2018-04-10  Andy Estes  <aestes@apple.com>
3162
3163         [iOS] Use PDFKit to render PDFs in WKWebView
3164         https://bugs.webkit.org/show_bug.cgi?id=184387
3165
3166         Reviewed by Beth Dakin.
3167
3168         Adopted PDFHostViewController for rendering PDFs in WKWebView.
3169
3170         This patch implements rendering the PDF document and page number indicator. Link
3171         navigation, find-in-page, and printing will be implemented in follow-up patches.
3172
3173         WKLegacyPDFView is still the default PDF view.
3174
3175         * Configurations/WebKit.xcconfig:
3176
3177         Linked WebKit with PDFKit on iOS.
3178
3179         * UIProcess/API/Cocoa/WKWebView.mm:
3180         (-[WKWebView _currentContentView]):
3181         (-[WKWebView viewForZoomingInScrollView:]):
3182
3183         When WKPDFView loads a PDF document, it replaces itself with a view vended by
3184         PDFHostViewController as the WKScrollView's content view. Abstracted WKWebView's
3185         concept of the "current content view" to be either the WKContentView or a view of
3186         the custom content view's choosing (-web_contentView).
3187
3188         (-[WKWebView scrollViewWillBeginZooming:withView:]):
3189         (-[WKWebView scrollViewDidZoom:]):
3190         (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
3191
3192         Forwarded these calls to _customContentView if it responds to the equivalent
3193         WKWebViewContentProvider selectors.
3194
3195         * UIProcess/Cocoa/WKWebViewContentProvider.h:
3196
3197         Defined new protocol selectors.
3198
3199         * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
3200         (-[WKWebViewContentProviderRegistry init]):
3201         * UIProcess/ios/WKLegacyPDFView.h:
3202         * UIProcess/ios/WKLegacyPDFView.mm:
3203
3204         Changed ENABLE(WKPDFVIEW) to ENABLE(WKLEGACYPDFVIEW).
3205
3206         (-[WKLegacyPDFView web_contentView]):
3207
3208         Added. Returns self as the content view.
3209
3210         * UIProcess/ios/WKPDFView.h: Added.
3211         * UIProcess/ios/WKPDFView.mm: Added.
3212         (-[WKPDFView dealloc]):
3213
3214         Removed the host view and page number indicator from their superviews.
3215
3216         (-[WKPDFView gestureRecognizerShouldBegin:]):
3217
3218         Forwarded to _hostViewController.
3219
3220         (-[WKPDFView web_initWithFrame:webView:]):
3221
3222         Set ours and the scroll view's background color to UIColor.grayColor to match
3223         WKLegacyPDFView.
3224
3225         (-[WKPDFView web_setContentProviderData:suggestedFilename:]):
3226
3227         Created a PDFHostViewController and set its root view as the scroll view's content
3228         view after removing the WKPDFView itself. This allows WKPDFView to act as a
3229         placeholder content view until the PDF is loaded. Added the host view controller's
3230         page number indicator to the fixed overlay view. Finally, loaded the PDF document
3231         by calling -[PDFHostViewController setDocumentData:withScrollView:].
3232
3233         (-[WKPDFView _offsetForPageNumberIndicator]):
3234
3235         Computed an offset for the page number indicator like WKLegacyPDFView did, taking
3236         into account the overlaid accessory views inset, computed unobscured safe area
3237         inset, and computed obscured inset.
3238
3239         (-[WKPDFView _movePageNumberIndicatorToPoint:animated:]):
3240
3241         Moved the page number indicator using the margin and animation duration from
3242         WKLegacyPDFView.
3243
3244         (-[WKPDFView _updateLayoutAnimated:]):
3245
3246         Added a convenience method to update the PDF view layout and position the page
3247         number indicator.
3248
3249         (-[WKPDFView web_setMinimumSize:]):
3250
3251         Updated our own frame in case we are still the placeholder content view.
3252         Called -_updateLayoutAnimated:.
3253
3254         (-[WKPDFView web_setOverlaidAccessoryViewsInset:]):
3255
3256         Stored the inset and called -_updateLayoutAnimated:.
3257
3258         (-[WKPDFView web_computedContentInsetDidChange]):
3259
3260         Called -_updateLayoutAnimated:.
3261
3262         (-[WKPDFView web_setFixedOverlayView:]):
3263
3264         Stored the fixed overlay view.
3265
3266         (-[WKPDFView web_didSameDocumentNavigation:]):
3267         (-[WKPDFView web_countStringMatches:options:maxCount:]):
3268         (-[WKPDFView web_findString:options:maxCount:]):
3269         (-[WKPDFView web_hideFindUI]):
3270
3271         Added FIXMEs.
3272
3273         (-[WKPDFView web_contentView]):
3274
3275         If there is a host view controller, return its root view. Otherwise, return self.
3276
3277         (-[WKPDFView web_scrollViewDidScroll:]):
3278         (-[WKPDFView web_scrollViewWillBeginZooming:withView:]):
3279         (-[WKPDFView web_scrollViewDidEndZooming:withView:atScale:]):
3280         (-[WKPDFView web_scrollViewDidZoom:]):
3281
3282         Called -[PDFHostViewController updatePDFViewLayout].
3283
3284         (-[WKPDFView web_dataRepresentation]):
3285
3286         Returned _data.
3287
3288         (-[WKPDFView web_suggestedFilename]):
3289
3290         Returned _suggestedFilename.
3291
3292         (-[WKPDFView web_isBackground]):
3293
3294         Returned self.isBackground.
3295
3296         * UIProcess/ios/WKSystemPreviewView.mm:
3297         (-[WKSystemPreviewView web_contentView]):
3298
3299         Added. Returns self as the content view.
3300
3301         * WebKit.xcodeproj/project.pbxproj:
3302
3303 2018-04-10  Miguel Gomez  <magomez@igalia.com>
3304
3305         [GTK][WPE] Race condition when destroying webprocesses
3306         https://bugs.webkit.org/show_bug.cgi?id=184445
3307
3308         Reviewed by Carlos Garcia Campos.
3309
3310         Ensure that the WebProcess is properly closing its pages when it's exiting because
3311         the UIProcess has invalidated the IPC connection.
3312
3313         * WebProcess/WebProcess.cpp:
3314         (WebKit::WebProcess::didClose):
3315
3316 2018-04-09  Wenson Hsieh  <wenson_hsieh@apple.com>
3317
3318         Add missing availability macros after r230462
3319         https://bugs.webkit.org/show_bug.cgi?id=184426
3320
3321         Reviewed by Timothy Hatcher.
3322
3323         Annotate new SPI added in r230462 with the appropriate availability macros.
3324
3325         * UIProcess/API/Cocoa/WKViewPrivate.h:
3326         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
3327
3328 2018-04-09  Brent Fulgham  <bfulgham@apple.com>
3329
3330         Add ProcessPrivilege assertions to places that access NSApp
3331         https://bugs.webkit.org/show_bug.cgi?id=184322
3332         <rdar://problem/39194560>
3333
3334         Reviewed by Per Arne Vollan.
3335
3336         Add ProcessPrivilege assertions to places where we interact with NSApp so
3337         that we can prevent accidentally using them in the WebContent process.
3338
3339         * Shared/mac/ChildProcessMac.mm:
3340         (WebKit::ChildProcess::stopNSAppRunLoop):
3341         * Shared/mac/HangDetectionDisablerMac.mm:
3342         (WebKit::setClientsMayIgnoreEvents):
3343         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
3344         (WebKit::WebProcessPool::platformInitializeWebProcess):
3345         * UIProcess/Cocoa/WebViewImpl.mm:
3346         (WebKit::WebViewImpl::WebViewImpl):
3347         (WebKit::WebViewImpl::becomeFirstResponder):
3348         (WebKit::WebViewImpl::pluginFocusOrWindowFocusChanged):
3349         (WebKit::WebViewImpl::validateUserInterfaceItem):
3350         (WebKit::WebViewImpl::startSpeaking):
3351         (WebKit::WebViewImpl::stopSpeaking):
3352         (WebKit::applicationFlagsForDrag):
3353         (WebKit::WebViewImpl::doneWithKeyEvent):
3354         * UIProcess/Gamepad/mac/UIGamepadProviderMac.mm:
3355         (WebKit::UIGamepadProvider::platformWebPageProxyForGamepadInput):
3356         * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
3357         (WebKit::PluginProcessProxy::enterFullscreen):
3358         (WebKit::PluginProcessProxy::beginModal):
3359         (WebKit::PluginProcessProxy::endModal):
3360         * UIProcess/mac/DisplayLink.cpp:
3361         (WebKit::DisplayLink::DisplayLink):
3362         (WebKit::DisplayLink::~DisplayLink):
3363         * UIProcess/mac/PageClientImplMac.mm:
3364         (WebKit::PageClientImpl::isViewWindowActive):
3365         (WebKit::PageClientImpl::setCursor):
3366         * UIProcess/mac/WebPageProxyMac.mm:
3367         (WebKit::WebPageProxy::getIsSpeaking):
3368         (WebKit::WebPageProxy::speak):
3369         (WebKit::WebPageProxy::stopSpeaking):
3370         (WebKit::WebPageProxy::startDisplayLink):
3371         * UIProcess/mac/WebPopupMenuProxyMac.mm:
3372         (WebKit::WebPopupMenuProxyMac::showPopupMenu):
3373
3374 2018-04-09  John Wilander  <wilander@apple.com>
3375
3376         Refactor Ignore HSTS code
3377         https://bugs.webkit.org/show_bug.cgi?id=184433
3378         <rdar://problem/39298238>
3379
3380         Reviewed by Darin Adler.
3381
3382         This patch refactors our ignore HSTS code. The convenience functions are moved
3383         out of CFNetwork SPI in PAL, and into where they are used. It also switches
3384         from performSelector: calls to straight function calls, after checking that
3385         there is a responder.
3386
3387         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
3388         (schemeWasUpgradedDueToDynamicHSTS):
3389         (setIgnoreHSTS):
3390         (ignoreHSTS):
3391             Add convenience functions here since they were moved out of
3392             CFNetworkSPI.h.
3393
3394 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
3395
3396         Rename UNUSED to BUNUSED
3397         https://bugs.webkit.org/show_bug.cgi?id=184093
3398
3399         Reviewed by Yusuke Suzuki.
3400
3401         * UIProcess/API/Cocoa/WKWebView.mm:
3402         (-[WKWebView _getApplicationManifestWithCompletionHandler:]):
3403
3404 2018-04-09  Timothy Hatcher  <timothy@apple.com>
3405
3406         Add support for setting a background color on WKWebView and WKView
3407         https://bugs.webkit.org/show_bug.cgi?id=184426
3408
3409         Reviewed by Wenson Hsieh.
3410
3411         * UIProcess/API/Cocoa/WKViewPrivate.h: Added _backgroundColor property.
3412         * UIProcess/API/Cocoa/WKWebView.mm:
3413         (-[WKWebView _backgroundColor]): Added. Call through to WebViewImpl.
3414         (-[WKWebView _setBackgroundColor:]): Added. Call through to WebViewImpl.
3415         * UIProcess/API/Cocoa/WKWebViewPrivate.h: Added _backgroundColor property.
3416         * UIProcess/API/mac/WKView.mm:
3417         (-[WKView _backgroundColor]): Added. Call through to WebViewImpl.
3418         (-[WKView _setBackgroundColor:]): Added. Call through to WebViewImpl.
3419         * UIProcess/Cocoa/WebViewImpl.h:
3420         * UIProcess/Cocoa/WebViewImpl.mm:
3421         (WebKit::WebViewImpl::setBackgroundColor): Added.
3422         (WebKit::WebViewImpl::backgroundColor const): Added.
3423         (WebKit::WebViewImpl::updateLayer): Use m_backgroundColor when set.
3424
3425 2018-04-09  Yousuke Kimoto <yousuke.kimoto@sony.com> and Fujii Hironori  <Hironori.Fujii@sony.com>
3426
3427         [WinCairo] Add WebKit Shared/win event files for wincairo webkit
3428         https://bugs.webkit.org/show_bug.cgi?id=183043
3429
3430         Reviewed by Brent Fulgham.
3431
3432         * Shared/NativeWebKeyboardEvent.h:
3433         (WebKit::NativeWebKeyboardEvent::nativeEvent const):
3434         * Shared/NativeWebMouseEvent.h:
3435         (WebKit::NativeWebMouseEvent::nativeEvent const):
3436         * Shared/NativeWebTouchEvent.h:
3437         * Shared/NativeWebWheelEvent.h:
3438         (WebKit::NativeWebWheelEvent::nativeEvent const):
3439         * Shared/win/NativeWebKeyboardEventWin.cpp: Copied from Source/WebKit/Shared/NativeWebMouseEvent.h.
3440         (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent):
3441         * Shared/win/NativeWebMouseEventWin.cpp: Copied from Source/WebKit/Shared/NativeWebMouseEvent.h.
3442         (WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
3443         * Shared/win/NativeWebTouchEventWin.cpp: Copied from Source/WebKit/Shared/NativeWebTouchEvent.h.
3444         (WebKit::NativeWebTouchEvent::NativeWebTouchEvent):
3445         * Shared/win/NativeWebWheelEventWin.cpp: Copied from Source/WebKit/Shared/NativeWebMouseEvent.h.
3446         (WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
3447         * Shared/win/WebEventFactory.cpp: Added.
3448         (WebKit::relativeCursorPosition):
3449         (WebKit::point):
3450         (WebKit::horizontalScrollChars):
3451         (WebKit::verticalScrollLines):
3452         (WebKit::clickCount):
3453         (WebKit::IsKeyInDownState):
3454         (WebKit::modifiersForEvent):
3455         (WebKit::modifiersForCurrentKeyState):
3456         (WebKit::keyboardEventTypeForEvent):
3457         (WebKit::isSystemKeyEvent):
3458         (WebKit::isKeypadEvent):
3459         (WebKit::textFromEvent):
3460         (WebKit::unmodifiedTextFromEvent):
3461         (WebKit::keyIdentifierFromEvent):
3462         (WebKit::WebEventFactory::createWebMouseEvent):
3463         (WebKit::WebEventFactory::createWebWheelEvent):
3464         (WebKit::WebEventFactory::createWebKeyboardEvent):
3465         (WebKit::WebEventFactory::createWebTouchEvent):
3466         * Shared/win/WebEventFactory.h: Copied from Source/WebKit/Shared/NativeWebMouseEvent.h.
3467         (WebKit::createNativeEvent):
3468
3469 2018-04-09  Brent Fulgham  <bfulgham@apple.com>
3470
3471         WebCore::EventHandler::targetPositionInWindowForSelectionAutoscroll is directly accessing NSScreen
3472         https://bugs.webkit.org/show_bug.cgi?id=184344
3473         <rdar://problem/39224969>
3474
3475         Reviewed by Per Arne Vollan.
3476
3477         The implementation of targetPositionInWindowForSelectionAutoscroll uses the display ID to get the
3478         screen boundaries of the current display. This causes a bunch of interaction with NSScreen that
3479         we do not want to allow in the WebContent process.
3480
3481         Instead, we should just use the cached screen information the WebContent process already possesses.
3482
3483         This patch makes the following changes:
3484         1. We now retrieve the screen rect of the page's display from the cache, rather than interacting with
3485            the WindowServer directly.
3486         2. Add a new 'toUserSpaceForPrimaryScreen' so we don't have to deal with a nil NSWindow when computing
3487            the user space version of the coordinates. A nil Window just means we want to get coordinates in
3488            terms of the primary display.
3489         3. Keep track of the primary display so we can refer to it later.
3490         4. Modify the IPC messages to include the primary display's ID so we can easily access it later.
3491         5. Modify the PlatformScreen methods to actually use the primary display when appropriate, rather
3492            than whichever screen happened to hash to the lowest value.
3493
3494         Reviewed by Per Arne Vollan.
3495
3496         * UIProcess/WebProcessPool.cpp:
3497         (WebKit::displayReconfigurationCallBack): Update for new getScreenProperties implementation.
3498         (WebKit::WebProcessPool::initializeNewWebProcess): Ditto.
3499         * WebProcess/WebProcess.cpp:
3500         (WebKit::WebProcess::setScreenProperties): Ditto.
3501         * WebProcess/WebProcess.h:
3502         * WebProcess/WebProcess.messages.in: Ditto.
3503
3504 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
3505
3506         [WPE] Add API version to library soname and pkg-config files
3507         https://bugs.webkit.org/show_bug.cgi?id=180608
3508
3509         Reviewed by Žan Doberšek.
3510
3511         * PlatformWPE.cmake:
3512         * wpe/wpe-webkit.pc.in:
3513
3514 2018-04-09  Jer Noble  <jer.noble@apple.com>
3515
3516         Fix the selection assistant selectionView build
3517         https://bugs.webkit.org/show_bug.cgi?id=184423
3518         <rdar://problem/39288235>
3519
3520         Reviewed by Wenson Hsieh.
3521
3522         * Platform/spi/ios/UIKitSPI.h:
3523         * UIProcess/ios/WKContentView.mm:
3524         (-[WKContentView _didExitStableState]):
3525         * UIProcess/ios/WKContentViewInteraction.mm:
3526         (-[WKContentView _updateChangedSelection:]):
3527
3528 2018-04-09  Megan Gardner  <megan_gardner@apple.com>
3529
3530         Switch to UIWKTextInteractionAssistant for non-editable text
3531         https://bugs.webkit.org/show_bug.cgi?id=182834
3532
3533         Switch to only using one assistant for text selection.
3534
3535         Reviewed by Timothy Hatcher and Andy Estes.
3536
3537         * UIProcess/ios/WKContentViewInteraction.mm:
3538         (-[WKContentView useSelectionAssistantWithGranularity:]):
3539
3540 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
3541
3542         Unreviewed, move 'using namespace' back to the right place after r230429
3543
3544         * Shared/glib/ProcessExecutablePathGLib.cpp:
3545
3546 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
3547
3548         Unreviewed, rolling out r230390.
3549
3550         Broke accelerated compositing
3551
3552         Reverted changeset:
3553
3554         "[GTK] WaylandCompositorDisplay leaks its wl_display"
3555         https://bugs.webkit.org/show_bug.cgi?id=184406
3556         https://trac.webkit.org/changeset/230390
3557
3558 2018-04-09  Wenson Hsieh  <wenson_hsieh@apple.com>
3559
3560         [Extra zoom mode] Disable fast clicking by default in extra zoom mode
3561         https://bugs.webkit.org/show_bug.cgi?id=184411
3562         <rdar://problem/38726867>
3563
3564         Reviewed by Andy Estes.
3565
3566         As it turns out, existing fast-clicking heuristics don't work so well in extra zoom mode. Even at device-width,
3567         since the page is scaled to fit within the viewport, having single taps take precedence over double taps leads
3568         to a confusing experience when trying to double tap to zoom further on content that contains links and other
3569         click targets. Revert to legacy behavior here by disabling these heuristics.
3570
3571         * UIProcess/API/Cocoa/WKWebView.mm:
3572         (-[WKWebView _initializeWithConfiguration:]):
3573
3574 2018-04-06  Wenson Hsieh  <wenson_hsieh@apple.com>
3575
3576         [Extra zoom mode] Add an SPI hook for clients to opt in to focus overlay UI
3577         https://bugs.webkit.org/show_bug.cgi?id=184370
3578         <rdar://problem/39250494>
3579
3580         Reviewed by Timothy Hatcher and Andy Estes.
3581
3582         Add a new SPI hook for internal clients to opt in to showing the focused form control overlay. By default, the
3583         overlay is not shown.
3584
3585         * UIProcess/API/Cocoa/_WKInputDelegate.h:
3586
3587 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
3588
3589         [WPE] Use GNU install directories
3590         https://bugs.webkit.org/show_bug.cgi?id=184377
3591
3592         Reviewed by Carlos Garcia Campos.
3593
3594         Merge ProcessExecutablePathGtk and ProcessExecutablePathWPE into ProcessExecutablePathGLib.
3595         WPE will now load its secondary processes from PKGLIBEXECDIR, like WebKitGTK+.
3596
3597         * PlatformWPE.cmake:
3598         * Shared/glib/ProcessExecutablePathGLib.cpp: Renamed from Source/WebKit/Shared/gtk/ProcessExecutablePathGtk.cpp.
3599         (WebKit::getExecutablePath):
3600         (WebKit::findWebKitProcess):
3601         (WebKit::executablePathOfWebProcess):
3602         (WebKit::executablePathOfPluginProcess):
3603         (WebKit::executablePathOfNetworkProcess):
3604         (WebKit::executablePathOfStorageProcess):
3605         * Shared/wpe/ProcessExecutablePathWPE.cpp: Removed.
3606         * SourcesGTK.txt:
3607         * SourcesWPE.txt:
3608
3609 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
3610
3611         [GTK] WaylandCompositorDisplay leaks its wl_display
3612         https://bugs.webkit.org/show_bug.cgi?id=184406
3613
3614         Reviewed by Carlos Garcia Campos.
3615
3616         * WebProcess/gtk/WaylandCompositorDisplay.cpp:
3617         (WebKit::WaylandCompositorDisplay::create): Fix a log message (drive-by).
3618         (WebKit::WaylandCompositorDisplay::WaylandCompositorDisplay): Fix the leak.
3619
3620 2018-04-08  Zan Dobersek  <zdobersek@igalia.com>
3621
3622         Non-Cocoa ports use default directory for ServiceWorker data during testing
3623         https://bugs.webkit.org/show_bug.cgi?id=183784
3624
3625         Reviewed by Youenn Fablet.
3626
3627         Add API to WKWebsiteDataStore that enables setting and retrieving the
3628         service worker registration directory for a given data store object.
3629         This enables setting the temporary directory for testing purposes in
3630         WebKitTestRunner.
3631
3632         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
3633         (WKWebsiteDataStoreCopyServiceWorkerRegistrationDirectory):
3634         (WKWebsiteDataStoreSetServiceWorkerRegistrationDirectory):
3635         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
3636
3637 2018-04-08  Fujii Hironori  <Hironori.Fujii@sony.com>
3638
3639         [CMake] WebKit should link to WebCore as a PRIVATE library if WebCore is a static library
3640         https://bugs.webkit.org/show_bug.cgi?id=184127
3641
3642         Reviewed by Konstantin Tokarev.
3643
3644         * CMakeLists.txt: Link with WebCore as private,
3645         WebCoreHeaderInterface as public to WebKit if WebCore is a static
3646         library.
3647         * CMakeLists.txt:
3648         * PlatformGTK.cmake: Added PRIVATE keyword for WebKit_LIBRARIES.
3649         * PlatformWPE.cmake: Ditto.
3650         * PlatformWin.cmake: Ditto.
3651
3652 2018-04-08  Andy Estes  <aestes@apple.com>
3653
3654         [iOS] WKContentView and WKLegacyPDFView should share application state tracking logic
3655         https://bugs.webkit.org/show_bug.cgi?id=184402
3656
3657         Reviewed by Dan Bernstein.
3658
3659         WKContentView and WKLegacyPDFView have nearly identical logic for tracking
3660         application foreground state. Let's share it so we can more easily create new
3661         content views with proper application state tracking.
3662
3663         * UIProcess/ios/WKApplicationStateTrackingView.h: Added.
3664         * UIProcess/ios/WKApplicationStateTrackingView.mm: Added.
3665         (-[WKApplicationStateTrackingView initWithFrame:webView:]):
3666         (-[WKApplicationStateTrackingView willMoveToWindow:]):
3667         (-[WKApplicationStateTrackingView didMoveToWindow]):
3668         (-[WKApplicationStateTrackingView _applicationDidEnterBackground]):
3669         (-[WKApplicationStateTrackingView _applicationDidCreateWindowContext]):
3670         (-[WKApplicationStateTrackingView _applicationDidFinishSnapshottingAfterEnteringBackground]):
3671         (-[WKApplicationStateTrackingView _applicationWillEnterForeground]):
3672         (-[WKApplicationStateTrackingView isBackground]):
3673
3674         Moved common logic from WKContentView and WKLegacyPDFView into
3675         WKApplicationStateTrackingView.
3676
3677         * UIProcess/ios/WKContentView.h:
3678         * UIProcess/ios/WKContentView.mm:
3679         (-[WKContentView initWithFrame:processPool:configuration:webView:]):
3680         (-[WKContentView willMoveToWindow:]):
3681         (-[WKContentView _applicationDidCreateWindowContext]):
3682         (-[WKContentView didMoveToWindow]): Deleted.
3683         (-[WKContentView isBackground]): Deleted.
3684         (-[WKContentView _applicationDidEnterBackground]): Deleted.
3685         (-[WKContentView _applicationDidFinishSnapshottingAfterEnteringBackground]): Deleted.
3686         (-[WKContentView _applicationWillEnterForeground]): Deleted.
3687
3688         Made WKContentView a subclass of WKApplicationStateTrackingView.
3689
3690         * UIProcess/ios/WKLegacyPDFView.h:
3691         * UIProcess/ios/WKLegacyPDFView.mm:
3692         (-[WKLegacyPDFView web_initWithFrame:webView:]):
3693         (-[WKLegacyPDFView web_isBackground]):
3694         (-[WKLegacyPDFView _applicationWillEnterForeground]):
3695         (-[WKLegacyPDFView willMoveToWindow:]): Deleted.
3696         (-[WKLegacyPDFView didMoveToWindow]): Deleted.
3697         (-[WKLegacyPDFView _applicationDidEnterBackground]): Deleted.
3698         (-[WKLegacyPDFView _applicationDidCreateWindowContext]): Deleted.
3699         (-[WKLegacyPDFView _applicationDidFinishSnapshottingAfterEnteringBackground]): Deleted.
3700
3701         Made WKLegacyPDFView a subclass of WKApplicationStateTrackingView.
3702
3703         * WebKit.xcodeproj/project.pbxproj:
3704
3705 2018-04-08  Dan Bernstein  <mitz@apple.com>
3706
3707         [Cocoa] Keep library validation disabled for WebContent.Development
3708         https://bugs.webkit.org/show_bug.cgi?id=184393
3709
3710         Reviewed by Anders Carlsson.
3711
3712         * Configurations/WebContent.Development.entitlements: Added. Includes the
3713           com.apple.security.cs.disable-library-validation entitlement set to true.
3714         * Configurations/WebContentService.Development.xcconfig: Set CODE_SIGN_ENTITLEMENTS to the
3715           above.
3716         * WebKit.xcodeproj/project.pbxproj: Added reference to new file.
3717
3718 2018-04-06  Brian Burg  <bburg@apple.com>
3719
3720         REGRESSION(r228371): WebAutomationSession::deleteAllCookies doesn't delete some cookies
3721         https://bugs.webkit.org/show_bug.cgi?id=184334
3722         <rdar://problem/39212863>
3723
3724         Reviewed by Timothy Hatcher.
3725
3726         When WebDriver adds a cookie for 'localhost', it actually uses the domain '.localhost' per RFC.
3727         When deleting cookies, we first fetch all cookies matching the document's hostname, and
3728         then delete them one by one. However, this code path does not add the dot prefix. This causes
3729         no cookies to match the requested domain, and thus none of them are deleted.
3730
3731         * UIProcess/Automation/WebAutomationSession.cpp:
3732         (WebKit::domainByAddingDotPrefixIfNeeded): Extract this helper method.
3733         (WebKit::WebAutomationSession::addSingleCookie): Use helper method.
3734         (WebKit::WebAutomationSession::deleteAllCookies): Add a dot prefix when
3735         requesting to delete all cookies for a hostname.
3736
3737 2018-04-06  Youenn Fablet  <youenn@apple.com>
3738
3739         Response headers should be filtered when sent from NetworkProcess to WebProcess
3740         https://bugs.webkit.org/show_bug.cgi?id=184310
3741
3742         Reviewed by Ryosuke Niwa.
3743
3744         Pass destination parameter to NetworkResourceLoader.
3745         Use new sanitization routine to filter response headers as needed:
3746         - Cross-origin routines are filtered by removing any non CORS allowed headers.
3747         - Same-origin responses are filtered by removing non used headers, except when filtering would be visible by JS (XHR, fetch).
3748         In all cases, Set-Cookie/Set-Cookie2 headers are filtered out.
3749
3750         * NetworkProcess/NetworkResourceLoadParameters.cpp:
3751         (WebKit::NetworkResourceLoadParameters::encode const):
3752         (WebKit::NetworkResourceLoadParameters::decode):
3753         * NetworkProcess/NetworkResourceLoadParameters.h:
3754         * NetworkProcess/NetworkResourceLoader.cpp:
3755         (WebKit::NetworkResourceLoader::didReceiveResponse):
3756         (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
3757         (WebKit::NetworkResourceLoader::sanitizeResponseIfPossible):
3758         (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
3759         (WebKit::NetworkResourceLoader::dispatchWillSendRequestForCacheEntry):
3760         * NetworkProcess/NetworkResourceLoader.h:
3761         * WebProcess/Network/WebLoaderStrategy.cpp:
3762         (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
3763         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
3764         (WebKit::WebSWContextManagerConnection::updatePreferencesStore):
3765
3766 2018-04-05  Ryosuke Niwa  <rniwa@webkit.org>
3767
3768         Make all sync IPCs during ScriptDisallowedScope set DoNotProcessIncomingMessagesWhenWaitingForSyncReply
3769         https://bugs.webkit.org/show_bug.cgi?id=182449
3770         <rdar://problem/39222541>
3771
3772         Reviewed by Chris Dumez.
3773
3774         Release assert that a sync IPC inside ScriptDisallowedScope sets DoNotProcessIncomingMessagesWhenWaitingForSyncReply
3775         to avoid executing arbitrary scripts as a result of processing incoming sync IPCs.
3776
3777         * Platform/IPC/Connection.h:
3778         (IPC::Connection::sendSync): Added the release assertion.
3779
3780 2018-04-05  Youenn Fablet  <youenn@apple.com>
3781
3782         REGRESSION (r230223): LayoutTest http/tests/contentextensions/css-display-none-overflows-rule-data-1.html is crashing
3783         https://bugs.webkit.org/show_bug.cgi?id=184306
3784
3785         Reviewed by Ryosuke Niwa.
3786
3787         * NetworkProcess/NetworkContentRuleListManager.cpp:
3788         (WebKit::NetworkContentRuleListManager::addContentRuleLists):
3789
3790 2018-04-05  Brent Fulgham  <bfulgham@apple.com>
3791
3792         WebContent process is calling CGDisplayUsesInvertedPolarity
3793         https://bugs.webkit.org/show_bug.cgi?id=184337
3794         <rdar://problem/39215702>
3795
3796         Reviewed by Zalan Bujtas.
3797
3798         The PlatformScreenMac code is still calling display-related routines directly, specifically
3799         CGDisplayUsesInvertedPolarity and CGDisplayUsesForceToGray. These should be brokered from
3800         the UIProcess.
3801         
3802         There's also no reason to avoid the brokering behavior on current WebKit builds. Remove
3803         the compile guards so all macOS builds use this behavior.
3804         
3805         Finally, add some ProcessPrivilege assertions to guard against accidentally calling these
3806         routines in the future.
3807
3808         * UIProcess/WebProcessPool.cpp:
3809         (WebKit::WebProcessPool::initializeNewWebProcess): Activate screen brokering code for all builds.
3810         * WebProcess/WebProcess.cpp: Ditto.
3811         * WebProcess/WebProcess.h: Ditto.
3812         * WebProcess/WebProcess.messages.in: Ditto.
3813
3814 2018-04-05  Brady Eidson  <beidson@apple.com>
3815
3816         Process Swap on Navigation causes many webpages to hang due to attempted process swap for iframe navigations.
3817         <rdar://problem/39162236> and https://bugs.webkit.org/show_bug.cgi?id=184318
3818
3819         Reviewed by Andy Estes.
3820
3821         * UIProcess/WebPageProxy.cpp:
3822         (WebKit::WebPageProxy::receivedPolicyDecision): Don't consider a swap if the navigation is not in the main frame.
3823
3824 2018-04-05  Ryosuke Niwa  <rniwa@webkit.org>
3825
3826         WebContent process sometimes hangs in WebProcess::ensureNetworkProcessConnection
3827         https://bugs.webkit.org/show_bug.cgi?id=184326
3828
3829         Reviewed by Chris Dumez.
3830
3831         The hang was caused by UI process never sending the reply back to GetNetworkProcessConnection
3832         due to m_pendingOutgoingMachMessage being set and the event handler for DISPATCH_MACH_SEND_POSSIBLE
3833         never getting called. This is because the event handler registration happens asynchronously,
3834         and may not have completed by the time we send the first IPC to the web content process
3835         in which case it can timeout and we may never get the callback.
3836
3837         Fixed the hang by waiting for the event handler registration to be completed using
3838         dispatch_source_set_registration_handler. To do this, this patch adds a new boolean instance variable,
3839         m_isInitializingSendSource, to Connection which is set to true between the time mach port is created
3840         and until the event handler registration has been completed. platformCanSendOutgoingMessages returns
3841         false while m_isInitializingSendSource is set to prevent the attempt to send messages like we do when
3842         m_pendingOutgoingMachMessage is set to true.
3843
3844         * Platform/IPC/Connection.h:
3845         (IPC::Connection::m_isInitializingSendSource): Added.
3846         * Platform/IPC/mac/ConnectionMac.mm:
3847         (IPC::Connection::platformInvalidate): Set m_isInitializingSendSource to false.
3848         (IPC::Connection::sendMessage): Assert that m_isInitializingSendSource is false.
3849         (IPC::Connection::platformCanSendOutgoingMessages const): Return false if m_isInitializingSendSource
3850         is set to true.
3851         (IPC::Connection::sendOutgoingMessage): Assert that m_isInitializingSendSource is false.
3852         (IPC::Connection::initializeSendSource): Set m_isInitializingSendSource to true temporarily until
3853         dispatch_source_set_registration_handler's callback is called. Resume and send any pending outgoing
3854         messages.
3855         (IPC::Connection::resumeSendSource): Extracted from initializeSendSource.
3856
3857 2018-04-05  Youenn Fablet  <youenn@apple.com>
3858
3859         WebRTC data channel only applications require capture permissions for direct connections
3860         https://bugs.webkit.org/show_bug.cgi?id=174500
3861         <rdar://problem/34134281>
3862
3863         Unreviewed.
3864         Changed the code to suppress: "error: unused variable 'error' [-Werror,-Wunused-variable]"
3865         Added some logging to this error case as a side bonus.
3866
3867         * NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
3868         (WebKit::NetworkMDNSRegister::registerMDNSName):
3869
3870 2018-04-05  Carlos Garcia Campos  <cgarcia@igalia.com>
3871
3872         REGRESSION(r229831): Test WebKit2.ProvisionalURLAfterWillSendRequestCallback times out since r229831
3873         https://bugs.webkit.org/show_bug.cgi?id=184293
3874
3875         Reviewed by Alex Christensen.
3876
3877         The problem is that after willSendRequest callback changes the request, the load is cancelled while
3878         transitioning to committed state. This happens because the load is not waiting for the response policy check, so
3879         it continues and when transitioning to committed, FrameLoader::closeURL() invalidates the current policy check
3880         that causes a load failure. The new request returned by the API doesn't have any requester, so it's no longer
3881         considered a main resource load. In the network process the resource load task doesn't wait for the response
3882         policy and continues the load, sending the data to the web process. Once the first data is received, the load
3883         transitions to commit, but the response policy check is still ongoing. This can only happen when using the C API
3884         (I don't know about the Cocoa API), but not with the GLib API because it doesn't allow to create a new request,
3885         only to modify the passed in one. With the C API we loss other internal things of the request like the priority,
3886         but I guess the most important one is the requester.
3887
3888         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
3889         (WebKit::WebFrameLoaderClient::dispatchWillSendRequest):
3890
3891 2018-04-04  Ryan Haddad  <ryanhaddad@apple.com>
3892
3893         Unreviewed, rolling out r230283.
3894
3895         Caused webkitpy test failures.
3896
3897         Reverted changeset:
3898
3899         "Use CompletionHandlers for DelayedReplies"
3900         https://bugs.webkit.org/show_bug.cgi?id=182269
3901         https://trac.webkit.org/changeset/230283
3902
3903 2018-04-04  Youenn Fablet  <youenn@apple.com>
3904
3905         webrtc/video-update-often.html is flakily crashing on iOS simulator Debug
3906         https://bugs.webkit.org/show_bug.cgi?id=184022
3907
3908         Reviewed by Jer Noble.
3909
3910         Remove client context once the new context identifier is set.
3911         Covered by test no longer crashing locally.
3912
3913         * WebProcess/cocoa/PlaybackSessionManager.mm:
3914         (WebKit::PlaybackSessionManager::setUpPlaybackControlsManager):
3915
3916 2018-04-04  Youenn Fablet  <youenn@apple.com>
3917
3918         WebRTC data channel only applications require capture permissions for direct connections
3919         https://bugs.webkit.org/show_bug.cgi?id=174500
3920         <rdar://problem/34134281>
3921
3922         Reviewed by Eric Carlson.
3923
3924         Add support for MDNS registration and resolution by NetworkProcess.
3925         WebProcess gives instruction to do the actual registrations/resolutions.
3926
3927         * CMakeLists.txt:
3928         * DerivedSources.make:
3929         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
3930         (WebKit::NetworkConnectionToWebProcess::NetworkConnectionToWebProcess):
3931         (WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
3932         * NetworkProcess/NetworkConnectionToWebProcess.h:
3933         (WebKit::NetworkConnectionToWebProcess::mdnsRegister):
3934         * NetworkProcess/webrtc/NetworkMDNSRegister.cpp: Added.
3935         (WebKit::NetworkMDNSRegister::NetworkMDNSRegister):
3936         (WebKit::NetworkMDNSRegister::~NetworkMDNSRegister):
3937         (WebKit::NetworkMDNSRegister::unregisterMDNSNames):
3938         (WebKit::PendingRegistrationRequest::PendingRegistrationRequest):
3939         (WebKit::registerMDNSNameCallback):
3940         (WebKit::NetworkMDNSRegister::registerMDNSName):
3941         (WebKit::PendingResolutionRequest::PendingResolutionRequest):
3942         (WebKit::PendingResolutionRequest::~PendingResolutionRequest):
3943         (WebKit::PendingResolutionRequest::timeout):
3944         (WebKit::resolveMDNSNameCallback):
3945         (WebKit::NetworkMDNSRegister::resolveMDNSName):
3946         * NetworkProcess/webrtc/NetworkMDNSRegister.h: Added.
3947         * NetworkProcess/webrtc/NetworkMDNSRegister.messages.in: Added.
3948         * Shared/WebPreferences.yaml:
3949         * UIProcess/API/C/WKPreferences.cpp:
3950         (WKPreferencesSetWebRTCMDNSICECandidatesEnabled):
3951         (WKPreferencesGetWebRTCMDNSICECandidatesEnabled):
3952         * UIProcess/API/C/WKPreferencesRef.h:
3953         * WebKit.xcodeproj/project.pbxproj:
3954         * WebProcess/InjectedBundle/InjectedBundle.cpp:
3955         (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
3956         * WebProcess/Network/NetworkProcessConnection.cpp:
3957         (WebKit::NetworkProcessConnection::didReceiveMessage):
3958         * WebProcess/Network/webrtc/LibWebRTCNetwork.h:
3959         (WebKit::LibWebRTCNetwork::mdnsRegister):
3960         * WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
3961         (WebKit::LibWebRTCProvider::unregisterMDNSNames):
3962         (WebKit::LibWebRTCProvider::registerMDNSName):
3963         (WebKit::LibWebRTCProvider::resolveMDNSName):
3964         * WebProcess/Network/webrtc/LibWebRTCProvider.h:
3965         * WebProcess/Network/webrtc/WebMDNSRegister.cpp: Added.
3966         (WebKit::WebMDNSRegister::finishedRegisteringMDNSName):
3967         (WebKit::WebMDNSRegister::finishedResolvingMDNSName):
3968         (WebKit::WebMDNSRegister::unregisterMDNSNames):
3969         (WebKit::WebMDNSRegister::registerMDNSName):
3970         (WebKit::WebMDNSRegister::resolveMDNSName):
3971         * WebProcess/Network/webrtc/WebMDNSRegister.h: Added.
3972         * WebProcess/Network/webrtc/WebMDNSRegister.messages.in: Added.
3973
3974 2018-04-04  Alex Christensen  <achristensen@webkit.org>
3975
3976         Use CompletionHandlers for DelayedReplies
3977         https://bugs.webkit.org/show_bug.cgi?id=182269
3978
3979         Reviewed by Youenn Fablet.
3980
3981         DelayedReplies should be a noncopyable, non-refcountable type.  They should be
3982         called once and only once.  This is what CompletionHandlers are for.
3983
3984         No change in behavior.  Just cleaner code.
3985
3986         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
3987         (WebKit::NetworkConnectionToWebProcess::performSynchronousLoad):
3988         * NetworkProcess/NetworkConnectionToWebProcess.h:
3989         * NetworkProcess/NetworkResourceLoader.cpp:
3990         (WebKit::NetworkResourceLoader::SynchronousLoadData::SynchronousLoadData):
3991         (WebKit::sendReplyToSynchronousRequest):
3992         (WebKit::NetworkResourceLoader::NetworkResourceLoader):
3993         * NetworkProcess/NetworkResourceLoader.h:
3994         * Platform/IPC/Connection.h:
3995         * Platform/IPC/HandleMessage.h:
3996         (IPC::callMemberFunctionImpl):
3997         (IPC::callMemberFunction):
3998         (IPC::handleMessageDelayed):
3999         * PluginProcess/PluginControllerProxy.cpp:
4000         (WebKit::PluginControllerProxy::setInitializationReply):
4001         (WebKit::PluginControllerProxy::takeInitializationReply):
4002         * PluginProcess/PluginControllerProxy.h:
4003         * PluginProcess/WebProcessConnection.cpp:
4004         (WebKit::WebProcessConnection::destroyPlugin):
4005         (WebKit::WebProcessConnection::createPlugin):
4006         (WebKit::WebProcessConnection::createPluginAsynchronously):
4007         * PluginProcess/WebProcessConnection.h:
4008         * Scripts/webkit/messages.py:
4009         (message_to_struct_declaration):
4010         (generate_message_handler):
4011         * UIProcess/Network/NetworkProcessProxy.cpp:
4012         (WebKit::NetworkProcessProxy::getNetworkProcessConnection):
4013         (WebKit::NetworkProcessProxy::networkProcessCrashed):
4014         (WebKit::NetworkProcessProxy::networkProcessFailedToLaunch):
4015         (WebKit::NetworkProcessProxy::didCreateNetworkConnectionToWebProcess):
4016         * UIProcess/Network/NetworkProcessProxy.h:
4017         * UIProcess/Plugins/PluginProcessManager.cpp:
4018         (WebKit::PluginProcessManager::getPluginProcessConnection):
4019         * UIProcess/Plugins/PluginProcessManager.h:
4020         * UIProcess/Plugins/PluginProcessProxy.cpp:
4021         (WebKit::PluginProcessProxy::getPluginProcessConnection):
4022         (WebKit::PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch):
4023         (WebKit::PluginProcessProxy::didCreateWebProcessConnection):
4024         * UIProcess/Plugins/PluginProcessProxy.h:
4025         * UIProcess/Storage/StorageProcessProxy.cpp:
4026         (WebKit::StorageProcessProxy::getStorageProcessConnection):
4027         (WebKit::StorageProcessProxy::didClose):
4028         (WebKit::StorageProcessProxy::didCreateStorageToWebProcessConnection):
4029         * UIProcess/Storage/StorageProcessProxy.h:
4030         * UIProcess/WebPageProxy.cpp:
4031         (WebKit::ExceededDatabaseQuotaRecords::createRecord):
4032         (WebKit::WebPageProxy::createNewPage):
4033         (WebKit::WebPageProxy::runJavaScriptAlert):
4034         (WebKit::WebPageProxy::runJavaScriptConfirm):
4035         (WebKit::WebPageProxy::runJavaScriptPrompt):
4036         (WebKit::WebPageProxy::webGLPolicyForURL):
4037         (WebKit::WebPageProxy::resolveWebGLPolicyForURL):
4038         (WebKit::WebPageProxy::getToolbarsAreVisible):
4039         (WebKit::WebPageProxy::getMenuBarIsVisible):
4040         (WebKit::WebPageProxy::getStatusBarIsVisible):
4041         (WebKit::WebPageProxy::getWindowFrame):
4042         (WebKit::WebPageProxy::screenToRootView):
4043         (WebKit::WebPageProxy::rootViewToScreen):
4044         (WebKit::WebPageProxy::runBeforeUnloadConfirmPanel):
4045         (WebKit::WebPageProxy::exceededDatabaseQuota):
4046         (WebKit::WebPageProxy::reachedApplicationCacheOriginQuota):
4047         * UIProcess/WebPageProxy.h:
4048         * UIProcess/WebProcessPool.cpp:
4049         (WebKit::WebProcessPool::networkProcessCrashed):
4050         (WebKit::WebProcessPool::getNetworkProcessConnection):
4051         (WebKit::WebProcessPool::getStorageProcessConnection):
4052         * UIProcess/WebProcessPool.h:
4053         * UIProcess/WebProcessProxy.cpp:
4054         (WebKit::WebProcessProxy::getPluginProcessConnection):
4055         (WebKit::WebProcessProxy::getNetworkProcessConnection):
4056         (WebKit::WebProcessProxy::getStorageProcessConnection):
4057         * UIProcess/WebProcessProxy.h:
4058         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
4059         (WebKit::WebSWContextManagerConnection::syncTerminateWorker):
4060         * WebProcess/Storage/WebSWContextManagerConnection.h:
4061         * WebProcess/WebPage/WebPage.h:
4062         * WebProcess/WebPage/ios/WebPageIOS.mm:
4063         (WebKit::WebPage::computePagesForPrintingAndDrawToPDF):
4064
4065 2018-04-04  Alex Christensen  <achristensen@webkit.org>
4066
4067         Remove legacyCustomProtocolManager from NetworkSessionCreationParameters
4068         https://bugs.webkit.org/show_bug.cgi?id=182178
4069
4070         Reviewed by Youenn Fablet.
4071
4072         Now that we only make NetworkSessions in the NetworkProcess, we don't need to pass this parameter around.
4073
4074         * NetworkProcess/NetworkProcess.cpp:
4075         (WebKit::NetworkProcess::initializeNetworkProcess):
4076         * NetworkProcess/NetworkSessionCreationParameters.h:
4077         (WebKit::NetworkSessionCreationParameters::decode):
4078         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
4079         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
4080         * NetworkProcess/mac/RemoteNetworkingContext.mm:
4081         (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
4082         * Shared/WebsiteDataStoreParameters.cpp:
4083         (WebKit::WebsiteDataStoreParameters::privateSessionParameters):
4084         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
4085         (WebKit::WebsiteDataStore::parameters):
4086
4087 2018-04-04  Alex Christensen  <achristensen@webkit.org>
4088
4089         Move PingHandle to WebKitLegacy
4090         https://bugs.webkit.org/show_bug.cgi?id=184145
4091
4092         Reviewed by Youenn Fablet.
4093
4094         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
4095