Title: [174235] trunk/Source/WebCore
- Revision
- 174235
- Author
- [email protected]
- Date
- 2014-10-02 15:49:06 -0700 (Thu, 02 Oct 2014)
Log Message
XMLHttpRequestProgressEventThrottle shouldn't throttle / defer progress events if there are no listeners
https://bugs.webkit.org/show_bug.cgi?id=137346
Reviewed by Alexey Proskuryakov.
Previously XMLHttpRequestProgressEventThrottle would throttle / defer
progress events, which involves queueing events and starting timers,
even if there were no listeners for those events (which is fairly
common case).
This patch updates XMLHttpRequestProgressEventThrottle to make sure
there are actual progress event listeners *before* attempting to
throttle and do extra processing, to avoid doing unnecessary work.
This patch also makes XMLHttpRequestProgressEventThrottle::dispatchEvent()
private as this method is only called from other dispatch methods of
the class and never from the outside.
No new tests, no behavior change.
* xml/XMLHttpRequestProgressEventThrottle.cpp:
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent):
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (174234 => 174235)
--- trunk/Source/WebCore/ChangeLog 2014-10-02 22:48:48 UTC (rev 174234)
+++ trunk/Source/WebCore/ChangeLog 2014-10-02 22:49:06 UTC (rev 174235)
@@ -1,3 +1,29 @@
+2014-10-02 Chris Dumez <[email protected]>
+
+ XMLHttpRequestProgressEventThrottle shouldn't throttle / defer progress events if there are no listeners
+ https://bugs.webkit.org/show_bug.cgi?id=137346
+
+ Reviewed by Alexey Proskuryakov.
+
+ Previously XMLHttpRequestProgressEventThrottle would throttle / defer
+ progress events, which involves queueing events and starting timers,
+ even if there were no listeners for those events (which is fairly
+ common case).
+
+ This patch updates XMLHttpRequestProgressEventThrottle to make sure
+ there are actual progress event listeners *before* attempting to
+ throttle and do extra processing, to avoid doing unnecessary work.
+
+ This patch also makes XMLHttpRequestProgressEventThrottle::dispatchEvent()
+ private as this method is only called from other dispatch methods of
+ the class and never from the outside.
+
+ No new tests, no behavior change.
+
+ * xml/XMLHttpRequestProgressEventThrottle.cpp:
+ (WebCore::XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent):
+ (WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent):
+
2014-10-01 Myles C. Maxfield <[email protected]>
[Subpixel] Use floats instead of ints for text justification expansion
Modified: trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp (174234 => 174235)
--- trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp 2014-10-02 22:48:48 UTC (rev 174234)
+++ trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp 2014-10-02 22:49:06 UTC (rev 174235)
@@ -55,6 +55,9 @@
m_lengthComputable = lengthComputable;
m_loaded = loaded;
m_total = total;
+
+ if (!m_target->hasEventListeners(eventNames().progressEvent))
+ return;
if (m_deferEvents) {
// Only store the latest progress event while suspended.
@@ -100,7 +103,7 @@
m_target->dispatchEvent(event);
}
-void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomicString &type)
+void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomicString& type)
{
ASSERT(type == eventNames().loadstartEvent || type == eventNames().progressEvent || type == eventNames().loadEvent || type == eventNames().loadendEvent || type == eventNames().abortEvent || type == eventNames().errorEvent || type == eventNames().timeoutEvent);
@@ -110,7 +113,8 @@
m_total = 0;
}
- dispatchEvent(XMLHttpRequestProgressEvent::create(type, m_lengthComputable, m_loaded, m_total));
+ if (m_target->hasEventListeners(type))
+ dispatchEvent(XMLHttpRequestProgressEvent::create(type, m_lengthComputable, m_loaded, m_total));
}
void XMLHttpRequestProgressEventThrottle::flushProgressEvent()
Modified: trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h (174234 => 174235)
--- trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h 2014-10-02 22:48:48 UTC (rev 174234)
+++ trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h 2014-10-02 22:49:06 UTC (rev 174235)
@@ -51,7 +51,6 @@
void dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total);
void dispatchReadyStateChangeEvent(PassRefPtr<Event>, ProgressEventAction = DoNotFlushProgressEvent);
- void dispatchEvent(PassRefPtr<Event>);
void dispatchProgressEvent(const AtomicString&);
void suspend();
@@ -63,6 +62,7 @@
virtual void fired();
void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*);
void flushProgressEvent();
+ void dispatchEvent(PassRefPtr<Event>);
bool hasEventToDispatch() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes