Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in dom/animation. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D104229
This commit is contained in:
Simon Giesecke 2021-02-09 18:19:44 +00:00
Родитель ba3b6a2b06
Коммит 8ae4e0da81
1 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -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);