Title: [288446] trunk/Source/WebCore
Revision
288446
Author
carlo...@webkit.org
Date
2022-01-24 08:20:20 -0800 (Mon, 24 Jan 2022)

Log Message

[GTK][a11y] Do not use heap allocated timers in AccessibilityAtspi
https://bugs.webkit.org/show_bug.cgi?id=235473

Reviewed by Adrian Perez de Castro.

It was needed to ensure they were constructed in the ax thread, but they are now always created in the main
thread, so they can be created once in the constructor.

* accessibility/atspi/AccessibilityAtspi.cpp:
(WebCore::AccessibilityAtspi::AccessibilityAtspi):
(WebCore::AccessibilityAtspi::addClient):
(WebCore::AccessibilityAtspi::removeClient):
(WebCore::AccessibilityAtspi::addToCacheIfPending):
(WebCore::AccessibilityAtspi::addAccessible):
(WebCore::AccessibilityAtspi::cacheClearTimerFired):
(WebCore::AccessibilityAtspi::scheduleCacheUpdate): Deleted.
* accessibility/atspi/AccessibilityAtspi.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288445 => 288446)


--- trunk/Source/WebCore/ChangeLog	2022-01-24 16:19:28 UTC (rev 288445)
+++ trunk/Source/WebCore/ChangeLog	2022-01-24 16:20:20 UTC (rev 288446)
@@ -1,5 +1,25 @@
 2022-01-24  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [GTK][a11y] Do not use heap allocated timers in AccessibilityAtspi
+        https://bugs.webkit.org/show_bug.cgi?id=235473
+
+        Reviewed by Adrian Perez de Castro.
+
+        It was needed to ensure they were constructed in the ax thread, but they are now always created in the main
+        thread, so they can be created once in the constructor.
+
+        * accessibility/atspi/AccessibilityAtspi.cpp:
+        (WebCore::AccessibilityAtspi::AccessibilityAtspi):
+        (WebCore::AccessibilityAtspi::addClient):
+        (WebCore::AccessibilityAtspi::removeClient):
+        (WebCore::AccessibilityAtspi::addToCacheIfPending):
+        (WebCore::AccessibilityAtspi::addAccessible):
+        (WebCore::AccessibilityAtspi::cacheClearTimerFired):
+        (WebCore::AccessibilityAtspi::scheduleCacheUpdate): Deleted.
+        * accessibility/atspi/AccessibilityAtspi.h:
+
+2022-01-24  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [GTK][a11y] Emit children-changed:remove signal even for ignored objects with ATSPI
         https://bugs.webkit.org/show_bug.cgi?id=235472
 

Modified: trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp (288445 => 288446)


--- trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp	2022-01-24 16:19:28 UTC (rev 288445)
+++ trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp	2022-01-24 16:20:20 UTC (rev 288446)
@@ -38,6 +38,14 @@
     return atspi;
 }
 
+AccessibilityAtspi::AccessibilityAtspi()
+    : m_cacheUpdateTimer(RunLoop::main(), this, &AccessibilityAtspi::cacheUpdateTimerFired)
+    , m_cacheClearTimer(RunLoop::main(), this, &AccessibilityAtspi::cacheClearTimerFired)
+{
+    m_cacheUpdateTimer.setPriority(RunLoopSourcePriority::RunLoopDispatcher);
+    m_cacheClearTimer.setPriority(RunLoopSourcePriority::ReleaseUnusedResourcesTimer);
+}
+
 void AccessibilityAtspi::connect(const String& busAddress)
 {
     if (busAddress.isEmpty())
@@ -191,7 +199,7 @@
     if (!addResult.isNewEntry)
         return;
 
-    m_cacheClearTimer = nullptr;
+    m_cacheClearTimer.stop();
 
     addResult.iterator->value = g_dbus_connection_signal_subscribe(m_connection.get(), nullptr, "org.freedesktop.DBus", "NameOwnerChanged", nullptr, dbusName,
         G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE, [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant* parameters, gpointer userData) {
@@ -217,14 +225,8 @@
         return;
 
     m_cacheUpdateList.clear();
-    m_cacheUpdateTimer->stop();
-
-    if (!m_cacheClearTimer) {
-        m_cacheClearTimer = makeUnique<RunLoop::Timer<AccessibilityAtspi>>(RunLoop::current(), this, &AccessibilityAtspi::cacheClearTimerFired);
-        m_cacheClearTimer->setPriority(RunLoopSourcePriority::ReleaseUnusedResourcesTimer);
-    }
-
-    m_cacheClearTimer->startOneShot(10_s);
+    m_cacheUpdateTimer.stop();
+    m_cacheClearTimer.startOneShot(10_s);
 }
 
 bool AccessibilityAtspi::shouldEmitSignal(const char* interface, const char* name, const char* detail)
@@ -788,8 +790,8 @@
         return;
 
     addToCacheIfNeeded(atspiObject);
-    if (m_cacheUpdateTimer && m_cacheUpdateList.isEmpty())
-        m_cacheUpdateTimer = nullptr;
+    if (m_cacheUpdateList.isEmpty())
+        m_cacheUpdateTimer.stop();
 }
 
 void AccessibilityAtspi::cacheUpdateTimerFired()
@@ -798,15 +800,6 @@
         addToCacheIfNeeded(*m_cacheUpdateList.takeFirst());
 }
 
