Diff
Modified: trunk/Source/WebCore/ChangeLog (285948 => 285949)
--- trunk/Source/WebCore/ChangeLog 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebCore/ChangeLog 2021-11-17 20:22:11 UTC (rev 285949)
@@ -1,3 +1,46 @@
+2021-11-17 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Add a helper class to coordinate batch analysis of images
+ https://bugs.webkit.org/show_bug.cgi?id=233075
+
+ Reviewed by Dean Jackson.
+
+ Introduce ImageAnalysisQueue, which will collect suitable image elements in the main document and coordinate
+ image analysis tasks for up to some (fixed, but easily configurable) maximum number of simultaneous pending
+ tasks. See below for more details.
+
+ * Headers.cmake:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/ImageAnalysisQueue.cpp: Added.
+ (WebCore::ImageAnalysisQueue::ImageAnalysisQueue):
+ (WebCore::ImageAnalysisQueue::enqueueAllImages):
+
+ Iterate through all image elements on the page with cached images, and add them as image analysis tasks to the
+ task queue as long as they are not tiny. Automatically start processing queued tasks afterwards (see below).
+
+ (WebCore::ImageAnalysisQueue::resumeProcessing):
+
+ Run the main processing loop of the task queue; while there are tasks remaining, push up to 5 images to the
+ client layer for image analysis at the same time, until there are no more queued tasks.
+
+ (WebCore::ImageAnalysisQueue::clear):
+ * page/ImageAnalysisQueue.h: Added.
+
+ Introduce the new class.
+
+ * page/Page.cpp:
+ (WebCore::Page::imageOverlayController):
+
+ Drive-by fix: `m_imageOverlayController` was being eagerly initialized here, despite the existence of both
+ `imageOverlayControllerIfExists()` and `imageOverlayController()`. Fix this by lazily creating the
+ ImageOverlayController instead.
+
+ (WebCore::Page::imageAnalysisQueue):
+ * page/Page.h:
+ (WebCore::Page::imageAnalysisQueueIfExists):
+ (WebCore::Page::imageOverlayController): Deleted.
+
2021-11-17 Alan Bujtas <za...@apple.com>
[LFC][IFC] Do not apply the "do not trim whitespace followed by br" legacy line layout quirk when computing the intrinsic widths
Modified: trunk/Source/WebCore/Headers.cmake (285948 => 285949)
--- trunk/Source/WebCore/Headers.cmake 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebCore/Headers.cmake 2021-11-17 20:22:11 UTC (rev 285949)
@@ -954,6 +954,7 @@
page/FrameViewLayoutContext.h
page/GlobalFrameIdentifier.h
page/GlobalWindowIdentifier.h
+ page/ImageAnalysisQueue.h
page/LayoutMilestone.h
page/MediaCanStartListener.h
page/MediaControlsContextMenuItem.h
Modified: trunk/Source/WebCore/Sources.txt (285948 => 285949)
--- trunk/Source/WebCore/Sources.txt 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebCore/Sources.txt 2021-11-17 20:22:11 UTC (rev 285949)
@@ -1725,6 +1725,7 @@
page/FrameView.cpp
page/FrameViewLayoutContext.cpp
page/History.cpp
+page/ImageAnalysisQueue.cpp
page/ImageOverlayController.cpp
page/IntersectionObserver.cpp
page/IntersectionObserverEntry.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (285948 => 285949)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-17 20:22:11 UTC (rev 285949)
@@ -5449,6 +5449,7 @@
F46729281E0DE68500ACC3D8 /* ScrollSnapOffsetsInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F46729251E0DE5AB00ACC3D8 /* ScrollSnapOffsetsInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
F46C447E234654540039A79D /* ClipboardItemBindingsDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = F46C447C234654540039A79D /* ClipboardItemBindingsDataSource.h */; };
F46D5386273D7E460009FA80 /* ImageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = F46D5385273D7E3F0009FA80 /* ImageOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ F46D53A1273EEFA00009FA80 /* ImageAnalysisQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = F46D539D273EECF70009FA80 /* ImageAnalysisQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
F473845825DDE9FB006DE8DD /* DataOwnerType.h in Headers */ = {isa = PBXBuildFile; fileRef = F473845725DDE9FB006DE8DD /* DataOwnerType.h */; settings = {ATTRIBUTES = (Private, ); }; };
F47A09D120A93A9700240FAE /* DisabledAdaptations.h in Headers */ = {isa = PBXBuildFile; fileRef = F47A09CF20A939F600240FAE /* DisabledAdaptations.h */; settings = {ATTRIBUTES = (Private, ); }; };
F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */ = {isa = PBXBuildFile; fileRef = F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -17266,6 +17267,8 @@
F46C44812346547A0039A79D /* ClipboardItemPasteboardDataSource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ClipboardItemPasteboardDataSource.cpp; sourceTree = "<group>"; };
F46D5384273D7E3E0009FA80 /* ImageOverlay.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageOverlay.cpp; sourceTree = "<group>"; };
F46D5385273D7E3F0009FA80 /* ImageOverlay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageOverlay.h; sourceTree = "<group>"; };
+ F46D539D273EECF70009FA80 /* ImageAnalysisQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageAnalysisQueue.h; sourceTree = "<group>"; };
+ F46D539E273EECF70009FA80 /* ImageAnalysisQueue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageAnalysisQueue.cpp; sourceTree = "<group>"; };
F473845725DDE9FB006DE8DD /* DataOwnerType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataOwnerType.h; sourceTree = "<group>"; };
F47A09CF20A939F600240FAE /* DisabledAdaptations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisabledAdaptations.h; sourceTree = "<group>"; };
F47A09D420A9DD0400240FAE /* DisabledAdaptations.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisabledAdaptations.cpp; sourceTree = "<group>"; };
@@ -23183,6 +23186,8 @@
BC94D1500C275C8B006BC617 /* History.cpp */,
BC94D1510C275C8B006BC617 /* History.h */,
BC94D1520C275C8B006BC617 /* History.idl */,
+ F46D539E273EECF70009FA80 /* ImageAnalysisQueue.cpp */,
+ F46D539D273EECF70009FA80 /* ImageAnalysisQueue.h */,
F482434A260C32F10022497C /* ImageOverlayController.cpp */,
F4824348260C32F10022497C /* ImageOverlayController.h */,
0F4710D51DB6FE22002DCEC3 /* IntersectionObserver.cpp */,
@@ -33855,6 +33860,7 @@
835051A524F573C8009911D7 /* IIRFilterOptions.h in Headers */,
830D0B6924F57D67007ED122 /* IIRProcessor.h in Headers */,
B27535700B053814002CE64F /* Image.h in Headers */,
+ F46D53A1273EEFA00009FA80 /* ImageAnalysisQueue.h in Headers */,
55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */,
31815A311F9A6C8F00FCBF89 /* ImageBitmap.h in Headers */,
721B49742512BA3B00FE9D3B /* ImageBitmapBacking.h in Headers */,
Added: trunk/Source/WebCore/page/ImageAnalysisQueue.cpp (0 => 285949)
--- trunk/Source/WebCore/page/ImageAnalysisQueue.cpp (rev 0)
+++ trunk/Source/WebCore/page/ImageAnalysisQueue.cpp 2021-11-17 20:22:11 UTC (rev 285949)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "config.h"
+#include "ImageAnalysisQueue.h"
+
+#if ENABLE(IMAGE_ANALYSIS)
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "HTMLCollection.h"
+#include "HTMLElement.h"
+#include "ImageOverlay.h"
+#include "RenderImage.h"
+#include "Timer.h"
+
+namespace WebCore {
+
+static constexpr unsigned maximumPendingImageAnalysisCount = 5;
+static constexpr float minimumWidthForAnalysis = 20;
+static constexpr float minimumHeightForAnalysis = 20;
+static constexpr Seconds resumeProcessingDelay = 100_ms;
+
+ImageAnalysisQueue::ImageAnalysisQueue(Page& page)
+ : m_page(page)
+ , m_resumeProcessingTimer(*this, &ImageAnalysisQueue::resumeProcessing)
+{
+}
+
+ImageAnalysisQueue::~ImageAnalysisQueue() = default;
+
+void ImageAnalysisQueue::enqueueAllImages(Document& document, const String& identifier)
+{
+ if (!m_page)
+ return;
+
+ // FIXME (233266): Analyze image elements that are loaded after we've enqueued all images in the document.
+ auto imageIterator = document.images()->createIterator();
+ for (RefPtr node = imageIterator.next(); node; node = imageIterator.next()) {
+ if (!is<HTMLElement>(*node))
+ continue;
+
+ auto& element = downcast<HTMLElement>(*node);
+ if (!is<RenderImage>(element.renderer()))
+ continue;
+
+ auto& renderImage = downcast<RenderImage>(*element.renderer());
+ auto* cachedImage = renderImage.cachedImage();
+ if (!cachedImage || cachedImage->errorOccurred())
+ continue;
+
+ if (renderImage.size().width() < minimumWidthForAnalysis || renderImage.size().height() < minimumHeightForAnalysis)
+ continue;
+
+ m_queue.append({ WeakPtr { element }, identifier });
+ }
+
+ resumeProcessing();
+}
+
+void ImageAnalysisQueue::resumeProcessing()
+{
+ if (!m_page)
+ return;
+
+ while (!m_queue.isEmpty() && m_pendingRequestCount < maximumPendingImageAnalysisCount) {
+ auto [weakElement, identifier] = m_queue.takeFirst();
+ RefPtr element = weakElement.get();
+ if (!element || !element->isConnected())
+ continue;
+
+ m_pendingRequestCount++;
+ m_page->resetTextRecognitionResult(*element);
+ m_page->chrome().client().requestTextRecognition(*element, [this, page = m_page] (auto&&) {
+ if (!page)
+ return;
+
+ if (m_pendingRequestCount)
+ m_pendingRequestCount--;
+
+ if (!m_queue.isEmpty() && !m_resumeProcessingTimer.isActive())
+ m_resumeProcessingTimer.startOneShot(resumeProcessingDelay);
+ });
+ }
+}
+
+void ImageAnalysisQueue::clear()
+{
+ // FIXME: This should cancel pending requests in addition to emptying the task queue.
+ m_pendingRequestCount = 0;
+ m_resumeProcessingTimer.stop();
+ m_queue.clear();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(IMAGE_ANALYSIS)
Added: trunk/Source/WebCore/page/ImageAnalysisQueue.h (0 => 285949)
--- trunk/Source/WebCore/page/ImageAnalysisQueue.h (rev 0)
+++ trunk/Source/WebCore/page/ImageAnalysisQueue.h 2021-11-17 20:22:11 UTC (rev 285949)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#if ENABLE(IMAGE_ANALYSIS)
+
+#include <wtf/Deque.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class Document;
+class HTMLElement;
+class Page;
+class Timer;
+
+class ImageAnalysisQueue {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ ImageAnalysisQueue(Page&);
+ ~ImageAnalysisQueue();
+
+ WEBCORE_EXPORT void enqueueAllImages(Document&, const String& identifier);
+ WEBCORE_EXPORT void clear();
+
+private:
+ void resumeProcessing();
+
+ struct Task {
+ WeakPtr<HTMLElement> element;
+ String identifier;
+ };
+
+ WeakPtr<Page> m_page;
+ Timer m_resumeProcessingTimer;
+ Deque<Task> m_queue;
+ unsigned m_pendingRequestCount { 0 };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(IMAGE_ANALYSIS)
Modified: trunk/Source/WebCore/page/Page.cpp (285948 => 285949)
--- trunk/Source/WebCore/page/Page.cpp 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebCore/page/Page.cpp 2021-11-17 20:22:11 UTC (rev 285949)
@@ -76,6 +76,7 @@
#include "HistoryController.h"
#include "HistoryItem.h"
#include "IDBConnectionToServer.h"
+#include "ImageAnalysisQueue.h"
#include "ImageOverlay.h"
#include "ImageOverlayController.h"
#include "InspectorClient.h"
@@ -316,7 +317,6 @@
#if PLATFORM(MAC) && (ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION))
, m_servicesOverlayController(makeUnique<ServicesOverlayController>(*this))
#endif
- , m_imageOverlayController(makeUnique<ImageOverlayController>(*this))
, m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
, m_pageOverlayController(makeUnique<PageOverlayController>(*this))
#if ENABLE(APPLE_PAY)
@@ -3704,8 +3704,22 @@
return ts;
}
+ImageOverlayController& Page::imageOverlayController()
+{
+ if (!m_imageOverlayController)
+ m_imageOverlayController = makeUnique<ImageOverlayController>(*this);
+ return *m_imageOverlayController;
+}
+
#if ENABLE(IMAGE_ANALYSIS)
+ImageAnalysisQueue& Page::imageAnalysisQueue()
+{
+ if (!m_imageAnalysisQueue)
+ m_imageAnalysisQueue = makeUnique<ImageAnalysisQueue>(*this);
+ return *m_imageAnalysisQueue;
+}
+
void Page::updateElementsWithTextRecognitionResults()
{
if (m_textRecognitionResults.isEmptyIgnoringNullReferences())
Modified: trunk/Source/WebCore/page/Page.h (285948 => 285949)
--- trunk/Source/WebCore/page/Page.h 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebCore/page/Page.h 2021-11-17 20:22:11 UTC (rev 285949)
@@ -115,6 +115,7 @@
class HTMLElement;
class HTMLMediaElement;
class HistoryItem;
+class ImageAnalysisQueue;
class ImageOverlayController;
class InspectorClient;
class InspectorController;
@@ -531,9 +532,14 @@
#if PLATFORM(MAC) && (ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION))
ServicesOverlayController& servicesOverlayController() { return *m_servicesOverlayController; }
#endif
- ImageOverlayController& imageOverlayController() { return *m_imageOverlayController; }
+ ImageOverlayController& imageOverlayController();
ImageOverlayController* imageOverlayControllerIfExists() { return m_imageOverlayController.get(); }
+#if ENABLE(IMAGE_ANALYSIS)
+ WEBCORE_EXPORT ImageAnalysisQueue& imageAnalysisQueue();
+ ImageAnalysisQueue* imageAnalysisQueueIfExists() { return m_imageAnalysisQueue.get(); }
+#endif
+
#if ENABLE(WHEEL_EVENT_LATCHING)
ScrollLatchingController& scrollLatchingController();
ScrollLatchingController* scrollLatchingControllerIfExists();
@@ -1192,6 +1198,10 @@
#endif
std::unique_ptr<ImageOverlayController> m_imageOverlayController;
+#if ENABLE(IMAGE_ANALYSIS)
+ std::unique_ptr<ImageAnalysisQueue> m_imageAnalysisQueue;
+#endif
+
std::unique_ptr<WheelEventDeltaFilter> m_recentWheelEventDeltaFilter;
std::unique_ptr<PageOverlayController> m_pageOverlayController;
Modified: trunk/Source/WebKit/ChangeLog (285948 => 285949)
--- trunk/Source/WebKit/ChangeLog 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/ChangeLog 2021-11-17 20:22:11 UTC (rev 285949)
@@ -1,3 +1,24 @@
+2021-11-17 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Add a helper class to coordinate batch analysis of images
+ https://bugs.webkit.org/show_bug.cgi?id=233075
+
+ Reviewed by Dean Jackson.
+
+ Add a couple of WKWebView SPI methods to kick off (and cancel) batch image analysis for mainframe content.
+ See WebCore ChangeLog for more details.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _startImageAnalysis:]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::startImageAnalysis):
+ * UIProcess/WebPageProxy.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::startImageAnalysis):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2021-11-17 Dean Jackson <d...@apple.com>
Add ModelDocument for directly showing content that can be handled by <model>
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (285948 => 285949)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-11-17 20:22:11 UTC (rev 285949)
@@ -2204,6 +2204,18 @@
});
}
+- (void)_startImageAnalysis:(NSString *)identifier
+{
+#if ENABLE(IMAGE_ANALYSIS)
+ THROW_IF_SUSPENDED;
+
+ if (!_page || !_page->preferences().textRecognitionEnhancementsEnabled())
+ return;
+
+ _page->startImageAnalysis(identifier);
+#endif
+}
+
- (void)_takeFindStringFromSelection:(id)sender
{
THROW_IF_SUSPENDED;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (285948 => 285949)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2021-11-17 20:22:11 UTC (rev 285949)
@@ -414,6 +414,8 @@
- (void)_suspendPage:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
- (void)_resumePage:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
+- (void)_startImageAnalysis:(NSString *)identifier WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
@end
#if TARGET_OS_IPHONE
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (285948 => 285949)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-11-17 20:22:11 UTC (rev 285949)
@@ -8636,6 +8636,12 @@
sendWithAsyncReply(Messages::WebPage::UpdateWithTextRecognitionResult(WTFMove(results), context, location), WTFMove(completionHandler));
}
+void WebPageProxy::startImageAnalysis(const String& identifier)
+{
+ if (hasRunningProcess())
+ send(Messages::WebPage::StartImageAnalysis(identifier));
+}
+
#endif // ENABLE(IMAGE_ANALYSIS)
#if ENABLE(ENCRYPTED_MEDIA)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (285948 => 285949)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-11-17 20:22:11 UTC (rev 285949)
@@ -1701,6 +1701,7 @@
void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
void updateWithTextRecognitionResult(WebCore::TextRecognitionResult&&, const WebCore::ElementContext&, const WebCore::FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&&);
void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
+ void startImageAnalysis(const String& identifier);
#endif
#if ENABLE(MEDIA_CONTROLS_CONTEXT_MENUS) && USE(UICONTEXTMENU)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (285948 => 285949)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-11-17 20:22:11 UTC (rev 285949)
@@ -202,6 +202,7 @@
#include <WebCore/HistoryController.h>
#include <WebCore/HistoryItem.h>
#include <WebCore/HitTestResult.h>
+#include <WebCore/ImageAnalysisQueue.h>
#include <WebCore/ImageOverlay.h>
#include <WebCore/InspectorController.h>
#include <WebCore/JSDOMExceptionHandling.h>
@@ -7631,6 +7632,15 @@
completionHandler(updateResult);
}
+void WebPage::startImageAnalysis(const String& identifier)
+{
+ if (RefPtr document = m_mainFrame->coreFrame()->document()) {
+ // We only consider main document content for now, to match the behavior of the corresponding feature
+ // that will trigger this codepath.
+ corePage()->imageAnalysisQueue().enqueueAllImages(*document, identifier);
+ }
+}
+
#endif // ENABLE(IMAGE_ANALYSIS)
#if ENABLE(MEDIA_CONTROLS_CONTEXT_MENUS) && USE(UICONTEXTMENU)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (285948 => 285949)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-11-17 20:22:11 UTC (rev 285949)
@@ -1432,6 +1432,7 @@
#if ENABLE(IMAGE_ANALYSIS)
void requestTextRecognition(WebCore::Element&, CompletionHandler<void(RefPtr<WebCore::Element>&&)>&&);
void updateWithTextRecognitionResult(const WebCore::TextRecognitionResult&, const WebCore::ElementContext&, const WebCore::FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&&);
+ void startImageAnalysis(const String& identifier);
#endif
#if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (285948 => 285949)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-11-17 20:16:45 UTC (rev 285948)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-11-17 20:22:11 UTC (rev 285949)
@@ -644,6 +644,7 @@
#if ENABLE(IMAGE_ANALYSIS)
UpdateWithTextRecognitionResult(struct WebCore::TextRecognitionResult result, struct WebCore::ElementContext element, WebCore::FloatPoint location) -> (enum:uint8_t WebKit::TextRecognitionUpdateResult result) Async
+ StartImageAnalysis(String identifier)
#endif
ScrollToRect(WebCore::FloatRect targetRect, WebCore::FloatPoint origin)