diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index ae45ef47c84e..f9daaecc3591 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -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 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, diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index e2739c817d8c..ce1c791268f9 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -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 */ diff --git a/dom/security/ReferrerInfo.cpp b/dom/security/ReferrerInfo.cpp index 76bd44b1b12b..39d32db20166 100644 --- a/dom/security/ReferrerInfo.cpp +++ b/dom/security/ReferrerInfo.cpp @@ -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( + return std::clamp( StaticPrefs::network_http_sendRefererHeader_DoNotUseDirectly(), MIN_REFERRER_SENDING_POLICY, MAX_REFERRER_SENDING_POLICY); } /* static */ uint32_t ReferrerInfo::GetUserXOriginSendingPolicy() { - return clamped( + return std::clamp( StaticPrefs::network_http_referer_XOriginPolicy_DoNotUseDirectly(), MIN_CROSS_ORIGIN_SENDING_POLICY, MAX_CROSS_ORIGIN_SENDING_POLICY); } /* static */ uint32_t ReferrerInfo::GetUserTrimmingPolicy() { - return clamped( + return std::clamp( StaticPrefs::network_http_referer_trimmingPolicy_DoNotUseDirectly(), MIN_TRIMMING_POLICY, MAX_TRIMMING_POLICY); } /* static */ uint32_t ReferrerInfo::GetUserXOriginTrimmingPolicy() { - return clamped( + return std::clamp( StaticPrefs:: network_http_referer_XOriginTrimmingPolicy_DoNotUseDirectly(), MIN_TRIMMING_POLICY, MAX_TRIMMING_POLICY); diff --git a/gfx/layers/apz/src/APZPublicUtils.cpp b/gfx/layers/apz/src/APZPublicUtils.cpp index d0f002e0255f..ead7b824766b 100644 --- a/gfx/layers/apz/src/APZPublicUtils.cpp +++ b/gfx/layers/apz/src/APZPublicUtils.cpp @@ -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 diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index c12e888a8d0c..e04a26310a65 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -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)); diff --git a/gfx/layers/apz/src/Axis.cpp b/gfx/layers/apz/src/Axis.cpp index 28fa8170997b..2176a2ad49fb 100644 --- a/gfx/layers/apz/src/Axis.cpp +++ b/gfx/layers/apz/src/Axis.cpp @@ -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 diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index efddf769c3be..5bb288d560ef 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -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); diff --git a/gfx/thebes/gfxQuaternion.h b/gfx/thebes/gfxQuaternion.h index ec6f94cad937..364f70ca1fe1 100644 --- a/gfx/thebes/gfxQuaternion.h +++ b/gfx/thebes/gfxQuaternion.h @@ -8,7 +8,6 @@ #include "mozilla/gfx/BasePoint4D.h" #include "mozilla/gfx/Matrix.h" -#include "nsAlgorithm.h" #include 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; } diff --git a/layout/base/MobileViewportManager.cpp b/layout/base/MobileViewportManager.cpp index 6572ed362841..a313edc5d589 100644 --- a/layout/base/MobileViewportManager.cpp +++ b/layout/base/MobileViewportManager.cpp @@ -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( diff --git a/layout/base/MotionPathUtils.cpp b/layout/base/MotionPathUtils.cpp index 723a8ab19347..bcb16d89972f 100644 --- a/layout/base/MotionPathUtils.cpp +++ b/layout/base/MotionPathUtils.cpp @@ -354,7 +354,7 @@ Maybe 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); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 4ee753d1bc75..78e84d998477 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -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; diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index b22f0f088543..7b939ae54b27 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -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)) { diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index 63a372158509..0fdc500f9aa7 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -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); diff --git a/layout/generic/ScrollAnimationBezierPhysics.cpp b/layout/generic/ScrollAnimationBezierPhysics.cpp index ffc69a9fa425..eb8a0227b5dc 100644 --- a/layout/generic/ScrollAnimationBezierPhysics.cpp +++ b/layout/generic/ScrollAnimationBezierPhysics.cpp @@ -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(eventsDeltaMs * mSettings.mIntervalRatio, - mSettings.mMinMS, mSettings.mMaxMS); + std::clamp(eventsDeltaMs * mSettings.mIntervalRatio, + mSettings.mMinMS, mSettings.mMaxMS); return TimeDuration::FromMilliseconds(durationMS); } diff --git a/layout/generic/ScrollAnimationBezierPhysics.h b/layout/generic/ScrollAnimationBezierPhysics.h index c3bf36ee71f0..2949b654825d 100644 --- a/layout/generic/ScrollAnimationBezierPhysics.h +++ b/layout/generic/ScrollAnimationBezierPhysics.h @@ -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, diff --git a/layout/generic/ScrollAnimationMSDPhysics.cpp b/layout/generic/ScrollAnimationMSDPhysics.cpp index 8f0ae32d3ba6..988232c700f7 100644 --- a/layout/generic/ScrollAnimationMSDPhysics.cpp +++ b/layout/generic/ScrollAnimationMSDPhysics.cpp @@ -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:: diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp index b8fa31d49b60..41f275f50770 100644 --- a/layout/generic/ScrollContainerFrame.cpp +++ b/layout/generic/ScrollContainerFrame.cpp @@ -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; } diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index 4f8fd0a2142c..370204cb1e0f 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -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; diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 780ba0b6d68b..dc8511443cdc 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -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 diff --git a/layout/painting/nsCSSRenderingGradients.h b/layout/painting/nsCSSRenderingGradients.h index 68ecab07ae30..3872e2cef40d 100644 --- a/layout/painting/nsCSSRenderingGradients.h +++ b/layout/painting/nsCSSRenderingGradients.h @@ -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; diff --git a/layout/style/nsStyleTransformMatrix.cpp b/layout/style/nsStyleTransformMatrix.cpp index 5aa670eefb54..b83455364492 100644 --- a/layout/style/nsStyleTransformMatrix.cpp +++ b/layout/style/nsStyleTransformMatrix.cpp @@ -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); diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 783011f6de84..c57b8c75d00c 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -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; diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index 0553a83fbff9..c2cbb59ae263 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -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(); diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 3b34323d75a7..4c92226e49ba 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -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; } diff --git a/widget/ScrollbarDrawingCocoa.cpp b/widget/ScrollbarDrawingCocoa.cpp index 449fe0e8645b..7d8b548d258e 100644 --- a/widget/ScrollbarDrawingCocoa.cpp +++ b/widget/ScrollbarDrawingCocoa.cpp @@ -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; diff --git a/widget/SwipeTracker.cpp b/widget/SwipeTracker.cpp index 7474432e718a..b09252fd60be 100644 --- a/widget/SwipeTracker.cpp +++ b/widget/SwipeTracker.cpp @@ -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 { diff --git a/widget/TouchResampler.cpp b/widget/TouchResampler.cpp index eeed30fe0e31..634da2f428a4 100644 --- a/widget/TouchResampler.cpp +++ b/widget/TouchResampler.cpp @@ -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. diff --git a/widget/cocoa/nsLookAndFeel.mm b/widget/cocoa/nsLookAndFeel.mm index 90fdae54275b..5eeb746ce482 100644 --- a/widget/cocoa/nsLookAndFeel.mm +++ b/widget/cocoa/nsLookAndFeel.mm @@ -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;