Skip to content

Commit

Permalink
Bug 1864406 - Add ReadableStreamBYOBReader.prototype.read(view, { min…
Browse files Browse the repository at this point in the history
… }). r=saschanaz,webidl,smaug

Implements whatwg/streams#1145

Differential Revision: https://phabricator.services.mozilla.com/D226225

UltraBlame original commit: 56a71d42ee3220891aa1cb2dfae5df8f544865f9
  • Loading branch information
marco-c committed Nov 1, 2024
1 parent 8ceece1 commit a16667f
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 1,886 deletions.
171 changes: 127 additions & 44 deletions dom/streams/ReadableByteStreamController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ aByteLength
uint64_t
aBytesFilled
uint64_t
aMinimumFill
uint64_t
aElementSize
Constructor
aViewConstructor
Expand Down Expand Up @@ -682,6 +684,10 @@ mBytesFilled
(
aBytesFilled
)
mMinimumFill
(
aMinimumFill
)
mElementSize
(
aElementSize
Expand Down Expand Up @@ -827,6 +833,16 @@ aBytesFilled
;
}
uint64_t
MinimumFill
(
)
const
{
return
mMinimumFill
;
}
uint64_t
ElementSize
(
)
Expand Down Expand Up @@ -915,6 +931,11 @@ mBytesFilled
0
;
uint64_t
mMinimumFill
=
0
;
uint64_t
mElementSize
=
0
Expand Down Expand Up @@ -1776,13 +1797,23 @@ getFirst
;
if
(
(
firstPendingPullInto
-
>
BytesFilled
(
)
%
firstPendingPullInto
-
>
ElementSize
(
)
)
!
=
0
)
{
Expand Down Expand Up @@ -2927,12 +2958,21 @@ Closed
{
MOZ_ASSERT
(
(
pullIntoDescriptor
-
>
BytesFilled
(
)
%
pullIntoDescriptor
-
>
ElementSize
(
)
)
=
=
0
Expand Down Expand Up @@ -4778,6 +4818,7 @@ autoAllocateChunkSize
autoAllocateChunkSize
0
1
1
PullIntoDescriptor
:
:
Expand Down Expand Up @@ -5243,12 +5284,21 @@ aRv
{
MOZ_ASSERT
(
(
aFirstDescriptor
-
>
BytesFilled
(
)
%
aFirstDescriptor
-
>
ElementSize
(
)
)
=
=
0
Expand Down Expand Up @@ -5515,7 +5565,7 @@ BytesFilled
aPullIntoDescriptor
-
>
ElementSize
MinimumFill
(
)
)
Expand Down Expand Up @@ -6534,37 +6584,6 @@ aRv
)
{
size_t
elementSize
=
aPullIntoDescriptor
-
>
ElementSize
(
)
;
size_t
currentAlignedBytes
=
aPullIntoDescriptor
-
>
BytesFilled
(
)
-
(
aPullIntoDescriptor
-
>
BytesFilled
(
)
%
elementSize
)
;
size_t
maxBytesToCopy
=
std
Expand Down Expand Up @@ -6620,31 +6639,62 @@ BytesFilled
maxBytesToCopy
;
size_t
maxAlignedBytes
totalBytesToCopyRemaining
=
maxBytesFilled
maxBytesToCopy
;
bool
ready
=
false
;
MOZ_ASSERT
(
aPullIntoDescriptor
-
>
BytesFilled
(
maxBytesFilled
%
elementSize
)
<
aPullIntoDescriptor
-
>
MinimumFill
(
)
)
;
size_t
totalBytesToCopyRemaining
remainderBytes
=
maxBytesToCopy
maxBytesFilled
%
aPullIntoDescriptor
-
>
ElementSize
(
)
;
bool
ready
size_t
maxAlignedBytes
=
false
maxBytesFilled
-
remainderBytes
;
if
(
maxAlignedBytes
>
currentAlignedBytes
=
aPullIntoDescriptor
-
>
MinimumFill
(
)
)
{
totalBytesToCopyRemaining
Expand Down Expand Up @@ -6930,7 +6980,7 @@ BytesFilled
aPullIntoDescriptor
-
>
ElementSize
MinimumFill
(
)
)
Expand Down Expand Up @@ -6958,6 +7008,8 @@ JSObject
*
>
aView
uint64_t
aMin
ReadIntoRequest
*
aReadIntoRequest
Expand Down Expand Up @@ -7048,6 +7100,36 @@ type
)
;
}
uint64_t
minimumFill
=
aMin
*
elementSize
;
MOZ_ASSERT
(
minimumFill
<
=
JS_GetArrayBufferViewByteLength
(
aView
)
)
;
MOZ_ASSERT
(
(
minimumFill
%
elementSize
)
=
=
0
)
;
size_t
byteOffset
=
Expand Down Expand Up @@ -7215,6 +7297,7 @@ buffer
byteOffset
byteLength
0
minimumFill
elementSize
ctor
ReaderType
Expand Down
2 changes: 2 additions & 0 deletions dom/streams/ReadableByteStreamController.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ JSObject
*
>
aView
uint64_t
aMin
ReadIntoRequest
*
aReadIntoRequest
Expand Down
Loading

0 comments on commit a16667f

Please sign in to comment.