Backed out changeset a5ae29b17323 (bug 1929270) for causing multiple failures related to mozalloc_abort

This commit is contained in:
Norisz Fay
2024-11-13 01:20:48 +02:00
parent a58dd8c30e
commit 5cbec17815
5 changed files with 19 additions and 14 deletions

View File

@@ -1968,8 +1968,10 @@ StickyTimeDuration Animation::IntervalStartTime(
MOZ_ASSERT(AsCSSTransition() || AsCSSAnimation(),
"Should be called for CSS animations or transitions");
static constexpr StickyTimeDuration zeroDuration = StickyTimeDuration();
return std::clamp(aActiveDuration, zeroDuration,
StickyTimeDuration(-mEffect->NormalizedTiming().Delay()));
return std::max(
std::min(StickyTimeDuration(-mEffect->NormalizedTiming().Delay()),
aActiveDuration),
zeroDuration);
}
// Later side of the elapsed time range reported in CSS Animations and CSS
@@ -1998,8 +2000,9 @@ StickyTimeDuration Animation::IntervalEndTime(
return zeroDuration;
}
return std::clamp(aActiveDuration, zeroDuration,
effectEnd - mEffect->NormalizedTiming().Delay());
return std::max(std::min(effectEnd - mEffect->NormalizedTiming().Delay(),
aActiveDuration),
zeroDuration);
}
} // namespace mozilla::dom

View File

@@ -151,8 +151,9 @@ ComputedTiming AnimationEffect::GetComputedTimingAt(
return result;
}
result.mActiveTime =
std::clamp(result.mActiveDuration, zeroDuration,
StickyTimeDuration(localTime - aTiming.Delay()));
std::max(std::min(StickyTimeDuration(localTime - aTiming.Delay()),
result.mActiveDuration),
zeroDuration);
} else if (localTime < beforeActiveBoundary ||
(aPlaybackRate < 0 && localTime == beforeActiveBoundary &&
!atProgressTimelineBoundary)) {

View File

@@ -382,9 +382,10 @@ void TimeoutManager::UpdateBudget(const TimeStamp& aNow,
double factor = GetRegenerationFactor(isBackground);
TimeDuration regenerated = (aNow - mLastBudgetUpdate).MultDouble(factor);
// Clamp the budget to the range of minimum and maximum allowed budget.
mExecutionBudget =
std::clamp(mExecutionBudget - aDuration + regenerated,
GetMinBudget(isBackground), GetMaxBudget(isBackground));
mExecutionBudget = TimeDuration::Max(
GetMinBudget(isBackground),
TimeDuration::Min(GetMaxBudget(isBackground),
mExecutionBudget - aDuration + regenerated));
} else {
// If budget throttling isn't enabled, reset the execution budget
// to the max budget specified in preferences. Always doing this
@@ -663,8 +664,8 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow,
uint32_t totalTimeLimitMS =
std::max(1u, StaticPrefs::dom_timeout_max_consecutive_callbacks_ms());
const TimeDuration totalTimeLimit =
std::clamp(mExecutionBudget, TimeDuration(),
TimeDuration::FromMilliseconds(totalTimeLimitMS));
TimeDuration::Min(TimeDuration::FromMilliseconds(totalTimeLimitMS),
TimeDuration::Max(TimeDuration(), mExecutionBudget));
// Allow up to 25% of our total time budget to be used figuring out which
// timers need to run. This is the initial loop in this method.

View File

@@ -16328,7 +16328,7 @@ class CGDOMJSProxyHandler_getElements(ClassMethod):
${nativeType}* self = UnwrapProxy(proxy);
uint32_t length = self->Length(${callerType});
// Compute the end of the indices we'll get ourselves
uint32_t ourEnd = std::clamp(length, begin, end);
uint32_t ourEnd = std::max(begin, std::min(end, length));
for (uint32_t index = begin; index < ourEnd; ++index) {
$*{get}

View File

@@ -4620,8 +4620,8 @@ static gfx::IntPoint ComputeHotspot(imgIContainer* aContainer,
aContainer->GetWidth(&imgWidth);
aContainer->GetHeight(&imgHeight);
auto hotspot = gfx::IntPoint::Round(*aHotspot);
return {std::clamp(hotspot.x.value, 0, imgWidth - 1),
std::clamp(hotspot.y.value, 0, imgHeight - 1)};
return {std::max(std::min(hotspot.x.value, imgWidth - 1), 0),
std::max(std::min(hotspot.y.value, imgHeight - 1), 0)};
}
gfx::IntPoint hotspot;