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