views: don't dangle mouse press handler on view destruction View::SetMouseAndGestureHandler()'s documentation alleges: // Note: if the mouse handler is no longer connected to a // view hierarchy, events won't be sent. but actually this is not true. There is logic in RootView::ViewHierarchyChanged() which clears mouse_pressed_handler_ if that view is removed from the RootView's tree, but that logic *doesn't* trigger if the handler was explicitly set. That means that doing this: View* v = root->AddChildView(std::make_unique<View>()); root->SetMouseAndGestureHandler(v); root->RemoveChildViewT(v); will leave root with a dangling mouse_pressed_handler_. If another mouse event then arrives, it will be sent to that dangling pointer. It's not easy to trigger this in production but there is a unit test (RootViewTest.EventHandlersResetWhenDeleted) that trips the dangling pointer detector in a similar way. To fix that problem, have RootView clear the handler *even if it was explicitly set* when it is removed from the RootView's view hierarchy. Bug: 361651894 Change-Id: I75fe49e2c8439b3986a5937ed887f4334fda1a2d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5906230 Commit-Queue: Elly FJ <ellyjones@chromium.org> Reviewed-by: Robert Liao <robliao@chromium.org> Cr-Commit-Position: refs/heads/main@{#1365015}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.