Bug 29920

Summary: Make a copy of listeners array before dispatching an event
Product: WebKit Reporter: Yury Semikhatsky <yurys>
Component: Web Inspector (Deprecated)Assignee: Yury Semikhatsky <yurys>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, pmuellr, timothy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
patch none

Description Yury Semikhatsky 2009-09-30 05:56:19 PDT
Make a copy of listeners array before dispatching an event in WebInspector.Object.prototype.dispatchEventToListeners. Otherwise if current listener removes itself from the array next listener will be skipped.
Comment 1 Yury Semikhatsky 2009-09-30 06:05:24 PDT
Created attachment 40366 [details]
patch
Comment 2 Timothy Hatcher 2009-09-30 09:18:45 PDT
Comment on attachment 40366 [details]
patch

Why did you remove the bind calls?

Those are needed to pass the event as the this object.
Comment 3 Patrick Mueller 2009-09-30 11:43:23 PDT
Looks like the bind() should be on preventDefault, but not on stopPropagation.  Not harmful on stopPropagation, but it's not needed, and otherwise creates a new function closure for no good reason.
Comment 4 Yury Semikhatsky 2009-09-30 23:48:07 PDT
(In reply to comment #2)
> (From update of attachment 40366 [details])
> Why did you remove the bind calls?
> 
> Those are needed to pass the event as the this object.

There is no need to bind the functions to event since 'this' variable will be resolved dynamically and as long as preventDefault and stopPropagation are invoked on 'event' 'this' object will be === 'event'. Please tell me if you still want me to revert the changes.
Comment 5 WebKit Commit Bot 2009-10-01 06:17:12 PDT
Comment on attachment 40366 [details]
patch

Clearing flags on attachment: 40366

Committed r48970: <http://trac.webkit.org/changeset/48970>
Comment 6 WebKit Commit Bot 2009-10-01 06:17:16 PDT
All reviewed patches have been landed.  Closing bug.