Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor optimizations to EventDispatcher::dispatchEvent() #11721

Merged

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented Mar 20, 2023

3e45e63

Minor optimizations to EventDispatcher::dispatchEvent()
https://bugs.webkit.org/show_bug.cgi?id=254170

Reviewed by Darin Adler.

Minor optimizations to EventDispatcher::dispatchEvent():
- Use a bool instead of a std::optional<bool> for shouldClearTargetsAfterDispatch
  since we don't need 3 states.
- Minimize calls to `event.type() == eventNames().clickEvent` since `eventNames()`
  is not super cheap.
- Minimize calls to shouldSuppressEventDispatchInDOM() and avoid calling
  `event.stopPropagation()` when this function returns true. We can factor the
  `if` check so that setting the stop propagation flag on the event is not actually
  necessary. Note that we call `resetAfterDispatch()` on the event shortly after,
  which resets the stop propagation flag anyway.

* Source/WebCore/dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):

Canonical link: https://commits.webkit.org/261906@main

7077d40

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 ❌ πŸ§ͺ gtk-wk2
βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2   πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim

@cdumez cdumez self-assigned this Mar 20, 2023
@cdumez cdumez added the DOM For bugs specific to XML/HTML DOM elements (including parsing). label Mar 20, 2023
@cdumez cdumez changed the title Minors optimizations to EventDispatcher::dispatchEvent() Minor optimizations to EventDispatcher::dispatchEvent() Mar 20, 2023
@cdumez cdumez force-pushed the 254170_EventDispatcher_dispatchEvent branch from 66330fd to 7077d40 Compare March 20, 2023 19:59
@cdumez cdumez marked this pull request as ready for review March 20, 2023 23:32
@cdumez cdumez requested a review from rniwa as a code owner March 20, 2023 23:32
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 21, 2023
@cdumez cdumez added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Mar 21, 2023
https://bugs.webkit.org/show_bug.cgi?id=254170

Reviewed by Darin Adler.

Minor optimizations to EventDispatcher::dispatchEvent():
- Use a bool instead of a std::optional<bool> for shouldClearTargetsAfterDispatch
  since we don't need 3 states.
- Minimize calls to `event.type() == eventNames().clickEvent` since `eventNames()`
  is not super cheap.
- Minimize calls to shouldSuppressEventDispatchInDOM() and avoid calling
  `event.stopPropagation()` when this function returns true. We can factor the
  `if` check so that setting the stop propagation flag on the event is not actually
  necessary. Note that we call `resetAfterDispatch()` on the event shortly after,
  which resets the stop propagation flag anyway.

* Source/WebCore/dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):

Canonical link: https://commits.webkit.org/261906@main
@webkit-commit-queue webkit-commit-queue force-pushed the 254170_EventDispatcher_dispatchEvent branch from 7077d40 to 3e45e63 Compare March 21, 2023 02:23
@webkit-commit-queue webkit-commit-queue merged commit 3e45e63 into WebKit:main Mar 21, 2023
@webkit-commit-queue
Copy link
Collaborator

Committed 261906@main (3e45e63): https://commits.webkit.org/261906@main

Reviewed commits have been landed. Closing PR #11721 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DOM For bugs specific to XML/HTML DOM elements (including parsing).
Projects
None yet
5 participants