Diff
Modified: trunk/Source/WebKit/ChangeLog (272557 => 272558)
--- trunk/Source/WebKit/ChangeLog 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/ChangeLog 2021-02-09 00:22:24 UTC (rev 272558)
@@ -1,3 +1,34 @@
+2021-02-08 Alex Christensen <[email protected]>
+
+ Use CompletionHandler instead of BoolCallback
+ https://bugs.webkit.org/show_bug.cgi?id=221575
+ <rdar://problem/74058604>
+
+ Reviewed by Chris Dumez.
+
+ This makes the code more modern, and it makes our fuzzers better at reasoning what the boolean value is going to be used for.
+ It should also fix a rare crash involving BoolCallback by completely removing it.
+
+ * UIProcess/GenericCallback.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::handlePreventableTouchEvent):
+ (WebKit::WebPageProxy::handleUnpreventableTouchEvent):
+ (WebKit::WebPageProxy::boolCallback): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebPage/EventDispatcher.cpp:
+ (WebKit::EventDispatcher::touchEventWithoutCallback):
+ (WebKit::EventDispatcher::touchEvent):
+ (WebKit::EventDispatcher::dispatchTouchEvents):
+ * WebProcess/WebPage/EventDispatcher.h:
+ * WebProcess/WebPage/EventDispatcher.messages.in:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::touchEventSync):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::dispatchAsynchronousTouchEvents):
+ (WebKit::WebPage::cancelAsynchronousTouchEvents):
+
2021-02-08 Brady Eidson <[email protected]>
Make the UserContentController for ServiceWorker pages be non-optional.
Modified: trunk/Source/WebKit/UIProcess/GenericCallback.h (272557 => 272558)
--- trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-09 00:22:24 UTC (rev 272558)
@@ -157,7 +157,6 @@
typedef GenericCallback<> VoidCallback;
typedef GenericCallback<const Vector<WebCore::IntRect>&, double, WebCore::FloatBoxExtent> ComputedPagesCallback;
typedef GenericCallback<const ShareableBitmap::Handle&> ImageCallback;
-typedef GenericCallback<bool> BoolCallback;
template<typename T>
void invalidateCallbackMap(HashMap<uint64_t, T>& callbackMap, CallbackBase::Error error)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (272557 => 272558)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-09 00:22:24 UTC (rev 272558)
@@ -2928,7 +2928,7 @@
if (isTouchEnd)
++m_handlingPreventableTouchEndCount;
- Function<void(bool, CallbackBase::Error)> completionHandler = [this, protectedThis = makeRef(*this), event](bool handled, CallbackBase::Error error) {
+ sendWithAsyncReply(Messages::EventDispatcher::TouchEvent(m_webPageID, event), [this, protectedThis = makeRef(*this), event] (bool handled) {
bool didFinishDeferringTouchStart = false;
ASSERT_IMPLIES(event.type() == WebEvent::TouchStart, m_handlingPreventableTouchStartCount);
if (event.type() == WebEvent::TouchStart && m_handlingPreventableTouchStartCount)
@@ -2939,13 +2939,10 @@
if (event.type() == WebEvent::TouchEnd && m_handlingPreventableTouchEndCount)
didFinishDeferringTouchEnd = !--m_handlingPreventableTouchEndCount;
- bool handledOrFailedWithError = handled || error != CallbackBase::Error::None || m_handledSynchronousTouchEventWhileDispatchingPreventableTouchStart;
+ bool handledOrFailedWithError = handled || m_handledSynchronousTouchEventWhileDispatchingPreventableTouchStart;
if (!isHandlingPreventableTouchStart())
m_handledSynchronousTouchEventWhileDispatchingPreventableTouchStart = false;
- if (error == CallbackBase::Error::ProcessExited)
- return;
-
didReceiveEvent(event.type(), handledOrFailedWithError);
pageClient().doneWithTouchEvent(event, handledOrFailedWithError);
@@ -2954,10 +2951,7 @@
if (didFinishDeferringTouchEnd)
pageClient().doneDeferringTouchEnd(handledOrFailedWithError);
- };
-
- auto callbackID = m_callbacks.put(WTFMove(completionHandler), m_process->throttler().backgroundActivity("WebPageProxy::handlePreventableTouchEvent"_s));
- send(Messages::EventDispatcher::TouchEvent(m_webPageID, event, callbackID), 0);
+ });
return;
}
@@ -2993,7 +2987,7 @@
if (touchEventsTrackingType == TrackingType::NotTracking)
return;
- send(Messages::EventDispatcher::TouchEvent(m_webPageID, event, WTF::nullopt), 0);
+ send(Messages::EventDispatcher::TouchEventWithoutCallback(m_webPageID, event), 0);
if (event.allTouchPointsAreReleased()) {
m_touchAndPointerEventTracking.reset();
@@ -7128,17 +7122,6 @@
callback->performCallbackWithReturnValue(API::Data::create(dataReference.data(), dataReference.size()).ptr());
}
-void WebPageProxy::boolCallback(bool result, CallbackID callbackID)
-{
- auto callback = m_callbacks.take<BoolCallback>(callbackID);
- if (!callback) {
- ASSERT_NOT_REACHED();
- return;
- }
-
- callback->performCallbackWithReturnValue(result);
-}
-
void WebPageProxy::imageCallback(const ShareableBitmap::Handle& bitmapHandle, CallbackID callbackID)
{
auto callback = m_callbacks.take<ImageCallback>(callbackID);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (272557 => 272558)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-09 00:22:24 UTC (rev 272558)
@@ -381,7 +381,6 @@
typedef GenericCallback<API::Data*> DataCallback;
typedef GenericCallback<uint64_t> UnsignedCallback;
typedef GenericCallback<const String&> StringCallback;
-typedef GenericCallback<bool> BoolCallback;
#if HAVE(VISIBILITY_PROPAGATION_VIEW)
using LayerHostingContextID = uint32_t;
@@ -2164,7 +2163,6 @@
void voidCallback(CallbackID);
void dataCallback(const IPC::DataReference&, CallbackID);
void imageCallback(const ShareableBitmap::Handle&, CallbackID);
- void boolCallback(bool result, CallbackID);
void stringCallback(const String&, CallbackID);
void invalidateStringCallback(CallbackID);
void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, CallbackID);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (272557 => 272558)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-09 00:22:24 UTC (rev 272558)
@@ -167,7 +167,6 @@
DataCallback(IPC::SharedBufferDataReference resultData, WebKit::CallbackID callbackID)
ImageCallback(WebKit::ShareableBitmap::Handle bitmapHandle, WebKit::CallbackID callbackID)
StringCallback(String resultString, WebKit::CallbackID callbackID)
- BoolCallback(bool result, WebKit::CallbackID callbackID)
InvalidateStringCallback(WebKit::CallbackID callbackID)
ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin, WebKit::CallbackID callbackID)
UnsignedCallback(uint64_t result, WebKit::CallbackID callbackID)
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (272557 => 272558)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2021-02-09 00:22:24 UTC (rev 272558)
@@ -192,8 +192,13 @@
destinationQueue = m_touchEvents.take(webPage.identifier());
}
-void EventDispatcher::touchEvent(PageIdentifier pageID, const WebKit::WebTouchEvent& touchEvent, Optional<CallbackID> callbackID)
+void EventDispatcher::touchEventWithoutCallback(PageIdentifier pageID, const WebTouchEvent& touchEvent)
{
+ this->touchEvent(pageID, touchEvent, nullptr);
+}
+
+void EventDispatcher::touchEvent(PageIdentifier pageID, const WebTouchEvent& touchEvent, CompletionHandler<void(bool)>&& completionHandler)
+{
bool updateListWasEmpty;
{
LockHolder locker(&m_touchEventsLock);
@@ -200,16 +205,16 @@
updateListWasEmpty = m_touchEvents.isEmpty();
auto addResult = m_touchEvents.add(pageID, TouchEventQueue());
if (addResult.isNewEntry)
- addResult.iterator->value.append({ touchEvent, callbackID });
+ addResult.iterator->value.append({ touchEvent, WTFMove(completionHandler) });
else {
auto& queuedEvents = addResult.iterator->value;
ASSERT(!queuedEvents.isEmpty());
auto& lastEventAndCallback = queuedEvents.last();
// Coalesce touch move events.
- if (touchEvent.type() == WebEvent::TouchMove && lastEventAndCallback.first.type() == WebEvent::TouchMove && !callbackID && !lastEventAndCallback.second)
- queuedEvents.last() = { touchEvent, WTF::nullopt };
+ if (touchEvent.type() == WebEvent::TouchMove && lastEventAndCallback.first.type() == WebEvent::TouchMove && !completionHandler && !lastEventAndCallback.second)
+ queuedEvents.last() = { touchEvent, nullptr };
else
- queuedEvents.append({ touchEvent, callbackID });
+ queuedEvents.append({ touchEvent, WTFMove(completionHandler) });
}
}
@@ -231,8 +236,8 @@
}
for (auto& slot : localCopy) {
- if (WebPage* webPage = WebProcess::singleton().webPage(slot.key))
- webPage->dispatchAsynchronousTouchEvents(slot.value);
+ if (auto* webPage = WebProcess::singleton().webPage(slot.key))
+ webPage->dispatchAsynchronousTouchEvents(WTFMove(slot.value));
}
}
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h (272557 => 272558)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h 2021-02-09 00:22:24 UTC (rev 272558)
@@ -67,7 +67,7 @@
#endif
#if ENABLE(IOS_TOUCH_EVENTS)
- using TouchEventQueue = Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>;
+ using TouchEventQueue = Vector<std::pair<WebTouchEvent, CompletionHandler<void(bool)>>, 1>;
void takeQueuedTouchEventsForPage(const WebPage&, TouchEventQueue&);
#endif
@@ -84,7 +84,8 @@
// Message handlers
void wheelEvent(WebCore::PageIdentifier, const WebWheelEvent&, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom);
#if ENABLE(IOS_TOUCH_EVENTS)
- void touchEvent(WebCore::PageIdentifier, const WebTouchEvent&, Optional<CallbackID>);
+ void touchEvent(WebCore::PageIdentifier, const WebTouchEvent&, CompletionHandler<void(bool)>&&);
+ void touchEventWithoutCallback(WebCore::PageIdentifier, const WebTouchEvent&);
#endif
#if ENABLE(MAC_GESTURE_EVENTS)
void gestureEvent(WebCore::PageIdentifier, const WebGestureEvent&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in (272557 => 272558)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in 2021-02-09 00:22:24 UTC (rev 272558)
@@ -23,7 +23,8 @@
messages -> EventDispatcher {
WheelEvent(WebCore::PageIdentifier pageID, WebKit::WebWheelEvent event, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
#if ENABLE(IOS_TOUCH_EVENTS)
- TouchEvent(WebCore::PageIdentifier pageID, WebKit::WebTouchEvent event, Optional<WebKit::CallbackID> callbackID)
+ TouchEvent(WebCore::PageIdentifier pageID, WebKit::WebTouchEvent event) -> (bool handled) Async
+ TouchEventWithoutCallback(WebCore::PageIdentifier pageID, WebKit::WebTouchEvent event)
#endif
#if ENABLE(MAC_GESTURE_EVENTS)
GestureEvent(WebCore::PageIdentifier pageID, WebKit::WebGestureEvent event)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (272557 => 272558)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-09 00:22:24 UTC (rev 272558)
@@ -3067,13 +3067,14 @@
#endif
#if ENABLE(IOS_TOUCH_EVENTS)
-void WebPage::dispatchTouchEvent(const WebTouchEvent& touchEvent, bool& handled)
+bool WebPage::dispatchTouchEvent(const WebTouchEvent& touchEvent)
{
SetForScope<bool> userIsInteractingChange { m_userIsInteracting, true };
m_lastInteractionLocation = touchEvent.position();
CurrentEvent currentEvent(touchEvent);
- handled = handleTouchEvent(touchEvent, m_page.get());
+ bool handled = handleTouchEvent(touchEvent, m_page.get());
updatePotentialTapSecurityOrigin(touchEvent, handled);
+ return handled;
}
void WebPage::touchEventSync(const WebTouchEvent& touchEvent, CompletionHandler<void(bool)>&& reply)
@@ -3088,10 +3089,9 @@
EventDispatcher::TouchEventQueue queuedEvents;
WebProcess::singleton().eventDispatcher().takeQueuedTouchEventsForPage(*this, queuedEvents);
- dispatchAsynchronousTouchEvents(queuedEvents);
+ dispatchAsynchronousTouchEvents(WTFMove(queuedEvents));
- bool handled = true;
- dispatchTouchEvent(touchEvent, handled);
+ bool handled = dispatchTouchEvent(touchEvent);
if (auto reply = WTFMove(m_pendingSynchronousTouchEventReply))
reply(handled);
@@ -6133,7 +6133,7 @@
#if ENABLE(IOS_TOUCH_EVENTS)
EventDispatcher::TouchEventQueue queuedEvents;
WebProcess::singleton().eventDispatcher().takeQueuedTouchEventsForPage(*this, queuedEvents);
- cancelAsynchronousTouchEvents(queuedEvents);
+ cancelAsynchronousTouchEvents(WTFMove(queuedEvents));
#endif
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (272557 => 272558)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-09 00:22:24 UTC (rev 272558)
@@ -796,8 +796,8 @@
#endif
#if PLATFORM(IOS_FAMILY) && ENABLE(IOS_TOUCH_EVENTS)
- void dispatchAsynchronousTouchEvents(const Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>& queue);
- void cancelAsynchronousTouchEvents(const Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>& queue);
+ void dispatchAsynchronousTouchEvents(Vector<std::pair<WebTouchEvent, CompletionHandler<void(bool)>>, 1>&&);
+ void cancelAsynchronousTouchEvents(Vector<std::pair<WebTouchEvent, CompletionHandler<void(bool)>>, 1>&&);
#endif
bool hasRichlyEditableSelection() const;
@@ -1076,7 +1076,7 @@
#endif
#if ENABLE(IOS_TOUCH_EVENTS)
- void dispatchTouchEvent(const WebTouchEvent&, bool& handled);
+ bool dispatchTouchEvent(const WebTouchEvent&);
#endif
bool shouldUseCustomContentProviderForResponse(const WebCore::ResourceResponse&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (272557 => 272558)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-02-08 23:53:07 UTC (rev 272557)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-02-09 00:22:24 UTC (rev 272558)
@@ -3953,22 +3953,20 @@
}
#if ENABLE(IOS_TOUCH_EVENTS)
-void WebPage::dispatchAsynchronousTouchEvents(const Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>& queue)
+void WebPage::dispatchAsynchronousTouchEvents(Vector<std::pair<WebTouchEvent, CompletionHandler<void(bool)>>, 1>&& queue)
{
for (auto& eventAndCallbackID : queue) {
- bool handled;
- dispatchTouchEvent(eventAndCallbackID.first, handled);
- if (eventAndCallbackID.second)
- send(Messages::WebPageProxy::BoolCallback(handled, *eventAndCallbackID.second));
+ bool handled = dispatchTouchEvent(eventAndCallbackID.first);
+ if (auto& completionHandler = eventAndCallbackID.second)
+ completionHandler(handled);
}
}
-void WebPage::cancelAsynchronousTouchEvents(const Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>& queue)
+void WebPage::cancelAsynchronousTouchEvents(Vector<std::pair<WebTouchEvent, CompletionHandler<void(bool)>>, 1>&& queue)
{
for (auto& eventAndCallbackID : queue) {
- if (!eventAndCallbackID.second)
- continue;
- send(Messages::WebPageProxy::BoolCallback(true, *eventAndCallbackID.second));
+ if (auto& completionHandler = eventAndCallbackID.second)
+ completionHandler(true);
}
}
#endif