Diff
Modified: trunk/Source/WebKit/ChangeLog (264054 => 264055)
--- trunk/Source/WebKit/ChangeLog 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/ChangeLog 2020-07-08 02:28:46 UTC (rev 264055)
@@ -1,3 +1,38 @@
+2020-07-07 Alex Christensen <[email protected]>
+
+ Modernize FindOptions IPC code
+ https://bugs.webkit.org/show_bug.cgi?id=214063
+
+ Reviewed by Chris Dumez.
+
+ Use callWithAsyncReply instead of GenericCallback.
+ Use OptionSet<FindOptions> instead of FindOptions or uint32_t.
+ No change in behavior.
+
+ * Shared/API/c/WKSharedAPICast.h:
+ (WebKit::toFindOptions):
+ * Shared/WebFindOptions.h:
+ (): Deleted.
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (toFindOptions):
+ (-[WKWebView findString:withConfiguration:completionHandler:]):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::findStringMatches):
+ (WebKit::WebPageProxy::findString):
+ (WebKit::WebPageProxy::countStringMatches):
+ (WebKit::WebPageProxy::findStringCallback): Deleted.
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::findString):
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebPage/FindController.cpp:
+ (WebKit::core):
+ (WebKit::FindController::countStringMatches):
+ (WebKit::FindController::updateFindUIAfterPageScroll):
+ (WebKit::FindController::findString):
+ (WebKit::FindController::findStringMatches):
+ * WebProcess/WebPage/FindController.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2020-07-07 Sam Weinig <[email protected]>
Part 2 of SimpleColor and SRGBA<uint8_t> are essentially the same - let's converge them
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (264054 => 264055)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2020-07-08 02:28:46 UTC (rev 264055)
@@ -662,6 +662,7 @@
'WebKit::ActivityStateChangeID': ['"DrawingAreaInfo.h"'],
'WebKit::BackForwardListItemState': ['"SessionState.h"'],
'WebKit::ContentWorldIdentifier': ['"ContentWorldShared.h"'],
+ 'WebKit::FindOptions': ['"WebFindOptions.h"'],
'WebKit::GestureRecognizerState': ['"GestureTypes.h"'],
'WebKit::GestureType': ['"GestureTypes.h"'],
'WebKit::LayerHostingContextID': ['"LayerHostingContext.h"'],
Modified: trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h (264054 => 264055)
--- trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2020-07-08 02:28:46 UTC (rev 264055)
@@ -753,28 +753,28 @@
}
}
-inline FindOptions toFindOptions(WKFindOptions wkFindOptions)
+inline OptionSet<FindOptions> toFindOptions(WKFindOptions wkFindOptions)
{
- unsigned findOptions = 0;
+ OptionSet<FindOptions> findOptions;
if (wkFindOptions & kWKFindOptionsCaseInsensitive)
- findOptions |= FindOptionsCaseInsensitive;
+ findOptions.add(FindOptions::CaseInsensitive);
if (wkFindOptions & kWKFindOptionsAtWordStarts)
- findOptions |= FindOptionsAtWordStarts;
+ findOptions.add(FindOptions::AtWordStarts);
if (wkFindOptions & kWKFindOptionsTreatMedialCapitalAsWordStart)
- findOptions |= FindOptionsTreatMedialCapitalAsWordStart;
+ findOptions.add(FindOptions::TreatMedialCapitalAsWordStart);
if (wkFindOptions & kWKFindOptionsBackwards)
- findOptions |= FindOptionsBackwards;
+ findOptions.add(FindOptions::Backwards);
if (wkFindOptions & kWKFindOptionsWrapAround)
- findOptions |= FindOptionsWrapAround;
+ findOptions.add(FindOptions::WrapAround);
if (wkFindOptions & kWKFindOptionsShowOverlay)
- findOptions |= FindOptionsShowOverlay;
+ findOptions.add(FindOptions::ShowOverlay);
if (wkFindOptions & kWKFindOptionsShowFindIndicator)
- findOptions |= FindOptionsShowFindIndicator;
+ findOptions.add(FindOptions::ShowFindIndicator);
if (wkFindOptions & kWKFindOptionsShowHighlight)
- findOptions |= FindOptionsShowHighlight;
+ findOptions.add(FindOptions::ShowHighlight);
- return static_cast<FindOptions>(findOptions);
+ return findOptions;
}
inline WKFrameNavigationType toAPI(WebCore::NavigationType type)
Modified: trunk/Source/WebKit/Shared/WebFindOptions.h (264054 => 264055)
--- trunk/Source/WebKit/Shared/WebFindOptions.h 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/Shared/WebFindOptions.h 2020-07-08 02:28:46 UTC (rev 264055)
@@ -25,19 +25,41 @@
#pragma once
+#include <wtf/EnumTraits.h>
+
namespace WebKit {
-enum FindOptions : uint16_t {
- FindOptionsCaseInsensitive = 1 << 0,
- FindOptionsAtWordStarts = 1 << 1,
- FindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
- FindOptionsBackwards = 1 << 3,
- FindOptionsWrapAround = 1 << 4,
- FindOptionsShowOverlay = 1 << 5,
- FindOptionsShowFindIndicator = 1 << 6,
- FindOptionsShowHighlight = 1 << 7,
- FindOptionsDetermineMatchIndex = 1 << 8,
- FindOptionsNoIndexChange = 1 << 9,
+enum class FindOptions : uint16_t {
+ CaseInsensitive = 1 << 0,
+ AtWordStarts = 1 << 1,
+ TreatMedialCapitalAsWordStart = 1 << 2,
+ Backwards = 1 << 3,
+ WrapAround = 1 << 4,
+ ShowOverlay = 1 << 5,
+ ShowFindIndicator = 1 << 6,
+ ShowHighlight = 1 << 7,
+ DetermineMatchIndex = 1 << 8,
+ NoIndexChange = 1 << 9,
};
} // namespace WebKit
+
+namespace WTF {
+
+template<> struct EnumTraits<WebKit::FindOptions> {
+ using values = EnumValues<
+ WebKit::FindOptions,
+ WebKit::FindOptions::CaseInsensitive,
+ WebKit::FindOptions::AtWordStarts,
+ WebKit::FindOptions::TreatMedialCapitalAsWordStart,
+ WebKit::FindOptions::Backwards,
+ WebKit::FindOptions::WrapAround,
+ WebKit::FindOptions::ShowOverlay,
+ WebKit::FindOptions::ShowFindIndicator,
+ WebKit::FindOptions::ShowHighlight,
+ WebKit::FindOptions::DetermineMatchIndex,
+ WebKit::FindOptions::NoIndexChange
+ >;
+};
+
+} // namespace WTF
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (264054 => 264055)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2020-07-08 02:28:46 UTC (rev 264055)
@@ -1124,18 +1124,18 @@
return _page->pageZoomFactor();
}
-inline WebKit::FindOptions toFindOptions(WKFindConfiguration *configuration)
+inline OptionSet<WebKit::FindOptions> toFindOptions(WKFindConfiguration *configuration)
{
- unsigned findOptions = 0;
+ OptionSet<WebKit::FindOptions> findOptions;
if (!configuration.caseSensitive)
- findOptions |= WebKit::FindOptionsCaseInsensitive;
+ findOptions.add(WebKit::FindOptions::CaseInsensitive);
if (configuration.backwards)
- findOptions |= WebKit::FindOptionsBackwards;
+ findOptions.add(WebKit::FindOptions::Backwards);
if (configuration.wraps)
- findOptions |= WebKit::FindOptionsWrapAround;
+ findOptions.add(WebKit::FindOptions::WrapAround);
- return static_cast<WebKit::FindOptions>(findOptions);
+ return findOptions;
}
- (void)findString:(NSString *)string withConfiguration:(WKFindConfiguration *)configuration completionHandler:(void (^)(WKFindResult *result))completionHandler
@@ -1145,8 +1145,8 @@
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]);
+ _page->findString(string, toFindOptions(configuration), 1, [handler = makeBlockPtr(completionHandler)](bool found) {
+ handler([[[WKFindResult alloc] _initWithMatchFound:found] autorelease]);
});
}
@@ -2569,32 +2569,32 @@
static_cast<WebKit::FindClient&>(_page->findClient()).setDelegate(findDelegate);
}
-static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
+static inline OptionSet<WebKit::FindOptions> toFindOptions(_WKFindOptions wkFindOptions)
{
- unsigned findOptions = 0;
+ OptionSet<WebKit::FindOptions> findOptions;
if (wkFindOptions & _WKFindOptionsCaseInsensitive)
- findOptions |= WebKit::FindOptionsCaseInsensitive;
+ findOptions.add(WebKit::FindOptions::CaseInsensitive);
if (wkFindOptions & _WKFindOptionsAtWordStarts)
- findOptions |= WebKit::FindOptionsAtWordStarts;
+ findOptions.add(WebKit::FindOptions::AtWordStarts);
if (wkFindOptions & _WKFindOptionsTreatMedialCapitalAsWordStart)
- findOptions |= WebKit::FindOptionsTreatMedialCapitalAsWordStart;
+ findOptions.add(WebKit::FindOptions::TreatMedialCapitalAsWordStart);
if (wkFindOptions & _WKFindOptionsBackwards)
- findOptions |= WebKit::FindOptionsBackwards;
+ findOptions.add(WebKit::FindOptions::Backwards);
if (wkFindOptions & _WKFindOptionsWrapAround)
- findOptions |= WebKit::FindOptionsWrapAround;
+ findOptions.add(WebKit::FindOptions::WrapAround);
if (wkFindOptions & _WKFindOptionsShowOverlay)
- findOptions |= WebKit::FindOptionsShowOverlay;
+ findOptions.add(WebKit::FindOptions::ShowOverlay);
if (wkFindOptions & _WKFindOptionsShowFindIndicator)
- findOptions |= WebKit::FindOptionsShowFindIndicator;
+ findOptions.add(WebKit::FindOptions::ShowFindIndicator);
if (wkFindOptions & _WKFindOptionsShowHighlight)
- findOptions |= WebKit::FindOptionsShowHighlight;
+ findOptions.add(WebKit::FindOptions::ShowHighlight);
if (wkFindOptions & _WKFindOptionsNoIndexChange)
- findOptions |= WebKit::FindOptionsNoIndexChange;
+ findOptions.add(WebKit::FindOptions::NoIndexChange);
if (wkFindOptions & _WKFindOptionsDetermineMatchIndex)
- findOptions |= WebKit::FindOptionsDetermineMatchIndex;
+ findOptions.add(WebKit::FindOptions::DetermineMatchIndex);
- return static_cast<WebKit::FindOptions>(findOptions);
+ return findOptions;
}
- (void)_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitFindController.cpp (264054 => 264055)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitFindController.cpp 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitFindController.cpp 2020-07-08 02:28:46 UTC (rev 264055)
@@ -73,8 +73,7 @@
struct _WebKitFindControllerPrivate {
CString searchText;
- // Interpreted as WebKit::FindOptions.
- uint32_t findOptions;
+ OptionSet<WebKit::FindOptions> findOptions;
unsigned maxMatchCount;
WebKitWebView* webView;
};
@@ -83,22 +82,29 @@
WEBKIT_DEFINE_TYPE(WebKitFindController, webkit_find_controller, G_TYPE_OBJECT)
-static inline WebKit::FindOptions toWebFindOptions(uint32_t findOptions)
+static inline OptionSet<WebKit::FindOptions> toWebFindOptions(uint32_t findOptions)
{
- return static_cast<WebKit::FindOptions>((findOptions & WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE ? FindOptionsCaseInsensitive : 0)
- | (findOptions & WEBKIT_FIND_OPTIONS_AT_WORD_STARTS ? FindOptionsAtWordStarts : 0)
- | (findOptions & WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START ? FindOptionsTreatMedialCapitalAsWordStart : 0)
- | (findOptions & WEBKIT_FIND_OPTIONS_BACKWARDS ? FindOptionsBackwards : 0)
- | (findOptions & WEBKIT_FIND_OPTIONS_WRAP_AROUND ? FindOptionsWrapAround : 0));
+ OptionSet<WebKit::FindOptions> options;
+ if (findOptions & WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE)
+ options.add(WebKit::FindOptions::CaseInsensitive);
+ if (findOptions & WEBKIT_FIND_OPTIONS_AT_WORD_STARTS)
+ options.add(WebKit::FindOptions::AtWordStarts);
+ if (findOptions & WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START)
+ options.add(WebKit::FindOptions::TreatMedialCapitalAsWordStart);
+ if (findOptions & WEBKIT_FIND_OPTIONS_BACKWARDS)
+ options.add(WebKit::FindOptions::Backwards);
+ if (findOptions & WEBKIT_FIND_OPTIONS_WRAP_AROUND)
+ options.add(WebKit::FindOptions::WrapAround);
+ return options;
}
-static inline WebKitFindOptions toWebKitFindOptions(uint32_t findOptions)
+static inline WebKitFindOptions toWebKitFindOptions(OptionSet<WebKit::FindOptions> findOptions)
{
- return static_cast<WebKitFindOptions>((findOptions & FindOptionsCaseInsensitive ? WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE : 0)
- | (findOptions & FindOptionsAtWordStarts ? WEBKIT_FIND_OPTIONS_AT_WORD_STARTS : 0)
- | (findOptions & FindOptionsTreatMedialCapitalAsWordStart ? WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START : 0)
- | (findOptions & FindOptionsBackwards ? WEBKIT_FIND_OPTIONS_BACKWARDS : 0)
- | (findOptions & FindOptionsWrapAround ? WEBKIT_FIND_OPTIONS_WRAP_AROUND : 0));
+ return static_cast<WebKitFindOptions>((findOptions.contains(WebKit::FindOptions::CaseInsensitive) ? WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE : 0)
+ | (findOptions.contains(WebKit::FindOptions::AtWordStarts) ? WEBKIT_FIND_OPTIONS_AT_WORD_STARTS : 0)
+ | (findOptions.contains(WebKit::FindOptions::TreatMedialCapitalAsWordStart) ? WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START : 0)
+ | (findOptions.contains(WebKit::FindOptions::Backwards) ? WEBKIT_FIND_OPTIONS_BACKWARDS : 0)
+ | (findOptions.contains(WebKit::FindOptions::WrapAround) ? WEBKIT_FIND_OPTIONS_WRAP_AROUND : 0));
}
static inline WebPageProxy& getPage(WebKitFindController* findController)
@@ -365,11 +371,11 @@
WebKitFindControllerPrivate* priv = findController->priv;
if (operation == CountOperation) {
getPage(findController).countStringMatches(String::fromUTF8(priv->searchText.data()),
- static_cast<WebKit::FindOptions>(priv->findOptions), priv->maxMatchCount);
+ priv->findOptions, priv->maxMatchCount);
return;
}
- uint32_t findOptions = priv->findOptions;
+ OptionSet<WebKit::FindOptions> findOptions = priv->findOptions;
if (operation == FindOperation)
// Unconditionally highlight text matches when the search
// starts. WK1 API was forcing clients to enable/disable
@@ -378,15 +384,15 @@
// unconditionally show highlights. Both search_next() and
// search_prev() should not enable highlighting to avoid an
// extra unmarkAllTextMatches() + markAllTextMatches()
- findOptions |= FindOptionsShowHighlight;
+ findOptions.add(WebKit::FindOptions::ShowHighlight);
- getPage(findController).findString(String::fromUTF8(priv->searchText.data()), static_cast<WebKit::FindOptions>(findOptions), priv->maxMatchCount);
+ getPage(findController).findString(String::fromUTF8(priv->searchText.data()), findOptions, priv->maxMatchCount);
}
static inline void webKitFindControllerSetSearchData(WebKitFindController* findController, const gchar* searchText, guint32 findOptions, guint maxMatchCount)
{
findController->priv->searchText = searchText;
- findController->priv->findOptions = findOptions;
+ findController->priv->findOptions = toWebFindOptions(findOptions);
findController->priv->maxMatchCount = maxMatchCount;
}
@@ -421,7 +427,7 @@
{
g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
g_return_if_fail(searchText);
- webKitFindControllerSetSearchData(findController, searchText, toWebFindOptions(findOptions), maxMatchCount);
+ webKitFindControllerSetSearchData(findController, searchText, findOptions, maxMatchCount);
webKitFindControllerPerform(findController, FindOperation);
}
@@ -438,8 +444,8 @@
{
g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
- findController->priv->findOptions &= ~FindOptionsBackwards;
- findController->priv->findOptions &= ~FindOptionsShowHighlight;
+ findController->priv->findOptions.remove(WebKit::FindOptions::Backwards);
+ findController->priv->findOptions.remove(WebKit::FindOptions::ShowHighlight);
webKitFindControllerPerform(findController, FindNextPrevOperation);
}
@@ -456,8 +462,8 @@
{
g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
- findController->priv->findOptions |= FindOptionsBackwards;
- findController->priv->findOptions &= ~FindOptionsShowHighlight;
+ findController->priv->findOptions.add(WebKit::FindOptions::Backwards);
+ findController->priv->findOptions.remove(WebKit::FindOptions::ShowHighlight);
webKitFindControllerPerform(findController, FindNextPrevOperation);
}
@@ -478,7 +484,7 @@
g_return_if_fail(WEBKIT_IS_FIND_CONTROLLER(findController));
g_return_if_fail(searchText);
- webKitFindControllerSetSearchData(findController, searchText, toWebFindOptions(findOptions), maxMatchCount);
+ webKitFindControllerSetSearchData(findController, searchText, findOptions, maxMatchCount);
webKitFindControllerPerform(findController, CountOperation);
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (264054 => 264055)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-07-08 02:28:46 UTC (rev 264055)
@@ -4027,7 +4027,7 @@
m_pluginZoomFactor = pluginZoomFactor;
}
-void WebPageProxy::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
+void WebPageProxy::findStringMatches(const String& string, OptionSet<FindOptions> options, unsigned maxMatchCount)
{
if (string.isEmpty()) {
didFindStringMatches(string, Vector<Vector<WebCore::IntRect>> (), 0);
@@ -4037,24 +4037,11 @@
send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount));
}
-void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount, Function<void (bool, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::findString(const String& string, OptionSet<FindOptions> options, unsigned maxMatchCount, CompletionHandler<void(bool)>&& callbackFunction)
{
- Optional<CallbackID> callbackID;
- if (callbackFunction)
- callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::findString"_s));
-
- send(Messages::WebPage::FindString(string, options, maxMatchCount, callbackID));
+ sendWithAsyncReply(Messages::WebPage::FindString(string, options, maxMatchCount), WTFMove(callbackFunction));
}
-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)
{
send(Messages::WebPage::GetImageForFindMatch(matchIndex));
@@ -4075,7 +4062,7 @@
send(Messages::WebPage::HideFindUI());
}
-void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
+void WebPageProxy::countStringMatches(const String& string, OptionSet<FindOptions> options, unsigned maxMatchCount)
{
if (!hasRunningProcess())
return;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (264054 => 264055)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-07-08 02:28:46 UTC (rev 264055)
@@ -1097,14 +1097,14 @@
void pluginZoomFactorDidChange(double);
// Find.
- void findString(const String&, FindOptions, unsigned maxMatchCount, Function<void (bool, CallbackBase::Error)>&& = nullptr);
- void findStringMatches(const String&, FindOptions, unsigned maxMatchCount);
+ void findString(const String&, OptionSet<FindOptions>, unsigned maxMatchCount, CompletionHandler<void(bool)>&& = [](bool) { });
+ void findStringMatches(const String&, OptionSet<FindOptions>, unsigned maxMatchCount);
void getImageForFindMatch(int32_t matchIndex);
void selectFindMatch(int32_t matchIndex);
void indicateFindMatch(int32_t matchIndex);
void didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex);
void hideFindUI();
- void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
+ void countStringMatches(const String&, OptionSet<FindOptions>, unsigned maxMatchCount);
void replaceMatches(Vector<uint32_t>&& matchIndices, const String& replacementText, bool selectionOnly, Function<void(uint64_t, CallbackBase::Error)>&&);
void didCountStringMatches(const String&, uint32_t matchCount);
void setTextIndicator(const WebCore::TextIndicatorData&, uint64_t /* WebCore::TextIndicatorWindowLifetime */ lifetime = 0 /* Permanent */);
@@ -1111,7 +1111,6 @@
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 (264054 => 264055)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2020-07-08 02:28:46 UTC (rev 264055)
@@ -200,7 +200,6 @@
DrawToPDFCallback(IPC::DataReference pdfData, 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/UIProcess/mac/WKTextFinderClient.mm (264054 => 264055)
--- trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm 2020-07-08 02:28:46 UTC (rev 264055)
@@ -208,21 +208,21 @@
// proportional to document length.
maxResults = std::min(maxResults, maximumFindMatches);
- unsigned kitFindOptions = 0;
+ OptionSet<WebKit::FindOptions> kitFindOptions;
if (findOptions & NSTextFinderAsynchronousDocumentFindOptionsBackwards)
- kitFindOptions |= WebKit::FindOptionsBackwards;
+ kitFindOptions.add(WebKit::FindOptions::Backwards);
if (findOptions & NSTextFinderAsynchronousDocumentFindOptionsWrap)
- kitFindOptions |= WebKit::FindOptionsWrapAround;
+ kitFindOptions.add(WebKit::FindOptions::WrapAround);
if (findOptions & NSTextFinderAsynchronousDocumentFindOptionsCaseInsensitive)
- kitFindOptions |= WebKit::FindOptionsCaseInsensitive;
+ kitFindOptions.add(WebKit::FindOptions::CaseInsensitive);
if (findOptions & NSTextFinderAsynchronousDocumentFindOptionsStartsWith)
- kitFindOptions |= WebKit::FindOptionsAtWordStarts;
+ kitFindOptions.add(WebKit::FindOptions::AtWordStarts);
if (!_usePlatformFindUI) {
- kitFindOptions |= WebKit::FindOptionsShowOverlay;
- kitFindOptions |= WebKit::FindOptionsShowFindIndicator;
- kitFindOptions |= WebKit::FindOptionsDetermineMatchIndex;
+ kitFindOptions.add(WebKit::FindOptions::ShowOverlay);
+ kitFindOptions.add(WebKit::FindOptions::ShowFindIndicator);
+ kitFindOptions.add(WebKit::FindOptions::DetermineMatchIndex);
}
RetainPtr<NSProgress> progress = [NSProgress progressWithTotalUnitCount:1];
@@ -234,9 +234,9 @@
});
if (maxResults == 1)
- _page->findString(targetString, static_cast<WebKit::FindOptions>(kitFindOptions), maxResults);
+ _page->findString(targetString, kitFindOptions, maxResults);
else
- _page->findStringMatches(targetString, static_cast<WebKit::FindOptions>(kitFindOptions), maxResults);
+ _page->findStringMatches(targetString, kitFindOptions, maxResults);
}
- (void)getSelectedText:(void (^)(NSString *selectedTextString))completionHandler
Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (264054 => 264055)
--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2020-07-08 02:28:46 UTC (rev 264055)
@@ -55,18 +55,18 @@
namespace WebKit {
using namespace WebCore;
-WebCore::FindOptions core(FindOptions options)
+WebCore::FindOptions core(OptionSet<FindOptions> options)
{
WebCore::FindOptions result;
- if (options & FindOptionsCaseInsensitive)
+ if (options.contains(FindOptions::CaseInsensitive))
result.add(WebCore::CaseInsensitive);
- if (options & FindOptionsAtWordStarts)
+ if (options.contains(FindOptions::AtWordStarts))
result.add(WebCore::AtWordStarts);
- if (options & FindOptionsTreatMedialCapitalAsWordStart)
+ if (options.contains(FindOptions::TreatMedialCapitalAsWordStart))
result.add(WebCore::TreatMedialCapitalAsWordStart);
- if (options & FindOptionsBackwards)
+ if (options.contains(FindOptions::Backwards))
result.add(WebCore::Backwards);
- if (options & FindOptionsWrapAround)
+ if (options.contains(FindOptions::WrapAround))
result.add(WebCore::WrapAround);
return result;
}
@@ -80,7 +80,7 @@
{
}
-void FindController::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
+void FindController::countStringMatches(const String& string, OptionSet<FindOptions> options, unsigned maxMatchCount)
{
if (maxMatchCount == std::numeric_limits<unsigned>::max())
--maxMatchCount;
@@ -132,7 +132,7 @@
return 0;
}
-void FindController::updateFindUIAfterPageScroll(bool found, const String& string, FindOptions options, unsigned maxMatchCount, DidWrap didWrap, FindUIOriginator originator)
+void FindController::updateFindUIAfterPageScroll(bool found, const String& string, OptionSet<FindOptions> options, unsigned maxMatchCount, DidWrap didWrap, FindUIOriginator originator)
{
Frame* selectedFrame = frameWithSelection(m_webPage->corePage());
@@ -153,9 +153,9 @@
m_webPage->send(Messages::WebPageProxy::DidFailToFindString(string));
} else {
- shouldShowOverlay = options & FindOptionsShowOverlay;
- bool shouldShowHighlight = options & FindOptionsShowHighlight;
- bool shouldDetermineMatchIndex = options & FindOptionsDetermineMatchIndex;
+ shouldShowOverlay = options.contains(FindOptions::ShowOverlay);
+ bool shouldShowHighlight = options.contains(FindOptions::ShowHighlight);
+ bool shouldDetermineMatchIndex = options.contains(FindOptions::DetermineMatchIndex);
unsigned matchCount = 1;
if (shouldDetermineMatchIndex) {
@@ -221,11 +221,11 @@
m_findPageOverlay->setNeedsDisplay();
}
- if (found && (!(options & FindOptionsShowFindIndicator) || !selectedFrame || !updateFindIndicator(*selectedFrame, shouldShowOverlay)))
+ if (found && (!options.contains(FindOptions::ShowFindIndicator) || !selectedFrame || !updateFindIndicator(*selectedFrame, shouldShowOverlay)))
hideFindIndicator();
}
-void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount, Optional<CallbackID> callbackID)
+void FindController::findString(const String& string, OptionSet<FindOptions> options, unsigned maxMatchCount, CompletionHandler<void(bool)>&& completionHandler)
{
auto* pluginView = WebPage::pluginViewForFrame(m_webPage->mainFrame());
@@ -267,9 +267,9 @@
didFindString();
if (!foundStringStartsAfterSelection) {
- if (options & FindOptionsBackwards)
+ if (options.contains(FindOptions::Backwards))
m_foundStringMatchIndex--;
- else if (!(options & FindOptionsNoIndexChange))
+ else if (!options.contains(FindOptions::NoIndexChange))
m_foundStringMatchIndex++;
}
}
@@ -279,11 +279,10 @@
protectedWebPage->findController().updateFindUIAfterPageScroll(found, string, options, maxMatchCount, didWrap, FindUIOriginator::FindString);
});
- if (callbackID)
- m_webPage->send(Messages::WebPageProxy::FindStringCallback(found, *callbackID));
+ completionHandler(found);
}
-void FindController::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
+void FindController::findStringMatches(const String& string, OptionSet<FindOptions> options, unsigned maxMatchCount)
{
m_findMatches.clear();
int indexForSelection;
@@ -296,7 +295,7 @@
m_webPage->send(Messages::WebPageProxy::DidFindStringMatches(string, matchRects, indexForSelection));
- if (!(options & FindOptionsShowOverlay || options & FindOptionsShowFindIndicator))
+ if (!options.contains(FindOptions::ShowOverlay) && !options.contains(FindOptions::ShowFindIndicator))
return;
bool found = !m_findMatches.isEmpty();
Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.h (264054 => 264055)
--- trunk/Source/WebKit/WebProcess/WebPage/FindController.h 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.h 2020-07-08 02:28:46 UTC (rev 264055)
@@ -57,13 +57,13 @@
explicit FindController(WebPage*);
virtual ~FindController();
- void findString(const String&, FindOptions, unsigned maxMatchCount, Optional<CallbackID>);
- void findStringMatches(const String&, FindOptions, unsigned maxMatchCount);
+ void findString(const String&, OptionSet<FindOptions>, unsigned maxMatchCount, CompletionHandler<void(bool)>&&);
+ void findStringMatches(const String&, OptionSet<FindOptions>, unsigned maxMatchCount);
void getImageForFindMatch(uint32_t matchIndex);
void selectFindMatch(uint32_t matchIndex);
void indicateFindMatch(uint32_t matchIndex);
void hideFindUI();
- void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
+ void countStringMatches(const String&, OptionSet<FindOptions>, unsigned maxMatchCount);
uint32_t replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly);
void hideFindIndicator();
@@ -88,7 +88,7 @@
bool updateFindIndicator(WebCore::Frame& selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
enum class FindUIOriginator : uint8_t { FindString, FindStringMatches };
- void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount, WebCore::DidWrap, FindUIOriginator);
+ void updateFindUIAfterPageScroll(bool found, const String&, OptionSet<FindOptions>, unsigned maxMatchCount, WebCore::DidWrap, FindUIOriginator);
void willFindString();
void didFindString();
@@ -116,6 +116,6 @@
#endif
};
-WebCore::FindOptions core(FindOptions);
+WebCore::FindOptions core(OptionSet<FindOptions>);
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (264054 => 264055)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-07-08 02:28:46 UTC (rev 264055)
@@ -4186,12 +4186,12 @@
m_activeOpenPanelResultListener = WTFMove(openPanelResultListener);
}
-bool WebPage::findStringFromInjectedBundle(const String& target, FindOptions options)
+bool WebPage::findStringFromInjectedBundle(const String& target, OptionSet<FindOptions> options)
{
return m_page->findString(target, core(options));
}
-void WebPage::findStringMatchesFromInjectedBundle(const String& target, FindOptions options)
+void WebPage::findStringMatchesFromInjectedBundle(const String& target, OptionSet<FindOptions> options)
{
findController().findStringMatches(target, options, 0);
}
@@ -4201,14 +4201,14 @@
findController().replaceMatches(matchIndices, replacementText, selectionOnly);
}
-void WebPage::findString(const String& string, uint32_t options, uint32_t maxMatchCount, Optional<CallbackID> callbackID)
+void WebPage::findString(const String& string, OptionSet<FindOptions> options, uint32_t maxMatchCount, CompletionHandler<void(bool)>&& completionHandler)
{
- findController().findString(string, static_cast<FindOptions>(options), maxMatchCount, callbackID);
+ findController().findString(string, options, maxMatchCount, WTFMove(completionHandler));
}
-void WebPage::findStringMatches(const String& string, uint32_t options, uint32_t maxMatchCount)
+void WebPage::findStringMatches(const String& string, OptionSet<FindOptions> options, uint32_t maxMatchCount)
{
- findController().findStringMatches(string, static_cast<FindOptions>(options), maxMatchCount);
+ findController().findStringMatches(string, options, maxMatchCount);
}
void WebPage::getImageForFindMatch(uint32_t matchIndex)
@@ -4231,9 +4231,9 @@
findController().hideFindUI();
}
-void WebPage::countStringMatches(const String& string, uint32_t options, uint32_t maxMatchCount)
+void WebPage::countStringMatches(const String& string, OptionSet<FindOptions> options, uint32_t maxMatchCount)
{
- findController().countStringMatches(string, static_cast<FindOptions>(options), maxMatchCount);
+ findController().countStringMatches(string, options, maxMatchCount);
}
void WebPage::replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly, CallbackID callbackID)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (264054 => 264055)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-07-08 02:28:46 UTC (rev 264055)
@@ -277,7 +277,7 @@
class WebWheelEvent;
class RemoteLayerTreeTransaction;
-enum FindOptions : uint16_t;
+enum class FindOptions : uint16_t;
enum class DragControllerAction : uint8_t;
enum class SyntheticEditingCommandType : uint8_t;
@@ -471,8 +471,8 @@
InjectedBundlePageFullScreenClient& injectedBundleFullScreenClient() { return m_fullScreenClient; }
#endif
- bool findStringFromInjectedBundle(const String&, FindOptions);
- void findStringMatchesFromInjectedBundle(const String&, FindOptions);
+ bool findStringFromInjectedBundle(const String&, OptionSet<FindOptions>);
+ void findStringMatchesFromInjectedBundle(const String&, OptionSet<FindOptions>);
void replaceStringMatchesFromInjectedBundle(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly);
WebFrame& mainWebFrame() const { return m_mainFrame; }
@@ -1583,13 +1583,13 @@
void reapplyEditCommand(WebUndoStepID commandID);
void didRemoveEditCommand(WebUndoStepID commandID);
- void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount, Optional<CallbackID>);
- void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
+ void findString(const String&, OptionSet<FindOptions>, uint32_t maxMatchCount, CompletionHandler<void(bool)>&&);
+ void findStringMatches(const String&, OptionSet<FindOptions>, uint32_t maxMatchCount);
void getImageForFindMatch(uint32_t matchIndex);
void selectFindMatch(uint32_t matchIndex);
void indicateFindMatch(uint32_t matchIndex);
void hideFindUI();
- void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
+ void countStringMatches(const String&, OptionSet<FindOptions>, uint32_t maxMatchCount);
void replaceMatches(const Vector<uint32_t>& matchIndices, const String& replacementText, bool selectionOnly, CallbackID);
#if USE(COORDINATED_GRAPHICS)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (264054 => 264055)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-07-08 01:56:20 UTC (rev 264054)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-07-08 02:28:46 UTC (rev 264055)
@@ -296,13 +296,13 @@
PostInjectedBundleMessage(String messageName, WebKit::UserData messageBody)
# Find.
- FindString(String string, uint32_t findOptions, unsigned maxMatchCount, Optional<WebKit::CallbackID> callbackID)
- FindStringMatches(String string, uint32_t findOptions, unsigned maxMatchCount)
+ FindString(String string, OptionSet<WebKit::FindOptions> findOptions, unsigned maxMatchCount) -> (bool found) Async
+ FindStringMatches(String string, OptionSet<WebKit::FindOptions> findOptions, unsigned maxMatchCount)
GetImageForFindMatch(uint32_t matchIndex)
SelectFindMatch(uint32_t matchIndex)
IndicateFindMatch(uint32_t matchIndex)
HideFindUI()
- CountStringMatches(String string, uint32_t findOptions, unsigned maxMatchCount)
+ CountStringMatches(String string, OptionSet<WebKit::FindOptions> findOptions, unsigned maxMatchCount)
ReplaceMatches(Vector<uint32_t> matchIndices, String replacementText, bool selectionOnly, WebKit::CallbackID callbackID)
AddMIMETypeWithCustomContentProvider(String mimeType)