WheelEventTestMonitor doesn't need to be threadsafe
https://bugs.webkit.org/show_bug.cgi?id=203012
Reviewed by Dean Jackson.
WheelEventTestMonitor is only called on the main thread, so doesn't need a lock to protect
m_deferCompletionReasons, and add main thread assertions.
* page/WheelEventTestMonitor.cpp:
(WebCore::WheelEventTestMonitor::clearAllTestDeferrals):
(WebCore::WheelEventTestMonitor::setTestCallbackAndStartNotificationTimer):
(WebCore::WheelEventTestMonitor::deferForReason):
(WebCore::WheelEventTestMonitor::removeDeferralForReason):
(WebCore::WheelEventTestMonitor::triggerTestTimerFired):
* page/WheelEventTestMonitor.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251172 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 6c382f5..36e44ec 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2019-10-15 Simon Fraser <simon.fraser@apple.com>
+
+ WheelEventTestMonitor doesn't need to be threadsafe
+ https://bugs.webkit.org/show_bug.cgi?id=203012
+
+ Reviewed by Dean Jackson.
+
+ WheelEventTestMonitor is only called on the main thread, so doesn't need a lock to protect
+ m_deferCompletionReasons, and add main thread assertions.
+
+ * page/WheelEventTestMonitor.cpp:
+ (WebCore::WheelEventTestMonitor::clearAllTestDeferrals):
+ (WebCore::WheelEventTestMonitor::setTestCallbackAndStartNotificationTimer):
+ (WebCore::WheelEventTestMonitor::deferForReason):
+ (WebCore::WheelEventTestMonitor::removeDeferralForReason):
+ (WebCore::WheelEventTestMonitor::triggerTestTimerFired):
+ * page/WheelEventTestMonitor.h:
+
2019-10-15 Andres Gonzalez <andresg_22@apple.com>
AX: Make AXIsolatedTree compile again
diff --git a/Source/WebCore/page/WheelEventTestMonitor.cpp b/Source/WebCore/page/WheelEventTestMonitor.cpp
index 061ff11..1b68303 100644
--- a/Source/WebCore/page/WheelEventTestMonitor.cpp
+++ b/Source/WebCore/page/WheelEventTestMonitor.cpp
@@ -46,7 +46,7 @@
void WheelEventTestMonitor::clearAllTestDeferrals()
{
- std::lock_guard<Lock> lock(m_reasonsLock);
+ ASSERT(isMainThread());
m_deferCompletionReasons.clear();
m_completionCallback = nullptr;
m_testForCompletionTimer.stop();
@@ -55,10 +55,8 @@
void WheelEventTestMonitor::setTestCallbackAndStartNotificationTimer(WTF::Function<void()>&& functionCallback)
{
- {
- std::lock_guard<Lock> lock(m_reasonsLock);
- m_completionCallback = WTFMove(functionCallback);
- }
+ ASSERT(isMainThread());
+ m_completionCallback = WTFMove(functionCallback);
if (!m_testForCompletionTimer.isActive())
m_testForCompletionTimer.startRepeating(1_s / 60.);
@@ -66,7 +64,7 @@
void WheelEventTestMonitor::deferForReason(ScrollableAreaIdentifier identifier, DeferReason reason)
{
- std::lock_guard<Lock> lock(m_reasonsLock);
+ ASSERT(isMainThread());
m_deferCompletionReasons.ensure(identifier, [] {
return OptionSet<DeferReason>();
}).iterator->value.add(reason);
@@ -76,7 +74,7 @@
void WheelEventTestMonitor::removeDeferralForReason(ScrollableAreaIdentifier identifier, DeferReason reason)
{
- std::lock_guard<Lock> lock(m_reasonsLock);
+ ASSERT(isMainThread());
auto it = m_deferCompletionReasons.find(identifier);
if (it == m_deferCompletionReasons.end())
return;
@@ -90,18 +88,13 @@
void WheelEventTestMonitor::triggerTestTimerFired()
{
- WTF::Function<void()> functionCallback;
-
- {
- std::lock_guard<Lock> lock(m_reasonsLock);
- if (!m_deferCompletionReasons.isEmpty()) {
- LOG_WITH_STREAM(WheelEventTestMonitor, stream << " WheelEventTestMonitor::triggerTestTimerFired - scrolling still active, reasons " << m_deferCompletionReasons);
- return;
- }
-
- functionCallback = WTFMove(m_completionCallback);
+ ASSERT(isMainThread());
+ if (!m_deferCompletionReasons.isEmpty()) {
+ LOG_WITH_STREAM(WheelEventTestMonitor, stream << " WheelEventTestMonitor::triggerTestTimerFired - scrolling still active, reasons " << m_deferCompletionReasons);
+ return;
}
+ auto functionCallback = WTFMove(m_completionCallback);
m_testForCompletionTimer.stop();
LOG_WITH_STREAM(WheelEventTestMonitor, stream << " WheelEventTestMonitor::triggerTestTimerFired: scrolling is idle, FIRING TEST");
diff --git a/Source/WebCore/page/WheelEventTestMonitor.h b/Source/WebCore/page/WheelEventTestMonitor.h
index 0cdce5c..b0793a3 100644
--- a/Source/WebCore/page/WheelEventTestMonitor.h
+++ b/Source/WebCore/page/WheelEventTestMonitor.h
@@ -65,7 +65,6 @@
WTF::Function<void()> m_completionCallback;
RunLoop::Timer<WheelEventTestMonitor> m_testForCompletionTimer;
- mutable Lock m_reasonsLock;
ScrollableAreaReasonMap m_deferCompletionReasons;
};