Stop passing a PassRefPtr to dispatchEvent() because: 1. PassRefPtr is legacy and should no longer be used 2. We don't actually transfer ownership of the Event to the callee Pass a C++ reference instead.
Created attachment 265323 [details] Patch
Created attachment 265325 [details] Patch
Created attachment 265326 [details] Patch
Created attachment 265328 [details] Patch
Created attachment 265354 [details] Patch
Comment on attachment 265354 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=265354&action=review r=me with comments. This is a huge code improvement and reduces ref thrashing. I just have a few questions. Good luck landing this. > Source/WebCore/Modules/mediastream/MediaStream.cpp:306 > - dispatchEvent(event.release()); > + dispatchEvent(*event); I don't like adding unchecked dereferencing of pointers. Could we make events a Vector<Ref<Event>>? > Source/WebCore/Modules/mediastream/RTCDTMFSender.cpp:165 > + dispatchEvent(*event); ditto > Source/WebCore/Modules/mediastream/RTCDataChannel.cpp:324 > + dispatchEvent(*event); ditto > Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp:745 > + dispatchEvent(*event); ditto > Source/WebCore/css/FontLoader.cpp:191 > + dispatchEvent(*pendingEvents[index]); ditto > Source/WebCore/dom/EventTarget.h:127 > + bool dispatchEvent(Event*, ExceptionCode&); // DOM API Why is this comment here? > Source/WebCore/dom/MessagePort.cpp:-165 > - dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION); Should we completely remove IgnorableExceptionCode? > Source/WebCore/editing/Editor.cpp:-855 > - target->dispatchEvent(event, IGNORE_EXCEPTION); Same with IGNORE_EXCEPTION. Why are we getting rid of this? > Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp:153 > - dispatchEvent(WTF::move(deferredProgressEvent)); > + dispatchEvent(*deferredProgressEvent); Ditto
Created attachment 265361 [details] Patch
Comment on attachment 265354 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=265354&action=review >> Source/WebCore/Modules/mediastream/MediaStream.cpp:306 >> + dispatchEvent(*event); > > I don't like adding unchecked dereferencing of pointers. Could we make events a Vector<Ref<Event>>? Sure. Will do. >> Source/WebCore/dom/EventTarget.h:127 >> + bool dispatchEvent(Event*, ExceptionCode&); // DOM API > > Why is this comment here? Because this is supposed to be called from JS. >> Source/WebCore/dom/MessagePort.cpp:-165 >> - dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION); > > Should we completely remove IgnorableExceptionCode? I am pretty sure there is still a lot of code that uses it. >> Source/WebCore/editing/Editor.cpp:-855 >> - target->dispatchEvent(event, IGNORE_EXCEPTION); > > Same with IGNORE_EXCEPTION. Why are we getting rid of this? There are 2 dispatchEvent() overloads: 1. dispatchEvent(Event*, ExceptionCode&) -> Meant to be used by JS bindings. Because the event comes from JS, we do some additional checks on the event and throw an exception if those checks fail. The checks are: null pointer, event is not initialized, event is already being dispatched. 2. dispatchEvent(Event&) -> Meant to be called by C++ code. It cannot throw as we expect the event argument to be valid. Previously, some of our C++ code was unnecessarily calling the overload that is meant to be used by JS so I fixed that. I will also add assertions in dispatchEvent(Event&) to make sure the event is initialized and not already being dispatched. >> Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp:153 >> + dispatchEvent(*deferredProgressEvent); > > Ditto Well, this one has a null check.
Created attachment 265362 [details] Patch
Created attachment 265363 [details] Patch
Created attachment 265364 [details] Patch
Comment on attachment 265364 [details] Patch Clearing flags on attachment: 265364 Committed r192354: <http://trac.webkit.org/changeset/192354>
All reviewed patches have been landed. Closing bug.