Fix variable name |end| -> |size| in EventTarget::fireEventListeners
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 03:34:26 +0000 (03:34 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 03:34:26 +0000 (03:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119715

Reviewed by Benjamin Poulain.

Merge https://chromium.googlesource.com/chromium/blink/+/f58b017539c48059bb2b88d18ee0ee3d14decb01
and also fix variable names in FiringEventIterator.

* dom/EventTarget.cpp:
(WebCore::EventTarget::removeEventListener):
(WebCore::EventTarget::fireEventListeners):
(WebCore::EventTarget::removeAllEventListeners):
* dom/EventTarget.h:
(WebCore::FiringEventIterator::FiringEventIterator):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153972 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/EventTarget.cpp
Source/WebCore/dom/EventTarget.h

index 3f2c1c96e1f9eea3f11235c35d55b1fddbd524f4..1776beabca3904951016bc101c46da1e33e24096 100644 (file)
@@ -1,3 +1,20 @@
+2013-08-13  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Fix variable name |end| -> |size| in EventTarget::fireEventListeners
+        https://bugs.webkit.org/show_bug.cgi?id=119715
+
+        Reviewed by Benjamin Poulain.
+
+        Merge https://chromium.googlesource.com/chromium/blink/+/f58b017539c48059bb2b88d18ee0ee3d14decb01
+        and also fix variable names in FiringEventIterator.
+
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::removeEventListener):
+        (WebCore::EventTarget::fireEventListeners):
+        (WebCore::EventTarget::removeAllEventListeners):
+        * dom/EventTarget.h:
+        (WebCore::FiringEventIterator::FiringEventIterator):
+
 2013-08-12  Ryosuke Niwa  <rniwa@webkit.org>
 
         Encapsulate access to documentNamedItemMap and windowNamedItemMap
index 1f30609991cb329e97eac636a83299ec9f1189b4..080614d11fe23ccb4c4902e9e1f7194f2d3d4d23 100644 (file)
@@ -92,10 +92,10 @@ bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen
         if (eventType != firingIterator.eventType)
             continue;
 
-        if (indexOfRemovedListener >= firingIterator.end)
+        if (indexOfRemovedListener >= firingIterator.size)
             continue;
 
-        --firingIterator.end;
+        --firingIterator.size;
         if (indexOfRemovedListener <= firingIterator.iterator)
             --firingIterator.iterator;
     }
@@ -217,18 +217,17 @@ void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
 {
     RefPtr<EventTarget> protect = this;
 
-    // Fire all listeners registered for this event. Don't fire listeners removed
-    // during event dispatch. Also, don't fire event listeners added during event
-    // dispatch. Conveniently, all new event listeners will be added after 'end',
-    // so iterating to 'end' naturally excludes new event listeners.
+    // Fire all listeners registered for this event. Don't fire listeners removed during event dispatch.
+    // Also, don't fire event listeners added during event dispatch. Conveniently, all new event listeners will be added
+    // after or at index |size|, so iterating up to (but not including) |size| naturally excludes new event listeners.
 
     bool userEventWasHandled = false;
     size_t i = 0;
-    size_t end = entry.size();
+    size_t size = entry.size();
     if (!d->firingEventIterators)
         d->firingEventIterators = adoptPtr(new FiringEventIteratorVector);
-    d->firingEventIterators->append(FiringEventIterator(event->type(), i, end));
-    for ( ; i < end; ++i) {
+    d->firingEventIterators->append(FiringEventIterator(event->type(), i, size));
+    for (; i < size; ++i) {
         RegisteredEventListener& registeredListener = entry[i];
         if (event->eventPhase() == Event::CAPTURING_PHASE && !registeredListener.useCapture)
             continue;
@@ -286,7 +285,7 @@ void EventTarget::removeAllEventListeners()
     if (d->firingEventIterators) {
         for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
             d->firingEventIterators->at(i).iterator = 0;
-            d->firingEventIterators->at(i).end = 0;
+            d->firingEventIterators->at(i).size = 0;
         }
     }
 }
index d187840d9da8d7b057f6afedb6a9ceac68d13532..cd6922a023ec00175b2a111b25c508bde4541f65 100644 (file)
@@ -79,16 +79,16 @@ namespace WebCore {
     typedef int ExceptionCode;
 
     struct FiringEventIterator {
-        FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& end)
+        FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& size)
             : eventType(eventType)
             , iterator(iterator)
-            , end(end)
+            , size(size)
         {
         }
 
         const AtomicString& eventType;
         size_t& iterator;
-        size_t& end;
+        size_t& size;
     };
     typedef Vector<FiringEventIterator, 1> FiringEventIteratorVector;