Diff
Modified: trunk/Source/WebKit/ChangeLog (290313 => 290314)
--- trunk/Source/WebKit/ChangeLog 2022-02-22 17:44:56 UTC (rev 290313)
+++ trunk/Source/WebKit/ChangeLog 2022-02-22 17:50:53 UTC (rev 290314)
@@ -1,3 +1,24 @@
+2022-02-22 Aditya Keerthi <[email protected]>
+
+ [iOS] Adopt new _UITextSearching method for range comparison
+ https://bugs.webkit.org/show_bug.cgi?id=237012
+ rdar://88442811
+
+ Reviewed by Devin Rousso.
+
+ * Platform/spi/ios/UIKitSPI.h:
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView offsetFromPosition:toPosition:inDocument:]):
+
+ Mark deprecation.
+
+ (-[WKWebView compareFoundRange:toRange:inDocument:]):
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView compareFoundRange:toRange:inDocument:]):
+
+ Implement the new comparison method using existing offset computation logic.
+
2022-02-22 Alexander Kanavin <[email protected]>
When building introspection files, add CMAKE_C_FLAGS to the compiler flags.
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (290313 => 290314)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-02-22 17:44:56 UTC (rev 290313)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-02-22 17:50:53 UTC (rev 290314)
@@ -321,6 +321,8 @@
- (NSInteger)offsetFromPosition:(UITextPosition *)from toPosition:(UITextPosition *)toPosition inDocument:(_UITextSearchDocumentIdentifier)document;
+- (NSComparisonResult)compareFoundRange:(UITextRange *)fromRange toRange:(UITextRange *)toRange inDocument:(_UITextSearchDocumentIdentifier)document;
+
- (void)performTextSearchWithQueryString:(NSString *)string usingOptions:(_UITextSearchOptions *)options resultAggregator:(id<_UITextSearchAggregator>)aggregator;
- (void)decorateFoundTextRange:(UITextRange *)range inDocument:(_UITextSearchDocumentIdentifier)document usingStyle:(_UIFoundTextStyle)style;
Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (290313 => 290314)
--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-02-22 17:44:56 UTC (rev 290313)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-02-22 17:50:53 UTC (rev 290314)
@@ -3561,10 +3561,17 @@
ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
- (NSInteger)offsetFromPosition:(UITextPosition *)from toPosition:(UITextPosition *)toPosition inDocument:(_UITextSearchDocumentIdentifier)document
{
+ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
return [_contentView offsetFromPosition:from toPosition:toPosition inDocument:document];
+ ALLOW_DEPRECATED_DECLARATIONS_END
}
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
+- (NSComparisonResult)compareFoundRange:(UITextRange *)fromRange toRange:(UITextRange *)toRange inDocument:(_UITextSearchDocumentIdentifier)document
+{
+ return [_contentView compareFoundRange:fromRange toRange:toRange inDocument:document];
+}
+
- (void)performTextSearchWithQueryString:(NSString *)string usingOptions:(_UITextSearchOptions *)options resultAggregator:(id<_UITextSearchAggregator>)aggregator
{
[_contentView performTextSearchWithQueryString:string usingOptions:options resultAggregator:aggregator];
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (290313 => 290314)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2022-02-22 17:44:56 UTC (rev 290313)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2022-02-22 17:50:53 UTC (rev 290314)
@@ -790,6 +790,7 @@
#endif
#if HAVE(UIFINDINTERACTION)
+- (NSComparisonResult)compareFoundRange:(UITextRange *)fromRange toRange:(UITextRange *)toRange inDocument:(_UITextSearchDocumentIdentifier)document;
- (void)requestRectForFoundTextRange:(UITextRange *)range completionHandler:(void (^)(CGRect))completionHandler;
#endif
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (290313 => 290314)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-02-22 17:44:56 UTC (rev 290313)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-02-22 17:50:53 UTC (rev 290314)
@@ -10422,6 +10422,19 @@
}
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
+- (NSComparisonResult)compareFoundRange:(UITextRange *)fromRange toRange:(UITextRange *)toRange inDocument:(_UITextSearchDocumentIdentifier)document
+{
+ NSInteger offset = [self offsetFromPosition:fromRange.start toPosition:toRange.start];
+
+ if (offset < 0)
+ return NSOrderedAscending;
+
+ if (offset > 0)
+ return NSOrderedDescending;
+
+ return NSOrderedSame;
+}
+
- (void)requestRectForFoundTextRange:(UITextRange *)range completionHandler:(void (^)(CGRect))completionHandler
{
if (auto* foundTextRange = dynamic_objc_cast<WKFoundTextRange>(range)) {
Modified: trunk/Tools/ChangeLog (290313 => 290314)
--- trunk/Tools/ChangeLog 2022-02-22 17:44:56 UTC (rev 290313)
+++ trunk/Tools/ChangeLog 2022-02-22 17:50:53 UTC (rev 290314)
@@ -1,3 +1,21 @@
+2022-02-22 Aditya Keerthi <[email protected]>
+
+ [iOS] Adopt new _UITextSearching method for range comparison
+ https://bugs.webkit.org/show_bug.cgi?id=237012
+ rdar://88442811
+
+ Reviewed by Devin Rousso.
+
+ Ensure TestSearchAggregator conforms to _UITextSearchAggregator.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
+ (-[TestSearchAggregator initWithCompletionHandler:]):
+ (-[TestSearchAggregator allFoundRanges]):
+ (-[TestSearchAggregator invalidateFoundRange:inDocument:]):
+ (-[TestSearchAggregator invalidate]):
+ (textRangesForQueryString):
+ (-[TestSearchAggregator foundRanges]): Deleted.
+
2022-02-22 Angelos Oikonomopoulos <[email protected]>
[JSC] Guard against dead remotes in numberOfProcessors
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm (290313 => 290314)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm 2022-02-22 17:44:56 UTC (rev 290313)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm 2022-02-22 17:50:53 UTC (rev 290314)
@@ -340,7 +340,7 @@
@interface TestSearchAggregator : NSObject <_UITextSearchAggregator>
@property (readonly) NSUInteger count;
-@property (nonatomic, readonly) NSArray<UITextRange *> *foundRanges;
+@property (nonatomic, readonly) NSOrderedSet<UITextRange *> *allFoundRanges;
- (instancetype)initWithCompletionHandler:(dispatch_block_t)completionHandler;
@@ -347,7 +347,7 @@
@end
@implementation TestSearchAggregator {
- RetainPtr<NSMutableArray<UITextRange *>> _foundRanges;
+ RetainPtr<NSMutableOrderedSet<UITextRange *>> _foundRanges;
BlockPtr<void()> _completionHandler;
}
@@ -356,7 +356,7 @@
if (!(self = [super init]))
return nil;
- _foundRanges = adoptNS([[NSMutableArray alloc] init]);
+ _foundRanges = adoptNS([[NSMutableOrderedSet alloc] init]);
_completionHandler = makeBlockPtr(completionHandler);
return self;
@@ -373,11 +373,21 @@
_completionHandler();
}
-- (NSArray<UITextRange *>*)foundRanges
+- (NSOrderedSet<UITextRange *> *)allFoundRanges
{
return _foundRanges.get();
}
+- (void)invalidateFoundRange:(UITextRange *)range inDocument:(_UITextSearchDocumentIdentifier)document
+{
+ [_foundRanges removeObject:range];
+}
+
+- (void)invalidate
+{
+ [_foundRanges removeAllObjects];
+}
+
- (NSUInteger)count
{
return [_foundRanges count];
@@ -400,7 +410,7 @@
EXPECT_EQ([aggregator count], expectedMatches);
}
-static RetainPtr<NSArray<UITextRange *>> textRangesForQueryString(WKWebView *webView, NSString *query)
+static RetainPtr<NSOrderedSet<UITextRange *>> textRangesForQueryString(WKWebView *webView, NSString *query)
{
__block bool finishedSearching = false;
auto aggregator = adoptNS([[TestSearchAggregator alloc] initWithCompletionHandler:^{
@@ -413,7 +423,7 @@
TestWebKitAPI::Util::run(&finishedSearching);
- return adoptNS([[aggregator foundRanges] copy]);
+ return adoptNS([[aggregator allFoundRanges] copy]);
}
TEST(WebKit, FindInPage)