Bug 1822022 - Replace mfbt/FloatingPoint things with std cmath r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D172410
This commit is contained in:
Kagami Sascha Rosylight 2023-03-14 07:48:34 +00:00
parent 366d2b5404
commit 920138cd5c
5 changed files with 16 additions and 14 deletions

View File

@ -7,10 +7,10 @@
#ifndef mozilla_dom_QueueWithSizes_h
#define mozilla_dom_QueueWithSizes_h
#include <cmath>
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/UniquePtr.h"
#include "nsTArray.h"
@ -42,7 +42,7 @@ using QueueWithSizes = AutoCleanLinkedList<ValueWithSize>;
inline bool IsNonNegativeNumber(double v) {
// Step 1. Implicit.
// Step 2.
if (mozilla::IsNaN(v)) {
if (std::isnan(v)) {
return false;
}
@ -55,24 +55,29 @@ template <class QueueContainingClass>
inline void EnqueueValueWithSize(QueueContainingClass aContainer,
JS::Handle<JS::Value> aValue, double aSize,
ErrorResult& aRv) {
// Step 1. Implicit by template instantiation.
// Step 2.
// Step 1. Assert: container has [[queue]] and [[queueTotalSize]] internal
// slots. (Implicit by template instantiation.)
// Step 2. If ! IsNonNegativeNumber(size) is false, throw a RangeError
// exception.
if (!IsNonNegativeNumber(aSize)) {
aRv.ThrowRangeError("invalid size");
return;
}
// Step 3.
if (mozilla::IsInfinite(aSize)) {
// Step 3. If size is +∞, throw a RangeError exception.
if (std::isinf(aSize)) {
aRv.ThrowRangeError("Infinite queue size");
return;
}
// Step 4. See the comment on QueueWithSizes for the lifetime reasoning
// around this allocation.
// Step 4. Append a new value-with-size with value value and size size to
// container.[[queue]].
// (See the comment on QueueWithSizes for the lifetime reasoning around this
// allocation.)
ValueWithSize* valueWithSize = new ValueWithSize(aValue, aSize);
aContainer->Queue().insertBack(valueWithSize);
// Step 5.
// Step 5. Set container.[[queueTotalSize]] to container.[[queueTotalSize]] +
// size.
aContainer->SetQueueTotalSize(aContainer->QueueTotalSize() + aSize);
}

View File

@ -20,7 +20,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/dom/BindingCallContext.h"

View File

@ -4,7 +4,7 @@
#include "StreamUtils.h"
#include "mozilla/FloatingPoint.h"
#include <cmath>
#include "mozilla/dom/QueuingStrategyBinding.h"
namespace mozilla::dom {
@ -22,7 +22,7 @@ double ExtractHighWaterMark(const QueuingStrategy& aStrategy,
double highWaterMark = aStrategy.mHighWaterMark.Value();
// Step 3.
if (mozilla::IsNaN(highWaterMark) || highWaterMark < 0) {
if (std::isnan(highWaterMark) || highWaterMark < 0) {
aRv.ThrowRangeError("Invalid highWaterMark");
return 0.0;
}

View File

@ -15,7 +15,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/AbortSignal.h"
#include "mozilla/dom/BindingCallContext.h"

View File

@ -12,7 +12,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/WritableStream.h"
#include "mozilla/dom/WritableStreamDefaultWriterBinding.h"