Diff
Modified: trunk/Source/WebKit/ChangeLog (289684 => 289685)
--- trunk/Source/WebKit/ChangeLog 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/ChangeLog 2022-02-12 01:46:34 UTC (rev 289685)
@@ -1,3 +1,29 @@
+2022-02-11 Megan Gardner <[email protected]>
+
+ Implement Reveal methods
+ https://bugs.webkit.org/show_bug.cgi?id=236478
+
+ Reviewed by Wenson Hsieh.
+
+ Respond to protocol methods that request RVItems for selection.
+
+ * Platform/IPC/ArgumentCoder.h:
+ * Platform/IPC/DataReference.h:
+ * Shared/Cocoa/SandboxExtensionCocoa.mm:
+ * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h:
+ * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm:
+ * SourcesCocoa.txt:
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView requestRVItemInSelectedRangeWithCompletionHandler:]):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::requestRVItemInCurrentSelectedRange):
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::requestRVItemInCurrentSelectedRange):
+
2022-02-11 Wenson Hsieh <[email protected]>
[iOS] Add a "Copy Cropped Image" context menu item when long pressing images
Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h (289684 => 289685)
--- trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h 2022-02-12 01:46:34 UTC (rev 289685)
@@ -28,6 +28,7 @@
#include "Decoder.h"
#include "Encoder.h"
#include <wtf/EnumTraits.h>
+#include <wtf/Span.h>
namespace IPC {
namespace Detail {
Modified: trunk/Source/WebKit/Platform/IPC/DataReference.h (289684 => 289685)
--- trunk/Source/WebKit/Platform/IPC/DataReference.h 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/Platform/IPC/DataReference.h 2022-02-12 01:46:34 UTC (rev 289685)
@@ -26,6 +26,7 @@
#pragma once
#include "ArrayReference.h"
+#include <wtf/Span.h>
namespace IPC {
Copied: trunk/Source/WebKit/Shared/Cocoa/RevealItem.h (from rev 289684, trunk/Source/WebKit/Platform/IPC/DataReference.h) (0 => 289685)
--- trunk/Source/WebKit/Shared/Cocoa/RevealItem.h (rev 0)
+++ trunk/Source/WebKit/Shared/Cocoa/RevealItem.h 2022-02-12 01:46:34 UTC (rev 289685)
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#if ENABLE(REVEAL)
+
+#import "ArgumentCoders.h"
+
+#import <wtf/RetainPtr.h>
+
+OBJC_CLASS RVItem;
+
+namespace WebKit {
+
+class RevealItem {
+
+public:
+ RevealItem() = default;
+ RevealItem(RetainPtr<RVItem>&&);
+
+ void encode(IPC::Encoder&) const;
+ static std::optional<RevealItem> decode(IPC::Decoder&);
+
+ RVItem *item() const { return m_item.get(); }
+private:
+ RetainPtr<RVItem> m_item;
+};
+
+}
+
+#endif // ENABLE(REVEAL)
Copied: trunk/Source/WebKit/Shared/Cocoa/RevealItem.mm (from rev 289684, trunk/Source/WebKit/Platform/IPC/DataReference.h) (0 => 289685)
--- trunk/Source/WebKit/Shared/Cocoa/RevealItem.mm (rev 0)
+++ trunk/Source/WebKit/Shared/Cocoa/RevealItem.mm 2022-02-12 01:46:34 UTC (rev 289685)
@@ -0,0 +1,66 @@
+/*
+ * 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"
+#import "RevealItem.h"
+
+#import "ArgumentCodersCocoa.h"
+#import "WebCoreArgumentCoders.h"
+#import <pal/cocoa/RevealSoftLink.h>
+
+namespace WebKit {
+
+#if ENABLE(REVEAL)
+
+RevealItem::RevealItem(RetainPtr<RVItem>&& item)
+ : m_item { WTFMove(item) }
+{
+}
+
+void RevealItem::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_item;
+}
+
+std::optional<RevealItem> RevealItem::decode(IPC::Decoder& decoder)
+{
+ static NeverDestroyed<RetainPtr<NSArray>> allowedClasses;
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+ auto allowed = adoptNS([[NSMutableArray alloc] initWithCapacity:1]);
+ if (auto rvItemClass = PAL::getRVItemClass())
+ [allowed addObject:rvItemClass];
+ allowedClasses.get() = adoptNS([allowed copy]);
+ });
+
+ auto item = IPC::decode<RVItem>(decoder, allowedClasses.get().get());
+ if (!item)
+ return std::nullopt;
+
+ return RevealItem { WTFMove(*item) };
+}
+#endif
+
+}
Modified: trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm (289684 => 289685)
--- trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm 2022-02-12 01:46:34 UTC (rev 289685)
@@ -28,9 +28,11 @@
#if ENABLE(SANDBOX_EXTENSIONS)
+#import "ArgumentCodersCocoa.h"
#import "DataReference.h"
#import "Decoder.h"
#import "Encoder.h"
+#import "WebCoreArgumentCoders.h"
#import <string.h>
#import <wtf/FileSystem.h>
#import <wtf/spi/darwin/SandboxSPI.h>
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h (289684 => 289685)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h 2022-02-12 01:46:34 UTC (rev 289685)
@@ -28,6 +28,7 @@
#import <WebCore/Timer.h>
#import <wtf/HashSet.h>
#import <wtf/Noncopyable.h>
+#import <wtf/OptionSet.h>
namespace WebCore {
class ImageBuffer;
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm (289684 => 289685)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm 2022-02-12 01:46:34 UTC (rev 289685)
@@ -27,8 +27,10 @@
#import "RemoteLayerBackingStoreCollection.h"
#import "PlatformCALayerRemote.h"
+#import "PlatformImageBufferShareableBackend.h"
#import "RemoteLayerBackingStore.h"
#import "RemoteLayerTreeContext.h"
+#import <WebCore/ConcreteImageBuffer.h>
const Seconds volatileBackingStoreAgeThreshold = 1_s;
const Seconds volatileSecondaryBackingStoreAgeThreshold = 200_ms;
Modified: trunk/Source/WebKit/SourcesCocoa.txt (289684 => 289685)
--- trunk/Source/WebKit/SourcesCocoa.txt 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2022-02-12 01:46:34 UTC (rev 289685)
@@ -175,6 +175,7 @@
Shared/Cocoa/InsertTextOptions.cpp
Shared/Cocoa/LoadParametersCocoa.mm
Shared/Cocoa/PDFKitSoftLink.mm
+Shared/Cocoa/RevealItem.mm
Shared/Cocoa/SandboxExtensionCocoa.mm
Shared/Cocoa/SandboxInitialiationParametersCocoa.mm
Shared/Cocoa/SandboxUtilities.mm
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (289684 => 289685)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-02-12 01:46:34 UTC (rev 289685)
@@ -356,6 +356,7 @@
class RemoteLayerTreeTransaction;
class RemoteMediaSessionCoordinatorProxy;
class RemoteScrollingCoordinatorProxy;
+class RevealItem;
class SecKeyProxyStore;
class SpeechRecognitionPermissionManager;
class UserData;
@@ -876,6 +877,9 @@
void requestAutocorrectionContext();
void handleAutocorrectionContext(const WebAutocorrectionContext&);
void requestDictationContext(CompletionHandler<void(const String&, const String&, const String&)>&&);
+#if ENABLE(REVEAL)
+ void requestRVItemInCurrentSelectedRange(CompletionHandler<void(const RevealItem&)>&&);
+#endif
void replaceDictatedText(const String& oldText, const String& newText);
void replaceSelectedText(const String& oldText, const String& newText);
void didReceivePositionInformation(const InteractionInformationAtPosition&);
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (289684 => 289685)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-02-12 01:46:34 UTC (rev 289685)
@@ -40,6 +40,7 @@
#import "RemoteLayerTreeDrawingAreaProxy.h"
#import "RemoteLayerTreeViews.h"
#import "RemoteScrollingCoordinatorProxy.h"
+#import "RevealItem.h"
#import "SmartMagnificationController.h"
#import "TextChecker.h"
#import "TextInputSPI.h"
@@ -7546,6 +7547,15 @@
return YES;
}
+#if ENABLE(REVEAL)
+- (void)requestRVItemInSelectedRangeWithCompletionHandler:(void(^)(RVItem *item))completionHandler
+{
+ _page->requestRVItemInCurrentSelectedRange([revealItemSelectionHandler = makeBlockPtr(completionHandler)](const WebKit::RevealItem& item) {
+ revealItemSelectionHandler(item.item());
+ });
+}
+#endif
+
- (BOOL)hasHiddenContentEditable
{
return _suppressSelectionAssistantReasons.containsAny({ WebKit::EditableRootIsTransparentOrFullyClipped, WebKit::FocusedElementIsTooSmall });
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (289684 => 289685)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2022-02-12 01:46:34 UTC (rev 289685)
@@ -48,6 +48,7 @@
#import "RemoteLayerTreeDrawingAreaProxyMessages.h"
#import "RemoteLayerTreeTransaction.h"
#import "RemoteScrollingCoordinatorProxy.h"
+#import "RevealItem.h"
#import "ShareableResource.h"
#import "TapHandlingResult.h"
#import "UIKitSPI.h"
@@ -525,6 +526,16 @@
sendWithAsyncReply(Messages::WebPage::RequestDictationContext(), WTFMove(callbackFunction));
}
+#if ENABLE(REVEAL)
+void WebPageProxy::requestRVItemInCurrentSelectedRange(CompletionHandler<void(const WebKit::RevealItem&)>&& callbackFunction)
+{
+ if (!hasRunningProcess())
+ return callbackFunction(RevealItem());
+
+ sendWithAsyncReply(Messages::WebPage::RequestRVItemInCurrentSelectedRange(), WTFMove(callbackFunction));
+}
+#endif
+
void WebPageProxy::requestAutocorrectionContext()
{
m_process->send(Messages::WebPage::HandleAutocorrectionContextRequest(), m_webPageID);
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (289684 => 289685)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2022-02-12 01:46:34 UTC (rev 289685)
@@ -865,6 +865,7 @@
41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */; };
41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; };
41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; };
+ 442E7BEB27B4586900C69AC1 /* RevealItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 442E7BEA27B4581300C69AC1 /* RevealItem.h */; };
4459984222833E8700E61373 /* SyntheticEditingCommandType.h in Headers */ = {isa = PBXBuildFile; fileRef = 4459984122833E6000E61373 /* SyntheticEditingCommandType.h */; };
4476EF0925BFC8B7004A0587 /* _WKAppHighlightDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4476EF0825BFC8B7004A0587 /* _WKAppHighlightDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
4482734724528F6000A95493 /* CocoaImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4482734624528F6000A95493 /* CocoaImage.h */; };
@@ -4228,6 +4229,8 @@
41FFD2DA275A560B00501BBF /* ServiceWorkerDownloadTask.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerDownloadTask.cpp; sourceTree = "<group>"; };
41FFD2DB275A560C00501BBF /* ServiceWorkerDownloadTask.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerDownloadTask.h; sourceTree = "<group>"; };
41FFD2DC275A6A9400501BBF /* ServiceWorkerDownloadTask.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = ServiceWorkerDownloadTask.messages.in; sourceTree = "<group>"; };
+ 442E7BE827B4572B00C69AC1 /* RevealItem.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RevealItem.mm; sourceTree = "<group>"; };
+ 442E7BEA27B4581300C69AC1 /* RevealItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RevealItem.h; sourceTree = "<group>"; };
4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryCocoa.cpp; sourceTree = "<group>"; };
4459984122833E6000E61373 /* SyntheticEditingCommandType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SyntheticEditingCommandType.h; sourceTree = "<group>"; };
4476EF0825BFC8B7004A0587 /* _WKAppHighlightDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKAppHighlightDelegate.h; sourceTree = "<group>"; };
@@ -9121,6 +9124,8 @@
2D440B8325EF235E00A98D87 /* PDFKitSoftLink.h */,
2D440B8225EF235E00A98D87 /* PDFKitSoftLink.mm */,
F4BE0D7627AAE1CB005F0323 /* PlaybackSessionContextIdentifier.h */,
+ 442E7BEA27B4581300C69AC1 /* RevealItem.h */,
+ 442E7BE827B4572B00C69AC1 /* RevealItem.mm */,
7AB4EA3F22777C460085BBAA /* SandboxExtensionCocoa.mm */,
7AB4EA4122777FC70085BBAA /* SandboxInitialiationParametersCocoa.mm */,
E19BDA88193686A400B97F57 /* SandboxUtilities.h */,
@@ -13447,6 +13452,7 @@
6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */,
6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */,
1A30066E1110F4F70031937C /* ResponsivenessTimer.h in Headers */,
+ 442E7BEB27B4586900C69AC1 /* RevealItem.h in Headers */,
410482CE1DDD324F00F006D0 /* RTCNetwork.h in Headers */,
46F38E8C2416E6730059375A /* RunningBoardServicesSPI.h in Headers */,
0E97D74D200E900400BF6643 /* SafeBrowsingSPI.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (289684 => 289685)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2022-02-12 01:46:34 UTC (rev 289685)
@@ -797,6 +797,9 @@
void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint&, WebCore::TextGranularity, bool isInteractingWithFocusedElement, CompletionHandler<void(bool)>&&);
void requestDictationContext(CompletionHandler<void(const String&, const String&, const String&)>&&);
+#if ENABLE(REVEAL)
+ void requestRVItemInCurrentSelectedRange(CompletionHandler<void(const WebKit::RevealItem&)>&&);
+#endif
void replaceDictatedText(const String& oldText, const String& newText);
void replaceSelectedText(const String& oldText, const String& newText);
void requestAutocorrectionData(const String& textForAutocorrection, CompletionHandler<void(WebAutocorrectionData)>&& reply);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (289684 => 289685)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2022-02-12 01:46:34 UTC (rev 289685)
@@ -81,6 +81,9 @@
UpdateSelectionWithExtentPoint(WebCore::IntPoint point, bool isInteractingWithFocusedElement, enum:bool WebKit::RespectSelectionAnchor respectSelectionAnchor) -> (bool endIsMoving) Async
UpdateSelectionWithExtentPointAndBoundary(WebCore::IntPoint point, enum:uint8_t WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement) -> (bool endIsMoving) Async
RequestDictationContext() -> (String selectedText, String textBefore, String textAfter) Async
+#if ENABLE(REVEAL)
+ RequestRVItemInCurrentSelectedRange() -> (WebKit::RevealItem item) Async
+#endif
ReplaceDictatedText(String oldText, String newText)
ReplaceSelectedText(String oldText, String newText)
RequestAutocorrectionData(String textForAutocorrection) -> (struct WebKit::WebAutocorrectionData data) Async
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (289684 => 289685)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2022-02-12 01:45:56 UTC (rev 289684)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2022-02-12 01:46:34 UTC (rev 289685)
@@ -41,6 +41,7 @@
#import "PrintInfo.h"
#import "RemoteLayerTreeDrawingArea.h"
#import "RemoteScrollingCoordinator.h"
+#import "RevealItem.h"
#import "SandboxUtilities.h"
#import "ShareableBitmapUtilities.h"
#import "SharedBufferCopy.h"
@@ -147,6 +148,7 @@
#import <WebCore/UserGestureIndicator.h>
#import <WebCore/VisibleUnits.h>
#import <WebCore/WebEvent.h>
+#import <pal/cocoa/RevealSoftLink.h>
#import <wtf/MathExtras.h>
#import <wtf/MemoryPressureHandler.h>
#import <wtf/Scope.h>
@@ -2342,6 +2344,35 @@
completionHandler(selectedText, contextBefore, contextAfter);
}
+#if ENABLE(REVEAL)
+void WebPage::requestRVItemInCurrentSelectedRange(CompletionHandler<void(const WebKit::RevealItem&)>&& completionHandler)
+{
+ Ref frame = CheckedRef(m_page->focusController())->focusedOrMainFrame();
+ auto selection = frame->selection().selection();
+ RetainPtr<RVItem> item;
+ if (!selection.isNone()) {
+ std::optional<SimpleRange> fullCharacterRange;
+ if (selection.isRange()) {
+ auto selectionStart = selection.visibleStart();
+ auto selectionEnd = selection.visibleEnd();
+
+ // As context, we are going to use the surrounding paragraphs of text.
+ fullCharacterRange = makeSimpleRange(startOfParagraph(selectionStart), endOfParagraph(selectionEnd));
+ if (!fullCharacterRange)
+ fullCharacterRange = makeSimpleRange(selectionStart, selectionEnd);
+
+ if (fullCharacterRange) {
+ auto selectionRange = NSMakeRange(characterCount(*makeSimpleRange(fullCharacterRange->start, selectionStart)), characterCount(*makeSimpleRange(selectionStart, selectionEnd)));
+ String itemString = plainText(*fullCharacterRange);
+ item = adoptNS([PAL::allocRVItemInstance() initWithText:itemString selectedRange:selectionRange]);
+ }
+ }
+ }
+
+ completionHandler(RevealItem(WTFMove(item)));
+}
+#endif
+
void WebPage::replaceSelectedText(const String& oldText, const String& newText)
{
Ref frame = CheckedRef(m_page->focusController())->focusedOrMainFrame();