[Streams API] Rework some readable stream internals that can be common to writable streams
https://bugs.webkit.org/show_bug.cgi?id=150133
Reviewed by Darin Adler.
Source/JavaScriptCore:
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): Added RangeError also as native functions.
Source/WebCore:
There are some things in ReadableStream internals that be be used also for Writable Streams so it was necessary
to move some functions and refactor some code that can be shared by both implementations.
Queue was written with the functions declared at the implementation and keeping the improvement of having the
total size calculated instead of having to transverse the whole array.
The strategy is kept as an object and a common method is used to validate it as per spec.
Promises are reworked to keep in an internal slot inside the promise object the resolve and reject
functions. For convinience three functions were written, one to create the promise (and keep internally the
resolve and reject functions), one to resolve and another to reject. Promises can still be created with
Promise.resolve or reject as the resolve and rejectStreamsPromise functions operate under the assumption that
the internal slots might not exist.
invokeOrNoop and promiseInvokeOrNoop were moved to the common code as they will be also used by WritableStream.
Current test set suffices.
* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/WebCoreJSBuiltinInternals.h:
* bindings/js/WebCoreJSBuiltins.cpp:
* bindings/js/WebCoreJSBuiltins.h: Build infrastructure.
* Modules/streams/ReadableStream.js:
(initializeReadableStream): Reworked queue and strategy.
* Modules/streams/ReadableStreamInternals.js:
(privateInitializeReadableStreamReader):
(errorReadableStream):
(getReadableStreamDesiredSize):
(cancelReadableStream):
(closeReadableStream):
(closeReadableStreamReader):
(enqueueInReadableStream):
(readFromReadableStreamReader): Reworked queue, strategy and promises.
(invokeOrNoop): Deleted.
(promiseInvokeOrNoop): Deleted.
* Modules/streams/StreamInternals.js: Added.
(invokeOrNoop):
(promiseInvokeOrNoop): Moved from ReadableStreamInternals.js.
(validateAndNormalizeQueuingStrategy):
(createNewStreamsPromise):
(resolveStreamsPromise):
(rejectStreamsPromise):
(newQueue):
(dequeueValue):
(enqueueValueWithSize): Added according to the spec.
* bindings/js/WebCoreBuiltinNames.h: Updated private names according to the new slots.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@191335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index f4a37ca..07ec3c8 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -3369,6 +3369,7 @@
${WEBCORE_DIR}/Modules/streams/ReadableStreamController.js
${WEBCORE_DIR}/Modules/streams/ReadableStreamInternals.js
${WEBCORE_DIR}/Modules/streams/ReadableStreamReader.js
+ ${WEBCORE_DIR}/Modules/streams/StreamInternals.js
${WEBCORE_DIR}/Modules/streams/WritableStream.js
)
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 9309980..a782717 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,60 @@
+2015-10-20 Xabier Rodriguez Calvar <calvaris@igalia.com>
+
+ [Streams API] Rework some readable stream internals that can be common to writable streams
+ https://bugs.webkit.org/show_bug.cgi?id=150133
+
+ Reviewed by Darin Adler.
+
+ There are some things in ReadableStream internals that be be used also for Writable Streams so it was necessary
+ to move some functions and refactor some code that can be shared by both implementations.
+
+ Queue was written with the functions declared at the implementation and keeping the improvement of having the
+ total size calculated instead of having to transverse the whole array.
+
+ The strategy is kept as an object and a common method is used to validate it as per spec.
+
+ Promises are reworked to keep in an internal slot inside the promise object the resolve and reject
+ functions. For convinience three functions were written, one to create the promise (and keep internally the
+ resolve and reject functions), one to resolve and another to reject. Promises can still be created with
+ Promise.resolve or reject as the resolve and rejectStreamsPromise functions operate under the assumption that
+ the internal slots might not exist.
+
+ invokeOrNoop and promiseInvokeOrNoop were moved to the common code as they will be also used by WritableStream.
+
+ Current test set suffices.
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSDOMWindowBase.cpp:
+ * bindings/js/WebCoreJSBuiltinInternals.h:
+ * bindings/js/WebCoreJSBuiltins.cpp:
+ * bindings/js/WebCoreJSBuiltins.h: Build infrastructure.
+ * Modules/streams/ReadableStream.js:
+ (initializeReadableStream): Reworked queue and strategy.
+ * Modules/streams/ReadableStreamInternals.js:
+ (privateInitializeReadableStreamReader):
+ (errorReadableStream):
+ (getReadableStreamDesiredSize):
+ (cancelReadableStream):
+ (closeReadableStream):
+ (closeReadableStreamReader):
+ (enqueueInReadableStream):
+ (readFromReadableStreamReader): Reworked queue, strategy and promises.
+ (invokeOrNoop): Deleted.
+ (promiseInvokeOrNoop): Deleted.
+ * Modules/streams/StreamInternals.js: Added.
+ (invokeOrNoop):
+ (promiseInvokeOrNoop): Moved from ReadableStreamInternals.js.
+ (validateAndNormalizeQueuingStrategy):
+ (createNewStreamsPromise):
+ (resolveStreamsPromise):
+ (rejectStreamsPromise):
+ (newQueue):
+ (dequeueValue):
+ (enqueueValueWithSize): Added according to the spec.
+ * bindings/js/WebCoreBuiltinNames.h: Updated private names according to the new slots.
+
2015-10-20 Yoav Weiss <yoav@yoav.ws>
Rename the PICTURE_SIZES flag to CURRENTSRC
diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make
index fda593c..c37167e 100644
--- a/Source/WebCore/DerivedSources.make
+++ b/Source/WebCore/DerivedSources.make
@@ -1264,6 +1264,7 @@
$(WebCore)/Modules/streams/ReadableStreamController.js \
$(WebCore)/Modules/streams/ReadableStreamInternals.js \
$(WebCore)/Modules/streams/ReadableStreamReader.js \
+ $(WebCore)/Modules/streams/StreamInternals.js \
$(WebCore)/Modules/streams/WritableStream.js \
#
diff --git a/Source/WebCore/Modules/streams/ReadableStream.js b/Source/WebCore/Modules/streams/ReadableStream.js
index 1a52cf8..5f56f1e 100644
--- a/Source/WebCore/Modules/streams/ReadableStream.js
+++ b/Source/WebCore/Modules/streams/ReadableStream.js
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -42,8 +43,7 @@
this.@underlyingSource = underlyingSource;
- this.@queue = [];
- this.@queueSize = 0;
+ this.@queue = @newQueue();
this.@state = @readableStreamReadable;
this.@started = false;
this.@closeRequested = false;
@@ -52,13 +52,7 @@
this.@reader = undefined;
this.@storedError = undefined;
this.@controller = new @ReadableStreamController(this);
- this.@strategySize = strategy.size;
- this.@highWaterMark = Number(strategy.highWaterMark);
-
- if (Number.isNaN(this.@highWaterMark))
- throw new TypeError("highWaterMark parameter is not correct");
- if (this.@highWaterMark < 0)
- throw new RangeError("highWaterMark is negative");
+ this.@strategy = @validateAndNormalizeQueuingStrategy(strategy.size, strategy.highWaterMark);
var result = @invokeOrNoop(underlyingSource, "start", [this.@controller]);
var _this = this;
diff --git a/Source/WebCore/Modules/streams/ReadableStreamInternals.js b/Source/WebCore/Modules/streams/ReadableStreamInternals.js
index a77027a..8ad13a7 100644
--- a/Source/WebCore/Modules/streams/ReadableStreamInternals.js
+++ b/Source/WebCore/Modules/streams/ReadableStreamInternals.js
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Canon Inc. All rights reserved.
+ * Copyright (C) 2015 Igalia.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,10 +42,7 @@
this.@ownerReadableStream = stream;
this.@storedError = undefined;
stream.@reader = this;
- this.@closedPromise = new Promise(function(resolve, reject) {
- stream.@reader.@closedPromiseResolve = resolve;
- stream.@reader.@closedPromiseReject = reject;
- });
+ this.@closedPromise = @createNewStreamsPromise();
return this;
}
if (stream.@state === @readableStreamClosed) {
@@ -199,7 +197,7 @@
"use strict";
// TODO: ASSERT(stream.@state === @readableStreamReadable);
- stream.@queue = [];
+ stream.@queue = @newQueue();
stream.@storedError = error;
stream.@state = @readableStreamErrored;
@@ -209,14 +207,14 @@
var requests = reader.@readRequests;
for (var index = 0, length = requests.length; index < length; ++index)
- requests[index].reject(error);
+ @rejectStreamsPromise(requests[index], error);
reader.@readRequests = [];
@releaseReadableStreamReader(reader);
reader.@storedError = error;
reader.@state = @readableStreamErrored;
- reader.@closedPromiseReject(error);
+ @rejectStreamsPromise(reader.@closedPromise, error);
}
function requestReadableStreamPull(stream)
@@ -262,7 +260,7 @@
{
"use strict";
- return stream.@highWaterMark - stream.@queueSize;
+ return stream.@strategy.highWaterMark - stream.@queue.size;
}
function releaseReadableStreamReader(reader)
@@ -281,7 +279,7 @@
return Promise.resolve();
if (stream.@state === @readableStreamErrored)
return Promise.reject(stream.@storedError);
- stream.@queue = [];
+ stream.@queue = @newQueue();
@finishClosingReadableStream(stream);
return @promiseInvokeOrNoop(stream.@underlyingSource, "cancel", [reason]).then(function() { });
}
@@ -306,7 +304,7 @@
if (stream.@state === @readableStreamClosed)
return;
stream.@closeRequested = true;
- if (!stream.@queue.length)
+ if (!stream.@queue.content.length)
@finishClosingReadableStream(stream);
}
@@ -316,11 +314,11 @@
var requests = reader.@readRequests;
for (var index = 0, length = requests.length; index < length; ++index)
- requests[index].resolve({value:undefined, done: true});
+ @resolveStreamsPromise(requests[index], {value:undefined, done: true});
reader.@readRequests = [];
@releaseReadableStreamReader(reader);
reader.@state = @readableStreamClosed;
- reader.@closedPromiseResolve();
+ @resolveStreamsPromise(reader.@closedPromise);
}
function enqueueInReadableStream(stream, chunk)
@@ -332,19 +330,18 @@
if (stream.@state === @readableStreamClosed)
return undefined;
if (@isReadableStreamLocked(stream) && stream.@reader.@readRequests.length) {
- stream.@reader.@readRequests.shift().resolve({value: chunk, done: false});
+ @resolveStreamsPromise(stream.@reader.@readRequests.shift(), {value: chunk, done: false});
@requestReadableStreamPull(stream);
return;
}
try {
var size = 1;
- if (stream.@strategySize) {
- size = Number(stream.@strategySize(chunk));
+ if (stream.@strategy.size) {
+ size = Number(stream.@strategy.size(chunk));
if (Number.isNaN(size) || size === +Infinity || size < 0)
throw new RangeError("Chunk size is not valid");
}
- stream.@queue.push({ value: chunk, size: size });
- stream.@queueSize += size;
+ @enqueueValueWithSize(stream.@queue, chunk, size);
}
catch(error) {
@errorReadableStream(stream, error);
@@ -364,47 +361,16 @@
// TODO: ASSERT(!!reader.@ownerReadableStream);
// TODO: ASSERT(reader.@ownerReadableStream.@state === @readableStreamReadable);
var stream = reader.@ownerReadableStream;
- if (stream.@queue.length) {
- var chunk = stream.@queue.shift();
- stream.@queueSize -= chunk.size;
+ if (stream.@queue.content.length) {
+ var chunk = @dequeueValue(stream.@queue);
if (!stream.@closeRequested)
@requestReadableStreamPull(stream);
- else if (!stream.@queue.length)
+ else if (!stream.@queue.content.length)
@finishClosingReadableStream(stream);
- return Promise.resolve({value: chunk.value, done: false});
+ return Promise.resolve({value: chunk, done: false});
}
- var readRequest = {};
- var readPromise = new Promise(function(resolve, reject) {
- readRequest.resolve = resolve;
- readRequest.reject = reject;
- });
- reader.@readRequests.push(readRequest);
+ var readPromise = @createNewStreamsPromise();
+ reader.@readRequests.push(readPromise);
@requestReadableStreamPull(stream);
return readPromise;
}
-
-function invokeOrNoop(object, key, args)
-{
- "use strict";
-
- var method = object[key];
- if (typeof method === "undefined")
- return;
- return method.@apply(object, args);
-}
-
-function promiseInvokeOrNoop(object, key, args)
-{
- "use strict";
-
- try {
- var method = object[key];
- if (typeof method === "undefined")
- return Promise.resolve();
- var result = method.@apply(object, args);
- return Promise.resolve(result);
- }
- catch(error) {
- return Promise.reject(error);
- }
-}
diff --git a/Source/WebCore/Modules/streams/StreamInternals.js b/Source/WebCore/Modules/streams/StreamInternals.js
new file mode 100644
index 0000000..7b3dfd5
--- /dev/null
+++ b/Source/WebCore/Modules/streams/StreamInternals.js
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// @optional=STREAMS_API
+// @internals
+
+function invokeOrNoop(object, key, args)
+{
+ "use strict";
+
+ var method = object[key];
+ if (typeof method === "undefined")
+ return;
+ return method.@apply(object, args);
+}
+
+function promiseInvokeOrNoop(object, key, args)
+{
+ "use strict";
+
+ try {
+ var method = object[key];
+ if (typeof method === "undefined")
+ return Promise.resolve();
+ var result = method.@apply(object, args);
+ return Promise.resolve(result);
+ }
+ catch(error) {
+ return Promise.reject(error);
+ }
+
+}
+
+function validateAndNormalizeQueuingStrategy(size, highWaterMark)
+{
+ "use strict";
+
+ if (size !== undefined && typeof size !== "function")
+ throw new @TypeError("size parameter must be a function");
+
+ var normalizedStrategy = { };
+
+ normalizedStrategy.size = size;
+ normalizedStrategy.highWaterMark = Number(highWaterMark);
+
+ if (Number.isNaN(normalizedStrategy.highWaterMark))
+ throw new @TypeError("highWaterMark parameter is not a number");
+ if (normalizedStrategy.highWaterMark < 0)
+ throw new @RangeError("highWaterMark is negative");
+
+ return normalizedStrategy;
+}
+
+function createNewStreamsPromise()
+{
+ "use strict";
+
+ var resolveFunction;
+ var rejectFunction;
+ var promise = new Promise(function(resolve, reject) {
+ resolveFunction = resolve;
+ rejectFunction = reject;
+ });
+ promise.@resolve = resolveFunction;
+ promise.@reject = rejectFunction;
+ return promise;
+}
+
+function resolveStreamsPromise(promise, value)
+{
+ "use strict";
+
+ if (promise && promise.@resolve) {
+ promise.@resolve(value);
+ promise.@resolve = undefined;
+ promise.@reject = undefined;
+ }
+}
+
+function rejectStreamsPromise(promise, value)
+{
+ "use strict";
+
+ if (promise && promise.@reject) {
+ promise.@reject(value);
+ promise.@resolve = undefined;
+ promise.@reject = undefined;
+ }
+}
+
+function newQueue()
+{
+ return { content: [], size: 0 };
+}
+
+function dequeueValue(queue)
+{
+ "use strict";
+
+ var record = queue.content.shift();
+ queue.size -= record.size;
+ return record.value;
+}
+
+function enqueueValueWithSize(queue, value, size)
+{
+ size = Number(size);
+ if (Number.isNaN(size) || !Number.isFinite(size) || size < 0)
+ throw new @RangeError("size has an incorrect value");
+ queue.content.push({ value: value, size: size });
+ queue.size += size;
+
+ return undefined;
+}
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index c3457a9..c7ab5c0 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1515,6 +1515,8 @@
4162A4571011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4162A4551011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp */; };
4162A4581011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 4162A4561011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h */; };
416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */; };
+ 416E6FE81BBD12DF000A6033 /* StreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 416E6FEA1BBD1684000A6034 /* StreamInternalsBuiltinsWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8071BB3110D00B764CA /* StreamInternalsBuiltinsWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
416E6FE81BBD12DF000A6043 /* ReadableStreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764D9 /* ReadableStreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
416E6FE91BBD12E5000A6043 /* ReadableStreamBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764D8 /* ReadableStreamBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
416E6FEA1BBD1684000A6044 /* ReadableStreamInternalsBuiltinsWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8071BB3110D00B764DA /* ReadableStreamInternalsBuiltinsWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11360,6 +11362,8 @@
9908B0EC1BCACF1F00ED0F65 /* generate-js-builtins */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "generate-js-builtins"; sourceTree = "<group>"; };
9908B0ED1BCACF9100ED0F65 /* ByteLengthQueuingStrategy.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ByteLengthQueuingStrategy.js; sourceTree = "<group>"; };
9908B0EE1BCACF9100ED0F65 /* CountQueuingStrategy.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = CountQueuingStrategy.js; sourceTree = "<group>"; };
+ 9908B0F11BCACF9100ED0F55 /* StreamInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = StreamInternals.js; sourceTree = "<group>"; };
+ 9908B0FD1BCAD07D00ED0F55 /* StreamInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamInternalsBuiltins.cpp; sourceTree = "<group>"; };
9908B0EF1BCACF9100ED0F65 /* ReadableStream.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ReadableStream.js; sourceTree = "<group>"; };
9908B0F01BCACF9100ED0F65 /* ReadableStreamController.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ReadableStreamController.js; sourceTree = "<group>"; };
9908B0F11BCACF9100ED0F65 /* ReadableStreamInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ReadableStreamInternals.js; sourceTree = "<group>"; };
@@ -11416,6 +11420,8 @@
9A528E8217D7F52F00AA9518 /* FloatingObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingObjects.h; sourceTree = "<group>"; };
9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSToLengthConversionData.h; sourceTree = "<group>"; };
9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSToLengthConversionData.cpp; sourceTree = "<group>"; };
+ 9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamInternalsBuiltins.h; sourceTree = "<group>"; };
+ 9B03D8071BB3110D00B764CA /* StreamInternalsBuiltinsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamInternalsBuiltinsWrapper.h; sourceTree = "<group>"; };
9B03D8061BB3110D00B764D8 /* ReadableStreamBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamBuiltins.h; sourceTree = "<group>"; };
9B03D8061BB3110D00B764D9 /* ReadableStreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamInternalsBuiltins.h; sourceTree = "<group>"; };
9B03D8071BB3110D00B764D8 /* ReadableStreamBuiltinsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamBuiltinsWrapper.h; sourceTree = "<group>"; };
@@ -16392,6 +16398,7 @@
4129DF821BB5B7A600322A16 /* ReadableStreamReader.h */,
419FAFAD1ABABCD5005B828B /* ReadableStreamReader.idl */,
9908B0F21BCACF9100ED0F65 /* ReadableStreamReader.js */,
+ 9908B0F11BCACF9100ED0F55 /* StreamInternals.js */,
41A023ED1A39DB7900F722DF /* WritableStream.idl */,
9908B0EF1BCACF9100ED0F75 /* WritableStream.js */,
@@ -17231,6 +17238,9 @@
26AA0F9D18D2A18B00419381 /* SelectorPseudoElementTypeMap.cpp */,
26AA0F9F18D2A1C100419381 /* SelectorPseudoElementTypeMap.gperf */,
53EF766A16530A61004CBE49 /* SettingsMacros.h */,
+ 9908B0FD1BCAD07D00ED0F55 /* StreamInternalsBuiltins.cpp */,
+ 9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */,
+ 9B03D8071BB3110D00B764CA /* StreamInternalsBuiltinsWrapper.h */,
8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */,
83C05A581A686212007E5DEA /* StylePropertyShorthandFunctions.cpp */,
83C05A591A686212007E5DEA /* StylePropertyShorthandFunctions.h */,
@@ -27300,6 +27310,8 @@
51E0BB380DA5ACB600A9E417 /* StorageMap.h in Headers */,
C50D0E830FF4272900AC2644 /* StorageNamespace.h in Headers */,
1A37636C1A2E68BB009A7EE2 /* StorageNamespaceProvider.h in Headers */,
+ 416E6FE81BBD12DF000A6033 /* StreamInternalsBuiltins.h in Headers */,
+ 416E6FEA1BBD1684000A6034 /* StreamInternalsBuiltinsWrapper.h in Headers */,
81AC6C36131C57D30009A7E0 /* StringCallback.h in Headers */,
B23540F30D00782E002382FA /* StringTruncator.h in Headers */,
9B6C41531344949000085B62 /* StringWithDirection.h in Headers */,
diff --git a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
index 2af9799..fa2a309 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
@@ -50,6 +50,7 @@
#if ENABLE(STREAMS_API)
#include "JSReadableStreamPrivateConstructors.h"
#include "ReadableStreamInternalsBuiltins.h"
+#include "StreamInternalsBuiltins.h"
#endif
using namespace JSC;
@@ -96,6 +97,12 @@
m_privateFunctions.readableStreamInternals().m_##name##Function.get() , DontDelete | ReadOnly),
WEBCOREREADABLESTREAMINTERNALS_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
#undef DECLARE_GLOBAL_STATIC
+#define DECLARE_GLOBAL_STATIC(name)\
+ GlobalPropertyInfo(\
+ static_cast<JSVMClientData*>(vm.clientData)->builtinFunctions().streamInternalsBuiltins().name##PrivateName(), \
+ m_privateFunctions.streamInternals().m_##name##Function.get() , DontDelete | ReadOnly),
+ WEBCORESTREAMINTERNALS_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
+#undef DECLARE_GLOBAL_STATIC
#endif
};
diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
index be726c1..0fef220 100644
--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
@@ -34,17 +34,13 @@
#define WEBCORE_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro)\
macro(closeRequested) \
macro(closedPromise) \
- macro(closedPromiseResolve) \
- macro(closedPromiseReject) \
macro(controlledReadableStream) \
macro(controller) \
macro(getUserMediaFromJS) \
- macro(highWaterMark) \
macro(ownerReadableStream) \
macro(pulling) \
macro(pullAgain) \
macro(queue) \
- macro(queueSize) \
macro(readableStreamClosed) \
macro(readableStreamErrored) \
macro(readableStreamReadable) \
@@ -53,7 +49,7 @@
macro(state) \
macro(started) \
macro(storedError) \
- macro(strategySize) \
+ macro(strategy) \
macro(underlyingSource) \
macro(ReadableStreamReader) \
macro(ReadableStreamController) \
diff --git a/Source/WebCore/bindings/js/WebCoreJSBuiltinInternals.h b/Source/WebCore/bindings/js/WebCoreJSBuiltinInternals.h
index 96344f9..e29f1ef 100644
--- a/Source/WebCore/bindings/js/WebCoreJSBuiltinInternals.h
+++ b/Source/WebCore/bindings/js/WebCoreJSBuiltinInternals.h
@@ -29,6 +29,7 @@
#if ENABLE(STREAMS_API)
#include "ReadableStreamInternalsBuiltinsWrapper.h"
+#include "StreamInternalsBuiltinsWrapper.h"
#endif
namespace WebCore {
@@ -39,15 +40,18 @@
: vm(v)
#if ENABLE(STREAMS_API)
, m_readableStreamInternalsFunctions(vm)
+ , m_streamInternalsFunctions(vm)
#endif
{ }
#if ENABLE(STREAMS_API)
ReadableStreamInternalsBuiltinFunctions readableStreamInternals() { return m_readableStreamInternalsFunctions; }
+ StreamInternalsBuiltinFunctions streamInternals() { return m_streamInternalsFunctions; }
#endif
void visit(JSC::SlotVisitor& visitor) {
#if ENABLE(STREAMS_API)
m_readableStreamInternalsFunctions.visit(visitor);
+ m_streamInternalsFunctions.visit(visitor);
#else
UNUSED_PARAM(visitor);
#endif
@@ -55,6 +59,7 @@
void init(JSC::JSGlobalObject& globalObject) {
#if ENABLE(STREAMS_API)
m_readableStreamInternalsFunctions.init(globalObject);
+ m_streamInternalsFunctions.init(globalObject);
#else
UNUSED_PARAM(globalObject);
#endif
@@ -63,7 +68,8 @@
private:
JSC::VM& vm;
#if ENABLE(STREAMS_API)
- ReadableStreamInternalsBuiltinFunctions m_readableStreamInternalsFunctions;
+ ReadableStreamInternalsBuiltinFunctions m_readableStreamInternalsFunctions;
+ StreamInternalsBuiltinFunctions m_streamInternalsFunctions;
#endif
};
diff --git a/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp b/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp
index 41fe6e4..3460db3 100644
--- a/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp
+++ b/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp
@@ -37,5 +37,6 @@
#include "ReadableStreamControllerBuiltins.cpp"
#include "ReadableStreamInternalsBuiltins.cpp"
#include "ReadableStreamReaderBuiltins.cpp"
+#include "StreamInternalsBuiltins.cpp"
#include "WritableStreamBuiltins.cpp"
#endif
diff --git a/Source/WebCore/bindings/js/WebCoreJSBuiltins.h b/Source/WebCore/bindings/js/WebCoreJSBuiltins.h
index 4d141ff..b4055c9 100644
--- a/Source/WebCore/bindings/js/WebCoreJSBuiltins.h
+++ b/Source/WebCore/bindings/js/WebCoreJSBuiltins.h
@@ -38,6 +38,7 @@
#include "ReadableStreamControllerBuiltinsWrapper.h"
#include "ReadableStreamInternalsBuiltinsWrapper.h"
#include "ReadableStreamReaderBuiltinsWrapper.h"
+#include "StreamInternalsBuiltinsWrapper.h"
#include "WritableStreamBuiltinsWrapper.h"
#endif
@@ -56,6 +57,7 @@
, m_readableStreamControllerBuiltins(&vm)
, m_readableStreamInternalsBuiltins(&vm)
, m_readableStreamReaderBuiltins(&vm)
+ , m_streamInternalsBuiltins(&vm)
, m_writableStreamBuiltins(&vm)
#endif
#if ENABLE(MEDIA_STREAM)
@@ -64,6 +66,7 @@
{
#if ENABLE(STREAMS_API)
m_readableStreamInternalsBuiltins.exportNames();
+ m_streamInternalsBuiltins.exportNames();
#endif
}
#if ENABLE(STREAMS_API)
@@ -73,6 +76,7 @@
ReadableStreamControllerBuiltinsWrapper& readableStreamControllerBuiltins() { return m_readableStreamControllerBuiltins; }
ReadableStreamInternalsBuiltinsWrapper& readableStreamInternalsBuiltins() { return m_readableStreamInternalsBuiltins; }
ReadableStreamReaderBuiltinsWrapper& readableStreamReaderBuiltins() { return m_readableStreamReaderBuiltins; }
+ StreamInternalsBuiltinsWrapper& streamInternalsBuiltins() { return m_streamInternalsBuiltins; }
WritableStreamBuiltinsWrapper& writableStreamBuiltins() { return m_writableStreamBuiltins; }
#endif
#if ENABLE(MEDIA_STREAM)
@@ -88,6 +92,7 @@
ReadableStreamControllerBuiltinsWrapper m_readableStreamControllerBuiltins;
ReadableStreamInternalsBuiltinsWrapper m_readableStreamInternalsBuiltins;
ReadableStreamReaderBuiltinsWrapper m_readableStreamReaderBuiltins;
+ StreamInternalsBuiltinsWrapper m_streamInternalsBuiltins;
WritableStreamBuiltinsWrapper m_writableStreamBuiltins;
#endif
#if ENABLE(MEDIA_STREAM)