Bug 78840

Summary: Abstract ImageEventSender into a general purpose EventSender
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebCore Misc.Assignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, darin, yong.li.webkit
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 38995    
Attachments:
Description Flags
Patch
none
Patch abarth: review+

Description Daniel Bates 2012-02-16 14:03:21 PST
We should abstract the functionality of ImageEventSender into a general purpose class, called EventSender. This general purpose class may be useful towards fixing bug #38995.
Comment 1 Daniel Bates 2012-02-16 14:06:08 PST
Created attachment 127438 [details]
Patch

The name "EventSender" is a bit vague. The purpose of this class is to queue up senders of a specific DOM event, say a Load event, and to call each sender back when they should dispatch such an event. Maybe EventSenderScheduler or EventSenderQueue would be a more descriptive name?
Comment 2 Daniel Bates 2012-02-16 15:20:30 PST
Comment on attachment 127438 [details]
Patch

Clearing review flag as I need to add EventSender.h to all build systems.
Comment 3 Daniel Bates 2012-02-16 16:27:42 PST
Created attachment 127464 [details]
Patch
Comment 4 Adam Barth 2012-02-21 12:35:54 PST
Comment on attachment 127464 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=127464&action=review

> Source/WebCore/dom/EventSender.h:88
> +    if (m_dispatchSoonList.isEmpty())
> +        m_timer.stop();

Do you mean to check whether the list is empty or whether it contains all zeros?  I'm not sure how this function could result in m_dispatchSoonList being empty if it wasn't already empty.

> Source/WebCore/loader/ImageLoader.cpp:-385
> -    if (m_dispatchSoonList.isEmpty())
> -        m_timer.stop();

I see this was here already.  We might want to ask the original author why they intended here.
Comment 5 Daniel Bates 2012-02-22 15:19:15 PST
(In reply to comment #4)
> (From update of attachment 127464 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=127464&action=review
> 
> > Source/WebCore/dom/EventSender.h:88
> > +    if (m_dispatchSoonList.isEmpty())
> > +        m_timer.stop();
> 
> Do you mean to check whether the list is empty or whether it contains all zeros?  I'm not sure how this function could result in m_dispatchSoonList being empty if it wasn't already empty.

As far as I can tell this code isn't necessary anymore and is an artifact of using a QPtrList data structure for this functionality when it was originally in DocumentImpl::removeImage() (see <http://trac.webkit.org/browser/trunk/WebCore/khtml/xml/DocumentImpl.cpp?rev=12515#L2302>). In particular, DocumentImpl::removeImage() actually removed items from its QPtrList m_imageLoadEventDispatchSoonList (as opposed to zeroing out its items as we do today) ;=> m_imageLoadEventDispatchSoonList could become empty.

I'll remove this code before landing.

CC'ing Darin Adler since he may be interested to see this go by given that he kept this "if (m_dispatchSoonList.isEmpty())" code through both <http://trac.webkit.org/changeset/39296> (changed functionality to zero out list entries) and <http://trac.webkit.org/changeset/41766> (moved functionality out of Document.cpp).
Comment 6 Daniel Bates 2012-02-22 15:27:57 PST
Committed r108561: <http://trac.webkit.org/changeset/108561>
Comment 7 Yong Li 2013-01-25 07:18:41 PST
This EventSender should be SuspendableTimer or at least ActiveDOMObject?