Web Inspector: Timelines: don't call willDispatchEvent/didDispatchEvent unless there...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2019 18:04:45 +0000 (18:04 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2019 18:04:45 +0000 (18:04 +0000)
commita6f05e4b450e0c416a308a50a0aae323d23bea17
tree68bf59e636db2ee29e6e109f44cb905f5491cbb8
parent2e2cb6fe8fb467bc3fed16561d28bbb86d1dda53
Web Inspector: Timelines: don't call willDispatchEvent/didDispatchEvent unless there is a listener for the event
https://bugs.webkit.org/show_bug.cgi?id=202713

Reviewed by Joseph Pecoraro.

Fixes failing inspector/timeline/timeline-recording.html after r250672. This was because the
`InspectorTimelineAgent` expected a corresponding `willDispatchEvent` before it was told
about the `didDispatchEvent`, which wasn't happening since only `willDispatchEvent` would
early-return if the `DOMWindow` didn't have any event listeners for the dispatched event. By
making the `DOMWindow::dispatchEvent` itself early-return in that case, it now handles both
`willDispatchEvent` and `didDispatchEvent`, ensuring that they are always called in pairs.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchEvent):

* dom/EventTarget.cpp:
(WebCore::EventTarget::innerInvokeEventListeners):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willDispatchEvent):
(WebCore::InspectorInstrumentation::didDispatchEvent):
(WebCore::InspectorInstrumentation::willDispatchEventOnWindow):
(WebCore::InspectorInstrumentation::didDispatchEventOnWindow):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willDispatchEventImpl):
(WebCore::InspectorInstrumentation::didDispatchEventImpl):
(WebCore::InspectorInstrumentation::willDispatchEventOnWindowImpl):
(WebCore::InspectorInstrumentation::didDispatchEventOnWindowImpl):
`InspectorInstrumentation::willDispatchEventImpl` was always called with `hasEventListeners`
as `true`, so there's no reason to keep that parameter around. Similarly, the change inside
`DOMWindow::dispatchEvent` will make it so that the same is true for
`InspectorInstrumentation::willDispatchEventOnWindowImpl` as well.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250977 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/EventTarget.cpp
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/page/DOMWindow.cpp