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

Unified Diff: third_party/WebKit/Source/core/events/EventTarget.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/EventTarget.cpp
diff --git a/third_party/WebKit/Source/core/events/EventTarget.cpp b/third_party/WebKit/Source/core/events/EventTarget.cpp
index 1e283f2351d51fd792e8f6fc3dcf992b9350ae6b..de983a249438d7e47eb1764379effdb927a3e688 100644
--- a/third_party/WebKit/Source/core/events/EventTarget.cpp
+++ b/third_party/WebKit/Source/core/events/EventTarget.cpp
@@ -52,6 +52,11 @@ namespace {
void setDefaultEventListenerOptionsLegacy(EventListenerOptions& options, bool useCapture)
{
options.setCapture(useCapture);
+}
+
+void setDefaultAddEventListenerOptionsLegacy(AddEventListenerOptions& options, bool useCapture)
+{
+ setDefaultEventListenerOptionsLegacy(options, useCapture);
options.setPassive(false);
}
@@ -64,6 +69,11 @@ void setDefaultEventListenerOptions(EventListenerOptions& options)
// capture is true; with the setting on capture is false.
if (!options.hasCapture())
options.setCapture(!RuntimeEnabledFeatures::eventListenerOptionsEnabled());
+}
+
+void setDefaultAddEventListenerOptions(AddEventListenerOptions& options)
+{
+ setDefaultEventListenerOptions(options);
if (!options.hasPassive())
options.setPassive(false);
}
@@ -125,29 +135,29 @@ inline LocalDOMWindow* EventTarget::executingWindow()
bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
{
- EventListenerOptions options;
- setDefaultEventListenerOptionsLegacy(options, useCapture);
+ AddEventListenerOptions options;
+ setDefaultAddEventListenerOptionsLegacy(options, useCapture);
return addEventListenerInternal(eventType, listener, options);
}
-bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, const EventListenerOptionsOrBoolean& optionsUnion)
+bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, const AddEventListenerOptionsOrBoolean& optionsUnion)
{
if (optionsUnion.isBoolean())
return addEventListener(eventType, listener, optionsUnion.getAsBoolean());
- if (optionsUnion.isEventListenerOptions()) {
- EventListenerOptions options = optionsUnion.getAsEventListenerOptions();
+ if (optionsUnion.isAddEventListenerOptions()) {
+ AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOptions();
return addEventListener(eventType, listener, options);
}
return addEventListener(eventType, listener);
}
-bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, EventListenerOptions& options)
+bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, AddEventListenerOptions& options)
{
- setDefaultEventListenerOptions(options);
+ setDefaultAddEventListenerOptions(options);
return addEventListenerInternal(eventType, listener, options);
}
-bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventListener* listener, const EventListenerOptions& options)
+bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventListener* listener, const AddEventListenerOptions& options)
{
if (!listener)
return false;
@@ -197,34 +207,39 @@ bool EventTarget::removeEventListenerInternal(const AtomicString& eventType, Eve
return false;
size_t indexOfRemovedListener;
+ RegisteredEventListener registeredListener;
- if (!d->eventListenerMap.remove(eventType, listener, options, indexOfRemovedListener))
+ if (!d->eventListenerMap.remove(eventType, listener, options, indexOfRemovedListener, &registeredListener))
return false;
// Notify firing events planning to invoke the listener at 'index' that
// they have one less listener to invoke.
- if (!d->firingEventIterators)
- return true;
- for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
- FiringEventIterator& firingIterator = d->firingEventIterators->at(i);
- if (eventType != firingIterator.eventType)
- continue;
-
- if (indexOfRemovedListener >= firingIterator.end)
- continue;
-
- --firingIterator.end;
- // Note that when firing an event listener,
- // firingIterator.iterator indicates the next event listener
- // that would fire, not the currently firing event
- // listener. See EventTarget::fireEventListeners.
- if (indexOfRemovedListener < firingIterator.iterator)
- --firingIterator.iterator;
+ if (d->firingEventIterators) {
+ for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
+ FiringEventIterator& firingIterator = d->firingEventIterators->at(i);
+ if (eventType != firingIterator.eventType)
+ continue;
+
+ if (indexOfRemovedListener >= firingIterator.end)
+ continue;
+
+ --firingIterator.end;
+ // Note that when firing an event listener,
+ // firingIterator.iterator indicates the next event listener
+ // that would fire, not the currently firing event
+ // listener. See EventTarget::fireEventListeners.
+ if (indexOfRemovedListener < firingIterator.iterator)
+ --firingIterator.iterator;
+ }
}
-
+ removedEventListener(eventType, registeredListener);
return true;
}
+void EventTarget::removedEventListener(const AtomicString& eventType, const RegisteredEventListener& registeredListener)
+{
+}
+
bool EventTarget::setAttributeEventListener(const AtomicString& eventType, EventListener* listener)
{
clearAttributeEventListener(eventType);

Powered by Google App Engine
This is Rietveld 408576698