[Streams API] Rework some readable stream internals that can be common to writable...
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Oct 2015 09:51:09 +0000 (09:51 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Oct 2015 09:51:09 +0000 (09:51 +0000)
commit51cad001c1ffb865ac2d09217a903a1bf0d7ab7c
tree417da29cf5a7f595cc4fd683e123409d3b66dfe0
parentb7d691c6c5951affdef05a5a431bbba1b9fc8e0c
[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: https://svn.webkit.org/repository/webkit/trunk@191335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/streams/ReadableStream.js
Source/WebCore/Modules/streams/ReadableStreamInternals.js
Source/WebCore/Modules/streams/StreamInternals.js [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/bindings/js/WebCoreJSBuiltinInternals.h
Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp
Source/WebCore/bindings/js/WebCoreJSBuiltins.h