From 8ae4e0da8118b7c84f94f5980ef181f83abae667 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Tue, 9 Feb 2021 18:19:44 +0000 Subject: [PATCH] Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in dom/animation. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D104229 --- dom/animation/EffectCompositor.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/dom/animation/EffectCompositor.cpp b/dom/animation/EffectCompositor.cpp index 37644ca8654f..885f8ce07137 100644 --- a/dom/animation/EffectCompositor.cpp +++ b/dom/animation/EffectCompositor.cpp @@ -241,19 +241,21 @@ void EffectCompositor::RequestRestyle(dom::Element* aElement, PseudoElementHashEntry::KeyType key = {aElement, aPseudoType}; if (aRestyleType == RestyleType::Throttled) { - elementsToRestyle.LookupForAdd(key).OrInsert([]() { return false; }); + elementsToRestyle.WithEntryHandle( + key, [](auto&& entry) { entry.OrInsert(false); }); mPresContext->PresShell()->SetNeedThrottledAnimationFlush(); } else { - bool skipRestyle; // Update hashtable first in case PostRestyleForAnimation mutates it. // (It shouldn't, but just to be sure.) - if (auto p = elementsToRestyle.LookupForAdd(key)) { - skipRestyle = p.Data(); - p.Data() = true; - } else { - skipRestyle = false; - p.OrInsert([]() { return true; }); - } + const bool skipRestyle = + elementsToRestyle.WithEntryHandle(key, [](auto&& p) { + if (p) { + return std::exchange(p.Data(), true); + } + + p.Insert(true); + return false; + }); if (!skipRestyle) { PostRestyleForAnimation(aElement, aPseudoType, aCascadeLevel);