Bug 1887615 - Micro-optimize PointerEventHandler::ReleaseIfCaptureByDescendant, r=edgar

Differential Revision: https://phabricator.services.mozilla.com/D205547
This commit is contained in:
Olli Pettay 2024-03-25 11:22:13 +00:00
parent 74592b2a81
commit 21c5917a34

View File

@ -461,11 +461,13 @@ Element* PointerEventHandler::GetPointerCapturingElement(
void PointerEventHandler::ReleaseIfCaptureByDescendant(nsIContent* aContent) {
// We should check that aChild does not contain pointer capturing elements.
// If it does we should release the pointer capture for the elements.
for (const auto& entry : *sPointerCaptureList) {
PointerCaptureInfo* data = entry.GetWeak();
if (data && data->mPendingElement &&
data->mPendingElement->IsInclusiveDescendantOf(aContent)) {
ReleasePointerCaptureById(entry.GetKey());
if (!sPointerCaptureList->IsEmpty()) {
for (const auto& entry : *sPointerCaptureList) {
PointerCaptureInfo* data = entry.GetWeak();
if (data && data->mPendingElement &&
data->mPendingElement->IsInclusiveDescendantOf(aContent)) {
ReleasePointerCaptureById(entry.GetKey());
}
}
}
}