2020-04-10 Per Arne Vollan [iOS] Fix media accessibility sandbox violation in the WebContent process https://bugs.webkit.org/show_bug.cgi?id=210301 Reviewed by Daniel Bates. The media accessibility service is a global name, not a xpc service name. No new tests, since I have not observed any bugs related to the denial of this service. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-04-10 Youenn Fablet Introduce a RealtimeMediaSource observer dedicated to receiving audio samples https://bugs.webkit.org/show_bug.cgi?id=210180 Reviewed by Eric Carlson. Update SourceProxy to be an AudioSampleObserver. Update MediaRecorder to only listen for audio samples if GPU remote writer is successfully created. It also stops listening to audio samples as soon as stopping the recording. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy): (WebKit::UserMediaCaptureManagerProxy::SourceProxy::~SourceProxy): * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::~MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::audioSamplesAvailable): (WebKit::MediaRecorderPrivate::stopRecording): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: * WebProcess/GPU/webrtc/MediaRecorderProvider.cpp: (WebKit::MediaRecorderProvider::createMediaRecorderPrivate): * WebProcess/GPU/webrtc/MediaRecorderProvider.h: 2020-04-10 Youenn Fablet SWServer should not run a service worker that is terminating https://bugs.webkit.org/show_bug.cgi?id=210044 Reviewed by Chris Dumez. Implement whenServiceWorkerIsTerminated check. * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::whenServiceWorkerIsTerminatedForTesting): * NetworkProcess/ServiceWorker/WebSWServerConnection.h: * NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::whenServiceWorkerIsTerminatedForTesting): * WebProcess/Storage/WebSWClientConnection.h: 2020-04-10 Commit Queue Unreviewed, reverting r259818. https://bugs.webkit.org/show_bug.cgi?id=210330 "Causes crashes in at least three layout tests on iOS bots." (Requested by ddkilzer on #webkit). Reverted changeset: "Reset view navigation gesture state between tests" https://bugs.webkit.org/show_bug.cgi?id=210283 https://trac.webkit.org/changeset/259818 2020-04-10 Claudio Saavedra [GTK] Use X11-specific GDK API in Netscape plugin https://bugs.webkit.org/show_bug.cgi?id=210325 Reviewed by Adrian Perez de Castro. Since the code is X11-specific we can do that and remove deprecated API use. * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp: (WebKit::getPluginDisplay): (WebKit::x11Screen): 2020-04-10 Claudio Saavedra [GTK] Drop deprecated Drag and Drop API use https://bugs.webkit.org/show_bug.cgi?id=210327 Reviewed by Adrian Perez de Castro. Use gtk_drag_begin_with_coordinates(), even if we let it guess the coordinates itself from the event, as gtk_drag_begin() is deprecated. * UIProcess/gtk/DragAndDropHandler.cpp: (WebKit::DragAndDropHandler::startDrag): 2020-04-09 David Kilzer Add WARN_UNUSED_RETURN to decode methods in Source/WebKit/Platform/IPC Reviewed by Alex Christensen. * Platform/IPC/ArgumentCoder.h: * Platform/IPC/ArgumentCoders.cpp: (IPC::ArgumentCoder::decode): (IPC::ArgumentCoder::decode): (IPC::ArgumentCoder::decode): (IPC::ArgumentCoder::decode): (IPC::ArgumentCoder::decode): (IPC::ArgumentCoder::decode): (IPC::ArgumentCoder::decode): * Platform/IPC/ArgumentCoders.h: (IPC::SimpleArgumentCoder::decode): (IPC::ArgumentCoder>::decode): (IPC::ArgumentCoder>::decode): (IPC::ArgumentCoder>::decode): (IPC::TupleDecoderImpl::decode): (IPC::TupleDecoderImpl::decode): (IPC::TupleDecoder::decode): (IPC::TupleDecoder<0>::decode): (IPC::VariantCoder::decode): * Platform/IPC/Attachment.h: * Platform/IPC/DataReference.h: * Platform/IPC/Decoder.h: (IPC::Decoder::decodeEnum): * Platform/IPC/FormDataReference.h: (IPC::FormDataReference::decode): * Platform/IPC/ImageDataReference.h: (IPC::ImageDataReference::decode): * Platform/IPC/SharedBufferDataReference.h: (IPC::SharedBufferDataReference::decode): * Platform/IPC/StringReference.h: * Platform/IPC/cocoa/MachPort.h: (IPC::MachPort::decode): 2020-04-09 Alex Christensen IPC serialization of enums should serialize std::underlying_type instead of uint64_t https://bugs.webkit.org/show_bug.cgi?id=210228 Reviewed by Chris Dumez and Darin Adler. * Platform/IPC/Decoder.h: (IPC::Decoder::decode): (IPC::Decoder::operator>>): (IPC::Decoder::decodeEnum): * Platform/IPC/Encoder.h: * Shared/cf/ArgumentCodersCF.cpp: (IPC::encode): (IPC::decode): 2020-04-08 Darin Adler [Cocoa] Simplify NSArray, NSDictionary, and NSNumber idioms throughout WebKit https://bugs.webkit.org/show_bug.cgi?id=210138 Reviewed by Alex Christensen. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: Remove uneeded include. * Platform/mac/StringUtilities.mm: Ditto. * PluginProcess/mac/PluginProcessMac.mm: (WebKit::replacedNSConcreteTask_launch): Use makeVector. (WebKit::replacedNSWorkspace_launchApplicationAtURL_options_configuration_error): Ditto. * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: (WebKit::toSupportedNetworks): Deleted. (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Use createNSArray. * Shared/mac/PasteboardTypes.mm: (WebKit::PasteboardTypes::forEditing): Use @[]. (WebKit::PasteboardTypes::forURL): Ditto. (WebKit::PasteboardTypes::forImages): Ditto. (WebKit::PasteboardTypes::forImagesWithArchive): Ditto. (WebKit::PasteboardTypes::forSelection): Ditto. * UIProcess/API/Cocoa/WKContentRuleListStore.mm: (-[WKContentRuleListStore getAvailableContentRuleListIdentifiers:]): Use createNSArray. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _getActivePagesOriginsInWebProcessForTesting:completionHandler:]): Ditto. * UIProcess/API/Cocoa/WKUserScript.mm: (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:deferRunningUntilNotification:]): Use makeVector. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setupPageConfiguration:]): Use makeVector. * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration _corsDisablingPatterns]): Use createNSArray. (-[WKWebViewConfiguration _setCORSDisablingPatterns:]): Use makeVector. * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _contentsOfUserInterfaceItem:]): Use @(). * UIProcess/API/Cocoa/_WKContentRuleListAction.mm: (-[_WKContentRuleListAction notifications]): Use createNSArray. * UIProcess/API/Cocoa/_WKCustomHeaderFields.mm: (-[_WKCustomHeaderFields thirdPartyDomains]): Use createNSArray. (-[_WKCustomHeaderFields setThirdPartyDomains:]): Use makeVector. * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm: (-[_WKProcessPoolConfiguration cachePartitionedURLSchemes]): Use createNSArray. (-[_WKProcessPoolConfiguration setCachePartitionedURLSchemes:]): Use makeVector. (-[_WKProcessPoolConfiguration alwaysRevalidatedURLSchemes]): Use createNSArray. (-[_WKProcessPoolConfiguration setAlwaysRevalidatedURLSchemes:]): Use makeVector. * UIProcess/API/Cocoa/_WKUserContentWorldInternal.h: (API::toStringVector): Deleted. * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): Use makeVector. * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::accessibilityAttributeValue): Use @[]. (WebKit::WebViewImpl::performDragOperation): Use makeVector. (WebKit::WebViewImpl::namesOfPromisedFilesDroppedAtDestination): Use @[]. (WebKit::WebViewImpl::collectKeyboardLayoutCommandsForEvent): Use @[]. * UIProcess/Plugins/mac/PluginProcessProxyMac.mm: (WebKit::PluginProcessProxy::launchProcess): Use createNSArray. (WebKit::isJavaUpdaterURL): Use @[]. (WebKit::PluginProcessProxy::launchApplicationAtURL): Use @{} and createNSArray. (WebKit::isSilverlightPreferencesURL): Use @[]. * UIProcess/WebAuthentication/Cocoa/HidService.mm: (WebKit::HidService::HidService): Use @() and fixed an over-release mistake. This code was doing adoptNS on the result of +[NSNumberWithInt:], which is incorrect. * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm: (WebKit::MockLocalConnection::getAttestation const): Use @[]. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView textStylingAtPosition:inDirection:]): Use @(). (-[WKContentView requestRectsToEvadeForSelectionCommandsWithCompletionHandler:]): Use createNSArray. (-[WKContentView _itemsForBeginningOrAddingToSessionWithRegistrationLists:stagedDragSource:]): Fixed a wasteful call to autorelease where we are adding an item to a dictionary. Calling get is more efficient and still correct. * UIProcess/ios/forms/WKFileUploadPanel.mm: (-[WKFileUploadPanel imagePickerController:didFinishPickingMediaWithInfo:]): Use @[]. * UIProcess/ios/forms/WKFormColorPicker.mm: (-[WKColorMatrixView initWithFrame:colorMatrix:]): Removed uneeded RetainPtr local variable. * UIProcess/mac/CorrectionPanel.mm: (WebKit::CorrectionPanel::show): Use createNSArray. * UIProcess/mac/TextCheckerMac.mm: (WebKit::TextChecker::updateSpellingUIWithGrammarString): Use createNSArray. (WebKit::TextChecker::getGuessesForWord): Use makeVector. * UIProcess/mac/WKPrintingView.mm: (-[WKPrintingView _adjustPrintingMarginsForHeaderAndFooter]): Use @(). * UIProcess/mac/WKTextFinderClient.mm: (arrayFromRects): Deleted. (-[WKTextFinderClient didFindStringMatchesWithRects:didWrapAround:]): Use createNSArray. * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm: (-[WKDataListSuggestionsController notifyAccessibilityClients:]): Use @{} and fix a bug where this was creating a backwards dictionary. So this never could have been working before, making me wonder how we test it. * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::searchTheWeb): Use @[]. * WebProcess/InjectedBundle/API/mac/WKDOMInternals.h: Removed toNSArray. * WebProcess/InjectedBundle/API/mac/WKDOMInternals.mm: (WebKit::toNSArray): Deleted. * WebProcess/InjectedBundle/API/mac/WKDOMNode.mm: (-[WKDOMNode textRects]): Use createNSArray. * WebProcess/InjectedBundle/API/mac/WKDOMRange.mm: (-[WKDOMRange textRects]): Ditto. * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm: (WebKit::InjectedBundle::setBundleParameter): Use @{}. * WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm: (WebKit::makeRenderLayer): Use @[]. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::writeItemsToPasteboard): Use makeVector. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::applicationDidEnterBackground): Use @(). * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: (WebKit::TiledCoreAnimationDrawingArea::suspendPainting): Use @{}. (WebKit::TiledCoreAnimationDrawingArea::resumePainting): Use @{}. * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm: Removed an unneeded include. * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm: Ditto. (-[WKAccessibilityWebPageObject accessibilityActionNames]): Use @[]. (-[WKAccessibilityWebPageObject accessibilityChildren]): Use @[]. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::getActivePagesOriginsForTesting): Use makeVector. 2020-04-09 Megan Gardner Popovers are dismissed immediately when they try and bring up the keyboard. https://bugs.webkit.org/show_bug.cgi?id=210230 Reviewed by Darin Adler. When popovers use keyboards we dismiss them because the web view loses firstResponder. We already have ways of retaining focus when we lose first responde, so extend that code to cover the case where a keyboard comes up in a popover. We are also callling controlBeginEditing twice on refocusing a popover due to behaviour with touch and syntheticClick, so keep up from presenting the popover twice, and allow for the focus count to be correclty incremented and decremented. * UIProcess/ios/WKContentViewInteraction.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView preserveFocus]): (-[WKContentView releaseFocus]): * UIProcess/ios/forms/WKFormInputControl.mm: (-[WKDateTimePopover popoverWasDismissed:]): (-[WKDateTimePopover controlBeginEditing]): (-[WKDateTimePopover controlEndEditing]): 2020-04-09 David Kilzer Add using WTF::isInBounds to CheckedArithmetic.h Reviewed by Darin Adler. * Platform/IPC/ArgumentCoders.h: * Shared/UserData.cpp: (WebKit::UserData::decode): - Remove WTF:: prefix from isInBounds(). 2020-04-09 Keith Rollin Set ENTITLEMENTS_REQUIRED=NO for some Xcode build targets https://bugs.webkit.org/show_bug.cgi?id=210250 Reviewed by Jonathan Bedard. When building with the public version of Xcode 11.4, with XCBuild enabled, and targeting the iOS device, some build targets issue an error like: error: An empty identity is not valid when signing a binary for the product type 'Command-line Tool'. (in target 'yasm' from project 'libwebrtc') A comment in suggests setting ENTITLEMENTS_REQUIRED=NO to relax the requirement. To that end, when building with the public Xcode, establish that setting for the affected targets. * Configurations/GPUService.xcconfig: * Configurations/NetworkService.xcconfig: * Configurations/PluginProcessShim.xcconfig: * Configurations/PluginService.64.xcconfig: * Configurations/SecItemShim.xcconfig: * Configurations/WebContentService.xcconfig: 2020-04-09 Jacob Uphoff Unreviewed, reverting r259816. This commit broke the webkit build for macOS and iOS Reverted changeset: "Introduce a RealtimeMediaSource observer dedicated to receiving audio samples" https://bugs.webkit.org/show_bug.cgi?id=210180 https://trac.webkit.org/changeset/259816 2020-04-09 Simon Fraser eventSender.monitorWheelEvents() should clear latching state https://bugs.webkit.org/show_bug.cgi?id=210288 Reviewed by Tim Horton. Use monitorWheelEvents() as a trigger to clear scroll latching state, both main-thread (via Page) and scrolling thread (via ScrollingTree). Page::ensureWheelEventTestMonitor() had side-effects, so hide it, and have clients explicitly call Page::startMonitoringWheelEvents(). * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: (WKBundlePageStartMonitoringScrollOperations): (WKBundlePageRegisterScrollOperationCompletionCallback): 2020-04-09 Simon Fraser Reset view navigation gesture state between tests https://bugs.webkit.org/show_bug.cgi?id=210283 Reviewed by Tim Horton. State in ViewGestureController could leak between tests if a test did not wait for the gesture to complete. Specifically m_activeGestureType could be left as non-None. Fix by plumbing a 'reset' through from TestController::resetStateToConsistentValues(). The implementations leverage code from removeSwipeSnapshot(), but avoid the fact that removeSwipeSnapshot() early returns in various cases by just always calling reset code, which is factored into a new resetState function. * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _resetNavigationGestureStateForTesting]): * UIProcess/ViewGestureController.cpp: (WebKit::ViewGestureController::willBeginGesture): (WebKit::ViewGestureController::didEndGesture): (WebKit::ViewGestureController::PendingSwipeTracker::handleEvent): (WebKit::ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore): * UIProcess/ViewGestureController.h: * UIProcess/ios/ViewGestureControllerIOS.mm: (WebKit::ViewGestureController::removeSwipeSnapshot): (WebKit::ViewGestureController::resetState): (WebKit::ViewGestureController::reset): * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::removeSwipeSnapshot): (WebKit::ViewGestureController::resetState): (WebKit::ViewGestureController::reset): 2020-04-09 Ryan Haddad Unreviewed, reverting r259804. Breaks the watchOS build. Reverted changeset: "IPC serialization of enums should serialize std::underlying_type instead of uint64_t" https://bugs.webkit.org/show_bug.cgi?id=210228 https://trac.webkit.org/changeset/259804 2020-04-09 Youenn Fablet Introduce a RealtimeMediaSource observer dedicated to receiving audio samples https://bugs.webkit.org/show_bug.cgi?id=210180 Reviewed by Eric Carlson. Update SourceProxy to be an AudioSampleObserver. Update MediaRecorder to only listen for audio samples if GPU remote writer is successfully created. It also stops listening to audio samples as soon as stopping the recording. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy): (WebKit::UserMediaCaptureManagerProxy::SourceProxy::~SourceProxy): * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::~MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::audioSamplesAvailable): (WebKit::MediaRecorderPrivate::stopRecording): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: * WebProcess/GPU/webrtc/MediaRecorderProvider.cpp: (WebKit::MediaRecorderProvider::createMediaRecorderPrivate): * WebProcess/GPU/webrtc/MediaRecorderProvider.h: 2020-04-09 David Kilzer WTF::Persistence::Coder and WTF::Persistence::Decoder should use WARN_UNUSED_RETURN Reviewed by Darin Adler. * NetworkProcess/cache/NetworkCacheEntry.cpp: (WebKit::NetworkCache::Entry::decodeStorageRecord): - Add missing return value check for decode.decode(). 2020-04-09 Per Arne Vollan [iOS] Add routines to message filter in the WebContent sandbox https://bugs.webkit.org/show_bug.cgi?id=210293 Reviewed by Geoffrey Garen. Add required routines to the message filter in the WebContent process. This set of routines was compiled from local testing, and is therefore probably not the complete set. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-04-09 Megan Gardner [iOS] Date and time form controls are presented at the wrong size in some modes https://bugs.webkit.org/show_bug.cgi?id=210194 Reviewed by Tim Horton. Instead of relying on the default size for date/time controls, we should let the UIDatePicker determine its own size given the configuration we're going to use. * UIProcess/ios/forms/WKFormInputControl.mm: (-[WKDateTimePicker initWithView:datePickerMode:]): (-[WKDateTimePopover initWithView:datePickerMode:]): * UIProcess/ios/forms/WKFormSelectPopover.mm: (-[WKSelectPopover initWithView:hasGroups:]): 2020-04-08 Simon Fraser [Async overflow scroll] Horizontal scrolls can trigger unwanted back swipes https://bugs.webkit.org/show_bug.cgi?id=210095 Reviewed by Tim Horton. With async overflow/frame scrolling, EventDispatcher::wheelEvent() can't immediately determine whether the scrolling tree handled the scroll; we have to wait until the event has been processed by the scrolling thread. To allow that, add a ScrollingEventResult::SendToScrollingThread return value and a give tryToHandleWheelEvent() a callback that's called when the scrolling thread is done with the event. EventDispatcher uses that to send the "didReceiveEvent" with "handled" back to the UI process, which then proceeds with history or reading list swipes. Various fixes were necessary to correctly determine whether the event was handled. ScrollingTreeFrameScrollingNodeMac::handleWheelEvent() didn't return an accurate ScrollingEventResult, and ScrollController didn't return false in cases where rubber-banding was disabled (which broke navigation swipes and reading list navigation). * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: (WebKit::RemoteScrollingCoordinatorProxy::handleWheelEvent): * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp: (WebKit::RemoteScrollingTree::tryToHandleWheelEvent): * UIProcess/RemoteLayerTree/RemoteScrollingTree.h: * WebProcess/WebPage/EventDispatcher.cpp: (WebKit::EventDispatcher::wheelEvent): (WebKit::EventDispatcher::sendDidReceiveEvent): * WebProcess/WebPage/EventDispatcher.h: 2020-04-09 Alex Christensen IPC serialization of enums should serialize std::underlying_type instead of uint64_t https://bugs.webkit.org/show_bug.cgi?id=210228 Reviewed by Chris Dumez and Darin Adler. * Platform/IPC/Decoder.h: (IPC::Decoder::decode): (IPC::Decoder::operator>>): (IPC::Decoder::decodeEnum): * Platform/IPC/Encoder.h: * Shared/cf/ArgumentCodersCF.cpp: (IPC::encode): (IPC::decode): 2020-04-09 Youenn Fablet [MacOS] REGRESSION (r253275): Stopping a cloned audio capture track should not stop the original audio track https://bugs.webkit.org/show_bug.cgi?id=210259 Reviewed by Eric Carlson. We changed video track cloning so that each cloned track would get its own source. The source is getting video sample from the real capture source. The real capture source will get stopped if all its client sources are stopped. For audio, we are still using the same audio source for each track. We should thus not close the source until all its tracks are stopped. To do so, we reuse RealtimeMediaSource::requestToEnd instead of directly sending the order to stop observing the remote audio source. Test: fast/mediastream/mediastreamtrack-audio-clone.html * WebProcess/cocoa/UserMediaCaptureManager.cpp: (WebKit::UserMediaCaptureManager::Source::requestToEnd): (WebKit::UserMediaCaptureManager::Source::stopBeingObserved): Deleted. 2020-04-09 Claudio Saavedra [GTK] Clean-up use of deprecated GtkAction https://bugs.webkit.org/show_bug.cgi?id=210273 Reviewed by Carlos Garcia Campos. GtkAction is deprecated, however we use it because it's exposed in the public API. Guard deprecated API usage to remove warnings and update docs to not suggest using the deprecated API. * Shared/API/glib/WebKitContextMenuItem.cpp: * Shared/glib/WebContextMenuItemGlib.cpp: (WebKit::WebContextMenuItemGlib::buildActionName const): (WebKit::WebContextMenuItemGlib::createActionIfNeeded): 2020-04-09 David Kilzer UserData::decode should add bounds checks Reviewed by Alex Christensen. * Shared/UserData.cpp: (WebKit::UserData::decode): - Add bounds checks using WTF::isInBounds. * Shared/UserData.h: (WebKit::UserData::decode): - Add WARN_UNUSED_RETURN. 2020-04-09 David Kilzer Follow-up: WTF::Persistence::VectorCoder and IPC::VectorArgumentCoder should do bounds checking without crashing Reviewed by Alex Christensen. * Platform/IPC/ArgumentCoders.h: - Add missing call to decoder.markInvalid() if decoding of `decodedSize` fails. - Replace safeCast with isInBounds so that we don't crash if `decodedSize` is too big. Instead we fail decoding by marking the decoder invalid and returning early. - Revert checked arithemtic for multiplication since bufferIsLargeEnoughToContain WTF::Persistence::VectorCoder and IPC::VectorArgumentCoder should use checked arithmetic Reviewed by Alex Christensen. * Platform/IPC/ArgumentCoders.h: (IPC::VectorArgumentCoder::decode): - Use safeCast<> to cast from uint64_t to size_t. - Use checked arithemtic for multiplication. 2020-04-08 Alexey Proskuryakov Fix WebContent process launching after r259758. * WebProcess/com.apple.WebProcess.sb.in: 2020-04-08 Brady Eidson Enable incremental PDF loading. and https://bugs.webkit.org/show_bug.cgi?id=210241 Reviewed by Tim Horton. * FeatureFlags/WebKit.plist: 2020-04-08 David Kilzer UserMediaCaptureManagerProxy::clone should validate its parameters Reviewed by Alex Christensen. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (MESSAGE_CHECK): Define (and undef) new macro for assertion. (WebKit::UserMediaCaptureManagerProxy::clone): Change ASSERT() to MESSAGE_CHECK(). 2020-04-08 David Kilzer WebKit::ShareableBitmap::Handle::decode() should validate m_size instance variables Reviewed by Alex Christensen. * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::Handle::decode): Return early if either m_size instance variable is less than zero. 2020-04-08 Alex Christensen _corsDisablingPatterns should allow security policy access to those patterns https://bugs.webkit.org/show_bug.cgi?id=210218 Reviewed by Timothy Hatcher. * WebProcess/WebPage/WebPage.cpp: (WebKit::m_processDisplayName): 2020-04-08 Brent Fulgham REGRESSION(r257758): Launch time performance regression https://bugs.webkit.org/show_bug.cgi?id=210157 Reviewed by Alex Christensen. Address a launch time performance regression in the WebProcessPool constructor by starting a potentially slow server call in the constructor, and only waiting for its result if it has not been received when the value is needed. * UIProcess/WebProcessPool.cpp: (WebProcessPool::WebProcessPool): Start initialization function in constructor, rather than blocking for the 2020-04-08 Alex Christensen WKWebViews should behave as if they had loaded something after restoring session state https://bugs.webkit.org/show_bug.cgi?id=210097 Reviewed by Chris Dumez. Specifically, we don't want to close a WKWebView after restoring the session state into another WKWebView into it then navigating to a phishing page. We want to be at the previous page after the user clicks "Go back". * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::restoreFromSessionState): 2020-04-08 Kate Cheney Add curly braces after one line if statement for the case when we aren't using the internal SDK https://bugs.webkit.org/show_bug.cgi?id=210225 Reviewed by David Kilzer. * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::initializeAppBoundDomains): 2020-04-08 Brady Eidson Handle [PDFDocument initWithProvider:] returning nil and https://bugs.webkit.org/show_bug.cgi?id=210224 Reviewed by Geoff Garen. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::threadEntry): Treat a nil PDFDocument as "non-linearized, fallback to normal loading" 2020-04-08 Daniel Bates Track editable elements on screen https://bugs.webkit.org/show_bug.cgi?id=209888 Reviewed by Simon Fraser. Speed up -_requestTextInputContextsInRect when the rect does not intersect any editable elements by over 4450 times on reddit.com! Another way of saying this is that it reduces the time from an average of 303.252ms to 0.0680625ms in a Production build. This speed up is accomplished by having the web process track the rects of the editable elements on the page and send this information as a region data structure over to the UI process as part of the EventRegion object. This region is used to determine if there *may* be an editable element inside the rectangele. It never reports a false negative, but it can report a false positive: a rectangle is over an editable element when it actually isn't, (e.g. there is a non-composited element with a higher z-order than the editable element that intersects the search rect). * Configurations/FeatureDefines.xcconfig: Add feature define to track editable elements on screen (enabled by default on iOS and iOS Simulator). * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _mayContainEditableElementsInRect:]): Added. (-[WKWebView _requestTextInputContextsInRect:completionHandler:]): Checks if the search rects hits an editable element in a RemoteLayerTree node's editable region. If it does not hit any then we know there are no editable elements and return immediately. If it does hit something then we still need to ask the web process to perform a hit test to find the actual elements, respecting z-ordering (which is lost when these elements' rects are united to form the editable region). * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h: * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm: (WebKit::collectDescendantViewsInRect): Added. (WebKit::mayContainEditableElementsInRect): Added. 2020-04-08 Daniel Bates Should find touch-action elements inside non-composited iframes https://bugs.webkit.org/show_bug.cgi?id=210041 Reviewed by Simon Fraser. Pass EventRegionContext through. It is unused as it's not applicable for plugin painting. * WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::paint): * WebProcess/Plugins/PluginView.h: 2020-04-08 Brady Eidson Fix handling non-linearized PDFs when incremental PDF loading is enabled. and https://bugs.webkit.org/show_bug.cgi?id=210208 Reviewed by Tim Horton (and I think Geoff Garen, probably. It's confusing.) When we try to load a non-linearized PDF with PDFKit, it makes an outlandishly large range request to try to verify the PDF file size. That's covered by Meanwhile we need to detect that and fallback to non-incremental PDF loading. * WebProcess/Plugins/PDF/PDFPlugin.h: * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::receivedInvalidRangeRequest): (WebKit::dataProviderGetBytesAtPositionCallback): (WebKit::PDFPlugin::threadEntry): (WebKit::PDFPlugin::installPDFDocument): 2020-04-08 Per Arne Vollan Allow use of syscall from the WebContent sandbox https://bugs.webkit.org/show_bug.cgi?id=209920 Reviewed by Geoffrey Garen. Add syscall to the WebContent sandbox on macOS. * WebProcess/com.apple.WebProcess.sb.in: 2020-04-08 Per Arne Vollan [macOS] Crash under WebKit::SandboxExtension::consume https://bugs.webkit.org/show_bug.cgi?id=210188 Reviewed by Geoffrey Garen. When issuing a mach lookup extension to the database mapping service in the UI process fails, the WebContent process will crash when trying to consume the extension. No new tests, since I am not able to reproduce the issue. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/com.apple.WebProcess.sb.in: 2020-04-08 Rob Buis Make more use of FrameLoader pageID/frameID getters https://bugs.webkit.org/show_bug.cgi?id=210182 Reviewed by Chris Dumez. Make more use of FrameLoader pageID/frameID getters, before this change they were only used internally in FrameLoader. * WebProcess/Network/WebLoaderStrategy.cpp: (WebKit::addParametersShared): 2020-04-08 David Kilzer Follow-up: [iOS] WebPageProxy::didCommitLoadForFrame should not crash with null or empty `mimeType` parameter * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::didCommitLoadForMainFrame): - Remove UNUSED_PARAM() in lieu of deleting parameter names. 2020-04-08 Michael Catanzaro Remove unused WebProcessPool::sendToAllProcessesRelaunchingThemIfNecessary and WebProcessPool::sendToOneProcess https://bugs.webkit.org/show_bug.cgi?id=210199 Reviewed by Alex Christensen. Remove unused functions. * UIProcess/WebProcessPool.h: (WebKit::WebProcessPool::sendToAllProcessesRelaunchingThemIfNecessary): Deleted. (WebKit::WebProcessPool::sendToOneProcess): Deleted. 2020-04-08 Devin Rousso Web Inspector: only broadcast the console message to main frames https://bugs.webkit.org/show_bug.cgi?id=210122 Reviewed by Timothy Hatcher. * WebProcess/Network/NetworkProcessConnection.cpp: (WebKit::NetworkProcessConnection::broadcastConsoleMessage): 2020-04-08 Kate Cheney Return app-bound sessions for instances where WKAppBoundDomains is empty https://bugs.webkit.org/show_bug.cgi?id=210124 Reviewed by Brent Fulgham. No new tests. Behavior confirmed by existing In-App Browser Privacy tests. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::NetworkSessionCocoa::sessionWrapperForTask): Remove the flag checking if In-App Browser Privacy is enabled. We should return an app-bound session if WKAppBoundDomains is empty so we no longer need to check the flag here. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomain): (WebKit::WebPageProxy::decidePolicyForNavigationAction): * UIProcess/WebPageProxy.h: As described above, we no longer need to check the flag in this instance as we are determining behavior based on the WKAppBoundDomains list. Also moved the logic for checking an empty list to setIsNavigatingToAppBoundDomain, so it should take an Optional (WTF::nullopt indicates an empty list). * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::initializeAppBoundDomains): Use the flag to enable internal debugging for testing purposes. * UIProcess/API/APIHTTPCookieStore.cpp: (API::HTTPCookieStore::filterAppBoundCookies): Flag no longer needed. This should be gated by whether the domains list is empty or not. 2020-04-08 David Kilzer [iOS] WebPageProxy::didCommitLoadForFrame should not crash with null or empty `mimeType` parameter Reviewed by Chris Dumez. * UIProcess/API/ios/WKWebViewIOS.mm: (-[WKWebView _setHasCustomContentView:loadedMIMEType:]): - Extract logic for `representationClass` since -[WKWebViewContentProviderRegistry providerForMIMEType:] may return nil. * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: (-[WKWebViewContentProviderRegistry providerForMIMEType:]): - Add early return if `mimeType` is null or empty as those are not valid keys for `_contentProviderForMIMEType`. * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::didCommitLoadForMainFrame): - Add UNUSED_PARAM() for when -Wno-unused-parameter is removed in place of GCC_WARN_UNUSED_VARIABLE=YES. 2020-04-08 Brian Burg REGRESSION(r253346): some Automation commands targeted at an iframe do not return https://bugs.webkit.org/show_bug.cgi?id=210139 Reviewed by Devin Rousso. WebAutomationSession / WebAutomationSessionProxy are singletons, and only one exists at a time in the UIProcess / WebProcess respectively. A recent change was made to call Connection::sendWithAsyncReply from the WebPageProxy object rather than WebProcess. The effect of this is that the WebPage's destinationID is used for the response message rather than the WebProcess. Because WebAutomationSessionProxy registers itself as a global IPC message receiver, the page-targeted destinationID cannot find any receivers for the message at the destinationID, which causes an ASSERT in debug builds and a hang in non-debug builds. The fix is to continue sending messages via the WebProcess object, whose messages are tagged with a destinationID of 0 (eg, global message receiver). This could alternatively be accomplished by passing a destinationID of 0 to every sendWithAsyncReply, but as is this change is a straightforward partial revert of r253346. * UIProcess/Automation/WebAutomationSession.cpp: (WebKit::WebAutomationSession::switchToBrowsingContext): (WebKit::WebAutomationSession::evaluateJavaScriptFunction): (WebKit::WebAutomationSession::resolveChildFrameHandle): (WebKit::WebAutomationSession::resolveParentFrameHandle): (WebKit::WebAutomationSession::computeElementLayout): (WebKit::WebAutomationSession::selectOptionElement): (WebKit::WebAutomationSession::setFilesForInputFileUpload): (WebKit::WebAutomationSession::getAllCookies): (WebKit::WebAutomationSession::deleteSingleCookie): (WebKit::WebAutomationSession::takeScreenshot): 2020-04-08 Truitt Savell Unreviewed, reverting r259708. Broke the iOS device Build Reverted changeset: "Enable the use of XCBuild by default in Apple builds" https://bugs.webkit.org/show_bug.cgi?id=209890 https://trac.webkit.org/changeset/259708 2020-04-08 Chris Dumez Ref WebProcessProxy in NetworkProcessProxy::terminateUnresponsiveServiceWorkerProcesses() https://bugs.webkit.org/show_bug.cgi?id=210196 Reviewed by Youenn Fablet. Ref WebProcessProxy in NetworkProcessProxy::terminateUnresponsiveServiceWorkerProcesses() since the call to WebProcessProxy::disableServiceWorkers() may cause it to get destroyed otherwise. * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::terminateUnresponsiveServiceWorkerProcesses): 2020-04-08 Chris Dumez Regression(r259610) [RBSTarget targetWithPid:] may throw a 'must specify a valid pid' exception https://bugs.webkit.org/show_bug.cgi?id=210159 Reviewed by Alex Christensen. [RBSTarget targetWithPid:] may throw a 'must specify a valid pid' exception since r259610. There are apparently cases where the PID we are passing the ProcessAssertion is 0 (likely process crash on startup). BKSAssertion used to deal with this silently but RBSAssertion actually throws an exception in this case. To maintain the old behavior, we should do an explicit check to make sure the PID is valid before passing it to RunningBoard. * UIProcess/ios/ProcessAssertionIOS.mm: (WebKit::ProcessAssertion::ProcessAssertion): 2020-04-08 Claudio Saavedra [GTK] Drop usage of deprecated GdkDeviceManager https://bugs.webkit.org/show_bug.cgi?id=210179 Reviewed by Adrian Perez de Castro. Replace GdkDeviceManager usage for GdkSeat. For GTK4 further changes will be needed but this is a start. * UIProcess/gtk/ViewGestureControllerGtk.cpp: (WebKit::createScrollEvent): 2020-04-08 Carlos Garcia Campos Ensure base cache path exists before calculating disk cache capacity https://bugs.webkit.org/show_bug.cgi?id=209338 Reviewed by Adrian Perez de Castro. The base cache path might not exist yet in Cache::open() since it's Storage::open() the one calling FileSystem::makeAllDirectories() with the final cache directory. In such case, computeCapacity() fails because FileSystem::getVolumeFreeSpace() needs an existing file. * NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::Cache::open): 2020-04-08 Keith Rollin Enable the use of XCBuild by default in Apple builds https://bugs.webkit.org/show_bug.cgi?id=209890 Reviewed by Darin Adler. Switch from the "legacy" Xcode build system to the "new" build system (also known as "XCBuild"). Switching to the new system speeds up builds by a small percentage, better validates projects for build-related issues (such as dependency cycles), lets WebKit benefit from future improvements in XCBuild such as those coming from the underlying llbuild open source project, and prepares us for any other tools built for this new ecosystem. Specific changes: - Remove Xcode project and workspace settings that selected the Build system, allowing the default to take hold (which is currently the New build system). - Updated webkitdirs.pm with a terser check for Xcode version. - Update build-webkit and Makefile.shared to be explicit when using the old build system (no longer treat it as a default or fall-back configuration). - Update various xcconfig files similarly to treat the default as using the new build system. - Update various post-processing build steps to check for Xcode 11.4 and to no longer treat the default as using the old build system. * Configurations/WebKit.xcconfig: * WebKit.xcodeproj/project.pbxproj: 2020-04-07 Carlos Garcia Campos [GTK][WPE] WTR: fix handling of WebsiteDataStore https://bugs.webkit.org/show_bug.cgi?id=210106 Reviewed by Adrian Perez de Castro. Add WKContextSetPrimaryWebsiteDataStore() to expose WebProcessPool::setPrimaryDataStore(). * UIProcess/API/C/WKContext.cpp: (WKContextSetPrimaryWebsiteDataStore): * UIProcess/API/C/WKContextPrivate.h: 2020-04-07 Per Arne Vollan [iOS] Deny mach lookup access to the runningboard service in the WebContent process https://bugs.webkit.org/show_bug.cgi?id=209933 Reviewed by Chris Dumez. Creating the dependency process assertion in the WebContent process requires access to runningboard, but since this is only done on process startup, we can issue a temporary extension to the runningboard service, which will be immediately revoked after the process assertion has been created. Test: fast/sandbox/ios/sandbox-mach-lookup.html * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode const): (WebKit::WebProcessCreationParameters::decode): * Shared/WebProcessCreationParameters.h: * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::initializeConnection): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-04-07 John Wilander ITP Debug Mode logs should be more generic now that it blocks all third-party cookies by default https://bugs.webkit.org/show_bug.cgi?id=210133 Reviewed by Brent Fulgham. No new tests. Just a change of logging. * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking): Now logs if either vector has entries and uses more generic language. * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking): Now logs if either vector has entries and uses more generic language. * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: (WebKit::ResourceLoadStatisticsStore::debugLogDomainsInBatches): Removed hard-coded references to third-party cookie blocking and parameterized it instead. 2020-04-07 Joonghun Park Move the misplaced statement to the proper place where in RESOURCE_LOAD_STATISTICS macro. This patch removes the build warning below since r259275. warning: unused variable ‘sameSiteStrictEnforcementEnabled’ [-Wunused-variable] No new tests, no new behavior changes. * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::ensureNetworkProcess): 2020-04-07 Jiewen Tan [WebAuthn] Cancel WebAuthn requests when users cancel LocalAuthentication prompts https://bugs.webkit.org/show_bug.cgi?id=209923 Reviewed by Brent Fulgham. This patch intents to streamline WebAuthn local authenticator UX a bit more. Here, we should treat user cancellation of the LocalAuthentication UI as if it were being done on the UI Client's WebAuthn UI. * UIProcess/WebAuthentication/Authenticator.h: * UIProcess/WebAuthentication/AuthenticatorManager.cpp: (WebKit::AuthenticatorManager::cancelRequest): * UIProcess/WebAuthentication/AuthenticatorManager.h: * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.h: * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification): (WebKit::LocalAuthenticator::continueGetAssertionAfterUserVerification): (WebKit::LocalAuthenticator::validateUserVerification const): * UIProcess/WebAuthentication/Cocoa/LocalConnection.h: * UIProcess/WebAuthentication/Cocoa/LocalConnection.mm: (WebKit::LocalConnection::verifyUser const): * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm: (WebKit::MockLocalConnection::MockLocalConnection): (WebKit::MockLocalConnection::verifyUser const): (WebKit::MockLocalConnection::filterResponses const): * WebKit.xcodeproj/project.pbxproj: 2020-04-07 Sihui Liu [ macOS ] Update sandbox rules for storage https://bugs.webkit.org/show_bug.cgi?id=210120 Reviewed by Geoffrey Garen. This direcotry is used for cookie storage. * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: 2020-04-07 Ryan Haddad Unreviewed, reverting r259655. Caused assertion failures and timeouts on iOS bots Reverted changeset: "Return app-bound sessions for instances where WKAppBoundDomains is" https://bugs.webkit.org/show_bug.cgi?id=210124 https://trac.webkit.org/changeset/259655 2020-04-07 Chris Dumez Merge DependencyAssertion into ProcessAssertion https://bugs.webkit.org/show_bug.cgi?id=210076 Reviewed by Alex Christensen. Merge DependencyAssertion into ProcessAssertion. After r259610, ProcessAssertion can use RunningBoard assertions so there is no longer any need to a separate DependencyAssertion class. We can simply introduce a new assertion type to ProcessAssertion. * Shared/DependencyProcessAssertion.cpp: Removed. * Shared/DependencyProcessAssertion.h: Removed. * Shared/ios/DependencyProcessAssertionIOS.mm: Removed. * Sources.txt: * SourcesCocoa.txt: * UIProcess/ProcessAssertion.h: * UIProcess/ios/ProcessAssertionIOS.mm: (-[WKProcessAssertionBackgroundTaskManager init]): (-[WKProcessAssertionBackgroundTaskManager _hasBackgroundTask]): (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]): (-[WKProcessAssertionBackgroundTaskManager _releaseBackgroundTask]): (WebKit::runningBoardNameForAssertionType): * WebKit.xcodeproj/project.pbxproj: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::initializeConnection): * WebProcess/WebProcess.h: 2020-04-07 Alex Christensen Simplify and fortify network getNetworkProcessConnection and getGPUProcessConnection https://bugs.webkit.org/show_bug.cgi?id=210142 Reviewed by Youenn Fablet. We have reports of hangs inside WebKit::getNetworkProcessConnection that seem to last forever. Some of the reports indicate the network process is being suspended while a connection is being established with it. To fix this issue we do three things: 1. We take a foregroundActivity when sending an async message to establish a connection. 2. We use sendWithAsyncReply which already has logic to handle the case where we are currently launching the process. Instead of the complicated retry logic, we add a retry attempt in WebProcessPool if the connection identifier is invalid. 3. Add some release logging so we can better diagnose problems with this flow in the future. The functional change is adding the foreground activity, which should prevent some hangs. The rest is just to make this code more sane to understand and debug. I do the same changes to NetworkProcess and GPUProcess because they are intended to be the same. The latter is based on the former. The API test WebKit.NetworkProcessCrashWithPendingConnection covers what happens when the network process crashes during connection establishment. It fails if we don't retry somewhere, which I did in WebProcessPool. We also need to try again in getNetworkProcessConnection and getGPUProcessConnection. If it fails twice, there's nothing we can do, and we crash the web process to avoid a crash loop. * UIProcess/GPU/GPUProcessProxy.cpp: (WebKit::GPUProcessProxy::getGPUProcessConnection): (WebKit::GPUProcessProxy::didFinishLaunching): (WebKit::GPUProcessProxy::~GPUProcessProxy): Deleted. (WebKit::GPUProcessProxy::openGPUProcessConnection): Deleted. * UIProcess/GPU/GPUProcessProxy.h: * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::~NetworkProcessProxy): (WebKit::NetworkProcessProxy::getNetworkProcessConnection): (WebKit::NetworkProcessProxy::networkProcessCrashed): (WebKit::NetworkProcessProxy::didFinishLaunching): (WebKit::NetworkProcessProxy::openNetworkProcessConnection): Deleted. * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::networkProcessCrashed): (WebKit::WebProcessPool::getNetworkProcessConnection): (WebKit::WebProcessPool::getGPUProcessConnection): * UIProcess/WebProcessPool.h: * WebProcess/GPU/GPUProcessConnectionInfo.h: (WebKit::GPUProcessConnectionInfo::identifier const): (WebKit::GPUProcessConnectionInfo::identifier): Deleted. * WebProcess/Network/NetworkProcessConnectionInfo.h: (WebKit::NetworkProcessConnectionInfo::identifier const): (WebKit::NetworkProcessConnectionInfo::identifier): Deleted. 2020-04-07 Simon Fraser Use RectEdges<> in some scrolling tree code https://bugs.webkit.org/show_bug.cgi?id=210141 Reviewed by Tim Horton. Construct a RectEdges<>. Order is top, right, bottom, left. * WebProcess/WebPage/EventDispatcher.cpp: (WebKit::EventDispatcher::wheelEvent): 2020-04-07 Lauro Moura [GLIB] Avoid potential segfault in getPlatformEditorState https://bugs.webkit.org/show_bug.cgi?id=210149 Reviewed by Carlos Alberto Lopez Perez. Avoid potential surroundingRange dereference segfault. * WebProcess/WebPage/glib/WebPageGLib.cpp: (WebKit::WebPage::getPlatformEditorState const): 2020-04-07 Wenson Hsieh Preventing touch events should not prevent gestures installed above WKWebView from recognizing https://bugs.webkit.org/show_bug.cgi?id=210080 Reviewed by Tim Horton. Makes a small adjustment to native gesture deferral logic, so that gestures installed above WKWebView (in the view hierarchy) are not prevented from recognizing by WKDeferringGestureRecognizer. This makes it possible for WebKit clients to install custom gestures outside of WKWebView that cannot be prevented by web content, without having to create a separate window and pass touches through to the WKWebView. Test: fast/events/touch/ios/prevent-default-with-window-tap-gesture.html * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]): 2020-04-07 Brian Burg Web Automation: Automation.inspectBrowsingContext should bring Web Inspector to front automatically https://bugs.webkit.org/show_bug.cgi?id=210137 Reviewed by Joseph Pecoraro. * UIProcess/Automation/mac/WebAutomationSessionMac.mm: (WebKit::WebAutomationSession::inspectBrowsingContext): Previously, calling connect() would preload Web Inspector but not show its window. This made it awkward to use the 'safari:automaticInspection' capability without subsequently evaluating a `debugger;` statement to bring Web Inspector to front. 2020-04-07 Kate Cheney Return app-bound sessions for instances where WKAppBoundDomains is empty https://bugs.webkit.org/show_bug.cgi?id=210124 Reviewed by Brent Fulgham. No new tests. Behavior confirmed by existing In-App Browser Privacy tests. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::NetworkSessionCocoa::sessionWrapperForTask): Remove the flag checking if In-App Browser Privacy is enabled. We should return an app-bound session if WKAppBoundDomains is empty so we no longer need to check the flag here. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomain): (WebKit::WebPageProxy::decidePolicyForNavigationAction): * UIProcess/WebPageProxy.h: As described above, we no longer need to check the flag in this instance as we are determining behavior based on the WKAppBoundDomains list. Also moved the logic for checking an empty list to setIsNavigatingToAppBoundDomain, so it should take an Optional (WTF::nullopt indicates an empty list). * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::initializeAppBoundDomains): Use the flag to enable internal debugging for testing purposes. * UIProcess/API/APIHTTPCookieStore.cpp: (API::HTTPCookieStore::filterAppBoundCookies): Flag no longer needed. This should be gated by whether the domains list is empty or not. 2020-04-07 Per Arne Vollan [iOS] Add message to message filter in the WebContent sandbox https://bugs.webkit.org/show_bug.cgi?id=210130 Reviewed by Brent Fulgham. Add a required syscall-mach message to the message filter in the WebContent sandbox on iOS. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-04-07 Youenn Fablet REGRESSION (r259383-259384): ASSERTION FAILED: 'Completion handler should always be called' seen with http/wpt/service-workers/service-worker-different-process.https.html https://bugs.webkit.org/show_bug.cgi?id=209977 Reviewed by Chris Dumez. * UIProcess/AuxiliaryProcessProxy.cpp: (WebKit::AuxiliaryProcessProxy::~AuxiliaryProcessProxy): In case AuxiliaryProcessProxy has some enqueued messages but process crashes on launch for instance, we should call the completion handlers and fail. 2020-04-07 David Kilzer VisitedLinkStore.messages.in and VisitedLinkStore::addVisitedLinkHashFromPage() don't agree on type of `linkHash` Reviewed by Chris Dumez. * Scripts/webkit/messages.py: (types_that_cannot_be_forward_declared): - Don't forward-declare WebCore::SharedStringHash as a class since it is a uint32_t. * UIProcess/VisitedLinkStore.messages.in: - Use WebCore::SharedStringHash type for `linkHash` to fix the type mismatch. 2020-04-07 Chris Dumez Unreviewed, drop bad assertion introduced in r259610. On some bots (in particular OpenSource iOS ones), we are unable to take the assertion so this assertion does not hold true. * UIProcess/ios/ProcessAssertionIOS.mm: (WebKit::ProcessAssertion::ProcessAssertion): 2020-04-07 Rob Buis Use GlobalFrameIdentifier in NavigationAction https://bugs.webkit.org/show_bug.cgi?id=210036 Reviewed by Darin Adler. Adapt to API change. * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): 2020-04-06 Kate Cheney Create a way to signal if the WKAppBoundDomains list is empty https://bugs.webkit.org/show_bug.cgi?id=210074 Reviewed by Brent Fulgham. Updates the WebFramePolicyListener to return an Optional to signal if the WKAppBoundDomains list is empty. If so, we don't want to update any app-bound domain parameters in WebPageProxy. * UIProcess/WebFramePolicyListenerProxy.cpp: (WebKit::WebFramePolicyListenerProxy::didReceiveAppBoundDomainResult): * UIProcess/WebFramePolicyListenerProxy.h: * UIProcess/WebFrameProxy.cpp: (WebKit::WebFrameProxy::setUpPolicyListenerProxy): * UIProcess/WebFrameProxy.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::decidePolicyForNavigationAction): (WebKit::WebPageProxy::decidePolicyForNewWindowAction): (WebKit::WebPageProxy::decidePolicyForResponseShared): * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::beginAppBoundDomainCheck): Changed the WebFramePolicyListener to take a NavigatingToAppBoundDomain type as opposed to a boolean to allow it to handle the empty value. 2020-04-06 Chris Dumez [iOS] Transition most process assertions to RunningBoard https://bugs.webkit.org/show_bug.cgi?id=210065 Reviewed by Geoffrey Garen. Transition most process assertions to RunningBoard, instead of legacy BKSProcessAssertion. The only assertion that still uses BKSProcessAssertion is the MediaPlayback once because we do not have a RunningBoard equivalent for this one yet (see ). * UIProcess/ProcessAssertion.h: * UIProcess/ios/ProcessAssertionIOS.mm: (-[WKRBSAssertionDelegate assertionWillInvalidate:]): (-[WKRBSAssertionDelegate assertion:didInvalidateWithError:]): (WebKit::runningBoardNameForAssertionType): (WebKit::ProcessAssertion::ProcessAssertion): (WebKit::ProcessAssertion::~ProcessAssertion): (WebKit::ProcessAssertion::processAssertionWasInvalidated): 2020-04-06 Ross Kirsling Update minimum ICU version to 60.2 https://bugs.webkit.org/show_bug.cgi?id=209694 Reviewed by Darin Adler. * WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm: (-[WKDOMTextIterator currentTextPointer]): Manually convert between UChar and UniChar/unichar where needed. 2020-04-06 Simon Fraser Make ScrollableArea TextStream-loggable https://bugs.webkit.org/show_bug.cgi?id=210042 Reviewed by Darin Adler. ScrollableArea is a pure virtual base class, so has to dump via a virtual function, so add debugDescription() and implement it in derived classes. Make the common pattern be that operator<<(TextStream&, ...) calls debugDescription. * UIProcess/win/WebPopupMenuProxyWin.cpp: (WebKit::WebPopupMenuProxyWin::debugDescription const): * UIProcess/win/WebPopupMenuProxyWin.h: * WebProcess/Plugins/PDF/PDFPlugin.h: * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::debugDescription const): 2020-04-06 Commit Queue Unreviewed, reverting r259469. https://bugs.webkit.org/show_bug.cgi?id=210066 Introduced media playback regression (Requested by perarne on #webkit). Reverted changeset: "[iOS] Deny mach lookup access to the runningboard service in the WebContent process" https://bugs.webkit.org/show_bug.cgi?id=209933 https://trac.webkit.org/changeset/259469 2020-04-06 Per Arne Vollan Unreviewed sandbox compile fix. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-04-06 Víctor Manuel Jáquez Leal [GTK] Remove unused header in web process https://bugs.webkit.org/show_bug.cgi?id=210053 Reviewed by Michael Catanzaro. Remove unused headers from code removed in r203774. No new tests required. * WebProcess/gtk/WebProcessMainGtk.cpp: 2020-04-06 Dean Jackson CrashTracer: MobileSafari at WebKit: WebKit::SystemPreviewController::updateProgress https://bugs.webkit.org/show_bug.cgi?id=210040 rdar://51410841 Reviewed by Darin Adler. It appears that the SystemPreviewController on WebPageProxy can become null causing a call to an in-progress download to crash as it tries to talk to the QuickLook delegate. Guard against this by checking the SystemPreviewController each time. * UIProcess/Cocoa/DownloadClient.mm: (WebKit::systemPreviewController): (WebKit::DownloadClient::didReceiveResponse): (WebKit::DownloadClient::didReceiveData): (WebKit::DownloadClient::processDidCrash): (WebKit::DownloadClient::didFinish): (WebKit::DownloadClient::didFail): (WebKit::DownloadClient::didCancel): 2020-04-06 Chris Dumez ProcessAssertion should use ASCIILiteral for its reason https://bugs.webkit.org/show_bug.cgi?id=210049 Reviewed by Alex Christensen. ProcessAssertion should use ASCIILiteral for its reason, instead of a String. * Shared/ios/DependencyProcessAssertionIOS.mm: (WebKit::DependencyProcessAssertion::DependencyProcessAssertion): * UIProcess/ProcessAssertion.cpp: (WebKit::ProcessAssertion::ProcessAssertion): * UIProcess/ProcessAssertion.h: * UIProcess/ios/ProcessAssertionIOS.mm: (WebKit::ProcessAssertion::ProcessAssertion): (WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion): 2020-04-04 Darin Adler Stop using live ranges in DocumentMarkerController https://bugs.webkit.org/show_bug.cgi?id=209985 Reviewed by Antti Koivisto. * UIProcess/ViewSnapshotStore.h: Removed unused "Cocoa without IOSurface" code paths. * UIProcess/mac/ViewSnapshotStoreMac.mm: (WebKit::ViewSnapshot::create): Ditto. (WebKit::ViewSnapshot::ViewSnapshot): Ditto. (WebKit::ViewSnapshot::setSurface): Ditto. (WebKit::ViewSnapshot::hasImage const): Ditto. (WebKit::ViewSnapshot::clearImage): Ditto. (WebKit::ViewSnapshot::setVolatile): Ditto. (WebKit::ViewSnapshot::asLayerContents): Ditto. (WebKit::ViewSnapshot::asImageForTesting): Ditto. (WebKit::ViewSnapshotStore::snapshottingContext): Deleted. * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm: (WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): Updated since addPlatformTextCheckingMarker no longer exists. (WebKit::TextCheckingControllerProxy::removeAnnotationRelativeToSelection): Updated since filterMarkers passes a reference instead of a pointer now. (WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): Simplified code a bit by removing local variables. * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::dictionaryPopupInfoForRange): Use RenderObject::absoluteTextQuads. * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::performImmediateActionHitTestAtLocation): Use RenderObject::absoluteTextQuads and unitedBoundingBoxes. 2020-04-06 Per Arne Vollan Add syscall to the WebContent sandbox https://bugs.webkit.org/show_bug.cgi?id=210048 Reviewed by Brent Fulgham. Add a required syscall to the WebContent sandbox on iOS and macOS. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: * WebProcess/com.apple.WebProcess.sb.in: 2020-04-06 youenn fablet Add HEVC support in GPU Process for WebRTC https://bugs.webkit.org/show_bug.cgi?id=209857 Reviewed by Eric Carlson. * GPUProcess/webrtc/LibWebRTCCodecsProxy.h: * GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in: * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm: (WebKit::LibWebRTCCodecsProxy::createH264Decoder): (WebKit::LibWebRTCCodecsProxy::createH265Decoder): (WebKit::LibWebRTCCodecsProxy::createEncoder): (WebKit::LibWebRTCCodecsProxy::createDecoder): Deleted. * WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp: (WebKit::createVideoDecoder): (WebKit::createVideoEncoder): (WebKit::LibWebRTCCodecs::createDecoder): (WebKit::formatNameFromCodecType): (WebKit::LibWebRTCCodecs::createEncoder): * WebProcess/GPU/webrtc/LibWebRTCCodecs.h: 2020-04-05 Don Olmstead [CMake] Add WebKit::WebKit target https://bugs.webkit.org/show_bug.cgi?id=210033 Reviewed by Fujii Hironori. Use WEBKIT_EXECUTABLE macros for the Process executables. Rename the output file names to fit with the macro's expectations. Add Headers.cmake which lists out all the public headers that are currently shared by the PlayStation and Windows ports. This is then included on each platform that is using it. Additionally use WEBKIT_COPY_FILES to create a target which copies headers. Finally use WEBKIT_FRAMEWORK_TARGET to create a WebKit target. Its dependent on the WebKit library itself, the processes being built, and any headers that are copied. This ensures that everything is built for dependent targets. * CMakeLists.txt: * Headers.cmake: Copied from Source/WebKit/PlatformPlayStation.cmake. * PlatformFTW.cmake: * PlatformGTK.cmake: * PlatformMac.cmake: * PlatformPlayStation.cmake: * PlatformWPE.cmake: * PlatformWin.cmake: 2020-04-05 Zan Dobersek Unreviewed, adding missing header inclusions to get non-unified build building. * Shared/UserContentControllerParameters.cpp: 2020-04-04 Wenson Hsieh Add a fourth round of logging to help diagnose https://bugs.webkit.org/show_bug.cgi?id=210011 Reviewed by Darin Adler. Remove all logging previously added to WKContentView and DragDropInteractionState. * UIProcess/ios/DragDropInteractionState.mm: (WebKit::DragDropInteractionState::stageDragItem): (WebKit::DragDropInteractionState::clearStagedDragSource): * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _didHandleDragStartRequest:]): 2020-04-04 Chris Dumez [iOS] Simplify ProcessAssertion class in preparation for switch to RunningBoard https://bugs.webkit.org/show_bug.cgi?id=209984 Reviewed by Darin Adler. Simplify ProcessAssertion class in preparation for switch to RunningBoard. There is a slight mismatch between the way BKS and RunningBoard process assertion API. This refactoring makes it so that we can use the same ProcessAssertion class in WebKit to work with either BKS or RunningBoard. Support for RunningBoard will come later. In particular, the following changes were made: - Replace AssertionState & AssertionReason enums with a single ProcessAssertionType one since RunningBoard does not have 2 separate concepts. - Drop ProcessAssertion::setState() since it is not possible to change the flags on an existing RunningBoard assertion. Instead, we are expected to create a brand new process assertion of the expected type. * NetworkProcess/Downloads/DownloadMap.cpp: (WebKit::DownloadMap::add): * Platform/IPC/cocoa/ConnectionCocoa.mm: (IPC::ConnectionTerminationWatchdog::ConnectionTerminationWatchdog): * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _setAssertionTypeForTesting:]): (-[WKWebView _setAssertionStateForTesting:]): Deleted. * UIProcess/Downloads/DownloadProxyMap.cpp: (WebKit::DownloadProxyMap::createDownloadProxy): * UIProcess/GPU/GPUProcessProxy.h: * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::sendProcessDidResume): (WebKit::NetworkProcessProxy::takeUploadAssertion): (WebKit::NetworkProcessProxy::didSetAssertionState): Deleted. * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/ProcessAssertion.cpp: (WebKit::ProcessAssertion::ProcessAssertion): (WebKit::ProcessAssertion::setState): Deleted. * UIProcess/ProcessAssertion.h: (WebKit::ProcessAssertion::type const): (WebKit::ProcessAssertion::state const): Deleted. * UIProcess/ProcessThrottler.cpp: (WebKit::ProcessThrottler::expectedAssertionType): (WebKit::ProcessThrottler::updateAssertionTypeNow): (WebKit::ProcessThrottler::setAssertionType): (WebKit::ProcessThrottler::updateAssertionIfNeeded): (WebKit::ProcessThrottler::didConnectToProcess): (WebKit::ProcessThrottler::prepareToSuspendTimeoutTimerFired): (WebKit::ProcessThrottler::processReadyToSuspend): (WebKit::ProcessThrottler::sendPrepareToSuspendIPC): (WebKit::ProcessThrottler::expectedAssertionState): Deleted. (WebKit::ProcessThrottler::updateAssertionStateNow): Deleted. (WebKit::ProcessThrottler::setAssertionState): Deleted. * UIProcess/ProcessThrottler.h: * UIProcess/ProcessThrottlerClient.h: (WebKit::ProcessThrottlerClient::didSetAssertionType): * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::setWebProcessHasUploads): (WebKit::WebProcessPool::setWebProcessIsPlayingAudibleMedia): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::didSetAssertionType): (WebKit::WebProcessProxy::didSetAssertionState): Deleted. * UIProcess/WebProcessProxy.h: (WebKit::WebProcessProxy::setAssertionTypeForTesting): (WebKit::WebProcessProxy::setAssertionStateForTesting): Deleted. * UIProcess/ios/ProcessAssertionIOS.mm: (WebKit::flagsForAssertionType): (WebKit::toBKSProcessAssertionReason): (WebKit::ProcessAssertion::ProcessAssertion): (WebKit::ProcessAndUIAssertion::updateRunInBackgroundCount): (WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion): (WebKit::flagsForState): Deleted. (WebKit::reasonForState): Deleted. (WebKit::ProcessAssertion::setState): Deleted. (WebKit::ProcessAndUIAssertion::setState): Deleted. 2020-04-04 David Kilzer [GPUP] Remove unnecessary RemoteCDMInstanceSessionIdentifier argument from RemoteCDMFactory::addSession() Reviewed by Darin Adler. * WebProcess/GPU/media/RemoteCDMFactory.cpp: (WebKit::RemoteCDMFactory::addSession): - Remove argument. Use `session` parameter to retrieve the ID. * WebProcess/GPU/media/RemoteCDMFactory.h: (WebKit::RemoteCDMFactory::addSession): - Remove argument. * WebProcess/GPU/media/RemoteCDMInstance.cpp: (WebKit::RemoteCDMInstance::createSession): - Remove argument. 2020-04-04 Wenson Hsieh Add even more logging to try and diagnose https://bugs.webkit.org/show_bug.cgi?id=210008 Reviewed by Tim Horton. Revert all (except one) of the logging statements added in r259518, and add several new ones. This last logging pass demonstrated that DragController had failed to start a drag, since -[WKContentView _didHandleDragStartRequest:] receives word that the drag has started, yet there are no staged drag items. * UIProcess/ios/DragDropInteractionState.mm: (WebKit::DragDropInteractionState::stageDragItem): (WebKit::DragDropInteractionState::clearStagedDragSource): * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _didHandleAdditionalDragItemsRequest:]): (-[WKContentView cleanUpDragSourceSessionState]): (-[WKContentView _didPerformDragOperation:]): (-[WKContentView _prepareToDragPromisedAttachment:]): (-[WKContentView _dragInteraction:prepareForSession:completion:]): (-[WKContentView dragInteraction:itemsForBeginningSession:]): (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]): (-[WKContentView dragInteraction:sessionWillBegin:]): (-[WKContentView dragInteraction:session:didEndWithOperation:]): (-[WKContentView dragInteraction:item:willAnimateCancelWithAnimator:]): (-[WKContentView dropInteraction:canHandleSession:]): (-[WKContentView dropInteraction:sessionDidEnter:]): (-[WKContentView dropInteraction:sessionDidExit:]): (-[WKContentView dropInteraction:performDrop:]): (-[WKContentView dropInteraction:sessionDidEnd:]): 2020-04-03 David Kilzer WebPlatformStrategies::{readBufferFromPasteboard,bufferForType} should validate their `size` parameter Reviewed by Wenson Hsieh. * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: (WebKit::WebPlatformStrategies::bufferForType): (WebKit::WebPlatformStrategies::readBufferFromPasteboard): - Validate the `size` parameter. 2020-04-03 Wenson Hsieh The IPC message “registerAttachmentsFromSerializedData" should be capitalized https://bugs.webkit.org/show_bug.cgi?id=209995 Reviewed by Tim Horton. Tweak the name of this IPC message so that it begins with a capital letter. No change in behavior. * UIProcess/WebPageProxy.messages.in: * WebProcess/WebCoreSupport/WebEditorClient.cpp: (WebKit::WebEditorClient::registerAttachments): 2020-04-03 Alex Christensen Add SPI to make WKUserScripts wait for a notification https://bugs.webkit.org/show_bug.cgi?id=209845 Reviewed by Chris Dumez. * Shared/API/c/WKSharedAPICast.h: (WebKit::toUserScriptInjectionTime): (WebKit::toWKUserScriptInjectionTime): (WebKit::toUserContentInjectedFrames): * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * Shared/WebUserContentControllerDataTypes.cpp: (WebKit::WebUserScriptData::decode): * UIProcess/API/APIPageConfiguration.h: (API::PageConfiguration::userScriptsShouldWaitUntilNotification const): (API::PageConfiguration::setUserScriptsShouldWaitUntilNotification): * UIProcess/API/APIUserScript.h: * UIProcess/API/C/WKPageGroup.cpp: (WKPageGroupAddUserScript): * UIProcess/API/C/WKUserScriptRef.cpp: (WKUserScriptCreateWithSource): (WKUserScriptGetMainFrameOnly): * UIProcess/API/Cocoa/WKUserScript.mm: (-[WKUserScript initWithSource:injectionTime:forMainFrameOnly:]): (-[WKUserScript isForMainFrameOnly]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:userContentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:contentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:]): (-[WKUserScript _initWithSource:injectionTime:forMainFrameOnly:legacyWhitelist:legacyBlacklist:associatedURL:contentWorld:waitForNotification:]): * UIProcess/API/Cocoa/WKUserScriptInternal.h: (API::toWebCoreUserScriptInjectionTime): (API::toWKUserScriptInjectionTime): * UIProcess/API/Cocoa/WKUserScriptPrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _notifyUserScripts]): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration _userScriptsShouldWaitUntilNotification]): (-[WKWebViewConfiguration _setUserScriptsShouldWaitUntilNotification:]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/Cocoa/_WKUserStyleSheet.mm: (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:]): (-[_WKUserStyleSheet initWithSource:forWKWebView:forMainFrameOnly:userContentWorld:]): (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:userContentWorld:]): (-[_WKUserStyleSheet initWithSource:forMainFrameOnly:legacyWhitelist:legacyBlacklist:baseURL:userContentWorld:]): (-[_WKUserStyleSheet isForMainFrameOnly]): * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.h: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserScriptInternal): * WebProcess/WebPage/WebPage.cpp: (WebKit::m_processDisplayName): (WebKit::WebPage::notifyUserScripts): (WebKit::WebPage::addUserScript): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: 2020-04-03 Alex Christensen Use AuthenticationChallenge instead of AuthenticationChallengeProxy for ResourceLoadDelegate https://bugs.webkit.org/show_bug.cgi?id=207639 Reviewed by David Kilzer. In r254345 my younger and more naive self used AuthenticationChallengeProxy instead of AuthenticationChallenge because he didn't know about the WebCore::mac function, which is called by AuthenticationChallengeProxy, and it's all I needed to get an NSURLAuthenticationChallenge. Skipping the AuthenticationChallengeProxy step cleans up AuthenticationChallengeProxy by removing the unnecessary ability to have a null CompletionHandler. Covered by existing tests. * UIProcess/API/APIResourceLoadClient.h: * UIProcess/Authentication/AuthenticationChallengeProxy.cpp: (WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy): (): Deleted. * UIProcess/Cocoa/ResourceLoadDelegate.h: * UIProcess/Cocoa/ResourceLoadDelegate.mm: (WebKit::ResourceLoadDelegate::ResourceLoadClient::didReceiveChallenge const): * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::resourceLoadDidReceiveChallenge): * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.h: 2020-04-03 Kate Cheney Prevent non app-bound domain cookies from being read or set using API calls https://bugs.webkit.org/show_bug.cgi?id=209926 Reviewed by Brady Eidson. This patch filters out setting and fetching of cookies via API call to only set or return app-bound cookies. * UIProcess/API/APIHTTPCookieStore.cpp: (API::HTTPCookieStore::filterAppBoundCookies): This function queries the websiteDataStore for the WKAppBoundDomains entries and filters out non app-bound domains. (API::HTTPCookieStore::cookies): (API::HTTPCookieStore::cookiesForURL): (API::HTTPCookieStore::setCookies): These functions were updated to set/return the cookies after they've been filtered through the WKAppBoundDomains. * UIProcess/API/APIHTTPCookieStore.h: * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: (-[WKWebsiteDataStore _appBoundDomains:]): * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::getAppBoundDomains const): (WebKit::WebsiteDataStore::appBoundDomainsForTesting const): Deleted. Utilize a function formerly used for testing only to be used in the HTTPCookieStore. * UIProcess/WebsiteData/WebsiteDataStore.h: 2020-04-03 Wenson Hsieh Add more logging to help diagnose https://bugs.webkit.org/show_bug.cgi?id=209988 Reviewed by Timothy Hatcher. Replace logging that was previously added in r259465 with different logging. The fact that the prior logging never showed up in the failing tests suggests that the problem happens earlier than I had expected, so we need to ensure that codepaths for preparing and beginning a drag session are logged instead. This turns several existing `RELEASE_LOG`s in WKContentView into `NSLog`s, so that they will show up in test failure output when run on the bots. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _didHandleAdditionalDragItemsRequest:]): (-[WKContentView _didHandleDragStartRequest:]): (-[WKContentView cleanUpDragSourceSessionState]): (-[WKContentView _didPerformDragOperation:]): (-[WKContentView _prepareToDragPromisedAttachment:]): (-[WKContentView _dragInteraction:prepareForSession:completion:]): (-[WKContentView dragInteraction:itemsForBeginningSession:]): (-[WKContentView dragInteraction:willAnimateLiftWithAnimator:session:]): (-[WKContentView dragInteraction:sessionWillBegin:]): (-[WKContentView dragInteraction:session:didEndWithOperation:]): (-[WKContentView dragInteraction:item:willAnimateCancelWithAnimator:]): (-[WKContentView dropInteraction:canHandleSession:]): (-[WKContentView dropInteraction:sessionDidEnter:]): (-[WKContentView dropInteraction:sessionDidUpdate:]): (-[WKContentView dropInteraction:sessionDidExit:]): (-[WKContentView dropInteraction:performDrop:]): (-[WKContentView dropInteraction:sessionDidEnd:]): 2020-04-03 Chris Dumez [iOS] Give RunningBoard entitlement to all our child processes https://bugs.webkit.org/show_bug.cgi?id=209986 Reviewed by Geoffrey Garen. Give RunningBoard entitlement to all our child processes on iOS. As we are transitioning to RunningBoard process assertions, it is important for the target process of those assertion to have the com.apple.runningboard.assertions.webkit entitlement. * Scripts/process-entitlements.sh: 2020-04-03 Truitt Savell Unreviewed, reverting r259440. Introduced 2 failing tests on Mac and iOS Reverted changeset: "Add SPI to configure WebsiteDataStores with a URL for standalone web applications and use it to disable first-party website data removal in ITP" https://bugs.webkit.org/show_bug.cgi?id=209634 https://trac.webkit.org/changeset/259440 2020-04-03 Tim Horton Add a visual debug indicator for locating and identifying all kinds of WebViews https://bugs.webkit.org/show_bug.cgi?id=209982 Reviewed by Simon Fraser. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _initializeWithConfiguration:]): * UIProcess/API/mac/WKView.mm: (-[WKView initWithFrame:processPool:configuration:]): Adopt in WKWebView and WKView. 2020-04-03 Kate Cheney Remove _setIsNavigatingToAppBoundDomain testing SPI https://bugs.webkit.org/show_bug.cgi?id=209973 Reviewed by David Kilzer. This SPI is no longer needed to set a webView as navigating to an app-bound domain. We can now load a local file instead. No new tests, confirmed behavior by existing tests. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setIsNavigatingToAppBoundDomain:completionHandler:]): Deleted. * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomainTesting): Deleted. * UIProcess/WebPageProxy.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setIsNavigatingToAppBoundDomainTesting): Deleted. * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: 2020-04-03 Per Arne Vollan Unreviewed sandbox compile fix. * WebProcess/com.apple.WebProcess.sb.in: 2020-04-03 David Kilzer [Cocoa] Update MESSAGE_CHECK macros used in WebProcessProxy::didCreateSleepDisabler/WebProcessProxy::didDestroySleepDisabler Reviewed by Darin Adler. * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::didCreateSleepDisabler): - Remove MESSAGE_CHECK for `identifier` since decoding detects invalid values. - Add MESSAGE_CHECK for `reason` since a NULL string would cause CFStringCreateWithCString() to crash later. (WebKit::WebProcessProxy::didDestroySleepDisabler): - Remove MESSAGE_CHECK for `identifier` since decoding detects invalid values. 2020-04-03 Megan Gardner Color Form Control does not come up on second selection in macCatalyst https://bugs.webkit.org/show_bug.cgi?id=209939 Reviewed by Wenson Hsieh. On selection and manual dismissal of the form, we need to also call accessoryDone, as the UIKit callbacks are not called on manual dismissal. * UIProcess/ios/forms/WKFormColorPicker.mm: (-[WKColorPicker colorMatrixView:didTapColorButton:]): 2020-04-03 Brent Fulgham [macOS] Update sandbox rules for correct sanitizer paths in current OS releases https://bugs.webkit.org/show_bug.cgi?id=209818 Unreviewed follow-up based on feedback from the sanitizer team. The change in r259317 left the original, incorrect, 'literal' form of the path, rather than the correct 'subpath' form. This corrects that issue. * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: * WebProcess/com.apple.WebProcess.sb.in: 2020-04-03 Brent Fulgham Remove unneeded sandbox access to some file paths https://bugs.webkit.org/show_bug.cgi?id=209938 Reviewed by Per Arne Vollan. Remove unnecessary access to some locations in /etc. These may have been needed in the past, but the WebContent process no longer requires this access. We should remove it. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: * WebProcess/com.apple.WebProcess.sb.in: 2020-04-03 Per Arne Vollan [iOS] Deny mach lookup access to the runningboard service in the WebContent process https://bugs.webkit.org/show_bug.cgi?id=209933 Reviewed by Brent Fulgham. On iOS, after , mach lookup access to "com.apple.runningboard" can be denied in the WebContent process. Test: fast/sandbox/ios/sandbox-mach-lookup.html * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-04-03 Diego Pino Garcia REGRESSION(r259401): [GTK] Check surroundingRange is not null https://bugs.webkit.org/show_bug.cgi?id=209966 Reviewed by Darin Adler & Philippe Normand. * WebProcess/WebPage/glib/WebPageGLib.cpp: (WebKit::WebPage::getPlatformEditorState const): 2020-04-03 David Kilzer [Xcode] Replace ASAN_OTHER_CFLAGS and ASAN_OTHER_CPLUSPLUSFLAGS with $(inherited) Reviewed by Alexey Proskuryakov. * Configurations/Base.xcconfig: - Remove ASAN_OTHER_CFLAGS, ASAN_OTHER_CPLUSPLUSFLAGS and ASAN_OTHER_LDFLAGS. 2020-04-03 Wenson Hsieh Add logging to help diagnose https://bugs.webkit.org/show_bug.cgi?id=209967 Reviewed by Darin Adler. See WebCore/ChangeLog. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView dropInteraction:sessionDidUpdate:]): 2020-04-03 youenn fablet ServiceWorkerFetchTask::timeoutTimerFired should not call contextClosed https://bugs.webkit.org/show_bug.cgi?id=209906 Reviewed by Chris Dumez. Covered by http/tests/workers/service/basic-timeout.https.html no longer crashing. * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: (WebKit::ServiceWorkerFetchTask::timeoutTimerFired): We should not call contextClosed now that we are nullying m_swServerConnection in contextClosed. Instead, we should just call cannotHandle since the timer can only fire if we have not yet received any response. 2020-04-03 Adrian Perez de Castro Unreviewed fix after r259382 Rubber-stamped by Carlos Garcia Campos. No new tests needed. * UIProcess/API/glib/WebKitWebContext.cpp: (webkit_web_context_register_uri_scheme): Change g_return_if_fail() calls to actually check that the passed scheme is not one of the special ones. 2020-04-03 youenn fablet Add initial support for WebRTC HEVC https://bugs.webkit.org/show_bug.cgi?id=204283 Reviewed by Eric Carlson. Remove VP8 runtime flag and add a H365 runtime flag instead. * Shared/WebPreferences.yaml: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): 2020-04-03 Yousuke Kimoto FileSystem handle leaks in CurlCacheManager and NetworkCacheData when failed to open a file https://bugs.webkit.org/show_bug.cgi?id=209949 Reviewed by Fujii Hironori. A file handle of FileSystem is not closed when the file handle doesn't return its status. The handle should be released before returning. No new tests, no behavior change. * NetworkProcess/cache/NetworkCacheData.cpp: (WebKit::NetworkCache::mapFile): 2020-04-03 Peng Liu WebCore::HTMLMediaElement::mediaCanStart crashes https://bugs.webkit.org/show_bug.cgi?id=209950 Reviewed by Jer Noble. UserMediaPermissionRequestManager does not need to inherit from CanMakeWeakPtr because its parent class MediaCanStartListener supports WeakPtr now. * WebProcess/MediaStream/UserMediaPermissionRequestManager.h: 2020-04-02 John Wilander Add SPI to configure WebsiteDataStores with a URL for standalone web applications and use it to disable first-party website data removal in ITP https://bugs.webkit.org/show_bug.cgi?id=209634 Reviewed by Alex Christensen. This change adds a new property to _WKWebsiteDataStoreConfiguration.h called standaloneApplicationURL with which the hosting application can inform the website data store that it's running as a standalone web application. This change also forwards an existing standaloneApplicationURL as a WebCore::RegistrableDomain into ITP so that explicit exemptions can be made to first parties of standalone web applications. The exemptions made here all for all of ITP's website data removal. This part of the change is covered by the new layout tests. Tests: http/tests/resourceLoadStatistics/standalone-web-application-exempt-from-website-data-deletion-database.html http/tests/resourceLoadStatistics/standalone-web-application-exempt-from-website-data-deletion.html * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: (WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToDeleteOrRestrictWebsiteDataFor): * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: (WebKit::ResourceLoadStatisticsStore::setStandaloneApplicationDomain): (WebKit::ResourceLoadStatisticsStore::standaloneApplicationDomain const): * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::setStandaloneApplicationDomain): * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): (WebKit::NetworkSession::forwardResourceLoadStatisticsSettings): * NetworkProcess/NetworkSession.h: * Shared/ResourceLoadStatisticsParameters.h: (WebKit::ResourceLoadStatisticsParameters::encode const): (WebKit::ResourceLoadStatisticsParameters::decode): * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h: * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm: (-[_WKWebsiteDataStoreConfiguration standaloneApplicationURL]): (-[_WKWebsiteDataStoreConfiguration setStandaloneApplication:]): * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::ensureNetworkProcess): * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::platformSetNetworkParameters): * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp: (WebKit::WebsiteDataStoreConfiguration::copy const): * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h: (WebKit::WebsiteDataStoreConfiguration::standaloneApplicationURL const): (WebKit::WebsiteDataStoreConfiguration::setStandaloneApplicationURL): 2020-04-02 Per Arne Vollan Unreviewed build fix after r259396. * Shared/mac/AuxiliaryProcessMac.mm: 2020-04-02 David Kilzer WebPageProxy attachment methods should return early if attachment element is not enabled Reviewed by Chris Dumez. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::registerAttachmentIdentifierFromData): (WebKit::WebPageProxy::registerAttachmentIdentifierFromFilePath): (WebKit::WebPageProxy::registerAttachmentIdentifier): (WebKit::WebPageProxy::registerAttachmentsFromSerializedData): (WebKit::WebPageProxy::cloneAttachmentData): (WebKit::WebPageProxy::serializedAttachmentDataForIdentifiers): (WebKit::WebPageProxy::didInsertAttachmentWithIdentifier): - Add a message check for the attachment element being enabled. (WebKit::WebPageProxy::didRemoveAttachmentWithIdentifier): Ditto. - Also add a missing message check to validate `identifier`. 2020-04-02 Chris Dumez [iOS] Replace UIKit background task with a RunningBoard FinishTaskInterruptable assertion https://bugs.webkit.org/show_bug.cgi?id=209825 Reviewed by Geoffrey Garen. Replace UIKit background task with a RunningBoard FinishTaskInterruptable assertion on iOS. Our UIProcess gets terminated too frequently when the UIKit background task expires when the UIProcess holds it for longer than 30 seconds in the background. The RunningBoard FinishTaskInterruptable assertion is supposed to be equivalent but would cause suspension of our UIProcess on expiration, instead of termination. * UIProcess/ios/ProcessAssertionIOS.mm: (-[WKProcessAssertionBackgroundTaskManager init]): (-[WKProcessAssertionBackgroundTaskManager _scheduleReleaseTask]): (-[WKProcessAssertionBackgroundTaskManager _cancelPendingReleaseTask]): (-[WKProcessAssertionBackgroundTaskManager _hasBackgroundTask]): (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]): (-[WKProcessAssertionBackgroundTaskManager assertionWillInvalidate:]): (-[WKProcessAssertionBackgroundTaskManager assertion:didInvalidateWithError:]): (-[WKProcessAssertionBackgroundTaskManager _handleBackgroundTaskExpiration]): (-[WKProcessAssertionBackgroundTaskManager _releaseBackgroundTask]): 2020-04-02 Per Arne Vollan [iOS] Allow use of syscall from the WebContent sandbox https://bugs.webkit.org/show_bug.cgi?id=209920 Reviewed by Darin Adler. Add syscall to the WebContent sandbox on iOS. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-04-02 Brent Fulgham [iOS] Remove use of 'apple-signed-executable?' from Sandbox https://bugs.webkit.org/show_bug.cgi?id=209914 Reviewed by Per Arne Vollan. Some of the rules imported from the system sandbox make decisions based on whether the software is an apple-signed executable or not. This predicate is not relevant for the WebKit processes, and should be removed (it is always apple-signed). This patch makes the following changes: 1. Removes all uses of 'apple-signed-executable?' (since it is always true for WebKit). 2. Removed two iCloud preference reads that are not used in WebKit. 3. Switches from the deprecated 'com.apple.ReportCrash.SimulateCrash' XPC service to its correct name 'com.apple.osanalytics.osanalyticshelper'. Covered by existing regression tests. * Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb: * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-04-01 Darin Adler Remove all uses of live ranges from TextIterator https://bugs.webkit.org/show_bug.cgi?id=209723 Reviewed by Antti Koivisto. * Shared/EditingRange.cpp: (WebKit::EditingRange::fromRange): Use characterRange. * Shared/mac/AttributedString.h: Added a constructor that takes rvalue references so we can initialize this slightly more efficiently. * Shared/mac/AttributedString.mm: (IPC::ArgumentCoder::decode): Pass rvalue references when creating an AttributedString. * UIProcess/mac/TextCheckerMac.mm: (WebKit::TextChecker::updateSpellingUIWithGrammarString): Simplify the code to remove some local variables that weren't helpful. * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h: Made the annotatedSubstringBetweenPositions a static member function. Also used const& argument types to cut down on reference count churn a bit. * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm: (WebKit::TextCheckingControllerProxy::rangeAndOffsetRelativeToSelection): Streamlined and made this use characterCount instead of TextIterator::getLocationAndLengthFromRange. (WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): Tweaked the argument type. (WebKit::TextCheckingControllerProxy::removeAnnotationRelativeToSelection): Ditto. Also removed some unnecessary use of NSString. (WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): Rewrote to no longer use live ranges. * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::getContentsAsAttributedString): Use construction and rvalue references to tigten things up a bit. * WebProcess/WebPage/WebFrame.cpp: (WebKit::WebFrame::contentsAsString const): Use a SimpleRange instead of a live range to pass to plainText. * WebProcess/WebPage/glib/WebPageGLib.cpp: (WebKit::WebPage::getPlatformEditorState const): Pass references to live ranges to plainText. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::updateSelectionWithDelta): Rewrote to minimize use of live ranges. (WebKit::WebPage::requestDocumentEditingContext): Ditto. * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::getPlatformEditorState const): Pass reference to a live range to plainText. 2020-04-02 David Kilzer API::PageConfiguration may have conflicting preference values between WebPreferences and WebPreferencesStore::ValueMap instance variables Reviewed by Brent Fulgham. We fix this bug by removing API::PageConfiguration::m_preferenceValues and WebPageProxy::m_configurationPreferenceValues, and instead set values directly on the WebPreferences object, which holds values in its WebPreferencesStore instance variable. This change only requires that the API::PageConfiguration object has m_preferences set to a valid WebPreferences object before using the settings APIs. Covered by WKAttachment TestWebKitAPI tests and editing/undo-manager layout tests, among others. * UIProcess/API/APIPageConfiguration.cpp: (API::PageConfiguration::copy const): - Remove use of m_preferenceValues instance variable. * UIProcess/API/APIPageConfiguration.h: - Update headers after removing WebPreferencesStore.h. (API::PageConfiguration::preferenceValues): Delete. - Remove use of m_preferenceValues instance variable. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setupPageConfiguration:]): - Switch to use WebPreferences methods for settings. * UIProcess/API/mac/WKView.mm: (-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]): - Create WebPreferences object for API::PageConfiguration object. This is what WebProcessPool::createWebPage() does when creating a WebPageProxy object. - Switch to use WebPreferences method to set SystemLayoutDirection. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::WebPageProxy): - Remove initialization of m_configurationPreferenceValues. - Switch to use WebPreferences method to set DisableScreenSizeOverride. (WebKit::WebPageProxy::preferencesStore const): - Simplify this method after removing m_configurationPreferenceValues. * UIProcess/WebPageProxy.h: - Remove m_configurationPreferenceValues. 2020-04-02 Per Arne Vollan [macOS] Remove redundant call to check in with Launch Services https://bugs.webkit.org/show_bug.cgi?id=209911 Reviewed by Darin Adler. There is no need to explicitly check in with Launch Services or call RegisterApplication in the WebContent process, since this is handled when calling [NSApplication _accessibilityInitialize]. No new tests, since this only removes a redundant call, and should be covered by existing tests. * Shared/mac/AuxiliaryProcessMac.mm: * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): (WebKit::WebProcess::updateProcessName): (WebKit::WebProcess::platformInitializeProcess): 2020-04-02 Alex Christensen Add SPI to restrict loading to main resources or non-network loads https://bugs.webkit.org/show_bug.cgi?id=209893 Reviewed by Tim Horton. * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * UIProcess/API/APIPageConfiguration.cpp: (API::PageConfiguration::copy const): * UIProcess/API/APIPageConfiguration.h: (API::PageConfiguration::loadsSubresources const): (API::PageConfiguration::setLoadsSubresources): (API::PageConfiguration::loadsFromNetwork const): (API::PageConfiguration::setLoadsFromNetwork): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration _setLoadsFromNetwork:]): (-[WKWebViewConfiguration _loadsFromNetwork]): (-[WKWebViewConfiguration _setLoadsSubresources:]): (-[WKWebViewConfiguration _loadsSubresources]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: * UIProcess/WebPageProxy.cpp: * WebProcess/WebPage/WebPage.cpp: (WebKit::m_processDisplayName): 2020-04-02 youenn fablet Debug crash: ASSERTION FAILED: m_ongoingFetches.contains(task.fetchIdentifier()) https://bugs.webkit.org/show_bug.cgi?id=209743 Reviewed by Darin Adler. When context gets closed, we make ServiceWorkerFetchTask::m_serviceWorkerConnection null as it no longer needs to send messages and does not need to unregister itself. Test: http/wpt/service-workers/service-worker-crashing-while-fetching.https.html * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: (WebKit::ServiceWorkerFetchTask::contextClosed): 2020-04-02 youenn fablet Remove synchronous termination of service workers https://bugs.webkit.org/show_bug.cgi?id=209666 Reviewed by Chris Dumez. Update IPC code according removal of synchronous termination of service worker. Implement async-with-reply termination instead. * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::terminateWorkerFromClient): (WebKit::WebSWServerConnection::fetchTaskTimedOut): * NetworkProcess/ServiceWorker/WebSWServerConnection.h: * NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in: * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp: (WebKit::WebSWServerToContextConnection::terminateDueToUnresponsiveness): * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h: * WebProcess/Storage/WebServiceWorkerProvider.cpp: * WebProcess/Storage/WebServiceWorkerProvider.h: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::terminateWorkerForTesting): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.cpp: * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: 2020-04-02 Adrian Perez de Castro [WPE][GTK] Public API should not allow trying to register a special URI scheme https://bugs.webkit.org/show_bug.cgi?id=209900 Reviewed by Carlos Garcia Campos. No new tests needed. * UIProcess/API/glib/WebKitWebContext.cpp: (webkit_web_context_register_uri_scheme): Use g_return_if_fail() to check at the public API level whether the passed URI scheme is special and bail out early. 2020-04-02 Carlos Garcia Campos [GTK] [2.28.0] The Yelp build crashes if DISPLAY is not set https://bugs.webkit.org/show_bug.cgi?id=209431 Reviewed by Carlos Alberto Lopez Perez. Remove the assert when display is not X11 nor Wayland, and simply return false to ensure acceleration is not used. * UIProcess/gtk/AcceleratedBackingStore.cpp: (WebKit::AcceleratedBackingStore::checkRequirements): 2020-04-01 Per Arne Vollan [Cocoa] UTI from MIME type cache can be removed after r258915 https://bugs.webkit.org/show_bug.cgi?id=209787 Unreviewed rollout of r257828. * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode const): (WebKit::WebProcessCreationParameters::decode): * Shared/WebProcessCreationParameters.h: * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-04-01 Per Arne Vollan [macOS] Deny mach-lookup access to "com.apple.lsd.mapdb" in sandbox https://bugs.webkit.org/show_bug.cgi?id=209814 Reviewed by Darin Adler. This was done for iOS in , and in order to be able to do this on macOS, checking in with Launch Services and updating the process name needs to be done after the Launch Services database mapping has been done in WebProcess::platformInitializeWebProcess. Also, the previous call to RegisterApplication has been replaced with a call to launchServicesCheckIn, since RegisterApplication is an AppKit function, and should be avoided since the WebContent process is not a NSApplication anymore. Test: fast/sandbox/mac/sandbox-mach-lookup.html * Shared/mac/AuxiliaryProcessMac.mm: (WebKit::AuxiliaryProcess::launchServicesCheckIn): * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): (WebKit::WebProcess::initializeProcessName): (WebKit::WebProcess::updateProcessName): (WebKit::WebProcess::platformInitializeProcess): * WebProcess/com.apple.WebProcess.sb.in: 2020-04-01 Chris Dumez Regression(r257963) didFailProvisionalNavigation delegate no longer gets called when cancelling a cross-site provisional navigation https://bugs.webkit.org/show_bug.cgi?id=209873 Reviewed by Alex Christensen. ProvisionalPageProxy::cancel() was calling didFailProvisionalLoadForFrame() was not passing a valid FrameInfoData struct as parameter. As a result, FrameInfoData::isMainFrame ended up being false instead of true. This was an issue because NavigationState::NavigationClient::didFailProvisionalNavigationWithError() was relying on this flag to decide whether to call webViewDidFailProvisionalNavigationWithError or webViewNavigationDidFailProvisionalLoadInSubframeWithError, since r257963. Change is covered by new API tests. * UIProcess/ProvisionalPageProxy.cpp: (WebKit::ProvisionalPageProxy::cancel): 2020-04-01 Don Olmstead [GPUP][PlayStation] Enable GPU Process https://bugs.webkit.org/show_bug.cgi?id=209865 Reviewed by Eric Carlson. A generic LayerHostingContext is provided in this patch. It may make sense for this to be platform specific but it may also be possible to have some shared implementation with Cocoa ports. Once there are more implementations that can be decided. Add stubs for building out the GPU Process on the PlayStation port. No implementation is provided at this time but the GPU Process will compile and link with these changes. * GPUProcess/media/playstation/RemoteMediaPlayerProxyPlayStation.cpp: Added. (WebKit::RemoteMediaPlayerProxy::prepareForPlayback): (WebKit::RemoteMediaPlayerProxy::mediaPlayerFirstVideoFrameAvailable): (WebKit::RemoteMediaPlayerProxy::mediaPlayerRenderingModeChanged): (WebKit::RemoteMediaPlayerProxy::enterFullscreen): (WebKit::RemoteMediaPlayerProxy::exitFullscreen): * GPUProcess/playstation/GPUProcessMainPlayStation.cpp: Added. (WebKit::initializeAuxiliaryProcess): (WebKit::GPUProcessMain): * GPUProcess/playstation/GPUProcessPlayStation.cpp: Added. (WebKit::GPUProcess::initializeProcess): (WebKit::GPUProcess::initializeProcessName): (WebKit::GPUProcess::initializeSandbox): * Platform/generic/LayerHostingContext.h: Added. * PlatformPlayStation.cmake: * WebProcess/GPU/media/playstation/VideoLayerRemotePlayStation.cpp: Added. (WebKit::createVideoLayerRemote): 2020-04-01 Don Olmstead [PlayStation] Use OBJECT libraries for WebCore and PAL https://bugs.webkit.org/show_bug.cgi?id=209835 Reviewed by Ross Kirsling. Use the object libraries when building WebKit. * PlatformPlayStation.cmake: 2020-04-01 Commit Queue Unreviewed, reverting r259328. https://bugs.webkit.org/show_bug.cgi?id=209861 Introduced API test failures (Requested by perarne on #webkit). Reverted changeset: "[macOS] Deny mach-lookup access to "com.apple.lsd.mapdb" in sandbox" https://bugs.webkit.org/show_bug.cgi?id=209814 https://trac.webkit.org/changeset/259328 2020-04-01 Brent Fulgham Convert app-bound domain categorization parameter to a method https://bugs.webkit.org/show_bug.cgi?id=209842 Reviewed by John Wilander. SSIA. Covered by existing TestWebKitAPI tests. * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: 2020-04-01 Alex Christensen Deprecate WKWebsiteDataStore._indexedDBDatabaseDirectory https://bugs.webkit.org/show_bug.cgi?id=209243 Reviewed by David Kilzer. Luckily it's read-only, but we have a way to get the configuration, so let's encourage that instead. * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: 2020-04-01 Wenson Hsieh Make WebPasteboardProxy::didModifyContentsOfPasteboard robust when pasteboardName is null https://bugs.webkit.org/show_bug.cgi?id=209848 Reviewed by Megan Gardner and David Kilzer. Add more IPC message checks in WebPasteboardProxy; see below for more detail. * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: Rename what is currently MESSAGE_CHECK to MESSAGE_CHECK_COMPLETION, and introduce two more message check macros: MESSAGE_CHECK_WITH_RETURN_VALUE, which supports a return value, and MESSAGE_CHECK, which returns with no value. (WebKit::WebPasteboardProxy::canAccessPasteboardData const): Replace the early returns when pasteboardName is empty or when the web process for the given connection is null with `MESSAGE_CHECK`s. When the web content process is well-behaved, these early returns should never be hit. (WebKit::WebPasteboardProxy::didModifyContentsOfPasteboard): Similarly, replace this early return with a message check, and additionally `MESSAGE_CHECK` when the pasteboard name is empty. This addresses the main issue caught by this radar. (WebKit::WebPasteboardProxy::setPasteboardBufferForType): 2020-04-01 Victor M. Jaquez Bump libwebrtc to M82 https://bugs.webkit.org/show_bug.cgi?id=209542 Reviewed by Eric Carlson and Youenn Fablet. Update include paths to latest libwebrtc paths. * WebProcess/Network/webrtc/LibWebRTCResolver.h: * WebProcess/Network/webrtc/LibWebRTCSocketFactory.h: 2020-04-01 youenn fablet Support resolution of IPv6 STUN/TURN addresses https://bugs.webkit.org/show_bug.cgi?id=209808 Reviewed by Eric Carlson. Update code to support IPv6 addresses when doing DNS resolution of TURN/STUN servers. Refactor code to share more code between Cocoa ports and non Cocoa ports. Manually tested with external IPv6 TURN servers. * NetworkProcess/webrtc/NetworkRTCProvider.cpp: (WebKit::NetworkRTCProvider::createResolver): * NetworkProcess/webrtc/NetworkRTCResolverCocoa.cpp: (WebKit::resolvedName): 2020-03-31 Megan Gardner Dismiss color picker on color selection on MacCatalyst https://bugs.webkit.org/show_bug.cgi?id=209840 Reviewed by Darin Adler. To have correct behavior on mac, we need to dismiss the color picker popover once a color has been selected. * UIProcess/ios/forms/WKFormColorControl.mm: (-[WKColorPopover initWithView:]): * UIProcess/ios/forms/WKFormColorPicker.h: * UIProcess/ios/forms/WKFormColorPicker.mm: (-[WKColorPicker initWithView:]): (-[WKColorPicker initWithView:inPopover:]): (-[WKColorPicker colorMatrixView:didTapColorButton:]): 2020-03-31 Simon Fraser Add type traits for ScrollableArea, and other cleanup https://bugs.webkit.org/show_bug.cgi?id=209838 Reviewed by Chris Dumez. Because PDFPlugin inherits from both Plugin and ScrollableArea, expand out its SPECIALIZE_TYPE_TRAITS macros and change the macros to use the isFoo() pattern. * WebProcess/Plugins/Netscape/NetscapePlugin.h: * WebProcess/Plugins/PDF/PDFPlugin.h: (isType): * WebProcess/Plugins/Plugin.h: (WebKit::Plugin::isPluginProxy const): (WebKit::Plugin::isNetscapePlugin const): (WebKit::Plugin::isPDFPlugin const): * WebProcess/Plugins/PluginProxy.h: 2020-03-31 Wenson Hsieh Datalist option's label not used https://bugs.webkit.org/show_bug.cgi?id=201768 Reviewed by Darin Adler. Add support on macOS for showing option labels in datalist suggestions. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder::encode): Deleted. (IPC::ArgumentCoder::decode): Deleted. * Shared/WebCoreArgumentCoders.h: Remove WebCoreArgumentCoders logic for encoding and decoding DataListSuggestionInformation. See DataListSuggestionInformation.h in WebCore for more detail. * UIProcess/gtk/WebDataListSuggestionsDropdownGtk.cpp: (WebKit::WebDataListSuggestionsDropdownGtk::show): Tweak GTK code to adjust for the change from `String` to `DataListSuggestion`. * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm: (-[WKDataListSuggestionsControl didSelectOptionAtIndex:]): (-[WKDataListSuggestionsControl textSuggestions]): (-[WKDataListSuggestionsControl suggestionAtIndex:]): Adjust some iOS codepaths to use DataListSuggestion::value as the value string to display. * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm: Tweak several UI constants. A suggestion cell may now be either 20 or 40pt tall, depending on whether it has label text to show. Currently, the maximum combined height of the table view cells is 120 (not including spacing between cells and vertical padding around the top and bottom of the table view), since the maximum number of cells to show is 6 and each cell is 20pt tall. Maintain this constant by making the maximum cell height 120, which accomodates either three labeled cells, or 6 unlabeled cells (i.e. to match shipping behavior). (-[WKDataListSuggestionView initWithFrame:]): (-[WKDataListSuggestionView layout]): Maintain two text fields or value and (optionally) label text: `_valueField` and `_labelField`. The value field fills the bounds of the cell in the case where there is no label text, but fills only the top half of the cell in the case where there is label text. The label field takes the bottom half of the cell in this case. Additionally, add a divider view that may appear at the very bottom of each cell. This divider view is present when one or more suggestions in the datalist are labeled. (-[WKDataListSuggestionView setValue:label:]): Renamed from -setText:. Add a label string argument as well. (-[WKDataListSuggestionView setShouldShowBottomDivider:]): Add getters and setters for the -shouldShowBottomDivider property, which can be used to make the divider view visible or hidden. (-[WKDataListSuggestionView shouldShowBottomDivider]): (-[WKDataListSuggestionView setBackgroundStyle:]): Use -[NSColor secondaryLabelColor] for the label text field. (shouldShowDividersBetweenCells): Add a helper method to determine whether the table view should be showing clear dividers between each item. We only do so if there are one or more labels to be shown. (-[WKDataListSuggestionsController initWithInformation:inView:]): (-[WKDataListSuggestionsController currentSelectedString]): (-[WKDataListSuggestionsController updateWithInformation:]): (-[WKDataListSuggestionsController moveSelectionByDirection:]): Drive-by fix: scroll to reveal each selected row when using the arrow keys to navigate between items. (-[WKDataListSuggestionsController dropdownRectForElementRect:]): (-[WKDataListSuggestionsController tableView:heightOfRow:]): Return either `dropdownRowHeightWithoutLabel` or `dropdownRowHeightWithLabel`, depending on whether there is label text to be shown in that suggestion cell. (-[WKDataListSuggestionsController tableView:viewForTableColumn:row:]): (-[WKDataListSuggestionView setText:]): Deleted. * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::canShowDataListSuggestionLabels const): * WebProcess/WebCoreSupport/WebChromeClient.h: 2020-03-31 Per Arne Vollan [macOS] Deny mach-lookup access to "com.apple.lsd.mapdb" in sandbox https://bugs.webkit.org/show_bug.cgi?id=209814 Reviewed by Darin Adler. This was done for iOS in , and in order to be able to do this on macOS, checking in with Launch Services and updating the process name needs to be done after the Launch Services database mapping has been done in WebProcess::platformInitializeWebProcess. Also, the previous call to RegisterApplication has been replaced with a call to launchServicesCheckIn, since RegisterApplication is an AppKit function, and should be avoided since the WebContent process is not a NSApplication anymore. Test: fast/sandbox/mac/sandbox-mach-lookup.html * Shared/mac/AuxiliaryProcessMac.mm: (WebKit::AuxiliaryProcess::launchServicesCheckIn): * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): (WebKit::WebProcess::initializeProcessName): (WebKit::WebProcess::updateProcessName): (WebKit::WebProcess::platformInitializeProcess): * WebProcess/com.apple.WebProcess.sb.in: 2020-03-31 Don Olmstead [PlayStation] Fix build breaks after r259112 https://bugs.webkit.org/show_bug.cgi?id=209830 Unreviewed build fix. Replace PLATFORM(WPE) with USE(LIBWPE) within WebWheelEvent. * Shared/WebEvent.h: * Shared/WebWheelEvent.cpp: (WebKit::WebWheelEvent::encode const): (WebKit::WebWheelEvent::decode): 2020-03-31 Alex Christensen Send correct UserContentControllerIdentifier after using SPI WKWebpagePreferences._userContentController https://bugs.webkit.org/show_bug.cgi?id=209833 Reviewed by Tim Hatcher. Covered by an API test. I knew something was broken in r259307 and this was it. * Shared/UserContentControllerParameters.cpp: (WebKit::UserContentControllerParameters::encode const): (WebKit::UserContentControllerParameters::decode): * Shared/UserContentControllerParameters.h: * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::parameters const): * UIProcess/WebPageProxy.cpp: * WebProcess/WebPage/WebPage.cpp: 2020-03-31 Fujii Hironori Deduplicate WebsiteDataStore::parameters() of Cocoa port and non-Cocoa port https://bugs.webkit.org/show_bug.cgi?id=209644 Reviewed by Youenn Fablet. WinCairo WTR was failing an assertion ensuring ResourceLoadStatistics was enabled in NetworkSession::setThirdPartyCookieBlockingMode while running LayoutTests with useEphemeralSession=true becuase ResourceLoadStatisticsParameters was not set in WebsiteDataStoreParameters. * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::platformSetNetworkParameters): Added. (WebKit::WebsiteDataStore::parameters): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::parameters): * UIProcess/WebsiteData/WebsiteDataStore.h: 2020-03-31 Brent Fulgham Allow WKAppBoundDomains to be initialized with eTLD+1 only (no protocol) https://bugs.webkit.org/show_bug.cgi?id=209839 Reviewed by Darin Adler. Create a convenience mode for WKAppBoundDomains that assumes https if the user does not supply the full URL. This doesn't effect the behavior of the app-bound domains because we only deal in RegistrableDomains. Tested by TestWebKitAPI. * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::initializeAppBoundDomains): If the protocol is missing from a domain supplied by WKAppBoundDomains, assume it was https. 2020-03-31 Brent Fulgham [macOS] Update sandbox rules for correct sanitizer paths in current OS releases https://bugs.webkit.org/show_bug.cgi?id=209818 Reviewed by Per Arne Vollan. Update the sandbox rules to allow access to the new system Asan library locations. * GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in: Note: Don't bother leaving the old location in this sandbox, since it is not being used on any shipping software. * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: * WebProcess/com.apple.WebProcess.sb.in: 2020-03-31 Sihui Liu IndexedDB: destroy WebIDBServer when session is removed in network process https://bugs.webkit.org/show_bug.cgi?id=209606 Reviewed by Geoffrey Garen. Tested manually to verify WebIDBServer is removed and its thread ends when session is removed. * NetworkProcess/IndexedDB/WebIDBServer.cpp: (WebKit::WebIDBServer::~WebIDBServer): (WebKit::WebIDBServer::addConnection): (WebKit::WebIDBServer::removeConnection): (WebKit::WebIDBServer::close): * NetworkProcess/IndexedDB/WebIDBServer.h: * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::destroySession): (WebKit::NetworkProcess::connectionToWebProcessClosed): 2020-03-31 Chris Dumez Regression(r253357) DeviceMotionEvent acceleration and rotationRate are null https://bugs.webkit.org/show_bug.cgi?id=209831 Reviewed by Darin Adler. * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h: * UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm: (WebKit::WebDeviceOrientationUpdateProviderProxy::motionChanged): * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.cpp: (WebKit::WebDeviceOrientationUpdateProvider::deviceMotionChanged): * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.h: * WebProcess/WebCoreSupport/WebDeviceOrientationUpdateProvider.messages.in: 2020-03-31 Alex Christensen Add SPI WKWebpagePreferences._userContentController https://bugs.webkit.org/show_bug.cgi?id=209795 Reviewed by Tim Hatcher. This will allow us to switch which WKUserContentController we are using at decidePolicyForNavigationAction time like we do WKWebsiteDataStores. This is only allowed with main frame navigations. To do this I moved UserContentControllerParameters into their own struct. I remove unused WebsitePoliciesData.websiteDataStoreParameters. I pass an API::WebsitePolicies* further down the chain instead of switching to Optional, which allows us to access the WebUserContentControllerProxy* from the former in WebPageProxy::creationParameters. I removed an unused WebsitePolicies constructor. I added a missing copied member variable in WebsitePolicies::copy. * NetworkProcess/NetworkSession.cpp: * Shared/UserContentControllerParameters.cpp: Added. (WebKit::UserContentControllerParameters::encode const): (WebKit::UserContentControllerParameters::decode): * Shared/UserContentControllerParameters.h: Added. * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * Shared/WebsitePoliciesData.cpp: (WebKit::WebsitePoliciesData::encode const): (WebKit::WebsitePoliciesData::decode): * Shared/WebsitePoliciesData.h: * Sources.txt: * UIProcess/API/APIWebsitePolicies.cpp: (API::WebsitePolicies::copy const): (API::WebsitePolicies::setUserContentController): (API::WebsitePolicies::data): (API::WebsitePolicies::WebsitePolicies): Deleted. * UIProcess/API/APIWebsitePolicies.h: * UIProcess/API/C/WKPage.cpp: (WKPageUpdateWebsitePolicies): * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _updateWebpagePreferences:]): * UIProcess/API/Cocoa/WKWebpagePreferences.mm: (-[WKWebpagePreferences _userContentController]): (-[WKWebpagePreferences _setUserContentController:]): * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h: * UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): * UIProcess/ProvisionalPageProxy.cpp: (WebKit::ProvisionalPageProxy::ProvisionalPageProxy): (WebKit::ProvisionalPageProxy::initializeWebPage): (WebKit::ProvisionalPageProxy::goToBackForwardItem): * UIProcess/ProvisionalPageProxy.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::parameters const): (WebKit::WebUserContentControllerProxy::contentRuleListData const): (WebKit::WebUserContentControllerProxy::contentRuleListData): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::receivedNavigationPolicyDecision): (WebKit::WebPageProxy::receivedPolicyDecision): (WebKit::WebPageProxy::continueNavigationInNewProcess): (WebKit::WebPageProxy::decidePolicyForNavigationAction): (WebKit::WebPageProxy::decidePolicyForNewWindowAction): (WebKit::WebPageProxy::decidePolicyForResponseShared): * UIProcess/WebPageProxy.h: * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::addWebUserContentControllerProxy): * UIProcess/WebProcessProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/WebPage/WebPage.cpp: (WebKit::m_processDisplayName): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::didReceiveMessage): 2020-03-31 Alex Christensen Remove call to PageConfiguration::setUserContentController added in r225765 https://bugs.webkit.org/show_bug.cgi?id=209828 Reviewed by Brian Weinstein. r225765 added a way for a certain Mac application to use WKWebViewConfiguration._pageGroup to set its WKUserContentController. That Mac application has transitioned to setting the WKUserContentController manually, and this workaround needs to be removed for that application's WKUserContentControllers to continue working as desired. I verified this fixes that application, and it is the only user of WKWebViewConfiguration._pageGroup and all other applications will have no change in behavior. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setupPageConfiguration:]): 2020-03-31 Brent Fulgham [macOS] Add additional IPC permission needed by Security.framework https://bugs.webkit.org/show_bug.cgi?id=209815 Reviewed by Per Arne Vollan. Add missing permission needed for recent macOS releases. * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: 2020-03-31 Per Arne Vollan Silence preference write sandbox violations in the WebContent process https://bugs.webkit.org/show_bug.cgi?id=209806 Reviewed by Brent Fulgham. When CFPrefs direct mode is enabled in the WebContent process, the UI process will notify the WebContent about preference changes. When receiving these notifications, the WebContent process will use the CFPrefs API to update the value of these preferences in-process, which will also attempt to write these values to disk. Writing the preference values to disk is unnecessary, and will also be denied by the sandbox, so the sandbox violations should be silenced. No new tests, no behavior change. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: * WebProcess/com.apple.WebProcess.sb.in: 2020-03-31 Devin Rousso REGRESSION: (r259236) [ iOS and Catalina wk2 Debug ] ASSERTION FAILED: m_debugLoggingEnabled in WebKit::ResourceLoadStatisticsStore::debugBroadcastConsoleMessage https://bugs.webkit.org/show_bug.cgi?id=209810 Unreviewed, covered by existing tests. * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: (WebKit::ResourceLoadStatisticsStore::debugBroadcastConsoleMessage): Remove the assertion since `debugBroadcastConsoleMessage` is also called when turning off debug logging mode via `setResourceLoadStatisticsDebugMode`. Fundamentally, it's just a wrapper function for `broadcastConsoleMessage` anyways, so it doesn't need to be gated. 2020-03-31 Pablo Saavedra Several refactorings done in the MemoryPressureMonitor.cpp https://bugs.webkit.org/show_bug.cgi?id=209464 Reviewed by Adrian Perez de Castro. 1) toIntegralType() parses the C-string str interpreting its content as an `unsigned long long int` which is more appropriate for the size_t (unsigned integer type) variables used by the MemoryPressureMonitor functions in counterpoint of atoll() what returns a `long long int`. This change also controls if the parsing was succesful. In negative case returns `notSet`. 2) Added the getCgroupFileValue() function what encapsulates the manipulation of the opened files in the `/sys/fs/cgroup` hierarchy. This change simplify the code avoding unnecessary code repetion. 3) getCgroupControllerPath() now checks if there is a `name=systemd` controller listed in the `/proc/self/cgroup`. This important for cgroup v2 activated with `systemd.unified_cgroup_hierarchy=yes` through the Linux kernel cmdline. The unified hierarchy simplies path of the controllers under the same directory (check the "Deprecated v1 Core Features" section in the Linux Kernel documentation fir cgroup v2 [1]): Multiple hierarchies including named ones are not supported [1] https://www.kernel.org/doc/Documentation/cgroup-v2.txt 4) Because 3) the patch composited for cgroupV2 changes getMemoryUsageWithCgroup() slightly. The name of the controller is not needed anymore. 5) For cgroup v2, the MemoryTotal is calculated as the minimum between memory.high and memory.max. * UIProcess/linux/MemoryPressureMonitor.cpp: (WebKit::lowWatermarkPages): (WebKit::getCgroupFileValue): (WebKit::getMemoryTotalWithCgroup): (WebKit::getMemoryUsageWithCgroup): (WebKit::getCgroupControllerPath): (WebKit::systemMemoryUsedAsPercentage): (WebKit::getCgroupController): Deleted. 2020-03-31 Zan Dobersek [GTK][WPE] Jumpy rendering of fixed-element layers while scrolling https://bugs.webkit.org/show_bug.cgi?id=209466 Reviewed by Carlos Garcia Campos. Move the Nicosia::SceneIntegration ownership into the CompositingCoordinator class, along with the SceneIntegration::Client inheritance. LayerTreeHost in turn now implements the updateScene() method that triggers a scene update when invoked. * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: (WebKit::CompositingCoordinator::CompositingCoordinator): (WebKit::CompositingCoordinator::invalidate): (WebKit::CompositingCoordinator::attachLayer): (WebKit::CompositingCoordinator::requestUpdate): * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h: * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp: (WebKit::LayerTreeHost::LayerTreeHost): (WebKit::LayerTreeHost::~LayerTreeHost): (WebKit::LayerTreeHost::updateScene): (WebKit::LayerTreeHost::sceneIntegration): Deleted. (WebKit::LayerTreeHost::requestUpdate): Deleted. * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h: 2020-03-31 Carlos Garcia Campos REGRESSION(r258829): [CoordinatedGraphics] Web view not updated after cross site navigation with PSON enabled https://bugs.webkit.org/show_bug.cgi?id=209741 Reviewed by Žan Doberšek. Since r258829, the drawing area proxy of a provisional page ignores all messages until the load is committed. This is causing 2 problems for coordinated graphics drawing area. When not in accelerated compositing mode, Update message is sent before the commit is loaded, and the web process keeps waiting for the DidUpdate response message forever. When accelerated compositing mode is forced, the EnterAcceleratedCompositing message is also sent before the load is committed and ignored, so the UI process doesn't know it's in accelerated mode. * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp: (WebKit::DrawingAreaCoordinatedGraphics::scheduleRenderingUpdate): Return early if layer tree is frozen. This ensures that Update messages are not sent to the UI process while layer tree is frozen. (WebKit::DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode): Disable layer flush on the newly created LayerTreeHost if layer tree is frozen. This ensures that EnterAcceleratedCompositing message is sent after the first layer flush once the layer tree is no longer frozen. 2020-03-30 David Kilzer REGRESSION (r251574, r251600): _WKTextManipulationToken and _WKTextManipulationConfiguration are missing -dealloc Reviewed by Wenson Hsieh. * UIProcess/API/Cocoa/_WKTextManipulationConfiguration.mm: (-[_WKTextManipulationConfiguration dealloc]): Add. * UIProcess/API/Cocoa/_WKTextManipulationToken.mm: (-[_WKTextManipulationToken dealloc]): Add. 2020-03-30 John Wilander Experimental: Enforce SameSite=strict for domains classified as bounce trackers https://bugs.webkit.org/show_bug.cgi?id=209761 Reviewed by Brent Fulgham and Kate Cheney (informal). This experimental feature is part of Intelligent Tracking Prevention and only enabled if ITP (Resource Load Statistics) are. A new enum WebCore::SameSiteStrictEnforcementEnabled controls the new behavior with default setting WebCore::SameSiteStrictEnforcementEnabled::No. The features keeps a separate count of topFrameUniqueRedirectsToSinceSameSiteStrictEnforcement which builds up to a threshold. Once a domain goes above the threshold, its cookies are rewritten as SameSite=strict and the topFrameUniqueRedirectsToSinceSameSiteStrictEnforcement counter for that domain is reset, effectively giving the domain a new chance to change its behavior. Test infrastructure is added to allow for layout tests. * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: (WebKit::ResourceLoadStatisticsDatabaseStore::createUniqueIndices): (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema): (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationships): (WebKit::CompletionHandler Cache [WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames] to avoid hitting often the main thread in isolated tree mode. https://bugs.webkit.org/show_bug.cgi?id=209767 Reviewed by Chris Fleizach. [WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames] is called often in isolated tree mode causing a dispatch to the main thread. This change caches this value so it doesn't keep hitting the main thread. * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm: (-[WKAccessibilityWebPageObject ALLOW_DEPRECATED_IMPLEMENTATIONS_END]): 2020-03-30 Chris Dumez WebKit should take a foreground assertion for offscreen loads when the app is foreground https://bugs.webkit.org/show_bug.cgi?id=209748 Reviewed by Geoffrey Garen. * UIProcess/API/APIPageConfiguration.h: 2020-03-30 Chris Dumez REGRESSION (r259211): ASSERT(window) in applicationType() under shouldUseForegroundPriorityForClientNavigation() https://bugs.webkit.org/show_bug.cgi?id=209759 Reviewed by Darin Adler. Make sure to not call applicationType() with a null window. This patch maintains previous behavior in release builds. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::loadRequest): (WebKit::WebPageProxy::loadFile): (WebKit::WebPageProxy::loadData): * UIProcess/WebPageProxy.h: * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::isApplicationVisible): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::shouldForceForegroundPriorityForClientNavigation const): (WebKit::WebPageProxy::shouldUseForegroundPriorityForClientNavigation const): Deleted. 2020-03-30 Don Olmstead Non-unified build fixes late March 2020 edition https://bugs.webkit.org/show_bug.cgi?id=209781 Unreviewed build fix. * NetworkProcess/NetworkDataTask.cpp: 2020-03-30 Kate Cheney Known app-bound domain protocols should not check the app-bound domain list https://bugs.webkit.org/show_bug.cgi?id=209755 Reviewed by Chris Dumez. This patch checks if a url should be treated as app-bound based on protocol before deciding to check the app-bound domain list. It is wasteful to check the app-bound domain list when some protocols are automatically considered app-bound. Existing behavior should be maintained, this is tested by existing In-App Browser Privacy layout and API tests. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomain): (WebKit::shouldBeTreatedAsAppBound): Deleted. We can remove the check for the url protocol here because we are doing it instead in WebsiteDataStore::beginAppBoundDomainCheck. (WebKit::WebPageProxy::decidePolicyForNavigationAction): Changed if PLATFORM(COCOA) to if PLATFORM(IOS_FAMILY) because it is unnecessary to check the app-bound domain list for other platforms (the values returned would be ignored in setIsNavigatingToAppBoundDomain). * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::shouldTreatURLProtocolAsAppBound): (WebKit::WebsiteDataStore::beginAppBoundDomainCheck): * UIProcess/WebsiteData/WebsiteDataStore.h: 2020-03-30 David Kilzer REGRESSION (r256756): -[WKPreferenceObserver init]: Instance variable used while 'self' is not set to the result of '[(super or self) init...]' Reviewed by Darin Adler. * UIProcess/Cocoa/PreferenceObserver.mm: (-[WKPreferenceObserver init]): Call `[self init]` and set `self` to fix the clang static analyzer warning. 2020-03-30 Ryan Haddad Unreviewed, reverting r259211. Caused API test assertion failures on iOS Reverted changeset: "WebKit should take a foreground assertion for offscreen loads when the app is foreground" https://bugs.webkit.org/show_bug.cgi?id=209748 https://trac.webkit.org/changeset/259211 2020-03-30 Devin Rousso Web Inspector: provide a way to log messages from the network process https://bugs.webkit.org/show_bug.cgi?id=204775 Reviewed by Brian Burg. ITP can be influenced by multiple pages simultaneously, meaning that sending a console message to the Web Inspector that's connected to the page that caused a change may not be useful as developers often don't test in complete isolation. As such, having a way to broadcast a console message to all Web Inspectors ensures that any changes caused by any page are always able to be seen, no matter which page is being actively inspected. * NetworkProcess/NetworkProcess.h: * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::broadcastConsoleMessage): Added. * NetworkProcess/NetworkConnectionToWebProcess.cpp: * NetworkProcess/NetworkConnectionToWebProcess.h: (WebKit::NetworkConnectionToWebProcess::broadcastConsoleMessage): Added. * WebProcess/Network/NetworkProcessConnection.messages.in: * WebProcess/Network/NetworkProcessConnection.h: * WebProcess/Network/NetworkProcessConnection.cpp: (WebKit::NetworkProcessConnection::broadcastConsoleMessage): Added. * WebProcess/WebProcess.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::webFrames const): Added. Broadcasted console messages are relayed from the network process to the web process via the functions above in the order that they are written. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): * NetworkProcess/AdClickAttributionManager.h: (WebKit::AdClickAttributionManager::AdClickAttributionManager): * NetworkProcess/AdClickAttributionManager.cpp: (WebKit::AdClickAttributionManager::storeUnconverted): (WebKit::AdClickAttributionManager::handleConversion): (WebKit::AdClickAttributionManager::convert): (WebKit::AdClickAttributionManager::fireConversionRequest): * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: (WebKit::ResourceLoadStatisticsStore::removeDataRecords): (WebKit::ResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode): (WebKit::ResourceLoadStatisticsStore::debugBroadcastConsoleMessage): Added. (WebKit::ResourceLoadStatisticsStore::debugLogDomainsInBatches): * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccess): (WebKit::ResourceLoadStatisticsDatabaseStore::requestStorageAccessUnderOpener): (WebKit::ResourceLoadStatisticsDatabaseStore::ensurePrevalentResourcesForDebugMode): (WebKit::ResourceLoadStatisticsDatabaseStore::updateCookieBlocking): * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess): (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener): (WebKit::ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode): (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking): * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::willSendRedirectedRequest): Send a console message for the result of `WebCore::AdClickAttribution::parseConversionRequest`. 2020-03-30 Per Arne Vollan Unreviewed build fix after r259200. * WebProcess/WebSleepDisablerClient.cpp: (WebKit::WebSleepDisablerClient::didCreateSleepDisabler): (WebKit::WebSleepDisablerClient::didDestroySleepDisabler): * WebProcess/WebSleepDisablerClient.h: 2020-03-30 Chris Dumez WebKit should take a foreground assertion for offscreen loads when the app is foreground https://bugs.webkit.org/show_bug.cgi?id=209748 Reviewed by Geoffrey Garen. * UIProcess/API/APIPageConfiguration.h: 2020-03-30 Chris Dumez Regression(r246188) WebProcess is launched too eagerly when [WKWebView _restoreSessionState] is called https://bugs.webkit.org/show_bug.cgi?id=207908 Reviewed by Darin Adler. Since r246188, the WebProcess is launched eagerly when [WKWebView _restoreSessionState] is called. This is bad for performance because we are unable to leverage the process cache at this point (since we don't know which domain will be loaded). This patch thus reverts r246188 and fixes what r246188 was trying to address in a different way. If the process was not launched yet when restoreSessionState() is called, the session state properly gets sent to the WebProcess after launch, via the WebPageCreationParameters. What was missing at that point was that the session state was restore by an API Request. To fix this, we now pass an extra itemStatesWereRestoredByAPIRequest flag in WebPageCreationParameters. * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::restoreFromSessionState): * UIProcess/WebPageProxy.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::m_processDisplayName): 2020-03-30 Wenson Hsieh [Cocoa] Minor code cleanup around WebDataListSuggestionsDropdown https://bugs.webkit.org/show_bug.cgi?id=209747 Reviewed by Tim Horton. Refactor WKDataListSuggestionsController and WKDataListSuggestionsControl, such that their `_dropdown`s are `WeakPtr`s instead of raw pointers. Also, make `-showSuggestionsDropdown:` take a reference instead of a pointer, since the argument is always `this` (and assumed to be non-null). No change in behavior. * UIProcess/WebDataListSuggestionsDropdown.h: * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm: (WebKit::WebDataListSuggestionsDropdownIOS::show): (-[WKDataListSuggestionsControl showSuggestionsDropdown:activationType:]): (-[WKDataListSuggestionsPicker showSuggestionsDropdown:activationType:]): (-[WKDataListSuggestionsPopover showSuggestionsDropdown:activationType:]): * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm: (WebKit::WebDataListSuggestionsDropdownMac::show): (-[WKDataListSuggestionsController showSuggestionsDropdown:]): 2020-03-30 David Kilzer NetworkConnectionToWebProcess::registerFileBlobURL should validate its parameters Reviewed by Youenn Fablet. * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::registerFileBlobURL): - Add message check to validate `url` parameter. 2020-03-30 Per Arne Vollan [Cocoa] Sleep disabling should be performed in the UI process https://bugs.webkit.org/show_bug.cgi?id=209676 Reviewed by Darin Adler. Since sleep disabling is causing communication with the power management service, it should be performed in the UI process. The UI process will be notified by the WebContent process about sleep disablers being created and destroyed, and will perform the actual sleep disabling and enabling. * Scripts/webkit/messages.py: * Sources.txt: * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _hasSleepDisabler]): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::didCreateSleepDisabler): (WebKit::WebProcessProxy::didDestroySleepDisabler): (WebKit::WebProcessProxy::hasSleepDisabler): * UIProcess/WebProcessProxy.h: * UIProcess/WebProcessProxy.messages.in: * WebKit.xcodeproj/project.pbxproj: * WebProcess/GPU/media/RemoteLegacyCDM.cpp: * WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp: * WebProcess/GPU/media/ios/RemoteMediaSessionHelper.h: * WebProcess/WebPage/ViewGestureGeometryCollector.cpp: * WebProcess/WebSleepDisablerClient.cpp: Added. (WebKit::WebSleepDisablerClient::didCreateSleepDisabler): (WebKit::WebSleepDisablerClient::didDestroySleepDisabler): * WebProcess/WebSleepDisablerClient.h: Added. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-03-30 Wenson Hsieh [macOS] Datalist dropdown suggestions table can be scrolled too far https://bugs.webkit.org/show_bug.cgi?id=209721 Reviewed by Tim Horton. WKDataListSuggestionTableView's enclosing scroll view is set to an incorrect size while laying out the table view, due to AppKit logic that attempts to adjust the size of the table view's enclosing scroll view after we've already attempted to set the frame of the scroll view under the overridden call to -layout. Fix this by refactoring the logic around the suggestion table view's enclosing scroll view; currently, WKDataListSuggestionTableView overrides -enclosingScrollView to return its own NSScrollView, which it sizes underneath an overridden call to -layout. This is a bit strange, since the table view is actually a subview of the scroll view it owns; the fact that laying out the table view causes an ancestor view to change size (and subsequently invalidate the table view's layout) seems to be what breaks AppKit's enclosing scroll view adjustment logic. Instead, we can have own both the table view and the table view's enclosing scroll view. * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm: (-[WKDataListSuggestionTableView initWithElementRect:]): (-[WKDataListSuggestionsController initWithInformation:inView:]): Move the scroll view initialization logic out of -[WKDataListSuggestionTableView initWithElementRect:] and into this method. This also means that we can initialize the scroll view with the bounds of the window's content view, instead of waiting until we lay out the table view underneath the scroll view. (-[WKDataListSuggestionsController updateWithInformation:]): (-[WKDataListSuggestionsController invalidate]): Clear out and remove _scrollView as well when we tear down the controller. (-[WKDataListSuggestionsController showSuggestionsDropdown:]): (-[WKDataListSuggestionTableView layout]): Deleted. (-[WKDataListSuggestionTableView enclosingScrollView]): Deleted. (-[WKDataListSuggestionTableView removeFromSuperviewWithoutNeedingDisplay]): Deleted. Now that the controller owns the scroll view, we don't need to override these anymore. 2020-03-29 Antoine Quint [AutoSizing] Bring back the old auto-sizing code as a deprecated codepath for compatibility reasons https://bugs.webkit.org/show_bug.cgi?id=209669 Reviewed by Alan Bujtas and Darin Adler. We changed the auto-sizing code for webkit.org/b/196743 in r244098, but some clients need it and we bring it back via a new dedicated -[WKWebView _setSizeToContentAutoSizeMaximumSize:] SPI. * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * UIProcess/API/Cocoa/WKViewPrivate.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView sizeToContentAutoSizeMaximumSize]): (-[WKView setSizeToContentAutoSizeMaximumSize:]): * UIProcess/API/mac/WKWebViewMac.mm: (-[WKWebView _sizeToContentAutoSizeMaximumSize]): (-[WKWebView _setSizeToContentAutoSizeMaximumSize:]): * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::setSizeToContentAutoSizeMaximumSize): (WebKit::WebViewImpl::sizeToContentAutoSizeMaximumSize const): (WebKit::WebViewImpl::setIntrinsicContentSize): * UIProcess/DrawingAreaProxy.h: (WebKit::DrawingAreaProxy::sizeToContentAutoSizeMaximumSizeDidChange): * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::sizeToContentAutoSizeMaximumSize const): * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h: * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm: (WebKit::TiledCoreAnimationDrawingAreaProxy::sizeToContentAutoSizeMaximumSizeDidChange): (WebKit::TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry): (WebKit::TiledCoreAnimationDrawingAreaProxy::willSendUpdateGeometry): * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): * WebProcess/WebPage/WebPage.cpp: (WebKit::m_processDisplayName): (WebKit::WebPage::reinitializeWebPage): (WebKit::WebPage::setMinimumSizeForAutoLayout): (WebKit::WebPage::setSizeToContentAutoSizeMaximumSize): (WebKit::WebPage::updateIntrinsicContentSizeIfNeeded): * WebProcess/WebPage/WebPage.h: (WebKit::WebPage::sizeToContentAutoSizeMaximumSize const): * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: (WebKit::TiledCoreAnimationDrawingArea::updateGeometry): 2020-03-29 Darin Adler Move TextIterator::rangeFromLocationAndLength off of live ranges https://bugs.webkit.org/show_bug.cgi?id=209408 Reviewed by Antti Koivisto. * Shared/EditingRange.cpp: (WebKit::EditingRange::toRange): Use CharacterRange, resolveCharacterLocation/Range. * Shared/EditingRange.h: Added a FIXME about replacing with CharacterRange. * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder::encode): Added. (IPC::ArgumentCoder::decode): Added. (IPC::ArgumentCoder::encode): Updated to use CharacterRange. (IPC::ArgumentCoder::decode): Ditto. (IPC::ArgumentCoder::encode): Ditto. (IPC::ArgumentCoder::decode): Ditto. * Shared/WebCoreArgumentCoders.h: Added CharacterRange. * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::textCheckingResultFromNSTextCheckingResult): Use CharacterRange, resolveCharacterLocation/Range. * UIProcess/WebGrammarDetail.cpp: (WebKit::WebGrammarDetail::WebGrammarDetail): Ditto. * UIProcess/WebGrammarDetail.h: (WebKit::WebGrammarDetail::location const): Ditto. (WebKit::WebGrammarDetail::length const): Ditto. * UIProcess/gtk/TextCheckerGtk.cpp: (WebKit::TextChecker::checkTextOfParagraph): Ditto. * UIProcess/ios/TextCheckerIOS.mm: (WebKit::TextChecker::checkTextOfParagraph): Ditto. * UIProcess/mac/TextCheckerMac.mm: (WebKit::TextChecker::checkTextOfParagraph): Ditto. (WebKit::TextChecker::updateSpellingUIWithGrammarString): Ditto. * WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm: (WebKit::TextCheckingControllerProxy::rangeAndOffsetRelativeToSelection): Ditto. (WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): Ditto. (WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions): Ditto. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::deleteSurrounding): Ditto. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getPlatformEditorState const): Small tweak. (WebKit::WebPage::updateSelectionWithDelta): Ditto. (WebKit::WebPage::requestDocumentEditingContext): Ditto. 2020-03-29 Daniel Bates Attempt to fix the Mac Catalyst build after r258989 Remove code that has since been moved to WebPage::platformNeedsLayoutForEditorState(). * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getPlatformEditorState const): 2020-03-29 ddkilzer@apple.com Build fix for: [iOS] Delay process suspension for a while after loading an app link https://bugs.webkit.org/show_bug.cgi?id=209686#c12 * UIProcess/Cocoa/NavigationState.mm: (WebKit::tryInterceptNavigation): - Restrict call to WebPageProxy::willOpenAppLink() to PLATFORM(IOS_FAMILY) to fix the build. 2020-03-29 David Kilzer REGRESSION (r257867): [GPUP] Use-after-move in RemoteCDMInstance::createSession() Reviewed by Darin Adler. * WebProcess/GPU/media/RemoteCDMInstance.cpp: (WebKit::RemoteCDMInstance::createSession): Fix use-after-move by using RemoteCDMInstanceSession::identifier(). * WebProcess/GPU/media/RemoteCDMInstanceSession.h: (RemoteCDMInstanceSession::identifier): Add getter. 2020-03-28 Devin Rousso Web Inspector: support editing cookie key/values from inspector https://bugs.webkit.org/show_bug.cgi?id=31157 Reviewed by Timothy Hatcher. * WebProcess/WebPage/WebCookieJar.h: * WebProcess/WebPage/WebCookieJar.cpp: (WebKit::WebCookieJar::setRawCookie): * NetworkProcess/NetworkConnectionToWebProcess.messages.in: * NetworkProcess/NetworkConnectionToWebProcess.h: * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::setRawCookie): Added. 2020-03-28 David Kilzer REGRESSION (r258201): Use-after-move in UserMediaCaptureManager::Source::didFail() Reviewed by Darin Adler. * WebProcess/cocoa/UserMediaCaptureManager.cpp: (WebKit::UserMediaCaptureManager::Source::didFail): - Use `m_errorMessage` to fix the use-after-move. 2020-03-28 Alex Christensen REGRESSION(r257963) UI process crashes when setting navigation delegate inside navigation delegate callbacks https://bugs.webkit.org/show_bug.cgi?id=209705 Reviewed by Darin Adler. I introduced a pattern of making multiple delegate calls sequentially. This is bad because the delegate can change. We need to go back to the WebPageProxy and get the navigation client again between calls. I manually verified this fixes the crash in the radar. Covered by modifying an existing API test to modify the navigation delegate in a callback. * UIProcess/API/APINavigationClient.h: (API::NavigationClient::didStartProvisionalNavigation): (API::NavigationClient::didStartProvisionalLoadForFrame): (API::NavigationClient::didFailProvisionalNavigationWithError): (API::NavigationClient::didFailProvisionalLoadWithErrorForFrame): (API::NavigationClient::didCommitNavigation): (API::NavigationClient::didCommitLoadForFrame): (API::NavigationClient::didFinishNavigation): (API::NavigationClient::didFinishLoadForFrame): (API::NavigationClient::didFailNavigationWithError): (API::NavigationClient::didFailLoadWithErrorForFrame): * UIProcess/API/C/WKPage.cpp: (WKPageSetPageNavigationClient): * UIProcess/API/glib/WebKitNavigationClient.cpp: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::~NavigationState): (WebKit::NavigationState::NavigationClient::didStartProvisionalNavigation): (WebKit::NavigationState::NavigationClient::didStartProvisionalLoadForFrame): (WebKit::NavigationState::NavigationClient::didFailProvisionalNavigationWithError): (WebKit::NavigationState::NavigationClient::didFailProvisionalLoadWithErrorForFrame): (WebKit::NavigationState::NavigationClient::didCommitNavigation): (WebKit::NavigationState::NavigationClient::didCommitLoadForFrame): (WebKit::NavigationState::NavigationClient::didFinishNavigation): (WebKit::NavigationState::NavigationClient::didFinishLoadForFrame): (WebKit::NavigationState::NavigationClient::didFailNavigationWithError): (WebKit::NavigationState::NavigationClient::didFailLoadWithErrorForFrame): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::didStartProvisionalLoadForFrameShared): (WebKit::WebPageProxy::didFailProvisionalLoadForFrameShared): (WebKit::WebPageProxy::didCommitLoadForFrame): (WebKit::WebPageProxy::didFinishLoadForFrame): (WebKit::WebPageProxy::didFailLoadForFrame): 2020-03-28 David Kilzer Use-after-move in NetworkProcess::addServiceWorkerSession() Reviewed by Darin Adler. * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::addServiceWorkerSession): - Use `addResult.iterator->value.databasePath` instead of the `serviceWorkerRegistrationDirectory` parameter to fix the use-after-move. 2020-03-28 Chris Dumez [iOS] Delay process suspension for a while after loading an app link https://bugs.webkit.org/show_bug.cgi?id=209686 Reviewed by Darin Adler. Client apps that rely on WebKit to open app links cannot call the [WKWebView _willOpenAppLink] SPI that was added in r259146. Instead, we need to call WebPageProxy::willOpenAppLink() in tryInterceptNavigation() when WebKit opens the AppLink itself. * UIProcess/Cocoa/NavigationState.mm: (WebKit::tryInterceptNavigation): 2020-03-28 Alex Christensen Deprecate injected bundle page group SPI https://bugs.webkit.org/show_bug.cgi?id=209687 Reviewed by Timothy Hatcher. This old code is problematic, and the use of it is being removed in rdar://problem/60987265 * Shared/WebPageGroupData.cpp: (WebKit::WebPageGroupData::encode const): (WebKit::WebPageGroupData::decode): * Shared/WebPageGroupData.h: * UIProcess/WebPageGroup.cpp: (WebKit::WebPageGroup::WebPageGroup): * WebProcess/InjectedBundle/API/c/WKBundle.cpp: (WKBundleAddUserScript): (WKBundleAddUserStyleSheet): (WKBundleRemoveUserScript): (WKBundleRemoveUserStyleSheet): (WKBundleRemoveUserScripts): (WKBundleRemoveUserStyleSheets): (WKBundleRemoveAllUserContent): * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::addUserScript): Deleted. (WebKit::InjectedBundle::addUserStyleSheet): Deleted. (WebKit::InjectedBundle::removeUserScript): Deleted. (WebKit::InjectedBundle::removeUserStyleSheet): Deleted. (WebKit::InjectedBundle::removeUserScripts): Deleted. (WebKit::InjectedBundle::removeUserStyleSheets): Deleted. (WebKit::InjectedBundle::removeAllUserContent): Deleted. * WebProcess/InjectedBundle/InjectedBundle.h: * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::WebPageGroupProxy): (WebKit::WebPageGroupProxy::userContentController): Deleted. * WebProcess/WebPage/WebPageGroupProxy.h: 2020-03-27 Wenson Hsieh Web content processes should not be able to arbitrarily request pasteboard data from the UI process https://bugs.webkit.org/show_bug.cgi?id=209657 Reviewed by Geoff Garen. This patch adds a mechanism to prevent the UI process from sending pasteboard data to the web process in response to WebPasteboardProxy IPC messages, unless the user (or the WebKit client, on behalf of the user) has explicitly made the contents of the pasteboard available to a page in that web process. We determine the latter by maintaining information about the `changeCount`s of each pasteboard we allow each web process to read. This mapping is updated when either the user interacts with trusted UI (context menus, DOM paste menu) for pasting, or an API client calls into -[WKWebView paste:], as is the case when pasting via the callout bar on iOS or pasting via keyboard shortcuts (i.e. cmd + V) on macOS and iOS. See per-change comments below for more details. Under normal circumstances, there should be no change in behavior; refer to the radar for more context. * UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::grantAccessToCurrentPasteboardData): Add a helper method to grant access to the data currently on the pasteboard with the given name; for now, this grants access to all related pages that reside in the same web process, but this may be refactored in a future change to make the mapping granular to each WebPageProxy rather than WebProcessProxy. (Note: it is _critical_ that this method is never invoked as a result of IPC from the web process.) * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::grantAccessToCurrentData): Helper method to grant access to the current contents on the named pasteboard. Calling this method updates `m_pasteboardNameToChangeCountAndProcessesMap`, such that the given web process is able to read from the pasteboard with the given name, as long as the `changeCount` is still the same. To implement this behavior, we either (1) add the process to an existing `WeakHashSet` of process proxies in the case where the `changeCount` is the same as it was when we added the existing `WeakHashSet`, or in all other cases, (2) add a replace the current (changeCount, processes) pair with the new change count and a weak set containing only the given WebProcessProxy. (WebKit::WebPasteboardProxy::revokeAccessToAllData): Helper method to revoke all pasteboard access for the given WebProcessProxy. Called when resetting state, e.g. after web process termination. (WebKit::WebPasteboardProxy::canAccessPasteboardData const): Private helper method to check whether an IPC message can access pasteboard data, based on the IPC::Connection used to receive the message. This helper method returns true if either the WebKit client has used SPI (both DOMPasteAllowed and JavaScriptCanAccessClipboard) to grant unmitigated access to the clipboard from the web process, or access has been previously granted due to user interaction in the UI process or API calls made directly by the WebKit client. (WebKit::WebPasteboardProxy::didModifyContentsOfPasteboard): Private helper method to update the pasteboard changeCount that has been granted to a given web process, in the case where that web process was also responsible for writing data to the pasteboard and the pasteboard changeCount prior to modifying the pasteboard was still valid. In other words, we should always allow a web process to read contents it has just written. This allows us to maintain the use case where a WKWebView client copies and pastes using back-to-back API calls: ``` [webView copy:nil]; [webView paste:nil]; ``` (WebKit::WebPasteboardProxy::getPasteboardPathnamesForType): Add a FIXME to add the `canAccessPasteboardData` check here as well. We can't do this yet because the web process currently relies on being able to read the full list of pasteboard path names when dragging over the page, but this will be fixed in a followup patch in the near future (see https://webkit.org/b/209671). (WebKit::WebPasteboardProxy::getPasteboardStringForType): (WebKit::WebPasteboardProxy::getPasteboardStringsForType): (WebKit::WebPasteboardProxy::getPasteboardBufferForType): (WebKit::WebPasteboardProxy::getPasteboardColor): (WebKit::WebPasteboardProxy::getPasteboardURL): In all the call sites where we ask for pasteboard data (with the exception of getPasteboardPathnamesForType, for the time being), check whether we're allowed to read pasteboard data by consulting canAccessPasteboardData. If not, return early with no data. (WebKit::WebPasteboardProxy::addPasteboardTypes): (WebKit::WebPasteboardProxy::setPasteboardTypes): (WebKit::WebPasteboardProxy::setPasteboardURL): (WebKit::WebPasteboardProxy::setPasteboardColor): (WebKit::WebPasteboardProxy::setPasteboardStringForType): In all the call sites where we knowingly mutate the pasteboard (and bump the changeCount as a result), additionally update the changeCount to which we've granted access on behalf of the web process that is modifying the pasteboard. (WebKit::WebPasteboardProxy::urlStringSuitableForLoading): (WebKit::WebPasteboardProxy::setPasteboardBufferForType): (WebKit::WebPasteboardProxy::writeCustomData): (WebKit::WebPasteboardProxy::readStringFromPasteboard): (WebKit::WebPasteboardProxy::readURLFromPasteboard): (WebKit::WebPasteboardProxy::readBufferFromPasteboard): (WebKit::WebPasteboardProxy::writeURLToPasteboard): (WebKit::WebPasteboardProxy::writeWebContentToPasteboard): (WebKit::WebPasteboardProxy::writeImageToPasteboard): (WebKit::WebPasteboardProxy::writeStringToPasteboard): (See comments above). * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::performDragOperation): When performing a drop on macOS, grant temporary access to the drag pasteboard. (WebKit::WebViewImpl::requestDOMPasteAccess): (WebKit::WebViewImpl::handleDOMPasteRequestWithResult): If the user has granted DOM paste access, additionally grant access to the general pasteboard. * UIProcess/WebPageProxy.cpp: (WebKit::isPasteCommandName): (WebKit::WebPageProxy::executeEditCommand): When executing an edit command on behalf of a WebKit client, check to see if it is a paste command (one of the four that are defined in EditorCommand.cpp). If so, we grant access to the current contents of the general pasteboard. * UIProcess/WebPageProxy.h: * UIProcess/WebPasteboardProxy.cpp: (WebKit::WebPasteboardProxy::webProcessProxyForConnection const): Add a helper method to map a given IPC::Connection to a WebProcessProxy. While we have a list of WebProcessProxy objects, we know a priori that at most one of them will have the given connection, so returning a single `WebProcessProxy*` here is sufficient (rather than a list of `WebProcessProxy*`s). (WebKit::WebPasteboardProxy::allPasteboardItemInfo): (WebKit::WebPasteboardProxy::informationForItemAtIndex): (WebKit::WebPasteboardProxy::getPasteboardItemsCount): (WebKit::WebPasteboardProxy::readURLFromPasteboard): (WebKit::WebPasteboardProxy::readBufferFromPasteboard): (WebKit::WebPasteboardProxy::readStringFromPasteboard): (WebKit::WebPasteboardProxy::urlStringSuitableForLoading): Update interface stubs for non-Cocoa platforms. * UIProcess/WebPasteboardProxy.h: * UIProcess/WebPasteboardProxy.messages.in: Decorate more IPC endpoints with `WantsConnection`, so that we can reason about the `IPC::Connection`s used to receive pasteboard messages. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _handleDOMPasteRequestWithResult:]): If the user has granted DOM paste access, additionally grant access to the general pasteboard. (-[WKContentView dropInteraction:performDrop:]): When performing a drop on iOS, grant temporary access to the drag pasteboard. * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::willPerformPasteCommand): * UIProcess/libwpe/WebPasteboardProxyLibWPE.cpp: (WebKit::WebPasteboardProxy::readStringFromPasteboard): * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::platformDidSelectItemFromActiveContextMenu): Grant pasteboard access when using the context menu to paste on macOS. (WebKit::WebPageProxy::willPerformPasteCommand): Grant pasteboard access when triggering the "Paste" edit command using WebKit SPI. 2020-03-27 Chris Dumez [iOS] Delay process suspension for a while after loading an app link https://bugs.webkit.org/show_bug.cgi?id=209686 Reviewed by Darin Adler. Delay process suspension for a while after loading an app link. This will allow the page's script to pass information more reliably to the native app handling the navigation. This patch adds a [WKWebView _willOpenAppLink] SPI that the client needs to call before opening the app link. * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/API/ios/WKWebViewIOS.mm: (-[WKWebView _willOpenAppLink]): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::close): * UIProcess/WebPageProxy.h: * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::willOpenAppLink): 2020-03-27 David Kilzer NetworkConnectionToWebProcess::registerBlobURLOptionallyFileBacked should validate its parameters Reviewed by Alex Christensen. * NetworkProcess/NetworkConnectionToWebProcess.cpp: (NETWORK_PROCESS_MESSAGE_CHECK): - Define/undef macro for killing WebContent process when an invalid IPC message is received. (WebKit::NetworkConnectionToWebProcess::registerBlobURLOptionallyFileBacked): - Use NETWORK_PROCESS_MESSAGE_CHECK to validate its parameters. 2020-03-27 Tim Horton Unable to build WebKit with iOS 13.4 SDK https://bugs.webkit.org/show_bug.cgi?id=209317 Reviewed by Dean Jackson. * Platform/spi/ios/UIKitSPI.h: One more attempt. __IPHONE_OS_VERSION_MAX_ALLOWED is inaccurate. 2020-03-27 Daniel Bates Use -_hasFocusedElement in -_didUpdateInputMode https://bugs.webkit.org/show_bug.cgi?id=209662 Reviewed by Wenson Hsieh. Remove duplication by using -_hasFocusedElement. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _didUpdateInputMode:]): 2020-03-27 Wenson Hsieh DragData::containsURL() should avoid reading URL strings from the pasteboard https://bugs.webkit.org/show_bug.cgi?id=209642 Work towards Reviewed by Tim Horton. See WebCore/ChangeLog for more details. * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::containsURLStringSuitableForLoading): (WebKit::WebPasteboardProxy::urlStringSuitableForLoading): * UIProcess/WebPasteboardProxy.cpp: (WebKit::WebPasteboardProxy::containsURLStringSuitableForLoading): (WebKit::WebPasteboardProxy::urlStringSuitableForLoading): * UIProcess/WebPasteboardProxy.h: * UIProcess/WebPasteboardProxy.messages.in: Add IPC plumbing for the new pasteboard strategy methods: containsURLStringSuitableForLoading and urlStringSuitableForLoading. * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: (WebKit::WebPlatformStrategies::containsURLStringSuitableForLoading): (WebKit::WebPlatformStrategies::urlStringSuitableForLoading): * WebProcess/WebCoreSupport/WebPlatformStrategies.h: 2020-03-27 youenn fablet Filter DOMCache records in network process to reduce the number of records being sent to WebProcess https://bugs.webkit.org/show_bug.cgi?id=209469 Reviewed by Alex Christensen. Receive new retrieve record options and make use of them to filter the records sent back to the WebProcess. This includes filtering the records for a given requests. This includes removing responses in case the request is made to gather all requests for Cache.keys(). * NetworkProcess/cache/CacheStorageEngine.cpp: (WebKit::CacheStorage::Engine::retrieveRecords): * NetworkProcess/cache/CacheStorageEngine.h: * NetworkProcess/cache/CacheStorageEngineCache.cpp: (WebKit::CacheStorage::Cache::retrieveRecords): * NetworkProcess/cache/CacheStorageEngineCache.h: * NetworkProcess/cache/CacheStorageEngineConnection.cpp: (WebKit::CacheStorageEngineConnection::retrieveRecords): * NetworkProcess/cache/CacheStorageEngineConnection.h: * NetworkProcess/cache/CacheStorageEngineConnection.messages.in: * WebProcess/Cache/WebCacheStorageConnection.cpp: (WebKit::WebCacheStorageConnection::retrieveRecords): * WebProcess/Cache/WebCacheStorageConnection.h: 2020-03-27 Chris Lord [GTK][WPE] Enable kinetic scrolling with async scrolling https://bugs.webkit.org/show_bug.cgi?id=209230 Reviewed by Žan Doberšek. Modify WPE mousewheel event delivery so that it includes the necessary phases needed to infer press/release times and allow for kinetic scrolling. * Shared/NativeWebWheelEvent.h: * Shared/WebEvent.h: * Shared/WebWheelEvent.cpp: (WebKit::WebWheelEvent::encode const): (WebKit::WebWheelEvent::decode): * Shared/libwpe/NativeWebWheelEventLibWPE.cpp: (WebKit::NativeWebWheelEvent::NativeWebWheelEvent): * Shared/libwpe/WebEventFactory.cpp: (WebKit::WebEventFactory::createWebWheelEvent): * Shared/libwpe/WebEventFactory.h: * UIProcess/API/wpe/PageClientImpl.cpp: (WebKit::PageClientImpl::doneWithTouchEvent): * UIProcess/API/wpe/ScrollGestureController.cpp: (WebKit::ScrollGestureController::handleEvent): * UIProcess/API/wpe/ScrollGestureController.h: (WebKit::ScrollGestureController::phase): * UIProcess/API/wpe/WPEView.cpp: (WKWPE::m_backend): 2020-03-26 David Kilzer NetworkConnectionToWebProcess::domCookiesForHost should validate its `host` parameter Reviewed by Alex Christensen. * NetworkProcess/NetworkConnectionToWebProcess.cpp: (NETWORK_PROCESS_MESSAGE_CHECK_COMPLETION): - Define/undef macro for killing WebContent process when an invalid IPC message is received. (WebKit::NetworkConnectionToWebProcess::domCookiesForHost): - Use NETWORK_PROCESS_MESSAGE_CHECK_COMPLETION) to validate `host` parameter. 2020-03-26 Chris Dumez REGRESSION: Unable to show Web Inspector on empty tabs in Safari https://bugs.webkit.org/show_bug.cgi?id=209639 Reviewed by Darin Adler. Make sure we launch the WebPageProxy's initial process when trying to inspect the page using Web Inspector (i.e. WebInspectorProxy::connect() is called). * UIProcess/Inspector/WebInspectorProxy.cpp: (WebKit::WebInspectorProxy::WebInspectorProxy): - Take in a reference instead of a raw pointer as it could never be null. - Store the inspected page and add the message receiver to its process, even if the process is the dummy one (due to delayed process launch). (WebKit::WebInspectorProxy::invalidate): Call reset() to avoid code duplication. (WebKit::WebInspectorProxy::connect): Launch the page's initial process if necessary before trying to send IPC to that process. (WebKit::WebInspectorProxy::updateForNewPageProcess): Take in a reference instead of a raw pointer as it could never be null. * UIProcess/Inspector/WebInspectorProxy.h: (WebKit::WebInspectorProxy::create): Take in a reference instead of a raw pointer as it could never be null. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::launchProcess): Call WebInspectorProxy::reset() before launching and connecting to the new process. This is important now that the WebInspectorProxy connect to the dummy process proxy. We need to make sure the WebInspectorProxy disconnects from the dummy process proxy because we connect it to the newly launched process. (WebKit::WebPageProxy::finishAttachingToWebProcess): 2020-03-26 Chris Dumez Regression: Unable to trigger context menu on empty tabs in Safari https://bugs.webkit.org/show_bug.cgi?id=209628 Reviewed by Geoffrey Garen. Launch the WebPageProxy's initial process if it starts processing mouse events. As an optimization, the WebPageProxy only launches its initial process when it really needs to. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::handleMouseEvent): 2020-03-26 Michael Catanzaro Fix various compiler warnings https://bugs.webkit.org/show_bug.cgi?id=209438 Reviewed by Darin Adler. * UIProcess/API/C/WKPage.cpp: Suppress -Wdeprecated-declaration warnings. (WKPageSetPageLoaderClient): (WKPageSetPagePolicyClient): 2020-03-26 Daniel Bates Rename -_isInteractingWithFocusedElement, add it to the header, and replace calls to hasFocusedElement() with it https://bugs.webkit.org/show_bug.cgi?id=209623 Reviewed by Simon Fraser. Rename -_isInteractingWithFocusedElement to -_hasFocusedElement. For now, standardize around the convention of using -_hasFocusedElement instead of hasFocusedElement(_focusedElementInformation). I think in the ideal world -_hasFocusedElement would not exist and instead -_elementDidBlur would reset the state of _focusedElementInformation to what it was when a page is first loaded. I will look to do this in a subsequent patch because it is risky. Doing so requires a careful audit of all call sites that use _focusedElementInformation as they may have inadvertently depended on stale state. While I am here, I added -_hasFocusedElement to WKContentViewInteraction.h so that I can make use of it in the fix for . * UIProcess/ios/WKContentViewInteraction.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:nodeHasBuiltInClickHandling:]): (-[WKContentView inputViewForWebView]): (-[WKContentView _selectionClipRect]): (-[WKContentView gestureRecognizerShouldBegin:]): (-[WKContentView canPerformActionForWebView:withSender:]): (-[WKContentView _hasFocusedElement]): (-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]): (-[WKContentView selectPositionAtPoint:completionHandler:]): (-[WKContentView selectPositionAtBoundary:inDirection:fromPoint:completionHandler:]): (-[WKContentView selectTextWithGranularity:atPoint:completionHandler:]): (-[WKContentView updateSelectionWithExtentPoint:completionHandler:]): (-[WKContentView updateSelectionWithExtentPoint:withBoundary:completionHandler:]): (-[WKContentView setSelectedTextRange:]): (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): (-[WKContentView _updateInputContextAfterBlurringAndRefocusingElement]): (-[WKContentView _updateSelectionAssistantSuppressionState]): (-[WKContentView _autofillContext]): (hasFocusedElement): Deleted. (-[WKContentView _isInteractingWithFocusedElement]): Deleted. 2020-03-26 Daniel Bates Remove hitTestOrder from ElementContext as it is no longer need https://bugs.webkit.org/show_bug.cgi?id=209561 Reviewed by Wenson Hsieh. Revert the temporary workaround made in r257749 as has been fixed: WebKit no longer needs to explicitly annotate the resulting elements found in textInputContextsInRect() with their hit test order. Instead client code has been updated to assume these elements are returned in hit test order. * UIProcess/API/Cocoa/_WKTextInputContext.mm: (-[_WKTextInputContext _hitTestOrder]): Deleted. * UIProcess/API/Cocoa/_WKTextInputContextInternal.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::textInputContextsInRect): (WebKit::WebPage::contextForElement const): 2020-03-26 Tim Horton Pinch to zoom gesture has to be repeated twice if the cursor isn't moved between gestures https://bugs.webkit.org/show_bug.cgi?id=203132 Reviewed by Simon Fraser. * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::endMagnificationGesture): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::didEndMagnificationGesture): Plumb the end of a pinch-zoom gesture to EventHandler. 2020-03-26 Chris Dumez Regression(r258949) Safari sometimes crashes when becoming the foreground application https://bugs.webkit.org/show_bug.cgi?id=209620 Reviewed by Per Arne Vollan. Make sure m_activationObserver gets unregistered on all Cocoa platforms, not just on iOS. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::unregisterNotificationObservers): 2020-03-26 Daniel Bates WebPage::selectPositionAtPoint() does not focus an element in a non-focused frame https://bugs.webkit.org/show_bug.cgi?id=209559 Reviewed by Wenson Hsieh. Call setFocusedFrameBeforeSelectingTextAtLocation() in WebPage::selectPositionAtPoint() to update the focused frame before performing the selection. This way the target element will be focused by the selection, if not already focused. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::selectPositionAtPoint): 2020-03-26 Fujii Hironori WebKitTestRunner should enable ResourceLoadStatistics also for non-Cocoa ports https://bugs.webkit.org/show_bug.cgi?id=209410 Reviewed by Youenn Fablet. NetworkSession's member variables for ResourceLoadStatistics were initialized only for Cocoa port. They also should be initialized for non-Cocoa ports. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): Added member initializers for ResourceLoadStatistics. * NetworkProcess/NetworkSession.h: Have m_resourceLoadStatisticsDirectory only if ENABLE(RESOURCE_LOAD_STATISTICS). * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): Removed the code to initialize member variables for ResourceLoadStatistics. 2020-03-26 Kate Cheney Guard AppBound domain protections with PLATFORM(iOS_FAMILY) https://bugs.webkit.org/show_bug.cgi?id=209615 Reviewed by Darin Adler. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomain): 2020-03-26 Brent Fulgham [iOS] Deny mach lookup to 'com.apple.webinspector' in the WebContent process. https://bugs.webkit.org/show_bug.cgi?id=207170 Reviewed by Per Arne Vollan. We now dynamically add access to the 'com.apple.webinspector' service, so we should remove the blanket allow rule from the sandbox. * GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in: * Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb: * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-03-26 Daniel Bates REGRESSION (r258989): ASSERTION FAILED: !isMissingPostLayoutData in WebKit::EditorState::PostLayoutData https://bugs.webkit.org/show_bug.cgi?id=209570 Reviewed by Darin Adler. Send an editor state update before responding to a request for position information to ensure that the UI process has up-to-date selection state. Otherwise, calling code that uses this information to determine whether to query for the selection text will cause an assertion failure. This fixes the test failure TestWebKitAPI.ActionSheetTests.DataDetectorsLinkIsNotPresentedAsALink caused by r258989. Following r258989 WebKit now accurately reports whether editor state has or does not have post-layout details. Prior to this the default EditorState was marked as having post-layout data even if it did not actually have such data. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getPositionInformation): (WebKit::WebPage::requestPositionInformation): 2020-03-26 David Quesada Add SPI to specify whether file upload panels are uploading to an enterprise-managed destination https://bugs.webkit.org/show_bug.cgi?id=209607 rdar://problem/60888386 Reviewed by Darin Adler. When presenting the file upload panel, set the UIDocumentPickerViewController.isContentManaged property to a value ultimately provided by the UI delegate. This can be used to prevent the upload of personal data to enterprise websites on managed devices configured to prevent such a transfer. * Platform/spi/ios/UIKitSPI.h: * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/PageClient.h: (WebKit::PageClient::handleRunOpenPanel): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::runOpenPanel): * UIProcess/ios/PageClientImplIOS.h: * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::handleRunOpenPanel): * UIProcess/ios/WKContentViewInteraction.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _showRunOpenPanel:frameInfo:resultListener:]): (-[WKContentView fileUploadPanelDestinationIsManaged:]): (-[WKContentView _showRunOpenPanel:resultListener:]): Deleted. * UIProcess/ios/forms/WKFileUploadPanel.h: * UIProcess/ios/forms/WKFileUploadPanel.mm: (-[WKFileUploadPanel showFilePickerMenu]): 2020-03-26 Dean Jackson Force Touch preview on file:/// URL works while clicking on the URL is blocked https://bugs.webkit.org/show_bug.cgi?id=209589 Reviewed by Antoine Quint. The immediate action for links should never trigger on file: URLs. * UIProcess/mac/WKImmediateActionController.mm: (-[WKImmediateActionController _defaultAnimationController]): 2020-03-26 Per Arne Vollan [iOS] Deny mach lookup access to frontboard services in the WebContent process https://bugs.webkit.org/show_bug.cgi?id=209604 Reviewed by Darin Adler. Deny mach lookup access to "com.apple.frontboard.systemappservices" in the WebContent process on iOS. Test: fast/sandbox/ios/sandbox-mach-lookup.html * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-03-26 Per Arne Vollan [iOS] Adopt ScreenProperties class. https://bugs.webkit.org/show_bug.cgi?id=191767 Reviewed by Brent Fulgham. Make relevent macOS platform code cross platform. * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode const): (WebKit::WebProcessCreationParameters::decode): * Shared/WebProcessCreationParameters.h: * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::setScreenProperties): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: 2020-03-26 David Kilzer MESSAGE_CHECK base macros should use UNLIKELY() Reviewed by Youenn Fablet. * Platform/IPC/Connection.h: (MESSAGE_CHECK_COMPLETION_BASE): (MESSAGE_CHECK_WITH_RETURN_VALUE_BASE): - Add UNLIKELY() macro since these code paths should not be taken under normal conditions. - Add curly braces to multi-line do-while loops per WebKit style guidelines, and is required after moving the ASSERT(). - Move the ASSERT() outside the if statement since that's more idomatic. 2020-03-26 Per Arne Vollan [Cocoa] Fix incorrect rebase https://bugs.webkit.org/show_bug.cgi?id=209600 Reviewed by Brent Fulgham. A rebase went wrong in and placed the method call to enableRemoteInspectorIfNeeded() in the wrong method. It should be called in WebProcessProxy::didFinishLaunching. * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::mayBecomeUnresponsive): (WebKit::WebProcessProxy::didFinishLaunching): 2020-03-26 Michael Catanzaro [GTK] Crash in WebKit::LayerTreeHost::LayerTreeHost with bubblewrap sandbox enabled https://bugs.webkit.org/show_bug.cgi?id=209106 Reviewed by Carlos Garcia Campos. Don't bind the WaylandCompositor socket unless we're running under Wayland and it's actually started successfully. * UIProcess/Launcher/glib/BubblewrapLauncher.cpp: (WebKit::bindWayland): 2020-03-26 David Kilzer VideoFullscreenManagerProxy::setupFullscreenWithID should message check videoLayerID Reviewed by Eric Carlson. * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm: (MESSAGE_CHECK): Define (and undef) new macro for assertions. (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID): Change ASSERT() to MESSAGE_CHECK(). 2020-03-26 Michael Catanzaro Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) in IPC::Connection::sendOutgoingMessage https://bugs.webkit.org/show_bug.cgi?id=146729 Reviewed by Carlos Garcia Campos. The entire MessageInfo is passed to write(), so we have to zero the padding bytes to avoid writing uninitialized memory. * Platform/IPC/unix/UnixMessage.h: (IPC::MessageInfo::MessageInfo): 2020-03-25 Timothy Horton Unable to build WebKit with iOS 13.4 SDK https://bugs.webkit.org/show_bug.cgi?id=209317 * Platform/spi/ios/UIKitSPI.h: Address post-landing review comment; use SDK conditionals, not deployment target conditionals, since SPI headers are mimicing SDK content. 2020-03-25 Ryosuke Niwa Mini browser immediately hit an assertion in debug build https://bugs.webkit.org/show_bug.cgi?id=209575 Reviewed by Simon Fraser. Use 1 instead of 0 as the desination ID to avoid hitting assertions. * WebProcess/GPU/media/RemoteAudioSession.cpp: (WebKit::RemoteAudioSession::RemoteAudioSession): (WebKit::RemoteAudioSession::~RemoteAudioSession): 2020-03-25 Tim Horton Unable to build WebKit with iOS 13.4 SDK https://bugs.webkit.org/show_bug.cgi?id=209317 Reviewed by Megan Gardner. * Platform/spi/ios/UIKitSPI.h: Stop defining some UIKit SPI that is now API (hurray!). 2020-03-25 Per Arne Vollan [macOS] Fix sandbox violations related to media playback https://bugs.webkit.org/show_bug.cgi?id=209568 Reviewed by Brent Fulgham. Fix observed sandbox violations during media playback. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::mediaRelatedMachServices): 2020-03-25 Daniel Bates Element context character rects may be in wrong coordinate system https://bugs.webkit.org/show_bug.cgi?id=209493 Reviewed by Wenson Hsieh. Convert the character rects from content view coordinates to root view coordinates as that is the coordinate system callers of -requestDocumentContext expect. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestDocumentEditingContext): 2020-03-25 Wenson Hsieh Rename "data interaction pasteboard" to "drag and drop pasteboard" https://bugs.webkit.org/show_bug.cgi?id=209556 Reviewed by Tim Horton. Adopt Pasteboard::nameOfDragPasteboard instead of the literal string "data interaction pasteboard". * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView dropInteraction:sessionDidEnter:]): (-[WKContentView dropInteraction:sessionDidUpdate:]): (-[WKContentView dropInteraction:sessionDidExit:]): (-[WKContentView dropInteraction:performDrop:]): 2020-03-25 Brady Eidson Some WKWebView.h header doc cleanup. https://bugs.webkit.org/show_bug.cgi?id=209549 Reviewed by Simon Fraser. * UIProcess/API/Cocoa/WKWebView.h: 2020-03-25 Daniel Bates Remove newline that I accidentally added in r258989. * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: 2020-03-25 Brent Fulgham Avoid logging sensitive information for all network sessions https://bugs.webkit.org/show_bug.cgi?id=209522 Reviewed by Alex Christensen. We avoid logging sensitive information (such as visited URLs) on production builds and for ephemeral sessions. We should also avoid such logging for engineering and prerelease builds to reduce the possibility of any personally identifiable information being retained in logs. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::configurationForSessionID): Deny senstive logging for all sessions. 2020-03-24 Daniel Bates [iOS] ASSERTION FAILURE: !isMissingPostLayoutData in WebKit::EditorState::postLayoutData() https://bugs.webkit.org/show_bug.cgi?id=199960 Reviewed by Simon Fraser. Refactor the computation of editor state so that we can request that a layout be performed each time we compute the editor state as part of asking the UI process to interpret a key event. The full (read: after layout) editor state is needed for UIKit to perform a deletion because UIKit wants to know how many characters are before the selection. Otherwise, we hit an assert due to the fact the last editor state sent (when the Web process asked the UI process to interpret the key) is missing layout data. The refactoring also moves the Cocoa-common code out of the platform-independent WebPage.cpp file into WebPageCocoa.mm. One side effect of the refactoring is that we no longer allow the platformEditorState() function to override the isMissingPostLayoutData bit. Currently it can even though the calling code, the platform independent code (PIE) in WebPage, may have attached layout data. Now the PIE code sets this bit if it attached layout data and the platformEditorState() function only attaches more layout data if that bit is set. platformEditorState() never unsets that bit (i.e. sets isMissingPostLayoutData to true). The patch also removes m_isEditorStateMissingPostLayoutData in WebPage.h. This instance variable has been unused since . Also we haven't been using IncludePostLayoutDataHint::No since the last reference to it was removed in . I also renamed platformEditorState() to getPlatformEditorState() since it has an out argument. Test: editing/deleting/ios/backspace-last-character.html * Shared/EditorState.h: * UIProcess/API/glib/WebKitEditorState.cpp: (webkitEditorStateCreate): Initialize _WebKitEditorStatePrivate::typingAttributes to WEBKIT_EDITOR_TYPING_ATTRIBUTE_NONE. * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::getPlatformEditorStateCommon const): Added. Moved Cocoa-common code from WebPage.cpp to here. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::editorState const): Move Cocoa-common code to WebPageCocoa.mm. Change enum to track whether a layout should be performed. Keep the current behavior of only including post layout data if the frame view does not need a layout. This behavior is encoded in the enumerator ShouldPerformLayout::Default. which is the default argument value for the argument shouldPerformLayout. * WebProcess/WebPage/WebPage.h: (WebKit::WebPage::platformNeedsLayoutForEditorState const): Added. Non-Cocoa port implementation that returns false. * WebProcess/WebPage/glib/WebPageGLib.cpp: (WebKit::WebPage::getPlatformEditorState const): Early return if isMissingPostLayoutData is true. (WebKit::WebPage::platformEditorState const): Deleted. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::platformNeedsLayoutForEditorState const): Added. Keep the current behavior of performing a layout if we have a composition or a hardware keyboard is attached. (WebKit::WebPage::getPlatformEditorState const): Call platformEditorStateCommon(). Bail out early if isMissingPostLayoutData is true. (WebKit::WebPage::handleEditingKeyboardEvent): The important part of this patch. Request a layout when computing the editor state that we will send to the UI process. (WebKit::WebPage::platformEditorState const): Deleted. * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::getPlatformEditorState const): Call platformEditorStateCommon(). Bail out early if isMissingPostLayoutData is true. (WebKit::WebPage::platformEditorState const): Deleted. * WebProcess/WebPage/playstation/WebPagePlayStation.cpp: (WebKit::WebPage::getPlatformEditorState const): Update as needed. (WebKit::WebPage::platformEditorState const): Deleted. * WebProcess/WebPage/win/WebPageWin.cpp: (WebKit::WebPage::getPlatformEditorState const): Update as needed. (WebKit::WebPage::platformEditorState const): Deleted. 2020-03-25 Kate Cheney App-bound domain checks should provide more debugging details at script evaluation sites https://bugs.webkit.org/show_bug.cgi?id=209521 Reviewed by Chris Dumez. Return an exception because that option is available here, and also add console and release logging for consistency across app-bound domain checks. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runJavaScript): 2020-03-25 Wenson Hsieh Avoid querying pasteboard strings while dragging content over a potential drop target https://bugs.webkit.org/show_bug.cgi?id=209531 Reviewed by Tim Horton and Ryosuke Niwa. Add PasteboardStrategy and WebPasteboardProxy (IPC) plumbing; see WebCore for more details. * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::containsStringSafeForDOMToReadForType): * UIProcess/WebPasteboardProxy.cpp: (WebKit::WebPasteboardProxy::containsStringSafeForDOMToReadForType): * UIProcess/WebPasteboardProxy.h: * UIProcess/WebPasteboardProxy.messages.in: * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: (WebKit::WebPlatformStrategies::containsStringSafeForDOMToReadForType): * WebProcess/WebCoreSupport/WebPlatformStrategies.h: 2020-03-24 Daniel Bates Unreviewed, reverting r258945. Revert change that broke API tests while I investigate offline. Reverted changeset: "Element context character rects may be in wrong coordinate system" https://bugs.webkit.org/show_bug.cgi?id=209493 https://trac.webkit.org/changeset/258945 2020-03-24 John Wilander Refactor ResourceLoadStatisticsStore::registrableDomainsToDeleteOrRestrictWebsiteDataFor() to return a struct instead of a Vector of pairs https://bugs.webkit.org/show_bug.cgi?id=209463 Reviewed by Alex Christensen. This change does three things: 1. Replaces the Vector> with a new struct called RegistrableDomainsToDeleteOrRestrictWebsiteDataFor for sending around which domains to delete website data for. 2. Removes the enum WebsiteDataToRemove, replacing its structure with the members of the above mentioned struct: - domainsToDeleteAllCookiesFor - domainsToDeleteAllButHttpOnlyCookiesFor - domainsToDeleteAllNonCookieWebsiteDataFor 3. Consistently renames "domainsToDeleteFor" to "domainsToDeleteOrRestrictFor" in preparation for website data policies that are not about deletion, see for instance recently landed https://trac.webkit.org/changeset/258884. No new tests. No changed functionality. This code is covered by several existing tests. * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: (WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToDeleteOrRestrictWebsiteDataFor): (WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor): Deleted. * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: (WebKit::domainsToString): (WebKit::ResourceLoadStatisticsStore::removeDataRecords): * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::deleteAndRestrictWebsiteDataForRegistrableDomains): (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains): Deleted. * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: (WebKit::RegistrableDomainsToDeleteOrRestrictWebsiteDataFor::isolatedCopy const): (WebKit::RegistrableDomainsToDeleteOrRestrictWebsiteDataFor::isEmpty const): * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::deleteAndRestrictWebsiteDataForRegistrableDomains): (WebKit::NetworkProcess::deleteCookiesForTesting): (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains): Deleted. * NetworkProcess/NetworkProcess.h: * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::deleteAndRestrictWebsiteDataForRegistrableDomains): (WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomains): Deleted. * NetworkProcess/NetworkSession.h: 2020-03-24 Jiewen Tan [WebAuthn] Customize a bit more on the macOS LocalAuthentication prompt https://bugs.webkit.org/show_bug.cgi?id=208703 Reviewed by Brent Fulgham. Part 2. This patch adds a different LocalAuthentication prompt title for getAssertion. It also polishes the text used for makeCredential. Besides that, it also enhances the iOS title strings. * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: (WebKit::LocalAuthenticator::continueMakeCredentialAfterDecidePolicy): (WebKit::LocalAuthenticator::continueGetAssertionAfterResponseSelected): * UIProcess/WebAuthentication/Cocoa/LocalConnection.h: * UIProcess/WebAuthentication/Cocoa/LocalConnection.mm: (WebKit::LocalConnection::verifyUser const): * UIProcess/WebAuthentication/Mock/MockLocalConnection.h: * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm: (WebKit::MockLocalConnection::verifyUser const): 2020-03-24 Kate Cheney Ignore in-app browser privacy checks for apps with com.apple.private.applemediaservices entitlement https://bugs.webkit.org/show_bug.cgi?id=209509 Reviewed by Brent Fulgham. * UIProcess/WebPageProxy.cpp: (WebKit::m_ignoresAppBoundDomains): (WebKit::WebPageProxy::setIsNavigatingToAppBoundDomain): * UIProcess/WebPageProxy.h: 2020-03-24 Per Arne Vollan [Cocoa] Fix launch time regression with CF prefs direct mode enabled https://bugs.webkit.org/show_bug.cgi?id=209244 Reviewed by Darin Adler. When CF prefs direct mode was enabled in https://trac.webkit.org/changeset/258064/webkit, it introduced a significant launch time regression. This patch addresses this regression. The number of observed domains is reduced and domain observation is initiated later when Safari is first activated. Swizzling code is removed, since that has a performance cost in the Objective-C runtime. Normal priority instead of QOS_CLASS_BACKGROUND is used in the thread which starts the observing, since using a background priority class can lead to priority inversion. Finally, a dictionary comparison is removed when a notification about a preference change is received, since this check is redundant and doubles the cost of this method. * UIProcess/Cocoa/PreferenceObserver.mm: (-[WKPreferenceObserver init]): * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitialize): (WebKit::WebProcessPool::registerNotificationObservers): (WebKit::WebProcessPool::unregisterNotificationObservers): * UIProcess/WebProcessPool.h: 2020-03-24 Daniel Bates Element context character rects may be in wrong coordinate system https://bugs.webkit.org/show_bug.cgi?id=209493 Reviewed by Wenson Hsieh. Convert the character rects from content view coordinates to root view coordinates as that is the coordinate system callers of -requestDocumentContext expect. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestDocumentEditingContext): 2020-03-24 Daniel Bates Use SimpleRange in characterRectsForRange() https://bugs.webkit.org/show_bug.cgi?id=209495 Reviewed by Darin Adler. The function characterRectsForRange() is capable of working correctly with a SimpleRange instead of a Range. Callers currently pass a Range. So, there is still a conversion, but maybe someday they can pass a SimpleRange. This change is towards that future. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestDocumentEditingContext): 2020-03-24 Chris Dumez Unreviewed, reverting r258928. Broke the build Reverted changeset: "Refactor ResourceLoadStatisticsStore::registrableDomainsToDeleteOrRestrictWebsiteDataFor() to return a struct instead of a Vector of pairs" https://bugs.webkit.org/show_bug.cgi?id=209463 https://trac.webkit.org/changeset/258928 2020-03-24 John Wilander Refactor ResourceLoadStatisticsStore::registrableDomainsToDeleteOrRestrictWebsiteDataFor() to return a struct instead of a Vector of pairs https://bugs.webkit.org/show_bug.cgi?id=209463 Reviewed by Alex Christensen. This change does three things: 1. Replaces the Vector> with a new struct called RegistrableDomainsToDeleteOrRestrictWebsiteDataFor for sending around which domains to delete website data for. 2. Removes the enum WebsiteDataToRemove, replacing its structure with the members of the above mentioned struct: - domainsToDeleteAllCookiesFor - domainsToDeleteAllButHttpOnlyCookiesFor - domainsToDeleteAllNonCookieWebsiteDataFor 3. Consistently renames "domainsToDeleteFor" to "domainsToDeleteOrRestrictFor" in preparation for website data policies that are not about deletion, see for instance recently landed https://trac.webkit.org/changeset/258884. No new tests. No changed functionality. This code is covered by several existing tests. * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: (WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToDeleteOrRestrictWebsiteDataFor): (WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor): Deleted. * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: (WebKit::domainsToString): (WebKit::ResourceLoadStatisticsStore::removeDataRecords): * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::deleteAndRestrictWebsiteDataForRegistrableDomains): (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains): Deleted. * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: (WebKit::RegistrableDomainsToDeleteOrRestrictWebsiteDataFor::isolatedCopy const): (WebKit::RegistrableDomainsToDeleteOrRestrictWebsiteDataFor::isEmpty const): * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::deleteAndRestrictWebsiteDataForRegistrableDomains): (WebKit::NetworkProcess::deleteCookiesForTesting): (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains): Deleted. * NetworkProcess/NetworkProcess.h: * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::deleteAndRestrictWebsiteDataForRegistrableDomains): (WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomains): Deleted. * NetworkProcess/NetworkSession.h: 2020-03-24 Michael Catanzaro [GTK] Crash in WebKit::LayerTreeHost::LayerTreeHost with bubblewrap sandbox enabled https://bugs.webkit.org/show_bug.cgi?id=209106 Reviewed by Adrian Perez de Castro. The bubblewrap sandbox is blocking access to WebKit's nested Wayland compositor. Apparently nobody has ever tested the nested Wayland compositor with the sandbox enabled until now. * UIProcess/Launcher/glib/BubblewrapLauncher.cpp: (WebKit::bindWayland): 2020-03-24 Daniel Bates Simplify characterRectsForRange() in WebPage::requestDocumentEditingContext() https://bugs.webkit.org/show_bug.cgi?id=209462 Reviewed by Wenson Hsieh. No need to allow by-reference capture by default. Update code to take a const Range& and unsigned instead of non-const and uint64_t params. The former is const correct for this code, which doesn't modify anything. The latter is actually the max width data type callers pass. Simplify the inside of the loop by using StringView::isEmpty(). Lastly add a constant for the stride length to make the 1s less mysterious despite the name of the function alluding to this stride. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestDocumentEditingContext): 2020-03-24 Daniel Bates [iOS][WK2] Set text trait isSingleLineDocument https://bugs.webkit.org/show_bug.cgi?id=209391 Reviewed by Darin Adler. Set the SPI text trait isSingleLineDocument to NO if the focused element is a