Bug 1748874 - Part 4: Move MOZ_CAN_RUN_SCRIPT to declarations in dom/streams r=mgaudet

Depends on D135403

Differential Revision: https://phabricator.services.mozilla.com/D135404
This commit is contained in:
Kagami Sascha Rosylight 2022-01-07 20:46:19 +00:00
Родитель f4bf42dc63
Коммит 0aa656fceb
19 изменённых файлов: 98 добавлений и 116 удалений

Просмотреть файл

@ -396,7 +396,7 @@ bool ReadableByteStreamControllerShouldCallPull(
return false;
}
void ReadableByteStreamControllerCallPullIfNeeded(
MOZ_CAN_RUN_SCRIPT void ReadableByteStreamControllerCallPullIfNeeded(
JSContext* aCx, ReadableByteStreamController* aController,
ErrorResult& aRv);
@ -405,6 +405,7 @@ void ReadableByteStreamControllerCallPullIfNeeded(
class ByteStreamPullIfNeededPromiseHandler final : public PromiseNativeHandler {
~ByteStreamPullIfNeededPromiseHandler() = default;
// Virtually const, but cycle collected
RefPtr<ReadableByteStreamController> mController;
public:
@ -427,7 +428,8 @@ class ByteStreamPullIfNeededPromiseHandler final : public PromiseNativeHandler {
// Step 7.2.2
ErrorResult rv;
ReadableByteStreamControllerCallPullIfNeeded(aCx, mController, rv);
ReadableByteStreamControllerCallPullIfNeeded(
aCx, MOZ_KnownLive(mController), rv);
(void)rv.MaybeSetPendingException(aCx, "PullIfNeeded Resolved Error");
}
}
@ -450,7 +452,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ByteStreamPullIfNeededPromiseHandler)
NS_INTERFACE_MAP_END
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-call-pull-if-needed
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamControllerCallPullIfNeeded(
JSContext* aCx, ReadableByteStreamController* aController,
ErrorResult& aRv) {
@ -626,7 +627,6 @@ void ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(
}
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-enqueue
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamControllerEnqueue(
JSContext* aCx, ReadableByteStreamController* aController,
JS::Handle<JSObject*> aChunk, ErrorResult& aRv) {
@ -758,7 +758,6 @@ void ReadableByteStreamControllerEnqueue(
}
// https://streams.spec.whatwg.org/#rbs-controller-enqueue
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamController::Enqueue(JSContext* aCx,
const ArrayBufferView& aChunk,
ErrorResult& aRv) {
@ -808,7 +807,6 @@ void ReadableByteStreamController::Error(JSContext* aCx,
}
// https://streams.spec.whatwg.org/#rbs-controller-private-cancel
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> ReadableByteStreamController::CancelSteps(
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv) {
// Step 1.
@ -859,7 +857,6 @@ void ReadableByteStreamControllerHandleQueueDrain(
}
// https://streams.spec.whatwg.org/#rbs-controller-private-pull
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamController::PullSteps(JSContext* aCx,
ReadRequest* aReadRequest,
ErrorResult& aRv) {
@ -1140,7 +1137,6 @@ static void ReadableByteStreamControllerRespondInReadableState(
}
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond-internal
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamControllerRespondInternal(
JSContext* aCx, ReadableByteStreamController* aController,
uint64_t aBytesWritten, ErrorResult& aRv) {
@ -1192,7 +1188,6 @@ void ReadableByteStreamControllerRespondInternal(
}
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamControllerRespond(
JSContext* aCx, ReadableByteStreamController* aController,
uint64_t aBytesWritten, ErrorResult& aRv) {
@ -1247,7 +1242,6 @@ void ReadableByteStreamControllerRespond(
}
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond-with-new-view
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamControllerRespondWithNewView(
JSContext* aCx, ReadableByteStreamController* aController,
JS::Handle<JSObject*> aView, ErrorResult& aRv) {
@ -1449,7 +1443,6 @@ bool ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(
}
// https://streams.spec.whatwg.org/#readable-byte-stream-controller-pull-into
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamControllerPullInto(
JSContext* aCx, ReadableByteStreamController* aController,
JS::HandleObject aView, ReadIntoRequest* aReadIntoRequest,
@ -1682,7 +1675,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ByteStreamStartPromiseNativeHandler)
NS_INTERFACE_MAP_END
// https://streams.spec.whatwg.org/#set-up-readable-byte-stream-controller
MOZ_CAN_RUN_SCRIPT
void SetUpReadableByteStreamController(
JSContext* aCx, ReadableStream* aStream,
ReadableByteStreamController* aController,

Просмотреть файл

@ -63,16 +63,17 @@ class ReadableByteStreamController final : public ReadableStreamController,
void Close(JSContext* aCx, ErrorResult& aRv);
void Enqueue(JSContext* aCx, const ArrayBufferView& aChunk, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Enqueue(JSContext* aCx, const ArrayBufferView& aChunk,
ErrorResult& aRv);
void Error(JSContext* aCx, JS::Handle<JS::Value> aErrorValue,
ErrorResult& aRv);
virtual already_AddRefed<Promise> CancelSteps(JSContext* aCx,
JS::Handle<JS::Value> aReason,
ErrorResult& aRv) override;
virtual void PullSteps(JSContext* aCx, ReadRequest* aReadRequest,
ErrorResult& aRv) override;
MOZ_CAN_RUN_SCRIPT virtual already_AddRefed<Promise> CancelSteps(
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv) override;
MOZ_CAN_RUN_SCRIPT virtual void PullSteps(JSContext* aCx,
ReadRequest* aReadRequest,
ErrorResult& aRv) override;
// Internal Slot Accessors
Maybe<uint64_t> AutoAllocateChunkSize() { return mAutoAllocateChunkSize; }
@ -332,19 +333,19 @@ struct PullIntoDescriptor final
~PullIntoDescriptor() = default;
};
extern void ReadableByteStreamControllerRespond(
MOZ_CAN_RUN_SCRIPT extern void ReadableByteStreamControllerRespond(
JSContext* aCx, ReadableByteStreamController* aController,
uint64_t aBytesWritten, ErrorResult& aRv);
extern void ReadableByteStreamControllerRespondInternal(
MOZ_CAN_RUN_SCRIPT extern void ReadableByteStreamControllerRespondInternal(
JSContext* aCx, ReadableByteStreamController* aController,
uint64_t aBytesWritten, ErrorResult& aRv);
extern void ReadableByteStreamControllerRespondWithNewView(
MOZ_CAN_RUN_SCRIPT extern void ReadableByteStreamControllerRespondWithNewView(
JSContext* aCx, ReadableByteStreamController* aController,
JS::Handle<JSObject*> aView, ErrorResult& aRv);
extern void ReadableByteStreamControllerPullInto(
MOZ_CAN_RUN_SCRIPT extern void ReadableByteStreamControllerPullInto(
JSContext* aCx, ReadableByteStreamController* aController,
JS::HandleObject aView, ReadIntoRequest* aReadIntoRequest,
ErrorResult& aRv);
@ -353,7 +354,7 @@ extern void ReadableByteStreamControllerError(
ReadableByteStreamController* aController, JS::HandleValue aValue,
ErrorResult& aRv);
extern void ReadableByteStreamControllerEnqueue(
MOZ_CAN_RUN_SCRIPT extern void ReadableByteStreamControllerEnqueue(
JSContext* aCx, ReadableByteStreamController* aController,
JS::HandleObject aChunk, ErrorResult& aRv);
@ -365,7 +366,7 @@ extern void ReadableByteStreamControllerClose(
JSContext* aCx, ReadableByteStreamController* aController,
ErrorResult& aRv);
extern void SetUpReadableByteStreamController(
MOZ_CAN_RUN_SCRIPT extern void SetUpReadableByteStreamController(
JSContext* aCx, ReadableStream* aStream,
ReadableByteStreamController* aController,
UnderlyingSourceStartCallbackHelper* aStartAlgorithm,

Просмотреть файл

@ -320,7 +320,6 @@ void ReadableStreamClose(JSContext* aCx, ReadableStream* aStream,
}
// https://streams.spec.whatwg.org/#readable-stream-cancel
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> ReadableStreamCancel(JSContext* aCx,
ReadableStream* aStream,
JS::Handle<JS::Value> aError,
@ -408,7 +407,6 @@ already_AddRefed<Promise> ReadableStreamCancel(JSContext* aCx,
}
// https://streams.spec.whatwg.org/#rs-cancel
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> ReadableStream::Cancel(JSContext* aCx,
JS::Handle<JS::Value> aReason,
ErrorResult& aRv) {
@ -809,7 +807,6 @@ static void ReadableStreamTee(JSContext* aCx, ReadableStream* aStream,
ReadableStreamDefaultTee(aCx, aStream, aCloneForBranch2, aResult, aRv);
}
MOZ_CAN_RUN_SCRIPT
void ReadableStream::Tee(JSContext* aCx,
nsTArray<RefPtr<ReadableStream>>& aResult,
ErrorResult& aRv) {
@ -832,7 +829,6 @@ void ReadableStreamAddReadIntoRequest(ReadableStream* aStream,
}
// https://streams.spec.whatwg.org/#abstract-opdef-createreadablebytestream
MOZ_CAN_RUN_SCRIPT
already_AddRefed<ReadableStream> CreateReadableByteStream(
JSContext* aCx, nsIGlobalObject* aGlobal,
UnderlyingSourceStartCallbackHelper* aStartAlgorithm,

Просмотреть файл

@ -93,21 +93,23 @@ class ReadableStream final : public nsISupports, public nsWrapperCache {
JS::Handle<JSObject*> aGivenProto) override;
// IDL Methods
static already_AddRefed<ReadableStream> Constructor(
const GlobalObject& aGlobal,
const Optional<JS::Handle<JSObject*>>& aUnderlyingSource,
const QueuingStrategy& aStrategy, ErrorResult& aRv);
// TODO: Use MOZ_CAN_RUN_SCRIPT when IDL constructors can use it (bug 1749042)
MOZ_CAN_RUN_SCRIPT_BOUNDARY static already_AddRefed<ReadableStream>
Constructor(const GlobalObject& aGlobal,
const Optional<JS::Handle<JSObject*>>& aUnderlyingSource,
const QueuingStrategy& aStrategy, ErrorResult& aRv);
bool Locked() const;
already_AddRefed<Promise> Cancel(JSContext* cx, JS::Handle<JS::Value> aReason,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Cancel(
JSContext* cx, JS::Handle<JS::Value> aReason, ErrorResult& aRv);
void GetReader(JSContext* aCx, const ReadableStreamGetReaderOptions& aOptions,
OwningReadableStreamReader& resultReader, ErrorResult& aRv);
void Tee(JSContext* aCx, nsTArray<RefPtr<ReadableStream>>& aResult,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Tee(JSContext* aCx,
nsTArray<RefPtr<ReadableStream>>& aResult,
ErrorResult& aRv);
// Internal Slots:
private:
@ -141,7 +143,7 @@ extern void ReadableStreamAddReadRequest(ReadableStream* aStream,
extern void ReadableStreamAddReadIntoRequest(ReadableStream* aStream,
ReadIntoRequest* aReadIntoRequest);
extern already_AddRefed<Promise> ReadableStreamCancel(
MOZ_CAN_RUN_SCRIPT extern already_AddRefed<Promise> ReadableStreamCancel(
JSContext* aCx, ReadableStream* aStream, JS::Handle<JS::Value> aError,
ErrorResult& aRv);
@ -152,11 +154,12 @@ AcquireReadableStreamDefaultReader(JSContext* aCx, ReadableStream* aStream,
extern bool ReadableStreamHasBYOBReader(ReadableStream* aStream);
extern bool ReadableStreamHasDefaultReader(ReadableStream* aStream);
extern already_AddRefed<ReadableStream> CreateReadableByteStream(
JSContext* aCx, nsIGlobalObject* aGlobal,
UnderlyingSourceStartCallbackHelper* aStartAlgorithm,
UnderlyingSourcePullCallbackHelper* aPullAlgorithm,
UnderlyingSourceCancelCallbackHelper* aCancelAlgorithm, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT extern already_AddRefed<ReadableStream>
CreateReadableByteStream(JSContext* aCx, nsIGlobalObject* aGlobal,
UnderlyingSourceStartCallbackHelper* aStartAlgorithm,
UnderlyingSourcePullCallbackHelper* aPullAlgorithm,
UnderlyingSourceCancelCallbackHelper* aCancelAlgorithm,
ErrorResult& aRv);
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -156,7 +156,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Read_ReadIntoRequest)
NS_INTERFACE_MAP_END_INHERITING(ReadIntoRequest)
// https://streams.spec.whatwg.org/#readable-stream-byob-reader-read
MOZ_CAN_RUN_SCRIPT
void ReadableStreamBYOBReaderRead(JSContext* aCx,
ReadableStreamBYOBReader* aReader,
JS::HandleObject aView,
@ -191,7 +190,6 @@ void ReadableStreamBYOBReaderRead(JSContext* aCx,
}
// https://streams.spec.whatwg.org/#byob-reader-read
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> ReadableStreamBYOBReader::Read(
const ArrayBufferView& aArray, ErrorResult& aRv) {
AutoJSAPI jsapi;

Просмотреть файл

@ -57,8 +57,8 @@ class ReadableStreamBYOBReader final : public ReadableStreamGenericReader,
static already_AddRefed<ReadableStreamBYOBReader> Constructor(
const GlobalObject& global, ReadableStream& stream, ErrorResult& rv);
already_AddRefed<Promise> Read(const ArrayBufferView& aArray,
ErrorResult& rv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Read(
const ArrayBufferView& aArray, ErrorResult& rv);
void ReleaseLock(ErrorResult& rv);
@ -75,11 +75,9 @@ class ReadableStreamBYOBReader final : public ReadableStreamGenericReader,
already_AddRefed<ReadableStreamBYOBReader> AcquireReadableStreamBYOBReader(
JSContext* aCx, ReadableStream* aStream, ErrorResult& aRv);
void ReadableStreamBYOBReaderRead(JSContext* aCx,
ReadableStreamBYOBReader* aReader,
JS::HandleObject aView,
ReadIntoRequest* aReadIntoRequest,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void ReadableStreamBYOBReaderRead(
JSContext* aCx, ReadableStreamBYOBReader* aReader, JS::HandleObject aView,
ReadIntoRequest* aReadIntoRequest, ErrorResult& aRv);
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -48,7 +48,6 @@ void ReadableStreamBYOBRequest::GetView(
}
// https://streams.spec.whatwg.org/#rs-byob-request-respond
MOZ_CAN_RUN_SCRIPT
void ReadableStreamBYOBRequest::Respond(JSContext* aCx, uint64_t bytesWritten,
ErrorResult& aRv) {
// Step 1.
@ -84,7 +83,6 @@ void ReadableStreamBYOBRequest::Respond(JSContext* aCx, uint64_t bytesWritten,
}
// https://streams.spec.whatwg.org/#rs-byob-request-respond-with-new-view
MOZ_CAN_RUN_SCRIPT
void ReadableStreamBYOBRequest::RespondWithNewView(JSContext* aCx,
const ArrayBufferView& view,
ErrorResult& aRv) {

Просмотреть файл

@ -47,10 +47,12 @@ class ReadableStreamBYOBRequest final : public nsISupports,
void GetView(JSContext* cx, JS::MutableHandle<JSObject*> aRetVal) const;
void Respond(JSContext* aCx, uint64_t bytesWritten, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Respond(JSContext* aCx, uint64_t bytesWritten,
ErrorResult& aRv);
void RespondWithNewView(JSContext* aCx, const ArrayBufferView& view,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void RespondWithNewView(JSContext* aCx,
const ArrayBufferView& view,
ErrorResult& aRv);
ReadableByteStreamController* Controller() { return mController; }
void SetController(ReadableByteStreamController* aController) {

Просмотреть файл

@ -185,12 +185,11 @@ void ReadableStreamDefaultController::Close(JSContext* aCx, ErrorResult& aRv) {
ReadableStreamDefaultControllerClose(aCx, this, aRv);
}
static void ReadableStreamDefaultControllerCallPullIfNeeded(
MOZ_CAN_RUN_SCRIPT static void ReadableStreamDefaultControllerCallPullIfNeeded(
JSContext* aCx, ReadableStreamDefaultController* aController,
ErrorResult& aRv);
// https://streams.spec.whatwg.org/#readable-stream-default-controller-enqueue
MOZ_CAN_RUN_SCRIPT
void ReadableStreamDefaultControllerEnqueue(
JSContext* aCx, ReadableStreamDefaultController* aController,
JS::Handle<JS::Value> aChunk, ErrorResult& aRv) {
@ -277,7 +276,6 @@ void ReadableStreamDefaultControllerEnqueue(
}
// https://streams.spec.whatwg.org/#rs-default-controller-close
MOZ_CAN_RUN_SCRIPT
void ReadableStreamDefaultController::Enqueue(JSContext* aCx,
JS::Handle<JS::Value> aChunk,
ErrorResult& aRv) {
@ -357,6 +355,7 @@ void ReadableStreamDefaultControllerError(
class PullIfNeededNativePromiseHandler final : public PromiseNativeHandler {
~PullIfNeededNativePromiseHandler() = default;
// Virtually const, but cycle collected
RefPtr<ReadableStreamDefaultController> mController;
public:
@ -367,7 +366,8 @@ class PullIfNeededNativePromiseHandler final : public PromiseNativeHandler {
ReadableStreamDefaultController* aController)
: PromiseNativeHandler(), mController(aController) {}
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
MOZ_CAN_RUN_SCRIPT void ResolvedCallback(
JSContext* aCx, JS::Handle<JS::Value> aValue) override {
// https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed
// Step 7.1
mController->SetPulling(false);
@ -378,7 +378,8 @@ class PullIfNeededNativePromiseHandler final : public PromiseNativeHandler {
// Step 7.2.2
IgnoredErrorResult rv;
ReadableStreamDefaultControllerCallPullIfNeeded(aCx, mController, rv);
ReadableStreamDefaultControllerCallPullIfNeeded(
aCx, MOZ_KnownLive(mController), rv);
// Not Sure How To Handle Errors Inside Native Callbacks,
(void)NS_WARN_IF(rv.Failed());
}
@ -402,7 +403,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PullIfNeededNativePromiseHandler)
NS_INTERFACE_MAP_END
// https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed
MOZ_CAN_RUN_SCRIPT
static void ReadableStreamDefaultControllerCallPullIfNeeded(
JSContext* aCx, ReadableStreamDefaultController* aController,
ErrorResult& aRv) {
@ -528,7 +528,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StartPromiseNativeHandler)
NS_INTERFACE_MAP_END
// https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller
MOZ_CAN_RUN_SCRIPT
void SetUpReadableStreamDefaultController(
JSContext* aCx, ReadableStream* aStream,
ReadableStreamDefaultController* aController,
@ -594,7 +593,6 @@ void SetUpReadableStreamDefaultController(
}
// https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller-from-underlying-source
MOZ_CAN_RUN_SCRIPT
void SetupReadableStreamDefaultControllerFromUnderlyingSource(
JSContext* aCx, ReadableStream* aStream, JS::HandleObject aUnderlyingSource,
UnderlyingSource& aUnderlyingSourceDict, double aHighWaterMark,
@ -632,7 +630,6 @@ void SetupReadableStreamDefaultControllerFromUnderlyingSource(
}
// https://streams.spec.whatwg.org/#rs-default-controller-private-cancel
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> ReadableStreamDefaultController::CancelSteps(
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv) {
// Step 1.
@ -654,7 +651,6 @@ already_AddRefed<Promise> ReadableStreamDefaultController::CancelSteps(
}
// https://streams.spec.whatwg.org/#rs-default-controller-private-pull
MOZ_CAN_RUN_SCRIPT
void ReadableStreamDefaultController::PullSteps(JSContext* aCx,
ReadRequest* aReadRequest,
ErrorResult& aRv) {

Просмотреть файл

@ -62,15 +62,16 @@ class ReadableStreamDefaultController final : public ReadableStreamController,
void Close(JSContext* aCx, ErrorResult& aRv);
void Enqueue(JSContext* aCx, JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Enqueue(JSContext* aCx, JS::Handle<JS::Value> aChunk,
ErrorResult& aRv);
void Error(JSContext* aCx, JS::Handle<JS::Value> aError, ErrorResult& aRv);
virtual already_AddRefed<Promise> CancelSteps(JSContext* aCx,
JS::Handle<JS::Value> aReason,
ErrorResult& aRv) override;
virtual void PullSteps(JSContext* aCx, ReadRequest* aReadRequest,
ErrorResult& aRv) override;
MOZ_CAN_RUN_SCRIPT virtual already_AddRefed<Promise> CancelSteps(
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv) override;
MOZ_CAN_RUN_SCRIPT virtual void PullSteps(JSContext* aCx,
ReadRequest* aReadRequest,
ErrorResult& aRv) override;
// Internal Slot Accessors
UnderlyingSourceCancelCallbackHelper* GetCancelAlgorithm() const {
@ -138,7 +139,7 @@ class ReadableStreamDefaultController final : public ReadableStreamController,
RefPtr<ReadableStream> mStream;
};
extern void SetUpReadableStreamDefaultController(
MOZ_CAN_RUN_SCRIPT extern void SetUpReadableStreamDefaultController(
JSContext* aCx, ReadableStream* aStream,
ReadableStreamDefaultController* aController,
UnderlyingSourceStartCallbackHelper* aStartAlgorithm,
@ -147,12 +148,13 @@ extern void SetUpReadableStreamDefaultController(
double aHighWaterMark, QueuingStrategySize* aSizeAlgorithm,
ErrorResult& aRv);
extern void SetupReadableStreamDefaultControllerFromUnderlyingSource(
MOZ_CAN_RUN_SCRIPT extern void
SetupReadableStreamDefaultControllerFromUnderlyingSource(
JSContext* aCx, ReadableStream* aStream, JS::HandleObject aUnderlyingSource,
UnderlyingSource& aUnderlyingSourceDict, double aHighWaterMark,
QueuingStrategySize* aSizeAlgorithm, ErrorResult& aRv);
extern void ReadableStreamDefaultControllerEnqueue(
MOZ_CAN_RUN_SCRIPT extern void ReadableStreamDefaultControllerEnqueue(
JSContext* aCx, ReadableStreamDefaultController* aController,
JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
@ -160,10 +162,9 @@ extern void ReadableStreamDefaultControllerClose(
JSContext* aCx, ReadableStreamDefaultController* aController,
ErrorResult& aRv);
extern void ReadableStreamDefaultReaderRead(JSContext* aCx,
ReadableStreamGenericReader* reader,
ReadRequest* aRequest,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT extern void ReadableStreamDefaultReaderRead(
JSContext* aCx, ReadableStreamGenericReader* reader, ReadRequest* aRequest,
ErrorResult& aRv);
extern void ReadableStreamDefaultControllerError(
JSContext* aCx, ReadableStreamDefaultController* aController,

Просмотреть файл

@ -203,7 +203,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Read_ReadRequest)
NS_INTERFACE_MAP_END_INHERITING(ReadRequest)
// https://streams.spec.whatwg.org/#readable-stream-default-reader-read
MOZ_CAN_RUN_SCRIPT
void ReadableStreamDefaultReaderRead(JSContext* aCx,
ReadableStreamGenericReader* aReader,
ReadRequest* aRequest, ErrorResult& aRv) {
@ -241,7 +240,6 @@ void ReadableStreamDefaultReaderRead(JSContext* aCx,
// Return a raw pointer here to avoid refcounting, but make sure it's safe
// (the object should be kept alive by the callee).
// https://streams.spec.whatwg.org/#default-reader-read
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> ReadableStreamDefaultReader::Read(JSContext* aCx,
ErrorResult& aRv) {
// Step 1.
@ -336,7 +334,6 @@ static already_AddRefed<Promise> ReadableStreamGenericReaderCancel(
return ReadableStreamCancel(aCx, stream, aReason, aRv);
}
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> ReadableStreamGenericReader::Cancel(
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv) {
// Step 1.

Просмотреть файл

@ -54,7 +54,8 @@ class ReadableStreamDefaultReader final : public ReadableStreamGenericReader,
static already_AddRefed<ReadableStreamDefaultReader> Constructor(
const GlobalObject& aGlobal, ReadableStream& stream, ErrorResult& aRv);
already_AddRefed<Promise> Read(JSContext* aCx, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Read(JSContext* aCx,
ErrorResult& aRv);
void ReleaseLock(ErrorResult& aRv);

Просмотреть файл

@ -52,9 +52,8 @@ class ReadableStreamGenericReader : public nsISupports {
// IDL Methods
already_AddRefed<Promise> Closed() const;
already_AddRefed<Promise> Cancel(JSContext* aCx,
JS::Handle<JS::Value> aReason,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Cancel(
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv);
protected:
virtual ~ReadableStreamGenericReader() = default;

Просмотреть файл

@ -215,11 +215,12 @@ void ReadableStreamDefaultTeeReadRequest::ErrorSteps(
mTeeState->SetReading(false);
}
void PullWithDefaultReader(JSContext* aCx, TeeState* aTeeState,
ErrorResult& aRv);
void PullWithBYOBReader(JSContext* aCx, TeeState* aTeeState,
JS::HandleObject aView, bool aForBranch2,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void PullWithDefaultReader(JSContext* aCx,
TeeState* aTeeState,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void PullWithBYOBReader(JSContext* aCx, TeeState* aTeeState,
JS::HandleObject aView,
bool aForBranch2, ErrorResult& aRv);
// Algorithm described in
// https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamtee, Steps
@ -232,8 +233,9 @@ void PullWithBYOBReader(JSContext* aCx, TeeState* aTeeState,
// NativeByteStreamTeePullAlgorithm, which implements
// UnderlyingSourcePullCallbackHelper is the version which provies the return
// promise.
void ByteStreamTeePullAlgorithm(JSContext* aCx, size_t index,
TeeState* aTeeState, ErrorResult& aRv) {
MOZ_CAN_RUN_SCRIPT void ByteStreamTeePullAlgorithm(JSContext* aCx, size_t index,
TeeState* aTeeState,
ErrorResult& aRv) {
MOZ_ASSERT(index == 1 || index == 2);
// Step {17,18}.1: If reading is true,
@ -270,6 +272,7 @@ void ByteStreamTeePullAlgorithm(JSContext* aCx, size_t index,
class NativeByteStreamTeePullAlgorithm final
: public UnderlyingSourcePullCallbackHelper {
// Virtually const, but is cycle collected
RefPtr<TeeState> mTeeState;
size_t mBranchIndex;
@ -294,7 +297,8 @@ class NativeByteStreamTeePullAlgorithm final
return nullptr;
}
ByteStreamTeePullAlgorithm(aCx, mBranchIndex, mTeeState, aRv);
ByteStreamTeePullAlgorithm(aCx, mBranchIndex, MOZ_KnownLive(mTeeState),
aRv);
return returnPromise.forget();
}
@ -447,7 +451,7 @@ struct PullWithDefaultReaderReadRequest final : public ReadRequest {
// Step 8.
if (mTeeState->ReadAgainForBranch1()) {
ByteStreamTeePullAlgorithm(cx, 1, mTeeState, rv);
ByteStreamTeePullAlgorithm(cx, 1, MOZ_KnownLive(mTeeState), rv);
}
}
@ -483,7 +487,6 @@ NS_INTERFACE_MAP_END_INHERITING(ReadRequest)
// https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamtee:
// Step 15.
MOZ_CAN_RUN_SCRIPT
void PullWithDefaultReader(JSContext* aCx, TeeState* aTeeState,
ErrorResult& aRv) {
// Step 15.1: Not implemented until BYOB Readers are implemented.
@ -650,12 +653,12 @@ class PullWithBYOBReader_ReadIntoRequest final : public ReadIntoRequest {
// Step 8.
if (mTeeState->ReadAgainForBranch1()) {
ByteStreamTeePullAlgorithm(cx, 1, mTeeState, rv);
ByteStreamTeePullAlgorithm(cx, 1, MOZ_KnownLive(mTeeState), rv);
if (rv.MaybeSetPendingException(cx)) {
return;
}
} else if (mTeeState->ReadAgainForBranch2()) {
ByteStreamTeePullAlgorithm(cx, 1, mTeeState, rv);
ByteStreamTeePullAlgorithm(cx, 1, MOZ_KnownLive(mTeeState), rv);
if (rv.MaybeSetPendingException(cx)) {
return;
}
@ -771,7 +774,6 @@ NS_INTERFACE_MAP_END_INHERITING(ReadIntoRequest)
// https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamtee
// Step 16.
MOZ_CAN_RUN_SCRIPT
void PullWithBYOBReader(JSContext* aCx, TeeState* aTeeState,
JS::HandleObject aView, bool aForBranch2,
ErrorResult& aRv) {
@ -978,7 +980,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ReadableByteStreamTeeCancelAlgorithm)
NS_INTERFACE_MAP_END_INHERITING(UnderlyingSourceCancelCallbackHelper)
// https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamtee
MOZ_CAN_RUN_SCRIPT
void ReadableByteStreamTee(JSContext* aCx, ReadableStream* aStream,
nsTArray<RefPtr<ReadableStream>>& aResult,
ErrorResult& aRv) {

Просмотреть файл

@ -70,9 +70,9 @@ struct ReadableStreamDefaultTeeReadRequest final : public ReadRequest {
virtual ~ReadableStreamDefaultTeeReadRequest() = default;
};
void ReadableByteStreamTee(JSContext* aCx, ReadableStream* aStream,
nsTArray<RefPtr<ReadableStream>>& aResult,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void ReadableByteStreamTee(
JSContext* aCx, ReadableStream* aStream,
nsTArray<RefPtr<ReadableStream>>& aResult, ErrorResult& aRv);
} // namespace mozilla::dom
#endif

Просмотреть файл

@ -618,7 +618,6 @@ already_AddRefed<Promise> WritableStreamAbort(JSContext* aCx,
}
// https://streams.spec.whatwg.org/#ws-abort
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> WritableStream::Abort(JSContext* aCx,
JS::Handle<JS::Value> aReason,
ErrorResult& aRv) {
@ -697,7 +696,6 @@ already_AddRefed<Promise> WritableStreamClose(JSContext* aCx,
}
// https://streams.spec.whatwg.org/#ws-close
MOZ_CAN_RUN_SCRIPT
already_AddRefed<Promise> WritableStream::Close(JSContext* aCx,
ErrorResult& aRv) {
// Step 1. If ! IsWritableStreamLocked(this) is true, return a promise

Просмотреть файл

@ -141,17 +141,19 @@ class WritableStream final : public nsISupports, public nsWrapperCache {
JS::Handle<JSObject*> aGivenProto) override;
// IDL Methods
static already_AddRefed<WritableStream> Constructor(
const GlobalObject& aGlobal,
const Optional<JS::Handle<JSObject*>>& aUnderlyingSink,
const QueuingStrategy& aStrategy, ErrorResult& aRv);
// TODO: Use MOZ_CAN_RUN_SCRIPT when IDL constructors can use it (bug 1749042)
MOZ_CAN_RUN_SCRIPT_BOUNDARY static already_AddRefed<WritableStream>
Constructor(const GlobalObject& aGlobal,
const Optional<JS::Handle<JSObject*>>& aUnderlyingSink,
const QueuingStrategy& aStrategy, ErrorResult& aRv);
bool Locked() const { return !!mWriter; }
already_AddRefed<Promise> Abort(JSContext* cx, JS::Handle<JS::Value> aReason,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Abort(
JSContext* cx, JS::Handle<JS::Value> aReason, ErrorResult& aRv);
already_AddRefed<Promise> Close(JSContext* aCx, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Close(JSContext* aCx,
ErrorResult& aRv);
already_AddRefed<WritableStreamDefaultWriter> GetWriter(ErrorResult& aRv);

Просмотреть файл

@ -187,7 +187,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WritableStartPromiseNativeHandler)
NS_INTERFACE_MAP_END
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller
MOZ_CAN_RUN_SCRIPT
void SetUpWritableStreamDefaultController(
JSContext* aCx, WritableStream* aStream,
WritableStreamDefaultController* aController,
@ -272,7 +271,6 @@ void SetUpWritableStreamDefaultController(
}
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller-from-underlying-sink
MOZ_CAN_RUN_SCRIPT
void SetUpWritableStreamDefaultControllerFromUnderlyingSink(
JSContext* aCx, WritableStream* aStream, JS::HandleObject aUnderlyingSink,
UnderlyingSink& aUnderlyingSinkDict, double aHighWaterMark,

Просмотреть файл

@ -155,7 +155,7 @@ class WritableStreamDefaultController final : public nsISupports,
RefPtr<WritableStream> mStream;
};
extern void SetUpWritableStreamDefaultController(
MOZ_CAN_RUN_SCRIPT extern void SetUpWritableStreamDefaultController(
JSContext* aCx, WritableStream* aStream,
WritableStreamDefaultController* aController,
UnderlyingSinkStartCallbackHelper* aStartAlgorithm,
@ -164,7 +164,8 @@ extern void SetUpWritableStreamDefaultController(
UnderlyingSinkAbortCallbackHelper* aAbortAlgorithm, double aHighWaterMark,
QueuingStrategySize* aSizeAlgorithm, ErrorResult& aRv);
extern void SetUpWritableStreamDefaultControllerFromUnderlyingSink(
MOZ_CAN_RUN_SCRIPT extern void
SetUpWritableStreamDefaultControllerFromUnderlyingSink(
JSContext* aCx, WritableStream* aStream, JS::HandleObject aUnderlyingSink,
UnderlyingSink& aUnderlyingSinkDict, double aHighWaterMark,
QueuingStrategySize* aSizeAlgorithm, ErrorResult& aRv);