aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-22 10:21:54 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-22 10:21:54 -0700
commit2a0ab2aa9b07b99ce82564a01eeca3b666e91cf2 (patch)
tree3e8314119dc1775cd078710bf50b9dd3c1b96fc5 /src
parentfd5398ce80228625fb241f56fe9e92f477986ceb (diff)
downloadbun-2a0ab2aa9b07b99ce82564a01eeca3b666e91cf2.tar.gz
bun-2a0ab2aa9b07b99ce82564a01eeca3b666e91cf2.tar.zst
bun-2a0ab2aa9b07b99ce82564a01eeca3b666e91cf2.zip
Fix build error
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/webcore/EventEmitter.h5
-rw-r--r--src/bun.js/bindings/webcore/IdentifierEventListenerMap.h11
-rw-r--r--src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp2
3 files changed, 16 insertions, 2 deletions
diff --git a/src/bun.js/bindings/webcore/EventEmitter.h b/src/bun.js/bindings/webcore/EventEmitter.h
index d6fd20c65..eb6fa2e77 100644
--- a/src/bun.js/bindings/webcore/EventEmitter.h
+++ b/src/bun.js/bindings/webcore/EventEmitter.h
@@ -76,8 +76,11 @@ public:
const EventEmitterData* eventTargetData() const;
+ IdentifierEventListenerMap& eventListenerMap() { return ensureEventEmitterData().eventListenerMap; }
+
private:
- EventEmitter(ScriptExecutionContext& context) : ContextDestructionObserver(&context)
+ EventEmitter(ScriptExecutionContext& context)
+ : ContextDestructionObserver(&context)
{
}
diff --git a/src/bun.js/bindings/webcore/IdentifierEventListenerMap.h b/src/bun.js/bindings/webcore/IdentifierEventListenerMap.h
index 34da21122..f2a60f0a1 100644
--- a/src/bun.js/bindings/webcore/IdentifierEventListenerMap.h
+++ b/src/bun.js/bindings/webcore/IdentifierEventListenerMap.h
@@ -56,6 +56,7 @@ public:
WEBCORE_EXPORT SimpleEventListenerVector* find(const JSC::Identifier& eventType);
const SimpleEventListenerVector* find(const JSC::Identifier& eventType) const { return const_cast<IdentifierEventListenerMap*>(this)->find(eventType); }
Vector<JSC::Identifier> eventTypes() const;
+ template<typename Visitor> void visitJSEventListeners(Visitor&);
Lock& lock() { return m_lock; }
@@ -64,4 +65,14 @@ private:
Lock m_lock;
};
+template<typename Visitor>
+void IdentifierEventListenerMap::visitJSEventListeners(Visitor& visitor)
+{
+ Locker locker { m_lock };
+ for (auto& entry : m_entries) {
+ for (auto& eventListener : entry.second)
+ eventListener->callback().visitJSFunction(visitor);
+ }
+}
+
} // namespace WebCore
diff --git a/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp b/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp
index 53220536d..64ae6e1c8 100644
--- a/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp
+++ b/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp
@@ -44,7 +44,7 @@ std::unique_ptr<JSEventEmitterWrapper> jsEventEmitterCast(VM& vm, JSC::JSGlobalO
template<typename Visitor>
void JSEventEmitter::visitAdditionalChildren(Visitor& visitor)
{
- wrapped().visitJSEventListeners(visitor);
+ wrapped().eventListenerMap().visitJSEventListeners(visitor);
}
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSEventEmitter);