-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Site Isolation] Aggregate find string match counts
https://bugs.webkit.org/show_bug.cgi?id=269551 rdar://123067488 Reviewed by Alex Christensen. The find string callback aggregator should sum the match counts from each web process response. Also reuse the find delegate in `WKWebViewFindString.mm`. * Source/WebKit/UIProcess/FindStringCallbackAggregator.cpp: (WebKit::FindStringCallbackAggregator::foundString): (WebKit::FindStringCallbackAggregator::~FindStringCallbackAggregator): * Source/WebKit/UIProcess/FindStringCallbackAggregator.h: * Source/WebKit/UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::findString): * Tools/TestWebKitAPI/SourcesCocoa.txt: * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm: (TestWebKitAPI::TEST): * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindString.mm: (-[WKWebViewFindStringFindDelegate findString]): Deleted. (-[WKWebViewFindStringFindDelegate _webView:didCountMatches:forString:]): Deleted. (-[WKWebViewFindStringFindDelegate _webView:didFindMatches:forString:withMatchIndex:]): Deleted. (-[WKWebViewFindStringFindDelegate _webView:didFailToFindString:]): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindStringFindDelegate.h: Copied from Source/WebKit/UIProcess/FindStringCallbackAggregator.h. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindStringFindDelegate.mm: Copied from Source/WebKit/UIProcess/FindStringCallbackAggregator.h. (-[WKWebViewFindStringFindDelegate findString]): (-[WKWebViewFindStringFindDelegate _webView:didCountMatches:forString:]): (-[WKWebViewFindStringFindDelegate _webView:didFindMatches:forString:withMatchIndex:]): (-[WKWebViewFindStringFindDelegate _webView:didFailToFindString:]): Canonical link: https://commits.webkit.org/274897@main
- Loading branch information
1 parent
39c785b
commit 6c9a595
Showing
9 changed files
with
138 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindStringFindDelegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2024 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/_WKFindDelegate.h> | ||
|
||
@interface WKWebViewFindStringFindDelegate : NSObject <_WKFindDelegate> | ||
@property (nonatomic, readonly) NSString *findString; | ||
@property (nonatomic, readonly) NSUInteger matchesCount; | ||
@property (nonatomic, readonly) NSInteger matchIndex; | ||
@property (nonatomic, readonly) BOOL didFail; | ||
@end |
64 changes: 64 additions & 0 deletions
64
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewFindStringFindDelegate.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2024 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 "WKWebViewFindStringFindDelegate.h" | ||
|
||
#import "DeprecatedGlobalValues.h" | ||
|
||
@implementation WKWebViewFindStringFindDelegate { | ||
RetainPtr<NSString> _findString; | ||
} | ||
|
||
- (NSString *)findString | ||
{ | ||
return _findString.get(); | ||
} | ||
|
||
- (void)_webView:(WKWebView *)webView didCountMatches:(NSUInteger)matches forString:(NSString *)string | ||
{ | ||
_findString = string; | ||
_matchesCount = matches; | ||
_didFail = NO; | ||
isDone = YES; | ||
} | ||
|
||
- (void)_webView:(WKWebView *)webView didFindMatches:(NSUInteger)matches forString:(NSString *)string withMatchIndex:(NSInteger)matchIndex | ||
{ | ||
_findString = string; | ||
_matchesCount = matches; | ||
_matchIndex = matchIndex; | ||
_didFail = NO; | ||
isDone = YES; | ||
} | ||
|
||
- (void)_webView:(WKWebView *)webView didFailToFindString:(NSString *)string | ||
{ | ||
_findString = string; | ||
_didFail = YES; | ||
isDone = YES; | ||
} | ||
|
||
@end |