Diff
Modified: trunk/Source/WebKit/ChangeLog (252302 => 252303)
--- trunk/Source/WebKit/ChangeLog 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/ChangeLog 2019-11-09 04:06:58 UTC (rev 252303)
@@ -1,3 +1,57 @@
+2019-11-08 Brady Eidson <[email protected]>
+
+ WKWebView Find-in-page API.
+ <rdar://problem/46971112> and https://bugs.webkit.org/show_bug.cgi?id=203872
+
+ Reviewed by Tim Horton.
+
+ Covered by API tests.
+
+ - Promote _findString:
+ - Add a completion handler for it.
+
+ * SourcesCocoa.txt:
+
+ * UIProcess/API/Cocoa/WKFindConfiguration.h: Added.
+ * UIProcess/API/Cocoa/WKFindConfiguration.mm: Added.
+ (-[WKFindConfiguration init]):
+ (-[WKFindConfiguration copyWithZone:]):
+
+ * UIProcess/API/Cocoa/WKFindResult.h: Added.
+ * UIProcess/API/Cocoa/WKFindResult.mm: Added.
+ (-[WKFindResult init]):
+ (-[WKFindResult _initWithMatchFound:]):
+ (-[WKFindResult copyWithZone:]):
+ * UIProcess/API/Cocoa/WKFindResultInternal.h: Added.
+
+ * UIProcess/API/Cocoa/WKWebView.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (toFindOptions):
+ (-[WKWebView findString:withConfiguration:completionHandler:]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+ * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+
+ * UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h:
+ * UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::findString):
+ (WebKit::WebPageProxy::findStringCallback):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+
+ * WebKit.xcodeproj/project.pbxproj:
+
+ * WebProcess/WebPage/FindController.cpp:
+ (WebKit::FindController::findString):
+ * WebProcess/WebPage/FindController.h:
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::findString):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2019-11-08 Jiewen Tan <[email protected]>
[WebAuthn] Add quirk needed to support legacy Google NFC Titan security keys
Modified: trunk/Source/WebKit/SourcesCocoa.txt (252302 => 252303)
--- trunk/Source/WebKit/SourcesCocoa.txt 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2019-11-09 04:06:58 UTC (rev 252303)
@@ -290,6 +290,8 @@
UIProcess/API/Cocoa/WKContentRuleListStore.mm
UIProcess/API/Cocoa/WKContextMenuElementInfo.mm
UIProcess/API/Cocoa/WKError.mm
+UIProcess/API/Cocoa/WKFindConfiguration.mm
+UIProcess/API/Cocoa/WKFindResult.mm
UIProcess/API/Cocoa/WKFrameInfo.mm
UIProcess/API/Cocoa/WKHTTPCookieStore.mm
UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindConfiguration.h (0 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindConfiguration.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindConfiguration.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -0,0 +1,51 @@
+/*
+* Copyright (C) 2019 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 <WebKit/WKFoundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface WKFindConfiguration : NSObject <NSCopying>
+
+/* @abstract The direction to search from the current selection
+ @discussion The search will respect the writing direction of the document.
+ The initial value is NO.
+*/
+@property (nonatomic) BOOL backwards;
+
+/* @abstract Whether or not the search should be case sensitive
+ @discussion The initial value is NO.
+*/
+@property (nonatomic) BOOL caseSensitive;
+
+/* @abstract Whether the search should start at the beginning of the document once it reaches the end
+ @discussion The initial value is YES.
+*/
+@property (nonatomic) BOOL wraps;
+
+@end
+
+NS_ASSUME_NONNULL_END
Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindConfiguration.mm (from rev 252302, trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h) (0 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindConfiguration.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindConfiguration.mm 2019-11-09 04:06:58 UTC (rev 252303)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 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 "WKFindConfiguration.h"
+
+@implementation WKFindConfiguration
+
+- (instancetype)init
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _backwards = NO;
+ _caseSensitive = NO;
+ _wraps = YES;
+ return self;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ WKFindConfiguration *findConfiguration = [(WKFindConfiguration *)[[self class] allocWithZone:zone] init];
+
+ findConfiguration.backwards = _backwards;
+ findConfiguration.caseSensitive = _caseSensitive;
+ findConfiguration.wraps = _wraps;
+
+ return findConfiguration;
+}
+
+@end
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResult.h (0 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResult.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResult.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -0,0 +1,40 @@
+/*
+* Copyright (C) 2019 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 <WebKit/WKFoundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface WKFindResult : NSObject <NSCopying>
+
+- (instancetype)init NS_UNAVAILABLE;
+
+/* @abstract Whether or not a match was found during the find operation */
+@property (nonatomic, readonly) BOOL matchFound;
+
+@end
+
+NS_ASSUME_NONNULL_END
Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResult.mm (from rev 252302, trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h) (0 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResult.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResult.mm 2019-11-09 04:06:58 UTC (rev 252303)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 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 "WKFindResultInternal.h"
+
+@implementation WKFindResult
+
+- (instancetype)init
+{
+ return nil;
+}
+
+- (instancetype)_initWithMatchFound:(BOOL)matchFound
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _matchFound = matchFound;
+
+ return self;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ WKFindResult *findResult = [(WKFindResult *)[[self class] allocWithZone:zone] _initWithMatchFound:_matchFound];
+
+ return findResult;
+}
+
+@end
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResultInternal.h (0 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResultInternal.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKFindResultInternal.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -0,0 +1,32 @@
+/*
+* Copyright (C) 2019 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 "WKFindResult.h"
+
+@interface WKFindResult ()
+
+- (instancetype)_initWithMatchFound:(BOOL)matchFound;
+
+@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -35,6 +35,8 @@
@class WKBackForwardList;
@class WKBackForwardListItem;
+@class WKFindConfiguration;
+@class WKFindResult;
@class WKNavigation;
@class WKPDFConfiguration;
@class WKSnapshotConfiguration;
@@ -303,6 +305,16 @@
*/
@property (nonatomic) CGFloat pageZoom WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+/* @abstract Searches the page contents for the given string.
+ @param string The string to search for.
+ @param configuration A set of options configuring the search.
+ @param completionHandler A block to invoke when the search completes.
+ @discussion If the WKFindConfiguration is nil, all of the default WKFindConfiguration values will be used.
+ A match found by the search is selected and the page is scrolled to reveal the selection.
+ The completion handler is called after the search completes.
+*/
+- (void)findString:(NSString *)string withConfiguration:(nullable WKFindConfiguration *)configuration completionHandler:(void (^)(WKFindResult *result))completionHandler NS_REFINED_FOR_SWIFT WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
/* @abstract Checks whether or not WKWebViews handle the given URL scheme by default.
@param scheme The URL scheme to check.
*/
@@ -351,6 +363,10 @@
@end
+WK_API_AVAILABLE(macos(WK_MAC_TBA))
+@interface WKWebView (WKNSTextFinderClient) <NSTextFinderClient>
+@end
+
#endif
@interface WKWebView (WKDeprecated)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-11-09 04:06:58 UTC (rev 252303)
@@ -59,6 +59,8 @@
#import "WKBackForwardListItemInternal.h"
#import "WKBrowsingContextHandleInternal.h"
#import "WKErrorInternal.h"
+#import "WKFindConfiguration.h"
+#import "WKFindResultInternal.h"
#import "WKHistoryDelegatePrivate.h"
#import "WKLayoutMode.h"
#import "WKNSData.h"
@@ -4746,6 +4748,32 @@
});
}
+inline WebKit::FindOptions toFindOptions(WKFindConfiguration *configuration)
+{
+ unsigned findOptions = 0;
+
+ if (!configuration.caseSensitive)
+ findOptions |= WebKit::FindOptionsCaseInsensitive;
+ if (configuration.backwards)
+ findOptions |= WebKit::FindOptionsBackwards;
+ if (configuration.wraps)
+ findOptions |= WebKit::FindOptionsWrapAround;
+
+ return static_cast<WebKit::FindOptions>(findOptions);
+}
+
+- (void)findString:(NSString *)string withConfiguration:(WKFindConfiguration *)configuration completionHandler:(void (^)(WKFindResult *result))completionHandler
+{
+ if (!string.length) {
+ completionHandler([[[WKFindResult alloc] _initWithMatchFound:NO] autorelease]);
+ return;
+ }
+
+ _page->findString(string, toFindOptions(configuration), 1, [handler = makeBlockPtr(completionHandler)](bool found, WebKit::CallbackBase::Error error) {
+ handler([[[WKFindResult alloc] _initWithMatchFound:(error == WebKit::CallbackBase::Error::None && found)] autorelease]);
+ });
+}
+
@end
@implementation WKWebView (WKPrivate)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm 2019-11-09 04:06:58 UTC (rev 252303)
@@ -37,6 +37,7 @@
#import "WKWebView.h"
#import "WKWebViewContentProviderRegistry.h"
#import "WebKit2Initialize.h"
+#import "WebPreferencesDefaultValues.h"
#import "WebURLSchemeHandlerCocoa.h"
#import "_WKApplicationManifestInternal.h"
#import "_WKVisitedLinkStore.h"
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -450,11 +450,6 @@
@interface WKWebView () <UIResponderStandardEditActions>
@end
-#else
-
-@interface WKWebView (WKNSTextFinderClient) <NSTextFinderClient>
-@end
-
#endif
@interface WKWebView (WKTesting)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -28,6 +28,7 @@
#if HAVE(APP_SSO)
#include "SOAuthorizationSession.h"
+#include <wtf/CompletionHandler.h>
OBJC_CLASS WKSOSecretDelegate;
OBJC_CLASS WKWebView;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm 2019-11-09 04:06:58 UTC (rev 252303)
@@ -33,6 +33,7 @@
#import "WKUIDelegate.h"
#import "WKWebViewConfigurationPrivate.h"
#import "WKWebViewInternal.h"
+#import "WebPageProxy.h"
#import <WebCore/ResourceResponse.h>
#import <wtf/BlockPtr.h>
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-11-09 04:06:58 UTC (rev 252303)
@@ -3699,11 +3699,24 @@
m_process->send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount), m_webPageID);
}
-void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
+void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount, Function<void (bool, CallbackBase::Error)>&& callbackFunction)
{
- m_process->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_webPageID);
+ Optional<CallbackID> callbackID;
+ if (callbackFunction)
+ callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::findString"_s));
+
+ m_process->send(Messages::WebPage::FindString(string, options, maxMatchCount, callbackID), m_webPageID);
}
+void WebPageProxy::findStringCallback(bool found, CallbackID callbackID)
+{
+ auto callback = m_callbacks.take<BoolCallback>(callbackID);
+ if (!callback)
+ return;
+
+ callback->performCallbackWithReturnValue(found);
+}
+
void WebPageProxy::getImageForFindMatch(int32_t matchIndex)
{
m_process->send(Messages::WebPage::GetImageForFindMatch(matchIndex), m_webPageID);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -337,6 +337,7 @@
typedef GenericCallback<API::SerializedScriptValue*, bool, const WebCore::ExceptionDetails&> ScriptValueCallback;
typedef GenericCallback<const WebCore::FontAttributes&> FontAttributesCallback;
typedef GenericCallback<const String&, const String&, const String&> SelectionContextCallback;
+typedef GenericCallback<bool> BoolCallback;
#if HAVE(VISIBILITY_PROPAGATION_VIEW)
using LayerHostingContextID = uint32_t;
@@ -1019,7 +1020,7 @@
void pluginZoomFactorDidChange(double);
// Find.
- void findString(const String&, FindOptions, unsigned maxMatchCount);
+ void findString(const String&, FindOptions, unsigned maxMatchCount, Function<void (bool, CallbackBase::Error)>&& = nullptr);
void findStringMatches(const String&, FindOptions, unsigned maxMatchCount);
void getImageForFindMatch(int32_t matchIndex);
void selectFindMatch(int32_t matchIndex);
@@ -1032,6 +1033,8 @@
void setTextIndicator(const WebCore::TextIndicatorData&, uint64_t /* WebCore::TextIndicatorWindowLifetime */ lifetime = 0 /* Permanent */);
void setTextIndicatorAnimationProgress(float);
void clearTextIndicator();
+
+ void findStringCallback(bool found, CallbackID);
void didFindString(const String&, const Vector<WebCore::IntRect>&, uint32_t matchCount, int32_t matchIndex, bool didWrapAround);
void didFailToFindString(const String&);
void didFindStringMatches(const String&, const Vector<Vector<WebCore::IntRect>>& matchRects, int32_t firstIndexAfterSelection);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (252302 => 252303)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2019-11-09 04:06:58 UTC (rev 252303)
@@ -209,6 +209,7 @@
MachSendRightCallback(MachSendRight sendRight, WebKit::CallbackID callbackID)
NowPlayingInfoCallback(bool active, bool registeredAsNowPlayingApplication, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackID callbackID)
#endif
+ FindStringCallback(bool found, WebKit::CallbackID callbackID)
PageScaleFactorDidChange(double scaleFactor)
PluginScaleFactorDidChange(double zoomFactor)
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (252302 => 252303)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-11-09 04:06:58 UTC (rev 252303)
@@ -965,6 +965,9 @@
513FFB8D201459B0002596EA /* UIMessagePortChannelProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 513FFB8B201459A7002596EA /* UIMessagePortChannelProvider.h */; };
513FFB91201459C6002596EA /* WebMessagePortChannelProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 513FFB8F201459C2002596EA /* WebMessagePortChannelProvider.h */; };
514129941C6428BB0059E714 /* WebIDBConnectionToServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 514129921C6428100059E714 /* WebIDBConnectionToServer.h */; };
+ 51489CC32370DBFA0044E68A /* WKFindResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 51489CC12370DACC0044E68A /* WKFindResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 51489CC7237237800044E68A /* WKFindResultInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 51489CC6237237780044E68A /* WKFindResultInternal.h */; };
+ 514AB9F02360D2A900EDC396 /* WKFindConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 514AB9EF235FA59B00EDC396 /* WKFindConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
514BDED316C98EDD00E4E25E /* StatisticsRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 514BDED216C98EDD00E4E25E /* StatisticsRequest.h */; };
514D9F5719119D35000063A7 /* ServicesController.h in Headers */ = {isa = PBXBuildFile; fileRef = 514D9F5519119D35000063A7 /* ServicesController.h */; };
515262BC1FB9515D0070E579 /* WebSWServerToContextConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 515262BB1FB951310070E579 /* WebSWServerToContextConnectionMessages.h */; };
@@ -3344,6 +3347,11 @@
514129921C6428100059E714 /* WebIDBConnectionToServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIDBConnectionToServer.h; sourceTree = "<group>"; };
5143B25E1DDCDFD10014FAC6 /* _WKIconLoadingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKIconLoadingDelegate.h; sourceTree = "<group>"; };
5143B2611DDD0DA00014FAC6 /* APIIconLoadingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIIconLoadingClient.h; sourceTree = "<group>"; };
+ 51489CC12370DACC0044E68A /* WKFindResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindResult.h; sourceTree = "<group>"; };
+ 51489CC22370DACC0044E68A /* WKFindResult.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFindResult.mm; sourceTree = "<group>"; };
+ 51489CC6237237780044E68A /* WKFindResultInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindResultInternal.h; sourceTree = "<group>"; };
+ 514AB9EF235FA59B00EDC396 /* WKFindConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindConfiguration.h; sourceTree = "<group>"; };
+ 514AB9F12360E83D00EDC396 /* WKFindConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFindConfiguration.mm; sourceTree = "<group>"; };
514BDED216C98EDD00E4E25E /* StatisticsRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StatisticsRequest.h; sourceTree = "<group>"; };
514D9F5519119D35000063A7 /* ServicesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServicesController.h; sourceTree = "<group>"; };
514D9F5619119D35000063A7 /* ServicesController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ServicesController.mm; sourceTree = "<group>"; };
@@ -6442,6 +6450,11 @@
1AF4592C19464B2000F9D4A2 /* WKError.mm */,
1A2D252A194688FD004537B0 /* WKErrorInternal.h */,
37B5045119EEF31300CE2CF8 /* WKErrorPrivate.h */,
+ 514AB9EF235FA59B00EDC396 /* WKFindConfiguration.h */,
+ 514AB9F12360E83D00EDC396 /* WKFindConfiguration.mm */,
+ 51489CC12370DACC0044E68A /* WKFindResult.h */,
+ 51489CC22370DACC0044E68A /* WKFindResult.mm */,
+ 51489CC6237237780044E68A /* WKFindResultInternal.h */,
1A4D664A18A3030E00D82E21 /* WKFrameInfo.h */,
1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */,
2DF9EEE71A78245500B6CFBE /* WKFrameInfoInternal.h */,
@@ -10226,7 +10239,10 @@
BC4075FC124FF0270068F20A /* WKErrorRef.h in Headers */,
BC40783D1250FADD0068F20A /* WKEvent.h in Headers */,
A58B6F0818FCA733008CBA53 /* WKFileUploadPanel.h in Headers */,
+ 514AB9F02360D2A900EDC396 /* WKFindConfiguration.h in Headers */,
37F623B812A57B6200E3FDF6 /* WKFindOptions.h in Headers */,
+ 51489CC32370DBFA0044E68A /* WKFindResult.h in Headers */,
+ 51489CC7237237800044E68A /* WKFindResultInternal.h in Headers */,
2E16B6CF2017B7AD008996D6 /* WKFocusedFormControlView.h in Headers */,
E5CB07DC20E1678F0022C183 /* WKFormColorControl.h in Headers */,
E548EBD121015F0E00BE3C32 /* WKFormColorPicker.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (252302 => 252303)
--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2019-11-09 04:06:58 UTC (rev 252303)
@@ -224,7 +224,7 @@
hideFindIndicator();
}
-void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount)
+void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount, Optional<CallbackID> callbackID)
{
auto* pluginView = WebPage::pluginViewForFrame(m_webPage->mainFrame());
@@ -277,6 +277,9 @@
m_webPage->drawingArea()->dispatchAfterEnsuringUpdatedScrollPosition([protectedWebPage, found, string, options, maxMatchCount, didWrap] () {
protectedWebPage->findController().updateFindUIAfterPageScroll(found, string, options, maxMatchCount, didWrap, FindUIOriginator::FindString);
});
+
+ if (callbackID)
+ m_webPage->send(Messages::WebPageProxy::FindStringCallback(found, *callbackID));
}
void FindController::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.h (252302 => 252303)
--- trunk/Source/WebKit/WebProcess/WebPage/FindController.h 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -56,7 +56,7 @@
explicit FindController(WebPage*);
virtual ~FindController();
- void findString(const String&, FindOptions, unsigned maxMatchCount);
+ void findString(const String&, FindOptions, unsigned maxMatchCount, Optional<CallbackID>);
void findStringMatches(const String&, FindOptions, unsigned maxMatchCount);
void getImageForFindMatch(uint32_t matchIndex);
void selectFindMatch(uint32_t matchIndex);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (252302 => 252303)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-11-09 04:06:58 UTC (rev 252303)
@@ -4047,9 +4047,9 @@
findController().replaceMatches(matchIndices, replacementText, selectionOnly);
}
-void WebPage::findString(const String& string, uint32_t options, uint32_t maxMatchCount)
+void WebPage::findString(const String& string, uint32_t options, uint32_t maxMatchCount, Optional<CallbackID> callbackID)
{
- findController().findString(string, static_cast<FindOptions>(options), maxMatchCount);
+ findController().findString(string, static_cast<FindOptions>(options), maxMatchCount, callbackID);
}
void WebPage::findStringMatches(const String& string, uint32_t options, uint32_t maxMatchCount)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (252302 => 252303)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -1472,7 +1472,7 @@
void reapplyEditCommand(WebUndoStepID commandID);
void didRemoveEditCommand(WebUndoStepID commandID);
- void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
+ void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount, Optional<CallbackID>);
void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
void getImageForFindMatch(uint32_t matchIndex);
void selectFindMatch(uint32_t matchIndex);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (252302 => 252303)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2019-11-09 04:06:58 UTC (rev 252303)
@@ -284,7 +284,7 @@
PostInjectedBundleMessage(String messageName, WebKit::UserData messageBody)
# Find.
- FindString(String string, uint32_t findOptions, unsigned maxMatchCount)
+ FindString(String string, uint32_t findOptions, unsigned maxMatchCount, Optional<WebKit::CallbackID> callbackID)
FindStringMatches(String string, uint32_t findOptions, unsigned maxMatchCount)
GetImageForFindMatch(uint32_t matchIndex)
SelectFindMatch(uint32_t matchIndex)
Modified: trunk/Tools/ChangeLog (252302 => 252303)
--- trunk/Tools/ChangeLog 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Tools/ChangeLog 2019-11-09 04:06:58 UTC (rev 252303)
@@ -1,3 +1,17 @@
+2019-11-08 Brady Eidson <[email protected]>
+
+ WKWebView Find-in-page API.
+ <rdar://problem/46971112> and https://bugs.webkit.org/show_bug.cgi?id=203872
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/FindInPageAPI.mm: Added.
+ (TEST):
+ * TestWebKitAPI/cocoa/TestWKWebView.h:
+ * TestWebKitAPI/cocoa/TestWKWebView.mm:
+ (-[TestWKWebView selectionRangeHasStartOffset:endOffset:]):
+
2019-11-08 Jonathan Bedard <[email protected]>
Simulators having trouble launching apps after booting
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (252302 => 252303)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-11-09 04:06:58 UTC (rev 252303)
@@ -257,6 +257,7 @@
5110FCFA1E01CDB8006F8D0B /* IDBIndexUpgradeToV2.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5110FCEF1E01CBAA006F8D0B /* IDBIndexUpgradeToV2.mm */; };
5120C83D1E6751290025B250 /* WebsiteDataStoreCustomPaths.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */; };
5120C83E1E67678F0025B250 /* WebsiteDataStoreCustomPaths.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */; };
+ 51242CD52374E62500EED9C1 /* FindInPageAPI.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51242CD42374E61E00EED9C1 /* FindInPageAPI.mm */; };
512C4C9E20EAA40D004945EA /* ResponsivenessTimerCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 512C4C9D20EAA405004945EA /* ResponsivenessTimerCrash.mm */; };
51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */; };
51396E1A222E516000A42FCE /* LoadFileURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51396E19222E4E8600A42FCE /* LoadFileURL.mm */; };
@@ -1786,6 +1787,7 @@
5110FCF31E01CD77006F8D0B /* IndexUpgrade.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = IndexUpgrade.sqlite3; sourceTree = "<group>"; };
5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WebsiteDataStoreCustomPaths.html; sourceTree = "<group>"; };
5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebsiteDataStoreCustomPaths.mm; sourceTree = "<group>"; };
+ 51242CD42374E61E00EED9C1 /* FindInPageAPI.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindInPageAPI.mm; sourceTree = "<group>"; };
512C4C9D20EAA405004945EA /* ResponsivenessTimerCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResponsivenessTimerCrash.mm; sourceTree = "<group>"; };
51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionBasic_Bundle.cpp; sourceTree = "<group>"; };
51393E1E1523944A005F39C5 /* DOMWindowExtensionBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionBasic.cpp; sourceTree = "<group>"; };
@@ -2854,6 +2856,7 @@
F44D06461F395C4D001A0E29 /* EditorStateTests.mm */,
CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */,
2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
+ 51242CD42374E61E00EED9C1 /* FindInPageAPI.mm */,
118153472208BADF00B2CCD2 /* FirstVisuallyNonEmptyMilestone.mm */,
2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
2E92B8F8216490EA005B64F0 /* FontAttributes.mm */,
@@ -4605,6 +4608,7 @@
7A32D74A1F02151500162C44 /* FileMonitor.cpp in Sources */,
7CCE7EF31A411AE600447C4C /* Find.cpp in Sources */,
7C83E0BB1D0A650000FEBCF3 /* FindInPage.mm in Sources */,
+ 51242CD52374E62500EED9C1 /* FindInPageAPI.mm in Sources */,
7CCE7EF41A411AE600447C4C /* FindMatches.mm in Sources */,
11B7FD28219F47110069B27F /* FirstMeaningfulPaintMilestone.cpp in Sources */,
7C83E0401D0A63E300FEBCF3 /* FirstResponderScrollingPosition.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPageAPI.mm (0 => 252303)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPageAPI.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPageAPI.mm 2019-11-09 04:06:58 UTC (rev 252303)
@@ -0,0 +1,259 @@
+/*
+ * Copyright (C) 2019 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"
+
+#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKFindConfiguration.h>
+#import <WebKit/WKFindResult.h>
+#import <WebKit/WKWebView.h>
+#import <wtf/RetainPtr.h>
+
+
+TEST(WKWebView, FindAPIForwardsNoMatch)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:@"word word" baseURL:nil];
+
+ // The default find configuration is "forwards, case insensitive, wrapping"
+ auto configuration = adoptNS([[WKFindConfiguration alloc] init]);
+
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:0]);
+
+ static bool done;
+ [webView findString:@"foobar" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_FALSE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:0]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
+TEST(WKWebView, FindAPIForwardsWrap)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:@"word word" baseURL:nil];
+
+ // The default find configuration is "forwards, case insensitive, wrapping"
+ auto configuration = adoptNS([[WKFindConfiguration alloc] init]);
+
+ static bool done;
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:4]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:5 endOffset:9]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:4]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
+TEST(WKWebView, FindAPIForwardsNoWrap)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:@"word word" baseURL:nil];
+
+ // The default find configuration is "forwards, case insensitive, wrapping"
+ auto configuration = adoptNS([[WKFindConfiguration alloc] init]);
+ configuration.get().wraps = NO;
+
+ static bool done;
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:4]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:5 endOffset:9]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_FALSE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:0]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
+TEST(WKWebView, FindAPIBackwardsWrap)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:@"word word" baseURL:nil];
+
+ // The default find configuration is "forwards, case insensitive, wrapping"
+ auto configuration = adoptNS([[WKFindConfiguration alloc] init]);
+ configuration.get().backwards = YES;
+
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:0]);
+
+ static bool done;
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:5 endOffset:9]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:4]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:5 endOffset:9]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
+TEST(WKWebView, FindAPIBackwardsNoWrap)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:@"word word" baseURL:nil];
+
+ // The default find configuration is "forwards, case insensitive, wrapping"
+ auto configuration = adoptNS([[WKFindConfiguration alloc] init]);
+ configuration.get().backwards = YES;
+ configuration.get().wraps = NO;
+
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:0]);
+
+ static bool done;
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:5 endOffset:9]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:4]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_FALSE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:0]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
+TEST(WKWebView, FindAPIForwardsCaseSensitive)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView synchronouslyLoadHTMLString:@"word Word word" baseURL:nil];
+
+ // The default find configuration is "forwards, case insensitive, wrapping"
+ auto configuration = adoptNS([[WKFindConfiguration alloc] init]);
+ configuration.get().caseSensitive = YES;
+
+ static bool done;
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:4]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:10 endOffset:14]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:0 endOffset:4]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView findString:@"Word" withConfiguration:configuration.get() completionHandler:^(WKFindResult *result) {
+ EXPECT_TRUE(result.matchFound);
+ EXPECT_TRUE([webView selectionRangeHasStartOffset:5 endOffset:9]);
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (252302 => 252303)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2019-11-09 04:06:58 UTC (rev 252303)
@@ -83,6 +83,7 @@
- (void)collapseToStart;
- (void)collapseToEnd;
- (void)addToTestWindow;
+- (BOOL)selectionRangeHasStartOffset:(int)start endOffset:(int)end;
@end
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (252302 => 252303)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2019-11-09 03:45:18 UTC (rev 252302)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2019-11-09 04:06:58 UTC (rev 252303)
@@ -459,6 +459,24 @@
[self evaluateJavaScript:@"getSelection().collapseToEnd()" completionHandler:nil];
}
+- (BOOL)selectionRangeHasStartOffset:(int)start endOffset:(int)end
+{
+ __block bool isDone = false;
+ __block bool matches = true;
+ [self evaluateJavaScript:@"window.getSelection().getRangeAt(0).startOffset" completionHandler:^(id result, NSError *error) {
+ if ([(NSNumber *)result intValue] != start)
+ matches = false;
+ }];
+ [self evaluateJavaScript:@"window.getSelection().getRangeAt(0).endOffset" completionHandler:^(id result, NSError *error) {
+ if ([(NSNumber *)result intValue] != end)
+ matches = false;
+ isDone = true;
+ }];
+ TestWebKitAPI::Util::run(&isDone);
+
+ return matches;
+}
+
#if PLATFORM(IOS_FAMILY)
- (void)didStartFormControlInteraction