Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: third_party/WebKit/Source/core/events/EventListenerMap.cpp

Issue 1922093003: Add AddEventListenerOptions addEventListenerOptions interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/events/EventListenerMap.cpp
diff --git a/third_party/WebKit/Source/core/events/EventListenerMap.cpp b/third_party/WebKit/Source/core/events/EventListenerMap.cpp
index 5480595cc48759e793ecae240f1ace6488af2302..5f20cb314b305550fe1d8b029f405efec34273d9 100644
--- a/third_party/WebKit/Source/core/events/EventListenerMap.cpp
+++ b/third_party/WebKit/Source/core/events/EventListenerMap.cpp
@@ -106,7 +106,7 @@ Vector<AtomicString> EventListenerMap::eventTypes() const
return types;
}
-static bool addListenerToVector(EventListenerVector* vector, EventListener* listener, const EventListenerOptions& options)
+static bool addListenerToVector(EventListenerVector* vector, EventListener* listener, const AddEventListenerOptions& options)
{
RegisteredEventListener registeredListener(listener, options);
@@ -117,7 +117,7 @@ static bool addListenerToVector(EventListenerVector* vector, EventListener* list
return true;
}
-bool EventListenerMap::add(const AtomicString& eventType, EventListener* listener, const EventListenerOptions& options)
+bool EventListenerMap::add(const AtomicString& eventType, EventListener* listener, const AddEventListenerOptions& options)
{
assertNoActiveIterators();
@@ -130,23 +130,26 @@ bool EventListenerMap::add(const AtomicString& eventType, EventListener* listene
return addListenerToVector(m_entries.last().second.get(), listener, options);
}
-static bool removeListenerFromVector(EventListenerVector* listenerVector, EventListener* listener, const EventListenerOptions& options, size_t& indexOfRemovedListener)
+static bool removeListenerFromVector(EventListenerVector* listenerVector, EventListener* listener, const EventListenerOptions& options, size_t& indexOfRemovedListener, RegisteredEventListener* registeredListener)
{
- RegisteredEventListener registeredListener(listener, options);
- indexOfRemovedListener = listenerVector->find(registeredListener);
+ RegisteredEventListener queryListenerKey(listener, options);
+ indexOfRemovedListener = listenerVector->find(queryListenerKey);
if (indexOfRemovedListener == kNotFound)
return false;
+ // Aassign the |registeredListener| the value that was in the vector
dtapuska 2016/04/26 14:29:39 I recognize the typo on this line |Aassign|. I hav
bokan 2016/04/26 19:54:59 Acknowledged.
+ // so it contains the values the listener was registered with.
+ *registeredListener = listenerVector->at(indexOfRemovedListener);
listenerVector->remove(indexOfRemovedListener);
return true;
}
-bool EventListenerMap::remove(const AtomicString& eventType, EventListener* listener, const EventListenerOptions& options, size_t& indexOfRemovedListener)
+bool EventListenerMap::remove(const AtomicString& eventType, EventListener* listener, const EventListenerOptions& options, size_t& indexOfRemovedListener, RegisteredEventListener* registeredListener)
{
assertNoActiveIterators();
for (unsigned i = 0; i < m_entries.size(); ++i) {
if (m_entries[i].first == eventType) {
- bool wasRemoved = removeListenerFromVector(m_entries[i].second.get(), listener, options, indexOfRemovedListener);
+ bool wasRemoved = removeListenerFromVector(m_entries[i].second.get(), listener, options, indexOfRemovedListener, registeredListener);
if (m_entries[i].second->isEmpty())
m_entries.remove(i);
return wasRemoved;
@@ -174,7 +177,7 @@ static void copyListenersNotCreatedFromMarkupToTarget(const AtomicString& eventT
// Event listeners created from markup have already been transfered to the shadow tree during cloning.
if (eventListener.listener->wasCreatedFromMarkup())
continue;
- EventListenerOptions options = eventListener.options();
+ AddEventListenerOptions options = eventListener.options();
target->addEventListener(eventType, eventListener.listener, options);
}
}

Powered by Google App Engine
This is Rietveld 408576698