2020-12-21 Alan Coon Cherry-pick r270998. rdar://problem/72552852 Fix some issues with PDFs as . https://bugs.webkit.org/show_bug.cgi?id=220024 Reviewed by Tim Horton. No new tests (Unable to write automated tests) * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::dataProviderGetBytesAtPositionCallback): (WebKit::PDFPlugin::getResourceBytesAtPosition): Set the correct URL. (WebKit::PDFPlugin::ByteRangeRequest::completeWithAccumulatedData): Try harder to catch mismatches in delivered bytes vs expected bytes. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270998 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-12-18 Brady Eidson Fix some issues with PDFs as . https://bugs.webkit.org/show_bug.cgi?id=220024 Reviewed by Tim Horton. No new tests (Unable to write automated tests) * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::dataProviderGetBytesAtPositionCallback): (WebKit::PDFPlugin::getResourceBytesAtPosition): Set the correct URL. (WebKit::PDFPlugin::ByteRangeRequest::completeWithAccumulatedData): Try harder to catch mismatches in delivered bytes vs expected bytes. 2020-12-15 Alan Coon Cherry-pick r270559. rdar://problem/72320712 Potential crash under [WKRemoteObjectEncoder encodeObject:forKey:] when the object graph contains a cycle https://bugs.webkit.org/show_bug.cgi?id=219620 Source/WebKit: Reviewed by Geoffrey Garen. Update WKRemoteObjectEncoder to detect cycles when encoding objects. When a cycle is detected, we first attempt to encode a default-initialized object of the same type instead. If that fails, we raise a NSInvalidArgumentException. Based on crashes in the wild, we have evidence that such cycles are occuring and I suspect this is caused by Norton Safe Web extension somehow. * Shared/API/Cocoa/WKRemoteObjectCoder.mm: (-[WKRemoteObjectEncoder init]): (encodeObject): Tools: Reviewed by Geoffrey Garen. Add API test coverage. * TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.h: * TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.mm: (TEST): * TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistryPlugIn.mm: (-[RemoteObjectRegistryPlugIn takeDictionary:completionHandler:]): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270559 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-12-08 Chris Dumez Potential crash under [WKRemoteObjectEncoder encodeObject:forKey:] when the object graph contains a cycle https://bugs.webkit.org/show_bug.cgi?id=219620 Reviewed by Geoffrey Garen. Update WKRemoteObjectEncoder to detect cycles when encoding objects. When a cycle is detected, we first attempt to encode a default-initialized object of the same type instead. If that fails, we raise a NSInvalidArgumentException. Based on crashes in the wild, we have evidence that such cycles are occuring and I suspect this is caused by Norton Safe Web extension somehow. * Shared/API/Cocoa/WKRemoteObjectCoder.mm: (-[WKRemoteObjectEncoder init]): (encodeObject): 2020-12-01 Alan Coon Cherry-pick r270072. rdar://problem/71836681 REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken https://bugs.webkit.org/show_bug.cgi?id=219190 Reviewed by Tim Horton. Source/WebKit: Some system services, such as "Convert Text to (Traditional|Simplified) Chinese", use `-[NSServicesMenuRequestor readSelectionFromPasteboard:]` to insert the contents of the given pasteboard into the current selection. After the changes in r259151, this requires the UI process to explicitly grant access to the contents of the given pasteboard, on behalf of the web content process. Fix the bug by adding the missing call to `grantAccessToCurrentPasteboardData`. This is only called from API in the UI process, so it cannot be abused by a compromised web content process to grab the contents of `NSPasteboard`. Test: PasteHTML.ReadSelectionFromPasteboard * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::readSelectionFromPasteboard): Tools: Add an API test to exercise `-readSelectionFromPasteboard:`. * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270072 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-11-19 Wenson Hsieh REGRESSION (r259151): The "Convert Text to Traditional Chinese" services menu action is broken https://bugs.webkit.org/show_bug.cgi?id=219190 Reviewed by Tim Horton. Some system services, such as "Convert Text to (Traditional|Simplified) Chinese", use `-[NSServicesMenuRequestor readSelectionFromPasteboard:]` to insert the contents of the given pasteboard into the current selection. After the changes in r259151, this requires the UI process to explicitly grant access to the contents of the given pasteboard, on behalf of the web content process. Fix the bug by adding the missing call to `grantAccessToCurrentPasteboardData`. This is only called from API in the UI process, so it cannot be abused by a compromised web content process to grab the contents of `NSPasteboard`. Test: PasteHTML.ReadSelectionFromPasteboard * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::readSelectionFromPasteboard): 2020-11-16 Russell Epstein Cherry-pick r269651. rdar://problem/71442660 [macOS] Allow IOGLESBundleName for Apple Silicon Macs https://bugs.webkit.org/show_bug.cgi?id=218774 Unreviewed follow-up fix to r269649. Two additional keys are needed: MetalPluginClassName and MetalPluginName * WebProcess/com.apple.WebProcess.sb.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269651 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-11-10 Brent Fulgham [macOS] Allow IOGLESBundleName for Apple Silicon Macs https://bugs.webkit.org/show_bug.cgi?id=218774 Unreviewed follow-up fix to r269649. Two additional keys are needed: MetalPluginClassName and MetalPluginName * WebProcess/com.apple.WebProcess.sb.in: 2020-11-16 Russell Epstein Cherry-pick r269649. rdar://problem/71442660 [macOS] Allow IOGLESBundleName for Apple Silicon Macs https://bugs.webkit.org/show_bug.cgi?id=218774 Reviewed by Tim Horton. The WebContent should be able to read the IOGLESBundleName IOKit property on Apple Silicon Macs. This will help the OpenGL stack make better choices about which bundles to load when processing WebGL content. * WebProcess/com.apple.WebProcess.sb.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269649 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-11-10 Brent Fulgham [macOS] Allow IOGLESBundleName for Apple Silicon Macs https://bugs.webkit.org/show_bug.cgi?id=218774 Reviewed by Tim Horton. The WebContent should be able to read the IOGLESBundleName IOKit property on Apple Silicon Macs. This will help the OpenGL stack make better choices about which bundles to load when processing WebGL content. * WebProcess/com.apple.WebProcess.sb.in: 2020-11-04 Alan Coon Cherry-pick r268386. rdar://problem/70970067 Cocoa: Make WebGLLayer not dependent on GraphicsContextGLOpenGL https://bugs.webkit.org/show_bug.cgi?id=217212 Patch by Kimmo Kinnunen on 2020-10-13 Reviewed by Dean Jackson. Source/WebCore: WebGLLayer was needlessly using GraphicsContextGLOpenGL. This is problematic because WebGLLayer should work with upcoming remote GraphicsContextGL implementation. The prepare callgraph was: GCGLOpenGL -> WebGLLayer -> GCGLOpenGL Refactor it to be: GCGLOpenGL -> WebGLLayer Move the back buffer ownership to the GraphicsContextGLOpenGL. Make the front buffer ownership explicit in WebGLLayer. Move the EGL bindings ownerships of all buffers to GraphicsContextGLOpenGL. Make the WebGLLayer not use EGL or OpenGL, it does not need and cannot use it as not all of its clients use OpenGL (i.e. the above mentioned remote use-case). Improves the memory usage by not allocating front buffers unless needed. In case the canvas does not present, will not allocate front buffers at all. Improves error handling of the allocations and EGL bindings. No new tests, a refactor. * WebCore.xcodeproj/project.pbxproj: * platform/graphics/angle/GraphicsContextGLANGLE.cpp: (WebCore::GraphicsContextGLOpenGL::reshapeFBOs): (WebCore::GraphicsContextGLOpenGL::prepareTexture): (WebCore::GraphicsContextGLOpenGL::prepareTextureImpl): * platform/graphics/angle/GraphicsContextGLANGLEUtilities.h: Added. (WebCore::ScopedRestoreTextureBinding::ScopedRestoreTextureBinding): (WebCore::ScopedRestoreTextureBinding::~ScopedRestoreTextureBinding): * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm: (WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL): (WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL): (WebCore::GraphicsContextGLOpenGL::makeContextCurrent): (WebCore::GraphicsContextGLOpenGL::reshapeDisplayBufferBacking): (WebCore::GraphicsContextGLOpenGL::bindDisplayBufferBacking): (WebCore::GraphicsContextGLOpenGL::prepareForDisplay): (WebCore::GraphicsContextGLOpenGL::didDisplay): * platform/graphics/cocoa/WebGLLayer.h: * platform/graphics/cocoa/WebGLLayer.mm: (-[WebGLLayer initWithClient:devicePixelRatio:]): (-[WebGLLayer copyImageSnapshotWithColorSpace:]): (-[WebGLLayer recycleBuffer]): (-[WebGLLayer prepareForDisplayWithContents:]): (-[WebGLLayer display]): (-[WebGLLayer detachClient]): * platform/graphics/cocoa/WebGLLayerClient.h: Copied from Source/WebCore/platform/graphics/cocoa/WebGLLayer.h. (WebCore::WebGLLayerClient::~WebGLLayerClient): * platform/graphics/opengl/GraphicsContextGLOpenGL.h: * platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp: (WebCore::GraphicsContextGLOpenGL::reshapeFBOs): Source/WebKit: Removed unneeded inclusions of GraphicsContextGLOpenGL.h. The file is now using non-public headers. * WebProcess/WebPage/WebPage.cpp: * WebProcess/WebPage/mac/WebPageMac.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268386 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-13 Kimmo Kinnunen Cocoa: Make WebGLLayer not dependent on GraphicsContextGLOpenGL https://bugs.webkit.org/show_bug.cgi?id=217212 Reviewed by Dean Jackson. Removed unneeded inclusions of GraphicsContextGLOpenGL.h. The file is now using non-public headers. * WebProcess/WebPage/WebPage.cpp: * WebProcess/WebPage/mac/WebPageMac.mm: 2020-11-02 Russell Epstein Cherry-pick r268199. rdar://problem/70952726 Crash under WebKit::WebProcessCache::clear() https://bugs.webkit.org/show_bug.cgi?id=217480 Reviewed by Geoffrey Garen. Source/WebKit: Protect |process| in the responsiveness check lambda in WebProcessCache::addProcessIfPossible(). If we fail to do so and WebProcessCache::clear() gets called while the responsiveness check is pending, the WebProcessProxy destructor may get called while clear() clears m_pendingAddRequests, which would resolve the responsiveness check with responsive=false, and cause the lambda to try and remove the entry from m_pendingAddRequests (while clear() is clearing it). * UIProcess/WebProcessCache.cpp: (WebKit::WebProcessCache::addProcessIfPossible): Tools: Add API test coverage. * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268199 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-08 Chris Dumez Crash under WebKit::WebProcessCache::clear() https://bugs.webkit.org/show_bug.cgi?id=217480 Reviewed by Geoffrey Garen. Protect |process| in the responsiveness check lambda in WebProcessCache::addProcessIfPossible(). If we fail to do so and WebProcessCache::clear() gets called while the responsiveness check is pending, the WebProcessProxy destructor may get called while clear() clears m_pendingAddRequests, which would resolve the responsiveness check with responsive=false, and cause the lambda to try and remove the entry from m_pendingAddRequests (while clear() is clearing it). * UIProcess/WebProcessCache.cpp: (WebKit::WebProcessCache::addProcessIfPossible): 2020-10-29 Russell Epstein Cherry-pick r269118. rdar://problem/70795320 macCatalyst WebGL on Apple Silicon devices is using a software renderer https://bugs.webkit.org/show_bug.cgi?id=218303 Reviewed by Geoffrey Garen. Source/ThirdParty/ANGLE: * src/gpu_info_util/SystemInfo.h: * src/gpu_info_util/SystemInfo_apple.mm: (angle::GetSystemInfo): We can just use the macOS version of GetSystemInfo in macCatalyst. * src/gpu_info_util/SystemInfo_macos.mm: (angle::GetSystemInfo_mac): * src/libANGLE/Display.cpp: * src/libANGLE/formatutils.cpp: (gl::BuildInternalFormatInfoMap): * src/libANGLE/renderer/gl/renderergl_utils.cpp: (rx::nativegl_gl::GenerateCaps): It turns out we must use EAGL in macCatalyst on Apple Silicon in all cases, not just in-process in iOS apps (the problem is not just about coexistence of the two GLs, but actually about our ability to load the accelerated renderer /at all/ in macCatalyst processes). I left the runtime switching in place, because there is a future in which we /can/ use CGL in non-iOS-app processes, but that future is not now. Source/WebCore: * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm: (WebCore::needsEAGLOnMac): (WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL): (WebCore::GraphicsContextGLOpenGL::IOSurfaceTextureTarget): (WebCore::GraphicsContextGLOpenGL::IOSurfaceTextureTargetQuery): (WebCore::GraphicsContextGLOpenGL::EGLIOSurfaceTextureTarget): (WebCore::isiOSAppOnMac): Deleted. See ANGLE ChangeLog. Source/WebKit: * UIProcess/mac/HighPerformanceGPUManager.mm: (WebKit::HighPerformanceGPUManager::addProcessRequiringHighPerformance): (WebKit::HighPerformanceGPUManager::removeProcessRequiringHighPerformance): (WebKit::HighPerformanceGPUManager::updateState): (WebKit::isiOSAppOnMac): Deleted. HighPerformanceGPUManager is PLATFORM(MAC)-only, which is not true for MACCATALYST, so delete this dead code. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269118 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-28 Tim Horton macCatalyst WebGL on Apple Silicon devices is using a software renderer https://bugs.webkit.org/show_bug.cgi?id=218303 Reviewed by Geoffrey Garen. * UIProcess/mac/HighPerformanceGPUManager.mm: (WebKit::HighPerformanceGPUManager::addProcessRequiringHighPerformance): (WebKit::HighPerformanceGPUManager::removeProcessRequiringHighPerformance): (WebKit::HighPerformanceGPUManager::updateState): (WebKit::isiOSAppOnMac): Deleted. HighPerformanceGPUManager is PLATFORM(MAC)-only, which is not true for MACCATALYST, so delete this dead code. 2020-10-28 Russell Epstein Cherry-pick r269094. rdar://problem/70795299 Use _CFURLConnectionSetFrameworkStubs for SecItemShim instead of DYLD_INTERPOSE on Apple Silicon Macs https://bugs.webkit.org/show_bug.cgi?id=218269 Reviewed by Darin Adler. Source/WebKit: r171066 introduced the use of _CFURLConnectionSetFrameworkStubs on iOS for CFNetwork to be able to get and set credentials as the UI process. This is also needed on Apple Silicon Macs. We should eventually replace it with an even cleaner per-NSURLSession solution, but this is a step in the right direction, and I verified manually that it fixes the radar. Covered by an API test that used to fail on Apple Silicon Macs. * Shared/mac/SecItemShim.cpp: (WebKit::initializeSecItemShim): Tools: * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm: (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269094 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-27 Alex Christensen Use _CFURLConnectionSetFrameworkStubs for SecItemShim instead of DYLD_INTERPOSE on Apple Silicon Macs https://bugs.webkit.org/show_bug.cgi?id=218269 Reviewed by Darin Adler. r171066 introduced the use of _CFURLConnectionSetFrameworkStubs on iOS for CFNetwork to be able to get and set credentials as the UI process. This is also needed on Apple Silicon Macs. We should eventually replace it with an even cleaner per-NSURLSession solution, but this is a step in the right direction, and I verified manually that it fixes the radar. Covered by an API test that used to fail on Apple Silicon Macs. * Shared/mac/SecItemShim.cpp: (WebKit::initializeSecItemShim): 2020-10-27 Russell Epstein Cherry-pick r268878. rdar://problem/70733353 UIClient isn't notified when page muted state changes https://bugs.webkit.org/show_bug.cgi?id=218085 Reviewed by Youenn Fablet. Source/WebKit: API test: WKWebView.MediaMuted * UIProcess/API/C/WKPage.cpp: (WKPageGetMediaState): reportedMediaCaptureState -> reportedMediaState. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _mediaCaptureState]): Ditto. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::updateReportedMediaCaptureState): Only record current capture state in m_reportedMediaCaptureState. m_delayStopCapturingReporting isn't necessary, remove it. * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::reportedMediaState const): Renamed from reportedMediaCaptureState to reflect what it returns. (WebKit::WebPageProxy::mediaStateFlags const): Deleted. (WebKit::WebPageProxy::reportedMediaCaptureState const): Deleted. Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme: * TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm: Added. (-[AudioStateObserver initWithWebView:]): (-[AudioStateObserver observeValueForKeyPath:ofObject:change:context:]): (-[AudioStateTestView setMuted:]): (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268878 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-22 Eric Carlson UIClient isn't notified when page muted state changes https://bugs.webkit.org/show_bug.cgi?id=218085 Reviewed by Youenn Fablet. API test: WKWebView.MediaMuted * UIProcess/API/C/WKPage.cpp: (WKPageGetMediaState): reportedMediaCaptureState -> reportedMediaState. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _mediaCaptureState]): Ditto. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::updateReportedMediaCaptureState): Only record current capture state in m_reportedMediaCaptureState. m_delayStopCapturingReporting isn't necessary, remove it. * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::reportedMediaState const): Renamed from reportedMediaCaptureState to reflect what it returns. (WebKit::WebPageProxy::mediaStateFlags const): Deleted. (WebKit::WebPageProxy::reportedMediaCaptureState const): Deleted. 2020-10-27 Russell Epstein Cherry-pick r268537. rdar://problem/70733338 Crash in -[WKDateTimePicker setDateTimePickerToInitialValue] https://bugs.webkit.org/show_bug.cgi?id=217763 Reviewed by Wenson Hsieh. Crash occurs due to the use of an autoreleased NSString in setDateTimePickerToInitialValue. To fix, make the variable a RetainPtr. * UIProcess/ios/forms/WKDateTimeInputControl.mm: (-[WKDateTimePicker setDateTimePickerToInitialValue]): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268537 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-15 Aditya Keerthi Crash in -[WKDateTimePicker setDateTimePickerToInitialValue] https://bugs.webkit.org/show_bug.cgi?id=217763 Reviewed by Wenson Hsieh. Crash occurs due to the use of an autoreleased NSString in setDateTimePickerToInitialValue. To fix, make the variable a RetainPtr. * UIProcess/ios/forms/WKDateTimeInputControl.mm: (-[WKDateTimePicker setDateTimePickerToInitialValue]): 2020-10-21 Russell Epstein Cherry-pick r268570. rdar://problem/70541887 v2: WebKit::XPCServiceEventHandler block should call exit() on the main thread Reviewed by Geoff Garen. * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm: (WebKit::XPCServiceEventHandler): - Use NSRunLoop instead of libdispatch to run code on the main thread since libdispatch can randomly pick a new main thread when exit() is called on the original main thread. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268570 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-15 David Kilzer v2: WebKit::XPCServiceEventHandler block should call exit() on the main thread Reviewed by Geoff Garen. * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm: (WebKit::XPCServiceEventHandler): - Use NSRunLoop instead of libdispatch to run code on the main thread since libdispatch can randomly pick a new main thread when exit() is called on the original main thread. 2020-10-21 Russell Epstein Cherry-pick r268602. rdar://problem/70541712 [WebAuthn] Remove the "alg" field in the attestation statement https://bugs.webkit.org/show_bug.cgi?id=217720 Reviewed by Brent Fulgham. Source/WebKit: This old field was used in an unreleased old attestation statement format and is not used by the final attestation statement format that will be added to the spec: https://github.com/w3c/webauthn/pull/1491. Therefore, remove it to resolve confusion. Covered by existing tests. * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: (WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested): LayoutTests: * http/wpt/webauthn/public-key-credential-create-success-local.https.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268602 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-16 Jiewen Tan [WebAuthn] Remove the "alg" field in the attestation statement https://bugs.webkit.org/show_bug.cgi?id=217720 Reviewed by Brent Fulgham. This old field was used in an unreleased old attestation statement format and is not used by the final attestation statement format that will be added to the spec: https://github.com/w3c/webauthn/pull/1491. Therefore, remove it to resolve confusion. Covered by existing tests. * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: (WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested): 2020-10-21 Russell Epstein Cherry-pick r268507. rdar://problem/70541950 [iOS] Allow additional sysctl reads needed by image decoding https://bugs.webkit.org/show_bug.cgi?id=217733 Reviewed by Per Arne Vollan. Telemetry on iOS 14 shows that we are hitting some sandbox violations during image decoding. We should grant access to hw.byteorder, hw.cachelinesize_compat, and hw.vectorunit. We should silence warnings about hw.cpufrequency_compat since it is not needed in web-facing use cases. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268507 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-14 Brent Fulgham [iOS] Allow additional sysctl reads needed by image decoding https://bugs.webkit.org/show_bug.cgi?id=217733 Reviewed by Per Arne Vollan. Telemetry on iOS 14 shows that we are hitting some sandbox violations during image decoding. We should grant access to hw.byteorder, hw.cachelinesize_compat, and hw.vectorunit. We should silence warnings about hw.cpufrequency_compat since it is not needed in web-facing use cases. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-10-15 Russell Epstein Cherry-pick r268377. rdar://problem/70321875 Unreviewed build fix after r268367. * Configurations/WebKit.xcconfig: Corrected the definition of WK_PDFKIT_LDFLAGS_maccatalyst. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268377 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-12 Andy Estes Unreviewed build fix after r268367. * Configurations/WebKit.xcconfig: Corrected the definition of WK_PDFKIT_LDFLAGS_maccatalyst. 2020-10-15 Russell Epstein Cherry-pick r268376. rdar://problem/70321635 Cursor window is transparent - but not hidden - when `cursor: none` is specified https://bugs.webkit.org/show_bug.cgi?id=217639 Reviewed by Simon Fraser. * Platform/spi/mac/AppKitSPI.h: * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::setCursor): Adopt new AppKit SPI to actually hide the cursor when we set it to the "none" shape. This hiding lives until the next time the app-global cursor shape is changed by any client.] We'll re-set it the next time we set the "none" shape. This is important, because on some platforms, hiding the cursor is a performance improvement over simply making it transparent. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268376 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-12 Tim Horton Cursor window is transparent - but not hidden - when `cursor: none` is specified https://bugs.webkit.org/show_bug.cgi?id=217639 Reviewed by Simon Fraser. * Platform/spi/mac/AppKitSPI.h: * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::setCursor): Adopt new AppKit SPI to actually hide the cursor when we set it to the "none" shape. This hiding lives until the next time the app-global cursor shape is changed by any client.] We'll re-set it the next time we set the "none" shape. This is important, because on some platforms, hiding the cursor is a performance improvement over simply making it transparent. 2020-10-15 Russell Epstein Cherry-pick r268367. rdar://problem/70321875 [macCatalyst] Enable WKPDFView https://bugs.webkit.org/show_bug.cgi?id=217403 Reviewed by Tim Horton. Source/WebKit: * Configurations/WebKit.xcconfig: Linked PDFKit.framework when building for the Catalyst variant on Big Sur or later. Source/WTF: * wtf/PlatformEnableCocoa.h: Enabled WKPDFView when building for the Catalyst variant on Big Sur or later. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268367 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-12 Andy Estes [macCatalyst] Enable WKPDFView https://bugs.webkit.org/show_bug.cgi?id=217403 Reviewed by Tim Horton. * Configurations/WebKit.xcconfig: Linked PDFKit.framework when building for the Catalyst variant on Big Sur or later. 2020-10-15 Russell Epstein Cherry-pick r268246. rdar://problem/70321627 AX: Website Warning page is inaccessible https://bugs.webkit.org/show_bug.cgi?id=217489 Reviewed by Zalan Bujtas. If we have a safe browsing window, we need to use that instead of the content view. * UIProcess/Cocoa/WKSafeBrowsingWarning.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::accessibilityAttributeValue): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268246 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-08 Chris Fleizach AX: Website Warning page is inaccessible https://bugs.webkit.org/show_bug.cgi?id=217489 Reviewed by Zalan Bujtas. If we have a safe browsing window, we need to use that instead of the content view. * UIProcess/Cocoa/WKSafeBrowsingWarning.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::accessibilityAttributeValue): 2020-10-14 Russell Epstein Cherry-pick r267203. rdar://problem/70310545 Rename ShouldAllowExternalSchemes to ShouldAllowExternalSchemesButNotAppLinks to clarify what this enum value is for. https://bugs.webkit.org/show_bug.cgi?id=216651 Patch by Hoa Dinh on 2020-09-17 Reviewed by Alex Christensen. Rename ShouldAllowExternalSchemes to ShouldAllowExternalSchemesButNotAppLinks and reflects the change where it's used. Source/WebCore: Source/WebCore: * loader/FrameLoaderTypes.h: * page/ContextMenuController.cpp: (WebCore::ContextMenuController::contextMenuItemSelected): Source/WebKit: Source/WebKit: * Shared/SessionState.cpp: (WebKit::isValidEnum): * UIProcess/API/APINavigationAction.h: * UIProcess/API/glib/WebKitWebViewSessionState.cpp: (toExternalURLsPolicy): (toWebCoreExternalURLsPolicy): * UIProcess/WebPageProxy.h: * UIProcess/mac/LegacySessionStateCoding.cpp: (WebKit::decodeSessionHistoryEntry): * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp: (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267203 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-17 Hoa Dinh Rename ShouldAllowExternalSchemes to ShouldAllowExternalSchemesButNotAppLinks to clarify what this enum value is for. https://bugs.webkit.org/show_bug.cgi?id=216651 Reviewed by Alex Christensen. Rename ShouldAllowExternalSchemes to ShouldAllowExternalSchemesButNotAppLinks and reflects the change where it's used. Source/WebKit: * Shared/SessionState.cpp: (WebKit::isValidEnum): * UIProcess/API/APINavigationAction.h: * UIProcess/API/glib/WebKitWebViewSessionState.cpp: (toExternalURLsPolicy): (toWebCoreExternalURLsPolicy): * UIProcess/WebPageProxy.h: * UIProcess/mac/LegacySessionStateCoding.cpp: (WebKit::decodeSessionHistoryEntry): * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp: (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction): 2020-10-14 Russell Epstein Cherry-pick r268003. rdar://problem/70267725 Make NetscapePlugInStreamLoaderClient a weak pointer on NetscapePlugInStreamLoader Reviewed by Alex Christensen. Source/WebCore: Could not write a test since reproducing a crash requires rapidly reloading a URL to a PDF at random points during the previous load. Make NetscapePlugInStreamLoaderClient a WeakPtr on NetscapePlugInStreamLoader, and add nullptr checks for NetscapePlugInStreamLoader.m_client as needed. * loader/NetscapePlugInStreamLoader.cpp: (WebCore::NetscapePlugInStreamLoader::NetscapePlugInStreamLoader): (WebCore::NetscapePlugInStreamLoader::willSendRequest): (WebCore::NetscapePlugInStreamLoader::didReceiveResponse): (WebCore::NetscapePlugInStreamLoader::didReceiveDataOrBuffer): (WebCore::NetscapePlugInStreamLoader::didFinishLoading): (WebCore::NetscapePlugInStreamLoader::didFail): (WebCore::NetscapePlugInStreamLoader::willCancel): * loader/NetscapePlugInStreamLoader.h: Source/WebKit: Making NetscapePlugInStreamLoaderClient inherit from CanMakeWeakPtr<> caused PDFPlugin to fail to compile because one of its parent classes already inherited from CanMakeWeakPtr<>. To fix this, extract a PDFPluginStreamLoaderClient class from PDFPlugin and link the lifetime of PDFPluginStreamLoaderClient to PDFPlugin. After moving the NetscapePlugInStreamLoaderClient virtual methods from PDFPlugin to PDFPluginStreamLoaderClient, add some simple methods to PDFPlugin so that PDFPluginStreamLoaderClient doesn't access the instance variables directly. Also make use of these new methods in other parts of PDFPlugin. * WebProcess/Plugins/PDF/PDFPlugin.h: (WebKit::PDFPlugin::documentFinishedLoading): Add. (WebKit::PDFPlugin::identifierForLoader): Add. (WebKit::PDFPlugin::removeOutstandingByteRangeRequest): Add. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient): Add class. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::PDFPlugin): (WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel): (WebKit::PDFPlugin::getResourceBytesAtPosition): (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::willSendRequest): Move from PDFPlugin. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didReceiveResponse): Ditto. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didReceiveData): Ditto. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didFail): Ditto. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didFinishLoading): Ditto. (WebKit::PDFPlugin::byteRangeRequestForLoader): (WebKit::PDFPlugin::forgetLoader): (WebKit::PDFPlugin::willSendRequest): Move to PDFPluginStreamLoaderClient. (WebKit::PDFPlugin::didReceiveResponse): Ditto. (WebKit::PDFPlugin::didReceiveData): Ditto. (WebKit::PDFPlugin::didFail): Ditto. (WebKit::PDFPlugin::didFinishLoading): Ditto. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268003 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-05 David Kilzer Make NetscapePlugInStreamLoaderClient a weak pointer on NetscapePlugInStreamLoader Reviewed by Alex Christensen. Making NetscapePlugInStreamLoaderClient inherit from CanMakeWeakPtr<> caused PDFPlugin to fail to compile because one of its parent classes already inherited from CanMakeWeakPtr<>. To fix this, extract a PDFPluginStreamLoaderClient class from PDFPlugin and link the lifetime of PDFPluginStreamLoaderClient to PDFPlugin. After moving the NetscapePlugInStreamLoaderClient virtual methods from PDFPlugin to PDFPluginStreamLoaderClient, add some simple methods to PDFPlugin so that PDFPluginStreamLoaderClient doesn't access the instance variables directly. Also make use of these new methods in other parts of PDFPlugin. * WebProcess/Plugins/PDF/PDFPlugin.h: (WebKit::PDFPlugin::documentFinishedLoading): Add. (WebKit::PDFPlugin::identifierForLoader): Add. (WebKit::PDFPlugin::removeOutstandingByteRangeRequest): Add. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient): Add class. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::PDFPlugin): (WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel): (WebKit::PDFPlugin::getResourceBytesAtPosition): (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::willSendRequest): Move from PDFPlugin. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didReceiveResponse): Ditto. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didReceiveData): Ditto. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didFail): Ditto. (WebKit::PDFPlugin::PDFPluginStreamLoaderClient::didFinishLoading): Ditto. (WebKit::PDFPlugin::byteRangeRequestForLoader): (WebKit::PDFPlugin::forgetLoader): (WebKit::PDFPlugin::willSendRequest): Move to PDFPluginStreamLoaderClient. (WebKit::PDFPlugin::didReceiveResponse): Ditto. (WebKit::PDFPlugin::didReceiveData): Ditto. (WebKit::PDFPlugin::didFail): Ditto. (WebKit::PDFPlugin::didFinishLoading): Ditto. 2020-10-14 Alan Coon Cherry-pick r268371. rdar://problem/70267767 [macOS] Workaround for MAC_OS_X_VERSION_MAJOR incorrectly including minor version when building with Xcode 12 on macOS Big Sur SUs https://bugs.webkit.org/show_bug.cgi?id=217602 rdar://70194453 Patch by Luming Yin on 2020-10-12 Reviewed by Darin Adler. The previous workaround turns out to be ineffective because we can't set the value of TARGET_MAC_OS_X_VERSION_MAJOR based on a previous value of itself. Introduce a new variable TARGET_MAC_OS_X_VERSION_MAJOR to determine whether we need to explicitly adjust MAC_OS_X_VERSION_MAJOR to 110000. PerformanceTests: * DecoderTest/Configurations/DebugRelease.xcconfig: * MediaTime/Configurations/DebugRelease.xcconfig: Source/bmalloc: * Configurations/DebugRelease.xcconfig: Source/JavaScriptCore: * Configurations/DebugRelease.xcconfig: Source/ThirdParty: * gtest/xcode/Config/General.xcconfig: Source/ThirdParty/ANGLE: * Configurations/DebugRelease.xcconfig: Source/ThirdParty/libwebrtc: * Configurations/DebugRelease.xcconfig: Source/WebCore: * Configurations/DebugRelease.xcconfig: Source/WebCore/PAL: * Configurations/DebugRelease.xcconfig: Source/WebInspectorUI: * Configurations/DebugRelease.xcconfig: Source/WebKit: * Configurations/DebugRelease.xcconfig: Source/WebKitLegacy/mac: * Configurations/DebugRelease.xcconfig: Source/WTF: * Configurations/DebugRelease.xcconfig: Tools: * ContentExtensionTester/Configurations/DebugRelease.xcconfig: * DumpRenderTree/mac/Configurations/DebugRelease.xcconfig: * ImageDiff/cg/Configurations/DebugRelease.xcconfig: * MiniBrowser/Configurations/DebugRelease.xcconfig: * TestWebKitAPI/Configurations/DebugRelease.xcconfig: * WebEditingTester/Configurations/DebugRelease.xcconfig: * WebKitTestRunner/Configurations/DebugRelease.xcconfig: * lldb/lldbWebKitTester/Configurations/DebugRelease.xcconfig: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268371 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-12 Luming Yin [macOS] Workaround for MAC_OS_X_VERSION_MAJOR incorrectly including minor version when building with Xcode 12 on macOS Big Sur SUs https://bugs.webkit.org/show_bug.cgi?id=217602 rdar://70194453 Reviewed by Darin Adler. The previous workaround turns out to be ineffective because we can't set the value of TARGET_MAC_OS_X_VERSION_MAJOR based on a previous value of itself. Introduce a new variable TARGET_MAC_OS_X_VERSION_MAJOR to determine whether we need to explicitly adjust MAC_OS_X_VERSION_MAJOR to 110000. * Configurations/DebugRelease.xcconfig: 2020-10-14 Alan Coon Cherry-pick r268353. rdar://problem/70267767 [macOS] Workaround for MAC_OS_X_VERSION_MAJOR incorrectly including minor version when building with Xcode 12 on macOS Big Sur SUs https://bugs.webkit.org/show_bug.cgi?id=217602 rdar://70194453 Patch by Luming Yin on 2020-10-12 Reviewed by Darin Adler. Due to a bug in Xcode (rdar://70185899), Xcode 12.0 and Xcode 12.1 Beta incorrectly includes the minor release number in MAC_OS_X_VERSION_MAJOR, which causes Debug and Release builds of WebKit to be misconfigured when building on macOS Big Sur SUs, leading to webpages failing to load. To work around the Xcode bug, when the MAC_OS_X_VERSION_MAJOR includes the minor version number, drop the minor version number by explicitly setting TARGET_MAC_OS_X_VERSION_MAJOR to 110000. Note: This change should be reverted after is resolved. PerformanceTests: * DecoderTest/Configurations/DebugRelease.xcconfig: * MediaTime/Configurations/DebugRelease.xcconfig: Source/bmalloc: * Configurations/DebugRelease.xcconfig: Source/JavaScriptCore: * Configurations/DebugRelease.xcconfig: Source/ThirdParty: * gtest/xcode/Config/General.xcconfig: Source/ThirdParty/ANGLE: * Configurations/DebugRelease.xcconfig: Source/ThirdParty/libwebrtc: * Configurations/DebugRelease.xcconfig: Source/WebCore: * Configurations/DebugRelease.xcconfig: Source/WebCore/PAL: * Configurations/DebugRelease.xcconfig: Source/WebInspectorUI: * Configurations/DebugRelease.xcconfig: Source/WebKit: * Configurations/DebugRelease.xcconfig: Source/WebKitLegacy/mac: * Configurations/DebugRelease.xcconfig: Source/WTF: * Configurations/DebugRelease.xcconfig: Tools: * ContentExtensionTester/Configurations/DebugRelease.xcconfig: * DumpRenderTree/mac/Configurations/DebugRelease.xcconfig: * ImageDiff/cg/Configurations/DebugRelease.xcconfig: * MiniBrowser/Configurations/DebugRelease.xcconfig: * TestWebKitAPI/Configurations/DebugRelease.xcconfig: * WebEditingTester/Configurations/DebugRelease.xcconfig: * WebKitTestRunner/Configurations/DebugRelease.xcconfig: * lldb/lldbWebKitTester/Configurations/DebugRelease.xcconfig: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268353 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-12 Luming Yin [macOS] Workaround for MAC_OS_X_VERSION_MAJOR incorrectly including minor version when building with Xcode 12 on macOS Big Sur SUs https://bugs.webkit.org/show_bug.cgi?id=217602 rdar://70194453 Reviewed by Darin Adler. Due to a bug in Xcode (rdar://70185899), Xcode 12.0 and Xcode 12.1 Beta incorrectly includes the minor release number in MAC_OS_X_VERSION_MAJOR, which causes Debug and Release builds of WebKit to be misconfigured when building on macOS Big Sur SUs, leading to webpages failing to load. To work around the Xcode bug, when the MAC_OS_X_VERSION_MAJOR includes the minor version number, drop the minor version number by explicitly setting TARGET_MAC_OS_X_VERSION_MAJOR to 110000. Note: This change should be reverted after is resolved. * Configurations/DebugRelease.xcconfig: 2020-10-14 Alan Coon Cherry-pick r267352. rdar://problem/70267163 WKWebView Swift overlay has mis-annotated nullability for evaluateJavaScript Reviewed by Darin Adler. Due to a mistranslation of evaluateJavaScript, we are vending an API which does not expect to receive nil as a valid result value. This change fixes the crash, but does not yet fix the API to have the correct signature. That will come in a later patch. To fix the crash, we need to produce a valid Result to pass back to clients. Fortunately, instead of inventing something clever, we can just use nil. It's valid to box optional values into Any, and clients can technically retrieve them with the right dynamic cast as well. Since client code must be using dynamic casting to convert the result Any to a usable type, and because in the case where we now return a new value at runtime we would have previously crashed, this shouldn't have any binary compatibility impact either. To better validate these changes, I also add new unit tests for the conversion of JavaScript results into Swift values, including a test for the deprecated API. * SwiftOverlay/SwiftOverlay/ObjectiveCBlockConversions.swift: Added. For clarity I'm factoring helper methods into a single namespace, as it also makes a nice place to document their expectations. (ObjectiveCBlockConversion.exclusive.exclusive(_:)): This is renamed from the free function, makeResultHandler(_:). It still has the same fatalError (now precondition) as before, but hopefully a better name to clarify that it expects exactly-one value. (ObjectiveCBlockConversions.boxingNilAsAnyForCompatibility(_:)): This is a variant of exclusive(_:) that makes the tradeoff of boxing any nil values as Any to avoid crashing. This is still safe, since as mentioned our clients will need to cast the value they recieve to do anything with it, and since the deprecated API expects `Any`, no one could have been successfully comparing it to `nil` today anyways. * SwiftOverlay/Tests/JavaScriptToSwiftTypeConversions.swift: Added. (JavaScriptToSwiftConversions.setUp): Construct a new web view, and add it to a window so that it is in an expected state. I'm using about:blank as the URL, since page content doesn't matter for these tests and I want the web content to be ready immediately. (JavaScriptToSwiftConversions.tearDown): Just perform some window cleanup. (JavaScriptToSwiftConversions.evaluateJavaScript(_:andExpect:)): Helper method to evaluate script and check its result. I'm using String.debugDescription because it escapes quotes and special characters which makes the readout easier to parse. (JavaScriptToSwiftConversions.testNull): JavaScript's null is actually mapped to NSNull, not nil. (JavaScriptToSwiftConversions.testInteger): Some standard type coercion tests. The underlying value for all number types should be NSNumber, so this is actually check against a float or integer type without issue. (JavaScriptToSwiftConversions.testDecimal): Ditto. (JavaScriptToSwiftConversions.testBoolean): Ditto. (JavaScriptToSwiftConversions.testString): Ditto. (JavaScriptToSwiftConversions.testArray): Ditto. (JavaScriptToSwiftConversions.testDictionary): Ditto, only you can't evaluate an object literal directly so I need to store it in a temporary location first. (JavaScriptToSwiftConversions.testUndefined): Test our boxing of nil. The exact value matters less than not crashing at all. * SwiftOverlay/WebKitSwiftOverlay.xcodeproj/project.pbxproj: Added new files to project. I kept the new test file and helper files within the SwiftOverlay group, because they do not contribute any API. * UIProcess/API/Cocoa/WebKitSwiftOverlay.swift: (WKWebView.callAsyncJavaScript(_:arguments:in:in:completionHandler:)): Switch to a conversion which does not trap on nil. (WKWebView.createPDF(_:completionHandler:)): Updated to use new helper method name. (WKWebView.createWebArchiveData(_:)): Ditto. (WKWebView.evaluateJavaScript(_:in:in:completionHandler:Error:)): See above. (makeResultHandler(_:): This has been subsumed by ObjCBlockConversions. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267352 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-21 James Savage WKWebView Swift overlay has mis-annotated nullability for evaluateJavaScript Reviewed by Darin Adler. Due to a mistranslation of evaluateJavaScript, we are vending an API which does not expect to receive nil as a valid result value. This change fixes the crash, but does not yet fix the API to have the correct signature. That will come in a later patch. To fix the crash, we need to produce a valid Result to pass back to clients. Fortunately, instead of inventing something clever, we can just use nil. It's valid to box optional values into Any, and clients can technically retrieve them with the right dynamic cast as well. Since client code must be using dynamic casting to convert the result Any to a usable type, and because in the case where we now return a new value at runtime we would have previously crashed, this shouldn't have any binary compatibility impact either. To better validate these changes, I also add new unit tests for the conversion of JavaScript results into Swift values, including a test for the deprecated API. * SwiftOverlay/SwiftOverlay/ObjectiveCBlockConversions.swift: Added. For clarity I'm factoring helper methods into a single namespace, as it also makes a nice place to document their expectations. (ObjectiveCBlockConversion.exclusive.exclusive(_:)): This is renamed from the free function, makeResultHandler(_:). It still has the same fatalError (now precondition) as before, but hopefully a better name to clarify that it expects exactly-one value. (ObjectiveCBlockConversions.boxingNilAsAnyForCompatibility(_:)): This is a variant of exclusive(_:) that makes the tradeoff of boxing any nil values as Any to avoid crashing. This is still safe, since as mentioned our clients will need to cast the value they recieve to do anything with it, and since the deprecated API expects `Any`, no one could have been successfully comparing it to `nil` today anyways. * SwiftOverlay/Tests/JavaScriptToSwiftTypeConversions.swift: Added. (JavaScriptToSwiftConversions.setUp): Construct a new web view, and add it to a window so that it is in an expected state. I'm using about:blank as the URL, since page content doesn't matter for these tests and I want the web content to be ready immediately. (JavaScriptToSwiftConversions.tearDown): Just perform some window cleanup. (JavaScriptToSwiftConversions.evaluateJavaScript(_:andExpect:)): Helper method to evaluate script and check its result. I'm using String.debugDescription because it escapes quotes and special characters which makes the readout easier to parse. (JavaScriptToSwiftConversions.testNull): JavaScript's null is actually mapped to NSNull, not nil. (JavaScriptToSwiftConversions.testInteger): Some standard type coercion tests. The underlying value for all number types should be NSNumber, so this is actually check against a float or integer type without issue. (JavaScriptToSwiftConversions.testDecimal): Ditto. (JavaScriptToSwiftConversions.testBoolean): Ditto. (JavaScriptToSwiftConversions.testString): Ditto. (JavaScriptToSwiftConversions.testArray): Ditto. (JavaScriptToSwiftConversions.testDictionary): Ditto, only you can't evaluate an object literal directly so I need to store it in a temporary location first. (JavaScriptToSwiftConversions.testUndefined): Test our boxing of nil. The exact value matters less than not crashing at all. * SwiftOverlay/WebKitSwiftOverlay.xcodeproj/project.pbxproj: Added new files to project. I kept the new test file and helper files within the SwiftOverlay group, because they do not contribute any API. * UIProcess/API/Cocoa/WebKitSwiftOverlay.swift: (WKWebView.callAsyncJavaScript(_:arguments:in:in:completionHandler:)): Switch to a conversion which does not trap on nil. (WKWebView.createPDF(_:completionHandler:)): Updated to use new helper method name. (WKWebView.createWebArchiveData(_:)): Ditto. (WKWebView.evaluateJavaScript(_:in:in:completionHandler:Error:)): See above. (makeResultHandler(_:): This has been subsumed by ObjCBlockConversions. 2020-10-14 Alan Coon Cherry-pick r267619. rdar://problem/70296953 Add -[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:] to provide a way to allow app link https://bugs.webkit.org/show_bug.cgi?id=216977 Patch by Hoa Dinh on 2020-09-25 Reviewed by Alex Christensen. The method -[WKWebView _loadRequest:shouldOpenExternalURLs:] would only allow opening external or not. It wasn't providing the ability to allow external URL but not app links. This patch adds -[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:]. The parameters value for shouldOpenExternalURLsPolicy has the same meaning than WebCore::ShouldOpenExternalURLsPolicy. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:]): * UIProcess/API/Cocoa/WKWebViewPrivate.h: Added enum _WKShouldOpenExternalURLsPolicy, git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267619 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-25 Hoa Dinh Add -[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:] to provide a way to allow app link https://bugs.webkit.org/show_bug.cgi?id=216977 Reviewed by Alex Christensen. The method -[WKWebView _loadRequest:shouldOpenExternalURLs:] would only allow opening external or not. It wasn't providing the ability to allow external URL but not app links. This patch adds -[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:]. The parameters value for shouldOpenExternalURLsPolicy has the same meaning than WebCore::ShouldOpenExternalURLsPolicy. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:]): * UIProcess/API/Cocoa/WKWebViewPrivate.h: Added enum _WKShouldOpenExternalURLsPolicy, 2020-10-13 Russell Epstein Cherry-pick r268381. rdar://problem/70260409 Fix the macCatalyst build ("reference to 'Rect' is ambiguous") https://bugs.webkit.org/show_bug.cgi?id=217642 Reviewed by Wenson Hsieh. * UIProcess/ios/forms/WKDateTimeInputControl.mm: (-[WKDateTimePicker initWithView:datePickerMode:]): (-[WKDateTimePicker shouldPresentGregorianCalendar:]): (-[WKDateTimePicker controlBeginEditing]): (-[WKDateTimeInputControl initWithView:]): An earlier unified source's `using namespace WebCore` inside `namespace WebKit` and then WKDateTimeInputControl's `using namespace WebKit` in the global namespace resulted in once-again conflicting definitions of `Rect` between CSS code and MacTypes.h. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268381 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-12 Tim Horton Fix the macCatalyst build ("reference to 'Rect' is ambiguous") https://bugs.webkit.org/show_bug.cgi?id=217642 Reviewed by Wenson Hsieh. * UIProcess/ios/forms/WKDateTimeInputControl.mm: (-[WKDateTimePicker initWithView:datePickerMode:]): (-[WKDateTimePicker shouldPresentGregorianCalendar:]): (-[WKDateTimePicker controlBeginEditing]): (-[WKDateTimeInputControl initWithView:]): An earlier unified source's `using namespace WebCore` inside `namespace WebKit` and then WKDateTimeInputControl's `using namespace WebKit` in the global namespace resulted in once-again conflicting definitions of `Rect` between CSS code and MacTypes.h. 2020-10-11 Kocsen Chung Cherry-pick r268330. rdar://problem/70189394 Strip patch version from TARGET_MAC_OS_X_VERSION_MAJOR when building for macOS Big Sur or later https://bugs.webkit.org/show_bug.cgi?id=217594 rdar://70188497 Patch by Luming Yin on 2020-10-11 Reviewed by Darin Adler. To ensure successful Mac Catalyst WebKit builds, strip the patch version from TARGET_MAC_OS_X_VERSION_MAJOR by using two `base:`s on MACOSX_DEPLOYMENT_TARGET. * Configurations/Base.xcconfig: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268330 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-11 Luming Yin Strip patch version from TARGET_MAC_OS_X_VERSION_MAJOR when building for macOS Big Sur or later https://bugs.webkit.org/show_bug.cgi?id=217594 rdar://70188497 Reviewed by Darin Adler. To ensure successful Mac Catalyst WebKit builds, strip the patch version from TARGET_MAC_OS_X_VERSION_MAJOR by using two `base:`s on MACOSX_DEPLOYMENT_TARGET. * Configurations/Base.xcconfig: 2020-10-11 Kocsen Chung Cherry-pick r268327. rdar://problem/70189401 Ignore deployment suffix and identifier when computing major OS version for macOS Big Sur and newer https://bugs.webkit.org/show_bug.cgi?id=217584 rdar://70168426 Patch by Luming Yin on 2020-10-11 Reviewed by Darin Adler. Stop using MACOSX_DEPLOYMENT_TARGET:suffix:identifier to compute major OS versions. Only use the deployment target base for macOS Big Sur and newer. Keep the manual definitions for legacy versions of macOS. * Configurations/Base.xcconfig: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268327 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-11 Luming Yin Ignore deployment suffix and identifier when computing major OS version for macOS Big Sur and newer https://bugs.webkit.org/show_bug.cgi?id=217584 rdar://70168426 Reviewed by Darin Adler. Stop using MACOSX_DEPLOYMENT_TARGET:suffix:identifier to compute major OS versions. Only use the deployment target base for macOS Big Sur and newer. Keep the manual definitions for legacy versions of macOS. * Configurations/Base.xcconfig: 2020-10-09 Russell Epstein Cherry-pick r268257. rdar://problem/70142057 Switch Allow/Don't Allow buttons in getUserMedia prompt https://bugs.webkit.org/show_bug.cgi?id=217513 Reviewed by Eric Carlson. Return NotAllowedError instead of SecurityError in case user denies with default prompt. Make sure to have the Allow button in iOS prompt on the right instead of the left. Tested in MiniBrowser and MobileMiniBrowser. * UIProcess/Cocoa/UserMediaPermissionRequestProxy.mm: (WebKit::UserMediaPermissionRequestProxy::doDefaultAction): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268257 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-09 Youenn Fablet Switch Allow/Don't Allow buttons in getUserMedia prompt https://bugs.webkit.org/show_bug.cgi?id=217513 Reviewed by Eric Carlson. Return NotAllowedError instead of SecurityError in case user denies with default prompt. Make sure to have the Allow button in iOS prompt on the right instead of the left. Tested in MiniBrowser and MobileMiniBrowser. * UIProcess/Cocoa/UserMediaPermissionRequestProxy.mm: (WebKit::UserMediaPermissionRequestProxy::doDefaultAction): 2020-10-09 Russell Epstein Cherry-pick r268256. rdar://problem/70142054 Implement TCC checks in UserMediaPermissionRequestManagerProxy https://bugs.webkit.org/show_bug.cgi?id=217508 Reviewed by Eric Carlson. TCC checks must be done before asking the page client to decide whether to grant or not camera and/or microphone. This ensures that, should the default action be done (default prompt), for instance in case the WKWebView application does not provide any delegate, the TCC checks will happen before the default prompt. For that reason, we move the TCC checks from UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest to UserMediaPermissionRequestManagerProxy::requestSystemValidation. Manually tested in Safari and MiniBrowser. * UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): (WebKit::requestUserMediaAuthorizationForFrame): Deleted. (WebKit::requestAVCaptureAccessForMediaType): Deleted. * UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm: (WebKit::requestAVCaptureAccessForMediaType): (WebKit::UserMediaPermissionRequestManagerProxy::requestSystemValidation): * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest): (WebKit::UserMediaPermissionRequestManagerProxy::decidePolicyForUserMediaPermissionRequest): (WebKit::UserMediaPermissionRequestManagerProxy::requestSystemValidation): * UIProcess/UserMediaPermissionRequestManagerProxy.h: * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::preferences const): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268256 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-09 Youenn Fablet Implement TCC checks in UserMediaPermissionRequestManagerProxy https://bugs.webkit.org/show_bug.cgi?id=217508 Reviewed by Eric Carlson. TCC checks must be done before asking the page client to decide whether to grant or not camera and/or microphone. This ensures that, should the default action be done (default prompt), for instance in case the WKWebView application does not provide any delegate, the TCC checks will happen before the default prompt. For that reason, we move the TCC checks from UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest to UserMediaPermissionRequestManagerProxy::requestSystemValidation. Manually tested in Safari and MiniBrowser. * UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): (WebKit::requestUserMediaAuthorizationForFrame): Deleted. (WebKit::requestAVCaptureAccessForMediaType): Deleted. * UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm: (WebKit::requestAVCaptureAccessForMediaType): (WebKit::UserMediaPermissionRequestManagerProxy::requestSystemValidation): * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest): (WebKit::UserMediaPermissionRequestManagerProxy::decidePolicyForUserMediaPermissionRequest): (WebKit::UserMediaPermissionRequestManagerProxy::requestSystemValidation): * UIProcess/UserMediaPermissionRequestManagerProxy.h: * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::preferences const): 2020-10-08 Alan Coon Cherry-pick r268052. rdar://problem/70097377 Enable video capture in WebProcess by default on MacOS https://bugs.webkit.org/show_bug.cgi?id=217385 Reviewed by Sam Weinig. Source/WebKit: Manually tested in MiniBrowser. * Shared/WebPreferencesDefaultValues.cpp: * Shared/WebPreferencesDefaultValues.h: Source/WTF: * Scripts/Preferences/WebPreferencesInternal.yaml: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268052 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-06 Youenn Fablet Enable video capture in WebProcess by default on MacOS https://bugs.webkit.org/show_bug.cgi?id=217385 Reviewed by Sam Weinig. Manually tested in MiniBrowser. * Shared/WebPreferencesDefaultValues.cpp: * Shared/WebPreferencesDefaultValues.h: 2020-10-07 Alan Coon Cherry-pick r268012. rdar://problem/70056589 Disable media capture if an app's entitlements won't allow access to capture devices https://bugs.webkit.org/show_bug.cgi?id=217319 Reviewed by Youenn Fablet. Source/WebKit: No new tests, tested manually with MiniBrowser and Safari. * UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm: (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio): If the app is sandboxed, check for the entitlement required for audio capture. Don't bother checking for usage string if TCC has already authorized capture. (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo): Ditto for video capture. * UIProcess/Cocoa/WebPreferencesCocoa.mm: (WebKit::WebPreferences::platformInitializeStore): Initialize `mediaDevicesEnabled` manually because its default value is always `false` in the WebProcess and may be `true` in the UIProcess. WebPreferences assumes the default will always be the same in both processes, and so has an optimization that only sends values to the WebProcess if they differ from the default value. This means if the default in the UIProcess is true it won't be pushed to the WebProcess, so capture won't work. * Platform/spi/ios/TCCSPI.h: Update TCCAccessPreflightResult. Tools: * MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj: * MiniBrowser/mac/AppDelegate.m: (-[BrowserAppDelegate defaultConfiguration]): Don't set configuration._mediaCaptureEnabled, it should no longer be necessary. * MiniBrowser/mac/Info.plist: Remove unneeded keys. * MobileMiniBrowser/MobileMiniBrowser/Info.plist: Ditto. Add usage strings. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268012 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-05 Eric Carlson Disable media capture if an app's entitlements won't allow access to capture devices https://bugs.webkit.org/show_bug.cgi?id=217319 Reviewed by Youenn Fablet. No new tests, tested manually with MiniBrowser and Safari. * UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm: (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio): If the app is sandboxed, check for the entitlement required for audio capture. Don't bother checking for usage string if TCC has already authorized capture. (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo): Ditto for video capture. * UIProcess/Cocoa/WebPreferencesCocoa.mm: (WebKit::WebPreferences::platformInitializeStore): Initialize `mediaDevicesEnabled` manually because its default value is always `false` in the WebProcess and may be `true` in the UIProcess. WebPreferences assumes the default will always be the same in both processes, and so has an optimization that only sends values to the WebProcess if they differ from the default value. This means if the default in the UIProcess is true it won't be pushed to the WebProcess, so capture won't work. * Platform/spi/ios/TCCSPI.h: Update TCCAccessPreflightResult. 2020-10-07 Alan Coon Cherry-pick r267844. rdar://problem/70056601 Prevent media capture unless the application has correct data for system permission prompt https://bugs.webkit.org/show_bug.cgi?id=217104 Reviewed by Darin Adler. Source/WebKit: Tested manually with MiniBrowser. * SourcesCocoa.txt: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::requestAVCaptureAccessForMediaType): Renamed from requestAccessForMediaType. (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): Deny requests of the application is not permitted to capture. Restructure logic to make it easier to understand. (WebKit::requestAccessForMediaType): Deleted. * UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm: Added. (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio): Check for required Info.plist string. (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo): Ditto. * UIProcess/Cocoa/WebPageProxyCocoa.mm: Update for unified build. * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio): (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo): * UIProcess/UserMediaPermissionRequestManagerProxy.h: * WebKit.xcodeproj/project.pbxproj: Tools: * MiniBrowser/mac/Info.plist: Add necessary entitlements and usage strings. * MobileMiniBrowser/MobileMiniBrowserFramework/WebViewController.m: (-[WebViewController createWebView]): Setting the private capture preference is not necessary because we set configuration._mediaCaptureEnabled. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267844 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-01 Eric Carlson Prevent media capture unless the application has correct data for system permission prompt https://bugs.webkit.org/show_bug.cgi?id=217104 Reviewed by Darin Adler. Tested manually with MiniBrowser. * SourcesCocoa.txt: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::requestAVCaptureAccessForMediaType): Renamed from requestAccessForMediaType. (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): Deny requests of the application is not permitted to capture. Restructure logic to make it easier to understand. (WebKit::requestAccessForMediaType): Deleted. * UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm: Added. (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio): Check for required Info.plist string. (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo): Ditto. * UIProcess/Cocoa/WebPageProxyCocoa.mm: Update for unified build. * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio): (WebKit::UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo): * UIProcess/UserMediaPermissionRequestManagerProxy.h: * WebKit.xcodeproj/project.pbxproj: 2020-10-07 Alan Coon Cherry-pick r267698. rdar://problem/70056601 Make sure our calls to AVCaptureDevice requestAccessForMediaType do processing on the main thread https://bugs.webkit.org/show_bug.cgi?id=216974 Reviewed by Darin Adler. The completion handler to [AVCaptureDeviceClass requestAccessForMediaType:] may sometimes be called in a background thread on iOS. Make sure to hop to the main thread if that is the case. Also make sure to ref/weakref lambda captured variables. * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::requestAccessForMediaType): (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267698 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-28 Youenn Fablet Make sure our calls to AVCaptureDevice requestAccessForMediaType do processing on the main thread https://bugs.webkit.org/show_bug.cgi?id=216974 Reviewed by Darin Adler. The completion handler to [AVCaptureDeviceClass requestAccessForMediaType:] may sometimes be called in a background thread on iOS. Make sure to hop to the main thread if that is the case. Also make sure to ref/weakref lambda captured variables. * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::requestAccessForMediaType): (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): 2020-10-07 Alan Coon Cherry-pick r267563. rdar://problem/70056594 Introduce WKWebViewConfiguration mediaCaptureEnabled https://bugs.webkit.org/show_bug.cgi?id=216872 Reviewed by Alex Christensen. Source/WebKit: Add a new boolean configuration to enable/disable mediaDevices exposure. Value is off by default. A future patch will remove the mediaDevices WebPreferences based API, given there is no need to enable/disable mediaDevices during the lifetime of a page. Covered by existing tests. * UIProcess/API/APIPageConfiguration.cpp: (API::PageConfiguration::copy const): * UIProcess/API/APIPageConfiguration.h: (API::PageConfiguration::setMediaDevicesEnabled): (API::PageConfiguration::mediaDevicesEnabled const): * UIProcess/API/Cocoa/WKPreferencesPrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setupPageConfiguration:]): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration _mediaDevicesEnabled]): (-[WKWebViewConfiguration _setMediaDevicesEnabled:]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: Tools: Make use of new configuration boolean instead of mediaDevicesEnabled WebPreferences API. * MiniBrowser/mac/AppDelegate.m: (-[BrowserAppDelegate defaultConfiguration]): * TestWebKitAPI/Tests/WebKit/GetUserMedia.mm: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit/GetUserMediaNavigation.mm: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit/MediaStreamTrackDetached.mm: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm: (TestWebKitAPI::GetDisplayMediaTest::SetUp): * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: * TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm: (MediaCaptureDisabledTest::SetUp): * TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm: (MediaCaptureSimulateFailedSandbox::SetUp): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267563 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-25 Youenn Fablet Introduce WKWebViewConfiguration mediaCaptureEnabled https://bugs.webkit.org/show_bug.cgi?id=216872 Reviewed by Alex Christensen. Add a new boolean configuration to enable/disable mediaDevices exposure. Value is off by default. A future patch will remove the mediaDevices WebPreferences based API, given there is no need to enable/disable mediaDevices during the lifetime of a page. Covered by existing tests. * UIProcess/API/APIPageConfiguration.cpp: (API::PageConfiguration::copy const): * UIProcess/API/APIPageConfiguration.h: (API::PageConfiguration::setMediaDevicesEnabled): (API::PageConfiguration::mediaDevicesEnabled const): * UIProcess/API/Cocoa/WKPreferencesPrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setupPageConfiguration:]): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration _mediaDevicesEnabled]): (-[WKWebViewConfiguration _setMediaDevicesEnabled:]): * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h: 2020-10-07 Alan Coon Cherry-pick r267081. rdar://problem/70056594 End of media capture should not be reported before 3 seconds of the start of capture https://bugs.webkit.org/show_bug.cgi?id=216415 Source/WebCore: Reviewed by Eric Carlson. Add a timer that allows taking a function and a delay as parameter. Covered by added API test. * platform/Timer.h: (WebCore::DeferrableTaskTimer::fired): (WebCore::DeferrableTaskTimer::doTask): (WebCore::DeferrableTaskTimer::cancel): Source/WebKit: Reviewed by Eric Carlson. Add support for delaying of end of capture notification to the application. This allows to ensure that a capture indicator stays for long enough for the user to notice it. A capture indicator should be visible to the user for at least three seconds. A timer is scheduled when starting a capture and there is no ongoing capture. As long as the timer is active, the capture state cannot be transitioned to no capture. Other transitions are allowed. Once the timer kicks in, any capture state update is done synchronously. Ensure to update the capture state when the timer kicks in. Note that even navigations will not allow transitioning the capture state sooner. This is done to ensure a page does not try to capture one frame before navigating to another page. In practice, very few pages should navigate quickly after starting capture. * UIProcess/API/C/WKPage.cpp: (WKPageGetMediaState): (WKPageSetMediaCaptureReportingDelayForTesting): * UIProcess/API/C/WKPagePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _mediaCaptureState]): * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _mediaCaptureReportingDelayForTesting]): (-[WKWebView _setMediaCaptureReportingDelayForTesting:]): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::updatePlayingMediaDidChange): (WebKit::WebPageProxy::updateReportedMediaCaptureState): * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::reportedMediaCaptureState const): (WebKit::WebPageProxy::mediaCaptureReportingDelay const): (WebKit::WebPageProxy::setMediaCaptureReportingDelay): Tools: Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/GetUserMedia.mm: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: (-[GetUserMediaUIDelegate _webView:mediaCaptureStateDidChange:]): Add a notCapturing boolean and wait for the notification before going back to the capturing page. Decrease delay to 1 second to make the test run faster. * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetStateToConsistentValues): Make sure to set media capture state delay to zero. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267081 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-15 Youenn Fablet End of media capture should not be reported before 3 seconds of the start of capture https://bugs.webkit.org/show_bug.cgi?id=216415 Reviewed by Eric Carlson. Add support for delaying of end of capture notification to the application. This allows to ensure that a capture indicator stays for long enough for the user to notice it. A capture indicator should be visible to the user for at least three seconds. A timer is scheduled when starting a capture and there is no ongoing capture. As long as the timer is active, the capture state cannot be transitioned to no capture. Other transitions are allowed. Once the timer kicks in, any capture state update is done synchronously. Ensure to update the capture state when the timer kicks in. Note that even navigations will not allow transitioning the capture state sooner. This is done to ensure a page does not try to capture one frame before navigating to another page. In practice, very few pages should navigate quickly after starting capture. * UIProcess/API/C/WKPage.cpp: (WKPageGetMediaState): (WKPageSetMediaCaptureReportingDelayForTesting): * UIProcess/API/C/WKPagePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _mediaCaptureState]): * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _mediaCaptureReportingDelayForTesting]): (-[WKWebView _setMediaCaptureReportingDelayForTesting:]): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::updatePlayingMediaDidChange): (WebKit::WebPageProxy::updateReportedMediaCaptureState): * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::reportedMediaCaptureState const): (WebKit::WebPageProxy::mediaCaptureReportingDelay const): (WebKit::WebPageProxy::setMediaCaptureReportingDelay): 2020-10-07 Alan Coon Cherry-pick r267568. rdar://problem/70056584 Implement default behavior for getUserMedia requests in case where there is no delegate set https://bugs.webkit.org/show_bug.cgi?id=216968 Reviewed by Eric Carlson. Source/WebKit: In case page UIDelegate is not set, make the getUserMedia request do its default action. In case there is a UIDelegate but no getUserMedia specific delegates, make the getUserMedia request do its default action. Default action is deny for getDisplayMedia and for non cocoa ports. For cocoa ports, a prompt is shown. Manually tested with MiniBrowser and MobileMiniBrowser. * SourcesCocoa.txt: * UIProcess/API/APIUIClient.h: (API::UIClient::decidePolicyForUserMediaPermissionRequest): * UIProcess/Cocoa/UIDelegate.mm: (WebKit::requestUserMediaAuthorizationForFrame): * UIProcess/Cocoa/UserMediaPermissionRequestProxy.mm: Renamed from Source/WebKit/UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.mm. (WebKit::alertMessageText): (WebKit::UserMediaPermissionRequestProxy::doDefaultAction): * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.h: Removed. * UIProcess/UserMediaPermissionRequestProxy.cpp: (WebKit::UserMediaPermissionRequestProxy::doDefaultAction): * UIProcess/UserMediaPermissionRequestProxy.h: * WebKit.xcodeproj/project.pbxproj: Tools: Add camera and microphone entitlements to MobileMiniBrowser. Expose mediaDevices to web pages and use mock devices. * MobileMiniBrowser/MobileMiniBrowser/Info.plist: * MobileMiniBrowser/MobileMiniBrowserFramework/WebViewController.m: (-[WebViewController createWebView]): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267568 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-25 Youenn Fablet Implement default behavior for getUserMedia requests in case where there is no delegate set https://bugs.webkit.org/show_bug.cgi?id=216968 Reviewed by Eric Carlson. In case page UIDelegate is not set, make the getUserMedia request do its default action. In case there is a UIDelegate but no getUserMedia specific delegates, make the getUserMedia request do its default action. Default action is deny for getDisplayMedia and for non cocoa ports. For cocoa ports, a prompt is shown. Manually tested with MiniBrowser and MobileMiniBrowser. * SourcesCocoa.txt: * UIProcess/API/APIUIClient.h: (API::UIClient::decidePolicyForUserMediaPermissionRequest): * UIProcess/Cocoa/UIDelegate.mm: (WebKit::requestUserMediaAuthorizationForFrame): * UIProcess/Cocoa/UserMediaPermissionRequestProxy.mm: Renamed from Source/WebKit/UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.mm. (WebKit::alertMessageText): (WebKit::UserMediaPermissionRequestProxy::doDefaultAction): * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.h: Removed. * UIProcess/UserMediaPermissionRequestProxy.cpp: (WebKit::UserMediaPermissionRequestProxy::doDefaultAction): * UIProcess/UserMediaPermissionRequestProxy.h: * WebKit.xcodeproj/project.pbxproj: 2020-10-07 Alan Coon Cherry-pick r267414. rdar://problem/70056613 Implement a default prompt for getUserMedia https://bugs.webkit.org/show_bug.cgi?id=216821 Reviewed by Eric Carlson. Source/WebCore: Manually tested by running Minibrowser. * en.lproj/Localizable.strings: Source/WebKit: Move preferences used by WebRTC develop menu to internals. This allows having them in MiniBrowser. Enable video capture in UIProcess by default for non Safari applications. Add support for a getUserMedia prompt, very similar to iOS current prompt. Use the prompt in case the application does not implement any of the two delegates. * Shared/WebPreferences.yaml: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultCaptureVideoInUIProcessEnabled): * Shared/WebPreferencesDefaultValues.h: * Shared/WebPreferencesExperimental.yaml: * Shared/WebPreferencesInternal.yaml: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::setDelegate): (WebKit::requestUserMediaAuthorizationForFrame): (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.h: Added. * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.mm: Added. (WebKit::visibleDomain): (WebKit::alertMessageText): (WebKit::presentUserMediaCaptureAccessAlert): * WebKit.xcodeproj/project.pbxproj: Tools: Remove getUserMedia delegate implementations to use WebKit built-in prompt. Add camera and microphone entitlements to allow using real cameras and microphones. Keep using mock devices as the default. * MiniBrowser/MiniBrowser.entitlements: * MiniBrowser/mac/WK2BrowserWindowController.m: (-[WK2BrowserWindowController _webView:requestMediaCaptureAuthorization:decisionHandler:]): Deleted. (-[WK2BrowserWindowController _webView:includeSensitiveMediaDeviceDetails:]): Deleted. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267414 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-22 Youenn Fablet Implement a default prompt for getUserMedia https://bugs.webkit.org/show_bug.cgi?id=216821 Reviewed by Eric Carlson. Move preferences used by WebRTC develop menu to internals. This allows having them in MiniBrowser. Enable video capture in UIProcess by default for non Safari applications. Add support for a getUserMedia prompt, very similar to iOS current prompt. Use the prompt in case the application does not implement any of the two delegates. * Shared/WebPreferences.yaml: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultCaptureVideoInUIProcessEnabled): * Shared/WebPreferencesDefaultValues.h: * Shared/WebPreferencesExperimental.yaml: * Shared/WebPreferencesInternal.yaml: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::setDelegate): (WebKit::requestUserMediaAuthorizationForFrame): (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.h: Added. * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.mm: Added. (WebKit::visibleDomain): (WebKit::alertMessageText): (WebKit::presentUserMediaCaptureAccessAlert): * WebKit.xcodeproj/project.pbxproj: 2020-10-07 Alan Coon Cherry-pick r267237. rdar://problem/70056605 Unified build fixes in media code https://bugs.webkit.org/show_bug.cgi?id=216691 Reviewed by Sam Weinig. Add missing includes and/or missing undef. No change of behavior. * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: * WebProcess/WebPage/WebPageOverlay.h: * WebProcess/cocoa/RemoteRealtimeMediaSource.cpp: * WebProcess/cocoa/RemoteRealtimeMediaSource.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267237 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-18 Youenn Fablet Unified build fixes in media code https://bugs.webkit.org/show_bug.cgi?id=216691 Reviewed by Sam Weinig. Add missing includes and/or missing undef. No change of behavior. * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: * WebProcess/WebPage/WebPageOverlay.h: * WebProcess/cocoa/RemoteRealtimeMediaSource.cpp: * WebProcess/cocoa/RemoteRealtimeMediaSource.h: 2020-10-06 Alan Coon Apply patch. rdar://problem/70026315 2020-10-06 Youenn Fablet Enable MediaRecorder by default on iOS https://bugs.webkit.org/show_bug.cgi?id=216664 Reviewed by Eric Carlson and Darin Adler. Enable it on all platforms supporting HAVE(AVASSETWRITERDELEGATE). * Shared/WebPreferences.yaml: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultMediaRecorderEnabled): * Shared/WebPreferencesDefaultValues.h: 2020-10-06 Alan Coon Cherry-pick r267833. rdar://problem/70024626 MediaRecorder should support MediaRecorderOptions.mimeType https://bugs.webkit.org/show_bug.cgi?id=215018 Reviewed by Eric Carlson. LayoutTests/imported/w3c: * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt: Source/WebCore: Instead of setting mime type right away, set it just before firing start event as per spec. This will allow in the future to populate exact codec parameters if proven useful. Covered by rebased and updated tests. * Modules/mediarecorder/MediaRecorder.cpp: (WebCore::MediaRecorder::create): (WebCore::MediaRecorder::startRecording): * platform/mediarecorder/MediaRecorderPrivate.h: (WebCore::MediaRecorderPrivate::startRecording): * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h: Source/WebKit: Update code to pass mimeType as part of startRecording callback. * GPUProcess/webrtc/RemoteMediaRecorder.h: (WebKit::RemoteMediaRecorder::mimeType const): * GPUProcess/webrtc/RemoteMediaRecorderManager.cpp: (WebKit::RemoteMediaRecorderManager::createRecorder): * GPUProcess/webrtc/RemoteMediaRecorderManager.h: * GPUProcess/webrtc/RemoteMediaRecorderManager.messages.in: * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::startRecording): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: LayoutTests: Update test to expect setting of the mime type after start event. * http/wpt/mediarecorder/mimeType.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267833 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-01 Youenn Fablet MediaRecorder should support MediaRecorderOptions.mimeType https://bugs.webkit.org/show_bug.cgi?id=215018 Reviewed by Eric Carlson. Update code to pass mimeType as part of startRecording callback. * GPUProcess/webrtc/RemoteMediaRecorder.h: (WebKit::RemoteMediaRecorder::mimeType const): * GPUProcess/webrtc/RemoteMediaRecorderManager.cpp: (WebKit::RemoteMediaRecorderManager::createRecorder): * GPUProcess/webrtc/RemoteMediaRecorderManager.h: * GPUProcess/webrtc/RemoteMediaRecorderManager.messages.in: * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::startRecording): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: 2020-10-06 Alan Coon Cherry-pick r267825. rdar://problem/70024248 MediaRecorder should support isTypeSupported https://bugs.webkit.org/show_bug.cgi?id=216856 LayoutTests/imported/w3c: Reviewed by Darin Adler. * web-platform-tests/mediacapture-record/MediaRecorder-mimetype-expected.txt: * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt: * web-platform-tests/mediacapture-record/idlharness.window-expected.txt: * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https-expected.txt: * web-platform-tests/mediacapture-record/passthrough/MediaRecorder-passthrough.https.html: Remove JS console log error line. Source/WebCore: Reviewed by Darin Adler. Introduce MediaRecorder::isMimeTypeSupported whose result is exposed as MediaRecoder.isTypeSupported. Cocoa port allows mp4 audio and video mime types, with H264 and AAC codecs. Add a routine to get the mime type from the MediaRecorderPrivate. Store it in MediaRecorder and add a mimeType getter. Test: http/wpt/mediarecorder/mimeType.html * Modules/mediarecorder/MediaRecorder.cpp: (WebCore::MediaRecorder::isTypeSupported): (WebCore::MediaRecorder::create): * Modules/mediarecorder/MediaRecorder.h: * Modules/mediarecorder/MediaRecorder.idl: * Modules/mediarecorder/MediaRecorderProvider.cpp: (WebCore::MediaRecorderProvider::isSupported): * Modules/mediarecorder/MediaRecorderProvider.h: * platform/mediarecorder/MediaRecorderPrivate.h: * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp: (WebCore::MediaRecorderPrivateAVFImpl::mimeType const): * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h: * platform/mediarecorder/MediaRecorderPrivateMock.cpp: (WebCore::MediaRecorderPrivateMock::mimeType const): * platform/mediarecorder/MediaRecorderPrivateMock.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm: (WebCore::MediaRecorderPrivateWriter::mimeType const): * platform/mediastream/MediaStreamPrivate.h: Source/WebKit: Reviewed by Darin Adler. Stop passing mimeType for each data blob. Instead, compute it on WebProcess side. * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::fetchData): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::fetchData): (WebKit::MediaRecorderPrivate::mimeType const): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: LayoutTests: Reviewed by Darin Adler. * http/wpt/mediarecorder/mimeType-expected.txt: Added. * http/wpt/mediarecorder/mimeType.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267825 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-01 Youenn Fablet MediaRecorder should support isTypeSupported https://bugs.webkit.org/show_bug.cgi?id=216856 Reviewed by Darin Adler. Stop passing mimeType for each data blob. Instead, compute it on WebProcess side. * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::fetchData): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::fetchData): (WebKit::MediaRecorderPrivate::mimeType const): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: 2020-10-06 Alan Coon Cherry-pick r267366. rdar://problem/70023908 [iOS] MediaRecorder incorrect screen orientation handling https://bugs.webkit.org/show_bug.cgi?id=198912 Reviewed by Eric Carlson. Source/WebCore: Update MediaRecorderPrivateWriterCocoa to pass a MediaSample down to handle rotation. Set AVAssetWriterInput transform according the first MediaSample rotation value. Test: http/wpt/mediarecorder/video-rotation.html * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp: (WebCore::MediaRecorderPrivateAVFImpl::videoSampleAvailable): * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm: (WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer): Source/WebKit: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::videoSampleAvailable): LayoutTests: * http/wpt/mediarecorder/video-rotation-expected.txt: Added. * http/wpt/mediarecorder/video-rotation.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267366 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-21 Youenn Fablet [iOS] MediaRecorder incorrect screen orientation handling https://bugs.webkit.org/show_bug.cgi?id=198912 Reviewed by Eric Carlson. * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::videoSampleAvailable): 2020-10-06 Alan Coon Apply patch. rdar://problem/70010322 2020-10-06 Youenn Fablet Add support for MediaRecorder bitrate options https://bugs.webkit.org/show_bug.cgi?id=214973 Reviewed by Eric Carlson. Serialize options when creating remote media recorder. * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::create): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorderManager.cpp: (WebKit::RemoteMediaRecorderManager::createRecorder): * GPUProcess/webrtc/RemoteMediaRecorderManager.h: * GPUProcess/webrtc/RemoteMediaRecorderManager.messages.in: * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::startRecording): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: * WebProcess/GPU/webrtc/MediaRecorderProvider.cpp: (WebKit::MediaRecorderProvider::createMediaRecorderPrivate): * WebProcess/GPU/webrtc/MediaRecorderProvider.h: 2020-10-06 Alan Coon Cherry-pick r268030. rdar://problem/70010322 Break reference cycle with NSURLSessionDataTask in NetworkDataTaskCocoa https://bugs.webkit.org/show_bug.cgi?id=217347 Reviewed by Geoffrey Garen. * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::applyCookiePolicyForThirdPartyCNAMECloaking): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268030 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-05 Sihui Liu Break reference cycle with NSURLSessionDataTask in NetworkDataTaskCocoa https://bugs.webkit.org/show_bug.cgi?id=217347 Reviewed by Geoffrey Garen. * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::applyCookiePolicyForThirdPartyCNAMECloaking): 2020-10-06 Alan Coon Cherry-pick r268019. rdar://problem/70005083 Change a PDF RELEASE_ASSERT to an early return. rdar://problem/69805240 and https://bugs.webkit.org/show_bug.cgi?id=217346 Reviewed by Tim Horton. No new tests (Wish they were possible) * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::installPDFDocument): This release assert is getting hit regularly. Change to an early return while we continue tracking this down. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268019 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-10-05 Brady Eidson Change a PDF RELEASE_ASSERT to an early return. rdar://problem/69805240 and https://bugs.webkit.org/show_bug.cgi?id=217346 Reviewed by Tim Horton. No new tests (Wish they were possible) * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::installPDFDocument): This release assert is getting hit regularly. Change to an early return while we continue tracking this down. 2020-10-05 Alan Coon Cherry-pick r267602. rdar://problem/69904386 WebGL should use GLES in iOS apps running on Apple Silicon https://bugs.webkit.org/show_bug.cgi?id=216722 Reviewed by Tim Horton and Ken Russell. Source/ThirdParty/ANGLE: Change ANGLE to dynamically load either EAGL (OpenGLES) or CGL (OpenGL) depending on both compile and runtime configurations. Intel Mac -> CGL Intel Mac Catalyst -> CGL Intel iOS Simulator -> EAGL iOS Device -> EAGL Apple Silicon Mac -> CGL Apple Silicon Mac Catalyst (with Mac app) -> CGL Apple Silicon Mac Catalyst (with iOS app) -> EAGL The trickiest bit is Apple Silicon Mac Catalyst, which depends on the type of the application it is attempting to run. In that case ANGLE must compile both the CGL and EAGL interfaces and then pick one to use after launch. * ANGLE.xcodeproj/project.pbxproj: Add new files. * Configurations/ANGLE-dynamic.xcconfig: Remove all the OpenGL* linking. * Configurations/ANGLE-static.xcconfig: * GLESv2.cmake: New files. * src/common/platform.h: New definitions for CPU type on Apple Systems. * src/gpu_info_util/SystemInfo.h: Split SystemInfo for Apple into two files, for iOS and Mac. Added a field for isiOSAppOnMac that will only be true when running an iOS binary on Apple Silicon. * src/gpu_info_util/SystemInfo_apple.mm: Added. Decides which SystemInfo to call. (angle::GetSystemInfo): * src/gpu_info_util/SystemInfo_ios.cpp: (angle::GetSystemInfo_ios): (angle::GetSystemInfo): Deleted. * src/gpu_info_util/SystemInfo_macos.mm: (angle::GetSystemInfo_mac): (angle::GetSystemInfo): Deleted. * src/libANGLE/Caps.cpp: Can no longer just check for PLATFORM_IOS. This might still need a runtime check. (gl::DetermineDepthTextureANGLESupport): (gl::DetermineDepthTextureOESSupport): * src/libANGLE/Display.cpp: This is the main initialization point for ANGLE, which decides at compile/runtime which variant of Display to create. * src/libANGLE/formatutils.cpp: Add the correct formats. (gl::BuildInternalFormatInfoMap): * src/libANGLE/renderer/gl/SoftLinking_apple.h: Added. Macros to help soft-link functions and ObjC classes. * src/libANGLE/renderer/gl/cgl/CGLFunctions.cpp: Added. Where we soft-link all the OpenGL/CGL API. * src/libANGLE/renderer/gl/cgl/CGLFunctions.h: Added. * src/libANGLE/renderer/gl/cgl/DisplayCGL.mm: Use the soft-linked methods. * src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp: * src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h: * src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm: Rename WebSwapLayer to WebSwapLayerCGL otherwise it clashes with the EAGL version. (rx::WindowSurfaceCGL::initialize): (-[WebSwapLayer initWithSharedState:withContext:withFunctions:]): Deleted. (-[WebSwapLayer copyCGLPixelFormatForDisplayMask:]): Deleted. (-[WebSwapLayer copyCGLContextForPixelFormat:]): Deleted. (-[WebSwapLayer canDrawInCGLContext:pixelFormat:forLayerTime:displayTime:]): Deleted. (-[WebSwapLayer drawInCGLContext:pixelFormat:forLayerTime:displayTime:]): Deleted. * src/libANGLE/renderer/gl/eagl/DeviceEAGL.cpp: Similar changes to the CGL implementation. * src/libANGLE/renderer/gl/eagl/DeviceEAGL.h: * src/libANGLE/renderer/gl/eagl/DisplayEAGL.h: * src/libANGLE/renderer/gl/eagl/DisplayEAGL.mm: (rx::DisplayEAGL::initialize): (rx::DisplayEAGL::terminate): (rx::WorkerContextEAGL::~WorkerContextEAGL): (rx::WorkerContextEAGL::makeCurrent): (rx::WorkerContextEAGL::unmakeCurrent): (rx::DisplayEAGL::createWorkerContext): * src/libANGLE/renderer/gl/eagl/EAGLFunctions.h: Added. * src/libANGLE/renderer/gl/eagl/EAGLFunctions.mm: Added. * src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm: * src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.cpp: * src/libANGLE/renderer/gl/eagl/RendererEAGL.cpp: * src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h: * src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.mm: (-[WebSwapLayerEAGL display]): (rx::WindowSurfaceEAGL::initialize): (-[WebSwapLayer initWithSharedState:withContext:withFunctions:]): Deleted. (-[WebSwapLayer display]): Deleted. * src/libANGLE/renderer/gl/renderergl_utils.cpp: Runtime check. (rx::nativegl_gl::GenerateCaps): Source/WebCore: * Configurations/WebCore.xcconfig: Remove all OpenGL/OpenGLES linking. * WebCore.xcodeproj/project.pbxproj: * platform/graphics/GraphicsContextGL.h: Change the ANGLE IOSurface texture binding enums into functions, because they have to be calculated at run-time. * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm: Use the new soft-linked functions from PAL. Also implement the IOSurface texture binding helpers that were previously enums. * platform/mac/PlatformScreenMac.mm: * platform/mac/WebGLBlocklist.mm: Source/WebCore/PAL: Add soft-linking content for OpenGL/OpenGLES. * PAL.xcodeproj/project.pbxproj: * pal/PlatformMac.cmake: * pal/cocoa/OpenGLSoftLinkCocoa.h: Added. * pal/cocoa/OpenGLSoftLinkCocoa.mm: Added. Source/WebKit: * Configurations/WebKit.xcconfig: Remove OpenGL linking. * UIProcess/mac/HighPerformanceGPUManager.mm: Renamed to .mm. Use the PAL soft-linked OpenGL API. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267602 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-24 Dean Jackson WebGL should use GLES in iOS apps running on Apple Silicon https://bugs.webkit.org/show_bug.cgi?id=216722 Reviewed by Tim Horton. * Configurations/WebKit.xcconfig: Remove OpenGL linking. * UIProcess/mac/HighPerformanceGPUManager.mm: Renamed to .mm. Use the PAL soft-linked OpenGL API. 2020-10-02 Alan Coon Cherry-pick r267792. rdar://problem/69904383 REGRESSION (r265009): Web Share API can no longer be invoked if a previous invocation was dismissed using the close button https://bugs.webkit.org/show_bug.cgi?id=216913 Reviewed by Darin Adler. No new tests; not able to test without UI tests that actually use UIActivityViewController. * UIProcess/Cocoa/WKShareSheet.mm: (-[WKShareSheet presentWithShareDataArray:inRect:]): -presentationControllerDidDismiss is not called if the UIActivityViewController is programmatically dismissed, so we need to revert to observing completion via UIActivityViewController's -completionWithItemsHandler. In order to avoid regressing bug 214894 by doing so, we also need to make sure that we're actually not presented anymore, as -completionWithItemsHandler can be called multiple times before the share sheet is actually dismissed. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267792 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-30 Tim Horton REGRESSION (r265009): Web Share API can no longer be invoked if a previous invocation was dismissed using the close button https://bugs.webkit.org/show_bug.cgi?id=216913 Reviewed by Darin Adler. No new tests; not able to test without UI tests that actually use UIActivityViewController. * UIProcess/Cocoa/WKShareSheet.mm: (-[WKShareSheet presentWithShareDataArray:inRect:]): -presentationControllerDidDismiss is not called if the UIActivityViewController is programmatically dismissed, so we need to revert to observing completion via UIActivityViewController's -completionWithItemsHandler. In order to avoid regressing bug 214894 by doing so, we also need to make sure that we're actually not presented anymore, as -completionWithItemsHandler can be called multiple times before the share sheet is actually dismissed. 2020-10-02 Alan Coon Cherry-pick r267612. rdar://problem/69904365 Crunchyroll playback controls do not work on iPad with trackpad https://bugs.webkit.org/show_bug.cgi?id=217000 Reviewed by Wenson Hsieh. Source/WebCore: * platform/RuntimeApplicationChecks.h: * platform/cocoa/RuntimeApplicationChecksCocoa.mm: (WebCore::IOSApplication::isCrunchyroll): Source/WebKit: * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): Add it to the list. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267612 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-25 Tim Horton Crunchyroll playback controls do not work on iPad with trackpad https://bugs.webkit.org/show_bug.cgi?id=217000 Reviewed by Wenson Hsieh. * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): Add it to the list. 2020-10-02 Alan Coon Cherry-pick r266028. rdar://problem/69904377 Move node geometry functions from Range to RenderObject https://bugs.webkit.org/show_bug.cgi?id=215677 Reviewed by Zalan Bujtas. Source/WebCore: Moved functions that return quads and rectangles out of Range into RenderObject. We could find another home for them, but for now they make sense as static member functions there since RenderObject has the non-static member functions that they call on multiple nodes. Mostly did not change the design of these functions much, and was careful not to change behavior at all. But did change a few things: - Got rid of the functions that return a single unioned rectangle. Instead callers call unionRect at each call site. - Changed the "use selection height" boolean to a BoundingRectBehavior flag. * accessibility/AccessibilityRenderObject.cpp: (WebCore::boundsForRects): Call unionRect(RenderObject::absoluteTextRects) instead of Range::absoluteBoundingBox. * dom/DocumentMarkerController.cpp: (WebCore::updateRenderedRectsForMarker): Instead of passing "true", pass "RenderObject::BoundingRectBehavior::UseSelectionHeight". * dom/Range.cpp: (WebCore::Range::absoluteBoundingBox const): Deleted. (WebCore::Range::absoluteRectsForRangeInText const): Deleted. (WebCore::Range::absoluteTextRects const): Deleted. (WebCore::Range::getClientRects const): Call RenderObject::clientBorderAndTextRects. (WebCore::Range::getBoundingClientRect const): Call unionRect(RenderObject::clientBorderAndTextRects). (WebCore::Range::borderAndTextRects const): Deleted. (WebCore::Range::boundingRect const): Deleted. (WebCore::Range::absoluteBoundingRect const): Deleted. * dom/Range.h: Updated for above. * dom/SimpleRange.cpp: (WebCore::IntersectingNodeIterator::IntersectingNodeIterator): Fix bug affecting empty ranges by calling enforceEndInvariant. (WebCore::IntersectingNodeIterator::advance): Refactor to call enforceEndInvariant. (WebCore::IntersectingNodeIterator::advanceSkippingChildren): Ditto. (WebCore::IntersectingNodeIterator::enforceEndInvariant): Added. * dom/SimpleRange.h: Added enforceEndInvariant. * editing/FrameSelection.cpp: (WebCore::FrameSelection::getClippedVisibleTextRectangles const): Instead of passing a useSelectionHeight boolean, pass BoundingRectBehavior. * page/TextIndicator.cpp: (WebCore::absoluteBoundingRectForRange): Call unionRectIgnoringZeroRects(RenderObject::absoluteBorderAndTextRects). (WebCore::initializeIndicator): Call RenderObject::absoluteTextRects. * platform/graphics/GeometryUtilities.cpp: (WebCore::unionRectIgnoringZeroRects): Added. * platform/graphics/GeometryUtilities.h: Updated for above. * rendering/RenderLineBreak.h: Marked a lot of functions final. Added a default value for the absoluteQuads out argument. * rendering/RenderObject.cpp: (WebCore::RenderObject::addPDFURLRect): Tweaked code style a bit. (WebCore::RenderObject::absoluteTextQuads): Replaced boolean useSelectionHeight argument with a BoundingRectBehavior argument. Also added a downcast so the call to RenderLineBreak::absoluteQuads is a non-virtual function call. (WebCore::absoluteRectsForRangeInText): Added. (WebCore::RenderObject::absoluteTextRects): Replaced boolean useSelectionHeight argument with a BoundingRectBehavior argument. (WebCore::nodeBefore): Added. (WebCore::borderAndTextRects): Added. (WebCore::RenderObject::absoluteBorderAndTextRects): Added. (WebCore::RenderObject::clientBorderAndTextRects): Added. * rendering/RenderObject.h: Updated for above. Source/WebKit: * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp: (WebKit::InjectedBundleRangeHandle::boundingRectInWindowCoordinates const): Call unionRectIgnoringZeroRects(RenderObject::absoluteBorderAndTextRects). (WebKit::InjectedBundleRangeHandle::renderedImage): Call unionRectIgnoringZeroRects(RenderObject::absoluteBorderAndTextRects). * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestEvasionRectsAboveSelection): Call unionRect(RenderObject::absoluteTextRects). (WebKit::WebPage::requestDocumentEditingContext): Call unionRect(RenderObject::absoluteTextRects). Source/WebKitLegacy/mac: * DOM/DOM.mm: (-[DOMRange boundingBox]): Call unionRect(RenderObject::absoluteTextRects). Source/WebKitLegacy/win: * AccessibleTextImpl.cpp: (AccessibleText::scrollSubstringTo): Call unionRect(RenderObject::absoluteTextRects) instead of Range::absoluteBoundingBox. LayoutTests: * fast/dom/Range/scale-page-bounding-client-rect.html: Fix this test that accidentally depended on getting rects for an empty range (the contents of a div element with no text inside it) to instead get rects for a non-empty element (the div element, not just its contents). Test now works correctly, but results don't need to change. * fast/dom/Range/scale-page-client-rects.html: Ditto. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266028 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-19 Darin Adler Move node geometry functions from Range to RenderObject https://bugs.webkit.org/show_bug.cgi?id=215677 Reviewed by Zalan Bujtas. * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp: (WebKit::InjectedBundleRangeHandle::boundingRectInWindowCoordinates const): Call unionRectIgnoringZeroRects(RenderObject::absoluteBorderAndTextRects). (WebKit::InjectedBundleRangeHandle::renderedImage): Call unionRectIgnoringZeroRects(RenderObject::absoluteBorderAndTextRects). * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestEvasionRectsAboveSelection): Call unionRect(RenderObject::absoluteTextRects). (WebKit::WebPage::requestDocumentEditingContext): Call unionRect(RenderObject::absoluteTextRects). 2020-09-27 Alan Coon Cherry-pick r267540. rdar://problem/69593993 CrashTracer: com.apple.WebKit.Networking in NetworkSession::firstPartyHostCNAMEDomain() code https://bugs.webkit.org/show_bug.cgi?id=216934 Reviewed by Alex Christensen. Add a check for a valid key. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::firstPartyHostCNAMEDomain): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267540 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-24 Kate Cheney CrashTracer: com.apple.WebKit.Networking in NetworkSession::firstPartyHostCNAMEDomain() code https://bugs.webkit.org/show_bug.cgi?id=216934 Reviewed by Alex Christensen. Add a check for a valid key. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::firstPartyHostCNAMEDomain): 2020-09-27 Alan Coon Cherry-pick r267496. rdar://problem/69594104 [macOS] Change name of client decoder entitlement https://bugs.webkit.org/show_bug.cgi?id=216670 Reviewed by Darin Adler. The client decoder entitlement landed in has changed name, and should be updated. * Scripts/process-entitlements.sh: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267496 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-23 Per Arne Vollan [macOS] Change name of client decoder entitlement https://bugs.webkit.org/show_bug.cgi?id=216670 Reviewed by Darin Adler. The client decoder entitlement landed in has changed name, and should be updated. * Scripts/process-entitlements.sh: 2020-09-27 Alan Coon Cherry-pick r267412. rdar://problem/69594162 Crashtracer inside PDFPlugin::createScrollbar. and https://bugs.webkit.org/show_bug.cgi?id=216810 Reviewed by Tim Horton. To quote Tim from r264945: No new tests; timing is such that I can't reproduce without inserting intentional delays into the main thread hops, which is further than I'm willing to go for a test. This is a speculative fix due to the aforementioned reproducibility issue. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::installPDFDocument): With all the past fixes in place, its apparent the plug-in HAS been torn down, and it's somewhat common to bypass the other "hasBeenDestroyed" checks. So put an explicit check here followed by an explicit release assert. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267412 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-22 Brady Eidson Crashtracer inside PDFPlugin::createScrollbar. and https://bugs.webkit.org/show_bug.cgi?id=216810 Reviewed by Tim Horton. To quote Tim from r264945: No new tests; timing is such that I can't reproduce without inserting intentional delays into the main thread hops, which is further than I'm willing to go for a test. This is a speculative fix due to the aforementioned reproducibility issue. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::installPDFDocument): With all the past fixes in place, its apparent the plug-in HAS been torn down, and it's somewhat common to bypass the other "hasBeenDestroyed" checks. So put an explicit check here followed by an explicit release assert. 2020-09-27 Alan Coon Cherry-pick r267394. rdar://problem/69593980 paper.io ad close buttons cannot be iteracted with via trackpad on iPad https://bugs.webkit.org/show_bug.cgi?id=216812 Reviewed by Wenson Hsieh. Source/WebCore: * platform/RuntimeApplicationChecks.h: * platform/cocoa/RuntimeApplicationChecksCocoa.mm: (WebCore::IOSApplication::isPaperIO): Source/WebKit: * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267394 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-21 Tim Horton paper.io ad close buttons cannot be iteracted with via trackpad on iPad https://bugs.webkit.org/show_bug.cgi?id=216812 Reviewed by Wenson Hsieh. * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): 2020-09-27 Alan Coon Cherry-pick r267305. rdar://problem/69594350 [macOS] REGRESSION (r265702): System Services receive 0 bytes when extracting selected content as rich text data https://bugs.webkit.org/show_bug.cgi?id=216718 Reviewed by Tim Horton. Source/WebKit: Test: CopyHTML.WriteRichTextSelectionToPasteboard * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::dataSelectionForPasteboard): After r265702, the `IPCHandle` received in the UI process was always being converted into a buffer of size 0, due to using the `size` local variable (which is no longer set as an outparam of the sync IPC message). Instead, use `ipcHandle.dataSize`. Tools: Add a new API test to verify that we get non-empty web archive data when using `-writeSelectionToPasteboard:types:` to grab selected content as rich text data. * TestWebKitAPI/Tests/WebKitCocoa/CopyHTML.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267305 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-18 Wenson Hsieh [macOS] REGRESSION (r265702): System Services receive 0 bytes when extracting selected content as rich text data https://bugs.webkit.org/show_bug.cgi?id=216718 Reviewed by Tim Horton. Test: CopyHTML.WriteRichTextSelectionToPasteboard * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::dataSelectionForPasteboard): After r265702, the `IPCHandle` received in the UI process was always being converted into a buffer of size 0, due to using the `size` local variable (which is no longer set as an outparam of the sync IPC message). Instead, use `ipcHandle.dataSize`. 2020-09-27 Alan Coon Cherry-pick r267215. rdar://problem/69594225 Per-app accent color overrides are broken https://bugs.webkit.org/show_bug.cgi?id=216674 Reviewed by Wenson Hsieh. Source/WebCore/PAL: * pal/spi/mac/NSApplicationSPI.h: Source/WebKit: No new tests; I've no idea how to write a test that would have caught this; any test I can imagine would have also written to _accentColor and worked fine. * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::accentColor): AppKit changed the meaning of the IPI. Use the correct version. We still write to _accentColor; it is now purely an override. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267215 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-17 Tim Horton Per-app accent color overrides are broken https://bugs.webkit.org/show_bug.cgi?id=216674 Reviewed by Wenson Hsieh. No new tests; I've no idea how to write a test that would have caught this; any test I can imagine would have also written to _accentColor and worked fine. * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::accentColor): AppKit changed the meaning of the IPI. Use the correct version. We still write to _accentColor; it is now purely an override. 2020-09-27 Alan Coon Cherry-pick r267092. rdar://problem/69594199 REGRESSION (r267002): ASSERTION FAILED:[ iOS wk2 Debug ] !HashTranslator::equal(KeyTraits::emptyValue(), key) on compositing/ios/overflow-scroll-update-overlap.html https://bugs.webkit.org/show_bug.cgi?id=216520 Reviewed by Tim Horton. Source/WebKit: Avoid hash lookups with zero nodeIDs. * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm: (WebKit::RemoteScrollingCoordinator::isRubberBandInProgress const): (WebKit::RemoteScrollingCoordinator::isUserScrollInProgress const): (WebKit::RemoteScrollingCoordinator::isScrollSnapInProgress const): LayoutTests: * platform/ios-wk2/TestExpectations: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267092 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-15 Simon Fraser REGRESSION (r267002): ASSERTION FAILED:[ iOS wk2 Debug ] !HashTranslator::equal(KeyTraits::emptyValue(), key) on compositing/ios/overflow-scroll-update-overlap.html https://bugs.webkit.org/show_bug.cgi?id=216520 Reviewed by Tim Horton. Avoid hash lookups with zero nodeIDs. * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm: (WebKit::RemoteScrollingCoordinator::isRubberBandInProgress const): (WebKit::RemoteScrollingCoordinator::isUserScrollInProgress const): (WebKit::RemoteScrollingCoordinator::isScrollSnapInProgress const): 2020-09-27 Alan Coon Cherry-pick r267002. rdar://problem/69594199 Overflow:scroll rubberbanding is interrupted by post-layout scrolling https://bugs.webkit.org/show_bug.cgi?id=216463 Reviewed by Darin Adler. When rubberbanding overflow:scroll RenderLayer has an overscrolled scroll offset. If RenderLayer::updateScrollInfoAfterLayout() happens when in this state, it can clamp the scroll offset, causing the rubberband to collapse which interferes with the user interaction. This happend on Gmail when composing a reply. Fix by tracking the rubberbanding state in the scrolling tree, and having RenderLayer query this state via the ScrollingCoordinator. RenderLayer::updateScrollInfoAfterLayout() already tested isRubberBandInProgress(). This is similar to how isUserScrollInProgress() and isScrollSnapInProgress() work. This patch also fixes the tracking of rubberbanding state. Previously setMainFrameIsRubberBanding() was just based on when the timer was started and stopped, which did not match the implementation of ScrollController::isRubberBandInProgress(). Now ScrollController correctly notifies its clients when the rubberbanding state changes by updating that state whenever any of the conditions consulted in isRubberBandInProgressInternal() change. Source/WebCore: I tried to make tests for this, but the timing of wheel and scroll event delivery makes reliable detection of interrupted rubberbands impossible in WebKitTestRunner. * page/FrameView.cpp: (WebCore::FrameView::isRubberBandInProgress const): * page/scrolling/AsyncScrollingCoordinator.cpp: (WebCore::AsyncScrollingCoordinator::isRubberBandInProgress const): * page/scrolling/AsyncScrollingCoordinator.h: * page/scrolling/ScrollingCoordinator.h: (WebCore::ScrollingCoordinator::isRubberBandInProgress const): * page/scrolling/ScrollingTree.cpp: (WebCore::ScrollingTree::isRubberBandInProgressForNode): (WebCore::ScrollingTree::setRubberBandingInProgressForNode): (WebCore::ScrollingTree::isRubberBandInProgress): Deleted. (WebCore::ScrollingTree::setMainFrameIsRubberBanding): Deleted. * page/scrolling/ScrollingTree.h: * page/scrolling/ScrollingTreeScrollingNode.cpp: (WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren): * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged): (WebCore::ScrollingTreeFrameScrollingNodeMac::updateMainFramePinAndRubberbandState): * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h: * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm: (WebCore::ScrollingTreeOverflowScrollingNodeMac::currentScrollPositionChanged): * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h: * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: (WebCore::ScrollingTreeScrollingNodeDelegateMac::currentScrollPositionChanged): (WebCore::ScrollingTreeScrollingNodeDelegateMac::isRubberBandInProgress const): (WebCore::ScrollingTreeScrollingNodeDelegateMac::didStopRubberbandSnapAnimation): (WebCore::ScrollingTreeScrollingNodeDelegateMac::rubberBandingStateChanged): * platform/ScrollAnimator.cpp: (WebCore::ScrollAnimator::notifyPositionChanged): * platform/cocoa/ScrollController.h: (WebCore::ScrollControllerClient::rubberBandingStateChanged): * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::handleWheelEvent): (WebCore::ScrollController::snapRubberBandTimerFired): (WebCore::ScrollController::scrollPositionChanged): (WebCore::ScrollController::isRubberBandInProgress const): (WebCore::ScrollController::stopSnapRubberbandTimer): (WebCore::ScrollController::isRubberBandInProgressInternal const): (WebCore::ScrollController::updateRubberBandingState): (WebCore::ScrollController::updateGestureInProgressState): * rendering/RenderLayer.cpp: (WebCore::RenderLayer::isRubberBandInProgress const): (WebCore::RenderLayer::updateScrollInfoAfterLayout): Source/WebKit: * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h: * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm: (WebKit::RemoteScrollingCoordinator::isRubberBandInProgress const): (WebKit::RemoteScrollingCoordinator::scrollingStateInUIProcessChanged): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267002 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-13 Simon Fraser Overflow:scroll rubberbanding is interrupted by post-layout scrolling https://bugs.webkit.org/show_bug.cgi?id=216463 Reviewed by Darin Adler. When rubberbanding overflow:scroll RenderLayer has an overscrolled scroll offset. If RenderLayer::updateScrollInfoAfterLayout() happens when in this state, it can clamp the scroll offset, causing the rubberband to collapse which interferes with the user interaction. This happend on Gmail when composing a reply. Fix by tracking the rubberbanding state in the scrolling tree, and having RenderLayer query this state via the ScrollingCoordinator. RenderLayer::updateScrollInfoAfterLayout() already tested isRubberBandInProgress(). This is similar to how isUserScrollInProgress() and isScrollSnapInProgress() work. This patch also fixes the tracking of rubberbanding state. Previously setMainFrameIsRubberBanding() was just based on when the timer was started and stopped, which did not match the implementation of ScrollController::isRubberBandInProgress(). Now ScrollController correctly notifies its clients when the rubberbanding state changes by updating that state whenever any of the conditions consulted in isRubberBandInProgressInternal() change. * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h: * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm: (WebKit::RemoteScrollingCoordinator::isRubberBandInProgress const): (WebKit::RemoteScrollingCoordinator::scrollingStateInUIProcessChanged): 2020-09-27 Alan Coon Cherry-pick r266611. rdar://problem/69594191 MediaRecorder timeslice parameter causing internal error on longer videos https://bugs.webkit.org/show_bug.cgi?id=216076 Reviewed by Eric Carlson. Source/WebCore: Test: http/wpt/fetch/blob-range.html * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::readDataAsync): Source/WebKit: Test: http/wpt/fetch/blob-range.html * NetworkProcess/NetworkDataTaskBlob.cpp: (WebKit::NetworkDataTaskBlob::readData): readData can be re-entrant so we need to reset m_currentItemReadSize before consuming data. LayoutTests: * http/wpt/fetch/blob-range-expected.txt: Added. * http/wpt/fetch/blob-range.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266611 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-04 Youenn Fablet MediaRecorder timeslice parameter causing internal error on longer videos https://bugs.webkit.org/show_bug.cgi?id=216076 Reviewed by Eric Carlson. Test: http/wpt/fetch/blob-range.html * NetworkProcess/NetworkDataTaskBlob.cpp: (WebKit::NetworkDataTaskBlob::readData): readData can be re-entrant so we need to reset m_currentItemReadSize before consuming data. 2020-09-27 Alan Coon Cherry-pick r265977. rdar://problem/69594018 Could not find module 'WebKit' for target 'armv7-apple-ios' Reviewed by Brady Eidson. The config changes here got added to the wrong config file. They need to be for the overlay, not its tests. * SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig: * SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265977 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-20 James Savage Could not find module 'WebKit' for target 'armv7-apple-ios' Reviewed by Brady Eidson. The config changes here got added to the wrong config file. They need to be for the overlay, not its tests. * SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig: * SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: 2020-09-27 Alan Coon Cherry-pick r265322. rdar://problem/69594018 Could not find module 'WebKit' for target 'armv7-apple-ios' Reviewed by Brady Eidson. * SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: Define SWIFT_MODULE_ONLY_ARCHS to emit other architectures. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265322 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-06 James Savage Could not find module 'WebKit' for target 'armv7-apple-ios' Reviewed by Brady Eidson. * SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: Define SWIFT_MODULE_ONLY_ARCHS to emit other architectures. 2020-09-25 Alan Coon Cherry-pick r266804. rdar://problem/69583164 macCatalyst: Form controls behave strangely (like iPhone) in macOS-idiom apps https://bugs.webkit.org/show_bug.cgi?id=216326 Reviewed by Wenson Hsieh. * Shared/UserInterfaceIdiom.h: * Shared/UserInterfaceIdiom.mm: (WebKit::userInterfaceIdiomIsPad): (WebKit::currentUserInterfaceIdiomIsPadOrMac): (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac): (WebKit::currentUserInterfaceIdiomIsPad): Deleted. (WebKit::setCurrentUserInterfaceIdiomIsPad): Deleted. * Shared/ios/WebPreferencesDefaultValuesIOS.mm: (WebKit::defaultTextAutosizingUsesIdempotentMode): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration init]): * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * UIProcess/ios/SmartMagnificationController.mm: (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture): * UIProcess/ios/WKContentViewInteraction.mm: (-[WKFormInputSession setAccessoryViewCustomButtonTitle:]): (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]): (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]): (-[WKContentView _zoomToRevealFocusedElement]): (-[WKContentView requiresAccessoryView]): (-[WKContentView _updateAccessory]): (shouldShowKeyboardForElement): (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]): * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm: (WebKit::WebDataListSuggestionsDropdownIOS::show): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::desktopClassBrowsingSupported): * UIProcess/ios/forms/WKAirPlayRoutePicker.mm: (-[WKAirPlayRoutePicker show:fromRect:]): * UIProcess/ios/forms/WKFileUploadPanel.mm: (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]): (-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]): * UIProcess/ios/forms/WKFormColorControl.mm: (-[WKFormColorControl initWithView:]): * UIProcess/ios/forms/WKFormColorPicker.mm: (-[WKColorPicker initWithView:inPopover:]): (-[WKColorPicker drawSelectionIndicatorForColorButton:]): * UIProcess/ios/forms/WKFormSelectControl.mm: (-[WKFormSelectControl initWithView:]): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Rename currentUserInterfaceIdiomIsPad to currentUserInterfaceIdiomIsPadOrMac, and force it to YES on macCatalyst since internally we use it to distinguish between iPhone and iPad behavior, and (for our behaviors, at least) macCatalyst should always follow iPad. We should clean this up, and make all callers make their iPhone vs. iPad vs. macOS decisions more explicit. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266804 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-09 Tim Horton macCatalyst: Form controls behave strangely (like iPhone) in macOS-idiom apps https://bugs.webkit.org/show_bug.cgi?id=216326 Reviewed by Wenson Hsieh. * Shared/UserInterfaceIdiom.h: * Shared/UserInterfaceIdiom.mm: (WebKit::userInterfaceIdiomIsPad): (WebKit::currentUserInterfaceIdiomIsPadOrMac): (WebKit::setCurrentUserInterfaceIdiomIsPadOrMac): (WebKit::currentUserInterfaceIdiomIsPad): Deleted. (WebKit::setCurrentUserInterfaceIdiomIsPad): Deleted. * Shared/ios/WebPreferencesDefaultValuesIOS.mm: (WebKit::defaultTextAutosizingUsesIdempotentMode): * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration init]): * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): * UIProcess/ios/SmartMagnificationController.mm: (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture): * UIProcess/ios/WKContentViewInteraction.mm: (-[WKFormInputSession setAccessoryViewCustomButtonTitle:]): (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]): (-[WKContentView _shouldShowAutomaticKeyboardUIIgnoringInputMode]): (-[WKContentView _zoomToRevealFocusedElement]): (-[WKContentView requiresAccessoryView]): (-[WKContentView _updateAccessory]): (shouldShowKeyboardForElement): (-[WKContentView _shouldUseLegacySelectPopoverDismissalBehavior]): * UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm: (WebKit::WebDataListSuggestionsDropdownIOS::show): * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::desktopClassBrowsingSupported): * UIProcess/ios/forms/WKAirPlayRoutePicker.mm: (-[WKAirPlayRoutePicker show:fromRect:]): * UIProcess/ios/forms/WKFileUploadPanel.mm: (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]): (-[WKFileUploadPanel _presentMenuOptionForCurrentInterfaceIdiom:]): * UIProcess/ios/forms/WKFormColorControl.mm: (-[WKFormColorControl initWithView:]): * UIProcess/ios/forms/WKFormColorPicker.mm: (-[WKColorPicker initWithView:inPopover:]): (-[WKColorPicker drawSelectionIndicatorForColorButton:]): * UIProcess/ios/forms/WKFormSelectControl.mm: (-[WKFormSelectControl initWithView:]): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Rename currentUserInterfaceIdiomIsPad to currentUserInterfaceIdiomIsPadOrMac, and force it to YES on macCatalyst since internally we use it to distinguish between iPhone and iPad behavior, and (for our behaviors, at least) macCatalyst should always follow iPad. We should clean this up, and make all callers make their iPhone vs. iPad vs. macOS decisions more explicit. 2020-09-25 Alan Coon Cherry-pick r266798. rdar://problem/69583118 Make sure WKWebsiteDataStore operations reuse existing process pools even when all WKWebViews have closed. and https://bugs.webkit.org/show_bug.cgi?id=216317 Reviewed by Geoffrey Garen. Source/WebKit: Covered by new API test. When WebsiteDataStores are gathering all the NetworkProcesses they might need to message, they miss some obvious candidates if there are no longer any related WKWebViews. Fix that by tracking which sessions a NetworkProcess knows about. * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::addSession): (WebKit::NetworkProcessProxy::hasSession const): (WebKit::NetworkProcessProxy::removeSession): * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::isAssociatedProcessPool const): Tools: * TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm: (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266798 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-09 Brady Eidson Make sure WKWebsiteDataStore operations reuse existing process pools even when all WKWebViews have closed. and https://bugs.webkit.org/show_bug.cgi?id=216317 Reviewed by Geoffrey Garen. Covered by new API test. When WebsiteDataStores are gathering all the NetworkProcesses they might need to message, they miss some obvious candidates if there are no longer any related WKWebViews. Fix that by tracking which sessions a NetworkProcess knows about. * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::addSession): (WebKit::NetworkProcessProxy::hasSession const): (WebKit::NetworkProcessProxy::removeSession): * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::isAssociatedProcessPool const): 2020-09-18 Alan Coon Cherry-pick r267208. rdar://problem/69178138 Enable ITP in WKWebViews for apps with the full browser entitlement who are not linked to iOS 14.0 https://bugs.webkit.org/show_bug.cgi?id=216655 Reviewed by Brent Fulgham. Apps with the full browser entitlement who are not linked to iOS 14.0 should have ITP enabled in WKWebViews by default. No new tests, no way currently to test apps with different iOS versions. Tested manually. * Shared/Cocoa/DefaultWebBrowserChecks.mm: (WebKit::determineITPStateInternal): Ignore the early return for the linked-on-or-after check if the app has the default browser entitlement so we still enable ITP based on the user's preference. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267208 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-17 Kate Cheney Enable ITP in WKWebViews for apps with the full browser entitlement who are not linked to iOS 14.0 https://bugs.webkit.org/show_bug.cgi?id=216655 Reviewed by Brent Fulgham. Apps with the full browser entitlement who are not linked to iOS 14.0 should have ITP enabled in WKWebViews by default. No new tests, no way currently to test apps with different iOS versions. Tested manually. * Shared/Cocoa/DefaultWebBrowserChecks.mm: (WebKit::determineITPStateInternal): Ignore the early return for the linked-on-or-after check if the app has the default browser entitlement so we still enable ITP based on the user's preference. 2020-09-17 Alan Coon Cherry-pick r266802. rdar://problem/69101097 Text copied and pasted from Mac Catalyst apps appears larger than expected https://bugs.webkit.org/show_bug.cgi?id=215971 Reviewed by Tim Horton. Source/WebKit: Various pieces of platform logic in Mac Catalyst depend on the user interface idiom (i.e. Mac or iPad) of the app, as well as the application-wide "scale factor". In the context of this bug, NSAttributedString to RTF data conversion methods in `UIFoundation` consult the scale factor of `UIiOSMacIdiomManager` to determine whether to emit 0 (standard) or 1 (iOS) for the `\cocoatextscaling` attribute. The fact that the web process' scale factor may be out of sync with the UI process' scale factor leads to copied RTF data in the web process appearing either larger or smaller than expected, due to an incorrect `NSTextScalingType` value. To mitigate this (as well as any other issues), we add a mechanism for the UI process to forward the global scale factor and user interface idiom to the web process inside of the web process creation parameters, and then use new UIKit SPI to override the scale factor and idiom within the web process. * Scripts/process-entitlements.sh: Add a new entitlement needed to use `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode const): (WebKit::WebProcessCreationParameters::decode): * Shared/WebProcessCreationParameters.h: * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): Use `_UIApplicationCatalystUserInterfaceIdiom` and `_UIApplicationCatalystScaleFactor` to grab the global user interface idiom and scale factor, respectively. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Override the idiom and scale factor in the web process with the idiom and scale factor from the UI process, using the new SPI `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. As this function hasn't landed yet, we soft link the function for now to avoid causing the web process to instantly crash on any builds without the fix for . Source/WTF: Add a new flag to guard the presence of `_UIApplicationCatalystUserInterfaceIdiom`, `_UIApplicationCatalystScaleFactor`, and `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. * wtf/PlatformHave.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266802 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-09 Wenson Hsieh Text copied and pasted from Mac Catalyst apps appears larger than expected https://bugs.webkit.org/show_bug.cgi?id=215971 Reviewed by Tim Horton. Various pieces of platform logic in Mac Catalyst depend on the user interface idiom (i.e. Mac or iPad) of the app, as well as the application-wide "scale factor". In the context of this bug, NSAttributedString to RTF data conversion methods in `UIFoundation` consult the scale factor of `UIiOSMacIdiomManager` to determine whether to emit 0 (standard) or 1 (iOS) for the `\cocoatextscaling` attribute. The fact that the web process' scale factor may be out of sync with the UI process' scale factor leads to copied RTF data in the web process appearing either larger or smaller than expected, due to an incorrect `NSTextScalingType` value. To mitigate this (as well as any other issues), we add a mechanism for the UI process to forward the global scale factor and user interface idiom to the web process inside of the web process creation parameters, and then use new UIKit SPI to override the scale factor and idiom within the web process. * Scripts/process-entitlements.sh: Add a new entitlement needed to use `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode const): (WebKit::WebProcessCreationParameters::decode): * Shared/WebProcessCreationParameters.h: * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): Use `_UIApplicationCatalystUserInterfaceIdiom` and `_UIApplicationCatalystScaleFactor` to grab the global user interface idiom and scale factor, respectively. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Override the idiom and scale factor in the web process with the idiom and scale factor from the UI process, using the new SPI `_UIApplicationCatalystRequestViewServiceIdiomAndScaleFactor`. As this function hasn't landed yet, we soft link the function for now to avoid causing the web process to instantly crash on any builds without the fix for . 2020-09-17 Alan Coon Cherry-pick r266677. rdar://problem/68740521 [MotionMark] RenderLayer::paintLayerContents spends ~5% of the time in MonotonicTime::now() in Multiply https://bugs.webkit.org/show_bug.cgi?id=216190 Reviewed by Darin Adler. Source/WebCore: In several of MotionMark's subtests (for instance, Multiply), we spent a large amount of time underneath `RenderLayer::paintLayerContents` due to both the large number of layers and the need to frequently repaint each layer (all of which are constantly being animated). Underneath this method, a nontrivial amount of time (~5%) is then spent grabbing the system time via `MonotonicTime::now()`. We can avoid this extra work by instead using the timestamp of the last rendering update (before we started painting), which we keep track of using a new member variable on `Page`. See below for more details, as well as the WebKit2 ChangeLog. * page/ChromeClient.h: (WebCore::ChromeClient::timestampForPaintFrequencyTracking const): Add a client hook to fetch the timestamp to use when tracking painting frequency. See the WebKit2 ChangeLog for more details. * page/Page.cpp: (WebCore::Page::updateRendering): Update `m_lastRenderingUpdateTimestamp`. * page/Page.h: (WebCore::Page::lastRenderingUpdateTimestamp const): * rendering/PaintFrequencyTracker.h: Drive-by cleanup: narrow the `PaintFrequency` enum to `bool` width. (WebCore::PaintFrequencyTracker::begin): (WebCore::SinglePaintFrequencyTracking::SinglePaintFrequencyTracking): * rendering/RenderLayer.cpp: (WebCore::RenderLayer::paintLayerContents): Call out to the client layer to return a timestamp for tracking painting frequency. By default, this is simply the current time (`MonotonicTime::now()`), but ports (namely, WebKit2) may opt for a coarser granularity. (WebCore::RenderLayer::simulateFrequentPaint): * rendering/RenderLayer.h: Source/WebKit: * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::timestampForPaintFrequencyTracking const): In WebKit2, we can assume (with the exception of SVG pages) that we must've performed a rendering update prior to tracking painting frequencies. As such, we can use the page's rendering update timestamp instead of the real current time (`MonotonicTime::now()`). Note that in WebKit1, it is possible for any client to force a synchronous paint of the page before the page has performed a rendering update, which triggers assertions in `SinglePaintFrequencyTracking::end()`. As such, we stick with `MonotonicTime::now()` in WebKit1. * WebProcess/WebCoreSupport/WebChromeClient.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266677 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-05 Wenson Hsieh [MotionMark] RenderLayer::paintLayerContents spends ~5% of the time in MonotonicTime::now() in Multiply https://bugs.webkit.org/show_bug.cgi?id=216190 Reviewed by Darin Adler. * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::timestampForPaintFrequencyTracking const): In WebKit2, we can assume (with the exception of SVG pages) that we must've performed a rendering update prior to tracking painting frequencies. As such, we can use the page's rendering update timestamp instead of the real current time (`MonotonicTime::now()`). Note that in WebKit1, it is possible for any client to force a synchronous paint of the page before the page has performed a rendering update, which triggers assertions in `SinglePaintFrequencyTracking::end()`. As such, we stick with `MonotonicTime::now()` in WebKit1. * WebProcess/WebCoreSupport/WebChromeClient.h: 2020-09-17 Alan Coon Cherry-pick r267031. rdar://problem/69101165 Web Inspector: docking buttons don't work when already docked if window is too small https://bugs.webkit.org/show_bug.cgi?id=216488 Reviewed by Timothy Hatcher. Source/WebInspectorUI: * UserInterface/Base/Main.js: (WI.updateDockingAvailability): (WI.updateDockedState): (WI._updateDockNavigationItems): Always be sure to update the docking navigation items when docking becomes unavailable instead of just forcing Web Inspector to undock as if Web Inspector is already undocked then none of the docking navigation items will be updated. This makes it so that the docking navigation items are hidden when docking becomes unavailable while undocked. Source/WebKit: * UIProcess/Inspector/WebInspectorProxy.cpp: (WebKit::WebInspectorProxy::attach): (WebKit::WebInspectorProxy::attachAvailabilityChanged): If Web Inspector is already attached, it can re-attach with a different configuration. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267031 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-14 Devin Rousso Web Inspector: docking buttons don't work when already docked if window is too small https://bugs.webkit.org/show_bug.cgi?id=216488 Reviewed by Timothy Hatcher. * UIProcess/Inspector/WebInspectorProxy.cpp: (WebKit::WebInspectorProxy::attach): (WebKit::WebInspectorProxy::attachAvailabilityChanged): If Web Inspector is already attached, it can re-attach with a different configuration. 2020-09-17 Alan Coon Cherry-pick r266745. rdar://problem/69100985 Tighten checks when creating an audio buffer list https://bugs.webkit.org/show_bug.cgi?id=216237 Reviewed by Geoffrey Garen. Source/WebCore: Add a routine to check there is no multiplication integer overflow. * platform/audio/cocoa/WebAudioBufferList.cpp: (WebCore::computeBufferSize): (WebCore::WebAudioBufferList::isSupportedDescription): (WebCore::WebAudioBufferList::setSampleCount): * platform/audio/cocoa/WebAudioBufferList.h: Source/WebKit: Add message checks to verify that no message integer overflows happen when processing audio buffer list messages. * GPUProcess/GPUConnectionToWebProcess.cpp: (WebKit::GPUConnectionToWebProcess::audioTrackRendererManager): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: (WebKit::RemoteAudioMediaStreamTrackRenderer::RemoteAudioMediaStreamTrackRenderer): (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesStorageChanged): (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesAvailable): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererManager.cpp: (WebKit::RemoteAudioMediaStreamTrackRendererManager::RemoteAudioMediaStreamTrackRendererManager): (WebKit::RemoteAudioMediaStreamTrackRendererManager::createRenderer): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererManager.h: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged): (WebKit::RemoteMediaRecorder::audioSamplesAvailable): * GPUProcess/webrtc/RemoteMediaRecorder.h: * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: (WebKit::RemoteCaptureSampleManager::RemoteAudio::audioSamplesAvailable): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266745 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-08 Youenn Fablet Tighten checks when creating an audio buffer list https://bugs.webkit.org/show_bug.cgi?id=216237 Reviewed by Geoffrey Garen. Add message checks to verify that no message integer overflows happen when processing audio buffer list messages. * GPUProcess/GPUConnectionToWebProcess.cpp: (WebKit::GPUConnectionToWebProcess::audioTrackRendererManager): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: (WebKit::RemoteAudioMediaStreamTrackRenderer::RemoteAudioMediaStreamTrackRenderer): (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesStorageChanged): (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesAvailable): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererManager.cpp: (WebKit::RemoteAudioMediaStreamTrackRendererManager::RemoteAudioMediaStreamTrackRendererManager): (WebKit::RemoteAudioMediaStreamTrackRendererManager::createRenderer): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererManager.h: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged): (WebKit::RemoteMediaRecorder::audioSamplesAvailable): * GPUProcess/webrtc/RemoteMediaRecorder.h: * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: (WebKit::RemoteCaptureSampleManager::RemoteAudio::audioSamplesAvailable): 2020-09-17 Alan Coon Cherry-pick r266411. rdar://problem/68300959 [iOS] AGX compiler service sandbox violation https://bugs.webkit.org/show_bug.cgi?id=216042 Reviewed by Brent Fulgham. For a set of devices, mach-lookup sandbox violations have been observed for an AGX compiler service. For these devices, we currently issue an extension for one AGX compiler service, but this is not sufficient since there is a similar service name that needs to be added as well. * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode const): (WebKit::WebProcessCreationParameters::decode): * Shared/WebProcessCreationParameters.h: * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::agxCompilerServices): (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266411 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-01 Per Arne Vollan [iOS] AGX compiler service sandbox violation https://bugs.webkit.org/show_bug.cgi?id=216042 Reviewed by Brent Fulgham. For a set of devices, mach-lookup sandbox violations have been observed for an AGX compiler service. For these devices, we currently issue an extension for one AGX compiler service, but this is not sufficient since there is a similar service name that needs to be added as well. * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode const): (WebKit::WebProcessCreationParameters::decode): * Shared/WebProcessCreationParameters.h: * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::agxCompilerServices): (WebKit::WebProcessPool::platformInitializeWebProcess): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-09-15 Russell Epstein Cherry-pick r266121. rdar://problem/68949237 [macOS] Update audio arbitration manager when audio transport changes https://bugs.webkit.org/show_bug.cgi?id=215781 Reviewed by Jer Noble. Source/WebCore: No new tests, updated AudioRoutingArbitration API test. * platform/audio/AudioSession.cpp: (WebCore::AudioSession::audioOutputDeviceChanged): Add empty method. (WebCore::setIsPlayingToBluetoothOverride): Ditto. * platform/audio/AudioSession.h: * platform/audio/cocoa/MediaSessionManagerCocoa.h: * platform/audio/cocoa/MediaSessionManagerCocoa.mm: (WebCore::MediaSessionManagerCocoa::audioOutputDeviceChanged): Call AudioSession::audioOutputDeviceChanged. * platform/audio/mac/AudioSessionMac.mm: (WebCore::defaultDeviceTransportIsBluetooth): New. (WebCore::AudioSession::audioOutputDeviceChanged): Clear m_private->playingToBluetooth if bluetooth transport has changed since the last arbitration update. (WebCore::AudioSession::setIsPlayingToBluetoothOverride): Allow override of bluetooth transport for testing. (WebCore::AudioSession::setCategory): Update routing arbitration if audio session category or bluetooth transport changes. * testing/Internals.cpp: (WebCore::Internals::setIsPlayingToBluetoothOverride): * testing/Internals.h: * testing/Internals.idl: Source/WebKit: * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _audioRoutingArbitrationUpdateTime]): * UIProcess/Media/AudioSessionRoutingArbitratorProxy.h: (WebKit::AudioSessionRoutingArbitratorProxy::arbitrationUpdateTime const): * UIProcess/Media/cocoa/AudioSessionRoutingArbitratorProxyCocoa.mm: (WebKit::AudioSessionRoutingArbitratorProxy::beginRoutingArbitrationWithCategory): Tools: * TestWebKitAPI/Tests/WebKitCocoa/AudioRoutingArbitration.mm: (AudioRoutingArbitration::statusShouldBecomeEqualTo): Add message string to help debugging when the test fails. * TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266121 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-25 Eric Carlson [macOS] Update audio arbitration manager when audio transport changes https://bugs.webkit.org/show_bug.cgi?id=215781 Reviewed by Jer Noble. * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _audioRoutingArbitrationUpdateTime]): * UIProcess/Media/AudioSessionRoutingArbitratorProxy.h: (WebKit::AudioSessionRoutingArbitratorProxy::arbitrationUpdateTime const): * UIProcess/Media/cocoa/AudioSessionRoutingArbitratorProxyCocoa.mm: (WebKit::AudioSessionRoutingArbitratorProxy::beginRoutingArbitrationWithCategory): 2020-09-14 Alan Coon Cherry-pick r266932. rdar://problem/68881008 Fix undeclared identifier issue due to clashes in soft link headers https://bugs.webkit.org/show_bug.cgi?id=216412 Reviewed by Geoffrey Garen. Source/WebCore/PAL: r266898 broke builds on certain SDKs. The reason for this is that it includes MediaToolbox/FigPhoto.h, which transitively includes CoreMedia/CMTimePrivate.h. The latter header has a bunch of inline code in certain SDKs which conflicts with the CoreMediaSoftLink.h header. For instance, CoreMediaSoftLink.h redefines CMTimeCompare to softLink_CoreMedia_CMTimeCompare, which messes up the inline code in the CMTimePrivate.h header that references CMTimeCompare. For now, we just avoid including FigPhoto.h altogether and use a constant. We'll clean this up once we start weak linking rather than soft linking CoreMedia and MediaToolbox (216388). * pal/cocoa/MediaToolboxSoftLink.cpp: * pal/cocoa/MediaToolboxSoftLink.h: * pal/spi/cocoa/MediaToolboxSPI.h: Source/WebKit: Use the workaround constant kPALFigPhotoContainerFormat_JFIF instead of the enum value kFigPhotoContainerFormat_JFIF. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266932 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-11 Ben Nham Fix undeclared identifier issue due to clashes in soft link headers https://bugs.webkit.org/show_bug.cgi?id=216412 Reviewed by Geoffrey Garen. Use the workaround constant kPALFigPhotoContainerFormat_JFIF instead of the enum value kFigPhotoContainerFormat_JFIF. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-09-14 Alan Coon Cherry-pick r266898. rdar://problem/68881029 Disable hardware JPEG decoding on x86 Mac https://bugs.webkit.org/show_bug.cgi?id=216377 Reviewed by Geoff Garen. Source/WebCore/PAL: Add wrappers for a new MediaToolbox SPI that allows us to disable HW JPEG decoding. * PAL.xcodeproj/project.pbxproj: * pal/PlatformMac.cmake: * pal/cocoa/MediaToolboxSoftLink.cpp: * pal/cocoa/MediaToolboxSoftLink.h: Source/WebKit: In Big Sur, ImageIO uses hardware JPEG decoding automatically for certain JPEGs. This caused a small regression in our battery life benchmark since the one-time setup cost for the decoder (~20-30 ms per process) was higher than the per-decode win we got from the HW decoder. For now, we're reverting to the Catalina behavior of not using hardware JPEG on x86 Macs by calling a MediaToolbox SPI. (The tradeoffs for Apple Silicon are different so we use ImageIO's default heuristics on that architecture.) We plan to revisit this decision once we move to a GPUProcess world. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Source/WTF: Add macros to disable HW JPEG decoding on x86 Macs and indicate the presence of a new MediaToolbox SPI. (The latter is to prevent unnecessary dlopen/dlsym calls since we soft-link MediaToolbox.) * wtf/PlatformEnableCocoa.h: * wtf/PlatformHave.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266898 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-10 Ben Nham Disable hardware JPEG decoding on x86 Mac https://bugs.webkit.org/show_bug.cgi?id=216377 Reviewed by Geoff Garen. In Big Sur, ImageIO uses hardware JPEG decoding automatically for certain JPEGs. This caused a small regression in our battery life benchmark since the one-time setup cost for the decoder (~20-30 ms per process) was higher than the per-decode win we got from the HW decoder. For now, we're reverting to the Catalina behavior of not using hardware JPEG on x86 Macs by calling a MediaToolbox SPI. (The tradeoffs for Apple Silicon are different so we use ImageIO's default heuristics on that architecture.) We plan to revisit this decision once we move to a GPUProcess world. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-09-14 Alan Coon Cherry-pick r266797. rdar://problem/68881018 Move lazy DisplayLink tear down logic from the WebProcess to the UIProcess https://bugs.webkit.org/show_bug.cgi?id=216195 Reviewed by Simon Fraser. Move lazy DisplayLink tear down logic from the WebProcess to the UIProcess, now that the DisplayLink has been moved to the UIProcess due to sandboxing. After a DisplayLink no longer has any clients, we keep it firing up to 20 times without any clients in case a new client gets added shortly after. The idea was to avoid killing and respawning too many threads when adding and removing clients in quick succession. However, now that the DisplayLink lives in the UIProcess side and sends IPC to the WebProcesses every time it fires, it makes a lot more sense to implement this logic in the UIProcess side, to avoid sending unnecessary IPC to processes that do not care about it. Source/WebCore: * platform/graphics/DisplayRefreshMonitor.cpp: (WebCore::DisplayRefreshMonitor::displayDidRefresh): * platform/graphics/DisplayRefreshMonitor.h: (WebCore::DisplayRefreshMonitor::shouldBeTerminated const): Source/WebKit: * UIProcess/mac/DisplayLink.cpp: (WebKit::DisplayLink::addObserver): (WebKit::DisplayLink::removeObserver): (WebKit::DisplayLink::removeObservers): (WebKit::DisplayLink::displayLinkCallback): (WebKit::DisplayLink::hasObservers const): Deleted. * UIProcess/mac/DisplayLink.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266797 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-09 Chris Dumez Move lazy DisplayLink tear down logic from the WebProcess to the UIProcess https://bugs.webkit.org/show_bug.cgi?id=216195 Reviewed by Simon Fraser. Move lazy DisplayLink tear down logic from the WebProcess to the UIProcess, now that the DisplayLink has been moved to the UIProcess due to sandboxing. After a DisplayLink no longer has any clients, we keep it firing up to 20 times without any clients in case a new client gets added shortly after. The idea was to avoid killing and respawning too many threads when adding and removing clients in quick succession. However, now that the DisplayLink lives in the UIProcess side and sends IPC to the WebProcesses every time it fires, it makes a lot more sense to implement this logic in the UIProcess side, to avoid sending unnecessary IPC to processes that do not care about it. * UIProcess/mac/DisplayLink.cpp: (WebKit::DisplayLink::addObserver): (WebKit::DisplayLink::removeObserver): (WebKit::DisplayLink::removeObservers): (WebKit::DisplayLink::displayLinkCallback): (WebKit::DisplayLink::hasObservers const): Deleted. * UIProcess/mac/DisplayLink.h: 2020-09-11 Russell Epstein Cherry-pick r266771. rdar://problem/68666453 Regression(r260614) Power usage has increased due to extra thread hopping https://bugs.webkit.org/show_bug.cgi?id=216296 Reviewed by Simon Fraser. Power usage has increased after r260614 due to extra thread hopping. To recover, we now process the DisplayWasRefreshed IPC to a background queue if there is scrolling going on and responsiveness is thus critical. In the common case, where the user is not scrolling, we keep processing the IPC on the main thread, like before r260614. This avoids extra thread hopping and saves power. * UIProcess/WebPageProxy.cpp: (WebKit::ScrollingObserver::willSendWheelEvent): (WebKit::ScrollingObserver::ScrollingObserver): (WebKit::ScrollingObserver::singleton): (WebKit::WebPageProxy::sendWheelEvent): * UIProcess/mac/DisplayLink.cpp: (WebKit::DisplayLink::displayLinkCallback): * UIProcess/mac/DisplayLink.h: (WebKit::DisplayLink::setShouldSendIPCOnBackgroundQueue): * WebProcess/WebPage/EventDispatcher.cpp: (WebKit::EventDispatcher::notifyScrollingTreesDisplayWasRefreshed): (WebKit::EventDispatcher::displayWasRefreshed): * WebProcess/WebPage/EventDispatcher.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::displayWasRefreshed): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266771 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-08 Chris Dumez Regression(r260614) Power usage has increased due to extra thread hopping https://bugs.webkit.org/show_bug.cgi?id=216296 Reviewed by Simon Fraser. Power usage has increased after r260614 due to extra thread hopping. To recover, we now process the DisplayWasRefreshed IPC to a background queue if there is scrolling going on and responsiveness is thus critical. In the common case, where the user is not scrolling, we keep processing the IPC on the main thread, like before r260614. This avoids extra thread hopping and saves power. * UIProcess/WebPageProxy.cpp: (WebKit::ScrollingObserver::willSendWheelEvent): (WebKit::ScrollingObserver::ScrollingObserver): (WebKit::ScrollingObserver::singleton): (WebKit::WebPageProxy::sendWheelEvent): * UIProcess/mac/DisplayLink.cpp: (WebKit::DisplayLink::displayLinkCallback): * UIProcess/mac/DisplayLink.h: (WebKit::DisplayLink::setShouldSendIPCOnBackgroundQueue): * WebProcess/WebPage/EventDispatcher.cpp: (WebKit::EventDispatcher::notifyScrollingTreesDisplayWasRefreshed): (WebKit::EventDispatcher::displayWasRefreshed): * WebProcess/WebPage/EventDispatcher.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::displayWasRefreshed): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: 2020-09-11 Russell Epstein Cherry-pick r266743. rdar://problem/68652752 iOS: 's QuickLook thumbnails can appear squished https://bugs.webkit.org/show_bug.cgi?id=216209 Reviewed by Wenson Hsieh. Source/WebCore: Test: fast/attachment/attachment-thumbnail-preserves-aspect-ratio.html * html/HTMLAttachmentElement.idl: * testing/Internals.cpp: (WebCore::Internals::attachmentThumbnailInfo): * testing/Internals.h: * testing/Internals.idl: Expose the attachment thumbnail size via Internals. * rendering/RenderThemeIOS.mm: (WebCore::RenderAttachmentInfo::RenderAttachmentInfo): Allow the thumbnail aspect ratio to vary, instead of assuming it is always square. Source/WebKit: * UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::convertPlatformImageToBitmap): Propagate an image of the same aspect ratio that QuickLook provided, instead of squishing it to square. * UIProcess/QuickLookThumbnailLoader.mm: (-[WKQLThumbnailLoadOperation start]): Only request full thumbnails; we do not want the icon form, since already has one without QuickLook's help; if we can't get a full thumbnail, we'll just leave it alone. Tools: * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.h: (WTR::UIScriptController::insertAttachmentForFilePath): * WebKitTestRunner/TestController.cpp: (WTR::TestController::currentTestURL const): * WebKitTestRunner/TestController.h: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm: (WTR::UIScriptControllerCocoa::insertAttachmentForFilePath): Make it possible to insert an attachment wrapping a file on disk via UIScriptController. LayoutTests: * fast/attachment/attachment-thumbnail-preserves-aspect-ratio-expected.txt: Added. * fast/attachment/attachment-thumbnail-preserves-aspect-ratio.html: Added. * fast/attachment/resources/400x200-circle.png: Added. * platform/ios/fast/attachment/attachment-thumbnail-preserves-aspect-ratio-expected.txt: Added. * resources/ui-helper.js: (window.UIHelper.insertAttachmentForFilePath): Add a test that dumps the thumbnail size for a 400x200 attachment. We only run it on iOS, because on macOS, QuickLook always returns an image of the size we ask for (400x400), padded with whitespace, so the problem does not reproduce and the test doesn't work right there. On iOS, the result used to be 400x400 and now is 400x200. I tried and failed to make a more useful test (a ref test, actually testing the presentation) because it's quite hard to match the native painting. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266743 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-08 Tim Horton iOS: 's QuickLook thumbnails can appear squished https://bugs.webkit.org/show_bug.cgi?id=216209 Reviewed by Wenson Hsieh. * UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::convertPlatformImageToBitmap): Propagate an image of the same aspect ratio that QuickLook provided, instead of squishing it to square. * UIProcess/QuickLookThumbnailLoader.mm: (-[WKQLThumbnailLoadOperation start]): Only request full thumbnails; we do not want the icon form, since already has one without QuickLook's help; if we can't get a full thumbnail, we'll just leave it alone. 2020-09-10 Alan Coon Cherry-pick r266750. rdar://problem/68652608 Null check m_layerHostingContext in TiledCoreAnimationDrawingArea::sendDidFirstLayerFlushIfNeeded https://bugs.webkit.org/show_bug.cgi?id=216282 Patch by Alex Christensen on 2020-09-08 Reviewed by Tim Horton. There's no reason to dereference null here. Let's not crash. * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: (WebKit::TiledCoreAnimationDrawingArea::sendDidFirstLayerFlushIfNeeded): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266750 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-08 Alex Christensen Null check m_layerHostingContext in TiledCoreAnimationDrawingArea::sendDidFirstLayerFlushIfNeeded https://bugs.webkit.org/show_bug.cgi?id=216282 Reviewed by Tim Horton. There's no reason to dereference null here. Let's not crash. * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: (WebKit::TiledCoreAnimationDrawingArea::sendDidFirstLayerFlushIfNeeded): 2020-09-10 Alan Coon Cherry-pick r266613. rdar://problem/68652692 [macOS] Add client decoder entitlement https://bugs.webkit.org/show_bug.cgi?id=216175 Reviewed by Brent Fulgham. Add client decoder entitlement in the WebContent process on macOS. * Scripts/process-entitlements.sh: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266613 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-04 Per Arne Vollan [macOS] Add client decoder entitlement https://bugs.webkit.org/show_bug.cgi?id=216175 Reviewed by Brent Fulgham. Add client decoder entitlement in the WebContent process on macOS. * Scripts/process-entitlements.sh: 2020-09-10 Alan Coon Cherry-pick r266606. rdar://problem/68652779 WebProcessProxy::checkURLReceivedFromWebProcess() does not always need to check the back/forward list https://bugs.webkit.org/show_bug.cgi?id=216109 Reviewed by Brady Eidson. We should not need to check the back/forward list when setting a pasteboard URL because any valid pasteboard URL will be handled by one of the other if-statements in WebProcessProxy::checkURLReceivedFromWebProcess(), therefore checking again is a waste of time. This also hardens the process against potential abuse by preventing the possibility of an invalid URL in the back/forward list being saved in the pasteboard property list. * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::setPasteboardURL): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::checkURLReceivedFromWebProcess): * UIProcess/WebProcessProxy.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266606 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-04 Kate Cheney WebProcessProxy::checkURLReceivedFromWebProcess() does not always need to check the back/forward list https://bugs.webkit.org/show_bug.cgi?id=216109 Reviewed by Brady Eidson. We should not need to check the back/forward list when setting a pasteboard URL because any valid pasteboard URL will be handled by one of the other if-statements in WebProcessProxy::checkURLReceivedFromWebProcess(), therefore checking again is a waste of time. This also hardens the process against potential abuse by preventing the possibility of an invalid URL in the back/forward list being saved in the pasteboard property list. * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::setPasteboardURL): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::checkURLReceivedFromWebProcess): * UIProcess/WebProcessProxy.h: 2020-09-10 Alan Coon Cherry-pick r266493. rdar://problem/68652496 Remove custom domain from SameSite=strict jail protection https://bugs.webkit.org/show_bug.cgi?id=216083 Reviewed by Alex Christensen. No new tests. This was a site-specific opt-in rule. The feature itself has tests. * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: (WebKit::ResourceLoadStatisticsStore::shouldEnforceSameSiteStrictForSpecificDomain const): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266493 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-02 John Wilander Remove custom domain from SameSite=strict jail protection https://bugs.webkit.org/show_bug.cgi?id=216083 Reviewed by Alex Christensen. No new tests. This was a site-specific opt-in rule. The feature itself has tests. * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: (WebKit::ResourceLoadStatisticsStore::shouldEnforceSameSiteStrictForSpecificDomain const): 2020-09-10 Alan Coon Cherry-pick r266485. rdar://problem/68652729 iPad + Trackpad: JW Library highlighting and edit menus don't appear https://bugs.webkit.org/show_bug.cgi?id=216086 Reviewed by Wenson Hsieh. Source/WebCore: * platform/RuntimeApplicationChecks.h: * platform/cocoa/RuntimeApplicationChecksCocoa.mm: (WebCore::IOSApplication::isJWLibrary): Source/WebKit: * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): Add JW Library to the list. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266485 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-02 Timothy Horton iPad + Trackpad: JW Library highlighting and edit menus don't appear https://bugs.webkit.org/show_bug.cgi?id=216086 Reviewed by Wenson Hsieh. * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): Add JW Library to the list. 2020-09-10 Alan Coon Cherry-pick r266407. rdar://problem/68652645 Some apps linked beyond iOS 13.4 don't respect mouse events, only touch events https://bugs.webkit.org/show_bug.cgi?id=216021 Reviewed by Wenson Hsieh. Source/WebCore: * platform/RuntimeApplicationChecks.h: * platform/cocoa/RuntimeApplicationChecksCocoa.mm: (WebCore::IOSApplication::isFIFACompanion): (WebCore::IOSApplication::isNoggin): (WebCore::IOSApplication::isOKCupid): Add some more bundle checks. Source/WebKit: * UIProcess/Cocoa/VersionChecks.h: * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): (-[WKContentView shouldUseMouseGestureRecognizer]): Remove Feedly from the list, they are no longer affected. Add a once-per-app-launch error-level log message to warn developers of the impending behavior change. Add three new apps with a later linked-on target. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266407 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-01 Tim Horton Some apps linked beyond iOS 13.4 don't respect mouse events, only touch events https://bugs.webkit.org/show_bug.cgi?id=216021 Reviewed by Wenson Hsieh. * UIProcess/Cocoa/VersionChecks.h: * UIProcess/ios/WKContentViewInteraction.mm: (applicationIsKnownToIgnoreMouseEvents): (-[WKContentView shouldUseMouseGestureRecognizer]): Remove Feedly from the list, they are no longer affected. Add a once-per-app-launch error-level log message to warn developers of the impending behavior change. Add three new apps with a later linked-on target. 2020-09-10 Alan Coon Cherry-pick r266314. rdar://problem/68652747 Sites built with flambe.js don't work with trackpad on iPad https://bugs.webkit.org/show_bug.cgi?id=215954 Reviewed by Wenson Hsieh. Source/WebKit: New API Test: iOSMouseSupport.MouseTimestampTimebase * UIProcess/ios/WKMouseGestureRecognizer.mm: (-[WKMouseGestureRecognizer createMouseEventWithType:]): Use the timestamp property on UITouch instead of GSCurrentEventTimestamp(). This property is in the same units as mach_absolute_time/MonotonicTime. Previously, treating a monotonic time as wall time resulted in it getting clamped to 0, breaking sites that depend on it. Tools: * TestWebKitAPI/Tests/WebKitCocoa/iOSMouseSupport.mm: (-[WKTestingHoverEvent locationInView:]): (-[WKTestingTouch timestamp]): (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266314 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-28 Tim Horton Sites built with flambe.js don't work with trackpad on iPad https://bugs.webkit.org/show_bug.cgi?id=215954 Reviewed by Wenson Hsieh. New API Test: iOSMouseSupport.MouseTimestampTimebase * UIProcess/ios/WKMouseGestureRecognizer.mm: (-[WKMouseGestureRecognizer createMouseEventWithType:]): Use the timestamp property on UITouch instead of GSCurrentEventTimestamp(). This property is in the same units as mach_absolute_time/MonotonicTime. Previously, treating a monotonic time as wall time resulted in it getting clamped to 0, breaking sites that depend on it. 2020-09-09 Alan Coon Cherry-pick r266756. rdar://problem/68584247 Crashtracer inside PDFPlugin::createScrollbar. and https://bugs.webkit.org/show_bug.cgi?id=216286 Reviewed by Tim Horton. To quote Tim from r264945: No new tests; timing is such that I can't reproduce without inserting intentional delays into the main thread hops, which is further than I'm willing to go for a test. This is a speculative fix due to the aforementioned reproducibility issue. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::createScrollbar): Plugin hasn't been destroyed, and there's still a PluginView, but the PluginView isn't in a frame. So null check that. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266756 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-09-08 Brady Eidson Crashtracer inside PDFPlugin::createScrollbar. and https://bugs.webkit.org/show_bug.cgi?id=216286 Reviewed by Tim Horton. To quote Tim from r264945: No new tests; timing is such that I can't reproduce without inserting intentional delays into the main thread hops, which is further than I'm willing to go for a test. This is a speculative fix due to the aforementioned reproducibility issue. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::createScrollbar): Plugin hasn't been destroyed, and there's still a PluginView, but the PluginView isn't in a frame. So null check that. 2020-09-03 Alan Coon Cherry-pick r266265. rdar://problem/68168939 [iOS] provide a way to get previously inserted alternatives for the selected text https://bugs.webkit.org/show_bug.cgi?id=215816 Reviewed by Darin Adler. Source/WebCore: * editing/cocoa/AlternativeTextUIController.h: * editing/cocoa/AlternativeTextUIController.mm: (WebCore::AlternativeTextUIController::alternativesForContext): Return the raw `NSTextAlternatives *` and let the caller create the `Vector` if they need to so that callers that don't can use the actual `NSTextAlternatives *`. * editing/Editor.h: * editing/Editor.cpp: (WebCore::Editor::applyDictationAlternative): Added. (WebCore::Editor::applyDictationAlternativelternative): Deleted. * page/ContextMenuController.cpp: (WebCore::ContextMenuController::contextMenuItemSelected): Drive-by: fix typo. Source/WebKit: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView alternativesForSelectedText]): * UIProcess/WebPageProxy.h: * UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::platformDictationAlternatives): Added. * UIProcess/PageClient.h: * UIProcess/Cocoa/PageClientImplCocoa.h: * UIProcess/Cocoa/PageClientImplCocoa.mm: (WebKit::PageClientImplCocoa::dictationAlternatives): (WebKit::PageClientImplCocoa::platformDictationAlternatives): Added. Provide a way to get the raw `NSTextAlternatives *` for a given `WebCore::DictationContext`. * Shared/EditorState.h: * Shared/EditorState.cpp: (WebKit::EditorState::PostLayoutData::encode const): (WebKit::EditorState::PostLayoutData::decode): * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getPlatformEditorState const): Include a `Vector` as part of the `EditorState` that contains all of the `WebCore::DictationContext` that exist in the currently selected range (or the range of the word containing the cursor if nothing is selected). * Platform/spi/ios/UIKitSPI.h: Source/WebKitLegacy/mac: * WebView/WebView.mm: (-[WebView _dictationAlternatives:]): Create a `Vector` from the returned `NSTextAlternatives *` now that the member `WebCore::AlternativeTextUIController::alternativesForContext` returns it. Tools: * TestWebKitAPI/Tests/WebKitCocoa/InsertTextAlternatives.mm: (InsertTextAlternatives.Simple): * TestWebKitAPI/ios/UIKitSPI.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266265 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-27 Devin Rousso [iOS] provide a way to get previously inserted alternatives for the selected text https://bugs.webkit.org/show_bug.cgi?id=215816 Reviewed by Darin Adler. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView alternativesForSelectedText]): * UIProcess/WebPageProxy.h: * UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::platformDictationAlternatives): Added. * UIProcess/PageClient.h: * UIProcess/Cocoa/PageClientImplCocoa.h: * UIProcess/Cocoa/PageClientImplCocoa.mm: (WebKit::PageClientImplCocoa::dictationAlternatives): (WebKit::PageClientImplCocoa::platformDictationAlternatives): Added. Provide a way to get the raw `NSTextAlternatives *` for a given `WebCore::DictationContext`. * Shared/EditorState.h: * Shared/EditorState.cpp: (WebKit::EditorState::PostLayoutData::encode const): (WebKit::EditorState::PostLayoutData::decode): * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getPlatformEditorState const): Include a `Vector` as part of the `EditorState` that contains all of the `WebCore::DictationContext` that exist in the currently selected range (or the range of the word containing the cursor if nothing is selected). * Platform/spi/ios/UIKitSPI.h: 2020-09-03 Alan Coon Cherry-pick r266158. rdar://problem/67812825 Web Share API Level 2 functions even when its experimental feature flag is disabled https://bugs.webkit.org/show_bug.cgi?id=215831 Reviewed by Darin Adler. Source/WebCore: Tests: fast/web-share/canShare-with-files-feature-disabled.html fast/web-share/share-with-files-feature-disabled.html We had a feature flag for Web Share API Level 2, but it isn't actually consulted anywhere in the implementation. * page/Navigator.cpp: (WebCore::Navigator::canShare): Rewrite canShare to be a bit more readable, and also to consult the Level 2 feature flag. (WebCore::Navigator::share): Since canShare (per the spec) will return true if we have files and other content, even if files are not shareable, check the feature flag again before loading the files. Source/WebKit: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::showShareSheet): If the Web Content process sends us files, but the Level 2 feature flag is disabled, something fishy is happening, so fire a MESSAGE_CHECK. LayoutTests: * fast/web-share/canShare-with-files-feature-disabled-expected.txt: Added. * fast/web-share/canShare-with-files-feature-disabled.html: Added. * fast/web-share/share-with-files-feature-disabled-expected.txt: Added. * fast/web-share/share-with-files-feature-disabled.html: Added. Add some tests that ensure that disabling the feature actually works. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266158 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-25 Tim Horton Web Share API Level 2 functions even when its experimental feature flag is disabled https://bugs.webkit.org/show_bug.cgi?id=215831 Reviewed by Darin Adler. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::showShareSheet): If the Web Content process sends us files, but the Level 2 feature flag is disabled, something fishy is happening, so fire a MESSAGE_CHECK. 2020-09-03 Alan Coon Cherry-pick r266151. rdar://problem/67812825 Web Share API can share non-HTTP(S) URLs https://bugs.webkit.org/show_bug.cgi?id=215823 Reviewed by Wenson Hsieh. Source/WebCore: Test: fast/web-share/share-disallows-file-urls.html * page/Navigator.cpp: (WebCore::shareableURLForShareData): (WebCore::Navigator::canShare): (WebCore::Navigator::share): Factor out the code to complete and check the scheme of the URL. Make canShare() return NO and share() fail for non-HTTP(S) or data: URLs. Source/WebKit: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::showShareSheet): Ensure that only HTTP family or data: URLs are shared. LayoutTests: * fast/web-share/share-disallows-file-urls-expected.txt: Added. * fast/web-share/share-disallows-file-urls.html: Added. * fast/web-share/share-transient-activation-expired.html: * fast/web-share/share-transient-activation.html: * fast/web-share/share.html: Add a test that ensures that sharing a non-HTTP-family URL fails, and fix the existing tests to share HTTP-family URLs. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266151 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-25 Tim Horton Web Share API can share non-HTTP(S) URLs https://bugs.webkit.org/show_bug.cgi?id=215823 Reviewed by Wenson Hsieh. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::showShareSheet): Ensure that only HTTP family or data: URLs are shared. 2020-09-03 Alan Coon Cherry-pick r266240. rdar://problem/67963550 REGRESSION(r264710): Initializing the AVPlayer Obj-C class at process start up causes a regression in power-use tests https://bugs.webkit.org/show_bug.cgi?id=215861 Reviewed by Eric Carlson. Calling +instancesRespondToSelector: will cause the underyling Obj-C class to be initialized, which in the case of AVPlayer does a bunch of work which shows up on power-use tests. Because the API being checked for will always exist in macOS 11, and that code is already protected by a HAVE(AVPLAYER_VIDEORANGEOVERRIDE) pragma, just return early here without running the +instancesRespondToSelector: check. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::updatePageScreenProperties): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266240 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-27 Jer Noble REGRESSION(r264710): Initializing the AVPlayer Obj-C class at process start up causes a regression in power-use tests https://bugs.webkit.org/show_bug.cgi?id=215861 Reviewed by Eric Carlson. Calling +instancesRespondToSelector: will cause the underyling Obj-C class to be initialized, which in the case of AVPlayer does a bunch of work which shows up on power-use tests. Because the API being checked for will always exist in macOS 11, and that code is already protected by a HAVE(AVPLAYER_VIDEORANGEOVERRIDE) pragma, just return early here without running the +instancesRespondToSelector: check. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::updatePageScreenProperties): 2020-09-01 Alan Coon Cherry-pick r266301. rdar://problem/68177648 [macOS] Fix iokit-get-properties sandbox violations https://bugs.webkit.org/show_bug.cgi?id=215925 Reviewed by Brent Fulgham. Add iokit-property to WebContent sandbox that should have been a part of r266282. * WebProcess/com.apple.WebProcess.sb.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266301 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-28 Per Arne Vollan [macOS] Fix iokit-get-properties sandbox violations https://bugs.webkit.org/show_bug.cgi?id=215925 Reviewed by Brent Fulgham. Add iokit-property to WebContent sandbox that should have been a part of r266282. * WebProcess/com.apple.WebProcess.sb.in: 2020-09-01 Alan Coon Cherry-pick r266282. rdar://problem/68177648 [macOS] Fix iokit-get-properties sandbox violations https://bugs.webkit.org/show_bug.cgi?id=215925 Reviewed by Darin Adler. A few iokit properties needs to be added to the WebContent process' sandbox after observing these being in use. * WebProcess/com.apple.WebProcess.sb.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266282 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-28 Per Arne Vollan [macOS] Fix iokit-get-properties sandbox violations https://bugs.webkit.org/show_bug.cgi?id=215925 Reviewed by Darin Adler. A few iokit properties needs to be added to the WebContent process' sandbox after observing these being in use. * WebProcess/com.apple.WebProcess.sb.in: 2020-09-01 Alan Coon Cherry-pick r266099. rdar://problem/68176073 CrashTracer: com.apple.WebKit.WebContent at com.apple.WebKit: WebKit::PDFPlugin::createScrollbar and https://bugs.webkit.org/show_bug.cgi?id=215787 Reviewed by Tim Horton. To quote Tim from r264945: No new tests; timing is such that I can't reproduce without inserting intentional delays into the main thread hops, which is further than I'm willing to go for a test. This is a speculative fix due to the aforementioned reproducibility issue. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel): Check on the main thread whenever this is called, instead of when deciding to dispatch to the main thread. (WebKit::PDFPlugin::threadEntry): We can't do this check on the background thread when considering the dispatch to the main thread, as the flag might've changed by then. Let's *just* check it on the main thread. (WebKit::PDFPlugin::adoptBackgroundThreadDocument): We can't do the check on the background thread when (WebKit::PDFPlugin::updateScrollbars): This is where the crash itself is. All of the Obj-C code in here is safe to do after destroy(), up until the very end when we get into pluginView() derefencing. So it seems prudent to add another check here. (WebKit::PDFPlugin::documentDataDidFinishLoading): In addition to receivedNonLinearizedPDFSentinel and adoptBackgroundThreadDocument, this is the final of the (3) calls that end up calling installPDFDocument, so for added coverage it seems like a prudent place to add the check. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266099 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-24 Brady Eidson CrashTracer: com.apple.WebKit.WebContent at com.apple.WebKit: WebKit::PDFPlugin::createScrollbar and https://bugs.webkit.org/show_bug.cgi?id=215787 Reviewed by Tim Horton. To quote Tim from r264945: No new tests; timing is such that I can't reproduce without inserting intentional delays into the main thread hops, which is further than I'm willing to go for a test. This is a speculative fix due to the aforementioned reproducibility issue. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel): Check on the main thread whenever this is called, instead of when deciding to dispatch to the main thread. (WebKit::PDFPlugin::threadEntry): We can't do this check on the background thread when considering the dispatch to the main thread, as the flag might've changed by then. Let's *just* check it on the main thread. (WebKit::PDFPlugin::adoptBackgroundThreadDocument): We can't do the check on the background thread when (WebKit::PDFPlugin::updateScrollbars): This is where the crash itself is. All of the Obj-C code in here is safe to do after destroy(), up until the very end when we get into pluginView() derefencing. So it seems prudent to add another check here. (WebKit::PDFPlugin::documentDataDidFinishLoading): In addition to receivedNonLinearizedPDFSentinel and adoptBackgroundThreadDocument, this is the final of the (3) calls that end up calling installPDFDocument, so for added coverage it seems like a prudent place to add the check. 2020-09-01 Alan Coon Cherry-pick r266214. rdar://problem/68164557 Resource Load Statistics data summary does not report data which is held up in the web content process. https://bugs.webkit.org/show_bug.cgi?id=215822 Reviewed by Chris Dumez. Source/WebCore: Send empty lambda when calling updateCentralStatisticsStore() because in these cases we don't care about timing. * loader/ResourceLoadObserver.h: (WebCore::ResourceLoadObserver::updateCentralStatisticsStore): * page/DOMWindow.cpp: (WebCore::DOMWindow::close): * testing/Internals.cpp: (WebCore::Internals::notifyResourceLoadObserver): Source/WebKit: No new tests, this fixes a timing bug that is flaky to reproduce, so I was unable to write a test case. Non-regressed behavior is confirmed with existing API testing. * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated): Most of the time, the completion handler will be an empty function, but we should handle it in the network process so we fix the case where we wait to send the full data summary until the update has finished. (WebKit::WebResourceLoadStatisticsStore::aggregatedThirdPartyData): Delete extra space. * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated): * NetworkProcess/NetworkConnectionToWebProcess.h: * NetworkProcess/NetworkConnectionToWebProcess.messages.in: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::sendResourceLoadStatisticsDataImmediately): * UIProcess/WebProcessPool.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::getResourceLoadStatisticsDataSummary): Don't ask the network process for data until any lingering data in the web content process has been sent first. * WebProcess/InjectedBundle/API/c/WKBundle.cpp: (WKBundleResourceLoadStatisticsNotifyObserver): * WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp: (WebKit::WebResourceLoadObserver::WebResourceLoadObserver): (WebKit::WebResourceLoadObserver::~WebResourceLoadObserver): (WebKit::WebResourceLoadObserver::updateCentralStatisticsStore): * WebProcess/WebCoreSupport/WebResourceLoadObserver.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::flushResourceLoadStatistics): (WebKit::WebProcess::sendResourceLoadStatisticsDataImmediately): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266214 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-26 Kate Cheney Resource Load Statistics data summary does not report data which is held up in the web content process. https://bugs.webkit.org/show_bug.cgi?id=215822 Reviewed by Chris Dumez. No new tests, this fixes a timing bug that is flaky to reproduce, so I was unable to write a test case. Non-regressed behavior is confirmed with existing API testing. * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated): Most of the time, the completion handler will be an empty function, but we should handle it in the network process so we fix the case where we wait to send the full data summary until the update has finished. (WebKit::WebResourceLoadStatisticsStore::aggregatedThirdPartyData): Delete extra space. * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated): * NetworkProcess/NetworkConnectionToWebProcess.h: * NetworkProcess/NetworkConnectionToWebProcess.messages.in: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::sendResourceLoadStatisticsDataImmediately): * UIProcess/WebProcessPool.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::getResourceLoadStatisticsDataSummary): Don't ask the network process for data until any lingering data in the web content process has been sent first. * WebProcess/InjectedBundle/API/c/WKBundle.cpp: (WKBundleResourceLoadStatisticsNotifyObserver): * WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp: (WebKit::WebResourceLoadObserver::WebResourceLoadObserver): (WebKit::WebResourceLoadObserver::~WebResourceLoadObserver): (WebKit::WebResourceLoadObserver::updateCentralStatisticsStore): * WebProcess/WebCoreSupport/WebResourceLoadObserver.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::flushResourceLoadStatistics): (WebKit::WebProcess::sendResourceLoadStatisticsDataImmediately): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: 2020-09-01 Alan Coon Cherry-pick r266143. rdar://problem/68164547 Trying to lookup when WebView is in a popover causes process to hang. Fix for Legacy WebView. https://bugs.webkit.org/show_bug.cgi?id=215792 Reviewed by Tim Horton. Source/WebKit: Update code based on Darin's suggestion for mirror fix in legacy webkit. * UIProcess/mac/WebContextMenuProxyMac.mm: (WebKit::WebContextMenuProxyMac::getContextMenuFromItems): Source/WebKitLegacy/mac: Fix for https://bugs.webkit.org/show_bug.cgi?id=214773 also needed in legacy WebView. The Lookup framework does not populate the menus that it vends with the option to 'lookup' words that are selected in popovers. WebKit should follow the pattern and not put the item in the menu as Lookup is not able to handle this situation. Also if Lookup is disabled via defaults, we should not show it in the menu. * WebView/WebHTMLView.mm: (customMenuFromDefaultItems): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266143 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-25 Megan Gardner Trying to lookup when WebView is in a popover causes process to hang. Fix for Legacy WebView. https://bugs.webkit.org/show_bug.cgi?id=215792 Reviewed by Tim Horton. Update code based on Darin's suggestion for mirror fix in legacy webkit. * UIProcess/mac/WebContextMenuProxyMac.mm: (WebKit::WebContextMenuProxyMac::getContextMenuFromItems): 2020-09-01 Alan Coon Cherry-pick r266134. rdar://problem/68164543 [Mac] REGRESSION(r262322): Focusable elements are focused when exiting from video fullscreen mode. https://bugs.webkit.org/show_bug.cgi?id=215660 Reviewed by Darin Adler. Source/WebKit: API Test: Fullscreen.Focus. The default behavior of NSWindow is to change its -keyViewSelectionDirection to NSSelectingNext when activating and changing the firstResponder. This causes WKWebView to change it's focus in response to becoming first responder. The cheap fix is to ensure WKWebView is already the firstResponder when the window is activated. Then NSWindow won't try to change the firstResponder in response to activation. * UIProcess/mac/WKFullScreenWindowController.mm: (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]): Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/mac/FullscreenFocus.mm: Added. (-[FullscreenFocusUIDelegate _webViewDidEnterFullscreen:]): (-[FullscreenFocusUIDelegate _webViewDidExitFullscreen:]): (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266134 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-25 Jer Noble [Mac] REGRESSION(r262322): Focusable elements are focused when exiting from video fullscreen mode. https://bugs.webkit.org/show_bug.cgi?id=215660 Reviewed by Darin Adler. API Test: Fullscreen.Focus. The default behavior of NSWindow is to change its -keyViewSelectionDirection to NSSelectingNext when activating and changing the firstResponder. This causes WKWebView to change it's focus in response to becoming first responder. The cheap fix is to ensure WKWebView is already the firstResponder when the window is activated. Then NSWindow won't try to change the firstResponder in response to activation. * UIProcess/mac/WKFullScreenWindowController.mm: (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]): 2020-09-01 Alan Coon Cherry-pick r266268. rdar://problem/68107183 Remove the feature flag for capped cookies set in 3rd-party CNAME cloaked HTTP responses and add ITP debug logging https://bugs.webkit.org/show_bug.cgi?id=215902 Reviewed by Brent Fulgham. This change removes the feature flag, effectively turning the feature on. It also adds log output of cookie names that have been capped when ITP Debug Mode is enabled. Source/WebCore: WebCore::NetworkStorageSession now has a member flag for ITP debug logging. No new tests. This feature already has tests. * page/Settings.yaml: * platform/network/NetworkStorageSession.cpp: (WebCore::NetworkStorageSession::setResourceLoadStatisticsDebugLoggingEnabled): (WebCore::NetworkStorageSession::resourceLoadStatisticsDebugLoggingEnabled const): New function to be able to conditionalize log output in the new feature. * platform/network/NetworkStorageSession.h: Source/WebKit: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode): Now sets the flag in WebCore::NetworkStorageSession through the new function WebCore::NetworkStorageSession::setResourceLoadStatisticsDebugLoggingEnabled(). * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::resetParametersToDefaultValues): (WebKit::NetworkProcess::setIsRunningResourceLoadStatisticsTest): * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): (WebKit::NetworkSession::setFirstPartyHostCNAMEDomain): (WebKit::NetworkSession::firstPartyHostCNAMEDomain): * NetworkProcess/NetworkSession.h: (WebKit::NetworkSession::setCNAMECloakingMitigationEnabled): Deleted. (WebKit::NetworkSession::cnameCloakingMitigationEnabled const): Deleted. * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::updateFirstPartyInfoForSession): (WebKit::NetworkDataTaskCocoa::applyCookiePolicyForThirdPartyCNAMECloaking): * Shared/ResourceLoadStatisticsParameters.h: (WebKit::ResourceLoadStatisticsParameters::encode const): (WebKit::ResourceLoadStatisticsParameters::decode): * Shared/WebPreferences.yaml: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::ensureNetworkProcess): * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::platformSetNetworkParameters): * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::parameters): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266268 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-27 John Wilander Remove the feature flag for capped cookies set in 3rd-party CNAME cloaked HTTP responses and add ITP debug logging https://bugs.webkit.org/show_bug.cgi?id=215902 Reviewed by Brent Fulgham. This change removes the feature flag, effectively turning the feature on. It also adds log output of cookie names that have been capped when ITP Debug Mode is enabled. * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode): Now sets the flag in WebCore::NetworkStorageSession through the new function WebCore::NetworkStorageSession::setResourceLoadStatisticsDebugLoggingEnabled(). * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::resetParametersToDefaultValues): (WebKit::NetworkProcess::setIsRunningResourceLoadStatisticsTest): * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): (WebKit::NetworkSession::setFirstPartyHostCNAMEDomain): (WebKit::NetworkSession::firstPartyHostCNAMEDomain): * NetworkProcess/NetworkSession.h: (WebKit::NetworkSession::setCNAMECloakingMitigationEnabled): Deleted. (WebKit::NetworkSession::cnameCloakingMitigationEnabled const): Deleted. * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::updateFirstPartyInfoForSession): (WebKit::NetworkDataTaskCocoa::applyCookiePolicyForThirdPartyCNAMECloaking): * Shared/ResourceLoadStatisticsParameters.h: (WebKit::ResourceLoadStatisticsParameters::encode const): (WebKit::ResourceLoadStatisticsParameters::decode): * Shared/WebPreferences.yaml: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::ensureNetworkProcess): * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::platformSetNetworkParameters): * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::parameters): 2020-09-01 Alan Coon Cherry-pick r266238. rdar://problem/68161715 Unreviewed, add missing double quote in r266216. * WebProcess/com.apple.WebProcess.sb.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266238 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-27 Chris Dumez Unreviewed, add missing double quote in r266216. * WebProcess/com.apple.WebProcess.sb.in: 2020-09-01 Alan Coon Cherry-pick r266216. rdar://problem/68161715 [macOS] Stop logging sandbox violations of com.apple.CoreDisplay.Notification https://bugs.webkit.org/show_bug.cgi?id=215869 Reviewed by Darin Adler. On macOS, stop logging mach-lookup sandbox violations of com.apple.CoreDisplay.Notification for performance reasons. No new tests, since there is no change in behavior. The service was already being denied in the sandbox. * WebProcess/com.apple.WebProcess.sb.in: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266216 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-26 Per Arne Vollan [macOS] Stop logging sandbox violations of com.apple.CoreDisplay.Notification https://bugs.webkit.org/show_bug.cgi?id=215869 Reviewed by Darin Adler. On macOS, stop logging mach-lookup sandbox violations of com.apple.CoreDisplay.Notification for performance reasons. No new tests, since there is no change in behavior. The service was already being denied in the sandbox. * WebProcess/com.apple.WebProcess.sb.in: 2020-08-26 Alan Coon Cherry-pick r266168. rdar://problem/67836301 REGRESSION (r265908): Crash under Blob::arrayBuffer() / Blob::text() in stress GC https://bugs.webkit.org/show_bug.cgi?id=215832 Reviewed by Ryosuke Niwa. Source/WebCore: r265908 added support for Blob::arrayBuffer() / Blob::text() which are asynchronous operations returning promises. The crash is due to the fact that the Blob's JS wrapper may get garbage collected before the promise is settled. To address the issue, this patch makes Blob an ActiveDOMObject and creates an ActiveDOMObject::pendingActivity whenever there is a pending promise so that the JS wrapper does not get garbage collected too early. Test: fast/files/blob-text-gc.html * Modules/async-clipboard/Clipboard.cpp: (WebCore::Clipboard::getType): * Modules/async-clipboard/ClipboardImageReader.h: (WebCore::ClipboardImageReader::ClipboardImageReader): * Modules/async-clipboard/ClipboardItem.cpp: (WebCore::ClipboardItem::blobFromString): * Modules/async-clipboard/ClipboardItem.h: * Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp: (WebCore::ClipboardItemBindingsDataSource::getType): * Modules/async-clipboard/ios/ClipboardImageReaderIOS.mm: (WebCore::ClipboardImageReader::readBuffer): * Modules/async-clipboard/mac/ClipboardImageReaderMac.mm: (WebCore::ClipboardImageReader::readBuffer): * Modules/entriesapi/DOMFileSystem.cpp: (WebCore::DOMFileSystem::getFile): * Modules/entriesapi/DOMFileSystem.h: * Modules/entriesapi/FileSystemFileEntry.cpp: (WebCore::FileSystemFileEntry::file): * Modules/entriesapi/FileSystemFileEntry.h: * Modules/entriesapi/FileSystemFileEntry.idl: * Modules/fetch/FetchBody.cpp: (WebCore::FetchBody::fromFormData): * Modules/fetch/FetchBody.h: * Modules/fetch/FetchBodyConsumer.cpp: (WebCore::blobFromData): (WebCore::packageFormData): (WebCore::resolveWithTypeAndData): (WebCore::FetchBodyConsumer::resolve): (WebCore::FetchBodyConsumer::takeAsBlob): * Modules/fetch/FetchBodyConsumer.h: * Modules/fetch/FetchBodyOwner.cpp: (WebCore::FetchBodyOwner::blob): * Modules/mediarecorder/MediaRecorder.cpp: (WebCore::MediaRecorder::stopRecording): (WebCore::MediaRecorder::requestData): * Modules/mediastream/RTCDataChannel.cpp: (WebCore::RTCDataChannel::didReceiveRawData): * Modules/websockets/WebSocket.cpp: (WebCore::WebSocket::didReceiveBinaryData): * Modules/websockets/WorkerThreadableWebSocketChannel.cpp: (WebCore::WorkerThreadableWebSocketChannel::Bridge::send): * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readFile): (WebCore::CloneDeserializer::readTerminal): * dom/DataTransfer.cpp: (WebCore::DataTransfer::updateFileList): (WebCore::DataTransfer::items): (WebCore::DataTransfer::filesFromPasteboardAndItemList const): (WebCore::DataTransfer::files const): * dom/DataTransfer.h: * dom/DataTransfer.idl: * dom/DataTransferItemList.cpp: (WebCore::DataTransferItemList::DataTransferItemList): (WebCore::DataTransferItemList::remove): (WebCore::DataTransferItemList::clear): (WebCore::DataTransferItemList::ensureItems const): (WebCore::DataTransferItemList::document const): * dom/DataTransferItemList.h: * dom/DataTransferItemList.idl: * editing/WebCorePasteboardFileReader.cpp: (WebCore::WebCorePasteboardFileReader::readFilename): (WebCore::WebCorePasteboardFileReader::readBuffer): * editing/WebCorePasteboardFileReader.h: * editing/cocoa/WebContentReaderCocoa.mm: (WebCore::createFragmentForImageAttachment): (WebCore::replaceRichContentWithAttachments): (WebCore::createFragmentAndAddResources): (WebCore::sanitizeMarkupWithArchive): (WebCore::WebContentReader::readImage): (WebCore::attachmentForFilePath): (WebCore::attachmentForData): * editing/markup.cpp: (WebCore::restoreAttachmentElementsInFragment): * fileapi/Blob.cpp: (WebCore::Blob::Blob): (WebCore::Blob::loadBlob): (WebCore::Blob::activeDOMObjectName const): * fileapi/Blob.h: (WebCore::Blob::create): (WebCore::Blob::deserialize): (WebCore::Blob::slice const): * fileapi/Blob.idl: * fileapi/File.cpp: (WebCore::File::createWithRelativePath): (WebCore::File::create): (WebCore::File::File): (WebCore::File::activeDOMObjectName const): * fileapi/File.h: * fileapi/File.idl: * html/DOMFormData.cpp: (WebCore::DOMFormData::createFileEntry): * html/DirectoryFileListCreator.cpp: (WebCore::FileInformation::isolatedCopy const): (WebCore::appendDirectoryFiles): (WebCore::gatherFileInformation): (WebCore::toFileList): (WebCore::DirectoryFileListCreator::start): * html/DirectoryFileListCreator.h: * html/FileInputType.cpp: (WebCore::FileInputType::appendFormData const): (WebCore::FileInputType::filesChosen): * html/HTMLAttachmentElement.cpp: (WebCore::HTMLAttachmentElement::updateEnclosingImageWithData): * html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::toBlob): * testing/Internals.cpp: (WebCore::Internals::createFile): * testing/ServiceWorkerInternals.cpp: (WebCore::ServiceWorkerInternals::createOpaqueWithBlobBodyResponse): * workers/service/context/ServiceWorkerFetch.cpp: (WebCore::ServiceWorkerFetch::dispatchFetchEvent): * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::createResponseBlob): Source/WebKit: * WebProcess/Automation/WebAutomationSessionProxy.cpp: (WebKit::WebAutomationSessionProxy::setFilesForInputFileUpload): LayoutTests: Add better test coverage. * fast/files/blob-text-gc-expected.txt: Added. * fast/files/blob-text-gc.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266168 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-26 Chris Dumez REGRESSION (r265908): Crash under Blob::arrayBuffer() / Blob::text() in stress GC https://bugs.webkit.org/show_bug.cgi?id=215832 Reviewed by Ryosuke Niwa. * WebProcess/Automation/WebAutomationSessionProxy.cpp: (WebKit::WebAutomationSessionProxy::setFilesForInputFileUpload): 2020-08-26 Alan Coon Cherry-pick r266087. rdar://problem/67836301 Implement Request/Response consuming as FormData https://bugs.webkit.org/show_bug.cgi?id=215671 Patch by Alex Christensen on 2020-08-24 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/fetch/api/abort/general.any-expected.txt: * web-platform-tests/fetch/api/abort/general.any.worker-expected.txt: * web-platform-tests/fetch/api/request/request-consume-empty-expected.txt: This remaining failing test now fails similarly in all browsers. * web-platform-tests/fetch/api/request/request-consume-expected.txt: * web-platform-tests/fetch/api/request/request-init-002-expected.txt: * web-platform-tests/fetch/api/response/response-consume-empty-expected.txt: This remaining failing test now fails similarly in all browsers. * web-platform-tests/fetch/api/response/response-consume-expected.txt: * web-platform-tests/fetch/api/response/response-error-from-stream-expected.txt: This change makes the formData failures in this file look like all the other failures in this file, which should be fixed together in a separate patch. * web-platform-tests/fetch/api/response/response-init-002-expected.txt: * web-platform-tests/url/urlencoded-parser.any-expected.txt: * web-platform-tests/url/urlencoded-parser.any.worker-expected.txt: * web-platform-tests/service-workers/service-worker/fetch-event-respond-with-custom-response.https-expected.txt: Source/WebCore: Covered by many newly passing WPT tests, for most of which Safari was the only failing browser. * Modules/fetch/FetchBody.cpp: (WebCore::FetchBody::formData): (WebCore::FetchBody::consume): (WebCore::FetchBody::consumeFormData): * Modules/fetch/FetchBody.h: * Modules/fetch/FetchBodyConsumer.cpp: (WebCore::formDataFromData): (WebCore::resolveWithTypeAndData): (WebCore::FetchBodyConsumer::resolve): * Modules/fetch/FetchBodyConsumer.h: Source/WebKit: * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: (WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish): Add a fast path that allows non-blob FormData responses from service workers to not hang. This part is covered by this layout test: imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-custom-response.https.html Source/WTF: In order to be compatible with other browsers, we need a verson of String::fromUTF8 that uses U8_NEXT_OR_FFFD instead of U8_NEXT, but changing that across the board will break other things. Leave everything else as it is, use templates and constexpr to not add any branches, but add String::fromUTF8ReplacingInvalidSequences to allow me to make our FormData consuming compatible with other browsers. * wtf/text/WTFString.cpp: (WTF::fromUTF8Helper): (WTF::String::fromUTF8): (WTF::String::fromUTF8ReplacingInvalidSequences): * wtf/text/WTFString.h: * wtf/unicode/UTF8Conversion.cpp: (WTF::Unicode::convertUTF8ToUTF16Impl): (WTF::Unicode::convertUTF8ToUTF16): (WTF::Unicode::convertUTF8ToUTF16ReplacingInvalidSequences): * wtf/unicode/UTF8Conversion.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266087 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-08-24 Alex Christensen Implement Request/Response consuming as FormData https://bugs.webkit.org/show_bug.cgi?id=215671 Reviewed by Darin Adler. * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: (WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish): Add a fast path that allows non-blob FormData responses from service workers to not hang. This part is covered by this layout test: imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-custom-response.https.html 2020-08-21 Wenson Hsieh [macOS] Unable to copy text from the function browser panel in Numbers https://bugs.webkit.org/show_bug.cgi?id=215740 Reviewed by Darin Adler. On some versions of Xcode, using Interface Builder to set up WKWebViews causes the WKWebView to contain two WKFlippedViews as subviews; one of these is created and added in the normal initialization path of the web view underneath WebViewImpl's constructor, and the other is created and added underneath the superclass (NSView's) `-initWithCoder:` implementation. This causes issues when hit-testing WKWebView using the `-hitTest:` method, which is expected to return the WKWebView itself instead of the inner WKFlippedView. The logic that tries to implement this behavior is in `WebViewImpl::hitTest`, which calls into WKWebView's `-hitTest:` method and returns the WKWebView if the hit- tested view ended up being equal to the `m_layerHostingView`. Since we end up with two layer hosting views (only one of which is the real `m_layerHostingView`), we fail the check and end up returning the other WKFlippedView. In the context of this bug, this erroneous hit-test causes AppKit to ask if the WKFlippedView can become the first responder upon mousedown (which it cannot), and so the window's first responder remains the same (instead of changing to WKWebView). To fix this, adjust the constructor of WebViewImpl to avoid making an extra layer hosting view in the case where decoding the WKWebView already initialized and placed the layer hosting view, and just use the existing one instead. Test: WKWebView.HitTestAfterInitializingFromCoder * UIProcess/Cocoa/WebViewImpl.mm: (-[WKFlippedView initWithFrame:]): (-[WKFlippedView initWithCoder:]): (-[WKFlippedView _commonInitialize]): Override both designated initialization codepaths so that we call the `-_commonInitialize` helper, which sets the autoresizing mask. This was previously called immediately after creating the WKFlippedView in the constructor of WebViewImpl. (WebKit::WebViewImpl::WebViewImpl): 2020-08-21 Andy Estes IPC::encodeSharedBuffer combines SharedBuffer data segments when copying to SharedMemory https://bugs.webkit.org/show_bug.cgi?id=215737 Reviewed by Darin Adler. IPC::encodeSharedBuffer called SharedBuffer::data() when copying data into SharedMemory, requiring the SharedBuffer to combine its data segments. This can be avoided by using SharedMemory::copyBuffer() instead. * Platform/SharedMemory.cpp: (WebKit::SharedMemory::copyBuffer): Modernized to use auto and range-based for loops. * Shared/WebCoreArgumentCoders.cpp: (IPC::encodeSharedBuffer): Used SharedMemory::copyBuffer() to create a copy of the buffer in a new SharedMemory. Calling this function does not combine the buffer's data segments. * Platform/SharedMemory.h: Added a FIXME for how SharedMemory's factory functions could be improved. 2020-08-21 Jiten Mehta Use closeReason provided in didCloseWithCode delegate for the NSURLSessionWebSocket code path https://bugs.webkit.org/show_bug.cgi?id=215519 Reviewed by Youenn Fablet. Covered by existing protocol tests with NSURLSession code path enabled. http/tests/websocket/tests/hybi/workers/close-code-and-reason.html * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:webSocketTask:didCloseWithCode:reason:]): 2020-08-21 Andy Estes REGRESSION (r257667): 1.9x more CPU time in IPC::SharedBufferDataReference decoding during Netflix playback https://bugs.webkit.org/show_bug.cgi?id=215232 Reviewed by Geoff Garen. Prior to r257667, an IPC message defined a IPC::SharedBufferDataReference argument to allow its sender to easily encode SharedBuffer data as a DataReference. SharedBufferDataReference cost the same to encode as a DataReference -- both copied data into the Encoder -- but did so by iterating over the SharedBuffer's data segments rather than combining them into a contiguous allocation. The message argument was received as a decoded IPC::DataReference, which stores a pointer into the IPC::Decoder's buffer rather than making a copy. In r257667, IPC::SharedBufferDataReference switched its encoder to use IPC::ArgumentCoder's SharedBuffer specialization, which works by allocating a SharedMemory buffer, copying SharedBuffer data into it, creating a SharedMemory::IPCHandle from it, and encoding the handle. It makes only one copy like the old encoder did, but pays the added cost of combining SharedBuffer data segments prior to copying by needlessly calling SharedBuffer::data() (this should be fixed independently). Since this serialization could no longer be decoded by DataReference's decoder, SharedBufferDataReference implemented a decoder, also in terms of ArgumentCoder's SharedBuffer specialization. It works by mapping a SharedMemory buffer from a decoded SharedMemory::IPCHandle and copying that buffer into a new SharedBuffer. This copy is a cost that the old decoder did not incur, but in some cases the message receiver would have made such a copy anyway and can instead just ref the decoded SharedBuffer. In other cases though, the receiver either made no copies or couldn't use the decoded SharedBuffer to avoid making its own copy so creating the SharedBuffer was pure added cost. There are additional costs from allocating, mapping, and deleting shared memory and Mach send rights, but they are offset by savings due to smaller Encoder and Decoder buffers. The additional SharedBuffer combining and copying is not offset elsewhere, and on net makes sending and receiving IPC::SharedBufferDataReferences use up to 2x more CPU time when playing a video on netflix.com in Safari. Resolve this slowdown by reverting the argument encoding changes made to IPC::SharedBufferDataReference in r257667. For compatibility with code added after r257667, the current IPC::SharedBufferDataReference was copied to IPC::SharedBufferCopy and retains the behavior of copying into a SharedBuffer when decoded. IPC::SharedBufferDataReference now has the pre-r257667 behavior of decoding to an IPC::DataReference. Messages added after r257667 whose receivers were designed to handle a SharedBuffer were changed to use IPC::SharedBufferCopy, and all other receivers of messages with IPC::SharedBufferDataReference arguments were changed to handle an IPC::DataReference. * GPUProcess/media/RemoteCDMInstanceProxy.cpp: * GPUProcess/media/RemoteCDMInstanceProxy.h: * GPUProcess/media/RemoteCDMInstanceProxy.messages.in: * GPUProcess/media/RemoteCDMInstanceSessionProxy.cpp: * GPUProcess/media/RemoteCDMInstanceSessionProxy.h: * GPUProcess/media/RemoteCDMInstanceSessionProxy.messages.in: * GPUProcess/media/RemoteCDMProxy.cpp: * GPUProcess/media/RemoteCDMProxy.h: * GPUProcess/media/RemoteLegacyCDMSessionProxy.cpp: * GPUProcess/media/RemoteLegacyCDMSessionProxy.h: * GPUProcess/media/RemoteLegacyCDMSessionProxy.messages.in: * UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::platformRegisterAttachment): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::registerAttachmentIdentifierFromData): (WebKit::WebPageProxy::platformRegisterAttachment): * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * UIProcess/WebPasteboardProxy.h: * UIProcess/WebPasteboardProxy.messages.in: * UIProcess/gtk/WebPasteboardProxyGtk.cpp: * WebProcess/GPU/media/RemoteCDMInstance.cpp: * WebProcess/GPU/media/RemoteCDMInstanceSession.cpp: * WebProcess/GPU/media/RemoteCDMInstanceSession.h: * WebProcess/GPU/media/RemoteCDMInstanceSession.messages.in: * WebProcess/GPU/media/RemoteLegacyCDMSession.cpp: * WebProcess/GPU/media/RemoteLegacyCDMSession.h: * WebProcess/GPU/media/RemoteLegacyCDMSession.messages.in: * WebProcess/WebCoreSupport/WebEditorClient.cpp: * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: Replaced IPC::SharedBufferDataReference with IPC::SharedBufferCopy. * NetworkProcess/NetworkResourceLoader.cpp: * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h: * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.messages.in: * WebProcess/Network/WebResourceLoader.cpp: * WebProcess/Network/WebResourceLoader.h: * WebProcess/Network/WebResourceLoader.messages.in: * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: Removed the DidReceiveSharedBuffer message and reverted the DidReceiveData message back to taking an IPC::SharedBufferDataReference. * Platform/IPC/Encoder.h: Made Encoder::reserve(size_t) public so SharedBufferCopy::encode(Encoder&) can call it. * Platform/IPC/HandleMessage.h: Restored the CodingType specialization that decodes SharedBufferDataReference arguments as DataReferences. * Platform/IPC/SharedBufferCopy.cpp: * Platform/IPC/SharedBufferCopy.h: Copied from SharedBufferDataReference.h. Implemented the interface and decoding behavior that SharedBufferDataReference had between r257667 and this change. * Platform/IPC/SharedBufferDataReference.cpp: * Platform/IPC/SharedBufferDataReference.h: Reverted to the pre-r257667 interface and decoding behvior. * Scripts/webkit/messages.py: Removed an unneeded special case. * Sources.txt: * WebKit.xcodeproj/project.pbxproj: Added SharedBuffer{Copy,DataReference}.cpp. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::dataCallback): (WebKit::WebPageProxy::finishedLoadingIcon): * UIProcess/WebPageProxy.h: * WebProcess/WebPage/WebPage.cpp: * WebProcess/WebPage/WebPage.h: Used `const IPC::DataReference&` in message receiver signatures for SharedBufferDataReference arguments. * UIProcess/WebURLSchemeTask.cpp: * WebProcess/GPU/media/RemoteAudioBusData.h: * WebProcess/GPU/media/RemoteCDM.cpp: * WebProcess/Network/WebLoaderStrategy.cpp: Removed unused includes. 2020-08-20 Peng Liu Mac Catalyst Apps require "playsinline" attribute to support playing videos in the inline mode https://bugs.webkit.org/show_bug.cgi?id=215724 Reviewed by Tim Horton. Currently WebKit::currentUserInterfaceIdiomIsPad() returns NO on Mac Catalyst apps. Therefore, the behavior of Mac Catalyst apps regarding the inline media playback support is not consistent with iPad apps. This patch removes the usage of WebKit::currentUserInterfaceIdiomIsPad() to decide the settings of the inline media playback support on Mac Catalyst apps. * UIProcess/API/Cocoa/WKWebViewConfiguration.mm: (-[WKWebViewConfiguration init]): 2020-08-20 Carlos Garcia Campos [GTK][WPE] Debug crashes in backdrop filter tests https://bugs.webkit.org/show_bug.cgi?id=215209 Reviewed by Adrian Perez de Castro. * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp: (WebKit::CompositingCoordinator::~CompositingCoordinator): Use invalidateCoordinator() instead of setCoordinator() that has been removed. (WebKit::CompositingCoordinator::createGraphicsLayer): Use setCoordinatorIncludingSubLayersIfNeeded() instead of attaching the layer directly. (WebKit::CompositingCoordinator::attachLayer): Do not call setCoordinator(), the caller is expected to set the coordinator. 2020-08-20 Per Arne Vollan [macOS] Web pages are not responding correctly to changes in "Reduce motion" setting https://bugs.webkit.org/show_bug.cgi?id=215664 Reviewed by Darin Adler. This happens because there is a race between the preference change and notification being received in the WebContent process. This race is usually won by the notification, which then reads the wrong preference value when being handled. This bug was introduced when access to the preference daemon was closed in the WebContent process, and preferences were updated from the UI process. This patch addresses this issue by re-posting the notification when the preference value is updated in the WebContent process. API test: WebKit.AccessibilityReduceMotion * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::reduceMotionPreferenceKey): (WebKit::dispatchSimulatedNotificationsForPreferenceChange): 2020-08-20 James Savage Could not find module 'WebKit' for target 'armv7-apple-ios' Reviewed by Brady Eidson. The config changes here got added to the wrong config file. They need to be for the overlay, not its tests. * SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig: * SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: 2020-08-20 Aditya Keerthi Add runtime setting for editable components in date/time inputs https://bugs.webkit.org/show_bug.cgi?id=215705 Reviewed by Wenson Hsieh. Added DateTimeInputsEditableComponentsEnabled as a runtime setting. This setting is enabled by default on macOS. * Shared/WebPreferences.yaml: * Shared/WebPreferencesDefaultValues.h: 2020-08-20 Chris Dumez Sandbox violation when calling [NSHTTPCookieStorage sharedHTTPCookieStorage] from the WebProcess https://bugs.webkit.org/show_bug.cgi?id=215701 Reviewed by Geoffrey Garen. The sandbox does not allow calling [NSHTTPCookieStorage sharedHTTPCookieStorage] from the WebProcess. createPrivateStorageSession() was calling [NSHTTPCookieStorage sharedHTTPCookieStorage] to retrieve the cookieAcceptPolicy and createPrivateStorageSession() is used by the cookie cache in the WebProcess. To address the issue, we now allow the caller of createPrivateStorageSession() to provide the cookieAcceptPolicy and we have the cookie cache retrieve the cookieAcceptPolicy from the NetworkProcessConnection. * WebProcess/Network/NetworkProcessConnection.h: (WebKit::NetworkProcessConnection::cookieAcceptPolicy const): * WebProcess/WebPage/Cocoa/WebCookieCacheCocoa.mm: (WebKit::WebCookieCache::inMemoryStorageSession): 2020-08-20 Youenn Fablet Align console log message of new WebSocket code path with the legacy code path https://bugs.webkit.org/show_bug.cgi?id=215695 Reviewed by Alex Christensen. No observable change of behavior from the page. Console log messages appear in expected.txt files when NSURLSession code path is enabled. * WebProcess/Network/WebSocketChannel.cpp: (WebKit::WebSocketChannel::connect): (WebKit::WebSocketChannel::didReceiveMessageError): * WebProcess/Network/WebSocketChannel.h: 2020-08-20 Lauro Moura REGRESSION(r265856) [GTK][WPE] hybi websockets tests failing https://bugs.webkit.org/show_bug.cgi?id=215679 Reviewed by Carlos Garcia Campos. r265856 changed WebSocketChannel to expect AbnormalClosure when the closing handshake is not received. Covered by existing tests. * NetworkProcess/soup/WebSocketTaskSoup.cpp: (WebKit::WebSocketTask::didFail): 2020-08-20 Youenn Fablet WebSocketTask::close should correctly compute reason byte size in UTF-8 https://bugs.webkit.org/show_bug.cgi?id=215645 Reviewed by Darin Adler. Covered by http/tests/websocket/tests/hybi/close.html with NSURLSession code path enabled. * NetworkProcess/cocoa/WebSocketTaskCocoa.mm: (WebKit::WebSocketTask::close): Instead of calling sizeInBytes, we should just get the utf8 CString and gets its size directly. 2020-08-19 Fujii Hironori IPC message can't be decoded due to uninitialized NavigationActionData member variables with the latest MSVC https://bugs.webkit.org/show_bug.cgi?id=215662 Reviewed by Darin Adler. WinCairo WebKit2 is crashing in AuxiliaryProcess::didReceiveInvalidMessage if it is compiled by the latest MSVC (Visual Studio 2019 16.7) with optimizer (/O2). LockHistory is a bool based enum type. NavigationActionData doesn't initialize the member variable of it. IPC::Encoder converts a LockHistory value to the underlying type bool. The uninitialized value is converted 0 or 1 in GCC, Clang and old MSVC. However, the latest MSVC doesn't convert and IPC::Decoder detects an invalid enum value. * Shared/NavigationActionData.h: Added initializes for userGestureTokenIdentifier, lockHistory and lockBackForwardList. 2020-08-19 Brady Eidson Improperly linearized PDFs show up as blank gray on Big Sur. rdar://problem/67117968 and https://bugs.webkit.org/show_bug.cgi?id=215683 Reviewed by Darin Adler. Will add a new test once an in-house expert helps us construct an example PDF that we will have the legal right to commit. * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::threadEntry): When PDFKit indicates a PDFDocument is *improperly* linearized (as opposed to not linearized at all), we failed to appopriately notify the main thread that it needs to start handling the PDF. Failure to create a PDFDocument is equivalent to receiving the "nonlinearized sentinel", so adding that call fixes this issue. 2020-08-19 Simon Fraser Fix possible crash when webAnimationsCSSIntegrationEnabled is false https://bugs.webkit.org/show_bug.cgi?id=215668 Reviewed by Dean Jackson. When webAnimationsCSSIntegrationEnabled is false, GraphicsLayerCA::setupAnimation() doesn't set a timing function on the animation, causing a null de-ref when the animation is being encoded. Fix the encoder to handle null timing functions. Test: animations/legacy-encoding-timing-function.html * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm: (WebKit::PlatformCAAnimationRemote::Properties::encode const): (WebKit::PlatformCAAnimationRemote::Properties::decode): 2020-08-19 Alex Christensen Fix null pointer crashes in network process after r265835 ​https://bugs.webkit.org/show_bug.cgi?id=215626 Call the correct CompletionHandler. completionHandler has already been moved from at this point. This crash was being hit in the test, but the test recovered from it. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::NetworkSessionCocoa::continueDidReceiveChallenge): 2020-08-19 Kate Cheney Third party domains are not stored in the case of back/forward navigations https://bugs.webkit.org/show_bug.cgi?id=215595 Reviewed by Chris Dumez. This patch adds the ability to retrieve loaded third party domains from the page synchronously to be stored in the CachedPage in the case of a back/forward navigation. It also changes the functions loadedThirdPartyDomains and getLoadedThirdPartyDomains to loadedSubresourceDomains and getLoadedSubresourceDomains respectively based on the conversation from https://bugs.webkit.org/show_bug.cgi?id=215595. * UIProcess/API/C/WKPage.cpp: (WKPageLoadedSubresourceDomains): (WKPageClearLoadedSubresourceDomains): (WKPageLoadedThirdPartyDomains): Deleted. (WKPageClearLoadedThirdPartyDomains): Deleted. * UIProcess/API/C/WKPagePrivate.h: * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: (-[WKWebsiteDataStore _loadedSubresourceDomainsFor:completionHandler:]): (-[WKWebsiteDataStore _clearLoadedSubresourceDomainsFor:]): (-[WKWebsiteDataStore _loadedThirdPartyDomainsFor:completionHandler:]): Deleted. (-[WKWebsiteDataStore _clearLoadedThirdPartyDomainsFor:]): Deleted. * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::getLoadedSubresourceDomains): (WebKit::WebPageProxy::clearLoadedSubresourceDomains): (WebKit::WebPageProxy::loadedThirdPartyDomains): Deleted. (WebKit::WebPageProxy::clearLoadedThirdPartyDomains): Deleted. * UIProcess/WebPageProxy.h: * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::loadedSubresourceDomains const): * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::didCommitLoad): (WebKit::WebPage::didLoadFromRegistrableDomain): (WebKit::WebPage::getLoadedSubresourceDomains): (WebKit::WebPage::clearLoadedSubresourceDomains): (WebKit::WebPage::loadedThirdPartyDomains): Deleted. (WebKit::WebPage::clearLoadedThirdPartyDomains): Deleted. * WebProcess/WebPage/WebPage.h: (WebKit::WebPage::loadedSubresourceDomains const): * WebProcess/WebPage/WebPage.messages.in: 2020-08-19 Chris Dumez REGRESSION (r261407): Sharing rich links from Twitter/Netflix via Messages is unreliable https://bugs.webkit.org/show_bug.cgi?id=215656 Reviewed by Tim Horton. The WKWebView._clientNavigationsRunAtForegroundPriority SPI was not working for the MessagesViewService because the view is unparented and PageClient::isApplicationVisible() would not work return accurate results when [view window] returns nil. It is very unfortunate to have to rely on the view or the view's window to determine application visibility so this patch fixes this. We now rely on UIKit's visibility endowment to determine if the UIProcess is visible, using RunningBoard API. I have verified that the visibility endowment properly gets propagated from the host application to the view service when the application is a view service and I have verified that this detects the MessagesViewService as visible for the use-case at , which causes the WKWebView._clientNavigationsRunAtForegroundPriority SPI to work as intended. Note that when the application does not have the visibility endowment, we still allow it to take a foreground assertion for client navigations if the process is allowed to run in the background for an extended period of time, according to RunningBoard. This allows the SPI to work for daemons (like maild) which rely on it. * UIProcess/PageClient.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::runJavaScriptInFrameInScriptWorld): * UIProcess/ios/PageClientImplIOS.h: * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::canTakeForegroundAssertions): (WebKit::PageClientImpl::isApplicationVisible): Deleted. * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::shouldForceForegroundPriorityForClientNavigation const): 2020-08-19 Youenn Fablet WebSocketChannel::didClose should correctly compute whether a closing handshake was received https://bugs.webkit.org/show_bug.cgi?id=215644 Reviewed by Darin Adler. Covered by LayoutTests/http/tests/websocket/tests/hybi/close-code-and-reason.html with NSURLSession code path enabled. * WebProcess/Network/WebSocketChannel.cpp: (WebKit::WebSocketChannel::didClose): As noted by Jiten Mehta, absence of closing handshake from the server is notified by WebSocketChannel::CloseEventCodeAbnormalClosure. Update check accordingly. 2020-08-18 Alex Christensen WKWebViews using fastServerTrustEvaluationEnabled should only allow legacy TLS for main resource loads https://bugs.webkit.org/show_bug.cgi?id=215626 Reviewed by Darin Adler. We have introduced public API webView:authenticationChallenge:shouldAllowDeprecatedTLS: in WKNavigationDelegate to allow applications to choose whether to allow TLS 1.0 or 1.1 connections. We don't want to break this API or break existing third party apps that load pages that load third party subresources that use TLS 1.0 or 1.1. However, we do want Safari, which uses fastServerTrustEvaluationEnabled SPI, to silently fail subresource loads that use TLS 1.0 or 1.1. This matches the current behavior of Chrome and Firefox, which was not implemented in those other browsers when we decided to ask about subresources. Covered by an API test. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::NetworkSessionCocoa::continueDidReceiveChallenge): 2020-08-18 Jer Noble [Mac] Unhandled keyDown: events cause a system beep in full screen mode https://bugs.webkit.org/show_bug.cgi?id=215596 Reviewed by Darin Adler. * UIProcess/mac/WKFullScreenWindowController.mm: (-[WKFullScreenWindowController noResponderFor:]): 2020-08-18 Youenn Fablet NetworkSocketChannel should delay sending back error message as done by NetworkSocketStream https://bugs.webkit.org/show_bug.cgi?id=215563 Reviewed by Alex Christensen. Apply same policy as NetworkSocketStream in case of WebSocket connection error. Covered by http/tests/websocket/tests/hybi/closed-port-delay.html with NSURLSession WebSocket code path. * NetworkProcess/NetworkSocketChannel.cpp: (WebKit::NetworkSocketChannel::NetworkSocketChannel): (WebKit::NetworkSocketChannel::didClose): (WebKit::NetworkSocketChannel::didReceiveMessageError): (WebKit::NetworkSocketChannel::sendDelayedError): * NetworkProcess/NetworkSocketChannel.h: 2020-08-17 Chris Dumez AudioContext.getOutputTimestamp() is missing https://bugs.webkit.org/show_bug.cgi?id=215591 Reviewed by Darin Adler. * GPUProcess/media/RemoteAudioDestinationManager.cpp: * WebProcess/GPU/media/RemoteAudioBusData.h: (WebKit::RemoteAudioBusData::encode const): (WebKit::RemoteAudioBusData::decode): * WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp: (WebKit::RemoteAudioDestinationProxy::renderBuffer): 2020-08-17 Per Arne Vollan Assert failure after r265715 https://bugs.webkit.org/show_bug.cgi?id=215592 Reviewed by Darin Adler. The change set r265715 introduced an assert failure in AuthenticationManager::initializeConnection. This happens because after r265715 the new XPC event handler set in AuthenticationManager::initializeConnection, will no longer be called on the main thread. This patch addresses this issue by dispatching this work on the main thread. No new tests, covered by existing tests. * Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm: (WebKit::AuthenticationManager::initializeConnection): 2020-08-17 Per Arne Vollan [Cocoa] Avoid waiting for Launch Services on every load https://bugs.webkit.org/show_bug.cgi?id=215569 Reviewed by Darin Adler. Currently, we are waiting for the Launch Services database to be present on every load in the WebContent process. It should be sufficient to wait only on the first load. Since we now are waiting only once per WebContent process, increase the maximum wait time from 1s to 5s. No new tests, covered by existing tests. * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::platformDidReceiveLoadParameters): 2020-08-17 Jer Noble [Mac] Add Experimental Feature preference for SW VP9 https://bugs.webkit.org/show_bug.cgi?id=215043 Reviewed by Darin Adler. Follow up fix: during a rebase, a line deletion was dropped which causes the SW decoder to always be registered regardless of the new setting. * WebProcess/WebProcess.cpp: (WebKit::WebProcess::enableVP9Decoder): (WebKit::WebProcess::enableVP9SWDecoder): 2020-08-17 Youenn Fablet Remove message check in WebSocketTask::readNextMessage https://bugs.webkit.org/show_bug.cgi?id=215561 Reviewed by Alex Christensen. This if check was added as a workaround to cases where both error and message were null. This is no longer the case as per running existing tests with NSURLSession WebSocket code path on BigSur. * NetworkProcess/cocoa/WebSocketTaskCocoa.mm: (WebKit::WebSocketTask::readNextMessage): 2020-08-17 Youenn Fablet Remove Cocoa WebSocketTask::send workaround https://bugs.webkit.org/show_bug.cgi?id=215564 Reviewed by Alex Christensen. Covered by existing tests run in Debug. * NetworkProcess/cocoa/WebSocketTaskCocoa.mm: (WebKit::WebSocketTask::sendString): (WebKit::WebSocketTask::sendData): 2020-08-17 David Kilzer Clean up DragApplicationFlags after switch to OptionSet<> Reviewed by Darin Adler. Change WebCore::DragApplicationFlags to an enum class. * UIProcess/API/gtk/DropTargetGtk3.cpp: (WebKit::DropTarget::drop): - Switch to use OptionSet. * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::applicationFlagsForDrag): * WebProcess/WebPage/WebPage.h: - Update forward declaration. 2020-08-17 Carlos Garcia Campos [GTK][WPE] Remove support for NPAPI plugins https://bugs.webkit.org/show_bug.cgi?id=215503 Reviewed by Darin Adler. * PlatformGTK.cmake: * PluginProcess/unix/PluginControllerProxyUnix.cpp: Removed. * PluginProcess/unix/PluginProcessMainUnix.cpp: Removed. * PluginProcess/unix/PluginProcessUnix.cpp: Removed. * Shared/Plugins/Netscape/unix/NetscapePluginModuleUnix.cpp: Removed. * Shared/Plugins/unix/PluginSearchPath.cpp: Removed. * Shared/Plugins/unix/PluginSearchPath.h: Removed. * SourcesGTK.txt: * SourcesWPE.txt: * UIProcess/API/glib/WebKitMimeInfo.cpp: (webkit_mime_info_ref): (webkit_mime_info_unref): (webkit_mime_info_get_mime_type): (webkit_mime_info_get_description): (webkit_mime_info_get_extensions): * UIProcess/API/glib/WebKitMimeInfoPrivate.h: Removed. * UIProcess/API/glib/WebKitPlugin.cpp: (webkit_plugin_get_name): (webkit_plugin_get_description): (webkit_plugin_get_path): (webkit_plugin_get_mime_info_list): * UIProcess/API/glib/WebKitPluginPrivate.h: Removed. * UIProcess/API/glib/WebKitSettings.cpp: (webKitSettingsSetProperty): (webKitSettingsGetProperty): (webkit_settings_class_init): (webkit_settings_get_enable_plugins): (webkit_settings_set_enable_plugins): * UIProcess/API/glib/WebKitWebContext.cpp: (webkit_web_context_set_additional_plugins_directory): (webkit_web_context_get_plugins): (webkit_web_context_get_plugins_finish): * UIProcess/API/glib/WebKitWebView.cpp: (webkitWebViewLoadFail): * UIProcess/API/glib/WebKitWebsiteData.cpp: (recordContainsSupportedDataTypes): (toWebKitWebsiteDataTypes): * UIProcess/API/glib/WebKitWebsiteDataManager.cpp: (toWebsiteDataTypes): * UIProcess/API/gtk/WebKitError.h: * UIProcess/API/gtk/WebKitMimeInfo.h: * UIProcess/API/gtk/WebKitPlugin.h: * UIProcess/API/gtk/WebKitSettings.h: * UIProcess/API/gtk/WebKitWebContext.h: * UIProcess/API/gtk/WebKitWebsiteData.h: * UIProcess/API/wpe/WebKitError.h: * UIProcess/API/wpe/WebKitMimeInfo.h: * UIProcess/API/wpe/WebKitPlugin.h: * UIProcess/API/wpe/WebKitSettings.h: * UIProcess/API/wpe/WebKitWebContext.h: * UIProcess/API/wpe/WebKitWebsiteData.h: * UIProcess/Launcher/glib/BubblewrapLauncher.cpp: (WebKit::bubblewrapSpawn): * UIProcess/Launcher/glib/ProcessLauncherGLib.cpp: (WebKit::ProcessLauncher::launchProcess): * UIProcess/Plugins/gtk/PluginInfoCache.cpp: Removed. * UIProcess/Plugins/gtk/PluginInfoCache.h: Removed. * UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp: Removed. * UIProcess/Plugins/unix/PluginProcessProxyUnix.cpp: Removed. * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * UIProcess/gtk/WebPageProxyGtk.cpp: * WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.cpp: Removed. * WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.h: Removed. * WebProcess/Plugins/Netscape/unix/PluginProxyUnix.cpp: Removed. * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp: Removed. * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.h: Removed. * WebProcess/Plugins/PluginController.h: * WebProcess/Plugins/PluginView.cpp: * WebProcess/Plugins/PluginView.h: 2020-08-17 Youenn Fablet Set Sec-WebSocket-Protocol for WebSocket NSURLSession code path https://bugs.webkit.org/show_bug.cgi?id=215456 Reviewed by Alex Christensen. Covered by existing protocol tests with NSURLSession code path enabled. http/tests/websocket/tests/hybi/set-protocol.html, http/tests/websocket/tests/hybi/workers/multiple-subprotocols.html Code change originating from Jiten Mehta. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::NetworkSessionCocoa::createWebSocketTask): Set Sec-WebSocket-Protocol to support WebSocket protocol negotiation. 2020-08-17 Carlos Garcia Campos REGRESSION(r265725) [GTK][WPE] Several http/tests timeout/failures https://bugs.webkit.org/show_bug.cgi?id=215542 Reviewed by Sergio Villar Senin. The problem is that ShareableResource is now using the dataSize member of IPCHandle to encode/decode the resource size, but SharedMemoryUnix is not encoding/decoding dataSize. * Platform/unix/SharedMemoryUnix.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): 2020-08-14 Simon Fraser Scrolling sync changes in r261985 regressed CPU usage by ~2 ms/s https://bugs.webkit.org/show_bug.cgi?id=215529 Reviewed by Geoff Garen. r261985 added two code paths that wake up the scrolling thread on every rendering update (triggered by displayDidRefresh()). One is a ping from the EventDispatcher thread, the other is a wake-and-block from the main thread. If the scrolling thread isn't active (no wheel events received recently), we can avoid both of these to reduce the number of CPU core wakeups. * WebProcess/WebPage/EventDispatcher.cpp: (WebKit::EventDispatcher::wheelEvent): 2020-08-15 Tim Horton Live Web Content processes do not respect accent color if dynamically changed to "multicolor" https://bugs.webkit.org/show_bug.cgi?id=215523 Reviewed by Wenson Hsieh. * UIProcess/Cocoa/PreferenceObserver.mm: (-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::setPreferenceValue): The NSUserDefaults syncing mechanism does not propagate defaults that are deleted or changed to nil. Allow nil, and fix up an assert that would fire for the same reason. 2020-08-14 Alex Christensen Revert r263551 https://bugs.webkit.org/show_bug.cgi?id=215530 Reviewed by Geoffrey Garen. I was hoping to fix many developers' bugs, but it caused hangs and more hangs, so back to the status quo. https://bugs.webkit.org/show_bug.cgi?id=203547 will fix this the right way in the hopefully-not-too-distant future. * UIProcess/API/APIHTTPCookieStore.cpp: (API::HTTPCookieStore::setCookies): (API::HTTPCookieStore::registerForNewProcessPoolNotifications): (API::HTTPCookieStore::flushDefaultUIProcessCookieStore): * UIProcess/API/APIHTTPCookieStore.h: * UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm: (API::HTTPCookieStore::flushDefaultUIProcessCookieStore): 2020-08-14 Kate Cheney Convert remaining SharedMemory::Handle to SharedMemory::IPCHandle https://bugs.webkit.org/show_bug.cgi?id=215471 Reviewed by David Kilzer. Use the new struct for sending SharedMemory::Handle objects via IPC, so we can include the exact size of data (SharedMemory::Handle::size() rounds up to the nearest page), and verify these sizes match when decoding. In many cases, the size is not sent as a separate argument via IPC, so we can initialize the IPCHandle object with SharedMemory::Handle::size(). We can remove the additional size parameter when it exists, because we are now passing IPCHandle which should include the size value. * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.messages.in: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: Send SharedMemory::IPCHandle object instead of SharedMemory::Handle over IPC. * NetworkProcess/ServiceWorker/WebSWOriginStore.cpp: (WebKit::WebSWOriginStore::sendStoreHandle): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * Platform/SharedMemory.h: Remove encode/decode functions in SharedMemory::Handle. * Platform/cocoa/SharedMemoryCocoa.cpp: (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. * Platform/unix/SharedMemoryUnix.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): * Platform/win/SharedMemoryWin.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. Remove SharedMemory::Handle encode/decode functions so we will not ever send a SharedMemory::Handle object over IPC accidentally in the future. * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::Handle::encode const): (WebKit::ShareableBitmap::Handle::decode): Keep m_size here because it is an IntSize object and is useful to check width/height parameters in the SharableBitmap object. * Shared/ShareableResource.cpp: (WebKit::ShareableResource::Handle::encode const): (WebKit::ShareableResource::Handle::decode): * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): * Shared/WebCoreArgumentCoders.cpp: (IPC::encodeSharedBuffer): (IPC::decodeSharedBuffer): * Shared/WebHitTestResultData.cpp: (WebKit::WebHitTestResultData::encode const): (WebKit::WebHitTestResultData::decode): More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::sendStoreHandleToProcess): * WebProcess/GPU/media/RemoteAudioBusData.h: (WebKit::RemoteAudioBusData::encode const): (WebKit::RemoteAudioBusData::decode): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * WebProcess/GPU/webrtc/AudioMediaStreamTrackRenderer.cpp: (WebKit::AudioMediaStreamTrackRenderer::storageChanged): * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::storageChanged): * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::setSWOriginTableSharedMemory): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/WebPage/VisitedLinkTableController.cpp: (WebKit::VisitedLinkTableController::setVisitedLinkTable): * WebProcess/WebPage/VisitedLinkTableController.h: * WebProcess/WebPage/VisitedLinkTableController.messages.in: * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: (WebKit::RemoteCaptureSampleManager::audioStorageChanged): * WebProcess/cocoa/RemoteCaptureSampleManager.h: * WebProcess/cocoa/RemoteCaptureSampleManager.messages.in: More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. 2020-08-14 Per Arne Vollan [Cocoa] Avoid changing XPC target queue inside XPC event handler https://bugs.webkit.org/show_bug.cgi?id=215460 Reviewed by Darin Adler. In WebProcess::handleXPCEndpointMessages we currently change the XPC target queue for the XPC bootstrap connection while under the XPC event handler. This sometimes causes simulated crashes on iOS and should be avoided. According to the documentation in https://developer.apple.com/documentation/xpc/1448786-xpc_connection_set_target_queue?language=objc, there does not seem to be anything saying this is a programming error, but the simulated crash claims otherwise. This patch addresses this issue by changing the initial target queue for the XPC bootstrap connection from the main thread queue to a queue on a secondary thread. The WebKit initializer function needs to be called on the main thread, which is done by synchronously dispatching the call on the main thread. This patch also stops changing the event handler for the bootstrap connection, but instead adds the additional XPC handling to the current event handler. No new tests, since this is covered by existing tests. The handling of the Launch Services XPC endpoint message that this patch changes, is used to receive the Launch Services database from the Networking process. The Launch Services database is used in MIME type mapping APIs, and many tests would fail if this database was not received in the WebContent process. * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm: (WebKit::XPCServiceEventHandler): * WebKit.xcodeproj/project.pbxproj: * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::platformDidReceiveLoadParameters): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::initializeConnection): * WebProcess/WebProcess.h: * WebProcess/cocoa/HandleXPCEndpointMessages.h: Added. * WebProcess/cocoa/HandleXPCEndpointMessages.mm: Added. (WebKit::handleXPCEndpointMessages): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::handleXPCEndpointMessages const): Deleted. 2020-08-14 Kate Cheney Convert SharedMemory::Handle to SharedMemory::IPCHandle WebPage image/pasteboard functions https://bugs.webkit.org/show_bug.cgi?id=215478 Reviewed by Chris Dumez. Convert SharedMemory::Handle objects to SharedMemory::IPCHandle objects which automatically verify the size of data being sent. We can remove the additional size parameter being sent in many IPC messages along with the handle, now that both are stored in the IPCHandle struct. * UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::setPromisedDataForImage): * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::getPasteboardBufferForType): No longer need size check, this is done in the IPCHandle::decode() function. (WebKit::WebPasteboardProxy::setPasteboardBufferForType): (WebKit::WebPasteboardProxy::readBufferFromPasteboard): * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * UIProcess/WebPasteboardProxy.cpp: (WebKit::WebPasteboardProxy::readBufferFromPasteboard): * UIProcess/WebPasteboardProxy.h: * UIProcess/WebPasteboardProxy.messages.in: * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::saveImageToLibrary): * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::dataSelectionForPasteboard): No longer need size check, this is done in the IPCHandle::decode() function. (WebKit::WebPageProxy::setPromisedDataForImage): * WebProcess/Plugins/PDF/PDFPlugin.mm: (WebKit::PDFPlugin::writeItemsToPasteboard): * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: (WebKit::WebPlatformStrategies::bufferForType): (WebKit::WebPlatformStrategies::setBufferForType): (WebKit::WebPlatformStrategies::readBufferFromPasteboard): No longer need size check, this is done in the IPCHandle::decode() function. * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: (WebKit::WebDragClient::declareAndWriteDragImage): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getDataSelectionForPasteboard): (WebKit::WebPage::performActionOnElement): * WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::getDataSelectionForPasteboard): 2020-08-14 Wenson Hsieh Unreviewed, revert r265213 and r265441 https://bugs.webkit.org/show_bug.cgi?id=215089 This logging is no longer needed, since the test seems to be passing reliably in internal automation now. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView selectAllForWebView:]): 2020-08-13 Carlos Garcia Campos [GTK4] Notify the web process on drag leave https://bugs.webkit.org/show_bug.cgi?id=215373 Reviewed by Adrian Perez de Castro. We missed this when implemented drag and drop support for GTK4. * UIProcess/API/gtk/DropTargetGtk4.cpp: (WebKit::DropTarget::leave): Call dragExited() and resetCurrentDragInformation() on WebPageProxy. 2020-08-13 Carlos Garcia Campos [GTK] Do not accept drag operations when the matched target list is empty https://bugs.webkit.org/show_bug.cgi?id=215372 Reviewed by Adrian Perez de Castro. Do not initialize m_selectionData if we don't have valid targets. * UIProcess/API/gtk/DropTargetGtk3.cpp: (WebKit::DropTarget::accept): (WebKit::DropTarget::leaveTimerFired): 2020-08-13 Brady Eidson (WK2 only) gamepad mapping stops being reported as “standard” in new tabs. rdar://problem/66946505 and https://bugs.webkit.org/show_bug.cgi?id=215486 Reviewed by Tim Horton. Covered by new API test. Get rid of the premature optimization that was "full gamepaddata" vs "condensed gamepaddata" In practice, the actual button and axis values are larger than the mapping and id, so not much IPC was being saved. * Shared/Gamepad/GamepadData.cpp: * Shared/Gamepad/GamepadData.h: * UIProcess/Gamepad/UIGamepad.cpp: (WebKit::UIGamepad::gamepadData const): (WebKit::UIGamepad::condensedGamepadData const): Deleted. (WebKit::UIGamepad::fullGamepadData const): Deleted. * UIProcess/Gamepad/UIGamepad.h: * UIProcess/Gamepad/UIGamepadProvider.cpp: (WebKit::UIGamepadProvider::snapshotGamepads): * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::gamepadConnected): 2020-08-13 Kate Cheney Create SharedMemory::IPCHandle object to validate the size of SharedMemory::Handle objects sent over IPC https://bugs.webkit.org/show_bug.cgi?id=215288 Reviewed by David Kilzer. Part 1 of a multi-patch plan to convert all SharedMemory::Handle objects being sent over IPC to use SharedMemory::IPCHandle objects instead. * Platform/SharedMemory.h: (WebKit::SharedMemory::IPCHandle::IPCHandle): * Platform/cocoa/SharedMemoryCocoa.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): Validate the size of the data sent in the IPCHandle::decode() function. * Platform/unix/SharedMemoryUnix.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): * Platform/win/SharedMemoryWin.cpp: Implement IPCHandle encode and decode for all platforms for when we remove SharedMemory::Handle encode/decode functions. 2020-08-13 Adrian Perez de Castro Unreviewed non-unified build fix. No new tests needed. * WebProcess/FullScreen/WebFullScreenManager.cpp: (WebKit::WebFullScreenManager::requestEnterFullScreen): Add missing WebCore:: namespace prefix to usage of WebCore::FullscreenManager. 2020-08-13 Chris Dumez REGRESSION (r260684): Messages YouTube inline video: after Multitasking away and Back, Audio is heard but icon indicates "muted" https://bugs.webkit.org/show_bug.cgi?id=215453 Reviewed by Tim Horton. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setIsDoingSnapshotSequence): (WebKit::WebPageProxy::setShouldFireEvents): Deleted. * UIProcess/WebPageProxy.h: * UIProcess/ios/WKApplicationStateTrackingView.mm: (-[WKApplicationStateTrackingView _willBeginSnapshotSequence]): (-[WKApplicationStateTrackingView _didCompleteSnapshotSequence]): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setIsDoingSnapshotSequence): (WebKit::WebPage::setShouldFireEvents): Deleted. * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: 2020-08-13 Per Arne Vollan Unreviewed, reverting r265520. Invalid sandbox change Reverted changeset: "[macOS] Deny access to directory for compiled WebKit sandboxes" https://bugs.webkit.org/show_bug.cgi?id=215384 https://trac.webkit.org/changeset/265520 2020-08-12 Keith Rollin Remove the need for defining USE_NEW_BUILD_SYSTEM https://bugs.webkit.org/show_bug.cgi?id=215439 Reviewed by Darin Adler. When building WebKit for XCBuild, we currently require that the external build system (such as the Makefile, build-webkit, etc.) defines the USE_NEW_BUILD_SYSTEM=YES build setting. This build setting controls parts of our build instructions that are sensitive to when XCBuild or the Legacy build system are being used. Notably, we need to know when to use our custom “copy and modify” scripts with copying certain header files (used with the Legacy build system) vs. using the enhanced Copy Headers build phase that’s enabled with APPLY_RULES_IN_COPY_HEADERS=YES (introduced with and used by XCBuild). The choice of which method to copy headers is used is controlled by USE_NEW_BUILD_SYSTEM. There is no built-in build setting that we can probe to help us determine which approach to take when copying and modifying headers, which is why we need to define USE_NEW_BUILD_SYSTEM ourselves. But it turns out that we can *detect* which build system is being used by taking advantage of a subtle difference between the two systems. As noted in: https://developer.apple.com/documentation/xcode-release-notes/build-system-release-notes-for-xcode-10 “When an .xcconfig file contains multiple assignments of the same build setting, later assignments using $(inherited) or $() will inherit from earlier assignments in the .xcconfig. The legacy build system caused every use of $(inherited) or $() skip any other values defined within the .xcconfig.” This difference can be exploited as follows: WK_WHICH_BUILD_SYSTEM = not_ WK_WHICH_BUILD_SYSTEM = $(inherited)legacy WK_USE_NEW_BUILD_SYSTEM = $(WK_USE_NEW_BUILD_SYSTEM_$(WK_WHICH_BUILD_SYSTEM)) WK_USE_NEW_BUILD_SYSTEM_legacy = NO WK_USE_NEW_BUILD_SYSTEM_not_legacy = YES We can then use WK_USE_NEW_BUILD_SYSTEM where we used to use the externally-defined USE_NEW_BUILD_SYSTEM. No new tests -- no new or changed functionality. * Configurations/Base.xcconfig: * Configurations/WebKit.xcconfig: * WebKit.xcodeproj/project.pbxproj: 2020-08-12 Alex Christensen Fail preconnect requests to deprecated TLS instead of allowing application to show warning https://bugs.webkit.org/show_bug.cgi?id=215424 Reviewed by Geoffrey Garen. Preconnecting is just a suggestion, so if the content really wants to load something from the deprecated TLS server, we will see the warning when the load actually happens. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]): 2020-08-12 Brent Fulgham [iOS] Allow additional iokit-get-property to support HEIF images https://bugs.webkit.org/show_bug.cgi?id=215431 Reviewed by Per Arne Vollan. Allow the WebContent process to read the HEVCCanDecodeTileToCanvas property. * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb: 2020-08-12 Per Arne Vollan [macOS] Fix iokit get property sandbox violation https://bugs.webkit.org/show_bug.cgi?id=215430 Reviewed by Brent Fulgham. The WebContent process' sandbox on macOS needs to allow querying the iokit property "acoustic-id". * WebProcess/com.apple.WebProcess.sb.in: 2020-08-12 Peng Liu Add the support to return to element fullscreen from picture-in-picture https://bugs.webkit.org/show_bug.cgi?id=215305 Reviewed by Jer Noble. This patch replaces WKFullScreenViewControllerVideoFullscreenModelClient with WKFullScreenWindowControllerVideoFullscreenModelClient. We need to do that because the instance of WKFullScreenViewControllerVideoFullscreenModelClient will be destroyed after the container element exits fullscreen while the video element enters picture-in-picture. The instance of WKFullScreenWindowControllerVideoFullscreenModelClient will always exist when the WKFullScreenWindowController instance is alive, so that it can receive callbacks from the VideoFullscreenInterfaceAVKit instance to implement the "return to element fullscreen from picture-in-picture" feature. This patch supports the following transitions: element fullscreen -> picture-in-picture (through user gestures) element fullscreen -> picture-in-picture (through the PiP button) picture-in-picture -> element fullscreen (when the tab is visible) picture-in-picture -> element fullscreen (when the tab is invisible) picture-in-picture -> element fullscreen (when the browser is in background) picture-in-picture -> inline (when the browser is in foreground) exit picture-in-picture when the browser is in background * UIProcess/Cocoa/VideoFullscreenManagerProxy.h: * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm: (WebKit::VideoFullscreenModelContext::fullscreenWillReturnToInline): (WebKit::VideoFullscreenModelContext::prepareToExitFullscreen): Notify clients to prepare for the stop of fullscreen/picture-in-picture. (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID): Fix issues that increase the client count unnecessarily. (WebKit::VideoFullscreenManagerProxy::preparedToReturnToInline): Call m_page->fullscreenMayReturnToInline() earlier. (WebKit::VideoFullscreenManagerProxy::fullscreenMayReturnToInline): Ditto. (WebKit::VideoFullscreenManagerProxy::fullscreenWillReturnToInline): Notify VideoFullscreenManager to prepare for exiting picture-in-picture or video fullscreen and report the destination rectangle of the exit picture-in-picture or video fullscreen animations. * UIProcess/WebFullScreenManagerProxy.cpp: (WebKit::WebFullScreenManagerProxy::requestEnterFullScreen): * UIProcess/WebFullScreenManagerProxy.h: Add a function requestEnterFullScreen() so that we can request an element to enter fullscreen from the UI process side. * UIProcess/ios/fullscreen/WKFullScreenViewController.h: * UIProcess/ios/fullscreen/WKFullScreenViewController.mm: (-[WKFullScreenViewController initWithWebView:]): (-[WKFullScreenViewController dealloc]): (-[WKFullScreenViewController videoControlsManagerDidChange]): (-[WKFullScreenViewController setAnimatingViewAlpha:]): (-[WKFullScreenViewController _cancelAction:]): (WKFullScreenViewControllerVideoFullscreenModelClient::setParent): Deleted. (WKFullScreenViewControllerVideoFullscreenModelClient::setInterface): Deleted. (WKFullScreenViewControllerVideoFullscreenModelClient::interface const): Deleted. (-[WKFullScreenViewController willEnterPictureInPicture]): Deleted. (-[WKFullScreenViewController didEnterPictureInPicture]): Deleted. (-[WKFullScreenViewController failedToEnterPictureInPicture]): Deleted. Minor clean-ups and remove code related to WKFullScreenViewControllerVideoFullscreenModelClient. * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.h: * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm: (WKFullScreenWindowControllerVideoFullscreenModelClient::setParent): (WKFullScreenWindowControllerVideoFullscreenModelClient::setInterface): (WKFullScreenWindowControllerVideoFullscreenModelClient::interface const): (-[WKFullScreenWindowController initWithWebView:]): (-[WKFullScreenWindowController dealloc]): (-[WKFullScreenWindowController enterFullScreen]): (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]): (-[WKFullScreenWindowController requestEnterFullScreen]): (-[WKFullScreenWindowController requestExitFullScreen]): (-[WKFullScreenWindowController _completedExitFullScreen]): (-[WKFullScreenWindowController videoControlsManagerDidChange]): (-[WKFullScreenWindowController willEnterPictureInPicture]): (-[WKFullScreenWindowController didEnterPictureInPicture]): (-[WKFullScreenWindowController failedToEnterPictureInPicture]): (-[WKFullScreenWindowController prepareToExitPictureInPicture]): (-[WKFullScreenWindowController didExitPictureInPicture]): Add WKFullScreenWindowControllerVideoFullscreenModelClient and implement the support to "restore fullscreen from picture-in-picture". * WebProcess/FullScreen/WebFullScreenManager.cpp: (WebKit::WebFullScreenManager::enterFullScreenForElement): (WebKit::WebFullScreenManager::requestEnterFullScreen): * WebProcess/FullScreen/WebFullScreenManager.h: * WebProcess/FullScreen/WebFullScreenManager.messages.in: Add the interface requestEnterFullScreen() and the corresponding IPC message. * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::prepareForVideoFullscreen): * WebProcess/WebCoreSupport/WebChromeClient.h: Add the interface to prepare for video fullscreen standby. The web process can use this interface to create a VideoFullscreenManager instance to avoid the scenario that an IPC message comes from the VideoFullscreenManagerProxy but the VideoFullscreenManager instance is not constructed yet. * WebProcess/cocoa/VideoFullscreenManager.h: * WebProcess/cocoa/VideoFullscreenManager.messages.in: * WebProcess/cocoa/VideoFullscreenManager.mm: (WebKit::VideoFullscreenManager::fullscreenWillReturnToInline): (WebKit::VideoFullscreenManager::fullscreenMayReturnToInline): Deleted. Rename fullscreenMayReturnToInline() to fullscreenWillReturnToInline(). In the UI process side, fullscreenMayReturnToInline() is used by VideoFullscreenManagerProxy to notify applications regarding UI changes (e.g., switch browser tabs). 2020-08-12 Wenson Hsieh WebPageProxy::registerEditCommand should be robust against invalid undo step identifiers https://bugs.webkit.org/show_bug.cgi?id=215412 Reviewed by Tim Horton. Add a `MESSAGE_CHECK` to avoid ever creating a `WebEditCommandProxy` with an invalid command identifier. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::registerEditCommand): 2020-08-12 Youenn Fablet Refresh WritableStream up to spec https://bugs.webkit.org/show_bug.cgi?id=215267 Reviewed by Geoff Garen. * Shared/WebPreferences.yaml: Add a dedicated runtime flag, off by default. 2020-08-12 Youenn Fablet Enable H264 low latency code path by default for MacOS https://bugs.webkit.org/show_bug.cgi?id=215371 Reviewed by Eric Carlson. Covered by existing tests, in particular platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html. * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultWebRTCH264LowLatencyEncoderEnabled): 2020-08-12 Carlos Garcia Campos REGRESSION(r261570): [GTK] Fails to send drop event to JavaScript https://bugs.webkit.org/show_bug.cgi?id=215032 Reviewed by Darin Adler. Handle custom data in drag and drop operations. * UIProcess/API/gtk/DragSourceGtk3.cpp: (WebKit::DragSource::DragSource): (WebKit::DragSource::begin): * UIProcess/API/gtk/DragSourceGtk4.cpp: (WebKit::DragSource::begin): * UIProcess/API/gtk/DropTargetGtk3.cpp: (WebKit::DropTarget::DropTarget): (WebKit::DropTarget::accept): (WebKit::DropTarget::dataReceived): * UIProcess/API/gtk/DropTargetGtk4.cpp: (WebKit::DropTarget::DropTarget): (WebKit::DropTarget::accept): 2020-08-11 Jer Noble [Mac] Add Experimental Feature preference for SW VP9 https://bugs.webkit.org/show_bug.cgi?id=215043 Reviewed by Beth Dakin. * FeatureFlags/WebKit.plist: * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): * Shared/WebPageCreationParameters.h: * Shared/WebPreferences.yaml: * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultVP9SWDecoderEnabledOnBattery): * Shared/WebPreferencesDefaultValues.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::creationParameters): * WebProcess/WebPage/WebPage.cpp: (WebKit::m_limitsNavigationsToAppBoundDomains): * WebProcess/WebProcess.cpp: (WebKit::WebProcess::enableVP9Decoder): (WebKit::WebProcess::enableVP9SWDecoder): * WebProcess/WebProcess.h: 2020-08-11 Brady Eidson Add a "use stored credentials" setting to WKWebView. and https://bugs.webkit.org/show_bug.cgi?id=215388 Reviewed by Geoff Garen. * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::preconnectTo): * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode const): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _canUseCredentialStorage]): (-[WKWebView _setCanUseCredentialStorage:]): * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::preconnectTo): (WebKit::WebPageProxy::setCanUseCredentialStorage): (WebKit::WebPageProxy::creationParameters): * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::canUseCredentialStorage): * WebProcess/Network/WebLoaderStrategy.cpp: (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): * WebProcess/WebPage/WebPage.cpp: (WebKit::m_limitsNavigationsToAppBoundDomains): (WebKit::WebPage::setCanUseCredentialStorage): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: 2020-08-11 Per Arne Vollan [macOS] Deny access to directory for compiled WebKit sandboxes https://bugs.webkit.org/show_bug.cgi?id=215384 Reviewed by Brent Fulgham. A WebKit process on macOS should not be allowed access to the directory containing compiled sandboxes after entering the sandbox itself. * GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in: * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: * WebProcess/com.apple.WebProcess.sb.in: 2020-08-11 Tim Horton iOS: Scrolling and touch events sporadically stop working after navigating https://bugs.webkit.org/show_bug.cgi?id=215368 Reviewed by Wenson Hsieh. Test: fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html WebPageProxy::handlePreventableTouchEvent keeps a counter of the number of outstanding "preventable" touch events that it is waiting to hear from the Web Content process about. This counter is incremented when the event is dispatched to the Web Content process's EventHandler queue, and decremented when the reply (whether it was handled or not) comes back from the Web Content process. While the counter is non-zero, all deferrable gestures remain deferred (and when it returns to zero, the WKDeferringGestureRecognizer gate is lifted, and events are allowed to flow). This means that it is very important that every event eventually reply about its handling status. Before this change, when the Web Content process is navigating, and reaches didCommitLoad, it cleared all queued touch events, without replying to to the UI process. Thus, there is a small window of time in which an incoming touch event will end up in the queue, *not* get dispatched/replied, and then get dropped on the floor in didCommitLoad. Most events do not meet this fate, because they are handled promptly, and commitLoad/didCommitLoad tend to be very quick. However, if the Web Content process ends up spending any significant amount of time under commitLoad (say, in an unload handler, or in media frameworks), any incoming touch events during that time will get lost, and the UI process' count of outstanding events will end up getting stuck non-zero. Fix this by always pretending that the page ate any events that were outstanding when didCommitLoad occurs, instead of just dropping them on the floor. * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::doneWithTouchEvent): * WebProcess/WebPage/EventDispatcher.cpp: (WebKit::EventDispatcher::takeQueuedTouchEventsForPage): (WebKit::EventDispatcher::clearQueuedTouchEventsForPage): Deleted. (WebKit::EventDispatcher::getQueuedTouchEventsForPage): Deleted. Also, rename getQueuedTouchEventsForPage to takeQueuedTouchEventsForPage, since it removes the queue from EventDispatcher's set. * WebProcess/WebPage/EventDispatcher.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::touchEventSync): (WebKit::WebPage::didCommitLoad): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::cancelAsynchronousTouchEvents): 2020-08-11 Philippe Normand [GStreamer] gst-full standalone library support https://bugs.webkit.org/show_bug.cgi?id=215262 Reviewed by Xabier Rodriguez-Calvar. Disable missing-plugins handling when gst-full is in use. The plugin installer doesn't make much sense for this scenario. * PlatformWPE.cmake: * UIProcess/API/glib/WebKitInstallMissingMediaPluginsPermissionRequest.cpp: (webkitInstallMissingMediaPluginsPermissionRequestAllow): (webkitInstallMissingMediaPluginsPermissionRequestDeny): (webkit_install_missing_media_plugins_permission_request_get_description): * UIProcess/API/glib/WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h: * UIProcess/API/glib/WebKitWebView.cpp: (webkitWebViewRequestInstallMissingMediaPlugins): * UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp: * UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.h: * UIProcess/gstreamer/WebPageProxyGStreamer.cpp: (WebKit::WebPageProxy::requestInstallMissingMediaPlugins): 2020-08-10 Chris Dumez AuxiliaryProcess::didReceiveInvalidMessage() for WebPage::PerformDragControllerAction IPC https://bugs.webkit.org/show_bug.cgi?id=215341 Reviewed by Alex Christensen. DragApplicationFlags is an enum containing flags. It was being sent over IPC as a DragApplicationFlags instead of an OptionSet, and thus would fail enum value validation when decoding when more than one flag is set. * Scripts/webkit/messages.py: * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder::decode): * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::applicationFlagsForDrag): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::performDragControllerAction): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: 2020-08-10 David Kilzer Use RefPtr for WebKit::WebOpenPanelResultListenerProxy Reviewed by Geoffrey Garen. Unable to create an API test for this. * UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::UIClient::runOpenPanel): - Use RefPtr when passing `listener` into the block. 2020-08-10 Wenson Hsieh Add more logging to diagnose editing/selection/ios/select-all-non-editable-text-using-keyboard.html https://bugs.webkit.org/show_bug.cgi?id=215089 Reviewed by Tim Horton. Remove some unnecessary declarations that were only used for debug logging in WebKitTestRunner, and add some more logging to check whether the web view is even getting a call to select all from UIKit. * Platform/spi/ios/UIKitSPI.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView selectAllForWebView:]): 2020-08-10 Sihui Liu Always suspend IDB work when network process is prepared to suspend https://bugs.webkit.org/show_bug.cgi?id=215239 Reviewed by Geoffrey Garen. We do not suspend IDB work in the network process when there is an ongoing transaction because the network process is going to ask the UI process to hold a background process assertion for it. However, it is possible that the request from the network process does not reach the UI process in time: RunningBoard may already decide to suspend the network process after app is backgrounded and UI process drops the foreground assertion for the network process. In this case, IDB in the network process would continue its transaction and the network process will be killed when it becomes suspened for holding database file locks. A network process crash can lead to a worse result than suspending IDB work, which aborts ongoing transactions, because it will destroy all database connections and transaction. Therefore, let's just suspend IDB work when the network process receives prepareToSuspend message. * NetworkProcess/IndexedDB/WebIDBServer.cpp: (WebKit::WebIDBServer::suspend): * NetworkProcess/IndexedDB/WebIDBServer.h: * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::prepareToSuspend): 2020-08-10 Per Arne Vollan Add required entitlement for Catalyst https://bugs.webkit.org/show_bug.cgi?id=215244 Reviewed by Darin Adler. The entitlement 'com.apple.private.webkit.use-xpc-endpoint' should be added to the WebContent process on Catalyst as well, since it is needed on all Apple platforms. This entitlement is needed to support direct XPC communication between WebKit processes, which is used to send the Launch Services database to the WebContent process from the Networking process. Also, add some more logging related to this, to detect if it takes a long time for the WebContent process to receive the database. * Scripts/process-entitlements.sh: * WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::platformDidReceiveLoadParameters): 2020-08-09 Said Abou-Hallawa [macOS] Drag/drop an image of a unsupported format to an file input element should convert it to a supported format https://bugs.webkit.org/show_bug.cgi?id=212482 Reviewed by Darin Adler. Move ImageUtilities.h and ImageUtilitiesCG.cpp from WebKit to WebCore. Use the image transcoding functions and shared WorkQueue from WebCore. * Platform/ImageUtilities.h: Removed. * Platform/cg: Removed. * SourcesCocoa.txt: * UIProcess/WebPageProxy.cpp: (WebKit::m_limitsNavigationsToAppBoundDomains): (WebKit::WebPageProxy::didChooseFilesForOpenPanelWithImageTranscoding): (WebKit::m_transcodingQueue): Deleted. * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: 2020-08-08 Wenson Hsieh [ iOS wk2 ] editing/pasteboard/paste-without-nesting.html is a flaky failure https://bugs.webkit.org/show_bug.cgi?id=215218 Reviewed by Darin Adler. This test writes to the system pasteboard using `document.execCommand("Copy")`, and then immediately reads from the system pasteboard by triggering `document.execCommand("Paste")`. On rare occasions, this fails on iOS, where IPC messages for writing content to the pasteboard (e.g. `WebPasteboardProxy::WriteWebContentToPasteboard`) are asynchronous, but the IPC message to get the pasteboard change count before pasting (`GetPasteboardChangeCount`) is synchronous. This means that `Connection` may end up dispatching the sync `GetPasteboardChangeCount` IPC message before dispatching `WriteWebContentToPasteboard`, which causes the pasteboard read to fail, because the contents on the pasteboard have changed after starting to read from the pasteboard. Note that this is not a problem on macOS since all pasteboard writing IPC is synchronous. Instead of turning all of the async iOS pasteboard writing messages synchronous as well, we can fix this by adding a mechanism in `WebProcess` to keep track of outgoing async pasteboard write messages; then, before attempting to grab the change count when we start reading, wait for any of these pending async writes to finish before we continue. In a future patch, we could actually adopt this same mechanism in `SetPasteboardTypes` and neighboring IPC messages to turn these all asynchronous. * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::writeURLToPasteboard): (WebKit::WebPasteboardProxy::writeWebContentToPasteboard): (WebKit::WebPasteboardProxy::writeImageToPasteboard): (WebKit::WebPasteboardProxy::writeStringToPasteboard): Call `didWriteToPasteboardAsynchronously` after we finish writing to the pasteboard asynchronously. * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: (WebKit::WebPlatformStrategies::changeCount): Before accessing changeCount, wait until any asynchronous calls to write to the system pasteboard have finished. (WebKit::WebPlatformStrategies::writeToPasteboard): Right before we send an async message to the UI process to write to the system pasteboard, notify `WebProcess` so that it can keep track of pending clipboard writes. * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::willWriteToPasteboardAsynchronously): (WebKit::WebProcess::didWriteToPasteboardAsynchronously): (WebKit::WebProcess::waitForPendingPasteboardWritesToFinish): Wait for a maximum of 1 second for any outgoing pasteboard writing messages to return to the web process. 2020-08-07 Chris Dumez baseLatency attribute is missing on AudioContext interface https://bugs.webkit.org/show_bug.cgi?id=215277 Reviewed by Eric Carlson. * GPUProcess/media/RemoteAudioDestinationManager.cpp: (WebKit::RemoteAudioDestination::framesPerBuffer const): (WebKit::RemoteAudioDestinationManager::createAudioDestination): * GPUProcess/media/RemoteAudioDestinationManager.h: * GPUProcess/media/RemoteAudioDestinationManager.messages.in: * WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp: (WebKit::RemoteAudioDestinationProxy::RemoteAudioDestinationProxy): * WebProcess/GPU/media/RemoteAudioDestinationProxy.h: 2020-08-07 John Wilander Experimental: Cap the expiry of persistent cookies set in 3rd-party CNAME cloaked HTTP responses https://bugs.webkit.org/show_bug.cgi?id=215201 Reviewed by Brent Fulgham. Also reviewed and commented on by Chris Dumez, Jiten Mehta, Sam Weinig, and Alex Christensen. This experimental feature is off by default. CNAME cloaking means a host resolves to a a different domain, potentially a third-party domain, as part of DNS resolution. This patch makes WebKit::NetworkDataTaskCocoa capture any CNAME cloaking for the first party host and stores it in a table in the WebKit::NetworkSession. It then checks first party subresource loads to see if they resolve to a different domain and if so, compare that domain to both the first party domain and its CNAME cloaking domain, if there is one. If there's a mismatch, it's deemed a case of third-party CNAME cloaking and any cookies set in the response of the cloaked subresource load will have their expiry capped to 7 days. The cases for capping expiry look like this (and are backed by test cases): First-party host | First-party subdomain | Capped expiry ------------------|----------------------------|-------------- No CNAME cloaking | No CNAME cloaking | No No CNAME cloaking | First-party CNAME cloaking | No No CNAME cloaking | Third-party CNAME cloaking | Yes CNAME cloaking | No CNAME cloaking | No CNAME cloaking | Matching CNAME cloaking | No CNAME cloaking | First-party CNAME cloaking | No CNAME cloaking | Third-party CNAME cloaking | Yes This patch makes use of two new CFNetwork SPIs on NSURLSessionTask: - _cookieTransformCallback - _resolvedCNAMEChain * NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::resetParametersToDefaultValues): This reset now covers the new CNAME cloaking member variables. (WebKit::NetworkProcess::setIsRunningResourceLoadStatisticsTest): This function now also enables the CNAME cloaking code. (WebKit::NetworkProcess::setFirstPartyHostCNAMEDomainForTesting): (WebKit::NetworkProcess::setThirdPartyCNAMEDomainForTesting): * NetworkProcess/NetworkProcess.h: * NetworkProcess/NetworkProcess.messages.in: New IPC to forward test configuration. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): Now picks up the flag for this feature. (WebKit::NetworkSession::setFirstPartyHostCNAMEDomain): This is called from NetworkDataTaskCocoa::updateFirstPartyInfoForTaskAndSession() when there is CNAME cloaking for the first party host. This is done to make it possible to not cap the expiry of cookies if subsequent subresource loads have CNAME cloaking that matches the first-party host's CNAME cloaking. This happens when whole websites are hosted on edge networks. This function is also used by the test infrastructure to mock the DNS resolution for a first-party host. (WebKit::NetworkSession::firstPartyHostCNAMEDomain): This returns any captured CNAME cloaking for a host, if there is one. (WebKit::NetworkSession::resetCNAMEDomainData): * NetworkProcess/NetworkSession.h: (WebKit::NetworkSession::setCNAMECloakingMitigationEnabled): (WebKit::NetworkSession::cnameCloakingMitigationEnabled const): (WebKit::NetworkSession::setThirdPartyCNAMEDomainForTesting): This test functions allows us to mock the DNS resolution for a subresource. (WebKit::NetworkSession::thirdPartyCNAMEDomainForTesting const): * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::hasCNAMEAndCookieTransformSPI): (WebKit::lastCNAMEDomain): (WebKit::NetworkDataTaskCocoa::updateFirstPartyInfoForSession): This is called by NetworkDataTaskCocoa::didReceiveResponse() to capture any CNAME cloaking for the first-party host. (WebKit::NetworkDataTaskCocoa::applyCookiePolicyForThirdPartyCNAMECloaking): This is called in the NetworkDataTaskCocoa constructor and in NetworkDataTaskCocoa::willPerformHTTPRedirection() and sets the new _cookieTransformCallback SPI property on the task which will check the response for any third-party CNAME cloaking and cap the expiry of incoming cookies accordingly. (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): This now calls NetworkDataTaskCocoa::applyCookiePolicyForThirdPartyCNAMECloaking(). (WebKit::NetworkDataTaskCocoa::didReceiveResponse): This now calls NetworkDataTaskCocoa::updateFirstPartyInfoForTaskAndSession(). (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): This now calls NetworkDataTaskCocoa::applyCookiePolicyForThirdPartyCNAMECloaking(). * Shared/ResourceLoadStatisticsParameters.h: Now holds a WebCore::CNAMECloakingMitigationEnabled flag. (WebKit::ResourceLoadStatisticsParameters::encode const): (WebKit::ResourceLoadStatisticsParameters::decode): * Shared/WebPreferences.yaml: * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: (WKWebsiteDataStoreSetResourceLoadStatisticsFirstPartyHostCNAMEDomainForTesting): Used to mock CNAME resolution data. (WKWebsiteDataStoreSetResourceLoadStatisticsThirdPartyCNAMEDomainForTesting): Used to mock CNAME resolution data. * UIProcess/API/C/WKWebsiteDataStoreRef.h: * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::setFirstPartyHostCNAMEDomainForTesting): (WebKit::NetworkProcessProxy::setThirdPartyCNAMEDomainForTesting): * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::ensureNetworkProcess): Now handles the WebCore::CNAMECloakingMitigationEnabled flag. * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::platformSetNetworkParameters): Now handles the WebCore::CNAMECloakingMitigationEnabled flag. * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::setResourceLoadStatisticsFirstPartyHostCNAMEDomainForTesting): (WebKit::WebsiteDataStore::setResourceLoadStatisticsThirdPartyCNAMEDomainForTesting): (WebKit::WebsiteDataStore::parameters): * UIProcess/WebsiteData/WebsiteDataStore.h: 2020-08-07 Wenson Hsieh Remove UIScriptController.removeAllDynamicDictionaries() https://bugs.webkit.org/show_bug.cgi?id=215207 Reviewed by Sam Weinig. See Tools/ChangeLog for more detail. * Platform/spi/ios/UIKitSPI.h: 2020-08-06 Kenneth Russell Implement createImageBitmap(ImageData) https://bugs.webkit.org/show_bug.cgi?id=183438 Reviewed by Dean Jackson. Add "AlphaPremultiplication destFormat" argument to putImageData, to handle creation of non-premultiplied ImageBitmaps from ImageData. * GPUProcess/graphics/RemoteImageBufferProxy.h: * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp: (WebKit::ImageBufferShareableBitmapBackend::putImageData): * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h: * WebProcess/GPU/graphics/RemoteImageBuffer.h: (WebKit::RemoteImageBuffer::putImageData): 2020-08-06 David Kilzer WTF::makeString() should handle enum values Reviewed by Sam Weinig. * Platform/IPC/cocoa/ConnectionCocoa.mm: (IPC::Connection::sendMessage): * Shared/Cocoa/AuxiliaryProcessCocoa.mm: (WebKit::AuxiliaryProcess::didReceiveInvalidMessage): - Update to take advantage of enum support in WTF::makeString(). 2020-08-06 Jer Noble [Mac,WK2] REGRESSION(r262322): ScreenTime overlay is hidden in fullscreen mode https://bugs.webkit.org/show_bug.cgi?id=215222 Reviewed by Eric Carlson. During a refactor, a call to -[NSWindow setAutodisplay:YES] was dropped (in addition to a call to NSEnableScreenUpdates(), but that has a 1s timeout so its effects aren't persistent). This meant all NSViews added to that window need -display called on them explicitly in order to paint, and so subviews like the ScreenTime overlay is never drawn. * UIProcess/mac/WKFullScreenWindowController.mm: (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]): 2020-08-06 Truitt Savell Unreviewed, reverting r265328. Broke 17 MediaRecorder tests. Reverted changeset: "Add support for MediaRecorder bitrate options" https://bugs.webkit.org/show_bug.cgi?id=214973 https://trac.webkit.org/changeset/265328 2020-08-06 Youenn Fablet Add support for MediaRecorder bitrate options https://bugs.webkit.org/show_bug.cgi?id=214973 Reviewed by Eric Carlson. Serialize options when creating remote media recorder. * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::create): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorderManager.cpp: (WebKit::RemoteMediaRecorderManager::createRecorder): * GPUProcess/webrtc/RemoteMediaRecorderManager.h: * GPUProcess/webrtc/RemoteMediaRecorderManager.messages.in: * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::MediaRecorderPrivate): (WebKit::MediaRecorderPrivate::startRecording): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: * WebProcess/GPU/webrtc/MediaRecorderProvider.cpp: (WebKit::MediaRecorderProvider::createMediaRecorderPrivate): * WebProcess/GPU/webrtc/MediaRecorderProvider.h: 2020-08-06 Adrian Perez de Castro [WPE][GTK] Wrong argument order for clone syscall seccomp filter on s390x https://bugs.webkit.org/show_bug.cgi?id=215212 Reviewed by Michael Catanzaro. Patch based on this Flatpak pull request: https://github.com/flatpak/flatpak/pull/3777 No new tests needed. * UIProcess/Launcher/glib/BubblewrapLauncher.cpp: (WebKit::setupSeccomp): Add preprocessor guard to choose the correct clone() system call argument on S390. 2020-08-06 James Savage Could not find module 'WebKit' for target 'armv7-apple-ios' Reviewed by Brady Eidson. * SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: Define SWIFT_MODULE_ONLY_ARCHS to emit other architectures. 2020-08-05 Tim Horton Remove all references to non-existent 10.16 https://bugs.webkit.org/show_bug.cgi?id=215202 Reviewed by Wenson Hsieh. * Configurations/Base.xcconfig: * Configurations/DebugRelease.xcconfig: * Configurations/Version.xcconfig: * Configurations/WebKitTargetConditionals.xcconfig: * Scripts/process-entitlements.sh: * WebProcess/com.apple.WebProcess.sb.in: 2020-08-05 Per Arne Vollan [Cocoa] Sandbox extension token not cleared from memory https://bugs.webkit.org/show_bug.cgi?id=215136 Reviewed by Geoffrey Garen. As a security mitigation, an invalidated sandbox extension should have its token cleared from memory. No new tests, covered by existing tests. * Shared/Cocoa/SandboxExtensionCocoa.mm: (WebKit::SandboxExtensionImpl::m_length): (WebKit::SandboxExtensionImpl::~SandboxExtensionImpl): 2020-08-05 Per Arne Vollan [Cocoa] Remove obsolete sandbox extension after r264178 https://bugs.webkit.org/show_bug.cgi?id=215154 Reviewed by Brent Fulgham. After r264178, the code related to issuing an extension to com.apple.lsd.mapdb is obsolete, and should be removed. No new tests, covered by existing tests. * 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/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): * WebProcess/com.apple.WebProcess.sb.in: 2020-08-05 Wenson Hsieh [iOS] Keyboard shortcuts and arrow key scrolling stop working after navigating via swipe gesture https://bugs.webkit.org/show_bug.cgi?id=215137 Reviewed by Tim Horton. The process of starting a navigation swipe gesture causes the first responder (in this case, WKContentView) to resign. Subsequently, nothing makes the content view first responder again once the navigation gesture ends, even if the gesture is cancelled and we don't end up navigating. This results in several symptoms, two of which are that keyboard shortcuts stop working, and pressing arrow keys does not scroll the web view after ending the swipe gesture. To mitigate this, add a mechanism to have the web view remember that our content view was first responder before calling `-startInteractiveTransition:`; after ending the interactive transition (i.e. swipe gesture), we then restore the web view's content view as first responder if it is not already first responder (and it is also parented, which is not the case when swiping back to close a newly opened tab in Safari). Test: NavigationSwipeTests.RestoreFirstResponderAfterNavigationSwipe NavigationSwipeTests.DoNotBecomeFirstResponderAfterNavigationSwipeIfWebViewIsUnparented * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/ios/WKWebViewIOS.mm: (-[WKWebView _navigationGestureDidBegin]): (-[WKWebView _navigationGestureDidEnd]): 2020-08-04 Brent Fulgham Unreviewed build fix after r265263 https://bugs.webkit.org/show_bug.cgi?id=215139 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): 2020-08-04 Devin Rousso "DoubleDown Casino" respin button stops working with trackpad https://bugs.webkit.org/show_bug.cgi?id=215146 Reviewed by Tim Horton. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView shouldUseMouseGestureRecognizer]): 2020-08-04 Per Arne Vollan [iOS] Issue a temporary extension to the MobileGestalt daemon when the MobileGestalt cache is invalid https://bugs.webkit.org/show_bug.cgi?id=214965 Unreviewed, address review comments. Add comment explaining why a set of MobileGestalt queries are performed when starting up the WebContent process on iOS. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-08-04 Per Arne Vollan [iOS] Check that Accessibility is enabled when receiving the enable Accessibility notification https://bugs.webkit.org/show_bug.cgi?id=215112 Reviewed by Youenn Fablet. As a security mitigation, return early when handling this notification if Accessibility is not enabled. API test: WebKit.AccessibilityHasNoPreferencesServiceAccessWhenPostingNotification * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::registerNotificationObservers): 2020-08-04 Brent Fulgham Limit 'com.apple.webkit.microphone' use to macOS and MacCatalyst https://bugs.webkit.org/show_bug.cgi?id=215139 Reviewed by Eric Carlson. We only need the 'com.apple.webkit.microphone' Sandbox Extension at startup on macOS and MacCatalyst (and even on those platforms, only until is fixed). We should not issue this extension on the iOS family of targets. * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeWebProcess): 2020-08-04 Per Arne Vollan [iOS Simulator] Assert under WebPage::platformDidReceiveLoadParameters https://bugs.webkit.org/show_bug.cgi?id=215108 Reviewed by Youenn Fablet. This asserts because it appears that the WebContent and Networking process do not have the required entitlement com.apple.private.webkit.use-xpc-endpoint on the iOS Simulator. Add the entitlement for simulator. No new tests, covered by existing tests. * Resources/ios/XPCService-embedded-simulator.entitlements: 2020-08-03 Wenson Hsieh Allow -accessoryDone to blur the focused element on iPad when AutoFilling strong passwords https://bugs.webkit.org/show_bug.cgi?id=215105 Reviewed by Tim Horton. `-accessoryDone` is now used to dismiss the strong password AutoFill keyboard after choosing a password on iOS, due to how it hides the keyboard without causing the content view to resign first responder; being stuck in a state where the content view is not first responder causes several issues when choosing strong passwords on iOS, such as keyboard shortcuts no longer working. On iPad, to ensure that `-accessoryDone` actually dismisses the keyboard, we need to additionally teach `-endEditingAndUpdateFocusAppearanceWithReason:` (when given `EndEditingReasonAccessoryDone`) to allow the focused element to blur when dismissing the strong password input view. Test: KeyboardInputTests.TestWebViewAccessoryDoneDuringStrongPasswordAssistance * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]): Refactor this logic into a local helper lambda with early returns, instead of using a single if statement. 2020-08-03 Youenn Fablet Move user gesture propagation over promise behind a feature flag https://bugs.webkit.org/show_bug.cgi?id=215014 Reviewed by Eric Carlson. Add a preference, on by default. * Shared/WebPreferences.yaml: 2020-08-03 Alex Christensen Null check parentProcessConnection when creating a NetworkDataTaskCocoa https://bugs.webkit.org/show_bug.cgi?id=215109 Reviewed by Chris Dumez. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (WebKit::NetworkSessionCocoa::sessionWrapperForTask): Null check parentProcessConnection. Otherwise, we can dereference null and crash between disconnecting with the parent process and terminating, which isn't the worst time to crash because we are trying to terminate anyways. But we may as well not crash. 2020-08-03 Wenson Hsieh Remove the ENABLE_DATA_INTERACTION feature flag https://bugs.webkit.org/show_bug.cgi?id=215091 Reviewed by Megan Gardner. * UIProcess/PageClient.h: * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.messages.in: * UIProcess/ios/DragDropInteractionState.h: * UIProcess/ios/DragDropInteractionState.mm: * UIProcess/ios/PageClientImplIOS.h: * UIProcess/ios/PageClientImplIOS.mm: * UIProcess/ios/WKContentViewInteraction.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView setUpInteraction]): (-[WKContentView cleanUpInteraction]): (-[WKContentView actionSheetAssistant:showCustomSheetForElement:]): * UIProcess/ios/WebPageProxyIOS.mm: * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/ios/WebPageIOS.mm: 2020-08-03 Tim Horton Fix the macCatalyst build * UIProcess/EndowmentStateTracker.mm: (WebKit::EndowmentStateTracker::stateFromEndowments): 2020-08-03 Per Arne Vollan Finalize the list of MobileGestalt queries needed to populate the in-memory cache in the WebContent process https://bugs.webkit.org/show_bug.cgi?id=215095 Reviewed by Geoffrey Garen. When the MobileGestalt cache is invalid, we issue a temporary extension to the MobileGestalt daemon for the WebContent process, which will populate the in-memory cache by doing a set of MobileGestalt queries before revoking the extension. This patch finalizes the list of MobileGestalt queries needed to populate the in-memory cache in the WebContent process on iOS before revoking the temporary extension to com.apple.mobilegestalt.xpc. This list was compiled by querying every possible MobileGestalt key after the temporary extension was revoked, and make a note of all queries that were contacting the MobileGestalt daemon to get the answer. The added queries in this patch should make the list complete, and ensures that all cachable values are in the in-memory cache before revoking the extension, since every possible MobileGestalt query was tested. This again means that users that have an invalid MobileGestalt cache, will have access to the exact same MobileGestalt values, as those users who have a valid MobileGestalt cache. * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): 2020-08-03 Wenson Hsieh [iOS 14] editing/selection/ios/select-all-non-editable-text-using-keyboard.html sometimes times out https://bugs.webkit.org/show_bug.cgi?id=215089 Reviewed by Tim Horton. * Platform/spi/ios/UIKitSPI.h: 2020-08-03 Devin Rousso should be able to request an editing context for a given region of a given input https://bugs.webkit.org/show_bug.cgi?id=215042 Reviewed by Wenson Hsieh. Right now, it's only possible to request an editing context for either an entire input element or a particular rect of the page. It should be possible to request an editing context for a particular rect within a given input element as well (e.g. get one paragraph or the currently selected text in a `