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

View File

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

View File

@@ -382,9 +382,10 @@ void TimeoutManager::UpdateBudget(const TimeStamp& aNow,
double factor = GetRegenerationFactor(isBackground); double factor = GetRegenerationFactor(isBackground);
TimeDuration regenerated = (aNow - mLastBudgetUpdate).MultDouble(factor); TimeDuration regenerated = (aNow - mLastBudgetUpdate).MultDouble(factor);
// Clamp the budget to the range of minimum and maximum allowed budget. // Clamp the budget to the range of minimum and maximum allowed budget.
mExecutionBudget = mExecutionBudget = TimeDuration::Max(
std::clamp(mExecutionBudget - aDuration + regenerated, GetMinBudget(isBackground),
GetMinBudget(isBackground), GetMaxBudget(isBackground)); TimeDuration::Min(GetMaxBudget(isBackground),
mExecutionBudget - aDuration + regenerated));
} else { } else {
// If budget throttling isn't enabled, reset the execution budget // If budget throttling isn't enabled, reset the execution budget
// to the max budget specified in preferences. Always doing this // to the max budget specified in preferences. Always doing this
@@ -663,8 +664,8 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow,
uint32_t totalTimeLimitMS = uint32_t totalTimeLimitMS =
std::max(1u, StaticPrefs::dom_timeout_max_consecutive_callbacks_ms()); std::max(1u, StaticPrefs::dom_timeout_max_consecutive_callbacks_ms());
const TimeDuration totalTimeLimit = const TimeDuration totalTimeLimit =
std::clamp(mExecutionBudget, TimeDuration(), TimeDuration::Min(TimeDuration::FromMilliseconds(totalTimeLimitMS),
TimeDuration::FromMilliseconds(totalTimeLimitMS)); TimeDuration::Max(TimeDuration(), mExecutionBudget));
// Allow up to 25% of our total time budget to be used figuring out which // 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. // 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); ${nativeType}* self = UnwrapProxy(proxy);
uint32_t length = self->Length(${callerType}); uint32_t length = self->Length(${callerType});
// Compute the end of the indices we'll get ourselves // 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) { for (uint32_t index = begin; index < ourEnd; ++index) {
$*{get} $*{get}

View File

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