Check IDB quota usage through QuotaManager
[WebKit-https.git] / Source / WebKit / ChangeLog
1 2019-03-13  Youenn Fablet  <youenn@apple.com>
2
3         Check IDB quota usage through QuotaManager
4         https://bugs.webkit.org/show_bug.cgi?id=195302
5
6         Reviewed by Chris Dumez.
7
8         Set the quota manager getter for IDBServer at creation time.
9
10         * NetworkProcess/NetworkProcess.cpp:
11         (WebKit::NetworkProcess::createIDBServer):
12         (WebKit::NetworkProcess::idbServer):
13         * NetworkProcess/NetworkProcess.h:
14         * WebProcess/Databases/WebDatabaseProvider.cpp:
15         (WebKit::WebDatabaseProvider::idbConnectionToServerForSession):
16
17 2019-03-13  Timothy Hatcher  <timothy@apple.com>
18
19         Consolidate ArgumentCodersMac and ArgumentCodersCocoa.
20         https://bugs.webkit.org/show_bug.cgi?id=195636
21         rdar://problem/45055697
22
23         Reviewed by Ryosuke Niwa.
24
25         Merge the two similar encoders and decoders. This avoids issues where
26         one encoder could be used and the other decoder, which caused a crash.
27         It also stops handling NSAttributedString specifically and just uses
28         the NSSecureCoding path to handle more complex attributes.
29
30         Some WebCore encoders code needed to move to platform files, since
31         ArgumentCodersCocoa.h requires an ObjectiveC++ implementation to work.
32
33         * Shared/Cocoa/ArgumentCodersCocoa.h:
34         (IPC::encode):
35         (IPC::decode):
36         (IPC::ArgumentCoder<RetainPtr<T>>::encode):
37         (IPC::ArgumentCoder<RetainPtr<T>>::decode):
38         * Shared/Cocoa/ArgumentCodersCocoa.mm:
39         (IPC::typeFromObject):
40         (IPC::isSerializableFont):
41         (IPC::isSerializableValue):
42         (IPC::encodeObject):
43         (IPC::decodeObject):
44         * Shared/Cocoa/LoadParametersCocoa.mm:
45         * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
46         (IPC::ArgumentCoder<WebCore::DictionaryPopupInfo>::encodePlatformData):
47         (IPC::ArgumentCoder<WebCore::DictionaryPopupInfo>::decodePlatformData):
48         (IPC::ArgumentCoder<WebCore::FontAttributes>::encodePlatformData):
49         (IPC::ArgumentCoder<WebCore::FontAttributes>::decodePlatformData):
50         * Shared/WebCoreArgumentCoders.cpp:
51         (IPC::ArgumentCoder<DictionaryPopupInfo>::encode):
52         (IPC::ArgumentCoder<DictionaryPopupInfo>::decode):
53         (IPC::ArgumentCoder<FontAttributes>::encode):
54         (IPC::ArgumentCoder<FontAttributes>::decode):
55         * Shared/WebCoreArgumentCoders.h:
56         * Shared/mac/ArgumentCodersMac.h: Removed.
57         * Shared/mac/ArgumentCodersMac.mm: Removed.
58         * Shared/mac/AttributedString.mm:
59         (WebKit::AttributedString::encode const):
60         * Shared/mac/ObjCObjectGraph.mm:
61         * SourcesCocoa.txt:
62         * WebKit.xcodeproj/project.pbxproj:
63
64 2019-03-13  Chris Dumez  <cdumez@apple.com>
65
66         Use a ServiceWorker process per registrable domain
67         https://bugs.webkit.org/show_bug.cgi?id=195649
68
69         Reviewed by Youenn Fablet.
70
71         Use a ServiceWorker process per registrable domain instead of one per security origin. This is
72         more in line with PSON and avoids launching too many processes.
73
74         * NetworkProcess/NetworkProcess.cpp:
75         (WebKit::NetworkProcess::createNetworkConnectionToWebProcess):
76         (WebKit::NetworkProcess::connectionToContextProcessWasClosed):
77         (WebKit::NetworkProcess::needsServerToContextConnectionForRegistrableDomain const):
78         (WebKit::NetworkProcess::serverToContextConnectionForRegistrableDomain):
79         (WebKit::NetworkProcess::createServerToContextConnection):
80         (WebKit::NetworkProcess::swContextConnectionMayNoLongerBeNeeded):
81         * NetworkProcess/NetworkProcess.h:
82         * NetworkProcess/NetworkProcess.messages.in:
83         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
84         (WebKit::WebSWServerConnection::scheduleJobInServer):
85         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
86         (WebKit::WebSWServerToContextConnection::WebSWServerToContextConnection):
87         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
88         * UIProcess/Network/NetworkProcessProxy.cpp:
89         (WebKit::NetworkProcessProxy::getNetworkProcessConnection):
90         (WebKit::NetworkProcessProxy::establishWorkerContextConnectionToNetworkProcess):
91         (WebKit::NetworkProcessProxy::establishWorkerContextConnectionToNetworkProcessForExplicitSession):
92         * UIProcess/Network/NetworkProcessProxy.h:
93         * UIProcess/Network/NetworkProcessProxy.messages.in:
94         * UIProcess/ServiceWorkerProcessProxy.cpp:
95         (WebKit::ServiceWorkerProcessProxy::create):
96         (WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy):
97         (WebKit::ServiceWorkerProcessProxy::getLaunchOptions):
98         * UIProcess/ServiceWorkerProcessProxy.h:
99         * UIProcess/WebProcessPool.cpp:
100         (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
101         (WebKit::WebProcessPool::disconnectProcess):
102         (WebKit::WebProcessPool::updateProcessAssertions):
103         * UIProcess/WebProcessPool.h:
104
105 2019-03-13  Chris Dumez  <cdumez@apple.com>
106
107         REGRESSION(PSON, r240660): Navigation over process boundary is flashy when using Cmd-left/right arrow to navigate
108         https://bugs.webkit.org/show_bug.cgi?id=195684
109         <rdar://problem/48294714>
110
111         Reviewed by Antti Koivisto.
112
113         * Shared/NavigationActionData.cpp:
114         (WebKit::NavigationActionData::encode const):
115         (WebKit::NavigationActionData::decode):
116         * Shared/NavigationActionData.h:
117         * UIProcess/WebPageProxy.cpp:
118         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
119         (WebKit::WebPageProxy::backForwardAddItem):
120         * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
121         (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
122
123 2019-03-13  Chris Dumez  <cdumez@apple.com>
124
125         Drop legacy WebCore::toRegistrableDomain() utility function
126         https://bugs.webkit.org/show_bug.cgi?id=195637
127
128         Reviewed by Geoffrey Garen.
129
130         Drop legacy toRegistrableDomain() / registrableDomainAreEqual() utility functions.
131         Update call sites to use modern RegistrableDomain type instead.
132
133         * UIProcess/WebProcessPool.cpp:
134         (WebKit::WebProcessPool::processForNavigationInternal):
135
136 2019-03-12  Brady Eidson  <beidson@apple.com>
137
138         Take UnboundedNetworking assertion when a file upload is in progress.
139         https://bugs.webkit.org/show_bug.cgi?id=195497
140
141         Reviewed by Geoff Garen.
142
143         This patch implements whole bunch of bookkeeping in both the Networking and UI processes.
144
145         The TLDR of that bookkeeping is:
146         - Whenever any uploads are in progress, take an assertion for both Networking and UI processes.
147         - Whenever a particular WebProcess has an upload in progress, take an assertion for it.
148
149         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
150         (WebKit::NetworkConnectionToWebProcess::NetworkConnectionToWebProcess):
151         (WebKit::NetworkConnectionToWebProcess::setProcessIdentifier):
152         (WebKit::NetworkConnectionToWebProcess::setConnectionHasUploads):
153         (WebKit::NetworkConnectionToWebProcess::clearConnectionHasUploads):
154         * NetworkProcess/NetworkConnectionToWebProcess.h:
155         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
156
157         * NetworkProcess/NetworkResourceLoadMap.cpp: Added.
158         (WebKit::NetworkResourceLoadMap::add):
159         (WebKit::NetworkResourceLoadMap::remove):
160         (WebKit::NetworkResourceLoadMap::get const):
161         * NetworkProcess/NetworkResourceLoadMap.h: Added.
162         (WebKit::NetworkResourceLoadMap::NetworkResourceLoadMap):
163         (WebKit::NetworkResourceLoadMap::isEmpty const):
164         (WebKit::NetworkResourceLoadMap::contains const):
165         (WebKit::NetworkResourceLoadMap::begin):
166         (WebKit::NetworkResourceLoadMap::values):
167
168         * NetworkProcess/NetworkSession.cpp:
169  
170        * Scripts/webkit/messages.py:
171
172         * Sources.txt:
173
174         * UIProcess/Network/NetworkProcessProxy.cpp:
175         (WebKit::NetworkProcessProxy::takeUploadAssertion):
176         (WebKit::NetworkProcessProxy::clearUploadAssertion):
177         * UIProcess/Network/NetworkProcessProxy.h:
178
179         * UIProcess/WebProcessPool.cpp:
180         (WebKit::WebProcessPool::setWebProcessHasUploads):
181         (WebKit::WebProcessPool::clearWebProcessHasUploads):
182         * UIProcess/WebProcessPool.h:
183         * UIProcess/WebProcessPool.messages.in:
184  
185        * WebKit.xcodeproj/project.pbxproj:
186
187         * WebProcess/WebProcess.cpp:
188         (WebKit::WebProcess::ensureNetworkProcessConnection):
189
190 2019-03-13  Chris Dumez  <cdumez@apple.com>
191
192         Use new RegistrableDomain type in PSON code
193         https://bugs.webkit.org/show_bug.cgi?id=195634
194
195         Reviewed by Youenn Fablet.
196
197         Use new RegistrableDomain type in PSON code instead of more error-prone String type.
198
199         * UIProcess/SuspendedPageProxy.cpp:
200         (WebKit::SuspendedPageProxy::SuspendedPageProxy):
201         * UIProcess/SuspendedPageProxy.h:
202         * UIProcess/WebProcessCache.cpp:
203         (WebKit::WebProcessCache::canCacheProcess const):
204         (WebKit::WebProcessCache::addProcessIfPossible):
205         (WebKit::WebProcessCache::takeProcess):
206         (WebKit::WebProcessCache::clearAllProcessesForSession):
207         * UIProcess/WebProcessCache.h:
208         * UIProcess/WebProcessPool.cpp:
209         (WebKit::WebProcessPool::addProcessToOriginCacheSet):
210         (WebKit::WebProcessPool::removeProcessFromOriginCacheSet):
211         (WebKit::WebProcessPool::processForNavigationInternal):
212         (WebKit::WebProcessPool::findReusableSuspendedPageProcess):
213         (WebKit::WebProcessPool::didCollectPrewarmInformation):
214         (WebKit::WebProcessPool::tryPrewarmWithDomainInformation):
215         * UIProcess/WebProcessPool.h:
216         * UIProcess/WebProcessProxy.cpp:
217         (WebKit::WebProcessProxy::canBeAddedToWebProcessCache const):
218         (WebKit::WebProcessProxy::maybeShutDown):
219         (WebKit::WebProcessProxy::didCollectPrewarmInformation):
220         (WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame):
221         * UIProcess/WebProcessProxy.h:
222         (WebKit::WebProcessProxy::registrableDomain const):
223         * UIProcess/WebProcessProxy.messages.in:
224         * WebProcess/WebProcess.cpp:
225         (WebKit::WebProcess::sendPrewarmInformation):
226
227 2019-03-13  Fujii Hironori  <Hironori.Fujii@sony.com>
228
229         [Win][PlayStation] Remove WebCore::standardUserAgentForURL
230         https://bugs.webkit.org/show_bug.cgi?id=195662
231
232         Reviewed by Ryosuke Niwa.
233
234         * WebProcess/WebPage/win/WebPageWin.cpp:
235         (WebKit::WebPage::platformUserAgent const): Return an empty string as well as mac/ios ports.
236
237 2019-03-12  Ross Kirsling  <ross.kirsling@sony.com>
238
239         [Win] Fix a slew of simple clang-cl warnings.
240         https://bugs.webkit.org/show_bug.cgi?id=195652
241
242         Reviewed by Don Olmstead.
243
244         * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
245         (WebKit::NetworkDataTaskCurl::invokeDidReceiveResponse): -Wswitch
246         * Platform/IPC/win/ConnectionWin.cpp:
247         (IPC::Connection::readEventHandler): -Wunused-variable
248         * Platform/win/LoggingWin.cpp:
249         (WebKit::logLevelString): -Wwritable-strings
250         * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
251         (WebKit::ProcessLauncher::launchProcess): -Wunused-variable
252
253 2019-03-12  Ryosuke Niwa  <rniwa@webkit.org>
254
255         Move the code for determining the need for touch bar quirks to Quirks class
256         https://bugs.webkit.org/show_bug.cgi?id=195654
257
258         Reviewed by Brent Fulgham.
259
260         Moved the code to determine whether touch bar quirks are needed or not to WebCore.
261
262         Also renamed HiddenContentEditableQuirk to IsTouchBarUpdateSupressedForHiddenContentEditable
263         and PlainTextQuirk to NeverRichlyEditableForTouchBar.
264
265         * UIProcess/Cocoa/WebViewImpl.h:
266         (WebKit::WebViewImpl::isRichlyEditableForTouchBar): Renamed.
267         * UIProcess/Cocoa/WebViewImpl.mm:
268         (WebKit::WebViewImpl::updateTouchBar):
269         (WebKit::WebViewImpl::candidateListTouchBarItem const):
270         (WebKit::WebViewImpl::isRichlyEditableForTouchBar const): Renamed from isRichlyEditable.
271         (WebKit::WebViewImpl::textTouchBar const):
272         (WebKit::WebViewImpl::updateTextTouchBar):
273         * UIProcess/WebPageProxy.cpp:
274         (WebKit::WebPageProxy::setIsTouchBarUpdateSupressedForHiddenContentEditable): Renamed from
275         setNeedsHiddenContentEditableQuirk.
276         (WebKit::WebPageProxy::setIsNeverRichlyEditableForTouchBar): Renamed from setNeedsPlainTextQuirk.
277         * UIProcess/WebPageProxy.h:
278         (WebKit::WebPageProxy::isTouchBarUpdateSupressedForHiddenContentEditable const): Renamed from
279         needsHiddenContentEditableQuirk.
280         (WebKit::WebPageProxy::isNeverRichlyEditableForTouchBar const): Renamed from needsPlainTextQuirk.
281         * UIProcess/WebPageProxy.messages.in: Renamed the IPC messages.
282         * WebProcess/WebPage/WebPage.cpp:
283         (WebKit::needsHiddenContentEditableQuirk): Deleted. Moved to WebCore.
284         (WebKit::needsPlainTextQuirk): Deleted. Moved to WebCore.
285         (WebKit::WebPage::didStartPageTransition):
286         (WebKit::WebPage::didChangeSelection):
287         * WebProcess/WebPage/WebPage.h:
288         (WebKit::WebPage):
289
290 2019-03-12  Jiewen Tan  <jiewen_tan@apple.com>
291
292         Add WebFrameProxy::loadData
293         https://bugs.webkit.org/show_bug.cgi?id=195647
294         <rdar://problem/48826856>
295
296         Reviewed by Youenn Fablet.
297
298         This patch adds WebFrameProxy::loadData which is a simplified version of WebPageProxy::loadData that
299         loads substitute data to an iframe. This is needed by the Load Optimizer.
300
301         * UIProcess/WebFrameProxy.cpp:
302         (WebKit::WebFrameProxy::loadData):
303         * UIProcess/WebFrameProxy.h:
304         * WebProcess/WebPage/WebPage.cpp:
305         (WebKit::WebPage::loadDataInFrame):
306         * WebProcess/WebPage/WebPage.h:
307         * WebProcess/WebPage/WebPage.messages.in:
308
309 2019-03-12  Wenson Hsieh  <wenson_hsieh@apple.com>
310
311         [iOS] Input view sometimes flickers when blurring and refocusing an element
312         https://bugs.webkit.org/show_bug.cgi?id=195639
313         <rdar://problem/48735337>
314
315         Reviewed by Tim Horton.
316
317         On iOS, if a focused element is blurred and immediately refocused in the scope of user interaction, we will end
318         up reloading interaction state (input views, autocorrection contexts, etc.) in the UI process. On certain well-
319         trafficked websites, this results in the input view and input accessory view flickering (or more egregiously,
320         scrolling to re-reveal the focused element) when changing selection.
321
322         To fix the issue, this patch refactors some focus management logic to suppress sending focused element updates
323         to the UI process in the case where the same element is being blurred and immediately refocused. To do this, we
324         track the most recently blurred element and bail when the recently blurred element is identical to the newly
325         focused element. See below for more detail.
326
327         Test: fast/forms/ios/keyboard-stability-when-refocusing-element.html
328
329         * UIProcess/WebPageProxy.h:
330         * UIProcess/ios/WKContentViewInteraction.mm:
331         (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
332         (-[WKContentView _elementDidBlur]):
333
334         Update the web process' notion of whether an input view is showing. Importantly, this accounts for decisions
335         made by _WKUIDelegate. See below for more details.
336
337         (isAssistableInputType): Deleted.
338
339         Removed this helper function; this was only used in one place as a sanity check that the focused element's type
340         is not none, right before attempting to show an input view. Instead, we can just check the focused element's
341         type directly against InputType::None in the if statement of the early return.
342
343         * UIProcess/ios/WebPageProxyIOS.mm:
344         (WebKit::WebPageProxy::setIsShowingInputViewForFocusedElement):
345
346         Add a hook to notify the web process when an input view is showing or not (see below for more detail).
347
348         * WebProcess/WebPage/WebPage.cpp:
349         (WebKit::WebPage::didStartPageTransition):
350         (WebKit::WebPage::elementDidRefocus):
351         (WebKit::WebPage::shouldDispatchUpdateAfterFocusingElement const):
352
353         Add a helper to determine whether we notify the UI process about a newly focused element. On macOS, this is true
354         only when the new focused element is neither the currently focused element, nor the focused element that was
355         just blurred. On iOS, we have an additional constraint that when the input view is not showing, we still need to
356         notify the UI process, since the UI process might want to begin showing the keyboard for an element that has
357         only been programmatically focused, for which we aren't currently showing the input view.
358
359         (WebKit::WebPage::elementDidFocus):
360         (WebKit::WebPage::elementDidBlur):
361
362         Replace a couple of existing member variables in WebPage used for focus management:
363         -   Replace m_hasPendingBlurNotification with m_recentlyBlurredElement, a RefPtr to the Element that is being
364             blurred. Behavior here is the same as before (i.e. having a pending blur notification is equivalent to
365             having recently blurred a focused element). However, this allows us to check newly focused elements against
366             the recently blurred element in WebPage::elementDidFocus().
367         -   Replace m_isFocusingElementDueToUserInteraction with m_isShowingInputViewForFocusedElement. The flag
368             m_isFocusingElementDueToUserInteraction was originally added to fix <webkit.org/b/146735>, by ensuring that
369             we don't send redundant ElementDidFocus (formerly, StartAssistingNode) messages to the UI process even when
370             the keyboard is already up. In these simpler times, user interaction when focusing an element was equivalent
371             to showing an input view for the focused element. However, in today's world, there are a variety of reasons
372             why we might or might not show an input view for a given element (including, but not limited to activity
373             state changes and decisions made by _WKInputDelegate). As such, it doesn't make sense to continue relying on
374             m_isFocusingElementDueToUserInteraction in this early return. Instead, have the UI process propagate a
375             message back to the web process, to let it know whether there is a keyboard showing, and use this flag
376             instead.
377
378         * WebProcess/WebPage/WebPage.h:
379         * WebProcess/WebPage/WebPage.messages.in:
380         * WebProcess/WebPage/ios/WebPageIOS.mm:
381         (WebKit::WebPage::setIsShowingInputViewForFocusedElement):
382
383 2019-03-12  Tim Horton  <timothy_horton@apple.com>
384
385         More attempts at build fixing.
386
387         * UIProcess/ios/WKActionSheetAssistant.mm:
388         Yet more.
389
390 2019-03-12  Chris Dumez  <cdumez@apple.com>
391
392         Device Orientation access permission should be denied unless explicitly granted by the client
393         https://bugs.webkit.org/show_bug.cgi?id=195625
394
395         Reviewed by Youenn Fablet.
396
397         Device Orientation access permission should be denied unless explicitly granted by the client.
398         Previously, it was granted by default.
399
400         * UIProcess/API/APIUIClient.h:
401         (API::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
402         * UIProcess/API/C/WKPage.cpp:
403         (WKPageSetPageUIClient):
404         * UIProcess/Cocoa/UIDelegate.mm:
405         (WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
406
407 2019-03-12  Antti Koivisto  <antti@apple.com>
408
409         [iOS] Enable asynchronous frame scrolling by default
410         https://bugs.webkit.org/show_bug.cgi?id=195622
411         <rdar://problem/48658028>
412
413         Reviewed by Simon Fraser
414
415         * Shared/WebPreferences.yaml:
416         * Shared/WebPreferencesDefaultValues.h:
417
418 2019-03-12  Per Arne Vollan  <pvollan@apple.com>
419
420         [iOS] Block access to backboardd service
421         https://bugs.webkit.org/show_bug.cgi?id=195484
422
423         Reviewed by Brent Fulgham.
424
425         This patch is addressing blocking the backboardd service "com.apple.backboard.hid.services". Getting the
426         backlight level in the WebContent process will initiate a connection with this service. To be able to
427         block the service, the backlight level is queried in the UI process and sent to the WebContent process
428         when the WebContent process is started, and when the backlight level is changed. On the WebContent side,
429         the method getting the backlight level is swizzled to return the value sent from the UI process.
430
431         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
432         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
433         (WebKit::WebProcessPool::displayBrightness):
434         (WebKit::WebProcessPool::backlightLevelDidChangeCallback):
435         (WebKit::WebProcessPool::registerNotificationObservers):
436         (WebKit::WebProcessPool::unregisterNotificationObservers):
437         * UIProcess/WebProcessPool.cpp:
438         (WebKit::WebProcessPool::initializeNewWebProcess):
439         * UIProcess/WebProcessPool.h:
440         * WebProcess/WebProcess.h:
441         * WebProcess/WebProcess.messages.in:
442         * WebProcess/cocoa/WebProcessCocoa.mm:
443         (WebKit::currentBacklightLevel):
444         (WebKit::WebProcess::backlightLevelDidChange):
445
446 2019-03-12  Tim Horton  <timothy_horton@apple.com>
447
448         Fix the build after 242801
449
450         * UIProcess/ios/WKActionSheetAssistant.mm:
451         (-[WKActionSheetAssistant _elementActionForDDAction:]):
452         More.
453
454 2019-03-12  Tim Horton  <timothy_horton@apple.com>
455
456         Fix the build after 242801
457
458         * UIProcess/ios/WKActionSheetAssistant.mm:
459         (-[WKActionSheetAssistant _elementActionForDDAction:]):
460
461 2019-03-12  Eric Carlson  <eric.carlson@apple.com>
462
463         [iOS] Sandbox must allow mach lookup required to compress video
464         https://bugs.webkit.org/show_bug.cgi?id=195627
465         <rdar://problem/48811072>
466
467         Reviewed by Youenn Fablet.
468
469         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
470
471 2019-03-12  Jennifer Moore  <jennifer.moore@apple.com>
472
473         Check whether to launch a default action instead of action sheet
474         https://bugs.webkit.org/show_bug.cgi?id=195225
475         <rdar://problem/47715544>
476
477         Reviewed by Daniel Bates and Tim Horton.
478
479         Notify DataDetectors at the start of a touch on a link, and check whether to immediately
480         launch the default action instead of an action sheet.
481
482         * UIProcess/ios/WKActionSheetAssistant.h:
483         * UIProcess/ios/WKActionSheetAssistant.mm:
484         (-[WKActionSheetAssistant interactionDidStart]):
485         (-[WKActionSheetAssistant _createSheetWithElementActions:defaultTitle:showLinkTitle:]):
486         (-[WKActionSheetAssistant showImageSheet]):
487         (-[WKActionSheetAssistant showLinkSheet]):
488         (-[WKActionSheetAssistant showDataDetectorsSheet]):
489         (-[WKActionSheetAssistant _createSheetWithElementActions:showLinkTitle:]): Deleted.
490         * UIProcess/ios/WKContentViewInteraction.mm:
491         (-[WKContentView _webTouchEventsRecognized:]):
492 :
493 2019-03-12  Zalan Bujtas  <zalan@apple.com>
494
495         [Synthetic Click] Dispatch mouseout soon after mouseup
496         https://bugs.webkit.org/show_bug.cgi?id=195575
497         <rdar://problem/47093049>
498
499         Reviewed by Simon Fraser.
500
501         * WebProcess/WebPage/ios/WebPageIOS.mm:
502         (WebKit::WebPage::completeSyntheticClick):
503
504 2019-03-12  Zalan Bujtas  <zalan@apple.com>
505
506         [ContentChangeObserver] Stop content change observation when the touch event turns into long press
507         https://bugs.webkit.org/show_bug.cgi?id=195601
508         <rdar://problem/48796324>
509
510         Reviewed by Wenson Hsieh.
511
512         Add didRecognizeLongPress() message to be able to cancel content observation (started at touchStart).
513
514         * UIProcess/WebPageProxy.h:
515         * UIProcess/ios/WKContentViewInteraction.mm:
516         (-[WKContentView _longPressRecognized:]):
517         * UIProcess/ios/WebPageProxyIOS.mm:
518         (WebKit::WebPageProxy::didRecognizeLongPress):
519         * WebProcess/WebPage/WebPage.h:
520         * WebProcess/WebPage/WebPage.messages.in:
521         * WebProcess/WebPage/ios/WebPageIOS.mm:
522         (WebKit::WebPage::didRecognizeLongPress):
523
524 2019-03-11  Andy Estes  <aestes@apple.com>
525
526         [Mac] Ensure Apple Pay is unavailable when PassKit.framework is missing
527         https://bugs.webkit.org/show_bug.cgi?id=195583
528         <rdar://problem/48420224>
529
530         Reviewed by Daniel Bates.
531
532         PassKit.framework is optionally soft-linked on Mac because it is missing from the Recovery
533         Partition. We need to check if the framework is available before calling into it.
534
535         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
536         (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
537         (WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard):
538         (WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup):
539         (WebKit::WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks):
540         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
541         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
542
543 2019-03-12  Antti Koivisto  <antti@apple.com>
544
545         Compositing layer that renders two positioned elements should not hit test
546         https://bugs.webkit.org/show_bug.cgi?id=195371
547         <rdar://problem/48649586>
548
549         Reviewed by Simon Fraser.
550
551         * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
552         (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
553         * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
554         * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
555         (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
556         (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode const):
557         (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
558
559         Pass event region to UI process.
560
561         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
562         (WebKit::RemoteLayerTreeNode::layerID const):
563         (WebKit::RemoteLayerTreeNode::eventRegion const):
564         * UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm:
565         (WebKit::RemoteLayerTreeNode::RemoteLayerTreeNode):
566         (WebKit::RemoteLayerTreeNode::~RemoteLayerTreeNode):
567         (WebKit::RemoteLayerTreeNode::setEventRegion):
568
569         Maintain event region in RemoteLayerTreeNodes.
570
571         (WebKit::RemoteLayerTreeNode::initializeLayer):
572         (WebKit::RemoteLayerTreeNode::layerID):
573         (WebKit::RemoteLayerTreeNode::forCALayer):
574
575         Move layerID to RemoteLayerTreeNode and store RemoteLayerTreeNode pointer to CALayers instead.
576         This makes it easy to find the matching RemoteLayerTreeNode from a layer, globally.
577
578         (WebKit::RemoteLayerTreeNode::setLayerID): Deleted.
579         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
580         (WebKit::collectDescendantViewsAtPoint):
581
582         If we have event region, use it for hit testing.
583
584         (-[UIView _web_findDescendantViewAtPoint:withEvent:]):
585         (collectDescendantViewsAtPoint): Deleted.
586         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
587         (WebKit::PlatformCALayerRemote::eventRegion const):
588         (WebKit::PlatformCALayerRemote::setEventRegion):
589         * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
590
591 2019-03-12  Carlos Garcia Campos  <cgarcia@igalia.com>
592
593         [WPE][GTK] Load events may occur in unexpected order when JS redirects page before subresource load finishes
594         https://bugs.webkit.org/show_bug.cgi?id=194131
595
596         Reviewed by Michael Catanzaro.
597
598         Ensure we emit the load-failed and load-changed with finished event when there's still an ongoing load when a
599         new provisional load strarts. Previous load fails with cancelled error.
600
601         * UIProcess/API/glib/WebKitWebView.cpp:
602         (webkitWebViewWillStartLoad): Call webkitWebViewLoadFailed() if current page load state is not finished.
603         * UIProcess/API/glib/WebKitWebViewPrivate.h:
604         * UIProcess/API/gtk/PageClientImpl.cpp:
605         (WebKit::PageClientImpl::didStartProvisionalLoadForMainFrame): Call webkitWebViewWillStartLoad().
606         * UIProcess/API/wpe/APIViewClient.h:
607         (API::ViewClient::willStartLoad): Add willStartLoad() to API::ViewClient
608         * UIProcess/API/wpe/PageClientImpl.cpp:
609         (WebKit::PageClientImpl::didStartProvisionalLoadForMainFrame): Call WPEView::willStartLoad().
610         * UIProcess/API/wpe/PageClientImpl.h:
611         * UIProcess/API/wpe/WPEView.cpp:
612         (WKWPE::View::willStartLoad): Call API::ViewClient::willStartLoad().
613         * UIProcess/API/wpe/WPEView.h:
614         * UIProcess/PageLoadState.h:
615         (WebKit::PageLoadState::isProvisional const):
616         (WebKit::PageLoadState::isCommitted const):
617         (WebKit::PageLoadState::isFinished const):
618
619 2019-03-11  Ryan Haddad  <ryanhaddad@apple.com>
620
621         Unreviewed, rolling out r242763.
622
623         Causes layout test crashes on iOS simulator
624
625         Reverted changeset:
626
627         "[Synthetic Click] Dispatch mouseout soon after mouseup"
628         https://bugs.webkit.org/show_bug.cgi?id=195575
629         https://trac.webkit.org/changeset/242763
630
631 2019-03-11  Ross Kirsling  <ross.kirsling@sony.com>
632
633         Add Optional to Forward.h.
634         https://bugs.webkit.org/show_bug.cgi?id=195586
635
636         Reviewed by Darin Adler.
637
638         * Shared/RTCNetwork.cpp:
639         * Shared/RTCNetwork.h:
640         * Shared/RTCPacketOptions.cpp:
641         * Shared/RTCPacketOptions.h:
642         * UIProcess/API/APIWebsitePolicies.h:
643         * UIProcess/WebStorage/LocalStorageDatabaseTracker.h:
644         Remove unnecessary includes from headers.
645
646 2019-03-11  Commit Queue  <commit-queue@webkit.org>
647
648         Unreviewed, rolling out r242745 and r242756.
649         https://bugs.webkit.org/show_bug.cgi?id=195606
650
651         Breaks internal builds (Requested by ryanhaddad on #webkit).
652
653         Reverted changesets:
654
655         "[iOS] Block access to backboardd service"
656         https://bugs.webkit.org/show_bug.cgi?id=195484
657         https://trac.webkit.org/changeset/242745
658
659         "Unreviewed build fix after r242745."
660         https://trac.webkit.org/changeset/242756
661
662 2019-03-11  Fujii Hironori  <Hironori.Fujii@sony.com>
663
664         [CoordinatedGraphics] ASSERTION FAILED: !m_state.isSuspended
665         https://bugs.webkit.org/show_bug.cgi?id=195550
666
667         Reviewed by Carlos Garcia Campos.
668
669         CompositingRunLoop::suspend() locks a mutex and stops the update
670         timer. But, the timer can be fired after the lock was acquired and
671         before the timer is stopped.
672
673         * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
674         (WebKit::CompositingRunLoop::updateTimerFired): Removed the
675         assertion. Return early if m_state.isSuspended.
676
677 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
678
679         [macOS] Remove the Kerberos rules from the WebContent sandbox
680         https://bugs.webkit.org/show_bug.cgi?id=195464
681         <rdar://problem/35369230>
682
683         Reviewed by Brent Fulgham.
684
685         Kerberos auth is done in the UIProcess or NetworkProcess now.
686
687         * WebProcess/com.apple.WebProcess.sb.in:
688
689 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
690
691         [iOS] Add entitlement to enable use of graphics endpoint with limited capabilities
692         https://bugs.webkit.org/show_bug.cgi?id=195582
693         <rdar://problem/36082379>
694
695         Reviewed by Brent Fulgham.
696
697         This is a QuartzCore endpoint with a minimal set of capabilities.
698
699         * Configurations/WebContent-iOS.entitlements:
700
701 2019-03-11  John Wilander  <wilander@apple.com>
702
703         Move NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm functionality into UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
704         https://bugs.webkit.org/show_bug.cgi?id=195117
705         <rdar://problem/48448715>
706
707         Reviewed by Brent Fulgham.
708
709         Reading of user defaults on Cocoa platforms should be done in the UI process and
710         forwarded to Resource Load Statistics in the network process through the
711         WebKit::NetworkSessionCreationParameters struct.
712
713         This patch does away with some old user defaults we don't use anymore. It also
714         changes the developer-facing default name to ITPManualPrevalentResource.
715
716         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
717         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
718             Removed the call to the old registerUserDefaultsIfNeeded().
719         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
720         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
721             Removed the call to the old registerUserDefaultsIfNeeded().
722         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
723             Removed the declaration of the old registerUserDefaultsIfNeeded().
724         * NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm: Removed.
725         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
726             Added an enum class EnableResourceLoadStatisticsDebugMode.
727         * NetworkProcess/NetworkSession.cpp:
728         (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
729         * NetworkProcess/NetworkSession.h:
730         * NetworkProcess/NetworkSessionCreationParameters.cpp:
731         (WebKit::NetworkSessionCreationParameters::encode const):
732         (WebKit::NetworkSessionCreationParameters::decode):
733         * NetworkProcess/NetworkSessionCreationParameters.h:
734            The struct now has two new fields:
735            - enableResourceLoadStatisticsDebugMode
736            - resourceLoadStatisticsManualPrevalentResource
737         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
738         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
739             Forwarding of the parameters.
740         * SourcesCocoa.txt:
741         * UIProcess/WebProcessPool.cpp:
742         (WebKit::WebProcessPool::ensureNetworkProcess):
743             Forwarding of the parameters.
744         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
745         (WebKit::WebsiteDataStore::parameters):
746             This is where user defaults for Resource Load Statistics are now read.
747         * WebKit.xcodeproj/project.pbxproj:
748
749 2019-03-11  Zalan Bujtas  <zalan@apple.com>
750
751         [Synthetic Click] Dispatch mouseout soon after mouseup
752         https://bugs.webkit.org/show_bug.cgi?id=195575
753         <rdar://problem/47093049>
754
755         Reviewed by Simon Fraser.
756
757         * WebProcess/WebPage/ios/WebPageIOS.mm:
758         (WebKit::WebPage::completeSyntheticClick):
759
760 2019-03-11  Tim Horton  <timothy_horton@apple.com>
761
762         API test WebKit.RequestTextInputContext fails on iOS
763         https://bugs.webkit.org/show_bug.cgi?id=195585
764
765         Reviewed by Wenson Hsieh and Simon Fraser.
766
767         * UIProcess/API/Cocoa/WKWebView.mm:
768         (-[WKWebView _convertRectFromRootViewCoordinates:]):
769         (-[WKWebView _convertRectToRootViewCoordinates:]):
770         (-[WKWebView _requestTextInputContextsInRect:completionHandler:]):
771         (-[WKWebView _focusTextInputContext:completionHandler:]):
772         * WebProcess/WebPage/WebPage.cpp:
773         (WebKit::elementRectInRootViewCoordinates):
774         (WebKit::WebPage::textInputContextsInRect):
775         (WebKit::elementRectInWindowCoordinates): Deleted.
776         Text input context SPI should be in terms of WKWebView coordinates,
777         for consistency's sake. This is a bit irritating; WebPage(Proxy) continue
778         to operate in "root view" coordinates, which means different things
779         depending on if delegatesScrolling is true or not. So, WKWebView does
780         the conversion, re-creating objects as needed.
781
782 2019-03-09  Jiewen Tan  <jiewen_tan@apple.com>
783
784         Optimizing loads when creating new pages
785         https://bugs.webkit.org/show_bug.cgi?id=195516
786         <rdar://problem/48738086>
787
788         Reviewed by Darin Adler.
789
790         This patch adds hooks in WebPageProxy::createNewPage to optimize loads, and moves the creationParameters
791         of API::NavigationAction from UI clients to WebPageProxy::createNewPage. Also, we now pass the whole
792         API::NavigationAction to the load optimizer instead of the request within.
793
794         * UIProcess/API/APINavigationAction.h:
795         * UIProcess/API/APIUIClient.h:
796         (API::UIClient::createNewPage):
797         * UIProcess/API/C/WKPage.cpp:
798         (WKPageSetPageUIClient):
799         * UIProcess/API/glib/WebKitUIClient.cpp:
800         * UIProcess/Cocoa/NavigationState.mm:
801         (WebKit::tryOptimizingLoad):
802         (WebKit::tryInterceptNavigation):
803         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
804         * UIProcess/Cocoa/UIDelegate.h:
805         * UIProcess/Cocoa/UIDelegate.mm:
806         (WebKit::UIDelegate::UIClient::createNewPage):
807         * UIProcess/WebPageProxy.cpp:
808         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
809         (WebKit::tryOptimizingLoad):
810         (WebKit::WebPageProxy::createNewPage):
811         * UIProcess/WebPageProxy.h:
812
813 2019-03-11  Dean Jackson  <dino@apple.com>
814
815         [iOS] Implement a faster click detection that intercepts double-tap-to-zoom if possible
816         https://bugs.webkit.org/show_bug.cgi?id=195473
817         <rdar://problem/48718396>
818
819         Reviewed by Wenson Hsieh (with some help from Dan Bates).
820
821         Adds a new algorithm, behind a flag FasterClicksEnabled, that can trigger a click
822         event without waiting to see if a double tap will occur. It does this by examining
823         the amount of zoom that would be triggered if it was a double tap, and if that value
824         doesn't exceed a set threshold, commits to the click event instead.
825
826         This is implemented by having the Web Process respond to the potential click with
827         some geometry information. If the UI Process receives the information before the
828         second tap in a double tap, it can decide to trigger a click.
829
830         * Shared/WebPreferences.yaml: New internal feature so this can be toggled in
831             a UI for testing.
832
833         * SourcesCocoa.txt: Renamed WKSyntheticTapGestureRecognizer.
834         * WebKit.xcodeproj/project.pbxproj: Ditto.
835
836         * UIProcess/ios/WKSyntheticTapGestureRecognizer.h:
837         * UIProcess/ios/WKSyntheticTapGestureRecognizer.m:
838         (-[WKSyntheticTapGestureRecognizer setGestureIdentifiedTarget:action:]):
839         (-[WKSyntheticTapGestureRecognizer setGestureFailedTarget:action:]):
840         (-[WKSyntheticTapGestureRecognizer setResetTarget:action:]):
841         (-[WKSyntheticTapGestureRecognizer setState:]):
842         (-[WKSyntheticTapGestureRecognizer reset]):  Renamed WKSyntheticClickTapGestureRecognizer to
843             WKSyntheticTapGestureRecognizer, changed the signature of the main function to be a bit
844             more clear about what it does, and added a gesture failed target.
845
846         * UIProcess/API/Cocoa/WKWebViewInternal.h:
847         * UIProcess/API/Cocoa/WKWebView.mm:
848         (-[WKWebView _initialScaleFactor]):
849         (-[WKWebView _contentZoomScale]):
850         (-[WKWebView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
851             Exposed the initial content scale, the current scale and added a declaration that
852             was missing from the .h.
853
854         * UIProcess/WebPageProxy.messages.in: Add a new message,
855             HandleSmartMagnificationInformationForPotentialTap, to
856             communicate the geometry of the clicked node to the UI Process.
857
858         * UIProcess/PageClient.h: Pure virtual function for the geometry message response.
859         * UIProcess/WebPageProxy.h: Ditto.
860
861         * UIProcess/ios/PageClientImplIOS.h: Calls into the WKContentView.
862         * UIProcess/ios/PageClientImplIOS.mm:
863         (WebKit::PageClientImpl::handleSmartMagnificationInformationForPotentialTap):
864
865         * UIProcess/ios/SmartMagnificationController.h:
866         * UIProcess/ios/SmartMagnificationController.mm:
867         (WebKit::SmartMagnificationController::calculatePotentialZoomParameters): A new method that
868             asks the WKContentView to work out what the zoom factor will be for a potential double
869             tap at a location.
870         (WebKit::SmartMagnificationController::smartMagnificationTargetRectAndZoomScales): New implementation
871             of this function to avoid multiple out-arguments.
872
873         * UIProcess/ios/WKContentView.h:
874         * UIProcess/ios/WKContentView.mm:
875         (-[WKContentView _initialScaleFactor]):
876         (-[WKContentView _contentZoomScale]):
877         (-[WKContentView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
878             Exposed the initial content scale, the current scale and the target zoom scale. These
879             all just call into the WKWebView implementation.
880
881         * UIProcess/ios/WKContentViewInteraction.h:
882         * UIProcess/ios/WKContentViewInteraction.mm:
883         (-[WKContentView _createAndConfigureDoubleTapGestureRecognizer]): Use a WKSyntheticTapGestureRecognizer instead
884             of a generic one, so we can capture the failure.
885         (-[WKContentView setupInteraction]):
886         (-[WKContentView cleanupInteraction]):
887         (-[WKContentView _handleSmartMagnificationInformationForPotentialTap:origin:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:]):
888             New method that responds to the incoming Web Process message, and decides if any
889             potential zoom would be "significant".
890         (-[WKContentView _singleTapIdentified:]):
891         (-[WKContentView _doubleTapDidFail:]):
892         (-[WKContentView _didCompleteSyntheticClick]):
893         (-[WKContentView _singleTapRecognized:]):
894         (-[WKContentView _doubleTapRecognized:]):
895             Add some release logging.
896         (-[WKContentView _singleTapCommited:]): Deleted.
897
898         * UIProcess/ios/WebPageProxyIOS.mm:
899         (WebKit::WebPageProxy::potentialTapAtPosition):
900         (WebKit::WebPageProxy::handleSmartMagnificationInformationForPotentialTap):
901         * WebProcess/WebPage/ViewGestureGeometryCollector.h:
902         * WebProcess/WebPage/WebPage.h:
903         * WebProcess/WebPage/WebPage.messages.in:
904             Removed an unused parameter from the existing message.
905
906         * WebProcess/WebPage/ios/WebPageIOS.mm:
907         (WebKit::WebPage::potentialTapAtPosition): Calculates the geometry of the element
908         if requested, and sends it to the UIProcess.
909
910 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
911
912         Unreviewed build fix after r242745.
913
914         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
915         (WebKit::WebProcessPool::registerNotificationObservers):
916         (WebKit::WebProcessPool::unregisterNotificationObservers):
917
918 2019-03-11  Chris Dumez  <cdumez@apple.com>
919
920         Assert in WebPageProxy::suspendCurrentPageIfPossible()
921         https://bugs.webkit.org/show_bug.cgi?id=195506
922         <rdar://problem/48733477>
923
924         Reviewed by Alex Christensen.
925
926         The crash was caused by the top-hit preloading logic in MobileSafari which creates a new Web view that is *related*
927         to the previous one, restores the session state onto it and then triggers a load in this new Web view.
928
929         Initially, the 2 Web views use the same process as they are related. However, if the new load's URL is cross-site
930         with regards to the first view's URL, then we decide to process swap in the new view. This process swap makes
931         sense from a security standpoint. However, when we commit the load in the new process and call
932         suspendCurrentPageIfPossible() we end up in an unexpected state because we have a fromItem (due to the session
933         state having been restored on the new view) but we haven't committed any load yet in this new view.
934
935         To address the issue, suspendCurrentPageIfPossible() now returns early and does not attempt to suspend anything
936         if we have not committed any load yet.
937
938         * UIProcess/WebPageProxy.cpp:
939         (WebKit::WebPageProxy::suspendCurrentPageIfPossible):
940         Do not attempt to suspend to current page if we have not committed any provisional load yet.
941
942 2019-03-11  Chris Dumez  <cdumez@apple.com>
943
944         Update device orientation & motion permission native SPI as per latest proposal
945         https://bugs.webkit.org/show_bug.cgi?id=195567
946
947         Reviewed by Youenn Fablet.
948
949         The native SPI is now:
950         +- (void)_webView:(WKWebView *)webView shouldAllowDeviceOrientationAndMotionAccessRequestedByFrame:(WKFrameInfo *)frameInfo decisionHandler:(void (^)(BOOL))decisionHandler;
951
952         * UIProcess/API/APIUIClient.h:
953         (API::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
954         * UIProcess/API/C/WKPage.cpp:
955         (WKPageSetPageUIClient):
956         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
957         * UIProcess/Cocoa/UIDelegate.h:
958         * UIProcess/Cocoa/UIDelegate.mm:
959         (WebKit::UIDelegate::setDelegate):
960         (WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
961         * UIProcess/WebPageProxy.cpp:
962         (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
963         * UIProcess/WebPageProxy.h:
964         * UIProcess/WebPageProxy.messages.in:
965         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
966         (WebKit::WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess):
967         * WebProcess/WebCoreSupport/WebChromeClient.h:
968         * WebProcess/WebPage/WebPage.cpp:
969         (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
970         * WebProcess/WebPage/WebPage.h:
971
972 2019-03-11  Andy Estes  <aestes@apple.com>
973
974         [Apple Pay] Use PKPaymentAuthorizationController to present the Apple Pay UI remotely from the Networking service on iOS
975         https://bugs.webkit.org/show_bug.cgi?id=195530
976         <rdar://problem/48747164>
977
978         Reviewed by Alex Christensen.
979
980         * Configurations/Network-iOS.entitlements: Added the 'com.apple.payment.all-access'
981         entitlement and reordered the others.
982
983         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
984         (WebKit::NetworkConnectionToWebProcess::didReceiveMessage): Forwarded
985         WebPaymentCoordinatorProxy messages to the payment coordinator.
986         (WebKit::NetworkConnectionToWebProcess::didReceiveSyncMessage): Ditto.
987         (WebKit::NetworkConnectionToWebProcess::didClose): Set m_paymentCoordinator to nullptr.
988         * NetworkProcess/NetworkConnectionToWebProcess.h: Inherited from
989         WebPaymentCoordinatorProxy::Client and added a unique_ptr<WebPaymentCoordinatorProxy> member.
990
991         * NetworkProcess/cocoa/NetworkSessionCocoa.h: Declared getters for source application bundle
992         and secondary identifiers, and CTDataConnectionServiceType on iOS.
993         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
994         (WebKit::NetworkSessionCocoa::sourceApplicationBundleIdentifier const): Defined getter.
995         (WebKit::NetworkSessionCocoa::sourceApplicationSecondaryIdentifier const): Ditto.
996         (WebKit::NetworkSessionCocoa::ctDataConnectionServiceType const): Ditto.
997         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): Initialized
998         m_sourceApplicationBundleIdentifier and m_sourceApplicationSecondaryIdentifier with
999         corresponding NetworkSessionCreationParameters.
1000
1001         * NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm: Added.
1002         (WebKit::NetworkConnectionToWebProcess::paymentCoordinator): Added. Returns
1003         m_paymentCoordinator after lazily initializing it.
1004         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorConnection): Added. Returns the
1005         connection to the web process.
1006         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorPresentingViewController): Added.
1007         Returns nil.
1008         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorCTDataConnectionServiceType):
1009         Added. Returns the value from the network session identified by sessionID.
1010         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationBundleIdentifier):
1011         Ditto.
1012         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationSecondaryIdentifier):
1013         Ditto.
1014         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAuthorizationPresenter): Added.
1015         Returns a new PaymentAuthorizationController.
1016         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAddMessageReceiver): Added empty
1017         definition. NetworkConnectionToWebProcess explicitly forwards WebPaymentCoordinatorProxy
1018         messages to its payment coordinator, so there's no need to register with a MessageReceiverMap.
1019         (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorRemoveMessageReceiver): Ditto.
1020
1021         * Platform/ios/PaymentAuthorizationController.h: Added. Declares a
1022         PaymentAuthorizationPresenter subclass based on PKPaymentAuthorizationController.
1023         * Platform/ios/PaymentAuthorizationController.mm: Added.
1024         (-[WKPaymentAuthorizationControllerDelegate initWithRequest:presenter:]):
1025         Initialized WKPaymentAuthorizationDelegate with request and presenter.
1026         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationControllerDidFinish:]):
1027         Forwarded call to WKPaymentAuthorizationDelegate.
1028         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didAuthorizePayment:handler:]):
1029         Ditto.
1030         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingMethod:handler:]):
1031         Ditto.
1032         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingContact:handler:]):
1033         Ditto.
1034         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectPaymentMethod:handler:]):
1035         Ditto.
1036         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:willFinishWithError:]):
1037         Ditto.
1038         (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didRequestMerchantSession:]):
1039         Ditto.
1040         (WebKit::PaymentAuthorizationController::PaymentAuthorizationController):
1041         Initialized m_controller with a new PKPaymentAuthorizationController and m_delegate with a
1042         new WKPaymentAuthorizationControllerDelegate.
1043         (WebKit::PaymentAuthorizationController::platformDelegate): Returned m_delegate.
1044         (WebKit::PaymentAuthorizationController::dismiss): Dismissed the controller, set its
1045         delegates to nil, set m_controller to nil, invalidated the delegate, and set m_delegate to
1046         nil.
1047         (WebKit::PaymentAuthorizationController::present): Called -presentWithCompletion: on the
1048         controller, forwarding the passed-in completion handler.
1049         * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: Allowed PassKit to look up
1050         the "com.apple.passd.in-app-payment" and "com.apple.passd.library" service endpoints.
1051
1052         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
1053         (WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy): Changed to call
1054         paymentCoordinatorAddMessageReceiver.
1055         (WebKit::WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy): Changed to call
1056         paymentCoordinatorRemoveMessageReceiver.
1057         (WebKit::WebPaymentCoordinatorProxy::messageSenderDestinationID const): Deleted.
1058         (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard): Passed sessionID to
1059         platformCanMakePaymentsWithActiveCard.
1060         (WebKit::WebPaymentCoordinatorProxy::showPaymentUI): Stored destinationID and passed
1061         sessionID to platformShowPaymentUI.
1062         (WebKit::WebPaymentCoordinatorProxy::cancelPaymentSession): Changed to account for new
1063         behavior of didCancelPaymentSession.
1064         (WebKit::WebPaymentCoordinatorProxy::didCancelPaymentSession): Changed to call hidePaymentUI.
1065         (WebKit::WebPaymentCoordinatorProxy::presenterDidFinish): Changed to only call hidePaymentUI
1066         when didReachFinalState is true, since didCancelPaymentSession is called otherwise.
1067         (WebKit::WebPaymentCoordinatorProxy::didReachFinalState): Cleared m_destinationID.
1068         * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Added m_destionationID member.
1069         * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Changed
1070         CanMakePaymentsWithActiveCard and ShowPaymentUI messages to take destinationID and sessionID
1071         arguments.
1072
1073         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
1074         (WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard): Passed
1075         sessionID to paymentCoordinatorSourceApplicationSecondaryIdentifier.
1076         (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Passed sessionID to various
1077         m_client call sites.
1078
1079         * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
1080         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
1081         platformPaymentRequest.
1082         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
1083         before calling dismiss.
1084
1085         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
1086         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
1087         platformPaymentRequest.
1088         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
1089         before calling dismiss.
1090
1091         * Shared/WebPreferences.yaml: Added ApplePayRemoteUIEnabled as an internal preference.
1092
1093         * SourcesCocoa.txt: Added NetworkConnectionToWebProcessIOS.mm and
1094         PaymentAuthorizationController.mm.
1095
1096         * UIProcess/AuxiliaryProcessProxy.h:
1097         (WebKit::AuxiliaryProcessProxy::messageReceiverMap): Deleted.
1098
1099         * UIProcess/Cocoa/WebPageProxyCocoa.mm:
1100         (WebKit::WebPageProxy::paymentCoordinatorConnection): Moved from WebPageProxy.cpp.
1101         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
1102         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
1103         (WebKit::WebPageProxy::paymentCoordinatorAddMessageReceiver): Ditto.
1104         (WebKit::WebPageProxy::paymentCoordinatorRemoveMessageReceiver): Ditto.
1105
1106         * UIProcess/WebPageProxy.cpp:
1107         (WebKit::WebPageProxy::paymentCoordinatorConnection): Moved to WebPageProxyCocoa.mm.
1108         (WebKit::WebPageProxy::paymentCoordinatorMessageReceiver): Ditto.
1109         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
1110         (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
1111         (WebKit::WebPageProxy::paymentCoordinatorDestinationID): Ditto.
1112         * UIProcess/WebPageProxy.h:
1113
1114         * UIProcess/ios/WebPageProxyIOS.mm:
1115         (WebKit::WebPageProxy::paymentCoordinatorCTDataConnectionServiceType): Asserted that
1116         sessionID equals the website data store's sessionID.
1117
1118         * WebKit.xcodeproj/project.pbxproj:
1119
1120         * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
1121         (WebKit::WebPaymentCoordinator::networkProcessConnectionClosed): Added. Cancels the current
1122         session if Apple Pay Remote UI is enabled and the network process connection closes.
1123         (WebKit::WebPaymentCoordinator::availablePaymentNetworks): Changed to account for
1124         WebPaymentCoordinator being an IPC::MessageSender.
1125         (WebKit::WebPaymentCoordinator::canMakePayments): Ditto.
1126         (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard): Ditto.
1127         (WebKit::WebPaymentCoordinator::openPaymentSetup): Ditto.
1128         (WebKit::WebPaymentCoordinator::showPaymentUI): Ditto.
1129         (WebKit::WebPaymentCoordinator::completeMerchantValidation): Ditto.
1130         (WebKit::WebPaymentCoordinator::completeShippingMethodSelection): Ditto.
1131         (WebKit::WebPaymentCoordinator::completeShippingContactSelection): Ditto.
1132         (WebKit::WebPaymentCoordinator::completePaymentMethodSelection): Ditto.
1133         (WebKit::WebPaymentCoordinator::completePaymentSession): Ditto.
1134         (WebKit::WebPaymentCoordinator::abortPaymentSession): Ditto.
1135         (WebKit::WebPaymentCoordinator::cancelPaymentSession): Ditto.
1136         (WebKit::WebPaymentCoordinator::messageSenderConnection const): Added. Returns a connection
1137         to the network process if Apple Pay Remote UI is enabled. Otherwise, returned the web
1138         process's parent connection.
1139         (WebKit::WebPaymentCoordinator::messageSenderDestinationID const): Added. Returns the web
1140         page's ID.
1141         (WebKit::WebPaymentCoordinator::remoteUIEnabled const): Added. Calls Settings::applePayRemoteUIEnabled.
1142         * WebProcess/ApplePay/WebPaymentCoordinator.h: Inherited from IPC::MessageSender.
1143
1144         * WebProcess/Network/NetworkProcessConnection.cpp:
1145         (WebKit::NetworkProcessConnection::didReceiveMessage): Forwarded WebPaymentCoordinator
1146         messages to the payment coordinator of the web page matching the decoder's destination ID.
1147         (WebKit::NetworkProcessConnection::didReceiveSyncMessage): Ditto for sync messages.
1148
1149         * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
1150         (WebKit::WebPage::paymentCoordinator): Added a payment coordinator getter.
1151         * WebProcess/WebPage/WebPage.h: Ditto.
1152
1153         * WebProcess/WebProcess.cpp:
1154         (WebKit::WebProcess::networkProcessConnectionClosed): Called
1155         WebPaymentCoordinator::networkProcessConnectionClosed when the network process connection
1156         closes.
1157
1158 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
1159
1160         [iOS] Block access to backboardd service
1161         https://bugs.webkit.org/show_bug.cgi?id=195484
1162
1163         Reviewed by Brent Fulgham.
1164
1165         This patch is addressing blocking the backboardd service "com.apple.backboard.hid.services". Getting the
1166         backlight level in the WebContent process will initiate a connection with this service. To be able to
1167         block the service, the backlight level is queried in the UI process and sent to the WebContent process
1168         when the WebContent process is started, and when the backlight level is changed. On the WebContent side,
1169         the method getting the backlight level is swizzled to return the value sent from the UI process.
1170
1171         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
1172         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
1173         (WebKit::WebProcessPool::displayBrightness):
1174         (WebKit::WebProcessPool::backlightLevelDidChangeCallback):
1175         (WebKit::WebProcessPool::registerNotificationObservers):
1176         (WebKit::WebProcessPool::unregisterNotificationObservers):
1177         * UIProcess/WebProcessPool.cpp:
1178         (WebKit::WebProcessPool::initializeNewWebProcess):
1179         * UIProcess/WebProcessPool.h:
1180         * WebProcess/WebProcess.h:
1181         * WebProcess/WebProcess.messages.in:
1182         * WebProcess/cocoa/WebProcessCocoa.mm:
1183         (WebKit::currentBacklightLevel):
1184         (WebKit::WebProcess::backlightLevelDidChange):
1185
1186 2019-03-11  Brent Fulgham  <bfulgham@apple.com>
1187
1188         Remove obsolete runtime flag for StorageAccess API Prompt
1189         https://bugs.webkit.org/show_bug.cgi?id=195564
1190         <rdar://problem/37279014>
1191
1192         Reviewed by Chris Dumez.
1193
1194         This bug tracks the work of removing the obsolete flag that had been used to optionally
1195         prevent display of the StorageAccess API prompt. We have since shipped the final version
1196         of this feature with an always-on prompt, and should have removed this runtime flag.
1197
1198         No test changes because this has no change in behavior. Tests already assume the prompt
1199         behavior, and did not test turning the flag off.
1200
1201         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
1202         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
1203         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
1204         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
1205         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
1206         (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess):
1207         (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal):
1208         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
1209         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
1210         (WebKit::ResourceLoadStatisticsStore::debugModeEnabled const):
1211         (WebKit::ResourceLoadStatisticsStore::storageAccessPromptsEnabled const): Deleted.
1212         (WebKit::ResourceLoadStatisticsStore::setStorageAccessPromptsEnabled): Deleted.
1213         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1214         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted):
1215         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
1216         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
1217         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
1218         (WebKit::NetworkConnectionToWebProcess::requestStorageAccess):
1219         * NetworkProcess/NetworkConnectionToWebProcess.h:
1220         * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
1221         * NetworkProcess/NetworkProcess.cpp:
1222         (WebKit::NetworkProcess::requestStorageAccess):
1223         (WebKit::NetworkProcess::requestStorageAccessGranted):
1224         * NetworkProcess/NetworkProcess.h:
1225         * NetworkProcess/NetworkProcess.messages.in:
1226         * Shared/WebPreferences.yaml:
1227         * UIProcess/API/C/WKPreferences.cpp:
1228         (WKPreferencesSetStorageAccessPromptsEnabled): Deleted.
1229         (WKPreferencesGetStorageAccessPromptsEnabled): Deleted.
1230         * UIProcess/API/C/WKPreferencesRef.h:
1231         * UIProcess/API/Cocoa/WKPreferences.mm:
1232         (-[WKPreferences _storageAccessPromptsEnabled]): Deleted.
1233         (-[WKPreferences _setStorageAccessPromptsEnabled:]): Deleted.
1234         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
1235         * UIProcess/Network/NetworkProcessProxy.cpp:
1236         (WebKit::NetworkProcessProxy::requestStorageAccess):
1237         * UIProcess/Network/NetworkProcessProxy.h:
1238         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1239         (WebKit::WebsiteDataStore::requestStorageAccess):
1240         * UIProcess/WebsiteData/WebsiteDataStore.h:
1241         * WebProcess/WebPage/WebPage.cpp:
1242         (WebKit::WebPage::requestStorageAccess):
1243
1244 2019-03-11  Alex Christensen  <achristensen@webkit.org>
1245
1246         Add a WKContentRuleList variant that uses copied memory instead of mmap'd shared memory for class A containerized apps
1247         https://bugs.webkit.org/show_bug.cgi?id=195511
1248         <rdar://problem/44873269>
1249
1250         Reviewed by Darin Adler.
1251
1252         * NetworkProcess/NetworkContentRuleListManager.cpp:
1253         (WebKit::NetworkContentRuleListManager::addContentRuleLists):
1254         * NetworkProcess/NetworkContentRuleListManager.h:
1255         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
1256         (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting):
1257         (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting):
1258         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
1259         * NetworkProcess/cache/NetworkCacheFileSystem.h:
1260         * Shared/WebCompiledContentRuleList.cpp:
1261         (WebKit::WebCompiledContentRuleList::usesCopiedMemory const):
1262         (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):
1263         (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const):
1264         (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const):
1265         (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const):
1266         (WebKit::WebCompiledContentRuleList::actions const):
1267         * Shared/WebCompiledContentRuleList.h:
1268         * Shared/WebCompiledContentRuleListData.cpp:
1269         (WebKit::WebCompiledContentRuleListData::size const):
1270         (WebKit::WebCompiledContentRuleListData::dataPointer const):
1271         (WebKit::WebCompiledContentRuleListData::encode const):
1272         (WebKit::WebCompiledContentRuleListData::decode):
1273         * Shared/WebCompiledContentRuleListData.h:
1274         (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
1275         * UIProcess/API/APIContentRuleList.cpp:
1276         (API::ContentRuleList::usesCopiedMemory const):
1277         * UIProcess/API/APIContentRuleList.h:
1278         * UIProcess/API/APIContentRuleListStore.cpp:
1279         (API::getData):
1280         (API::decodeContentRuleListMetaData):
1281         (API::ContentRuleListStore::readContentsOfFile):
1282         (API::MappedOrCopiedData::dataPointer const):
1283         (API::openAndMapOrCopyContentRuleList):
1284         (API::compiledToFile):
1285         (API::createExtension):
1286         (API::ContentRuleListStore::lookupContentRuleList):
1287         (API::ContentRuleListStore::compileContentRuleList):
1288         (API::ContentRuleListStore::getContentRuleListSource):
1289         (API::openAndMapContentRuleList): Deleted.
1290         * UIProcess/API/APIContentRuleListStore.h:
1291         * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm:
1292         (API::ContentRuleListStore::readContentsOfFile):
1293         * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
1294         (+[WKContentRuleListStore _registerPathAsUnsafeToMemoryMapForTesting:]):
1295         * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h:
1296         * UIProcess/API/Cocoa/_WKUserContentFilter.mm:
1297         (-[_WKUserContentFilter usesCopiedMemory]):
1298         * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h:
1299         * WebProcess/UserContent/WebUserContentController.cpp:
1300         (WebKit::WebUserContentController::addContentRuleLists):
1301         * WebProcess/UserContent/WebUserContentController.h:
1302         * WebProcess/WebPage/WebPage.cpp:
1303         (WebKit::m_hostFileDescriptor):
1304
1305 2019-03-11  Chris Dumez  <cdumez@apple.com>
1306
1307         Unreviewed, fix assertions in layout tests on iOS Simulator after r242666.
1308
1309         Log an error but do not crash if we fail to acquire a ProcessAssertion.
1310
1311         * UIProcess/ios/ProcessAssertionIOS.mm:
1312         (WebKit::ProcessAssertion::ProcessAssertion):
1313
1314 2019-03-11  Chris Dumez  <cdumez@apple.com>
1315
1316         WebProcessCache should keep track of processes being added
1317         https://bugs.webkit.org/show_bug.cgi?id=195538
1318
1319         Reviewed by Geoffrey Garen.
1320
1321         WebProcessCache should keep track of processes being added, while they are being
1322         checked for responsiveness. This is useful so that:
1323         - Requests to clear the cache also clear processes being added
1324         - Requests to remove a given process from the cache (either because it crashed
1325           or because it is being used for a history navigation) actually remove the
1326           process if it is still being checked for responsiveness.
1327         - The cached process eviction timer applies to such processes in case something
1328           goes wrong with the code and the pending request does not get processed.
1329
1330         * UIProcess/WebProcessCache.cpp:
1331         (WebKit::generateAddRequestIdentifier):
1332         (WebKit::WebProcessCache::addProcessIfPossible):
1333         (WebKit::WebProcessCache::addProcess):
1334         (WebKit::WebProcessCache::clear):
1335         (WebKit::WebProcessCache::clearAllProcessesForSession):
1336         (WebKit::WebProcessCache::removeProcess):
1337         (WebKit::WebProcessCache::CachedProcess::evictionTimerFired):
1338         (WebKit::WebProcessCache::evictProcess): Deleted.
1339         * UIProcess/WebProcessCache.h:
1340         (WebKit::WebProcessCache::size const):
1341         * UIProcess/WebProcessPool.cpp:
1342         (WebKit::WebProcessPool::processForNavigationInternal):
1343         * UIProcess/WebProcessProxy.cpp:
1344         (WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
1345
1346 2019-03-11  Alex Christensen  <achristensen@webkit.org>
1347
1348         REGRESSION: ( r240978-r240985 ) [ iOS Release ] Layout Test imported/w3c/web-platform-tests/xhr/send-redirect-post-upload.htm is crashing
1349         https://bugs.webkit.org/show_bug.cgi?id=194523
1350
1351         Reviewed by Alexey Proskuryakov.
1352
1353         Attempt another workaround to prevent crashes.
1354
1355         * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
1356         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
1357         (WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
1358         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
1359         (-[WKNetworkSessionDelegate URLSession:task:needNewBodyStream:]):
1360
1361 2019-03-11  Ryan Haddad  <ryanhaddad@apple.com>
1362
1363         Unreviewed, rolling out r242688, r242643, r242624.
1364
1365         Caused multiple layout test failures and crashes on iOS and macOS.
1366
1367         Reverted changeset:
1368
1369         "requestAnimationFrame should execute before the next frame"
1370         https://bugs.webkit.org/show_bug.cgi?id=177484
1371         https://trac.webkit.org/changeset/242624/webkit
1372
1373         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
1374         (WebKit::DrawingAreaCoordinatedGraphics::scheduleCompositingLayerFlush):
1375         (WebKit::DrawingAreaCoordinatedGraphics::updateBackingStoreState):
1376         (WebKit::DrawingAreaCoordinatedGraphics::display):
1377         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
1378         (WebKit::LayerTreeHost::layerFlushTimerFired):
1379         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
1380         (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
1381         * WebProcess/WebPage/WebPage.cpp:
1382         (WebKit::WebPage::layoutIfNeeded):
1383         (WebKit::WebPage::willDisplayPage):
1384         (WebKit::WebPage::renderingUpdate): Deleted.
1385         * WebProcess/WebPage/WebPage.h:
1386         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
1387         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
1388
1389 2019-03-11  Darin Adler  <darin@apple.com>
1390
1391         Specify fixed precision explicitly to prepare to change String::number and StringBuilder::appendNumber floating point behavior
1392         https://bugs.webkit.org/show_bug.cgi?id=195533
1393
1394         Reviewed by Brent Fulgham.
1395
1396         * NetworkProcess/cache/NetworkCache.cpp:
1397         (WebKit::NetworkCache::Cache::dumpContentsToFile): Use appendFixedPrecisionNumber.
1398         * NetworkProcess/cache/NetworkCacheEntry.cpp:
1399         (WebKit::NetworkCache::Entry::asJSON const): Ditto.
1400         * Shared/Gamepad/GamepadData.cpp:
1401         (WebKit::GamepadData::loggingString const): Ditto.
1402         * UIProcess/WebPageProxy.cpp:
1403         (WebKit::WebPageProxy::logDiagnosticMessageWithValue): Use numberToStringFixedPrecision.
1404
1405 2019-03-11  John Wilander  <wilander@apple.com>
1406
1407         Resource Load Statistics: Make it possible exclude localhost from classification
1408         https://bugs.webkit.org/show_bug.cgi?id=195474
1409         <rdar://problem/47520577>
1410
1411         Reviewed by Brent Fulgham.
1412
1413         This patch allows for localhost to be excluded from classification and
1414         treatment as a prevalent resource.
1415
1416         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
1417         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
1418         (WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources):
1419             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1420         (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource):
1421             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1422         (WebKit::ResourceLoadStatisticsDatabaseStore::isPrevalentResource const):
1423             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1424         (WebKit::ResourceLoadStatisticsDatabaseStore::isVeryPrevalentResource const):
1425             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1426         (WebKit::ResourceLoadStatisticsDatabaseStore::setVeryPrevalentResource):
1427             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1428         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
1429         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
1430         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
1431         (WebKit::ResourceLoadStatisticsMemoryStore::classifyPrevalentResources):
1432             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1433         (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResource):
1434             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1435         (WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentResource const):
1436             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1437         (WebKit::ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource const):
1438             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1439         (WebKit::ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource):
1440             Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip().
1441         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
1442         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
1443         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
1444             Now takes a ShouldIncludeLocalhost parameter.
1445         (WebKit::ResourceLoadStatisticsStore::shouldSkip const):
1446             Convenience function, currently supporting the localhost exclusion.
1447         (WebKit::ResourceLoadStatisticsStore::setIsRunningTest):
1448             Test infrastructure.
1449         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
1450         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
1451         (WebKit::WebResourceLoadStatisticsStore::setIsRunningTest):
1452             Test infrastructure.
1453         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
1454             Now takes a ShouldIncludeLocalhost parameter.
1455         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
1456             Defines the new ShouldIncludeLocalhost boolean enum.
1457         * NetworkProcess/NetworkProcess.cpp:
1458         (WebKit::NetworkProcess::setIsRunningResourceLoadStatisticsTest):
1459             Test infrastructure.
1460         * NetworkProcess/NetworkProcess.h:
1461         * NetworkProcess/NetworkProcess.messages.in:
1462         * NetworkProcess/NetworkSession.cpp:
1463         (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
1464             Forwards the localhost setting to the create function.
1465         * NetworkProcess/NetworkSession.h:
1466         * NetworkProcess/NetworkSessionCreationParameters.cpp:
1467         (WebKit::NetworkSessionCreationParameters::encode const):
1468         (WebKit::NetworkSessionCreationParameters::decode):
1469         * NetworkProcess/NetworkSessionCreationParameters.h:
1470             New parameter called shouldIncludeLocalhostInResourceLoadStatistics.
1471         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
1472         (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
1473             Picks up the localhost setting from the parameters.
1474         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
1475         (WKWebsiteDataStoreSetStatisticsIsRunningTest):
1476             Test infrastructure.
1477         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
1478         * UIProcess/Network/NetworkProcessProxy.cpp:
1479         (WebKit::NetworkProcessProxy::setIsRunningResourceLoadStatisticsTest):
1480             Test infrastructure.
1481         * UIProcess/Network/NetworkProcessProxy.h:
1482         * UIProcess/WebProcessPool.cpp:
1483         (WebKit::WebProcessPool::ensureNetworkProcess):
1484             Picks up the localhost setting from the WebsiteDataStore parameters.
1485         * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
1486         (WebKit::WebsiteDataStore::parameters):
1487             Makes sure Safari does not exclude localhost.
1488         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
1489         (WebKit::WebsiteDataStore::setIsRunningResourceLoadStatisticsTest):
1490             Test infrastructure.
1491         * UIProcess/WebsiteData/WebsiteDataStore.h:
1492
1493 2019-03-11  Alex Christensen  <achristensen@webkit.org>
1494
1495         Unreviewed, rolling out r242698.
1496
1497         API test crashes on bots.
1498
1499         Reverted changeset:
1500
1501         "Add a WKContentRuleList variant that uses copied memory
1502         instead of mmap'd shared memory for class A containerized
1503         apps"
1504         https://bugs.webkit.org/show_bug.cgi?id=195511
1505         https://trac.webkit.org/changeset/242698
1506
1507 2019-03-11  Michael Catanzaro  <mcatanzaro@igalia.com>
1508
1509         [WPE] Enable web process sandbox
1510         https://bugs.webkit.org/show_bug.cgi?id=195169
1511
1512         Reviewed by Daniel Bates.
1513
1514         * PlatformWPE.cmake:
1515         * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
1516         (WebKit::bubblewrapSpawn):
1517
1518 2019-03-11  Truitt Savell  <tsavell@apple.com>
1519
1520         Unreviewed, rolling out r242697.
1521
1522         Broke internal builders.
1523
1524         Reverted changeset:
1525
1526         "Optimizing loads when creating new pages"
1527         https://bugs.webkit.org/show_bug.cgi?id=195516
1528         https://trac.webkit.org/changeset/242697
1529
1530 2019-03-10  Alex Christensen  <achristensen@webkit.org>
1531
1532         Add a WKContentRuleList variant that uses copied memory instead of mmap'd shared memory for class A containerized apps
1533         https://bugs.webkit.org/show_bug.cgi?id=195511
1534         <rdar://problem/44873269>
1535
1536         Reviewed by Darin Adler.
1537
1538         * NetworkProcess/NetworkContentRuleListManager.cpp:
1539         (WebKit::NetworkContentRuleListManager::addContentRuleLists):
1540         * NetworkProcess/NetworkContentRuleListManager.h:
1541         * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
1542         (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting):
1543         (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting):
1544         (WebKit::NetworkCache::isSafeToUseMemoryMapForPath):
1545         * NetworkProcess/cache/NetworkCacheFileSystem.h:
1546         * Shared/WebCompiledContentRuleList.cpp:
1547         (WebKit::WebCompiledContentRuleList::usesCopiedMemory const):
1548         (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):
1549         (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const):
1550         (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const):
1551         (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const):
1552         (WebKit::WebCompiledContentRuleList::actions const):
1553         * Shared/WebCompiledContentRuleList.h:
1554         * Shared/WebCompiledContentRuleListData.cpp:
1555         (WebKit::WebCompiledContentRuleListData::size const):
1556         (WebKit::WebCompiledContentRuleListData::dataPointer const):
1557         (WebKit::WebCompiledContentRuleListData::encode const):
1558         (WebKit::WebCompiledContentRuleListData::decode):
1559         * Shared/WebCompiledContentRuleListData.h:
1560         (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
1561         * UIProcess/API/APIContentRuleList.cpp:
1562         (API::ContentRuleList::usesCopiedMemory const):
1563         * UIProcess/API/APIContentRuleList.h:
1564         * UIProcess/API/APIContentRuleListStore.cpp:
1565         (API::getData):
1566         (API::decodeContentRuleListMetaData):
1567         (API::ContentRuleListStore::readContentsOfFile):
1568         (API::MappedOrCopiedData::dataPointer const):
1569         (API::openAndMapOrCopyContentRuleList):
1570         (API::compiledToFile):
1571         (API::createExtension):
1572         (API::ContentRuleListStore::lookupContentRuleList):
1573         (API::ContentRuleListStore::compileContentRuleList):
1574         (API::ContentRuleListStore::getContentRuleListSource):
1575         (API::openAndMapContentRuleList): Deleted.
1576         * UIProcess/API/APIContentRuleListStore.h:
1577         * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm:
1578         (API::ContentRuleListStore::readContentsOfFile):
1579         * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
1580         (+[WKContentRuleListStore _registerPathAsUnsafeToMemoryMapForTesting:]):
1581         * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h:
1582         * UIProcess/API/Cocoa/_WKUserContentFilter.mm:
1583         (-[_WKUserContentFilter usesCopiedMemory]):
1584         * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h:
1585         * WebProcess/UserContent/WebUserContentController.cpp:
1586         (WebKit::WebUserContentController::addContentRuleLists):
1587         * WebProcess/UserContent/WebUserContentController.h:
1588         * WebProcess/WebPage/WebPage.cpp:
1589         (WebKit::m_hostFileDescriptor):
1590
1591 2019-03-10  Jiewen Tan  <jiewen_tan@apple.com>
1592
1593         Optimizing loads when creating new pages
1594         https://bugs.webkit.org/show_bug.cgi?id=195516
1595         <rdar://problem/48738086>
1596
1597         Reviewed by Darin Adler.
1598
1599         This patch adds hooks in WebPageProxy::createNewPage to optimize loads, and moves the creationParameters
1600         of API::NavigationAction from UI clients to WebPageProxy::createNewPage. Also, we now pass the whole
1601         API::NavigationAction to the load optimizer instead of the request within.
1602
1603         * UIProcess/API/APINavigationAction.h:
1604         * UIProcess/API/APIUIClient.h:
1605         (API::UIClient::createNewPage):
1606         * UIProcess/API/C/WKPage.cpp:
1607         (WKPageSetPageUIClient):
1608         * UIProcess/API/glib/WebKitUIClient.cpp:
1609         * UIProcess/Cocoa/NavigationState.mm:
1610         (WebKit::tryOptimizingLoad):
1611         (WebKit::tryInterceptNavigation):
1612         (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
1613         * UIProcess/Cocoa/UIDelegate.h:
1614         * UIProcess/Cocoa/UIDelegate.mm:
1615         (WebKit::UIDelegate::UIClient::createNewPage):
1616         * UIProcess/WebPageProxy.cpp:
1617         (WebKit::WebPageProxy::decidePolicyForNavigationAction):
1618         (WebKit::tryOptimizingLoad):
1619         (WebKit::WebPageProxy::createNewPage):
1620         * UIProcess/WebPageProxy.h:
1621
1622 2019-03-10  Tim Horton  <timothy_horton@apple.com>
1623
1624         Add SPI to retrieve the set of text inputs in a given rect, and later focus one
1625         https://bugs.webkit.org/show_bug.cgi?id=195499
1626
1627         Reviewed by Darin Adler.
1628
1629         * Scripts/webkit/messages.py:
1630         * Shared/TextInputContext.cpp: Added.
1631         (IPC::ArgumentCoder<WebKit::TextInputContext>::encode):
1632         (IPC::ArgumentCoder<WebKit::TextInputContext>::decode):
1633         * Shared/TextInputContext.h: Added.
1634         (WebKit::TextInputContext::operator== const):
1635         Add TextInputContext, which represents a minimal set of information
1636         about a text field.
1637
1638         * Sources.txt:
1639         * SourcesCocoa.txt:
1640         * UIProcess/API/Cocoa/WKWebView.mm:
1641         (-[WKWebView _requestTextInputContextsInRect:completionHandler:]):
1642         (-[WKWebView _focusTextInputContext:completionHandler:]):
1643         * UIProcess/API/Cocoa/WKWebViewPrivate.h:
1644         Add SPI that allows clients to asynchronously request text input
1645         contexts for a given rect, and later focus a given context.
1646
1647         * UIProcess/API/Cocoa/_WKTextInputContext.h: Added.
1648         * UIProcess/API/Cocoa/_WKTextInputContext.mm: Added.
1649         (-[_WKTextInputContext _initWithTextInputContext:]):
1650         (-[_WKTextInputContext boundingRect]):
1651         (-[_WKTextInputContext _textInputContext]):
1652         (-[_WKTextInputContext isEqual:]):
1653         (-[_WKTextInputContext hash]):
1654         (-[_WKTextInputContext copyWithZone:]):
1655         * UIProcess/API/Cocoa/_WKTextInputContextInternal.h: Added.
1656         Add an SPI object that exposes a read-only window on a TextInputContext to clients.
1657
1658         * UIProcess/WebPageProxy.cpp:
1659         (WebKit::WebPageProxy::textInputContextsInRect):
1660         (WebKit::WebPageProxy::focusTextInputContext):
1661         * UIProcess/WebPageProxy.h:
1662         Plumbing from WKWebView<->WebPage.
1663
1664         * WebKit.xcodeproj/project.pbxproj:
1665         * WebProcess/WebPage/WebPage.cpp:
1666         (WebKit::elementRectInWindowCoordinates):
1667         (WebKit::isEditableTextInputElement):
1668         (WebKit::WebPage::textInputContextsInRect):
1669         Search the DOM for text input contexts: <input type='text'> (or other
1670         form fields that fall back on text field behavior), <textarea>, and
1671         contenteditable roots. Store the WebPage, Document, and Element identifiers
1672         so that we can find the element again later.
1673
1674         (WebKit::WebPage::focusTextInputContext):
1675         Find the element for a given (web page, document, element) triple and focus it,
1676         if it's still available.
1677
1678         * WebProcess/WebPage/WebPage.h:
1679         * WebProcess/WebPage/WebPage.messages.in:
1680
1681 2019-03-10  Tim Horton  <timothy_horton@apple.com>
1682
1683         iOS: Using ⌥ to scroll horizontally is no different than arrow key
1684         https://bugs.webkit.org/show_bug.cgi?id=195268
1685         <rdar://problem/48326682>
1686
1687         Reviewed by Brent Fulgham.
1688
1689         * UIProcess/ios/WKContentViewInteraction.mm:
1690         (-[WKContentView keyboardScrollViewAnimator:distanceForIncrement:inDirection:]):
1691         (-[WKContentView keyboardScrollViewAnimator:distanceForIncrement:]): Deleted.
1692         * UIProcess/ios/WKKeyboardScrollingAnimator.h:
1693         * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
1694         (-[WKKeyboardScrollingAnimator keyboardScrollForEvent:]):
1695         (-[WKKeyboardScrollViewAnimator setDelegate:]):
1696         (-[WKKeyboardScrollViewAnimator distanceForIncrement:inDirection:]):
1697         (-[WKKeyboardScrollViewAnimator distanceForIncrement:]): Deleted.
1698         Add a direction parameter to -distanceForIncrement:, so the client
1699         can return a different page/document size based on the scrolling axis.
1700         Adopt it both in the default implementation and in WKContentViewInteraction.
1701         Make the option key scroll by page when scrolling horizontally, like it
1702         does when scrolling vertically.
1703
1704 2019-03-10  David Quesada  <david_quesada@apple.com>
1705
1706         ASSERT(m_downloads.isEmpty()) fails in DownloadProxyMap::~DownloadProxyMap()
1707         https://bugs.webkit.org/show_bug.cgi?id=152480
1708
1709         Reviewed by Chris Dumez.
1710
1711         * UIProcess/Downloads/DownloadProxyMap.cpp:
1712         (WebKit::DownloadProxyMap::downloadFinished):
1713             If the DownloadProxy is holding the last reference to the process pool, then
1714             invalidating the proxy will cause the process pool, the network process proxy,
1715             and this DownloadProxyMap to deallocate. Ensure that doesn't happen until this
1716             method has done everything it wants to do to clean up.
1717
1718 2019-03-10  Wenson Hsieh  <wenson_hsieh@apple.com>
1719
1720         Fix some misleading function and variable names in WKContentViewInteraction.mm
1721         https://bugs.webkit.org/show_bug.cgi?id=195536
1722
1723         Reviewed by Tim Horton.
1724
1725         * UIProcess/ios/WKContentViewInteraction.mm:
1726         (shouldDeferZoomingToSelectionWhenRevealingFocusedElement):
1727
1728         Rename shouldZoomToRevealSelectionRect to shouldDeferZoomingToSelectionWhenRevealingFocusedElement; this
1729         function is used to determine whether we should zoom to the selection rect when revealing the focused element,
1730         and therefore affects whether we need to defer zooming until we get selection information.
1731
1732         (rectToRevealWhenZoomingToFocusedElement):
1733         (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
1734
1735         Rename shouldShowKeyboard to shouldShowInputView; this boolean indicates whether we should show not only the
1736         keyboard, but other UI for user input such as date and select pickers.
1737
1738         (-[WKContentView _didReceiveEditorStateUpdateAfterFocus]):
1739         (shouldZoomToRevealSelectionRect): Deleted.
1740
1741 2019-03-10  Simon Fraser  <simon.fraser@apple.com>
1742
1743         ScrollingTree should have the final say on where layers go
1744         https://bugs.webkit.org/show_bug.cgi?id=195507
1745
1746         Reviewed by Antti Koivisto.
1747
1748         * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
1749         (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
1750         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
1751         (WebKit::RemoteScrollingCoordinatorProxy::applyScrollingTreeLayerPositions):
1752         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
1753         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
1754         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
1755
1756 2019-03-09  Darin Adler  <darin@apple.com>
1757
1758         [Cocoa] Code signing fails because services are copied into XPCServices after the framework is signed
1759         https://bugs.webkit.org/show_bug.cgi?id=195523
1760
1761         Reviewed by Dan Bernstein.
1762
1763         * WebKit.xcodeproj/project.pbxproj: Make symbolic links while building the WebKit
1764         framework instead of copying in the services after the framework is built.
1765
1766 2019-03-09  Wenson Hsieh  <wenson_hsieh@apple.com>
1767
1768         REGRESSION (r242551): Sporadic hangs when tapping to change selection on iOS
1769         https://bugs.webkit.org/show_bug.cgi?id=195475
1770         <rdar://problem/48721153>
1771
1772         Reviewed by Chris Dumez.
1773
1774         r242551 refactored synchronous autocorrection context requests to send an async IPC message and then use
1775         waitForAndDispatchImmediately, instead of calling sendSync. However, this exposes a couple of existing issues in
1776         the implementation of waitForAndDispatchImmediately that causes sporadic IPC deadlocks when changing selection.
1777
1778         First, passing in InterruptWaitingIfSyncMessageArrives when synchronously waiting for an IPC message currently
1779         does not fulfill its intended behavior of interrupting waiting when a sync message arrives. This is because sync
1780         IPC messages, by default, may be dispatched while the receiver is waiting for a sync reply. This means that the
1781         logic in Connection::SyncMessageState::processIncomingMessage to dispatch an incoming sync message on the main
1782         thread will attempt to handle the incoming message by enqueueing it on the main thread, and then waking up the
1783         client runloop (i.e. signaling m_waitForSyncReplySemaphore). This works in the case of sendSync since the sync
1784         reply semaphore is used to block the main thread, but in the case of waitForAndDispatchImmediately, a different
1785         m_waitForMessageCondition is used instead, so SyncMessageState::processIncomingMessage will only enqueue the
1786         incoming sync message on the main thread, and not actually invoke it.
1787
1788         To fix this first issue, observe that there is pre-existing logic to enqueue the incoming message and signal
1789         m_waitForMessageCondition in Connection::processIncomingMessage. This codepath is currently not taken because we
1790         end up bailing early in the call to SyncMessageState::processIncomingMessage. Instead, we can move this early
1791         return further down in the function, such that if there is an incoming sync message and we're waiting with the
1792         InterruptWaitingIfSyncMessageArrives option, we will correctly enqueue the incoming message, wake the runloop,
1793         and proceed to handle the incoming message.
1794
1795         The second issue is more subtle; consider the scenario in which we send a sync message A from the web process to
1796         the UI process, and simultaneously, in the UI process, we schedule some work to be done on the main thread.
1797         Let's additionally suppose that this scheduled work will send an IPC message B to the web process and
1798         synchronously wait for a reply (in the case of this particular bug, this is the sync autocorrection context
1799         request). What happens upon receiving sync message A is that the IPC thread in the UI process will schedule A on
1800         the main thread; however, before the scheduled response to A is invoked, we will first invoke previously
1801         scheduled work that attempts to block synchronously until a message B is received. In summary:
1802
1803         1. (Web process)    sends sync IPC message A to UI process.
1804         2. (UI process)     schedules some main runloop task that will block synchronously on IPC message B.
1805         3. (UI process)     receives sync IPC message A and schedules A on the main runloop.
1806         4. (UI process)     carry out the task scheduled in (2) and block on B.
1807
1808         ...and then, the UI process and web process are now deadlocked because the UI process is waiting for B to
1809         arrive, but the web process can't send B because it's waiting for a reply for IPC message A! To fix this second
1810         deadlock, we first make an important observation: when using sendSync, we don't run into this problem because
1811         immediately before sending sync IPC, we will attempt to handle any incoming sync IPC messages that have been
1812         queued up. However, when calling waitForAndDispatchImmediately, we don't have this extra step, so a deadlock may
1813         occur in the manner described above. To fix this, we make waitForAndDispatchImmediately behave more like
1814         sendSync, by handling all incoming sync messages prior to blocking on an IPC response.
1815
1816         Test: editing/selection/ios/change-selection-by-tapping.html
1817
1818         * Platform/IPC/Connection.cpp:
1819         (IPC::Connection::waitForMessage):
1820         (IPC::Connection::processIncomingMessage):
1821
1822 2019-03-09  Andy Estes  <aestes@apple.com>
1823
1824         [Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages
1825         https://bugs.webkit.org/show_bug.cgi?id=195526
1826         <rdar://problem/48745636>
1827
1828         Reviewed by Chris Dumez.
1829
1830         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
1831         (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard):
1832         (WebKit::WebPaymentCoordinatorProxy::openPaymentSetup):
1833         * Shared/ApplePay/WebPaymentCoordinatorProxy.h:
1834         * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in:
1835         * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
1836         (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard):
1837         (WebKit::WebPaymentCoordinator::openPaymentSetup):
1838         (WebKit::generateCanMakePaymentsWithActiveCardReplyID): Deleted.
1839         (WebKit::generateOpenPaymentSetupReplyID): Deleted.
1840         (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCardReply): Deleted.
1841         (WebKit::WebPaymentCoordinator::openPaymentSetupReply): Deleted.
1842         * WebProcess/ApplePay/WebPaymentCoordinator.h:
1843         * WebProcess/ApplePay/WebPaymentCoordinator.messages.in:
1844
1845 2019-03-09  Andy Estes  <aestes@apple.com>
1846
1847         [iOS] Remove unneeded entitlements and sandbox allowances from the Networking service
1848         https://bugs.webkit.org/show_bug.cgi?id=195527
1849
1850         Reviewed by Eric Carlson.
1851
1852         * Configurations/Network-iOS.entitlements:
1853         * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb:
1854
1855 2019-03-09  Chris Dumez  <cdumez@apple.com>
1856
1857         Use modern async IPC with reply for device orientation permission
1858         https://bugs.webkit.org/show_bug.cgi?id=195529
1859
1860         Reviewed by Ryosuke Niwa.
1861
1862         * UIProcess/WebPageProxy.cpp:
1863         (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
1864         * UIProcess/WebPageProxy.h:
1865         * UIProcess/WebPageProxy.messages.in:
1866         * WebProcess/WebPage/WebPage.cpp:
1867         (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
1868         (WebKit::nextDeviceOrientationAndMotionPermissionCallbackID): Deleted.
1869         (WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision): Deleted.
1870         * WebProcess/WebPage/WebPage.h:
1871         * WebProcess/WebPage/WebPage.messages.in:
1872
1873 2019-03-09  Zalan Bujtas  <zalan@apple.com>
1874
1875         [ContentChangeObserver] Start observing for content change between touchEnd and mouseMoved start
1876         https://bugs.webkit.org/show_bug.cgi?id=195510
1877         <rdar://problem/48735695>
1878
1879         Reviewed by Simon Fraser.
1880
1881         * WebProcess/WebPage/ios/WebPageIOS.mm:
1882         (WebKit::WebPage::cancelPotentialTapInFrame):
1883
1884 2019-03-08  Chris Dumez  <cdumez@apple.com>
1885
1886         Enable ProcessAssertions on iOS Simulator
1887         https://bugs.webkit.org/show_bug.cgi?id=195479
1888
1889         Reviewed by Alexey Proskuryakov.
1890
1891         Enable ProcessAssertions on iOS Simulator. We have some layout tests timing out in the
1892         iOS Simulator due to the WebContent process suspending. Turning on ProcessAssertions in
1893         the iOS Simulator seems to make those tests pass.
1894
1895         * UIProcess/ProcessAssertion.cpp:
1896         * UIProcess/ProcessAssertion.h:
1897         * UIProcess/ios/ProcessAssertionIOS.mm:
1898
1899 2019-03-08  Chris Dumez  <cdumez@apple.com>
1900
1901         Add support for Device Orientation / Motion permission API
1902         https://bugs.webkit.org/show_bug.cgi?id=195329
1903         <rdar://problem/47645367>
1904
1905         Reviewed by Geoffrey Garen.
1906
1907         Add support for Device Orientation / Motion permission API:
1908         - https://github.com/w3c/deviceorientation/issues/57
1909
1910         This adds new SPI to WKUIDelegatePrivate, until we can make this API.
1911
1912         * Shared/WebPreferences.yaml:
1913         * UIProcess/API/APIUIClient.h:
1914         (API::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
1915         * UIProcess/API/C/WKPage.cpp:
1916         (WKPageSetPageUIClient):
1917         * UIProcess/API/C/WKPageUIClient.h:
1918         * UIProcess/API/Cocoa/WKUIDelegate.h:
1919         * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
1920         * UIProcess/Cocoa/UIDelegate.h:
1921         * UIProcess/Cocoa/UIDelegate.mm:
1922         (WebKit::UIDelegate::setDelegate):
1923         (WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
1924         * UIProcess/WebPageProxy.cpp:
1925         (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
1926         * UIProcess/WebPageProxy.h:
1927         * UIProcess/WebPageProxy.messages.in:
1928         * WebProcess/WebCoreSupport/WebChromeClient.cpp:
1929         (WebKit::WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess):
1930         * WebProcess/WebCoreSupport/WebChromeClient.h:
1931         * WebProcess/WebPage/WebPage.cpp:
1932         (WebKit::nextDeviceOrientationAndMotionPermissionCallbackID):
1933         (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
1934         (WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision):
1935         * WebProcess/WebPage/WebPage.h:
1936         * WebProcess/WebPage/WebPage.messages.in:
1937
1938 2019-03-08  Brady Eidson  <beidson@apple.com>
1939
1940         Have the UIProcess take the UnboundedNetworking assertion when downloads are in progress.
1941         https://bugs.webkit.org/show_bug.cgi?id=195468
1942
1943         Reviewed by Andy Estes.
1944
1945         * UIProcess/Downloads/DownloadProxyMap.cpp:
1946         (WebKit::DownloadProxyMap::DownloadProxyMap):
1947         (WebKit::DownloadProxyMap::createDownloadProxy): If this is the first download, and the process has the entitlement,
1948           take the assertion.
1949         (WebKit::DownloadProxyMap::downloadFinished):
1950         (WebKit::DownloadProxyMap::processDidClose):
1951         * UIProcess/Downloads/DownloadProxyMap.h:
1952
1953 2019-03-08  Chris Dumez  <cdumez@apple.com>
1954
1955         Add assertions to help debug a WebProcessCache crash
1956         https://bugs.webkit.org/show_bug.cgi?id=195469
1957
1958         Reviewed by Brady Eidson.
1959
1960         I suspect the process's registrableDomain in null when evictProcess() gets
1961         called, thus crashing when lookup it up in the HashMap. Confirm this and
1962         how this could happen via assertions.
1963
1964         * UIProcess/WebProcessCache.cpp:
1965         (WebKit::WebProcessCache::evictProcess):
1966         * UIProcess/WebProcessProxy.cpp:
1967         (WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame):
1968
1969 2019-03-08  Brady Eidson  <beidson@apple.com>
1970
1971         Rename AssertionState::Download.
1972         https://bugs.webkit.org/show_bug.cgi?id=195465
1973
1974         Reviewed by Andy Estes.
1975
1976         It's (currently) about uploads and downloads.
1977         Let's call it "UnboundedNetworking"
1978
1979         * NetworkProcess/Downloads/DownloadMap.cpp:
1980         (WebKit::DownloadMap::add):
1981
1982         * UIProcess/ProcessAssertion.h:
1983
1984         * UIProcess/WebProcessProxy.cpp:
1985         (WebKit::WebProcessProxy::didSetAssertionState):
1986
1987         * UIProcess/ios/ProcessAssertionIOS.mm:
1988         (WebKit::flagsForState):
1989         (WebKit::reasonForState):
1990
1991 2019-03-08  Simon Fraser  <simon.fraser@apple.com>
1992
1993         [macOS UI-side compositing] Mouse handling can trigger a crash before we have a scrolling tree root
1994         https://bugs.webkit.org/show_bug.cgi?id=195467
1995
1996         Reviewed by Antti Koivisto.
1997         
1998         When launching MiniBrowser with UI-side compositing enabled in a state where the window
1999         appears under the mouse, we can hit RemoteScrollingTree::handleMouseEvent() for a mouseEnter
2000         event before we have a scrolling tree root node, so add a null check.
2001
2002         * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
2003         (WebKit::RemoteScrollingTree::handleMouseEvent):
2004
2005 2019-03-08  Carlos Garcia Campos  <cgarcia@igalia.com>
2006
2007         REGRESSION(r242624): [GTK] New rAF code path assumes AC mode
2008         https://bugs.webkit.org/show_bug.cgi?id=195459
2009
2010         Reviewed by Žan Doberšek.
2011
2012         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
2013         (WebKit::DrawingAreaCoordinatedGraphics::scheduleCompositingLayerFlush):
2014         The refresh monitor now calls scheduleLayerFlush() but when AC
2015         mode is disabled this method does nothing, so setNeedsDisplay()
2016         needs to be called instead.
2017
2018 2019-03-07  Tim Horton  <timothy_horton@apple.com>
2019
2020         Crash under RemoteLayerTreePropertyApplier::applyProperties
2021         https://bugs.webkit.org/show_bug.cgi?id=195448
2022         <rdar://problem/48588226>
2023
2024         Reviewed by Simon Fraser.
2025
2026         * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
2027         (WebKit::RemoteLayerTreeHost::updateLayerTree):
2028         Under some currently-unknown circumstances, the UI process is receiving
2029         commits referring to layers that it does not know about.
2030         One understood case of this was fixed in r241899, but there seem to be
2031         cases remaining that are not understood.
2032         Also, add a release log so that we can identify any downstream effects.
2033
2034 2019-03-07  Zalan Bujtas  <zalan@apple.com>
2035
2036         [ContentChangeObserver] Introduce fixed duration content observation
2037         https://bugs.webkit.org/show_bug.cgi?id=195295
2038         <rdar://problem/48579913>
2039
2040         Reviewed by Simon Fraser.
2041
2042         * WebProcess/WebPage/ios/WebPageIOS.mm:
2043         (WebKit::WebPage::handleSyntheticClick):
2044         (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
2045
2046 2019-03-07  Fujii Hironori  <Hironori.Fujii@sony.com>
2047
2048         [WinCairo][WebKit] Nothing is drawn after Web process crashed
2049         https://bugs.webkit.org/show_bug.cgi?id=195399
2050
2051         Reviewed by Alex Christensen.
2052
2053         PageClientImpl::viewSize returned 0x0 size after Web process
2054         crashed. Restored the original implementation using GetClientRect
2055         (Bug 52175).
2056
2057         * UIProcess/win/PageClientImpl.cpp:
2058         (WebKit::PageClientImpl::viewSize):
2059
2060 2019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
2061
2062         requestAnimationFrame should execute before the next frame
2063         https://bugs.webkit.org/show_bug.cgi?id=177484
2064
2065         Reviewed by Simon Fraser.
2066
2067         Replace the calls to Page::layoutIfNeeded() and willDisplayPage() by
2068         a single call to Page::renderingUpdate(). This new function implements 
2069         "Update the rendering" step of the HTML Event Loop specification
2070         <https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>.
2071
2072         * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
2073         (WebKit::AcceleratedDrawingArea::updateBackingStoreState):
2074         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
2075         (WebKit::LayerTreeHost::layerFlushTimerFired):
2076         * WebProcess/WebPage/DrawingAreaImpl.cpp:
2077         (WebKit::DrawingAreaImpl::display):
2078         * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
2079         (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
2080         * WebProcess/WebPage/WebPage.cpp:
2081         (WebKit::WebPage::layoutIfNeeded):
2082         (WebKit::WebPage::renderingUpdate):
2083         (WebKit::WebPage::willDisplayPage): Deleted.
2084         * WebProcess/WebPage/WebPage.h:
2085         * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
2086         (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
2087
2088 2019-03-07  Zalan Bujtas  <zalan@apple.com>
2089
2090         [ContentChangeObserver] Add a setting to be able to turn content change observation on/off
2091         https://bugs.webkit.org/show_bug.cgi?id=195353
2092         <rdar://problem/48626394>
2093
2094         Reviewed by Simon Fraser.
2095
2096         * Shared/WebPreferences.yaml:
2097         * UIProcess/API/C/WKPreferences.cpp:
2098         (WKPreferencesSetContentChangeObserverEnabled):
2099         (WKPreferencesGetContentChangeObserverEnabled):
2100         * UIProcess/API/C/WKPreferencesRefPrivate.h:
2101         * UIProcess/API/Cocoa/WKPreferences.mm:
2102         (-[WKPreferences _contentChangeObserverEnabled]):
2103         (-[WKPreferences _setContentChangeObserverEnabled:]):
2104         * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
2105         * WebProcess/WebPage/ios/WebPageIOS.mm:
2106         (WebKit::WebPage::handleSyntheticClick):
2107
2108 2019-03-07  Andy Estes  <aestes@apple.com>
2109
2110         [Apple Pay] Untangle PKPaymentAuthorizationViewController from WebPaymentCoordinatorProxy
2111         https://bugs.webkit.org/show_bug.cgi?id=195349
2112         <rdar://problem/48625510>
2113
2114         Reviewed by Alex Christensen.
2115
2116         Introduced PaymentAuthorizationPresenter and WKPaymentAuthorizationDelegate to encapsulate
2117         PKPaymentAuthorizationViewController and its delegate. Taught WebPaymentCoordinatorProxy to
2118         interact with PaymentAuthorizationPresenter rather than PKPAVC directly.
2119
2120         These changes will allow us to swap out PKPaymentAuthorizationViewController with PKPaymentAuthorizationController in a follow-on patch.
2121
2122         * Platform/cocoa/PaymentAuthorizationPresenter.h: Added. Defined the abstract interface for
2123         payment authorization presenters that use PKPA(V)C.
2124         * Platform/cocoa/PaymentAuthorizationPresenter.mm: Added.
2125         (WebKit::toPKPaymentAuthorizationStatus): Moved from WebPaymentCoordinatorProxyCocoa.mm.
2126         (WebKit::toPKPaymentErrorCode): Ditto.
2127         (WebKit::toNSError): Ditto.
2128         (WebKit::toNSErrors): Ditto.
2129         (WebKit::toPKShippingMethods): Ditto.
2130         (WebKit::PaymentAuthorizationPresenter::completeMerchantValidation): Added. Implements the
2131         logic previously in WebPaymentCoordinatorProxy::platformCompleteMerchantValidation.
2132         (WebKit::PaymentAuthorizationPresenter::completePaymentMethodSelection): Ditto for
2133         WebPaymentCoordinatorProxy::platformCompletePaymentMethodSelection.
2134         (WebKit::PaymentAuthorizationPresenter::completePaymentSession): Ditto for 
2135         (WebKit::PaymentAuthorizationPresenter::completeShippingContactSelection): Ditto for
2136         WebPaymentCoordinatorProxy::platformCompletePaymentSession.
2137         (WebKit::PaymentAuthorizationPresenter::completeShippingMethodSelection): Ditto for
2138         WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection.
2139         * Platform/cocoa/PaymentAuthorizationViewController.h: Added. Defined a subclass of PaymentAuthorizationPresenter for PKPaymentAuthorizationViewController.
2140         * Platform/cocoa/PaymentAuthorizationViewController.mm: Added.
2141         (-[WKPaymentAuthorizationViewControllerDelegate initWithPresenter:]): Added a PKPAVC
2142         delegate that's a subclass of WKPaymentAuthorizationDelegate.
2143         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewControllerDidFinish:]):
2144         Called -[WKPaymentAuthorizationDelegate _didFinish].
2145         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:handler:]): Called
2146         -[WKPaymentAuthorizationDelegate _didAuthorizePayment:completion:].
2147         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:handler:]): Called
2148         -[WKPaymentAuthorizationDelegate _didSelectShippingMethod:completion:].
2149         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:handler:]): Called
2150         -[WKPaymentAuthorizationDelegate _didSelectShippingContact:completion:].
2151         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:handler:]): Called
2152         -[WKPaymentAuthorizationDelegate _didSelectPaymentMethod:completion:].
2153         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:willFinishWithError:]):
2154         Called -[WKPaymentAuthorizationDelegate _willFinishWithError:].
2155         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didRequestMerchantSession:]): Called
2156         -[WKPaymentAuthorizationDelegate _didRequestMerchantSession:].
2157         * Platform/cocoa/WKPaymentAuthorizationDelegate.h: Added.
2158         * Platform/cocoa/WKPaymentAuthorizationDelegate.mm: Added.
2159         (-[WKPaymentAuthorizationDelegate summaryItems]): Added a summaryItems getter.
2160         (-[WKPaymentAuthorizationDelegate shippingMethods]): Ditto for shippingMethods.
2161         (-[WKPaymentAuthorizationDelegate completeMerchantValidation:error:]): Called
2162         _didRequestMerchantSessionCompletion then set it to nil.
2163         (-[WKPaymentAuthorizationDelegate completePaymentMethodSelection:]): Ditto for
2164         _didSelectPaymentMethodCompletion.
2165         (-[WKPaymentAuthorizationDelegate completePaymentSession:errors:didReachFinalState:]): Ditto
2166         for _didAuthorizePaymentCompletion.
2167         (-[WKPaymentAuthorizationDelegate completeShippingContactSelection:summaryItems:shippingMethods:errors:]):
2168         Ditto for _didSelectShippingContactCompletion.
2169         (-[WKPaymentAuthorizationDelegate completeShippingMethodSelection:]): Ditto for
2170         _didSelectShippingMethodCompletion.
2171         (-[WKPaymentAuthorizationDelegate invalidate]): If there's an outstanding authorization
2172         callback, called -completePaymentSession:errors:didReachFinalState: with a state of
2173         PKPaymentAuthorizationStatusFailure.
2174         (-[WKPaymentAuthorizationDelegate _initWithPresenter:]):
2175         (-[WKPaymentAuthorizationDelegate _didAuthorizePayment:completion:]): Added. Implements the
2176         logic previously in WKPaymentAuthorizationViewControllerDelegate.
2177         (-[WKPaymentAuthorizationDelegate _didFinish]): Ditto.
2178         (-[WKPaymentAuthorizationDelegate _didRequestMerchantSession:]): Ditto.
2179         (-[WKPaymentAuthorizationDelegate _didSelectPaymentMethod:completion:]): Ditto.
2180         (-[WKPaymentAuthorizationDelegate _didSelectShippingContact:completion:]): Ditto.
2181         (toShippingMethod): Moved from WebPaymentCoordinatorProxyCocoa.mm.
2182         (-[WKPaymentAuthorizationDelegate _didSelectShippingMethod:completion:]): Added. Implements
2183         the logic previously in WKPaymentAuthorizationViewControllerDelegate.
2184         (-[WKPaymentAuthorizationDelegate _willFinishWithError:]): Ditto.
2185         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
2186         (WebKit::WebPaymentCoordinatorProxy::presenterWillValidateMerchant): To conform to
2187         PaymentAuthorizationPresenter::Client, renamed from validateMerchant.
2188         (WebKit::WebPaymentCoordinatorProxy::presenterDidAuthorizePayment): Renamed from
2189         didAuthorizePayment.
2190         (WebKit::WebPaymentCoordinatorProxy::presenterDidFinish): Moved logic here that previously
2191         existed in WKPaymentAuthorizationViewControllerDelegate.
2192         (WebKit::WebPaymentCoordinatorProxy::presenterDidSelectShippingMethod): Renamed from
2193         didSelectShippingMethod.
2194         (WebKit::WebPaymentCoordinatorProxy::presenterDidSelectShippingContact): Renamed from
2195         didSelectShippingContact.
2196         (WebKit::WebPaymentCoordinatorProxy::presenterDidSelectPaymentMethod): Renamed from
2197         didSelectPaymentMethod.
2198         (WebKit::WebPaymentCoordinatorProxy::validateMerchant): Renamed to
2199         presenterWillValidateMerchant.
2200         (WebKit::WebPaymentCoordinatorProxy::didAuthorizePayment): Renamed to
2201         presenterDidAuthorizePayment.
2202         (WebKit::WebPaymentCoordinatorProxy::didSelectShippingMethod): Renamed to
2203         presenterDidSelectShippingMethod.
2204         (WebKit::WebPaymentCoordinatorProxy::didSelectShippingContact): Renamed to
2205         presenterDidSelectShippingContact.
2206         (WebKit::WebPaymentCoordinatorProxy::didSelectPaymentMethod): Renamed to
2207         didSelectPaymentMethod.
2208         * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Changed WebPaymentCoordinatorProxy to
2209         subclass PaymentAuthorizationPresenter::Client.
2210         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h: Removed WKPaymentAuthorizationViewControllerDelegate interface and declared some helper functions
2211         needed by PaymentAuthorizationPresenter.
2212         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
2213         (WebKit::toPKPaymentSummaryItemType): Removed static keyword.
2214         (WebKit::toDecimalNumber): Ditto.
2215         (WebKit::toPKPaymentSummaryItem): Ditto.
2216         (WebKit::toPKPaymentSummaryItems): Ditto.
2217         (WebKit::toPKShippingMethod): Ditto.
2218         (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Changed to call
2219         m_authorizationPresenter.
2220         (WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentSession): Ditto.
2221         (WebKit::WebPaymentCoordinatorProxy::platformCompleteMerchantValidation): Ditto.
2222         (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection): Ditto.
2223         (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingContactSelection): Ditto.
2224         (WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentMethodSelection): Ditto.
2225         (-[WKPaymentAuthorizationViewControllerDelegate initWithPaymentCoordinatorProxy:]): Deleted.
2226         (-[WKPaymentAuthorizationViewControllerDelegate invalidate]): Deleted.
2227         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:willFinishWithError:]): Deleted.
2228         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didRequestMerchantSession:]): Deleted.
2229         (toShippingMethod): Deleted.
2230         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:handler:]): Deleted.
2231         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:handler:]): Deleted.
2232         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:handler:]): Deleted.
2233         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:handler:]): Deleted.
2234         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:completion:]): Deleted.
2235         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:completion:]): Deleted.
2236         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:completion:]): Deleted.
2237         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:completion:]): Deleted.
2238         (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewControllerDidFinish:]): Deleted.
2239         (WebKit::toPKPaymentAuthorizationStatus): Moved to PaymentAuthorizationPresenter.mm.
2240         (WebKit::toPKPaymentErrorCode): Ditto.
2241         (WebKit::toNSError): Ditto.
2242         (WebKit::toNSErrors): Ditto.
2243         * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
2244         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Changed to present a
2245         PaymentAuthorizationPresenter rather than a PKPAVC.
2246         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Changed to dismiss a
2247         PaymentAuthorizationPresenter rather than a PKPAVC.
2248         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
2249         (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Ditto.
2250         (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Ditto.
2251         * SourcesCocoa.txt:
2252         * UIProcess/WebPageProxy.h:
2253         * UIProcess/ios/WebPageProxyIOS.mm:
2254         (WebKit::WebPageProxy::paymentCoordinatorAuthorizationPresenter): Added. Returns a new
2255         PaymentAuthorizationViewController.
2256         * WebKit.xcodeproj/project.pbxproj:
2257
2258 2019-03-07  Chris Dumez  <cdumez@apple.com>
2259
2260         Regression(r242580) WebKit.NetworkProcessCrashWithPendingConnection API is crashing on iOS debug
2261         https://bugs.webkit.org/show_bug.cgi?id=195416
2262
2263         Reviewed by Antti Koivisto.
2264
2265         Drop ASSERT_NOT_REACHED() in WebPage::didCompletePageTransition() when the tree is still frozen due to
2266         LayerTreeFreezeReason::ProcessSuspended. As demonstrated by this API test, nothing prevents a load from
2267         completing and WebPage::didCompletePageTransition() to get called *after* WebProcess::prepareToSuspend()
2268         has been called. From the logging during the test, I can tell that WebProcess::processDidResume() gets
2269         called later on and the LayerTreeFreezeReason::ProcessSuspended freezing reason gets dropped, as expected.
2270
2271         * WebProcess/WebPage/WebPage.cpp:
2272         (WebKit::WebPage::didCompletePageTransition):
2273
2274 2019-03-07  Chris Dumez  <cdumez@apple.com>
2275
2276         Clean up / simplify ProcessAssertion code
2277         https://bugs.webkit.org/show_bug.cgi?id=195394
2278
2279         Reviewed by Geoffrey Garen.
2280
2281         Clean up / simplify ProcessAssertion code to facilitate its maintenance and make it
2282         less error-prone.
2283
2284         * Platform/IPC/mac/ConnectionMac.mm:
2285         (IPC::ConnectionTerminationWatchdog::ConnectionTerminationWatchdog):
2286         * UIProcess/ProcessAssertion.cpp:
2287         (WebKit::ProcessAssertion::ProcessAssertion):
2288         (WebKit::ProcessAssertion::setState):
2289         * UIProcess/ProcessAssertion.h:
2290         (WebKit::ProcessAssertion::Client::~Client):
2291         (WebKit::ProcessAssertion::setClient):
2292         (WebKit::ProcessAssertion::client):
2293         * UIProcess/ProcessThrottler.cpp:
2294         (WebKit::ProcessThrottler::didConnectToProcess):
2295         * UIProcess/ProcessThrottler.h:
2296         * UIProcess/ios/ProcessAssertionIOS.mm:
2297         (-[WKProcessAssertionBackgroundTaskManager dealloc]):
2298         (-[WKProcessAssertionBackgroundTaskManager addAssertionNeedingBackgroundTask:]):
2299         (-[WKProcessAssertionBackgroundTaskManager removeAssertionNeedingBackgroundTask:]):
2300         (-[WKProcessAssertionBackgroundTaskManager _notifyAssertionsOfImminentSuspension]):
2301         (-[WKProcessAssertionBackgroundTaskManager _releaseBackgroundTask]):
2302         (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]):
2303         (WebKit::ProcessAssertion::ProcessAssertion):
2304         (WebKit::ProcessAssertion::processAssertionWasInvalidated):
2305         (WebKit::ProcessAssertion::setState):
2306         (WebKit::ProcessAndUIAssertion::updateRunInBackgroundCount):
2307         (WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion):
2308         (WebKit::ProcessAndUIAssertion::~ProcessAndUIAssertion):
2309         (WebKit::ProcessAndUIAssertion::processAssertionWasInvalidated):
2310         (WebKit::ProcessAndUIAssertion::setState):
2311         (WebKit::ProcessAndUIAssertion::uiAssertionWillExpireImminently):
2312
2313 2019-03-07  Commit Queue  <commit-queue@webkit.org>
2314
2315         Unreviewed, rolling out r242297.
2316         https://bugs.webkit.org/show_bug.cgi?id=195430
2317
2318         Broke Microsoft Visio. (Requested by dydz on #webkit).
2319
2320         Reverted changeset:
2321
2322         "[iOS] Turn mouse event simulation on by default"
2323         https://bugs.webkit.org/show_bug.cgi?id=195218
2324         https://trac.webkit.org/changeset/242297
2325
2326 2019-03-07  John Wilander  <wilander@apple.com>
2327
2328         Resource Load Statistics: Log first-party navigations with link decoration
2329         https://bugs.webkit.org/show_bug.cgi?id=195301
2330         <rdar://problem/48569971>
2331
2332         Reviewed by Brent Fulgham.
2333
2334         This patch adds a call to the network process' resource load statistics to
2335         log cross-site navigations with link decoration. The logging checks if the
2336         source of the navigation is a prevalent resource and if so, sets the
2337         appropriate flag for the destination.
2338
2339         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
2340         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
2341         (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
2342         (WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceRedirect):
2343         (WebKit::ResourceLoadStatisticsDatabaseStore::logCrossSiteLoadWithLinkDecoration):
2344         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
2345         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
2346         (WebKit::ResourceLoadStatisticsMemoryStore::logCrossSiteLoadWithLinkDecoration):
2347         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
2348         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
2349         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
2350         (WebKit::WebResourceLoadStatisticsStore::logCrossSiteLoadWithLinkDecoration):
2351         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
2352         * NetworkProcess/NetworkProcess.cpp:
2353         (WebKit::NetworkProcess::committedCrossSiteLoadWithLinkDecoration):
2354             This now receives a completion handler. This is in preparation for
2355             test cases where we need to log such an event and wait for it to
2356             finish before continuing.
2357         * NetworkProcess/NetworkProcess.h:
2358         * NetworkProcess/NetworkProcess.messages.in:
2359         * UIProcess/Network/NetworkProcessProxy.cpp:
2360         (WebKit::NetworkProcessProxy::committedCrossSiteLoadWithLinkDecoration):
2361         * UIProcess/Network/NetworkProcessProxy.h:
2362         * UIProcess/WebPageProxy.cpp:
2363         (WebKit::WebPageProxy::didCommitLoadForFrame):
2364         * UIProcess/WebProcessPool.cpp:
2365         (WebKit::WebProcessPool::committedCrossSiteLoadWithLinkDecoration):
2366         * UIProcess/WebProcessPool.h:
2367
2368 2019-03-07  Per Arne Vollan  <pvollan@apple.com>
2369
2370         [iOS] Disable permissive call logging in sandbox
2371         https://bugs.webkit.org/show_bug.cgi?id=195288
2372         <rdar://problem/47683804>
2373
2374         Reviewed by Brent Fulgham.
2375
2376         As on macOS, we should enable strict call filtering in sandbox on iOS.
2377
2378         * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
2379
2380 2019-03-07  Youenn Fablet  <youenn@apple.com>
2381
2382         Introduce a quota manager for Cache API/Service Worker/IDB storage
2383         https://bugs.webkit.org/show_bug.cgi?id=195283
2384
2385         Reviewed by Chris Dumez.
2386
2387         Remove quota handling from Cache API storage and use StorageQuotaManager/StorageQuotaUser.
2388         CacheStorage::Caches becomes a quota user and has a StorageQuotaManager to check for space for any cache API write task.
2389         NetworkProcess is responsible to manage the quota managers.
2390         Quota managers will go through network process to ask UIProcess for quota extension.
2391
2392         Remove pending callback handling from CacheStorage since they are queued in QuotaManager now.
2393
2394         * NetworkProcess/NetworkProcess.cpp:
2395         (WebKit::NetworkProcess::~NetworkProcess):
2396         (WebKit::NetworkProcess::destroySession):
2397         (WebKit::NetworkProcess::cacheStorageRootPath):
2398         (WebKit::NetworkProcess::setCacheStorageParameters):
2399         (WebKit::NetworkProcess::storageQuotaManager):
2400         * NetworkProcess/NetworkProcess.h:
2401         * NetworkProcess/cache/CacheStorageEngine.cpp:
2402         (WebKit::CacheStorage::Engine::from):
2403         (WebKit::CacheStorage::Engine::Engine):
2404         (WebKit::CacheStorage::Engine::readCachesFromDisk):
2405         * NetworkProcess/cache/CacheStorageEngine.h:
2406         * NetworkProcess/cache/CacheStorageEngineCache.cpp:
2407         (WebKit::CacheStorage::Cache::put):
2408         * NetworkProcess/cache/CacheStorageEngineCache.h:
2409         * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
2410         (WebKit::CacheStorage::Caches::Caches):
2411         (WebKit::CacheStorage::Caches::~Caches):
2412         (WebKit::CacheStorage::Caches::requestSpace):
2413         (WebKit::CacheStorage::Caches::writeRecord):
2414         * NetworkProcess/cache/CacheStorageEngineCaches.h:
2415
2416 2019-03-07  John Wilander  <wilander@apple.com>
2417
2418         Resource Load Statistics: Make it possible to purge only script-accessible cookies
2419         https://bugs.webkit.org/show_bug.cgi?id=195383
2420         <rdar://problem/48570136>
2421
2422         Reviewed by Brent Fulgham.
2423
2424         This patch provides the ability to purge all script-accessible cookies while leaving
2425         HttpOnly cookies in place.
2426
2427         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
2428         (WebKit::ResourceLoadStatisticsStore::removeDataRecords):
2429         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
2430         (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores):
2431             Support for a new boolean flag on whether or not to include HttpOnly Cookies.
2432         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
2433         * NetworkProcess/NetworkProcess.cpp:
2434         (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores):
2435             Support for a new boolean flag on whether or not to include HttpOnly Cookies.
2436         (WebKit::NetworkProcess::deleteCookiesForTesting):
2437             Test infrastructure.
2438         * NetworkProcess/NetworkProcess.h:
2439         * NetworkProcess/NetworkProcess.messages.in:
2440         * NetworkProcess/NetworkSession.cpp:
2441         (WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores):
2442             Support for a new boolean flag on whether or not to include HttpOnly Cookies.
2443         * NetworkProcess/NetworkSession.h:
2444         * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
2445         (WKWebsiteDataStoreStatisticsDeleteCookiesForTesting):
2446             Test infrastructure.
2447         * UIProcess/API/C/WKWebsiteDataStoreRef.h:
2448         * UIProcess/Network/NetworkProcessProxy.cpp:
2449         (WebKit::NetworkProcessProxy::deleteCookiesForTesting):
2450             Test infrastructure.
2451         * UIProcess/Network/NetworkProcessProxy.h:
2452         * UIProcess/WebsiteData/WebsiteDataStore.cpp:
2453         (WebKit::WebsiteDataStore::deleteCookiesForTesting):
2454             Test infrastructure.
2455         * UIProcess/WebsiteData/WebsiteDataStore.h:
2456
2457 2019-03-07  Carlos Garcia Campos  <cgarcia@igalia.com>
2458
2459         REGRESSION(r242364): [WPE] Do not stop the compositing run loop update timer on suspend
2460         https://bugs.webkit.org/show_bug.cgi?id=195410
2461
2462         Reviewed by Žan Doberšek.
2463
2464         Calling CompositingRunLoop::stopUpdates() on suspend is leaving the threaded compositor in an inconsistent
2465         state, failing to resume and stopping the updates forever. This is causing timeouts in WPE layout tests. Instead
2466         of calling stopUpdates(), a new suspend() is called, that stops the update timer, without changing the current
2467         updae tha compositing state. A new method resume() is also added to schedule an update if needed.
2468
2469         * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
2470         (WebKit::CompositingRunLoop::suspend): Set state as suspended and stop the update timer.
2471         (WebKit::CompositingRunLoop::resume): Set state as not suspended and start the update timer if it was scheduled
2472         while suspended.
2473         (WebKit::CompositingRunLoop::scheduleUpdate): Do not start the update timer when suspended.
2474         (WebKit::CompositingRunLoop::compositionCompleted): Ditto.
2475         (WebKit::CompositingRunLoop::updateCompleted): Ditto.
2476         (WebKit::CompositingRunLoop::updateTimerFired): Add an assert to ensure the update timer is not fired while suspended.
2477         * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
2478         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
2479         (WebKit::ThreadedCompositor::suspend): Call CompositingRunLoop::suspend() instead of stopUpdates().
2480         (WebKit::ThreadedCompositor::resume): Call CompositingRunLoop::resume().
2481
2482 2019-03-06  Mark Lam  <mark.lam@apple.com>
2483
2484         Exception is a JSCell, not a JSObject.
2485         https://bugs.webkit.org/show_bug.cgi?id=195392
2486
2487         Reviewed by Saam Barati.
2488
2489         * WebProcess/Plugins/Netscape/JSNPObject.cpp:
2490         (WebKit::JSNPObject::throwInvalidAccessError):
2491         * WebProcess/Plugins/Netscape/JSNPObject.h:
2492
2493 2019-03-07  Commit Queue  <commit-queue@webkit.org>
2494
2495         Unreviewed, rolling out r242354.
2496         https://bugs.webkit.org/show_bug.cgi?id=195402
2497
2498         breaks layout tests in all configurations (Requested by
2499         zdobersek on #webkit).
2500
2501         Reverted changeset:
2502
2503         "[WPE] Enable web process sandbox"
2504         https://bugs.webkit.org/show_bug.cgi?id=195169
2505         https://trac.webkit.org/changeset/242354
2506
2507 2019-03-06  Ross Kirsling  <ross.kirsling@sony.com>
2508
2509         [Win] Remove -DUCHAR_TYPE=wchar_t stopgap and learn to live with char16_t.
2510         https://bugs.webkit.org/show_bug.cgi?id=195346
2511
2512         Reviewed by Fujii Hironori.
2513
2514         * Platform/IPC/win/ConnectionWin.cpp:
2515         (IPC::Connection::createServerAndClientIdentifiers):
2516         * Platform/win/ModuleWin.cpp:
2517         (WebKit::Module::load):
2518         * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
2519         (WebKit::ProcessLauncher::launchProcess):
2520         * UIProcess/win/WebContextMenuProxyWin.cpp:
2521         (WebKit::createMenuItem):
2522         * UIProcess/win/WebView.cpp:
2523         (WebKit::WebView::setToolTip):
2524         * WebProcess/InjectedBundle/win/InjectedBundleWin.cpp:
2525         (WebKit::InjectedBundle::initialize):
2526         Use wchar helpers as needed.
2527
2528 2019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
2529
2530         Crash when attempting to change input type while dismissing datalist suggestions
2531         https://bugs.webkit.org/show_bug.cgi?id=195384
2532         <rdar://problem/48563718>
2533
2534         Reviewed by Brent Fulgham.
2535
2536         See WebCore ChangeLog for more details.
2537
2538         * WebProcess/WebPage/WebPage.cpp:
2539         (WebKit::WebPage::setActiveDataListSuggestionPicker):
2540         (WebKit::WebPage::didSelectDataListOption):
2541         (WebKit::WebPage::didCloseSuggestions):
2542         * WebProcess/WebPage/WebPage.h:
2543
2544         Turn m_activeDataListSuggestionPicker from a raw pointer into a WeakPtr.
2545
2546 2019-03-06  Chris Dumez  <cdumez@apple.com>
2547
2548         [iOS] ProcessDidResume() IPC should be sent upon resuming when ProcessWillSuspendImminently() IPC was sent
2549         https://bugs.webkit.org/show_bug.cgi?id=195382
2550         <rdar://problem/48642739>
2551
2552         Reviewed by Geoffrey Garen.
2553
2554         ProcessDidResume() IPC should be sent upon resuming when ProcessWillSuspendImminently() IPC was sent. Previously,
2555         we only send ProcessDidResume() to the WebProcess if PrepareToSuspend() was sent, not when the more urgent
2556         ProcessWillSuspendImminently() IPC was sent.
2557
2558         This mismatch has lead to bugs because the WebProcess does not know it got resumed and failed to unfreeze the
2559         layers it froze upon suspension.
2560
2561         * UIProcess/ProcessAssertion.h:
2562         (WebKit::ProcessAssertionClient::~ProcessAssertionClient):
2563
2564         * UIProcess/ProcessThrottler.cpp:
2565         (WebKit::ProcessThrottler::updateAssertion):
2566         (WebKit::ProcessThrottler::uiAssertionWillExpireImminently):
2567         (WebKit::ProcessThrottler::assertionWillExpireImminently): Deleted.
2568
2569         * UIProcess/ProcessThrottler.h:
2570         * UIProcess/ios/ProcessAssertionIOS.mm:
2571         (-[WKProcessAssertionBackgroundTaskManager _notifyClientsOfImminentSuspension]):
2572         (WebKit::ProcessAssertion::~ProcessAssertion):
2573         (WebKit::ProcessAndUIAssertion::~ProcessAndUIAssertion):
2574         (WebKit::ProcessAndUIAssertion::setClient):
2575
2576         * WebProcess/WebPage/WebPage.cpp:
2577         (WebKit::WebPage::didCompletePageTransition):
2578         Revert change that was landed in r242098 to work around this ProcessThrottler bug.
2579
2580         * WebProcess/WebPage/ios/WebPageIOS.mm:
2581         (WebKit::WebPage::applicationWillEnterForeground):
2582         Revert change that was landed in r242554 to work around this ProcessThrottler bug.
2583
2584 2019-03-06  Alex Christensen  <achristensen@webkit.org>
2585
2586         Add gettid to allowed syscalls on Mac
2587         https://bugs.webkit.org/show_bug.cgi?id=195386
2588         <rdar://problem/48651255>
2589
2590         Reviewed by Brent Fulgham.
2591
2592         * WebProcess/com.apple.WebProcess.sb.in:
2593
2594 2019-03-06  Per Arne Vollan  <pvollan@apple.com>
2595
2596         [macOS] Sandbox call violation causes WebContent process to crash
2597         https://bugs.webkit.org/show_bug.cgi?id=195379
2598         <rdar://problem/48647263>
2599
2600         Reviewed by Brent Fulgham.
2601
2602         A new call needs to be added to the allow list in the WebContent process' sandbox.
2603
2604         * WebProcess/com.apple.WebProcess.sb.in:
2605
2606 2019-03-06  Antti Koivisto  <antti@apple.com>
2607
2608         [iOS] Basic hit testing for content overlapping fast-scrollable overflow
2609         https://bugs.webkit.org/show_bug.cgi?id=195360
2610
2611         Reviewed by Simon Fraser.
2612
2613         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
2614         (WebKit::RemoteLayerTreeHost::makeNode):
2615
2616         Use new UIView subclass for tiled layer hosting (so we know they have content even when contents property is nil).
2617
2618         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h:
2619         * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
2620         (collectDescendantViewsAtPoint):
2621
2622         Factor collection step into a function.
2623         Do basic skipping of event-transparent layers.
2624
2625         (-[UIView _web_findDescendantViewAtPoint:withEvent:]):
2626
2627         To handle overlap cases, find the scroll view that has the deepest non-transparent view hit as its descendant.
2628
2629         (-[UIView _web_recursiveFindDescendantInteractibleViewAtPoint:withEvent:]): Deleted.
2630
2631 2019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
2632
2633         Move RenderObject::isTransparentOrFullyClippedRespectingParentFrames() to RenderLayer
2634         https://bugs.webkit.org/show_bug.cgi?id=195300
2635
2636         Reviewed by Simon Fraser.
2637
2638         Refactor some logic to use isTransparentOrFullyClippedRespectingParentFrames on RenderLayer rather than
2639         RenderObject; introduce a helper method to ask whether the enclosing layer of a renderer is transparent or
2640         clipped.
2641
2642         * WebProcess/WebPage/ios/WebPageIOS.mm:
2643         (WebKit::enclosingLayerIsTransparentOrFullyClipped):
2644         (WebKit::WebPage::platformEditorState const):
2645         (WebKit::WebPage::requestEvasionRectsAboveSelection):
2646         (WebKit::WebPage::getFocusedElementInformation):
2647
2648 2019-03-06  Chris Dumez  <cdumez@apple.com>
2649
2650         REGRESSION (r238490): YouTube.com: Returning PiP to Safari after sleeping device loses page
2651         https://bugs.webkit.org/show_bug.cgi?id=195364
2652         <rdar://problem/48538837>
2653
2654         Reviewed by Geoffrey Garen.
2655
2656         Make sure we unset the LayerTreeFreezeReason::ProcessSuspended layer tree freeze reason
2657         when WebPage::applicationWillEnterForeground() is called. This restores pre-r238490
2658         behavior and addresses the issue with PiP on youtube.com.
2659
2660         * WebProcess/WebPage/ios/WebPageIOS.mm:
2661         (WebKit::WebPage::applicationWillEnterForeground):
2662
2663 2019-03-05  Dean Jackson  <dino@apple.com>
2664
2665         Fix WKPasswordView compilation on iOS
2666         https://bugs.webkit.org/show_bug.cgi?id=195344
2667         <rdar://problem/48620066>
2668
2669         Reviewed by Dan Bates.
2670
2671         Use WebKitAdditions.
2672
2673         * UIProcess/ios/WKPasswordView.mm:
2674         (-[WKPasswordView showInScrollView:]):
2675
2676 2019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
2677
2678         [iOS] Frequent 1 second IPC deadlocks when showing a paste callout
2679         https://bugs.webkit.org/show_bug.cgi?id=195354
2680         <rdar://problem/48624675>
2681
2682         Reviewed by Tim Horton.
2683
2684         When triggering programmatic paste, we frequently hit deadlocks due to sync IPC going from the UI process to the
2685         web process and vice versa. What happens in this scenario is that prior to triggering programmatic paste, the
2686         page may try to move focus to a different element (e.g. a hidden editable area) before calling `execCommand`.
2687         This causes us to send an ElementDidFocus message to the UI process, followed by RequestDOMPasteAccess.
2688
2689         However, upon receiving ElementDidFocus, we reload input views and (in the process) UIKit requests the
2690         autocorrection context, which we implement in WebKit using a sync message to the web process due to
2691         <rdar://problem/16207002> and its blocking bug <rdar://problem/48383001>. This means we'll end up in a state
2692         where both the UI process and web process are blocked on each other waiting for a sync IPC response, and the UI
2693         process is hung for a second until the IPC message times out.
2694
2695         Ideally, we should fix this by addressing <rdar://problem/16207002>. However, this requires potentially large
2696         changes in UIKit (<rdar://problem/48383001>); for the time being, work around this deadlock by refactoring
2697         synchronous autocorrection context requests such that they can be resolved by an out-of-band IPC response
2698         (HandleAutocorrectionContext). Then prior to requesting DOM paste access, preemptively send a
2699         HandleAutocorrectionContext message to the UI process to unblock any pending synchronous autocorrection context
2700         requests.
2701
2702         * UIProcess/PageClient.h:
2703         * UIProcess/WebPageProxy.h:
2704         * UIProcess/WebPageProxy.messages.in:
2705         * UIProcess/ios/PageClientImplIOS.h:
2706         * UIProcess/ios/PageClientImplIOS.mm:
2707         (WebKit::PageClientImpl::handleAutocorrectionContext):
2708         * UIProcess/ios/WKContentViewInteraction.h:
2709
2710         Make it possible for WKContentView to remember its current pending autocorrection context completion handler.
2711         This is invoked and cleared out in `-_invokePendingAutocorrectionContextHandler:`.
2712
2713         * UIProcess/ios/WKContentViewInteraction.mm:
2714         (-[WKContentView _invokePendingAutocorrectionContextHandler:]):
2715         (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]):
2716         (-[WKContentView _handleAutocorrectionContext:]):
2717
2718         Handle an autocorrection context response. This is invoked when the web process either handles an autocorrection
2719         context message, or when it preemptively sends an autocorrection context before requesting DOM paste access.
2720
2721         (+[WKAutocorrectionContext emptyAutocorrectionContext]):
2722
2723         Add a helper to create an empty autocorrection context.
2724
2725         * UIProcess/ios/WebPageProxyIOS.mm:
2726         (WebKit::WebPageProxy::requestAutocorrectionContext):
2727         (WebKit::WebPageProxy::handleAutocorrectionContext):
2728         (WebKit::WebPageProxy::autocorrectionContextSync): Deleted.
2729
2730         Removed this sync version, since we now only have requestAutocorrectionContext.
2731
2732         * WebProcess/WebPage/WebPage.cpp:
2733         (WebKit::WebPage::requestDOMPasteAccess):
2734
2735         Send WebPageProxy::HandleAutocorrectionContext, and add a FIXME referencing <rdar://problem/16207002>.
2736
2737         * WebProcess/WebPage/WebPage.h:
2738         * WebProcess/WebPage/WebPage.messages.in:
2739
2740         Split AutocorrectionContextSync into RequestAutocorrectionContext and HandleAutocorrectionContext; additionally,
2741         remove the existing RequestAutocorrectionContext message.
2742
2743         * WebProcess/WebPage/ios/WebPageIOS.mm:
2744         (WebKit::WebPage::requestAutocorrectionContext):
2745         (WebKit::WebPage::autocorrectionContextSync): Deleted.
2746
2747 2019-03-06  Rob Buis  <rbuis@igalia.com>
2748
2749         Consider supporting the `referrerpolicy` attribute.
2750         https://bugs.webkit.org/show_bug.cgi?id=179053
2751
2752         Reviewed by Darin Adler.
2753
2754         Add a runtime flag for referrerpolicy attribute.
2755
2756         * Shared/WebPreferences.yaml:
2757         * UIProcess/API/C/WKPreferences.cpp:
2758         (WKPreferencesSetReferrerPolicyAttributeEnabled):
2759         (WKPreferencesGetReferrerPolicyAttributeEnabled):
2760         * UIProcess/API/C/WKPreferencesRefPrivate.h:
2761         * WebProcess/Network/WebLoaderStrategy.cpp:
2762         (WebKit::WebLoaderStrategy::loadResource): do not hardcode choosing
2763         the document referrer policy.
2764
2765 2019-03-06  Philippe Normand  <pnormand@igalia.com>
2766
2767         Unreviewed, WPE build fix after r242503
2768
2769         * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
2770         ServiceWorker messages moved from network process to another
2771         header, so it needs to be included.
2772
2773 2019-03-05  David Quesada  <david_quesada@apple.com>
2774
2775         [WK2] It should be possible to follow links with 'download' attributes
2776         https://bugs.webkit.org/show_bug.cgi?id=195145
2777         rdar://problem/48462642
2778
2779         Reviewed by Alex Christensen.
2780
2781         When a link with a 'download' attribute is clicked and the navigation client
2782         says to allow the navigation (i.e. provides PolicyAction::Use),
2783         WebPageProxy::receivedNavigationPolicyDecision() should stop overriding this
2784         decision and downloading the link instead. Instead, web view should honor the
2785         policy chosen by the navigation delegate. This supports clients that want to
2786         offer the user the ability to view, rather than download, the contents of
2787         such links, which is permitted per the HTML spec.
2788
2789         This change is only made on Cocoa platforms for now since no other ports
2790         expose an API on their navigation action to express whether the page intends
2791         to download the linked resource.
2792
2793         * UIProcess/API/APINavigation.h:
2794         (API::Navigation::shouldPerformDownload const):
2795             Rename this to be in line with APINavigationAction's shouldPerformDownload()
2796             for consistency. 'Force' seems like too strong of a word for this property
2797             considering that 'forcing' the download isn't really an attribute inherent
2798             to the navigation, but a behavior implemented by the web page proxy.
2799         (API::Navigation::shouldForceDownload const): Deleted.
2800         * UIProcess/Cocoa/VersionChecks.h:
2801         * UIProcess/WebPageProxy.cpp:
2802         (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
2803
2804 2019-03-05  Takashi Komori  <Takashi.Komori@sony.com>
2805
2806         [Curl] Implement Cookie Accept Policy.
2807         https://bugs.webkit.org/show_bug.cgi?id=191645
2808
2809         Reviewed by Fujii Hironori.
2810
2811         * NetworkProcess/Cookies/curl/WebCookieManagerCurl.cpp:
2812         (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
2813         (WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy):
2814         * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
2815         (WebKit::NetworkDataTaskCurl::curlDidReceiveResponse):
2816         (WebKit::NetworkDataTaskCurl::handleCookieHeaders):
2817         * NetworkProcess/curl/NetworkDataTaskCurl.h:
2818
2819 2019-03-05  Youenn Fablet  <youenn@apple.com>
2820
2821         Introduce ServiceWorkerFetchTask
2822         https://bugs.webkit.org/show_bug.cgi?id=195130
2823
2824         Reviewed by Chris Dumez.
2825
2826         ServiceWorkerFetchTask is added to represent NetworkProcess side of an ongoing fetch intercepted by service worker.
2827         This patch should not change existing behavior.
2828
2829         * CMakeLists.txt:
2830         * DerivedSources-input.xcfilelist:
2831         * DerivedSources-output.xcfilelist:
2832         * DerivedSources.make:
2833         * NetworkProcess/NetworkConnectionToWebProcess.cpp:
2834         (WebKit::NetworkConnectionToWebProcess::didReceiveMessage):
2835         * NetworkProcess/NetworkProcess.cpp:
2836         (WebKit::NetworkProcess::didFailFetch): Deleted.
2837         (WebKit::NetworkProcess::didNotHandleFetch): Deleted.
2838         (WebKit::NetworkProcess::didReceiveFetchRedirectResponse): Deleted.
2839         (WebKit::NetworkProcess::didReceiveFetchResponse): Deleted.
2840         (WebKit::NetworkProcess::didReceiveFetchData): Deleted.
2841         (WebKit::NetworkProcess::didReceiveFetchFormData): Deleted.
2842         (WebKit::NetworkProcess::didFinishFetch): Deleted.
2843         * NetworkProcess/NetworkProcess.h:
2844         * NetworkProcess/NetworkProcess.messages.in:
2845         * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
2846         (WebKit::WebSWServerConnection::cancelFetch):
2847         (WebKit::WebSWServerConnection::continueDidReceiveFetchResponse):
2848         (WebKit::WebSWServerConnection::startFetch):
2849         (WebKit::WebSWServerConnection::didReceiveFetchRedirectResponse): Deleted.
2850         (WebKit::WebSWServerConnection::didReceiveFetchResponse): Deleted.
2851         (WebKit::WebSWServerConnection::didReceiveFetchData): Deleted.
2852         (WebKit::WebSWServerConnection::didReceiveFetchFormData): Deleted.
2853         (WebKit::WebSWServerConnection::didFinishFetch): Deleted.
2854         (WebKit::WebSWServerConnection::didFailFetch): Deleted.
2855         (WebKit::WebSWServerConnection::didNotHandleFetch): Deleted.
2856         * NetworkProcess/ServiceWorker/WebSWServerConnection.h:
2857         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
2858         (WebKit::WebSWServerToContextConnection::connectionClosed):
2859         (WebKit::WebSWServerToContextConnection::startFetch):
2860         (WebKit::WebSWServerToContextConnection::cancelFetch):
2861         (WebKit::WebSWServerToContextConnection::continueDidReceiveFetchResponse):
2862         (WebKit::WebSWServerToContextConnection::didReceiveFetchTaskMessage):
2863         * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
2864         * SourcesCocoa.txt:
2865         * WebKit.xcodeproj/project.pbxproj:
2866         * WebProcess/Storage/WebSWContextManagerConnection.cpp:
2867         (WebKit::WebSWContextManagerConnection::startFetch):
2868         * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
2869         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveRedirection):
2870         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveResponse):
2871         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveData):
2872         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish):
2873         (WebKit::WebServiceWorkerFetchTaskClient::didReceiveBlobChunk):
2874         (WebKit::WebServiceWorkerFetchTaskClient::didFail):
2875         (WebKit::WebServiceWorkerFetchTaskClient::didFinish):
2876         (WebKit::WebServiceWorkerFetchTaskClient::didNotHandle):
2877         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: Added.
2878         (WebKit::ServiceWorkerFetchTask::didReceiveRedirectResponse):
2879         (WebKit::ServiceWorkerFetchTask::didReceiveResponse):
2880         (WebKit::ServiceWorkerFetchTask::didReceiveData):
2881         (WebKit::ServiceWorkerFetchTask::didReceiveFormData):
2882         (WebKit::ServiceWorkerFetchTask::didFinish):
2883         (WebKit::ServiceWorkerFetchTask::didFail):
2884         (WebKit::ServiceWorkerFetchTask::didNotHandle):
2885         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h: Added.
2886         (WebKit::ServiceWorkerFetchTask::create):
2887         (WebKit::ServiceWorkerFetchTask::Identifier::hash const):
2888         (WebKit::ServiceWorkerFetchTask::identifier const):
2889         (WebKit::ServiceWorkerFetchTask::ServiceWorkerFetchTask):
2890         (WebKit::operator==):
2891         (WTF::ServiceWorkerFetchTaskIdentifierHash::hash):
2892         (WTF::ServiceWorkerFetchTaskIdentifierHash::equal):
2893         (WTF::HashTraits<WebKit::ServiceWorkerFetchTask::Identifier>::emptyValue):
2894         (WTF::HashTraits<WebKit::ServiceWorkerFetchTask::Identifier>::constructDeletedValue):
2895         (WTF::HashTraits<WebKit::ServiceWorkerFetchTask::Identifier>::isDeletedValue):
2896         * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.messages.in: Added.
2897
2898 2019-03-05  Youenn Fablet  <youenn@apple.com>
2899
2900         Rename requestCacheStorageSpace to requestStorageSpace
2901         https://bugs.webkit.org/show_bug.cgi?id=195282
2902
2903         Reviewed by Chris Dumez.
2904
2905         Make the name more abstract as it might be used in the future for other storage
2906         like IDB or service worker registrations.
2907
2908         * NetworkProcess/NetworkProcess.cpp:
2909         (WebKit::NetworkProcess::requestStorageSpace):
2910         (WebKit::NetworkProcess::requestCacheStorageSpace): Deleted.
2911         * NetworkProcess/NetworkProcess.h:
2912         * NetworkProcess/cache/CacheStorageEngine.cpp:
2913         (WebKit::CacheStorage::Engine::requestSpace):
2914         * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
2915         (WebsiteDataStoreClient::WebsiteDataStoreClient):
2916         * UIProcess/API/Cocoa/_WKWebsiteDataStoreDelegate.h:
2917         * UIProcess/Network/NetworkProcessProxy.cpp:
2918         (WebKit::NetworkProcessProxy::requestStorageSpace):
2919         (WebKit::NetworkProcessProxy::requestCacheStorageSpace): Deleted.
2920         * UIProcess/Network/NetworkProcessProxy.h:
2921         * UIProcess/Network/NetworkProcessProxy.messages.in:
2922         * UIProcess/WebsiteData/WebsiteDataStoreClient.h:
2923         (WebKit::WebsiteDataStoreClient::requestStorageSpace):
2924         (WebKit::WebsiteDataStoreClient::requestCacheStorageSpace): Deleted.
2925
2926 2019-03-05  Chris Dumez  <cdumez@apple.com>
2927
2928         Drop cached WebProcesses for a given session when this session is destroyed
2929         https://bugs.webkit.org/show_bug.cgi?id=195212
2930         <rdar://problem/48301483>
2931
2932         Reviewed by Geoffrey Garen.
2933
2934         Drop cached WebProcesses for a give session when this session is destroyed. This way, when you close
2935         your private browsing window, all the processes it used get cleared and it cannot leave any state
2936         behind.
2937
2938         * UIProcess/WebProcessCache.cpp:
2939         (WebKit::WebProcessCache::canCacheProcess const):
2940         (WebKit::WebProcessCache::addProcessIfPossible):
2941         (WebKit::WebProcessCache::addProcess):
2942         (WebKit::WebProcessCache::clearAllProcessesForSession):
2943         * UIProcess/WebProcessCache.h:
2944         (WebKit::WebProcessCache::capacity const):
2945         * UIProcess/WebProcessPool.cpp:
2946         (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore):
2947         (WebKit::WebProcessPool::hasPagesUsingWebsiteDataStore const):
2948         * UIProcess/WebProcessPool.h:
2949
2950 2019-03-05  Brady Eidson  <beidson@apple.com>
2951
2952         Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
2953         <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
2954
2955         Reviewed by Tim Horton.
2956
2957         * WebProcess/WebPage/WebPage.cpp:
2958         (WebKit::WebPage::SandboxExtensionTracker::shouldReuseCommittedSandboxExtension): If there is a pendingProvisionalSandboxExtension
2959           then its existence should override our willingness to reuse the existing committed extension.
2960         (WebKit::shouldReuseCommittedSandboxExtension): Deleted.
2961         * WebProcess/WebPage/WebPage.h:
2962
2963 2019-03-05  Ryan Haddad  <ryanhaddad@apple.com>
2964
2965         Unreviewed, rolling out r242403.
2966
2967         Caused layout test crashes on iOS simulator.
2968
2969         Reverted changeset:
2970
2971         "[ContentChangeObserver] Introduce fixed duration content
2972         observation"
2973         https://bugs.webkit.org/show_bug.cgi?id=195295
2974         https://trac.webkit.org/changeset/242403
2975
2976 2019-03-05  Loïc Yhuel  <loic.yhuel@softathome.com>
2977
2978         [WPE] Do not create a PlatformDisplay in the Service Worker process
2979         https://bugs.webkit.org/show_bug.cgi?id=194830
2980
2981         Reviewed by Žan Doberšek.
2982
2983         It avoids opening the Wayland socket in this WPEWebProcess, which might cause issues
2984         depending on the platform, and allocates unneeded resources.
2985
2986         * Shared/WebProcessCreationParameters.cpp:
2987         (WebKit::WebProcessCreationParameters::encode const):
2988         (WebKit::WebProcessCreationParameters::decode):
2989         * Shared/WebProcessCreationParameters.h: Add new isServiceWorkerProcess parameter.
2990         * UIProcess/WebProcessPool.cpp:
2991         (WebKit::WebProcessPool::initializeNewWebProcess): Set isServiceWorkerProcess parameter.
2992         * UIProcess/glib/WebProcessPoolGLib.cpp:
2993         (WebKit::WebProcessPool::platformInitializeWebProcess): No implementationLibraryName and hostClientFileDescriptor for Service Worker.
2994         * WebProcess/glib/WebProcessGLib.cpp:
2995         (WebKit::WebProcess::platformInitializeWebProcess): No wpe_loader_init nor PlatformDisplayLibWPE for Service Worker.
2996
2997 2019-03-04  Brady Eidson  <beidson@apple.com>
2998
2999         Unreviewed, rolling out r242376.
3000
3001         Broke some tests
3002
3003         Reverted changeset:
3004
3005         "Correctly handle sandbox extensions when the same WKWebView
3006         loads multiple file:// URLs."
3007         https://bugs.webkit.org/show_bug.cgi?id=195291
3008         https://trac.webkit.org/changeset/242376
3009
3010 2019-03-04  Fujii Hironori  <Hironori.Fujii@sony.com>
3011
3012         Use a SQLite database to hold the ResourceLoadStatistics data
3013         https://bugs.webkit.org/show_bug.cgi?id=194867
3014         <rdar://problem/24240854>
3015
3016         Unreviewed build fix for WinCairo.
3017
3018         ResourceLoadStatisticsDebug and RELEASE_LOG_INFO_IF are not
3019         defined because WinCairo port defines RELEASE_LOG_DISABLED.
3020
3021         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
3022         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess): Enclosed RELEASE_LOG_INFO_IF with #if !RELEASE_LOG_DISABLED.
3023         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener): Ditto.
3024         (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlocking): Ditto.
3025
3026 2019-03-04  Brent Fulgham  <bfulgham@apple.com>
3027
3028         Use a SQLite database to hold the ResourceLoadStatistics data
3029         https://bugs.webkit.org/show_bug.cgi?id=194867
3030         <rdar://problem/24240854>
3031
3032         Reviewed by Chris Dumez.
3033
3034         The ResourceLoadStatistics database plist is inefficient. It requires more memory use
3035         than it needs, and forces lots of looping and string comparisons to find information.
3036
3037         This problem has already been solved in the form of relational databases. We use them
3038         elsewhere in WebKit, and should do so for this storage as well.
3039
3040         This patch creates an optional SQLite database to handle ITP operations.
3041
3042         1. It adds a new internal experimental feature flag to activate it. It requires the user
3043            exit and restart the process to take effect.
3044         2. It populates itself from the existing plist file (if it exists).
3045         3. It stops using the plist in favor of the database.
3046         4. It does queries and other operations using the database instead of the old hash table
3047            implementation.
3048
3049         This patch refactors the exisiting ResourceLoadStatisticsMemoryStore class into a base
3050         ResourceLoadStatisticsStore class, which ResourceLoadStatisticsMemoryStore is based on.
3051         It adds a new ResourceLoadStatisticsDatabaseStore that is implemented in terms of SQL
3052         operations.
3053
3054         These code changes should not have any impact on existing operations, and when enabled
3055         should produce the same test results.
3056
3057         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: Added.
3058         (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
3059         (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
3060         (WebKit::ResourceLoadStatisticsDatabaseStore::prepareStatements):
3061         (WebKit::ResourceLoadStatisticsDatabaseStore::insertObservedDomain):
3062         (WebKit::ResourceLoadStatisticsDatabaseStore::relationshipExists const):
3063         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationship):
3064         (WebKit::ResourceLoadStatisticsDatabaseStore::confirmDomainDoesNotExist const):
3065         (WebKit::ResourceLoadStatisticsDatabaseStore::domainIDFromString const):
3066         (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships):
3067         (WebKit::ResourceLoadStatisticsDatabaseStore::databaseIsEmpty const):
3068         (WebKit::ResourceLoadStatisticsDatabaseStore::populateFromMemoryStore):
3069         (WebKit::ResourceLoadStatisticsDatabaseStore::calculateAndSubmitTelemetry const):
3070         (WebKit::ResourceLoadStatisticsDatabaseStore::incrementRecordsDeletedCountForDomains):
3071         (WebKit::ResourceLoadStatisticsDatabaseStore::recursivelyFindNonPrevalentDomainsThatRedirectedToThisDomain):
3072         (WebKit::buildList):
3073         (WebKit::ResourceLoadStatisticsDatabaseStore::markAsPrevalentIfHasRedirectedToPrevalent):
3074         (WebKit::listToString):
3075         (WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources):
3076         (WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources):
3077         (WebKit::ResourceLoadStatisticsDatabaseStore::classifyPrevalentResources):
3078         (WebKit::ResourceLoadStatisticsDatabaseStore::syncStorageIfNeeded):
3079         (WebKit::ResourceLoadStatisticsDatabaseStore::syncStorageImmediately):
3080         (WebKit::ResourceLoadStatisticsDatabaseStore::hasStorageAccess):
3081         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess):
3082         (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener):
3083         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccess):
3084         (WebKit::ResourceLoadStatisticsDatabaseStore::grantStorageAccessInternal):
3085         (WebKit::ResourceLoadStatisticsDatabaseStore::grandfatherDataForDomains):
3086         (WebKit::ResourceLoadStatisticsDatabaseStore::ensurePrevalentResourcesForDebugMode):
3087         (WebKit::ResourceLoadStatisticsDatabaseStore::logFrameNavigation):
3088         (WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceLoading):
3089         (WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceRedirect):
3090         (WebKit::ResourceLoadStatisticsDatabaseStore::setUserInteraction):
3091         (WebKit::ResourceLoadStatisticsDatabaseStore::logUserInteraction):
3092         (WebKit::ResourceLoadStatisticsDatabaseStore::clearUserInteraction):
3093         (WebKit::ResourceLoadStatisticsDatabaseStore::hasHadUserInteraction):
3094         (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource):
3095         (WebKit::ResourceLoadStatisticsDatabaseStore::setDomainsAsPrevalent):
3096         (WebKit::ResourceLoadStatisticsDatabaseStore::dumpResourceLoadStatistics const):
3097         (WebKit::ResourceLoadStatisticsDatabaseStore::predicateValueForDomain const):
3098         (WebKit::ResourceLoadStatisticsDatabaseStore::isPrevalentResource const):
3099         (WebKit::ResourceLoadStatisticsDatabaseStore::isVeryPrevalentResource const):
3100         (WebKit::ResourceLoadStatisticsDatabaseStore::isRegisteredAsSubresourceUnder const):
3101         (WebKit::ResourceLoadStatisticsDatabaseStore::isRegisteredAsSubFrameUnder const):
3102         (WebKit::ResourceLoadStatisticsDatabaseStore::isRegisteredAsRedirectingTo const):
3103         (WebKit::ResourceLoadStatisticsDatabaseStore::clearPrevalentResource):
3104         (WebKit::ResourceLoadStatisticsDatabaseStore::setGrandfathered):
3105         (WebKit::ResourceLoadStatisticsDatabaseStore::isGrandfathered const):
3106         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubframeUnderTopFrameOrigin):
3107         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUnderTopFrameOrigin):
3108         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUniqueRedirectTo):
3109         (WebKit::ResourceLoadStatisticsDatabaseStore::setSubresourceUniqueRedirectFrom):
3110         (WebKit::ResourceLoadStatisticsDatabaseStore::setTopFrameUniqueRedirectTo):
3111         (WebKit::ResourceLoadStatisticsDatabaseStore::setTopFrameUniqueRedirectFrom):
3112         (WebKit::ResourceLoadStatisticsDatabaseStore::ensureResourceStatisticsForPrimaryDomain):
3113         (WebKit::ResourceLoadStatisticsDatabaseStore::clear):
3114         (WebKit::ResourceLoadStatisticsDatabaseStore::cookieTreatmentForOrigin const):
3115         (WebKit::ResourceLoadStatisticsDatabaseStore::hasUserGrantedStorageAccessThroughPrompt):
3116         (WebKit::ResourceLoadStatisticsDatabaseStore::domainsToBlock const):
3117         (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlocking):
3118         (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlockingForDomains):
3119         (WebKit::ResourceLoadStatisticsDatabaseStore::clearBlockingStateForDomains):
3120         (WebKit::ResourceLoadStatisticsDatabaseStore::processStatistics const):
3121         (WebKit::ResourceLoadStatisticsDatabaseStore::prevalentDomains const):
3122         (WebKit::ResourceLoadStatisticsDatabaseStore::findExpiredUserInteractions const):
3123         (WebKit::ResourceLoadStatisticsDatabaseStore::clearExpiredUserInteractions):
3124         (WebKit::ResourceLoadStatisticsDatabaseStore::clearGrandfathering):
3125         (WebKit::ResourceLoadStatisticsDatabaseStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
3126         (WebKit::ResourceLoadStatisticsDatabaseStore::pruneStatisticsIfNeeded):
3127         (WebKit::ResourceLoadStatisticsDatabaseStore::updateLastSeen):
3128         (WebKit::ResourceLoadStatisticsDatabaseStore::setLastSeen):
3129         (WebKit::ResourceLoadStatisticsDatabaseStore::setVeryPrevalentResource):
3130         (WebKit::ResourceLoadStatisticsDatabaseStore::removeAllStorageAccess):
3131         * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: Added.
3132         (WebKit::ResourceLoadStatisticsDatabaseStore::isEmpty const):
3133         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
3134         (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore):
3135         (WebKit::ResourceLoadStatisticsMemoryStore::incrementRecordsDeletedCountForDomains):
3136         (WebKit::ResourceLoadStatisticsMemoryStore::classifyPrevalentResources):
3137         (WebKit::ResourceLoadStatisticsMemoryStore::syncStorageIfNeeded):
3138         (WebKit::ResourceLoadStatisticsMemoryStore::syncStorageImmediately):
3139         (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherDataForDomains):
3140         (WebKit::domainsToString): Deleted.
3141         (WebKit::OperatingDate::fromWallTime): Deleted.
3142         (WebKit::OperatingDate::today): Deleted.
3143         (WebKit::OperatingDate::secondsSinceEpoch const): Deleted.
3144         (WebKit::OperatingDate::operator== const): Deleted.
3145         (WebKit::OperatingDate::operator< const): Deleted.
3146         (WebKit::OperatingDate::operator<= const): Deleted.
3147         (WebKit::OperatingDate::OperatingDate): Deleted.
3148         (WebKit::mergeOperatingDates): Deleted.
3149         (WebKit::computeImportance): Deleted.
3150         (WebKit::ResourceLoadStatisticsMemoryStore::~ResourceLoadStatisticsMemoryStore): Deleted.
3151         (WebKit::ResourceLoadStatisticsMemoryStore::setNotifyPagesWhenDataRecordsWereScanned): Deleted.
3152         (WebKit::ResourceLoadStatisticsMemoryStore::setShouldClassifyResourcesBeforeDataRecordsRemoval): Deleted.
3153         (WebKit::ResourceLoadStatisticsMemoryStore::setShouldSubmitTelemetry): Deleted.
3154         (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords): Deleted.
3155         (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords): Deleted.
3156         (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData): Deleted.
3157         (WebKit::ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode): Deleted.
3158         (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode): Deleted.
3159         (WebKit::ResourceLoadStatisticsMemoryStore::scheduleStatisticsProcessingRequestIfNecessary): Deleted.
3160         (WebKit::ResourceLoadStatisticsMemoryStore::cancelPendingStatisticsProcessingRequest): Deleted.
3161         (WebKit::ResourceLoadStatisticsMemoryStore::setTimeToLiveUserInteraction): Deleted.
3162         (WebKit::ResourceLoadStatisticsMemoryStore::setMinimumTimeBetweenDataRecordsRemoval): Deleted.
3163         (WebKit::ResourceLoadStatisticsMemoryStore::setGrandfatheringTime): Deleted.
3164         (WebKit::ResourceLoadStatisticsMemoryStore::setCacheMaxAgeCap): Deleted.
3165         (WebKit::ResourceLoadStatisticsMemoryStore::updateCacheMaxAgeCap): Deleted.
3166         (WebKit::ResourceLoadStatisticsMemoryStore::setAgeCapForClientSideCookies): Deleted.
3167         (WebKit::ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap): Deleted.
3168         (WebKit::ResourceLoadStatisticsMemoryStore::shouldRemoveDataRecords const): Deleted.
3169         (WebKit::ResourceLoadStatisticsMemoryStore::setDataRecordsBeingRemoved): Deleted.
3170         (WebKit::debugLogDomainsInBatches): Deleted.
3171         (WebKit::ResourceLoadStatisticsMemoryStore::includeTodayAsOperatingDateIfNecessary): Deleted.
3172         (WebKit::ResourceLoadStatisticsMemoryStore::hasStatisticsExpired const): Deleted.
3173         (WebKit::ResourceLoadStatisticsMemoryStore::setMaxStatisticsEntries): Deleted.
3174         (WebKit::ResourceLoadStatisticsMemoryStore::setPruneEntriesDownTo): Deleted.
3175         (WebKit::ResourceLoadStatisticsMemoryStore::resetParametersToDefaultValues): Deleted.
3176         (WebKit::ResourceLoadStatisticsMemoryStore::logTestingEvent): Deleted.
3177         (WebKit::ResourceLoadStatisticsMemoryStore::didCreateNetworkProcess): Deleted.
3178         * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
3179         (WebKit::ResourceLoadStatisticsMemoryStore::data const):
3180         (WebKit::ResourceLoadStatisticsMemoryStore::isDebugModeEnabled const): Deleted.
3181         (WebKit::ResourceLoadStatisticsMemoryStore::store const): Deleted.
3182         (WebKit::ResourceLoadStatisticsMemoryStore::setStorageAccessPromptsEnabled): Deleted.
3183         (WebKit::ResourceLoadStatisticsMemoryStore::setDebugLogggingEnabled): Deleted.
3184         (): Deleted.
3185         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: Added.
3186         (WebKit::domainsToString):
3187         (WebKit::OperatingDate::fromWallTime):
3188         (WebKit::OperatingDate::today):
3189         (WebKit::OperatingDate::secondsSinceEpoch const):
3190         (WebKit::OperatingDate::operator== const):
3191         (WebKit::OperatingDate::operator< const):
3192         (WebKit::OperatingDate::operator<= const):
3193         (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore):
3194         (WebKit::ResourceLoadStatisticsStore::~ResourceLoadStatisticsStore):
3195         (WebKit::ResourceLoadStatisticsStore::calculateAndSubmitTelemetry const):
3196         (WebKit::ResourceLoadStatisticsStore::computeImportance):
3197         (WebKit::ResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
3198         (WebKit::ResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
3199         (WebKit::ResourceLoadStatisticsStore::setShouldSubmitTelemetry):
3200         (WebKit::ResourceLoadStatisticsStore::removeDataRecords):
3201         (WebKit::ResourceLoadStatisticsStore::processStatisticsAndDataRecords):
3202         (WebKit::ResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
3203         (WebKit::ResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
3204         (WebKit::ResourceLoadStatisticsStore::setPrevalentResourceForDebugMode):
3205         (WebKit::ResourceLoadStatisticsStore::scheduleStatisticsProcessingRequestIfNecessary):
3206         (WebKit::ResourceLoadStatisticsStore::cancelPendingStatisticsProcessingRequest):
3207         (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
3208         (WebKit::ResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
3209         (WebKit::ResourceLoadStatisticsStore::setGrandfatheringTime):
3210         (WebKit::ResourceLoadStatisticsStore::setCacheMaxAgeCap):
3211         (WebKit::ResourceLoadStatisticsStore::updateCacheMaxAgeCap):
3212         (WebKit::ResourceLoadStatisticsStore::setAgeCapForClientSideCookies):
3213         (WebKit::ResourceLoadStatisticsStore::updateClientSideCookiesAgeCap):
3214         (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords const):
3215         (WebKit::ResourceLoadStatisticsStore::setDataRecordsBeingRemoved):
3216         (WebKit::ResourceLoadStatisticsStore::updateCookieBlockingForDomains):
3217         (WebKit::ResourceLoadStatisticsStore::clearBlockingStateForDomains):
3218         (WebKit::ResourceLoadStatisticsStore::processStatistics const):
3219         (WebKit::ResourceLoadStatisticsStore::statisticsEpirationTime const):
3220         (WebKit::ResourceLoadStatisticsStore::mergeOperatingDates):
3221         (WebKit::ResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary):
3222         (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired const):
3223         (WebKit::ResourceLoadStatisticsStore::setMaxStatisticsEntries):
3224         (WebKit::ResourceLoadStatisticsStore::setPruneEntriesDownTo):
3225         (WebKit::ResourceLoadStatisticsStore::resetParametersToDefaultValues):
3226         (WebKit::ResourceLoadStatisticsStore::logTestingEvent):
3227         (WebKit::ResourceLoadStatisticsStore::removeAllStorageAccess):
3228         (WebKit::ResourceLoadStatisticsStore::didCreateNetworkProcess):
3229         (WebKit::ResourceLoadStatisticsStore::debugLogDomainsInBatches):
3230         * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: Copied from Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h.
3231         (WebKit::OperatingDate::OperatingDate):
3232         (WebKit::ResourceLoadStatisticsStore::isEmpty const):
3233         (WebKit::ResourceLoadStatisticsStore::data const):
3234         (WebKit::ResourceLoadStatisticsStore::isDebugModeEnabled const):
3235         (WebKit::ResourceLoadStatisticsStore::store const):
3236         (WebKit::ResourceLoadStatisticsStore::setStorageAccessPromptsEnabled):
3237         (WebKit::ResourceLoadStatisticsStore::setDebugLogggingEnabled):
3238         * NetworkProcess/Classifier/ResourceLoadStatisticsStoreCocoa.mm: Renamed from Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm.
3239         (WebKit::ResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):
3240         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
3241         (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
3242         (WebKit::WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
3243         (WebKit::WebResourceLoadStatisticsStore::setShouldSubmitTelemetry):
3244         (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
3245         (WebKit::WebResourceLoadStatisticsStore::flushAndDestroyPersistentStore):
3246         (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
3247         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode):
3248         (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
3249         (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess):
3250         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
3251         (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener):
3252         (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess):
3253         (WebKit::WebResourceLoadStatisticsStore::performDailyTasks):
3254         (WebKit::WebResourceLoadStatisticsStore::logFrameNavigation):
3255         (WebKit::WebResourceLoadStatisticsStore::logWebSocketLoading):
3256         (WebKit::WebResourceLoadStatisticsStore::logSubresourceLoading):
3257         (WebKit::WebResourceLoadStatisticsStore::logSubresourceRedirect):
3258         (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
3259         (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
3260         (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
3261         (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
3262         (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
3263         (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
3264         (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
3265         (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource):
3266         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder):
3267         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder):
3268         (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo):
3269         (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
3270         (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
3271         (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
3272         (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
3273         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
3274         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
3275         (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom):
3276         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo):
3277         (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom):
3278         (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdate):
3279         (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains):
3280         (WebKit::WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains):
3281         (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
3282         (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
3283         (WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
3284         (WebKit::WebResourceLoadStatisticsStore::setGrandfatheringTime):
3285         (WebKit::WebResourceLoadStatisticsStore::setMaxStatisticsEntries):
3286         (WebKit::WebResourceLoadStatisticsStore::setPruneEntriesDownTo):
3287         (WebKit::WebResourceLoadStatisticsStore::resetParametersToDefaultValues):
3288         * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
3289         * NetworkProcess/NetworkProcess.cpp:
3290         (WebKit::NetworkProcess::initializeNetworkProcess):
3291         * NetworkProcess/NetworkProcessCreationParameters.cpp:
3292         (WebKit::NetworkProcessCreationParameters::encode const):
3293         (WebKit::NetworkProcessCreationParameters::decode):
3294         * NetworkProcess/NetworkProcessCreationParameters.h:
3295         * Platform/classifier/ResourceLoadStatisticsClassifier.cpp:
3296         (WebKit::ResourceLoadStatisticsClassifier::calculateResourcePrevalence):
3297         * Platform/classifier/ResourceLoadStatisticsClassifier.h:
3298         * Shared/WebPreferences.yaml:
3299         * Sources.txt:
3300         * SourcesCocoa.txt:
3301         * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
3302         (WebKit::WebProcessPool::platformInitializeNetworkProcess):
3303         * UIProcess/WebProcessPool.cpp:
3304         * WebKit.xcodeproj/project.pbxproj:
3305
3306 2019-03-04  Zalan Bujtas  <zalan@apple.com>
3307
3308         [ContentChangeObserver] Introduce fixed duration content observation
3309         https://bugs.webkit.org/show_bug.cgi?id=195295
3310         <rdar://problem/48579913>
3311
3312         Reviewed by Simon Fraser.
3313
3314         * WebProcess/WebPage/ios/WebPageIOS.mm:
3315         (WebKit::WebPage::handleSyntheticClick):
3316
3317 2019-03-04  Truitt Savell  <tsavell@apple.com>
3318
3319         Unreviewed, rolling out r242396.
3320
3321         Found issue to be unrelated. reverting my rollout.
3322
3323         Reverted changeset:
3324
3325         "Unreviewed, rolling out r242222."
3326         https://bugs.webkit.org/show_bug.cgi?id=193683
3327         https://trac.webkit.org/changeset/242396
3328
3329 2019-03-04  Jiewen Tan  <jiewen_tan@apple.com>
3330
3331         Unreviewed, a followup after r242336
3332
3333         * UIProcess/WebPageProxy.cpp:
3334         (WebKit::WebPageProxy::webViewDidMoveToWindow):
3335         Copy the list of observers before iterating it to avoid observers modifying the list.
3336
3337 2019-03-04  Truitt Savell  <tsavell@apple.com>
3338
3339         Unreviewed, rolling out r242222.
3340
3341         Broke internal debug testing
3342
3343         Reverted changeset:
3344
3345         "[iOS] Move calls to [UIKeyboard isInHardwareKeyboardMode] to
3346         the UI process."
3347         https://bugs.webkit.org/show_bug.cgi?id=193683
3348         https://trac.webkit.org/changeset/242222
3349
3350 2019-03-04  Brent Fulgham  <bfulgham@apple.com>
3351
3352         Unreviewed build fix after r242378
3353
3354         * UIProcess/ios/EditableImageController.mm:
3355         (WebKit::EditableImageController::associateWithAttachment):
3356
3357 2019-03-04  Brent Fulgham  <bfulgham@apple.com>
3358
3359         Check contextIDs when handling WebContent messages
3360         https://bugs.webkit.org/show_bug.cgi?id=195289
3361         <rdar://problem/48475870>
3362
3363         Reviewed by Alex Christensen.
3364
3365         The WebContent process is untrusted because it handles arbitrary markup and javascript from untrusted sources.
3366         We should handle its messages with suspicion, and make sure the arguments are valid and usable before honoring them.
3367
3368         This patch hardens the message passing layer by performing MESSAGE_CHECK in places that had been overlooked.
3369
3370         * UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
3371         (WebKit::PlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID):
3372         (WebKit::PlaybackSessionManagerProxy::currentTimeChanged):
3373         (WebKit::PlaybackSessionManagerProxy::bufferedTimeChanged):
3374         (WebKit::PlaybackSessionManagerProxy::seekableRangesVectorChanged):
3375         (WebKit::PlaybackSessionManagerProxy::canPlayFastReverseChanged):
3376         (WebKit::PlaybackSessionManagerProxy::audioMediaSelectionOptionsChanged):
3377         (WebKit::PlaybackSessionManagerProxy::legibleMediaSelectionOptionsChanged):
3378         (WebKit::PlaybackSessionManagerProxy::audioMediaSelectionIndexChanged):
3379         (WebKit::PlaybackSessionManagerProxy::legibleMediaSelectionIndexChanged):
3380         (WebKit::PlaybackSessionManagerProxy::externalPlaybackPropertiesChanged):
3381         (WebKit::PlaybackSessionManagerProxy::wirelessVideoPlaybackDisabledChanged):
3382         (WebKit::PlaybackSessionManagerProxy::mutedChanged):
3383         (WebKit::PlaybackSessionManagerProxy::volumeChanged):
3384         (WebKit::PlaybackSessionManagerProxy::durationChanged):
3385         (WebKit::PlaybackSessionManagerProxy::playbackStartedTimeChanged):
3386         (WebKit::PlaybackSessionManagerProxy::rateChanged):
3387         (WebKit::PlaybackSessionManagerProxy::pictureInPictureSupportedChanged):
3388         (WebKit::PlaybackSessionManagerProxy::pictureInPictureActiveChanged):
3389         (WebKit::PlaybackSessionManagerProxy::handleControlledElementIDResponse const):
3390         * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
3391         (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
3392         (WebKit::UserMediaCaptureManagerProxy::startProducingData):
3393         (WebKit::UserMediaCaptureManagerProxy::stopProducingData):
3394         (WebKit::UserMediaCaptureManagerProxy::end):
3395         (WebKit::UserMediaCaptureManagerProxy::capabilities):
3396         (WebKit::UserMediaCaptureManagerProxy::setMuted):
3397         (WebKit::UserMediaCaptureManagerProxy::applyConstraints):
3398         * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
3399         (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
3400         (WebKit::VideoFullscreenManagerProxy::setHasVideo):
3401         (WebKit::VideoFullscreenManagerProxy::setVideoDimensions):
3402         (WebKit::VideoFullscreenManagerProxy::enterFullscreen):
3403         (WebKit::VideoFullscreenManagerProxy::exitFullscreen):
3404         (WebKit::VideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode):
3405         (WebKit::VideoFullscreenManagerProxy::setInlineRect):
3406         (WebKit::VideoFullscreenManagerProxy::setHasVideoContentLayer):
3407         (WebKit::VideoFullscreenManagerProxy::cleanupFullscreen):
3408         (WebKit::VideoFullscreenManagerProxy::preparedToReturnToInline):
3409         (WebKit::VideoFullscreenManagerProxy::preparedToExitFullscreen):
3410         * UIProcess/ios/EditableImageController.mm:
3411         (WebKit::EditableImageController::didCreateEditableImage):
3412         (WebKit::EditableImageController::didDestroyEditableImage):
3413         (WebKit::EditableImageController::associateWithAttachment):
3414
3415 2019-03-04  Alex Christensen  <achristensen@webkit.org>
3416
3417         Fix crashes when NetworkResourceLoader/NetworkLoadChecker are destroyed during HTTPS upgrade check
3418         https://bugs.webkit.org/show_bug.cgi?id=195238
3419         <rdar://problem/47598656>
3420
3421         Reviewed by Chris Dumez.
3422
3423         * NetworkProcess/NetworkLoadChecker.cpp:
3424         (WebKit::NetworkLoadChecker::checkRequest):
3425
3426 2019-03-04  Brady Eidson  <beidson@apple.com>
3427
3428         Correctly handle sandbox extensions when the same WKWebView loads multiple file:// URLs.
3429         <rdar://problem/47820581> and https://bugs.webkit.org/show_bug.cgi?id=195291
3430
3431         Reviewed by Andy Estes.
3432
3433         * WebProcess/WebPage/WebPage.cpp:
3434         (WebKit::shouldReuseCommittedSandboxExtension): Only retain the previous sandbox extension if the file URL
3435           we're currently loading is functionally equivalent to the previous one.
3436
3437 2019-03-04  Chris Dumez  <cdumez@apple.com>
3438
3439         Drop legacy userAgentForURL injected bundle SPI
3440         https://bugs.webkit.org/show_bug.cgi?id=195222
3441         <rdar://problem/46734147>
3442
3443         Reviewed by Darin Adler.
3444
3445         Drop legacy userAgentForURL injected bundle SPI. There are no longer any clients, and using
3446         WebsitePolicies.customUserAgent is the way to go nowadays.
3447
3448         * WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h:
3449         (API::InjectedBundle::PageLoaderClient::willDestroyFrame):
3450         (API::InjectedBundle::PageLoaderClient::userAgentForURL const): Deleted.
3451         * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h:
3452         * WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h:
3453         * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
3454         (setUpPageLoaderClient):
3455         (userAgentForURL): Deleted.
3456         * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
3457         (WebKit::InjectedBundlePageLoaderClient::userAgentForURL const): Deleted.
3458         * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
3459         * WebProcess/WebPage/WebPage.cpp:
3460         (WebKit::WebPage::userAgent const):
3461
3462 2019-03-04  Chris Dumez  <cdumez@apple.com>
3463
3464         Do not share WebProcesses between private and regular sessions
3465         https://bugs.webkit.org/show_bug.cgi?id=195189
3466         <rdar://problem/48421064>
3467
3468         Reviewed by Alex Christensen.
3469
3470         Do not share WebProcesses between private and regular sessions. There are some privacy concerns.
3471         Also, some of the WebsiteDataStore informations are passed via WebProcessCreationParameters (e.g.
3472         ApplicationCache path) and cannot be updated later.
3473
3474         There were 2 cases where this could happen and that are fixed in the patch:
3475         - A process may be prewarmed with a given website data store and then later on used for a page
3476           associated with a different data store. We now prevent this. While this is not necessary for
3477           privacy reasons, it is still useful because our code currently does not support well uses
3478           different sessions inside a single WebProcess, as mentioned above.
3479         - The client can force a WebsiteDataStore swap when responding to the decidePolicyForNavigationAction,
3480           via the WebsitePolicies. To address the issue, we now force a process swap whenever the client
3481           makes such a change.
3482
3483         As a result, WebProcessProxy::websiteDataStore() now makes sense and is always correct. It can
3484         also only contains pages whose WebPageProxy::websiteDataStore() returns the same store.
3485
3486         * UIProcess/API/C/WKContext.cpp:
3487         (WKContextWarmInitialProcess):
3488         * UIProcess/API/Cocoa/WKProcessPool.mm:
3489         (-[WKProcessPool _warmInitialProcess]):
3490         * UIProcess/ProvisionalPageProxy.cpp:
3491         (WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
3492         (WebKit::ProvisionalPageProxy::~ProvisionalPageProxy):
3493         * UIProcess/WebPageProxy.cpp:
3494         (WebKit::WebPageProxy::notifyProcessPoolToPrewarm):
3495         (WebKit::WebPageProxy::reattachToWebProcess):
3496         (WebKit::WebPageProxy::swapToWebProcess):
3497         (WebKit::WebPageProxy::close):
3498         (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
3499         (WebKit::WebPageProxy::commitProvisionalPage):
3500         (WebKit::WebPageProxy::creationParameters):
3501         * UIProcess/WebPageProxy.h:
3502         (WebKit::WebPageProxy::websiteDataStore):
3503         * UIProcess/WebProcessPool.cpp:
3504         (WebKit::WebProcessPool::ensureNetworkProcess):
3505         (WebKit::WebProcessPool::tryTakePrewarmedProcess):
3506         (WebKit::WebProcessPool::prewarmProcess):
3507         (WebKit::WebProcessPool::createWebPage):
3508         (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
3509         (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore):
3510         (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
3511         (WebKit::WebProcessPool::processForNavigation):
3512         (WebKit::WebProcessPool::processForNavigationInternal):
3513         (WebKit::WebProcessPool::findReusableSuspendedPageProcess):
3514         * UIProcess/WebProcessPool.h:
3515         (WebKit::WebProcessPool::sendToOneProcess):
3516         * UIProcess/WebProcessProxy.cpp:
3517         (WebKit::WebProcessProxy::createWebPage):
3518         (WebKit::WebProcessProxy::addExistingWebPage):
3519         (WebKit::WebProcessProxy::removeWebPage):
3520         * UIProcess/WebProcessProxy.h:
3521
3522 2019-03-04  Chris Dumez  <cdumez@apple.com>
3523
3524         [iOS] Improve our file picker
3525         https://bugs.webkit.org/show_bug.cgi?id=195284
3526         <rdar://problem/45655856>
3527
3528         Reviewed by Tim Horton and Wenson Hsieh.
3529
3530         Improve our file picker on iOS so that:
3531         - Accepted file extensions specified in the HTML (e.g. <input type="file"> accept=".pdf">) are now
3532           properly reflected in the file picker. Previously, we only we only supported MIME types in the
3533           accept attribute that only Image / Video ones.
3534         - If accepted types are specified in the HTML and not of them are Video or Image types, then bypass
3535           the UIDocumentMenuViewController and show the file picker directly (as if the user had tapped on
3536           "Browse..." on that menu). Other menu items such as "Take Photo or Video" and "Photo Library" do
3537           not make sense if the page only accepts PDF files for example.
3538
3539         Things that we should do but are not fixed in this patch:
3540         - Stop using UIDocumentMenuViewController entirely since it was deprecated in favor of using
3541           UIDocumentPickerViewController directly.
3542         - Add multiple selection support, which is supported both on the HTML side and in the
3543           UIDocumentPickerViewController API.
3544
3545         * UIProcess/ios/forms/WKFileUploadPanel.mm:
3546         (arrayContainsUTIThatConformsTo):
3547         (-[WKFileUploadPanel dealloc]):
3548         (-[WKFileUploadPanel presentWithParameters:resultListener:]):
3549         (UTIsForMIMETypes):
3550         (-[WKFileUploadPanel _mediaTypesForPickerSourceType:]):
3551         (-[WKFileUploadPanel _cameraButtonLabelAllowingPhoto:allowingVideo:]):
3552         (-[WKFileUploadPanel _showDocumentPickerMenu]):
3553
3554 2019-03-04  Alex Christensen  <achristensen@webkit.org>
3555
3556         REGRESSION: ( r240978-r240985 ) [ iOS Release ] Layout Test imported/w3c/web-platform-tests/xhr/send-redirect-post-upload.htm is crashing
3557         https://bugs.webkit.org/show_bug.cgi?id=194523
3558
3559         Reviewed by Ryosuke Niwa.
3560
3561         Attempt to work around a CFNetwork bug in the timing of tearing down tasks with upload streams.
3562         See rdar://problem/28233746.
3563
3564         * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
3565         * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
3566         (WebKit::NetworkDataTaskCocoa::~NetworkDataTaskCocoa):
3567         * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
3568         (-[WKNetworkSessionDelegate URLSession:task:needNewBodyStream:]):
3569
3570 2019-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
3571
3572         [CoordinatedGraphics] The compositing loop is still running even after exiting AC mode
3573         https://bugs.webkit.org/show_bug.cgi?id=195270
3574
3575         Reviewed by Don Olmstead.
3576
3577         Suspend the threaded compositor when the painting is paused or layer flush disabled, and resume it again when
3578         painting is resumed and layer flush enabled.
3579
3580         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
3581         (WebKit::ThreadedCompositor::suspend): Increment the suspend counter and mark the scene as inactive if it was suspended.
3582         (WebKit::ThreadedCompositor::resume): Decrement the suspend counter and mark the scene as active if it's now resumed.
3583         * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
3584         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
3585         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaint): Return early if layer tree state is frozen.
3586         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaintAsync): Ditto.
3587         * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
3588         (WebKit::LayerTreeHost::setLayerFlushSchedulingEnabled): Call ThreadedCompositor::suspend()/resume().
3589         (WebKit::LayerTreeHost::pauseRendering): Call ThreadedCompositor::suspend.
3590         (WebKit::LayerTreeHost::resumeRendering): Call ThreadedCompositor::resume().
3591
3592 2019-03-04  Simon Fraser  <simon.fraser@apple.com>
3593
3594         Share more code between overflow and frame scrolling nodes, fixing overflow scrollbar display
3595         https://bugs.webkit.org/show_bug.cgi?id=195258
3596
3597         Reviewed by Antti Koivisto.
3598
3599         This patch moves management of scrollbar layers and scrollbar painters ("NSScrollerImp") down to
3600         ScrollingStateScrollingNode to be shared between frame and overflow nodes, allowing for
3601         scrolling thread updates of overflow scrollbars. It also moves some scrolling tree-side code
3602         to ScrollingTreeScrollingNodeDelegateMac to be shared between the "tree" nodes for overflow and frames.
3603
3604         Layers for scrollbars are given to scrolling state nodes via setNodeLayers() now, and
3605         RenderLayerCompositor::updateScrollingNodeLayers() is added to provide a bottleneck to call that.
3606         At some point AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange() should be relieved
3607         of the responsibility of pushing scrollbar layers (but the scrolling state tree needs to hold
3608         references to GraphicsLayers before that becomes safe).
3609         
3610         The actual fix that allows overflow scrollbars to show is the change in
3611         AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange() that calls scrollableArea.*ScrollbarLayerDidChange()
3612         for all ScrollableAreas. This ensures that the CALayer is pushed onto the NSScrollerImp.
3613
3614         * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
3615         (ArgumentCoder<ScrollingStateScrollingNode>::encode):
3616         (ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
3617         (ArgumentCoder<ScrollingStateScrollingNode>::decode):
3618         (ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):
3619         * SourcesCocoa.txt:
3620         * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
3621         (WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
3622         * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
3623         (WebKit::RemoteScrollingTree::createScrollingTreeNode):
3624         * UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp:
3625         (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::commitStateBeforeChildren):
3626         (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::repositionRelatedLayers):
3627         (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::handleMouseEvent):
3628         * UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp: Copied from Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp.
3629         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::create):
3630         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::ScrollingTreeOverflowScrollingNodeRemoteMac):
3631         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::~ScrollingTreeOverflowScrollingNodeRemoteMac):
3632         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::commitStateBeforeChildren):
3633         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::repositionRelatedLayers):
3634         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::handleWheelEvent):
3635         (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::handleMouseEvent):
3636         * WebKit.xcodeproj/project.pbxproj:
3637
3638 2019-03-04  Andy Estes  <aestes@apple.com>
3639
3640         [Apple Pay] Move WebPaymentCoordinatorProxy from Source/WebKit/UIProcess to Source/WebKit/Shared
3641         https://bugs.webkit.org/show_bug.cgi?id=195080
3642         <rdar://problem/48421558>
3643
3644         Reviewed by Antti Koivisto.
3645
3646         * CMakeLists.txt:
3647         * DerivedSources-input.xcfilelist:
3648         * DerivedSources.make:
3649         * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp: Renamed from Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp.
3650         * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Renamed from Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h.
3651         * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Renamed from Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in.
3652         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h: Renamed from Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h.
3653         * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: Renamed from Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm.
3654         * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm: Renamed from Source/WebKit/UIProcess/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm.
3655         * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm: Renamed from Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm.
3656         * Shared/mac/WebHitTestResultData.mm:
3657         * SourcesCocoa.txt:
3658         * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h:
3659         * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
3660         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
3661         * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
3662         * WebKit.xcodeproj/project.pbxproj:
3663
3664 2019-03-04  Jer Noble  <jer.noble@apple.com>
3665
3666         [iOS] Fullscreen "stay in page" option breaks video playback
3667         https://bugs.webkit.org/show_bug.cgi?id=195277
3668         <rdar://problem/48537317>
3669
3670         Reviewed by Eric Carlson.
3671
3672         Make sure we resume media playback when the user chooses "stay in page" from the deceptive
3673         website warning dialog.
3674
3675         * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
3676         (-[WKFullScreenViewController _showPhishingAlert]):
3677
3678 2019-03-04  Michael Catanzaro  <mcatanzaro@igalia.com>
3679
3680         [WPE] Enable web process sandbox
3681         https://bugs.webkit.org/show_bug.cgi?id=195169
3682
3683         Reviewed by Daniel Bates.
3684
3685         * PlatformWPE.cmake:
3686         * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
3687         (WebKit::bubblewrapSpawn):
3688         * UIProcess/glib/WebProcessPoolGLib.cpp:
3689         (WebKit::WebProcessPool::platformInitialize):
3690
3691 2019-03-04  Adrian Perez de Castro  <aperez@igalia.com>
3692
3693         [GTK][WPE] Wrong license header in WebKit{,WebExtension}Autocleanups.h
3694         https://bugs.webkit.org/show_bug.cgi?id=195245
3695
3696         Reviewed by Carlos Garcia Campos.
3697
3698         Changed license headers to contain the LGPL, which is the correct one for the GTK
3699         and WPE ports. The change was agreed by the contributors to the files involved.
3700
3701         * UIProcess/API/gtk/WebKitAutocleanups.h:
3702         * UIProcess/API/wpe/WebKitAutocleanups.h:
3703         * WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionAutocleanups.h:
3704         * WebProcess/InjectedBundle/API/wpe/WebKitWebExtensionAutocleanups.h:
3705
3706 2019-03-04  Commit Queue  <commit-queue@webkit.org>
3707
3708         Unreviewed, rolling out r242045.
3709         https://bugs.webkit.org/show_bug.cgi?id=195273
3710
3711         WE not ready to enable PSON yet (Requested by KaL on #webkit).
3712
3713         Reverted changeset:
3714
3715         "[GTK] Enable PSON"
3716         https://bugs.webkit.org/show_bug.cgi?id=194979
3717         https://trac.webkit.org/changeset/242045
3718
3719 2019-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
3720
3721         [CoordinatedGraphics] Unify DrawingArea classes
3722         https://bugs.webkit.org/show_bug.cgi?id=195167
3723
3724         Reviewed by Žan Doberšek.
3725
3726         Add DrawingAreaProxyCoordinatedGraphics and DrawingAreaCoordinatedGraphics.
3727
3728         * PlatformGTK.cmake:
3729         * PlatformWPE.cmake:
3730         * PlatformWin.cmake:
3731         * Shared/DrawingAreaInfo.h:
3732         * SourcesGTK.txt:
3733         * SourcesWPE.txt:
3734         * UIProcess/API/gtk/PageClientImpl.cpp:
3735         (WebKit::PageClientImpl::createDrawingAreaProxy):
3736         (WebKit::PageClientImpl::viewSize):
3737         * UIProcess/API/gtk/WebKitWebViewBase.cpp:
3738         (webkitWebViewBaseRealize):
3739         (webkitWebViewBaseUnrealize):
3740         (webkitWebViewBaseDraw):
3741         (webkitWebViewBaseSizeAllocate):
3742         (webkitWebViewBaseDidRelaunchWebProcess):
3743         (webkitWebViewBasePageClosed):
3744         * UIProcess/API/wpe/PageClientImpl.cpp:
3745         (WebKit::PageClientImpl::createDrawingAreaProxy):
3746         * UIProcess/AcceleratedDrawingAreaProxy.cpp: Removed.
3747         * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp: Added.
3748         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingAreaProxyCoordinatedGraphics):
3749         (WebKit::DrawingAreaProxyCoordinatedGraphics::~DrawingAreaProxyCoordinatedGraphics):
3750         (WebKit::DrawingAreaProxyCoordinatedGraphics::paint):
3751         (WebKit::DrawingAreaProxyCoordinatedGraphics::sizeDidChange):
3752         (WebKit::DrawingAreaProxyCoordinatedGraphics::deviceScaleFactorDidChange):
3753         (WebKit::DrawingAreaProxyCoordinatedGraphics::waitForBackingStoreUpdateOnNextPaint):
3754         (WebKit::DrawingAreaProxyCoordinatedGraphics::setBackingStoreIsDiscardable):
3755         (WebKit::DrawingAreaProxyCoordinatedGraphics::update):
3756         (WebKit::DrawingAreaProxyCoordinatedGraphics::didUpdateBackingStoreState):
3757         (WebKit::DrawingAreaProxyCoordinatedGraphics::enterAcceleratedCompositingMode):
3758         (WebKit::DrawingAreaProxyCoordinatedGraphics::exitAcceleratedCompositingMode):
3759         (WebKit::DrawingAreaProxyCoordinatedGraphics::updateAcceleratedCompositingMode):
3760         (WebKit::DrawingAreaProxyCoordinatedGraphics::incorporateUpdate):
3761         (WebKit::DrawingAreaProxyCoordinatedGraphics::alwaysUseCompositing const):
3762         (WebKit::DrawingAreaProxyCoordinatedGraphics::backingStoreStateDidChange):
3763         (WebKit::DrawingAreaProxyCoordinatedGraphics::sendUpdateBackingStoreState):
3764         (WebKit::DrawingAreaProxyCoordinatedGraphics::waitForAndDispatchDidUpdateBackingStoreState):
3765         (WebKit::DrawingAreaProxyCoordinatedGraphics::discardBackingStoreSoon):
3766         (WebKit::DrawingAreaProxyCoordinatedGraphics::discardBackingStore):
3767         (WebKit::DrawingAreaProxyCoordinatedGraphics::setNativeSurfaceHandleForCompositing):
3768         (WebKit::DrawingAreaProxyCoordinatedGraphics::destroyNativeSurfaceHandleForCompositing):
3769         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::DrawingMonitor):
3770         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::~DrawingMonitor):
3771         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::webViewDrawCallback):
3772         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start):
3773         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::stop):
3774         (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::didDraw):
3775         (WebKit::DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing):
3776         * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.h: Renamed from Source/WebKit/UIProcess/AcceleratedDrawingAreaProxy.h.
3777         * UIProcess/DrawingAreaProxyImpl.cpp: Removed.
3778         * UIProcess/DrawingAreaProxyImpl.h: Removed.
3779         * UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
3780         (WebKit::AcceleratedBackingStoreX11::update):
3781         * UIProcess/win/PageClientImpl.cpp:
3782         (WebKit::PageClientImpl::createDrawingAreaProxy):
3783         * UIProcess/win/WebView.cpp:
3784         (WebKit::WebView::paint):
3785         * WebProcess/WebPage/AcceleratedDrawingArea.cpp: Removed.
3786         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp: Added.
3787         (WebKit::DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics):
3788         (WebKit::DrawingAreaCoordinatedGraphics::~DrawingAreaCoordinatedGraphics):
3789         (WebKit::DrawingAreaCoordinatedGraphics::setNeedsDisplay):
3790         (WebKit::DrawingAreaCoordinatedGraphics::setNeedsDisplayInRect):
3791         (WebKit::DrawingAreaCoordinatedGraphics::scroll):
3792         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaint):
3793         (WebKit::DrawingAreaCoordinatedGraphics::forceRepaintAsync):
3794         (WebKit::DrawingAreaCoordinatedGraphics::setLayerTreeStateIsFrozen):
3795         (WebKit::DrawingAreaCoordinatedGraphics::updatePreferences):
3796         (WebKit::DrawingAreaCoordinatedGraphics::mainFrameContentSizeChanged):
3797         (WebKit::DrawingAreaCoordinatedGraphics::deviceOrPageScaleFactorChanged):
3798         (WebKit::DrawingAreaCoordinatedGraphics::didChangeViewportAttributes):
3799         (WebKit::DrawingAreaCoordinatedGraphics::graphicsLayerFactory):
3800         (WebKit::DrawingAreaCoordinatedGraphics::setRootCompositingLayer):
3801         (WebKit::DrawingAreaCoordinatedGraphics::scheduleCompositingLayerFlush):
3802         (WebKit::DrawingAreaCoordinatedGraphics::layerHostDidFlushLayers):
3803         (WebKit::DrawingAreaCoordinatedGraphics::createDisplayRefreshMonitor):
3804         (WebKit::DrawingAreaCoordinatedGraphics::setNativeSurfaceHandleForCompositing):
3805         (WebKit::DrawingAreaCoordinatedGraphics::destroyNativeSurfaceHandleForCompositing):
3806         (WebKit::DrawingAreaCoordinatedGraphics::activityStateDidChange):
3807         (WebKit::DrawingAreaCoordinatedGraphics::attachViewOverlayGraphicsLayer):
3808         (WebKit::DrawingAreaCoordinatedGraphics::updateBackingStoreState):
3809         (WebKit::DrawingAreaCoordinatedGraphics::didUpdate):
3810         (WebKit::DrawingAreaCoordinatedGraphics::sendDidUpdateBackingStoreState):
3811         (WebKit::DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingModeSoon):
3812         (WebKit::DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingModeNow):
3813         (WebKit::DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost):
3814         (WebKit::DrawingAreaCoordinatedGraphics::suspendPainting):
3815         (WebKit::DrawingAreaCoordinatedGraphics::resumePainting):
3816         (WebKit::DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode):
3817         (WebKit::DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingMode):
3818         (WebKit::DrawingAreaCoordinatedGraphics::scheduleDisplay):
3819         (WebKit::DrawingAreaCoordinatedGraphics::displayTimerFired):
3820         (WebKit::DrawingAreaCoordinatedGraphics::display):
3821         (WebKit::shouldPaintBoundsRect):
3822         * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h: Renamed from Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h.
3823         * WebProcess/WebPage/DrawingArea.cpp:
3824         (WebKit::DrawingArea::create):
3825         * WebProcess/WebPage/DrawingArea.h:
3826         (WebKit::DrawingArea::layerFlushThrottlingIsActive const):
3827         * WebProcess/WebPage/DrawingAreaImpl.cpp: Removed.
3828         * WebProcess/WebPage/DrawingAreaImpl.h: Removed.
3829
3830 2019-03-03  Zalan Bujtas  <zalan@apple.com>
3831
3832         [ContentChangeObserver] Content observation should be limited to the current document.
3833         https://bugs.webkit.org/show_bug.cgi?id=195256
3834         <rdar://problem/48544402>
3835
3836         Reviewed by Simon Fraser.
3837
3838         * WebProcess/WebPage/WebPage.h:
3839         * WebProcess/WebPage/ios/WebPageIOS.mm:
3840         (WebKit::WebPage::handleSyntheticClick):
3841         (WebKit::WebPage::completePendingSyntheticClickForContentChangeObserver):
3842         (WebKit::WebPage::completeSyntheticClick):
3843         (WebKit::WebPage::handleTap):
3844         (WebKit::WebPage::handleTwoFingerTapAtPoint):
3845         (WebKit::WebPage::commitPotentialTap):
3846
3847 2019-03-03  Tim Horton  <timothy_horton@apple.com>
3848
3849         Rid the world of WK_API_ENABLED
3850         https://bugs.webkit.org/show_bug.cgi?id=195263
3851
3852         Reviewed by Dan Bernstein.
3853
3854         List of changed files elided because it's useless.
3855
3856 2019-03-03  Jiewen Tan  <jiewen_tan@apple.com>
3857
3858         Add a WebViewDidMoveToWindowObserver for WKWebView
3859         https://bugs.webkit.org/show_bug.cgi?id=195223
3860         <rdar://problem/48520161>
3861
3862         Reviewed by Darin Adler.
3863
3864         The load optimizer would only allow itself to optimize loads whenever the web view
3865         who owns the page is (visible && focused), otherwises it will wait until the web view
3866         becomes (visible && focused). Therefore, we need a way to notify the load optimizer
3867         changes of statuses.
3868
3869         * UIProcess/API/Cocoa/WKWebView.mm:
3870         (-[WKWebView didMoveToWindow]):
3871         * UIProcess/Cocoa/WebViewImpl.mm:
3872         (WebKit::WebViewImpl::viewDidMoveToWindow):
3873         * UIProcess/WebPageProxy.cpp:
3874         (WebKit::WebPageProxy::addWebViewDidMoveToWindowObserver):
3875         (WebKit::WebPageProxy::removeWebViewDidMoveToWindowObserver):
3876         (WebKit::WebPageProxy::webViewDidMoveToWindow):
3877         * UIProcess/WebPageProxy.h:
3878         * UIProcess/WebViewDidMoveToWindowObserver.h: Added.
3879         * WebKit.xcodeproj/project.pbxproj:
3880
3881 2019-03-03  Andy Estes  <aestes@apple.com>
3882
3883         [Apple Pay] Untangle WebPageProxy and WebPaymentCoordinatorProxy
3884         https://bugs.webkit.org/show_bug.cgi?id=195219
3885         <rdar://problem/48518082>
3886
3887         Reviewed by Darin Adler.
3888
3889         Rather than having WebPaymentCoordinatorProxy know about WebPageProxy, give
3890         WebPaymentCoordinatorProxy a client interface that WebPageProxy conforms to.
3891
3892         In a follow-on patch, WebPaymentCoordinatorProxy will have a non-WebPageProxy client.
3893
3894         * UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp:
3895         (WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy): Replaced use of
3896         m_webPageProxy with m_client.
3897         (WebKit::WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy): Ditto.
3898         (WebKit::WebPaymentCoordinatorProxy::messageSenderConnection const): Implemented
3899         IPC::MessageSender via m_client.
3900         (WebKit::WebPaymentCoordinatorProxy::messageSenderDestinationID const): Ditto.