LayoutTests/ChangeLog

 12015-07-28 Xabier Rodriguez Calvar <calvaris@igalia.com>
 2
 3 [Streams API] Create CountQueuingStrategy object as per spec
 4 https://bugs.webkit.org/show_bug.cgi?id=146594
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * streams/reference-implementation/brand-checks.html:
 9 * streams/reference-implementation/count-queuing-strategy.html: Removed reference to count-queuing-strategy.js.
 10 * streams/reference-implementation/resources/count-queuing-strategy.js: Removed.
 11 (CountQueuingStrategy): Deleted.
 12 (CountQueuingStrategy.prototype.size): Deleted.
 13
1142015-07-27 Yusuke Suzuki <utatane.tea@gmail.com>
215
316 SparseValueMap check is skipped when the butterfly's vectorLength is larger than the access-requested index

LayoutTests/streams/reference-implementation/brand-checks.html

22<script src='../../resources/testharness.js'></script>
33<script src='../../resources/testharnessreport.js'></script>
44<script src='resources/streams-utils.js'></script>
5 <script src='resources/count-queuing-strategy.js'></script>
65<script src='resources/byte-length-queuing-strategy.js'></script>
76<script>
87var ReadableStreamReader;

LayoutTests/streams/reference-implementation/count-queuing-strategy.html

