Diff
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2022-06-07 22:46:18 UTC (rev 295367)
@@ -543,26 +543,26 @@
void WebPageProxy::didChangePlaybackRate(PlaybackSessionContextIdentifier identifier)
{
if (m_currentFullscreenVideoSessionIdentifier == identifier)
- updateFullscreenVideoExtraction();
+ updateFullscreenVideoTextRecognition();
}
void WebPageProxy::didChangeCurrentTime(PlaybackSessionContextIdentifier identifier)
{
if (m_currentFullscreenVideoSessionIdentifier == identifier)
- updateFullscreenVideoExtraction();
+ updateFullscreenVideoTextRecognition();
}
-void WebPageProxy::updateFullscreenVideoExtraction()
+void WebPageProxy::updateFullscreenVideoTextRecognition()
{
- if (!pageClient().isFullscreenVideoExtractionEnabled())
+ if (!pageClient().isTextRecognitionInFullscreenVideoEnabled())
return;
if (m_currentFullscreenVideoSessionIdentifier && m_playbackSessionManager && m_playbackSessionManager->isPaused(*m_currentFullscreenVideoSessionIdentifier)) {
- m_fullscreenVideoExtractionTimer.startOneShot(250_ms);
+ m_fullscreenVideoTextRecognitionTimer.startOneShot(250_ms);
return;
}
- m_fullscreenVideoExtractionTimer.stop();
+ m_fullscreenVideoTextRecognitionTimer.stop();
if (!m_currentFullscreenVideoSessionIdentifier)
return;
@@ -569,11 +569,11 @@
#if PLATFORM(IOS_FAMILY)
if (RetainPtr controller = m_videoFullscreenManager->playerViewController(*m_currentFullscreenVideoSessionIdentifier))
- pageClient().cancelFullscreenVideoExtraction(controller.get());
+ pageClient().cancelTextRecognitionForFullscreenVideo(controller.get());
#endif
}
-void WebPageProxy::fullscreenVideoExtractionTimerFired()
+void WebPageProxy::fullscreenVideoTextRecognitionTimerFired()
{
if (!m_currentFullscreenVideoSessionIdentifier || !m_videoFullscreenManager)
return;
@@ -590,7 +590,7 @@
#if PLATFORM(IOS_FAMILY)
if (RetainPtr controller = fullscreenManager->playerViewController(identifier))
- protectedThis->pageClient().beginFullscreenVideoExtraction(imageHandle, controller.get());
+ protectedThis->pageClient().beginTextRecognitionForFullscreenVideo(imageHandle, controller.get());
#endif
});
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -678,8 +678,8 @@
void didFinishPresentation(WKRevealItemPresenter *);
#endif
- void beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle&, WebCore::FloatRect);
- void cancelElementFullscreenVideoExtraction();
+ void beginTextRecognitionForVideoInElementFullscreen(const ShareableBitmap::Handle&, WebCore::FloatRect);
+ void cancelTextRecognitionForVideoInElementFullscreen();
private:
#if HAVE(TOUCH_BAR)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2022-06-07 22:46:18 UTC (rev 295367)
@@ -5937,7 +5937,7 @@
#endif
}
-void WebViewImpl::beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle& bitmapHandle, WebCore::FloatRect bounds)
+void WebViewImpl::beginTextRecognitionForVideoInElementFullscreen(const ShareableBitmap::Handle& bitmapHandle, WebCore::FloatRect bounds)
{
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
auto imageBitmap = ShareableBitmap::create(bitmapHandle);
@@ -5966,7 +5966,7 @@
#endif
}
-void WebViewImpl::cancelElementFullscreenVideoExtraction()
+void WebViewImpl::cancelTextRecognitionForVideoInElementFullscreen()
{
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
if (auto identifier = std::exchange(m_currentImageAnalysisRequestID, 0))
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -500,13 +500,13 @@
virtual WebCore::Color contentViewBackgroundColor() = 0;
virtual String sceneID() = 0;
- virtual void beginFullscreenVideoExtraction(const ShareableBitmap::Handle&, AVPlayerViewController *) = 0;
- virtual void cancelFullscreenVideoExtraction(AVPlayerViewController *) = 0;
+ virtual void beginTextRecognitionForFullscreenVideo(const ShareableBitmap::Handle&, AVPlayerViewController *) = 0;
+ virtual void cancelTextRecognitionForFullscreenVideo(AVPlayerViewController *) = 0;
#endif
- virtual bool isFullscreenVideoExtractionEnabled() const { return false; }
+ virtual bool isTextRecognitionInFullscreenVideoEnabled() const { return false; }
- virtual void beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle&, WebCore::FloatRect) { }
- virtual void cancelElementFullscreenVideoExtraction() { }
+ virtual void beginTextRecognitionForVideoInElementFullscreen(const ShareableBitmap::Handle&, WebCore::FloatRect) { }
+ virtual void cancelTextRecognitionForVideoInElementFullscreen() { }
// Auxiliary Client Creation
#if ENABLE(FULLSCREEN_API)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2022-06-07 22:46:18 UTC (rev 295367)
@@ -520,7 +520,7 @@
#endif
, m_notificationManagerMessageHandler(*this)
#if ENABLE(VIDEO_PRESENTATION_MODE)
- , m_fullscreenVideoExtractionTimer(RunLoop::main(), this, &WebPageProxy::fullscreenVideoExtractionTimerFired)
+ , m_fullscreenVideoTextRecognitionTimer(RunLoop::main(), this, &WebPageProxy::fullscreenVideoTextRecognitionTimerFired)
#endif
{
WEBPAGEPROXY_RELEASE_LOG(Loading, "constructor:");
@@ -6094,7 +6094,7 @@
m_uiClient->didEnterFullscreen(this);
m_currentFullscreenVideoSessionIdentifier = identifier;
- updateFullscreenVideoExtraction();
+ updateFullscreenVideoTextRecognition();
}
void WebPageProxy::didExitFullscreen(PlaybackSessionContextIdentifier identifier)
@@ -6103,7 +6103,7 @@
if (m_currentFullscreenVideoSessionIdentifier == identifier) {
m_currentFullscreenVideoSessionIdentifier = std::nullopt;
- updateFullscreenVideoExtraction();
+ updateFullscreenVideoTextRecognition();
}
}
@@ -8259,7 +8259,7 @@
updatePlayingMediaDidChange(MediaProducer::IsNotPlaying);
#if ENABLE(VIDEO_PRESENTATION_MODE)
- m_fullscreenVideoExtractionTimer.stop();
+ m_fullscreenVideoTextRecognitionTimer.stop();
m_currentFullscreenVideoSessionIdentifier = std::nullopt;
#endif
@@ -11373,9 +11373,9 @@
m_uiClient->decidePolicyForModalContainer(types, WTFMove(completion));
}
-void WebPageProxy::extractVideoInElementFullScreen(MediaPlayerIdentifier identifier, FloatRect bounds)
+void WebPageProxy::beginTextRecognitionForVideoInElementFullScreen(MediaPlayerIdentifier identifier, FloatRect bounds)
{
- if (!pageClient().isFullscreenVideoExtractionEnabled())
+ if (!pageClient().isTextRecognitionInFullscreenVideoEnabled())
return;
#if ENABLE(GPU_PROCESS)
@@ -11383,14 +11383,14 @@
if (!gpuProcess)
return;
- m_hasPendingElementFullScreenVideoExtraction = true;
+ m_isPerformingTextRecognitionInElementFullScreen = true;
gpuProcess->requestBitmapImageForCurrentTime(m_process->coreProcessIdentifier(), identifier, [weakThis = WeakPtr { *this }, bounds](auto& bitmapHandle) {
RefPtr protectedThis = weakThis.get();
- if (!protectedThis || !protectedThis->m_hasPendingElementFullScreenVideoExtraction)
+ if (!protectedThis || !protectedThis->m_isPerformingTextRecognitionInElementFullScreen)
return;
- protectedThis->pageClient().beginElementFullscreenVideoExtraction(bitmapHandle, bounds);
- protectedThis->m_hasPendingElementFullScreenVideoExtraction = false;
+ protectedThis->pageClient().beginTextRecognitionForVideoInElementFullscreen(bitmapHandle, bounds);
+ protectedThis->m_isPerformingTextRecognitionInElementFullScreen = false;
});
#else
UNUSED_PARAM(identifier);
@@ -11398,13 +11398,13 @@
#endif
}
-void WebPageProxy::cancelVideoExtractionInElementFullScreen()
+void WebPageProxy::cancelTextRecognitionForVideoInElementFullScreen()
{
- if (!pageClient().isFullscreenVideoExtractionEnabled())
+ if (!pageClient().isTextRecognitionInFullscreenVideoEnabled())
return;
- m_hasPendingElementFullScreenVideoExtraction = false;
- pageClient().cancelElementFullscreenVideoExtraction();
+ m_isPerformingTextRecognitionInElementFullScreen = false;
+ pageClient().cancelTextRecognitionForVideoInElementFullscreen();
}
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -2102,8 +2102,8 @@
}
#endif
- void extractVideoInElementFullScreen(WebCore::MediaPlayerIdentifier, WebCore::FloatRect videoBounds);
- void cancelVideoExtractionInElementFullScreen();
+ void beginTextRecognitionForVideoInElementFullScreen(WebCore::MediaPlayerIdentifier, WebCore::FloatRect videoBounds);
+ void cancelTextRecognitionForVideoInElementFullScreen();
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
void replaceImageWithMarkupResults(const WebCore::ElementContext&, const Vector<String>& types, const IPC::DataReference&);
@@ -2677,8 +2677,8 @@
#endif
#if ENABLE(VIDEO_PRESENTATION_MODE)
- void updateFullscreenVideoExtraction();
- void fullscreenVideoExtractionTimerFired();
+ void updateFullscreenVideoTextRecognition();
+ void fullscreenVideoTextRecognitionTimerFired();
#endif
const Identifier m_identifier;
@@ -3265,9 +3265,9 @@
#if ENABLE(VIDEO_PRESENTATION_MODE)
std::optional<PlaybackSessionContextIdentifier> m_currentFullscreenVideoSessionIdentifier;
- RunLoop::Timer<WebPageProxy> m_fullscreenVideoExtractionTimer;
+ RunLoop::Timer<WebPageProxy> m_fullscreenVideoTextRecognitionTimer;
#endif
- bool m_hasPendingElementFullScreenVideoExtraction { false };
+ bool m_isPerformingTextRecognitionInElementFullScreen { false };
};
#ifdef __OBJC__
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2022-06-07 22:46:18 UTC (rev 295367)
@@ -378,8 +378,8 @@
DictationAlternatives(WebCore::DictationContext dictationContext) -> (Vector<String> alternatives) Synchronous
#endif
- ExtractVideoInElementFullScreen(WebCore::MediaPlayerIdentifier identifier, WebCore::FloatRect videoBounds)
- CancelVideoExtractionInElementFullScreen()
+ BeginTextRecognitionForVideoInElementFullScreen(WebCore::MediaPlayerIdentifier identifier, WebCore::FloatRect videoBounds)
+ CancelTextRecognitionForVideoInElementFullScreen()
#if PLATFORM(IOS_FAMILY)
CouldNotRestorePageState()
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -303,12 +303,12 @@
WebCore::Color contentViewBackgroundColor() final;
String sceneID() final;
- void beginFullscreenVideoExtraction(const ShareableBitmap::Handle&, AVPlayerViewController *) final;
- void cancelFullscreenVideoExtraction(AVPlayerViewController *) final;
- bool isFullscreenVideoExtractionEnabled() const final;
+ void beginTextRecognitionForFullscreenVideo(const ShareableBitmap::Handle&, AVPlayerViewController *) final;
+ void cancelTextRecognitionForFullscreenVideo(AVPlayerViewController *) final;
+ bool isTextRecognitionInFullscreenVideoEnabled() const final;
- void beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle&, WebCore::FloatRect) final;
- void cancelElementFullscreenVideoExtraction() final;
+ void beginTextRecognitionForVideoInElementFullscreen(const ShareableBitmap::Handle&, WebCore::FloatRect) final;
+ void cancelTextRecognitionForVideoInElementFullscreen() final;
bool hasResizableWindows() const final;
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2022-06-07 22:46:18 UTC (rev 295367)
@@ -1058,29 +1058,29 @@
return [m_contentView window].windowScene._sceneIdentifier;
}
-void PageClientImpl::beginFullscreenVideoExtraction(const ShareableBitmap::Handle& imageHandle, AVPlayerViewController *playerViewController)
+void PageClientImpl::beginTextRecognitionForFullscreenVideo(const ShareableBitmap::Handle& imageHandle, AVPlayerViewController *playerViewController)
{
- [m_contentView beginFullscreenVideoExtraction:imageHandle playerViewController:playerViewController];
+ [m_contentView beginTextRecognitionForFullscreenVideo:imageHandle playerViewController:playerViewController];
}
-void PageClientImpl::cancelFullscreenVideoExtraction(AVPlayerViewController *controller)
+void PageClientImpl::cancelTextRecognitionForFullscreenVideo(AVPlayerViewController *controller)
{
- [m_contentView cancelFullscreenVideoExtraction:controller];
+ [m_contentView cancelTextRecognitionForFullscreenVideo:controller];
}
-bool PageClientImpl::isFullscreenVideoExtractionEnabled() const
+bool PageClientImpl::isTextRecognitionInFullscreenVideoEnabled() const
{
- return [m_contentView isFullscreenVideoExtractionEnabled];
+ return [m_contentView isTextRecognitionInFullscreenVideoEnabled];
}
-void PageClientImpl::beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle& bitmapHandle, FloatRect bounds)
+void PageClientImpl::beginTextRecognitionForVideoInElementFullscreen(const ShareableBitmap::Handle& bitmapHandle, FloatRect bounds)
{
- [m_contentView beginElementFullscreenVideoExtraction:bitmapHandle bounds:bounds];
+ [m_contentView beginTextRecognitionForVideoInElementFullscreen:bitmapHandle bounds:bounds];
}
-void PageClientImpl::cancelElementFullscreenVideoExtraction()
+void PageClientImpl::cancelTextRecognitionForVideoInElementFullscreen()
{
- [m_contentView cancelElementFullscreenVideoExtraction];
+ [m_contentView cancelTextRecognitionForVideoInElementFullscreen];
}
bool PageClientImpl::hasResizableWindows() const
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -535,7 +535,7 @@
BOOL _hasVisualSearchResults;
#endif // USE(QUICK_LOOK)
#endif // ENABLE(IMAGE_ANALYSIS)
- uint32_t _fullscreenVideoExtractionRequestIdentifier;
+ uint32_t _fullscreenVideoImageAnalysisRequestIdentifier;
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
RetainPtr<VKCImageAnalysisInteraction> _imageAnalysisInteraction;
RetainPtr<NSMutableSet<UIButton *>> _imageAnalysisActionButtons;
@@ -804,12 +804,12 @@
- (void)requestRectForFoundTextRange:(UITextRange *)range completionHandler:(void (^)(CGRect))completionHandler;
#endif
-- (void)beginFullscreenVideoExtraction:(const WebKit::ShareableBitmap::Handle&)imageHandle playerViewController:(AVPlayerViewController *)playerViewController;
-- (void)cancelFullscreenVideoExtraction:(AVPlayerViewController *)controller;
-@property (nonatomic, readonly) BOOL isFullscreenVideoExtractionEnabled;
+- (void)beginTextRecognitionForFullscreenVideo:(const WebKit::ShareableBitmap::Handle&)imageHandle playerViewController:(AVPlayerViewController *)playerViewController;
+- (void)cancelTextRecognitionForFullscreenVideo:(AVPlayerViewController *)controller;
+@property (nonatomic, readonly) BOOL isTextRecognitionInFullscreenVideoEnabled;
-- (void)beginElementFullscreenVideoExtraction:(const WebKit::ShareableBitmap::Handle&)bitmapHandle bounds:(WebCore::FloatRect)bounds;
-- (void)cancelElementFullscreenVideoExtraction;
+- (void)beginTextRecognitionForVideoInElementFullscreen:(const WebKit::ShareableBitmap::Handle&)bitmapHandle bounds:(WebCore::FloatRect)bounds;
+- (void)cancelTextRecognitionForVideoInElementFullscreen;
@end
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-06-07 22:46:18 UTC (rev 295367)
@@ -11067,12 +11067,12 @@
constexpr auto analysisTypesForFullscreenVideo = VKAnalysisTypeAll & ~VKAnalysisTypeVisualSearch;
#endif
-- (void)beginFullscreenVideoExtraction:(const WebKit::ShareableBitmap::Handle&)imageData playerViewController:(AVPlayerViewController *)controller
+- (void)beginTextRecognitionForFullscreenVideo:(const WebKit::ShareableBitmap::Handle&)imageData playerViewController:(AVPlayerViewController *)controller
{
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
ASSERT(_page->preferences().textRecognitionInVideosEnabled());
- if (_fullscreenVideoExtractionRequestIdentifier)
+ if (_fullscreenVideoImageAnalysisRequestIdentifier)
return;
auto imageBitmap = WebKit::ShareableBitmap::create(imageData);
@@ -11084,12 +11084,12 @@
return;
auto request = [self createImageAnalyzerRequest:analysisTypesForFullscreenVideo image:cgImage.get()];
- _fullscreenVideoExtractionRequestIdentifier = [self.imageAnalyzer processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([weakSelf = WeakObjCPtr<WKContentView>(self), controller = RetainPtr { controller }] (CocoaImageAnalysis *result, NSError *) mutable {
+ _fullscreenVideoImageAnalysisRequestIdentifier = [self.imageAnalyzer processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([weakSelf = WeakObjCPtr<WKContentView>(self), controller = RetainPtr { controller }] (CocoaImageAnalysis *result, NSError *) mutable {
auto strongSelf = weakSelf.get();
if (!strongSelf)
return;
- strongSelf->_fullscreenVideoExtractionRequestIdentifier = 0;
+ strongSelf->_fullscreenVideoImageAnalysisRequestIdentifier = 0;
if ([controller respondsToSelector:@selector(setImageAnalysis:)])
[controller setImageAnalysis:result];
@@ -11097,10 +11097,10 @@
#endif // ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
}
-- (void)cancelFullscreenVideoExtraction:(AVPlayerViewController *)controller
+- (void)cancelTextRecognitionForFullscreenVideo:(AVPlayerViewController *)controller
{
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
- if (auto identifier = std::exchange(_fullscreenVideoExtractionRequestIdentifier, 0))
+ if (auto identifier = std::exchange(_fullscreenVideoImageAnalysisRequestIdentifier, 0))
[_imageAnalyzer cancelRequestID:identifier];
if ([controller respondsToSelector:@selector(setImageAnalysis:)])
@@ -11108,7 +11108,7 @@
#endif
}
-- (BOOL)isFullscreenVideoExtractionEnabled
+- (BOOL)isTextRecognitionInFullscreenVideoEnabled
{
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
return _page->preferences().textRecognitionInVideosEnabled();
@@ -11117,7 +11117,7 @@
#endif
}
-- (void)beginElementFullscreenVideoExtraction:(const WebKit::ShareableBitmap::Handle&)bitmapHandle bounds:(WebCore::FloatRect)bounds
+- (void)beginTextRecognitionForVideoInElementFullscreen:(const WebKit::ShareableBitmap::Handle&)bitmapHandle bounds:(WebCore::FloatRect)bounds
{
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
auto imageBitmap = WebKit::ShareableBitmap::create(bitmapHandle);
@@ -11129,12 +11129,12 @@
return;
auto request = WebKit::createImageAnalyzerRequest(image.get(), analysisTypesForFullscreenVideo);
- _fullscreenVideoExtractionRequestIdentifier = [self.imageAnalyzer processRequest:request.get() progressHandler:nil completionHandler:[weakSelf = WeakObjCPtr<WKContentView>(self), bounds](CocoaImageAnalysis *result, NSError *error) {
+ _fullscreenVideoImageAnalysisRequestIdentifier = [self.imageAnalyzer processRequest:request.get() progressHandler:nil completionHandler:[weakSelf = WeakObjCPtr<WKContentView>(self), bounds](CocoaImageAnalysis *result, NSError *error) {
auto strongSelf = weakSelf.get();
- if (!strongSelf || !strongSelf->_fullscreenVideoExtractionRequestIdentifier)
+ if (!strongSelf || !strongSelf->_fullscreenVideoImageAnalysisRequestIdentifier)
return;
- strongSelf->_fullscreenVideoExtractionRequestIdentifier = 0;
+ strongSelf->_fullscreenVideoImageAnalysisRequestIdentifier = 0;
if (error || !result)
return;
@@ -11144,12 +11144,12 @@
#endif // ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
}
-- (void)cancelElementFullscreenVideoExtraction
+- (void)cancelTextRecognitionForVideoInElementFullscreen
{
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
[self uninstallImageAnalysisInteraction];
- if (auto previousIdentifier = std::exchange(_fullscreenVideoExtractionRequestIdentifier, 0))
+ if (auto previousIdentifier = std::exchange(_fullscreenVideoImageAnalysisRequestIdentifier, 0))
[self.imageAnalyzer cancelRequestID:previousIdentifier];
#endif
}
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -256,9 +256,9 @@
bool effectiveAppearanceIsDark() const override;
bool effectiveUserInterfaceLevelIsElevated() const override;
- bool isFullscreenVideoExtractionEnabled() const final { return true; }
- void beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle&, WebCore::FloatRect) final;
- void cancelElementFullscreenVideoExtraction() final;
+ bool isTextRecognitionInFullscreenVideoEnabled() const final { return true; }
+ void beginTextRecognitionForVideoInElementFullscreen(const ShareableBitmap::Handle&, WebCore::FloatRect) final;
+ void cancelTextRecognitionForVideoInElementFullscreen() final;
#if ENABLE(DRAG_SUPPORT)
void didPerformDragOperation(bool handled) final;
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (295366 => 295367)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2022-06-07 22:46:18 UTC (rev 295367)
@@ -1039,14 +1039,14 @@
#endif
-void PageClientImpl::beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle& bitmapHandle, FloatRect bounds)
+void PageClientImpl::beginTextRecognitionForVideoInElementFullscreen(const ShareableBitmap::Handle& bitmapHandle, FloatRect bounds)
{
- m_impl->beginElementFullscreenVideoExtraction(bitmapHandle, bounds);
+ m_impl->beginTextRecognitionForVideoInElementFullscreen(bitmapHandle, bounds);
}
-void PageClientImpl::cancelElementFullscreenVideoExtraction()
+void PageClientImpl::cancelTextRecognitionForVideoInElementFullscreen()
{
- m_impl->cancelElementFullscreenVideoExtraction();
+ m_impl->cancelTextRecognitionForVideoInElementFullscreen();
}
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp (295366 => 295367)
--- trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2022-06-07 22:46:18 UTC (rev 295367)
@@ -77,7 +77,7 @@
: WebCore::EventListener(WebCore::EventListener::CPPEventListenerType)
, m_page(page)
#if ENABLE(VIDEO)
- , m_mainVideoElementExtractionTimer(RunLoop::main(), this, &WebFullScreenManager::mainVideoElementExtractionTimerFired)
+ , m_mainVideoElementTextRecognitionTimer(RunLoop::main(), this, &WebFullScreenManager::mainVideoElementTextRecognitionTimerFired)
#endif
{
}
@@ -389,9 +389,9 @@
if (targetElement == m_mainVideoElement.get()) {
auto& targetVideoElement = downcast<WebCore::HTMLVideoElement>(*targetElement);
if (targetVideoElement.paused() && !targetVideoElement.seeking())
- scheduleMainVideoElementExtraction();
+ scheduleTextRecognitionForMainVideo();
else
- endMainVideoElementExtractionIfNeeded();
+ endTextRecognitionForMainVideoIfNeeded();
}
#else
UNUSED_PARAM(event);
@@ -401,7 +401,7 @@
#if ENABLE(VIDEO)
-void WebFullScreenManager::mainVideoElementExtractionTimerFired()
+void WebFullScreenManager::mainVideoElementTextRecognitionTimerFired()
{
if (!m_element || !m_element->document().fullscreenManager().isFullscreen())
return;
@@ -411,25 +411,25 @@
if (!m_mainVideoElement)
return;
- if (m_isExtractingMainVideoElement)
- m_page->cancelVideoExtractionInElementFullScreen();
+ if (m_isPerformingTextRecognitionInMainVideo)
+ m_page->cancelTextRecognitionForVideoInElementFullScreen();
- m_isExtractingMainVideoElement = true;
- m_page->extractVideoInElementFullScreen(*m_mainVideoElement);
+ m_isPerformingTextRecognitionInMainVideo = true;
+ m_page->beginTextRecognitionForVideoInElementFullScreen(*m_mainVideoElement);
}
-void WebFullScreenManager::scheduleMainVideoElementExtraction()
+void WebFullScreenManager::scheduleTextRecognitionForMainVideo()
{
- m_mainVideoElementExtractionTimer.startOneShot(250_ms);
+ m_mainVideoElementTextRecognitionTimer.startOneShot(250_ms);
}
-void WebFullScreenManager::endMainVideoElementExtractionIfNeeded()
+void WebFullScreenManager::endTextRecognitionForMainVideoIfNeeded()
{
- m_mainVideoElementExtractionTimer.stop();
+ m_mainVideoElementTextRecognitionTimer.stop();
- if (m_isExtractingMainVideoElement) {
- m_page->cancelVideoExtractionInElementFullScreen();
- m_isExtractingMainVideoElement = false;
+ if (m_isPerformingTextRecognitionInMainVideo) {
+ m_page->cancelTextRecognitionForVideoInElementFullScreen();
+ m_isPerformingTextRecognitionInMainVideo = false;
}
}
@@ -449,7 +449,7 @@
for (auto& eventName : eventsToObserve.get())
m_mainVideoElement->removeEventListener(eventName, *this, { });
- endMainVideoElementExtractionIfNeeded();
+ endTextRecognitionForMainVideoIfNeeded();
}
m_mainVideoElement = WTFMove(element);
@@ -459,7 +459,7 @@
m_mainVideoElement->addEventListener(eventName, *this, { });
if (m_mainVideoElement->paused())
- scheduleMainVideoElementExtraction();
+ scheduleTextRecognitionForMainVideo();
}
}
Modified: trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h (295366 => 295367)
--- trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -108,15 +108,15 @@
void setElement(WebCore::Element&);
#if ENABLE(VIDEO)
- void scheduleMainVideoElementExtraction();
- void endMainVideoElementExtractionIfNeeded();
- void mainVideoElementExtractionTimerFired();
+ void scheduleTextRecognitionForMainVideo();
+ void endTextRecognitionForMainVideoIfNeeded();
+ void mainVideoElementTextRecognitionTimerFired();
void updateMainVideoElement();
void setMainVideoElement(RefPtr<WebCore::HTMLVideoElement>&&);
WeakPtr<WebCore::HTMLVideoElement> m_mainVideoElement;
- RunLoop::Timer<WebFullScreenManager> m_mainVideoElementExtractionTimer;
- bool m_isExtractingMainVideoElement { false };
+ RunLoop::Timer<WebFullScreenManager> m_mainVideoElementTextRecognitionTimer;
+ bool m_isPerformingTextRecognitionInMainVideo { false };
#endif // ENABLE(VIDEO)
bool m_closing { false };
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (295366 => 295367)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-06-07 22:46:18 UTC (rev 295367)
@@ -8066,7 +8066,7 @@
}
#if ENABLE(VIDEO)
-void WebPage::extractVideoInElementFullScreen(const HTMLVideoElement& element)
+void WebPage::beginTextRecognitionForVideoInElementFullScreen(const HTMLVideoElement& element)
{
RefPtr view = element.document().view();
if (!view)
@@ -8084,12 +8084,12 @@
if (rectInRootView.isEmpty())
return;
- send(Messages::WebPageProxy::ExtractVideoInElementFullScreen(mediaPlayerIdentifier, rectInRootView));
+ send(Messages::WebPageProxy::BeginTextRecognitionForVideoInElementFullScreen(mediaPlayerIdentifier, rectInRootView));
}
-void WebPage::cancelVideoExtractionInElementFullScreen()
+void WebPage::cancelTextRecognitionForVideoInElementFullScreen()
{
- send(Messages::WebPageProxy::CancelVideoExtractionInElementFullScreen());
+ send(Messages::WebPageProxy::CancelTextRecognitionForVideoInElementFullScreen());
}
#endif // ENABLE(VIDEO)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (295366 => 295367)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2022-06-07 22:46:18 UTC (rev 295367)
@@ -1539,8 +1539,8 @@
#endif
#if ENABLE(VIDEO)
- void extractVideoInElementFullScreen(const WebCore::HTMLVideoElement&);
- void cancelVideoExtractionInElementFullScreen();
+ void beginTextRecognitionForVideoInElementFullScreen(const WebCore::HTMLVideoElement&);
+ void cancelTextRecognitionForVideoInElementFullScreen();
#endif
#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
Modified: trunk/Tools/TestWebKitAPI/SourcesCocoa.txt (295366 => 295367)
--- trunk/Tools/TestWebKitAPI/SourcesCocoa.txt 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Tools/TestWebKitAPI/SourcesCocoa.txt 2022-06-07 22:46:18 UTC (rev 295367)
@@ -115,7 +115,7 @@
Tests/WebKitCocoa/FullscreenDelegate.mm
Tests/WebKitCocoa/FullscreenLayoutConstraints.mm
Tests/WebKitCocoa/FullscreenRemoveNodeBeforeEnter.mm
-Tests/WebKitCocoa/FullscreenVideoExtraction.mm
+Tests/WebKitCocoa/FullscreenVideoTextRecognition.mm
Tests/WebKitCocoa/GPUProcess.mm
Tests/WebKitCocoa/Geolocation.mm
Tests/WebKitCocoa/GetDisplayMedia.mm
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (295366 => 295367)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-06-07 22:46:18 UTC (rev 295367)
@@ -3179,7 +3179,7 @@
F4B825D61EF4DBD4006E417F /* compressed-files.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "compressed-files.zip"; sourceTree = "<group>"; };
F4B86D4E20BCD5970099A7E6 /* paint-significant-area-milestone.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "paint-significant-area-milestone.html"; sourceTree = "<group>"; };
F4BC0B132146C849002A0478 /* FocusPreservationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FocusPreservationTests.mm; sourceTree = "<group>"; };
- F4BDA42E27F8BF2F00F9647D /* FullscreenVideoExtraction.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenVideoExtraction.mm; sourceTree = "<group>"; };
+ F4BDA42E27F8BF2F00F9647D /* FullscreenVideoTextRecognition.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenVideoTextRecognition.mm; sourceTree = "<group>"; };
F4BDA42F27F8CF5600F9647D /* element-fullscreen.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "element-fullscreen.html"; sourceTree = "<group>"; };
F4BFA68C1E4AD08000154298 /* LegacyDragAndDropTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyDragAndDropTests.mm; sourceTree = "<group>"; };
F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
@@ -3581,7 +3581,7 @@
CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */,
3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
CDDC7C6825FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.mm */,
- F4BDA42E27F8BF2F00F9647D /* FullscreenVideoExtraction.mm */,
+ F4BDA42E27F8BF2F00F9647D /* FullscreenVideoTextRecognition.mm */,
631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */,
07E1F6A01FFC3A080096C7EC /* GetDisplayMedia.mm */,
0738012E275EADAB000FA77C /* GetDisplayMediaWindowAndScreen.mm */,
Deleted: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenVideoExtraction.mm (295366 => 295367)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenVideoExtraction.mm 2022-06-07 21:45:25 UTC (rev 295366)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenVideoExtraction.mm 2022-06-07 22:46:18 UTC (rev 295367)
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 2022 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-
-#import "ImageAnalysisTestingUtilities.h"
-#import "InstanceMethodSwizzler.h"
-#import "PlatformUtilities.h"
-#import "Test.h"
-#import "TestWKWebView.h"
-#import "WKWebViewConfigurationExtras.h"
-#import <WebKit/WKWebViewPrivate.h>
-#import <WebKit/_WKFullscreenDelegate.h>
-#import <wtf/BlockPtr.h>
-#import <wtf/RunLoop.h>
-
-#import <pal/cocoa/VisionKitCoreSoftLink.h>
-
-#if PLATFORM(IOS_FAMILY)
-
-static void swizzledPresentViewController(UIViewController *, SEL, UIViewController *, BOOL, dispatch_block_t completion)
-{
- dispatch_async(dispatch_get_main_queue(), completion);
-}
-
-#endif
-
-static int32_t swizzledProcessRequest(VKCImageAnalyzer *, SEL, id request, void (^)(double progress), void (^completion)(VKImageAnalysis *, NSError *))
-{
- dispatch_async(dispatch_get_main_queue(), [completion = makeBlockPtr(completion)] {
- completion(TestWebKitAPI::createImageAnalysisWithSimpleFixedResults().get(), nil);
- });
- return 100;
-}
-
-static void swizzledSetAnalysis(VKCImageAnalysisInteraction *, SEL, VKCImageAnalysis *)
-{
-}
-
-@interface FullscreenVideoExtractionWebView : TestWKWebView
-@end
-
-@implementation FullscreenVideoExtractionWebView {
- std::unique_ptr<InstanceMethodSwizzler> _imageAnalysisRequestSwizzler;
-#if PLATFORM(IOS_FAMILY)
- std::unique_ptr<InstanceMethodSwizzler> _imageAnalysisInteractionSwizzler;
-#else
- std::unique_ptr<InstanceMethodSwizzler> _imageAnalysisOverlaySwizzler;
-#endif
- bool _doneEnteringFullscreen;
- bool _doneExitingFullscreen;
-}
-
-+ (RetainPtr<FullscreenVideoExtractionWebView>)create
-{
- auto configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
- configuration.preferences._fullScreenEnabled = YES;
- auto webView = adoptNS([[FullscreenVideoExtractionWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 568) configuration:configuration]);
- [webView synchronouslyLoadTestPageNamed:@"element-fullscreen"];
- return webView;
-}
-
-- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
-{
- if (!(self = [super initWithFrame:frame configuration:configuration]))
- return nil;
-
- _imageAnalysisRequestSwizzler = WTF::makeUnique<InstanceMethodSwizzler>(
- PAL::getVKImageAnalyzerClass(),
- @selector(processRequest:progressHandler:completionHandler:),
- reinterpret_cast<IMP>(swizzledProcessRequest)
- );
-
-#if PLATFORM(IOS_FAMILY)
- _imageAnalysisInteractionSwizzler = WTF::makeUnique<InstanceMethodSwizzler>(
- PAL::getVKCImageAnalysisInteractionClass(),
- @selector(setAnalysis:),
- reinterpret_cast<IMP>(swizzledSetAnalysis)
- );
-#else
- _imageAnalysisOverlaySwizzler = WTF::makeUnique<InstanceMethodSwizzler>(
- PAL::getVKCImageAnalysisOverlayViewClass(),
- @selector(setAnalysis:),
- reinterpret_cast<IMP>(swizzledSetAnalysis)
- );
-#endif
-
- return self;
-}
-
-- (void)loadVideoSource:(NSString *)source
-{
- __block bool done = false;
- [self callAsyncJavaScript:@"loadSource(source)" arguments:@{ @"source" : source } inFrame:nil inContentWorld:WKContentWorld.pageWorld completionHandler:^(id, NSError *error) {
- EXPECT_NULL(error);
- done = true;
- }];
- TestWebKitAPI::Util::run(&done);
- [self waitForNextPresentationUpdate];
-}
-
-- (void)enterFullscreen
-{
-#if PLATFORM(IOS_FAMILY)
- // Work around lack of a real UIApplication in TestWebKitAPIApp on iOS. Without this,
- // -presentViewController:animated:completion: never calls the completion handler,
- // which means we never transition into WKFullscreenStateInFullscreen.
- InstanceMethodSwizzler presentationSwizzler {
- UIViewController.class,
- @selector(presentViewController:animated:completion:),
- reinterpret_cast<IMP>(swizzledPresentViewController)
- };
-#endif // PLATFORM(IOS_FAMILY)
-
- _doneEnteringFullscreen = false;
- [self evaluateJavaScript:@"enterFullscreen()" completionHandler:nil];
- TestWebKitAPI::Util::run(&_doneEnteringFullscreen);
- [self waitForNextPresentationUpdate];
-}
-
-- (void)exitFullscreen
-{
- _doneExitingFullscreen = false;
- [self evaluateJavaScript:@"exitFullscreen()" completionHandler:nil];
- TestWebKitAPI::Util::run(&_doneExitingFullscreen);
- [self waitForNextPresentationUpdate];
-}
-
-- (void)didChangeValueForKey:(NSString *)key
-{
- [super didChangeValueForKey:key];
-
- if (![key isEqualToString:@"fullscreenState"])
- return;
-
- auto state = self.fullscreenState;
- switch (state) {
- case WKFullscreenStateNotInFullscreen:
- _doneExitingFullscreen = true;
- break;
- case WKFullscreenStateInFullscreen:
- _doneEnteringFullscreen = true;
- break;
- default:
- break;
- }
-}
-
-- (void)pause
-{
- [self objectByEvaluatingJavaScript:@"video.pause()"];
- [self waitForNextPresentationUpdate];
-}
-
-- (void)play
-{
- __block bool done = false;
- [self callAsyncJavaScript:@"video.play()" arguments:nil inFrame:nil inContentWorld:WKContentWorld.pageWorld completionHandler:^(id, NSError *error) {
- EXPECT_NULL(error);
- done = true;
- }];
- TestWebKitAPI::Util::run(&done);
- [self waitForNextPresentationUpdate];
-}
-
-- (double)waitForVideoFrame
-{
- __block double result = 0;
- __block bool done = false;
- [self callAsyncJavaScript:@"waitForVideoFrame()" arguments:nil inFrame:nil inContentWorld:WKContentWorld.pageWorld completionHandler:^(NSNumber *timestamp, NSError *error) {
- EXPECT_NULL(error);
- result = timestamp.doubleValue;
- done = true;
- }];
- TestWebKitAPI::Util::run(&done);
- return result;
-}
-
-- (BOOL)hasActiveImageAnalysis
-{
-#if PLATFORM(IOS_FAMILY)
- for (id<UIInteraction> interaction in self.textInputContentView.interactions) {
- if ([interaction isKindOfClass:PAL::getVKCImageAnalysisInteractionClass()])
- return YES;
- }
-#else
- for (NSView *subview in self.subviews) {
- if ([subview isKindOfClass:PAL::getVKCImageAnalysisOverlayViewClass()])
- return YES;
- }
-#endif
- return NO;
-}
-
-- (void)waitForImageAnalysisToBegin
-{
- TestWebKitAPI::Util::waitForConditionWithLogging([&] {
- return self.hasActiveImageAnalysis;
- }, 3, @"Expected image analysis to begin.");
-}
-
-- (void)waitForImageAnalysisToEnd
-{
- TestWebKitAPI::Util::waitForConditionWithLogging([&] {
- return !self.hasActiveImageAnalysis;
- }, 3, @"Expected image analysis to end.");
-}
-
-@end
-
-namespace TestWebKitAPI {
-
-TEST(FullscreenVideoExtraction, TogglePlaybackInElementFullscreen)
-{
- auto webView = [FullscreenVideoExtractionWebView create];
- [webView loadVideoSource:@"test.mp4"];
-
- [webView enterFullscreen];
- [webView pause];
- [webView waitForImageAnalysisToBegin];
-
- [webView play];
- [webView waitForImageAnalysisToEnd];
-}
-
-TEST(FullscreenVideoExtraction, AddVideoAfterEnteringFullscreen)
-{
- auto webView = [FullscreenVideoExtractionWebView create];
- [webView loadVideoSource:@"test.mp4"];
- [webView objectByEvaluatingJavaScript:@"video.remove()"];
-
- [webView enterFullscreen];
- [webView objectByEvaluatingJavaScript:@"container.appendChild(video); 0;"];
- [webView play];
- [webView waitForVideoFrame];
- [webView pause];
- [webView waitForImageAnalysisToBegin];
-}
-
-TEST(FullscreenVideoExtraction, DoNotAnalyzeVideoAfterExitingFullscreen)
-{
- auto webView = [FullscreenVideoExtractionWebView create];
- [webView loadVideoSource:@"test.mp4"];
-
- [webView enterFullscreen];
- [webView pause];
- [webView waitForImageAnalysisToBegin];
-
- [webView exitFullscreen];
- [webView waitForImageAnalysisToEnd];
-
- [webView play];
- [webView pause];
-
- bool doneWaiting = false;
- RunLoop::main().dispatchAfter(300_ms, [&] {
- EXPECT_FALSE([webView hasActiveImageAnalysis]);
- doneWaiting = true;
- });
- Util::run(&doneWaiting);
-}
-
-} // namespace TestWebKitAPI
-
-#endif // ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
Copied: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenVideoTextRecognition.mm (from rev 295366, trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenVideoExtraction.mm) (0 => 295367)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenVideoTextRecognition.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenVideoTextRecognition.mm 2022-06-07 22:46:18 UTC (rev 295367)
@@ -0,0 +1,289 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+
+#import "ImageAnalysisTestingUtilities.h"
+#import "InstanceMethodSwizzler.h"
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKFullscreenDelegate.h>
+#import <wtf/BlockPtr.h>
+#import <wtf/RunLoop.h>
+
+#import <pal/cocoa/VisionKitCoreSoftLink.h>
+
+#if PLATFORM(IOS_FAMILY)
+
+static void swizzledPresentViewController(UIViewController *, SEL, UIViewController *, BOOL, dispatch_block_t completion)
+{
+ dispatch_async(dispatch_get_main_queue(), completion);
+}
+
+#endif
+
+static int32_t swizzledProcessRequest(VKCImageAnalyzer *, SEL, id request, void (^)(double progress), void (^completion)(VKImageAnalysis *, NSError *))
+{
+ dispatch_async(dispatch_get_main_queue(), [completion = makeBlockPtr(completion)] {
+ completion(TestWebKitAPI::createImageAnalysisWithSimpleFixedResults().get(), nil);
+ });
+ return 100;
+}
+
+static void swizzledSetAnalysis(VKCImageAnalysisInteraction *, SEL, VKCImageAnalysis *)
+{
+}
+
+@interface FullscreenVideoTextRecognitionWebView : TestWKWebView
+@end
+
+@implementation FullscreenVideoTextRecognitionWebView {
+ std::unique_ptr<InstanceMethodSwizzler> _imageAnalysisRequestSwizzler;
+#if PLATFORM(IOS_FAMILY)
+ std::unique_ptr<InstanceMethodSwizzler> _imageAnalysisInteractionSwizzler;
+#else
+ std::unique_ptr<InstanceMethodSwizzler> _imageAnalysisOverlaySwizzler;
+#endif
+ bool _doneEnteringFullscreen;
+ bool _doneExitingFullscreen;
+}
+
++ (RetainPtr<FullscreenVideoTextRecognitionWebView>)create
+{
+ auto configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
+ configuration.preferences._fullScreenEnabled = YES;
+ auto webView = adoptNS([[FullscreenVideoTextRecognitionWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 568) configuration:configuration]);
+ [webView synchronouslyLoadTestPageNamed:@"element-fullscreen"];
+ return webView;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
+{
+ if (!(self = [super initWithFrame:frame configuration:configuration]))
+ return nil;
+
+ _imageAnalysisRequestSwizzler = WTF::makeUnique<InstanceMethodSwizzler>(
+ PAL::getVKImageAnalyzerClass(),
+ @selector(processRequest:progressHandler:completionHandler:),
+ reinterpret_cast<IMP>(swizzledProcessRequest)
+ );
+
+#if PLATFORM(IOS_FAMILY)
+ _imageAnalysisInteractionSwizzler = WTF::makeUnique<InstanceMethodSwizzler>(
+ PAL::getVKCImageAnalysisInteractionClass(),
+ @selector(setAnalysis:),
+ reinterpret_cast<IMP>(swizzledSetAnalysis)
+ );
+#else
+ _imageAnalysisOverlaySwizzler = WTF::makeUnique<InstanceMethodSwizzler>(
+ PAL::getVKCImageAnalysisOverlayViewClass(),
+ @selector(setAnalysis:),
+ reinterpret_cast<IMP>(swizzledSetAnalysis)
+ );
+#endif
+
+ return self;
+}
+
+- (void)loadVideoSource:(NSString *)source
+{
+ __block bool done = false;
+ [self callAsyncJavaScript:@"loadSource(source)" arguments:@{ @"source" : source } inFrame:nil inContentWorld:WKContentWorld.pageWorld completionHandler:^(id, NSError *error) {
+ EXPECT_NULL(error);
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ [self waitForNextPresentationUpdate];
+}
+
+- (void)enterFullscreen
+{
+#if PLATFORM(IOS_FAMILY)
+ // Work around lack of a real UIApplication in TestWebKitAPIApp on iOS. Without this,
+ // -presentViewController:animated:completion: never calls the completion handler,
+ // which means we never transition into WKFullscreenStateInFullscreen.
+ InstanceMethodSwizzler presentationSwizzler {
+ UIViewController.class,
+ @selector(presentViewController:animated:completion:),
+ reinterpret_cast<IMP>(swizzledPresentViewController)
+ };
+#endif // PLATFORM(IOS_FAMILY)
+
+ _doneEnteringFullscreen = false;
+ [self evaluateJavaScript:@"enterFullscreen()" completionHandler:nil];
+ TestWebKitAPI::Util::run(&_doneEnteringFullscreen);
+ [self waitForNextPresentationUpdate];
+}
+
+- (void)exitFullscreen
+{
+ _doneExitingFullscreen = false;
+ [self evaluateJavaScript:@"exitFullscreen()" completionHandler:nil];
+ TestWebKitAPI::Util::run(&_doneExitingFullscreen);
+ [self waitForNextPresentationUpdate];
+}
+
+- (void)didChangeValueForKey:(NSString *)key
+{
+ [super didChangeValueForKey:key];
+
+ if (![key isEqualToString:@"fullscreenState"])
+ return;
+
+ auto state = self.fullscreenState;
+ switch (state) {
+ case WKFullscreenStateNotInFullscreen:
+ _doneExitingFullscreen = true;
+ break;
+ case WKFullscreenStateInFullscreen:
+ _doneEnteringFullscreen = true;
+ break;
+ default:
+ break;
+ }
+}
+
+- (void)pause
+{
+ [self objectByEvaluatingJavaScript:@"video.pause()"];
+ [self waitForNextPresentationUpdate];
+}
+
+- (void)play
+{
+ __block bool done = false;
+ [self callAsyncJavaScript:@"video.play()" arguments:nil inFrame:nil inContentWorld:WKContentWorld.pageWorld completionHandler:^(id, NSError *error) {
+ EXPECT_NULL(error);
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ [self waitForNextPresentationUpdate];
+}
+
+- (double)waitForVideoFrame
+{
+ __block double result = 0;
+ __block bool done = false;
+ [self callAsyncJavaScript:@"waitForVideoFrame()" arguments:nil inFrame:nil inContentWorld:WKContentWorld.pageWorld completionHandler:^(NSNumber *timestamp, NSError *error) {
+ EXPECT_NULL(error);
+ result = timestamp.doubleValue;
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ return result;
+}
+
+- (BOOL)hasActiveImageAnalysis
+{
+#if PLATFORM(IOS_FAMILY)
+ for (id<UIInteraction> interaction in self.textInputContentView.interactions) {
+ if ([interaction isKindOfClass:PAL::getVKCImageAnalysisInteractionClass()])
+ return YES;
+ }
+#else
+ for (NSView *subview in self.subviews) {
+ if ([subview isKindOfClass:PAL::getVKCImageAnalysisOverlayViewClass()])
+ return YES;
+ }
+#endif
+ return NO;
+}
+
+- (void)waitForImageAnalysisToBegin
+{
+ TestWebKitAPI::Util::waitForConditionWithLogging([&] {
+ return self.hasActiveImageAnalysis;
+ }, 3, @"Expected image analysis to begin.");
+}
+
+- (void)waitForImageAnalysisToEnd
+{
+ TestWebKitAPI::Util::waitForConditionWithLogging([&] {
+ return !self.hasActiveImageAnalysis;
+ }, 3, @"Expected image analysis to end.");
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(FullscreenVideoTextRecognition, TogglePlaybackInElementFullscreen)
+{
+ auto webView = [FullscreenVideoTextRecognitionWebView create];
+ [webView loadVideoSource:@"test.mp4"];
+
+ [webView enterFullscreen];
+ [webView pause];
+ [webView waitForImageAnalysisToBegin];
+
+ [webView play];
+ [webView waitForImageAnalysisToEnd];
+}
+
+TEST(FullscreenVideoTextRecognition, AddVideoAfterEnteringFullscreen)
+{
+ auto webView = [FullscreenVideoTextRecognitionWebView create];
+ [webView loadVideoSource:@"test.mp4"];
+ [webView objectByEvaluatingJavaScript:@"video.remove()"];
+
+ [webView enterFullscreen];
+ [webView objectByEvaluatingJavaScript:@"container.appendChild(video); 0;"];
+ [webView play];
+ [webView waitForVideoFrame];
+ [webView pause];
+ [webView waitForImageAnalysisToBegin];
+}
+
+TEST(FullscreenVideoTextRecognition, DoNotAnalyzeVideoAfterExitingFullscreen)
+{
+ auto webView = [FullscreenVideoTextRecognitionWebView create];
+ [webView loadVideoSource:@"test.mp4"];
+
+ [webView enterFullscreen];
+ [webView pause];
+ [webView waitForImageAnalysisToBegin];
+
+ [webView exitFullscreen];
+ [webView waitForImageAnalysisToEnd];
+
+ [webView play];
+ [webView pause];
+
+ bool doneWaiting = false;
+ RunLoop::main().dispatchAfter(300_ms, [&] {
+ EXPECT_FALSE([webView hasActiveImageAnalysis]);
+ doneWaiting = true;
+ });
+ Util::run(&doneWaiting);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)