-void AccessibilityAtspi::scheduleCacheUpdate()
-{
-    if (!m_cacheUpdateTimer)
-        m_cacheUpdateTimer = makeUnique<RunLoop::Timer<AccessibilityAtspi>>(RunLoop::current(), this, &AccessibilityAtspi::cacheUpdateTimerFired);
-
-    if (!m_cacheUpdateTimer->isActive())
-        m_cacheUpdateTimer->startOneShot(0_s);
-}
-
 void AccessibilityAtspi::addAccessible(AccessibilityObjectAtspi& atspiObject)
 {
     if (!m_connection)
@@ -813,7 +806,8 @@
         return;
 
     m_cacheUpdateList.add(&atspiObject);
-    scheduleCacheUpdate();
+    if (!m_cacheUpdateTimer.isActive())
+        m_cacheUpdateTimer.startOneShot(0_s);
 }
 
 void AccessibilityAtspi::removeAccessible(AccessibilityObjectAtspi& atspiObject)
@@ -846,8 +840,8 @@
     m_cache.clear();
 
     RELEASE_ASSERT(m_cacheUpdateList.isEmpty());
-    m_cacheUpdateTimer = nullptr;
-    m_cacheClearTimer = nullptr;
+    m_cacheUpdateTimer.stop();
+    m_cacheClearTimer.stop();
 }
 
 namespace Accessibility {

Modified: trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.h (288445 => 288446)


--- trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.h	2022-01-24 16:19:28 UTC (rev 288445)
+++ trunk/Source/WebCore/accessibility/atspi/AccessibilityAtspi.h	2022-01-24 16:20:20 UTC (rev 288446)
@@ -90,7 +90,7 @@
 #endif
 
 private:
-    AccessibilityAtspi() = default;
+    AccessibilityAtspi();
 
     struct PendingRootRegistration {
         Ref<AccessibilityRootAtspi> root;
@@ -109,7 +109,6 @@
     void addToCacheIfNeeded(AccessibilityObjectAtspi&);
     void addToCacheIfPending(AccessibilityObjectAtspi&);
     void removeAccessible(AccessibilityObjectAtspi&);
-    void scheduleCacheUpdate();
     void cacheUpdateTimerFired();
     void cacheClearTimerFired();
 
@@ -139,8 +138,8 @@
     unsigned m_cacheID { 0 };
     HashMap<String, AccessibilityObjectAtspi*> m_cache;
     ListHashSet<RefPtr<AccessibilityObjectAtspi>> m_cacheUpdateList;
-    std::unique_ptr<RunLoop::Timer<AccessibilityAtspi>> m_cacheUpdateTimer;
-    std::unique_ptr<RunLoop::Timer<AccessibilityAtspi>> m_cacheClearTimer;
+    RunLoop::Timer<AccessibilityAtspi> m_cacheUpdateTimer;
+    RunLoop::Timer<AccessibilityAtspi> m_cacheClearTimer;
 #if ENABLE(DEVELOPER_MODE)
     HashMap<void*, NotificationObserver> m_notificationObservers;
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to