22<script src='../../resources/testharness.js'></script>
33<script src='../../resources/testharnessreport.js'></script>
44<script src='resources/streams-utils.js'></script>
5 <script src='resources/count-queuing-strategy.js'></script>
65<script>
76test(function() {
87 new CountQueuingStrategy({ highWaterMark: 4 });

LayoutTests/streams/reference-implementation/resources/count-queuing-strategy.js

1 // FIXME: Remove this file when implemented in WebCore.
2 
3 function CountQueuingStrategy({ highWaterMark }) {
4  createDataProperty(this, 'highWaterMark', highWaterMark);
5 }
6 
7 CountQueuingStrategy.prototype = {
8  size: function(chunk) {
9  return 1;
10  }
11 }

Source/WebCore/CMakeLists.txt

@@set(WebCore_NON_SVG_IDL_FILES
289289 Modules/speech/SpeechSynthesisUtterance.idl
290290 Modules/speech/SpeechSynthesisVoice.idl
291291
 292 Modules/streams/CountQueuingStrategy.idl
292293 Modules/streams/ReadableStream.idl
293294 Modules/streams/ReadableStreamController.idl
294295 Modules/streams/ReadableStreamReader.idl

@@set(WebCore_SOURCES
949950 Modules/speech/SpeechSynthesisUtterance.cpp
950951 Modules/speech/SpeechSynthesisVoice.cpp
951952
 953 Modules/streams/CountQueuingStrategy.cpp
952954 Modules/streams/ReadableStream.cpp
953955 Modules/streams/ReadableStreamReader.cpp
954956

@@set(WebCore_SOURCES
11891191 bindings/js/JSRequestAnimationFrameCallbackCustom.cpp
11901192 bindings/js/JSSQLResultSetRowListCustom.cpp
11911193 bindings/js/JSSQLTransactionCustom.cpp
 1194 bindings/js/JSStreamsCountQueuingStrategyCustom.cpp
11921195 bindings/js/JSSVGLengthCustom.cpp
11931196 bindings/js/JSSVGPathSegCustom.cpp
11941197 bindings/js/JSStorageCustom.cpp

Source/WebCore/ChangeLog

112015-07-28 Xabier Rodriguez Calvar <calvaris@igalia.com>
22
 3 [Streams API] Create CountQueuingStrategy object as per spec
 4 https://bugs.webkit.org/show_bug.cgi?id=146594
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 CountQueuingStrategy is a class part of the Streams API that can be found at
 9 https://streams.spec.whatwg.org/#cqs-class. We had it as js at the tests but the spec says we have to provide it
 10 natively. The class is implemented in this patch by creating its corresponding IDL with the size method using
 11 the [CustomObjectGenerateNoBindings] attribute, that does not create any bindings against the object allowing us
 12 full control to do what the spec requires (just returning 1 without any cast check). The constructor sets the
 13 highWaterMark property taking it from the argument.
 14
 15 Covered by current tests.
 16
 17 * CMakeLists.txt: Added files to compile.
 18 * Modules/streams/CountQueuingStrategy.cpp: Added.
 19 (WebCore::CountQueuingStrategy::CountQueuingStrategy):
 20 (WebCore::CountQueuingStrategy::~CountQueuingStrategy): Created empty (tracking refcounting)
 21 * Modules/streams/CountQueuingStrategy.h: Added.
 22 * Modules/streams/CountQueuingStrategy.idl: Added.
 23 * bindings/js/JSStreamsCountQueuingStrategyCustom.cpp: Added.
 24 (WebCore::jsCountQueuingStrategyPrototypeFunctionSize): Returns 1.
 25 (WebCore::constructJSCountQueuingStrategy): Constructs the strategy sets the highWaterMark and returns it.
 26 * bindings/js/ReadableJSStream.cpp:
 27 (WebCore::getPropertyFromObject): Deleted.
 28 * bindings/js/StreamsJSUtils.h: Added.
 29 (WebCore::getPropertyFromObject): Moved from ReadableJSStream.cpp.
 30 (WebCore::setPropertyToObject): Added to create a property into an object.
 31
 322015-07-28 Xabier Rodriguez Calvar <calvaris@igalia.com>
 33
334 Create [StaticToPrototype] extended IDL attribute
435 https://bugs.webkit.org/show_bug.cgi?id=146593
536

Source/WebCore/Modules/streams/CountQueuingStrategy.cpp

 1/*
 2 * Copyright (C) 2015 Canon Inc.
 3 * Copyright (C) 2015 Igalia S.L.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted, provided that the following conditions
 7 * are required to be met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer in the
 13 * documentation and/or other materials provided with the distribution.
 14 * 3. Neither the name of Canon Inc. nor the names of
 15 * its contributors may be used to endorse or promote products derived
 16 * from this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 21 * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30#include "config.h"
 31#include "CountQueuingStrategy.h"
 32
 33#if ENABLE(STREAMS_API)
 34
 35#include <wtf/RefCountedLeakCounter.h>
 36
 37namespace WebCore {
 38
 39DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, countQueuingStrategyCounter, ("CountQueuingStrategy"));
 40
 41CountQueuingStrategy::CountQueuingStrategy()
 42{
 43#ifndef NDEBUG
 44 countQueuingStrategyCounter.increment();
 45#endif
 46}
 47
 48CountQueuingStrategy::~CountQueuingStrategy()
 49{
 50#ifndef NDEBUG
 51 countQueuingStrategyCounter.decrement();
 52#endif
 53}
 54
 55}
 56
 57#endif

Source/WebCore/Modules/streams/CountQueuingStrategy.h

 1/*
 2 * Copyright (C) 2015 Canon Inc.
 3 * Copyright (C) 2015 Igalia S.L.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted, provided that the following conditions
 7 * are required to be met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer in the
 13 * documentation and/or other materials provided with the distribution.
 14 * 3. Neither the name of Canon Inc. nor the names of
 15 * its contributors may be used to endorse or promote products derived
 16 * from this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 21 * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30#ifndef CountQueuingStrategy_h
 31#define CountQueuingStrategy_h
 32
 33#if ENABLE(STREAMS_API)
 34
 35#include "ScriptWrappable.h"
 36#include <wtf/RefCounted.h>
 37#include <wtf/RefPtr.h>
 38
 39namespace WebCore {
 40
 41class ScriptExecutionContext;
 42
 43// CountQueuingStrategy implements a stratagy for the streams that counts the chunks one by one according to the spec.
 44// See https://streams.spec.whatwg.org/#cqs-class
 45class CountQueuingStrategy : public ScriptWrappable, public RefCounted<CountQueuingStrategy> {
 46public:
 47 explicit CountQueuingStrategy();
 48 virtual ~CountQueuingStrategy();
 49};
 50
 51}
 52
 53#endif
 54
 55#endif // CountQueuingStrategy_h

Source/WebCore/Modules/streams/CountQueuingStrategy.idl

 1/*
 2 * Copyright (C) 2015 Canon Inc.
 3 * Copyright (C) 2015 Igalia S.L.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted, provided that the following conditions
 7 * are required to be met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer in the
 13 * documentation and/or other materials provided with the distribution.
 14 * 3. Neither the name of Canon Inc. nor the names of
 15 * its contributors may be used to endorse or promote products derived
 16 * from this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 21 * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30[
 31 CustomConstructor(any properties),
 32 Conditional=STREAMS_API,
 33] interface CountQueuingStrategy {
 34 [CustomObjectGenerateNoBindings] double size();
 35};

Source/WebCore/bindings/js/JSStreamsCountQueuingStrategyCustom.cpp

 1/*
 2 * Copyright (C) 2015 Canon Inc.
 3 * Copyright (C) 2015 Igalia S.L.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted, provided that the following conditions
 7 * are required to be met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer in the
 13 * documentation and/or other materials provided with the distribution.
 14 * 3. Neither the name of Canon Inc. nor the names of
 15 * its contributors may be used to endorse or promote products derived
 16 * from this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 21 * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30#include "config.h"
 31
 32#if ENABLE(STREAMS_API)
 33#include "JSCountQueuingStrategy.h"
 34
 35#include "JSDOMBinding.h"
 36#include "StreamsJSUtils.h"
 37
 38using namespace JSC;
 39
 40namespace WebCore {
 41
 42EncodedJSValue JSC_HOST_CALL jsCountQueuingStrategyPrototypeFunctionSize(ExecState*)
 43{
 44 return JSValue::encode(jsNumber(1));
 45}
 46
 47EncodedJSValue JSC_HOST_CALL constructJSCountQueuingStrategy(ExecState* state)
 48{
 49 // FIXME: We should consider reducing the binding code here (using Dictionary/regular binding constructor and/or
 50 // improving the IDL generator).
 51 JSValue value = state->argument(0);
 52 if (value.isNull() || value.isUndefined())
 53 return throwVMError(state, createTypeError(state, ASCIILiteral("constructor argument cannot be null or undefined")));
 54
 55 RefPtr<CountQueuingStrategy> countQueuingStrategy = adoptRef(*new CountQueuingStrategy());
 56 JSValue jsCountQueuingStrategy = toJS(state, jsCast<JSDOMGlobalObject*>(state->callee()->globalObject()), WTF::move(countQueuingStrategy));
 57
 58 if (value.isObject()) {
 59 JSObject* argumentObject = value.getObject();
 60 JSValue jsHighWaterMark = getPropertyFromObject(*state, *argumentObject, "highWaterMark");
 61 if (state->hadException())
 62 return JSValue::encode(jsUndefined());
 63 setPropertyToObject(*state, *jsCountQueuingStrategy.getObject(), "highWaterMark", jsHighWaterMark);
 64 }
 65
 66 return JSValue::encode(jsCountQueuingStrategy);
 67}
 68
 69} // namespace WebCore
 70
 71#endif

Source/WebCore/bindings/js/ReadableJSStream.cpp

4040#include "JSReadableStreamController.h"
4141#include "ScriptExecutionContext.h"
4242#include "ScriptState.h"
 43#include "StreamsJSUtils.h"
4344#include <runtime/Error.h>
4445#include <runtime/Exception.h>
4546#include <runtime/JSCJSValueInlines.h>

@@using namespace JSC;
5152
5253namespace WebCore {
5354
54 static inline JSValue getPropertyFromObject(ExecState& exec, JSObject& object, const char* identifier)
55 {
56  return object.get(&exec, Identifier::fromString(&exec, identifier));
57 }
58 
5955static inline JSValue callFunction(ExecState& exec, JSValue jsFunction, JSValue thisValue, const ArgList& arguments)
6056{
6157 CallData callData;

Source/WebCore/bindings/js/StreamsJSUtils.h

 1/*
 2 * Copyright (C) 2O15 Canon Inc. 2015
 3 * Copyright (C) 2015 Igalia S.L. 2015
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted, provided that the following conditions
 7 * are required to be met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer in the
 13 * documentation and/or other materials provided with the distribution.
 14 * 3. Neither the name of Canon Inc. nor the names of
 15 * its contributors may be used to endorse or promote products derived
 16 * from this software without specific prior written permission.
 17 *
 18 * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 21 * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30#ifndef StreamsJSUtils_h
 31#define StreamsJSUtils_h
 32
 33#if ENABLE(STREAMS_API)
 34
 35#include <runtime/JSCJSValueInlines.h>
 36#include <runtime/JSObject.h>
 37
 38namespace JSC {
 39class ExecState;
 40class JSValue;
 41}
 42
 43namespace WebCore {
 44
 45inline JSC::JSValue getPropertyFromObject(JSC::ExecState& state, JSC::JSObject& object, const char* identifier)
 46{
 47 return object.get(&state, JSC::Identifier::fromString(&state, identifier));
 48}
 49
 50inline void setPropertyToObject(JSC::ExecState& state, JSC::JSObject& targetObject, const char* name, JSC::JSValue value)
 51{
 52 JSC::PutPropertySlot propertySlot(&targetObject);
 53 targetObject.put(&targetObject, &state, JSC::Identifier::fromString(&state, name), value, propertySlot);
 54}
 55
 56} // namespace WebCore
 57
 58#endif // ENABLE(STREAMS_API)
 59
 60#endif // StreamsJSUtils_h