Bug 1929338 - convert more mozilla:clamped to std:clamp r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D228069
This commit is contained in:
longsonr 2024-11-05 18:52:41 +00:00
parent c8987e34f7
commit 944913a6b6
28 changed files with 59 additions and 69 deletions

View File

@ -276,7 +276,6 @@
#include "mozilla/net/NeckoChannelParams.h"
#include "mozilla/net/RequestContextService.h"
#include "nsAboutProtocolUtils.h"
#include "nsAlgorithm.h"
#include "nsAttrValue.h"
#include "nsAttrValueInlines.h"
#include "nsBaseHashtable.h"
@ -10672,8 +10671,8 @@ static Maybe<LayoutDeviceToScreenScale> ParseScaleString(
if (scale < 0) {
return Nothing();
}
return Some(clamped(LayoutDeviceToScreenScale(scale), ViewportMinScale(),
ViewportMaxScale()));
return Some(std::clamp(LayoutDeviceToScreenScale(scale), ViewportMinScale(),
ViewportMaxScale()));
}
void Document::ParseScalesInViewportMetaData(
@ -10730,7 +10729,7 @@ void Document::ParseWidthAndHeightInMetaViewport(const nsAString& aWidthString,
if (NS_FAILED(widthErrorCode)) {
mMaxWidth = nsViewportInfo::kAuto;
} else if (mMaxWidth >= 0.0f) {
mMaxWidth = clamped(mMaxWidth, CSSCoord(1.0f), CSSCoord(10000.0f));
mMaxWidth = std::clamp(mMaxWidth, CSSCoord(1.0f), CSSCoord(10000.0f));
} else {
mMaxWidth = nsViewportInfo::kAuto;
}
@ -10757,7 +10756,7 @@ void Document::ParseWidthAndHeightInMetaViewport(const nsAString& aWidthString,
if (NS_FAILED(heightErrorCode)) {
mMaxHeight = nsViewportInfo::kAuto;
} else if (mMaxHeight >= 0.0f) {
mMaxHeight = clamped(mMaxHeight, CSSCoord(1.0f), CSSCoord(10000.0f));
mMaxHeight = std::clamp(mMaxHeight, CSSCoord(1.0f), CSSCoord(10000.0f));
} else {
mMaxHeight = nsViewportInfo::kAuto;
}
@ -11079,8 +11078,8 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
// prevent the viewport from taking on that size.
CSSSize effectiveMinSize = Min(CSSSize(kViewportMinSize), displaySize);
size.width = clamped(size.width, effectiveMinSize.width,
float(kViewportMaxSize.width));
size.width = std::clamp(size.width, effectiveMinSize.width,
float(kViewportMaxSize.width));
// Also recalculate the default zoom, if it wasn't specified in the
// metadata, and the width is specified.
@ -11089,8 +11088,8 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
scaleFloat = (scaleFloat > bestFitScale) ? scaleFloat : bestFitScale;
}
size.height = clamped(size.height, effectiveMinSize.height,
float(kViewportMaxSize.height));
size.height = std::clamp(size.height, effectiveMinSize.height,
float(kViewportMaxSize.height));
// In cases of user-scalable=no, if we have a positive scale, clamp it to
// min and max, and then use the clamped value for the scale, the min, and
@ -11099,7 +11098,7 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
if (effectiveZoomFlag == nsViewportInfo::ZoomFlag::DisallowZoom &&
scaleFloat > CSSToScreenScale(0.0f)) {
scaleFloat = scaleMinFloat = scaleMaxFloat =
clamped(scaleFloat, scaleMinFloat, scaleMaxFloat);
std::clamp(scaleFloat, scaleMinFloat, scaleMaxFloat);
}
MOZ_ASSERT(
scaleFloat > CSSToScreenScale(0.0f) || !mValidScaleFloat,

View File

@ -221,7 +221,6 @@
#include "mozilla/Tokenizer.h"
#include "mozilla/widget/IMEData.h"
#include "nsAboutProtocolUtils.h"
#include "nsAlgorithm.h"
#include "nsArrayUtils.h"
#include "nsAtomHashKeys.h"
#include "nsAttrName.h"
@ -1911,7 +1910,7 @@ int32_t nsContentUtils::ParseLegacyFontSize(const nsAString& aValue) {
}
}
return clamped(value, 1, 7);
return std::clamp(value, 1, 7);
}
/* static */

View File

@ -16,7 +16,6 @@
#include "nsIURL.h"
#include "nsWhitespaceTokenizer.h"
#include "nsAlgorithm.h"
#include "nsContentUtils.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsScriptSecurityManager.h"
@ -182,28 +181,28 @@ ReferrerPolicy ReferrerInfo::ReferrerPolicyFromHeaderString(
/* static */
uint32_t ReferrerInfo::GetUserReferrerSendingPolicy() {
return clamped<uint32_t>(
return std::clamp<uint32_t>(
StaticPrefs::network_http_sendRefererHeader_DoNotUseDirectly(),
MIN_REFERRER_SENDING_POLICY, MAX_REFERRER_SENDING_POLICY);
}
/* static */
uint32_t ReferrerInfo::GetUserXOriginSendingPolicy() {
return clamped<uint32_t>(
return std::clamp<uint32_t>(
StaticPrefs::network_http_referer_XOriginPolicy_DoNotUseDirectly(),
MIN_CROSS_ORIGIN_SENDING_POLICY, MAX_CROSS_ORIGIN_SENDING_POLICY);
}
/* static */
uint32_t ReferrerInfo::GetUserTrimmingPolicy() {
return clamped<uint32_t>(
return std::clamp<uint32_t>(
StaticPrefs::network_http_referer_trimmingPolicy_DoNotUseDirectly(),
MIN_TRIMMING_POLICY, MAX_TRIMMING_POLICY);
}
/* static */
uint32_t ReferrerInfo::GetUserXOriginTrimmingPolicy() {
return clamped<uint32_t>(
return std::clamp<uint32_t>(
StaticPrefs::
network_http_referer_XOriginTrimmingPolicy_DoNotUseDirectly(),
MIN_TRIMMING_POLICY, MAX_TRIMMING_POLICY);

View File

@ -72,8 +72,8 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
if (isOriginSmoothnessEnabled) {
static const int32_t kSmoothScrollMaxAllowedAnimationDurationMS = 10000;
maxMS = clamped(maxMS, 0, kSmoothScrollMaxAllowedAnimationDurationMS);
minMS = clamped(minMS, 0, maxMS);
maxMS = std::clamp(maxMS, 0, kSmoothScrollMaxAllowedAnimationDurationMS);
minMS = std::clamp(minMS, 0, maxMS);
}
// Keep the animation duration longer than the average event intervals

View File

@ -76,9 +76,8 @@
#include "mozilla/mozalloc.h" // for operator new, etc
#include "mozilla/Unused.h" // for unused
#include "mozilla/webrender/WebRenderTypes.h"
#include "nsAlgorithm.h" // for clamped
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_WARNING
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_WARNING
#include "nsLayoutUtils.h"
#include "nsMathUtils.h" // for NS_hypot
#include "nsPoint.h" // for nsIntPoint
@ -1677,8 +1676,8 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
(spanRatio < 1.0 && userZoom > realMinZoom));
if (doScale) {
spanRatio = clamped(spanRatio, realMinZoom.scale / userZoom.scale,
realMaxZoom.scale / userZoom.scale);
spanRatio = std::clamp(spanRatio, realMinZoom.scale / userZoom.scale,
realMaxZoom.scale / userZoom.scale);
// Note that the spanRatio here should never put us into OVERSCROLL_BOTH
// because up above we clamped it.
@ -6145,8 +6144,8 @@ void AsyncPanZoomController::ZoomToRect(const ZoomTarget& aZoomTarget,
compositionBounds.Height() / cssExpandedPageRect.Height()));
localMinZoom.scale =
clamped(localMinZoom.scale, mZoomConstraints.mMinZoom.scale,
mZoomConstraints.mMaxZoom.scale);
std::clamp(localMinZoom.scale, mZoomConstraints.mMinZoom.scale,
mZoomConstraints.mMaxZoom.scale);
localMinZoom = std::max(mZoomConstraints.mMinZoom, localMinZoom);
CSSToParentLayerScale localMaxZoom =
@ -6225,7 +6224,7 @@ void AsyncPanZoomController::ZoomToRect(const ZoomTarget& aZoomTarget,
}
targetZoom.scale =
clamped(targetZoom.scale, localMinZoom.scale, localMaxZoom.scale);
std::clamp(targetZoom.scale, localMinZoom.scale, localMaxZoom.scale);
FrameMetrics endZoomToMetrics = Metrics();
endZoomToMetrics.SetZoom(CSSToParentLayerScale(targetZoom));

View File

@ -141,7 +141,7 @@ ParentLayerCoord Axis::ApplyResistance(
(1 - fabsf(GetOverscroll()) / GetCompositionLength()) / 16;
float result = resistanceFactor < 0 ? ParentLayerCoord(0)
: aRequestedOverscroll * resistanceFactor;
result = clamped(result, -8.0f, 8.0f);
result = std::clamp(result, -8.0f, 8.0f);
return result;
}
@ -192,7 +192,7 @@ void Axis::RestoreOverscroll(ParentLayerCoord aOverscroll) {
void Axis::StartOverscrollAnimation(float aVelocity) {
const float maxVelocity = StaticPrefs::apz_overscroll_max_velocity();
aVelocity = clamped(aVelocity / 2.0f, -maxVelocity, maxVelocity);
aVelocity = std::clamp(aVelocity / 2.0f, -maxVelocity, maxVelocity);
SetVelocity(aVelocity);
mMSDModel.SetPosition(mOverscroll);
// Convert velocity from ParentLayerCoords/millisecond to

View File

@ -411,7 +411,7 @@ int CALLBACK GDIFontFamily::FamilyAddStylesProc(
}
// Some fonts claim to support things > 900, but we don't so clamp the sizes
logFont.lfWeight = clamped(logFont.lfWeight, LONG(100), LONG(900));
logFont.lfWeight = std::clamp(logFont.lfWeight, LONG(100), LONG(900));
gfxWindowsFontType feType =
GDIFontEntry::DetermineFontType(metrics, fontType);

View File

@ -8,7 +8,6 @@
#include "mozilla/gfx/BasePoint4D.h"
#include "mozilla/gfx/Matrix.h"
#include "nsAlgorithm.h"
#include <algorithm>
struct gfxQuaternion
@ -35,7 +34,7 @@ struct gfxQuaternion
}
gfxQuaternion Slerp(const gfxQuaternion& aOther, gfxFloat aCoeff) const {
gfxFloat dot = mozilla::clamped(DotProduct(aOther), -1.0, 1.0);
gfxFloat dot = std::clamp(DotProduct(aOther), -1.0, 1.0);
if (dot == 1.0) {
return *this;
}

View File

@ -413,7 +413,7 @@ void MobileViewportManager::UpdateResolutionForViewportSizeChange(
// +---+
// Conveniently, the denominator is c clamped to a..b.
float denominator = clamped(c, a, b);
float denominator = std::clamp(c, a, b);
float adjustedRatio = d / denominator;
CSSToScreenScale adjustedZoom = ScaleZoomWithDisplayWidth(

View File

@ -354,7 +354,7 @@ Maybe<ResolvedMotionPathData> MotionPathUtils::ResolveMotionPath(
} else {
// Per the spec, for unclosed interval, let used offset distance be equal
// to offset distance clamped by 0 and the total length of the path.
usedDistance = clamped(usedDistance, 0.0f, pathLength);
usedDistance = std::clamp(usedDistance, 0.0f, pathLength);
}
gfx::Point tangent;
point = path->ComputePointAtLength(usedDistance, &tangent);

View File

@ -1632,8 +1632,8 @@ void nsLayoutUtils::ConstrainToCoordValues(float& aStart, float& aSize) {
// nsRect::X/Y() and nsRect::XMost/YMost() can't return values outwith this
// range:
float end = aStart + aSize;
aStart = clamped(aStart, float(nscoord_MIN), float(nscoord_MAX));
end = clamped(end, float(nscoord_MIN), float(nscoord_MAX));
aStart = std::clamp(aStart, float(nscoord_MIN), float(nscoord_MAX));
end = std::clamp(end, float(nscoord_MIN), float(nscoord_MAX));
aSize = end - aStart;

View File

@ -891,7 +891,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
// If we're giving extra time for tasks outside a tick, try to
// ensure the next vsync after that period is handled, so subtract
// a grace period.
TimeDuration timeForOutsideTick = clamped(
TimeDuration timeForOutsideTick = std::clamp(
tickStart - mLastTickEnd - gracePeriod, gracePeriod, rate * 4);
mSuspendVsyncPriorityTicksUntil = tickEnd + timeForOutsideTick;
} else if (ShouldGiveNonVsyncTasksMoreTime(true)) {

View File

@ -364,7 +364,7 @@ Decimal nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) {
}
nscoord posAtStart = rangeRect.x + thumbSize.width / 2;
nscoord posAtEnd = posAtStart + traversableDistance;
nscoord posOfPoint = mozilla::clamped(point.x, posAtStart, posAtEnd);
nscoord posOfPoint = std::clamp(point.x, posAtStart, posAtEnd);
fraction = Decimal(posOfPoint - posAtStart) / Decimal(traversableDistance);
if (IsRightToLeft()) {
fraction = Decimal(1) - fraction;
@ -376,7 +376,7 @@ Decimal nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) {
}
nscoord posAtStart = rangeRect.y + thumbSize.height / 2;
nscoord posAtEnd = posAtStart + traversableDistance;
nscoord posOfPoint = mozilla::clamped(point.y, posAtStart, posAtEnd);
nscoord posOfPoint = std::clamp(point.y, posAtStart, posAtEnd);
// For a vertical range, the top (posAtStart) is the highest value, so we
// subtract the fraction from 1.0 to get that polarity correct.
fraction = Decimal(posOfPoint - posAtStart) / Decimal(traversableDistance);

View File

@ -70,8 +70,8 @@ TimeDuration ScrollAnimationBezierPhysics::ComputeDuration(
// duration, we average event intervals using the recent 4 timestamps (now +
// three prev -> 3 intervals).
int32_t durationMS =
clamped<int32_t>(eventsDeltaMs * mSettings.mIntervalRatio,
mSettings.mMinMS, mSettings.mMaxMS);
std::clamp<int32_t>(eventsDeltaMs * mSettings.mIntervalRatio,
mSettings.mMinMS, mSettings.mMaxMS);
return TimeDuration::FromMilliseconds(durationMS);
}

View File

@ -49,7 +49,7 @@ class ScrollAnimationBezierPhysics final : public ScrollAnimationPhysics {
protected:
double ProgressAt(const TimeStamp& aTime) const {
return clamped((aTime - mStartTime) / mDuration, 0.0, 1.0);
return std::clamp((aTime - mStartTime) / mDuration, 0.0, 1.0);
}
nscoord VelocityComponent(double aTimeProgress,

View File

@ -147,7 +147,7 @@ static double ClampVelocityToMaximum(double aVelocity, double aInitialPosition,
// destination.
double velocityLimit =
sqrt(aSpringConstant) * abs(aDestination - aInitialPosition);
return clamped(aVelocity, -velocityLimit, velocityLimit);
return std::clamp(aVelocity, -velocityLimit, velocityLimit);
}
ScrollAnimationMSDPhysics::NonOscillatingAxisPhysicsMSDModel::

View File

@ -2794,10 +2794,10 @@ static nscoord ClampAndAlignWithPixels(nscoord aDesired, nscoord aBoundLower,
nscoord aCurrent) {
// Intersect scroll range with allowed range, by clamping the ends
// of aRange to be within bounds
nscoord destLower = clamped(aDestLower, aBoundLower, aBoundUpper);
nscoord destUpper = clamped(aDestUpper, aBoundLower, aBoundUpper);
nscoord destLower = std::clamp(aDestLower, aBoundLower, aBoundUpper);
nscoord destUpper = std::clamp(aDestUpper, aBoundLower, aBoundUpper);
nscoord desired = clamped(aDesired, destLower, destUpper);
nscoord desired = std::clamp(aDesired, destLower, destUpper);
if (StaticPrefs::layout_scroll_disable_pixel_alignment()) {
return desired;
}

View File

@ -1103,8 +1103,8 @@ void nsColumnSetFrame::FindBestBalanceBSize(const ReflowInput& aReflowInput,
// extraBlockSize to try to make it on the feasible side.
nextGuess = aColData.mSumBSize / aConfig.mUsedColCount + extraBlockSize;
// Sanitize it
nextGuess = clamped(nextGuess, aConfig.mKnownInfeasibleBSize + 1,
aConfig.mKnownFeasibleBSize - 1);
nextGuess = std::clamp(nextGuess, aConfig.mKnownInfeasibleBSize + 1,
aConfig.mKnownFeasibleBSize - 1);
// We keep doubling extraBlockSize in every iteration until we find a
// feasible guess.
extraBlockSize *= 2;

View File

@ -25,7 +25,6 @@
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/StaticPrefs_layout.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsAlgorithm.h" // for clamped()
#include "nsCSSFrameConstructor.h"
#include "nsDisplayList.h"
#include "nsFieldSetFrame.h"
@ -4586,7 +4585,7 @@ nsGridContainerFrame::LineRange nsGridContainerFrame::Grid::ResolveLineRange(
// https://drafts.csswg.org/css-grid-2/#subgrid-implicit ("using the same
// procedure as for clamping placement in an overly-large grid").
//
// Note that these two clamped() assignments might collapse our range to
// Note that these two clamped assignments might collapse our range to
// have both edges pointing at the same line (spanning 0 tracks); this
// might happen here if e.g. r.first were mClampMaxLine, and r.second gets
// clamped from some higher number down to mClampMaxLine. We'll handle this
@ -4595,9 +4594,10 @@ nsGridContainerFrame::LineRange nsGridContainerFrame::Grid::ResolveLineRange(
// the #overlarge-grids clamping spec text that says "its span must be
// truncated to 1" when clamping an item that was completely outside the
// limits.
r.first = clamped(r.first, aNameMap.mClampMinLine, aNameMap.mClampMaxLine);
r.first =
std::clamp(r.first, aNameMap.mClampMinLine, aNameMap.mClampMaxLine);
r.second =
clamped(r.second, aNameMap.mClampMinLine, aNameMap.mClampMaxLine);
std::clamp(r.second, aNameMap.mClampMinLine, aNameMap.mClampMaxLine);
// Handle grid placement errors.
// https://drafts.csswg.org/css-grid-2/#grid-placement-errors

View File

@ -70,7 +70,7 @@ class MOZ_STACK_CLASS ColorStopInterpolator {
uint32_t extraStops =
(uint32_t)(floor(endPosition * kFullRangeExtraStops) -
floor(startPosition * kFullRangeExtraStops));
extraStops = clamped(extraStops, 1U, kFullRangeExtraStops);
extraStops = std::clamp(extraStops, 1U, kFullRangeExtraStops);
float step = 1.0f / (float)extraStops;
for (uint32_t extraStop = 0; extraStop <= extraStops; extraStop++) {
auto progress = (float)extraStop * step;

View File

@ -260,7 +260,7 @@ class Accumulate {
return aOne.ToMatrix();
}
double theta = acos(mozilla::clamped(aTwo.w, -1.0, 1.0));
double theta = acos(std::clamp(aTwo.w, -1.0, 1.0));
double scale = (theta != 0.0) ? 1.0 / sin(theta) : 0.0;
theta *= aCoeff;
scale *= sin(theta);

View File

@ -4654,7 +4654,7 @@ struct BCCorners {
BCCornerInfo& operator[](int32_t i) const {
NS_ASSERTION((i >= startIndex) && (i <= endIndex), "program error");
return corners[clamped(i, startIndex, endIndex) - startIndex];
return corners[std::clamp(i, startIndex, endIndex) - startIndex];
}
int32_t startIndex;
@ -4674,7 +4674,7 @@ struct BCCellBorders {
BCCellBorder& operator[](int32_t i) const {
NS_ASSERTION((i >= startIndex) && (i <= endIndex), "program error");
return borders[clamped(i, startIndex, endIndex) - startIndex];
return borders[std::clamp(i, startIndex, endIndex) - startIndex];
}
int32_t startIndex;

View File

@ -579,7 +579,7 @@ void nsSliderFrame::Reflow(nsPresContext* aPresContext,
int32_t pageIncrement = GetPageIncrement(scrollbar);
maxPos = std::max(minPos, maxPos);
curPos = clamped(curPos, minPos, maxPos);
curPos = std::clamp(curPos, minPos, maxPos);
// If modifying the logic here, be sure to modify the corresponding
// compositor-side calculation in ScrollThumbUtils::ApplyTransformForAxis().
@ -876,7 +876,7 @@ void nsSliderFrame::CurrentPositionChanged() {
int32_t maxPos = GetMaxPosition(scrollbar);
maxPos = std::max(minPos, maxPos);
curPos = clamped(curPos, minPos, maxPos);
curPos = std::clamp(curPos, minPos, maxPos);
// get the thumb's rect
nsIFrame* thumbFrame = mFrames.FirstChild();

View File

@ -22,7 +22,6 @@
#include "mozilla/intl/Segmenter.h"
#include "gfxUtils.h"
#include "nsAlgorithm.h"
#include "nsCOMPtr.h"
#include "nsComponentManagerUtils.h"
#include "nsFontMetrics.h"
@ -3545,7 +3544,7 @@ nsresult nsTreeBodyFrame::ScrollInternal(const ScrollParts& aParts,
// This can happen when items are removed for example. (bug 1085050)
int32_t maxTopRowIndex = std::max(0, mRowCount - mPageLength);
aRow = mozilla::clamped(aRow, 0, maxTopRowIndex);
aRow = std::clamp(aRow, 0, maxTopRowIndex);
if (aRow == mTopRowIndex) {
return NS_OK;
}

View File

@ -7,7 +7,6 @@
#include "ScrollbarDrawingCocoa.h"
#include "mozilla/RelativeLuminanceUtils.h"
#include "nsAlgorithm.h"
#include "nsIFrame.h"
#include "nsLayoutUtils.h"
#include "nsNativeTheme.h"
@ -166,7 +165,7 @@ static ThumbRect GetThumbRect(const LayoutDeviceRect& aRect,
// For the default alpha of 128 we want to end up with 48 in the outline.
constexpr float kAlphaScaling = 48.0f / 128.0f;
const uint8_t strokeAlpha =
uint8_t(clamped(NS_GET_A(faceColor) * kAlphaScaling, 0.0f, 48.0f));
uint8_t(std::clamp(NS_GET_A(faceColor) * kAlphaScaling, 0.0f, 48.0f));
if (strokeAlpha) {
strokeOutset = (aParams.isDark ? 0.3f : 0.5f) * aScale;
strokeWidth = (aParams.isDark ? 0.6f : 0.8f) * aScale;

View File

@ -14,7 +14,6 @@
#include "mozilla/TimeStamp.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/dom/SimpleGestureEventBinding.h"
#include "nsAlgorithm.h"
#include "nsIWidget.h"
#include "nsRefreshDriver.h"
#include "UnitTransforms.h"
@ -76,7 +75,7 @@ double SwipeTracker::ClampToAllowedRange(double aGestureAmount) const {
double max =
mSwipeDirection == dom::SimpleGestureEvent_Binding::DIRECTION_LEFT ? 1.0
: 0.0;
return clamped(aGestureAmount, min, max);
return std::clamp(aGestureAmount, min, max);
}
bool SwipeTracker::ComputeSwipeSuccess() const {

View File

@ -6,8 +6,6 @@
#include "TouchResampler.h"
#include "nsAlgorithm.h"
/**
* TouchResampler implementation
*/
@ -94,7 +92,7 @@ void TouchResampler::NotifyFrame(const TimeStamp& aTimeStamp) {
kTouchResampleMaxBacksampleMs);
TimeStamp upperBound = lastTouchTime + TimeDuration::FromMilliseconds(
kTouchResampleMaxPredictMs);
TimeStamp sampleTime = clamped(aTimeStamp, lowerBound, upperBound);
TimeStamp sampleTime = std::clamp(aTimeStamp, lowerBound, upperBound);
if (mLastEmittedEventTime && sampleTime < mLastEmittedEventTime) {
// Keep emitted timestamps in order.

View File

@ -116,11 +116,11 @@ static nscolor ProcessSelectionBackground(nscolor aColor, ColorScheme aScheme) {
if (sat > 0) {
// The color is not a shade of grey, restore the saturation taken away by
// the transparency.
sat = mozilla::clamped(sat * factor, 0, 255);
sat = std::clamp(sat * factor, 0, 255);
} else {
// The color is a shade of grey, find the value that looks equivalent
// on a white background with the given opacity.
value = mozilla::clamped(255 - (255 - value) * factor, 0, 255);
value = std::clamp(255 - (255 - value) * factor, 0, 255);
}
NS_HSV2RGB(resultColor, hue, sat, value, alpha);
return resultColor;