Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (191286 => 191287)
--- trunk/Source/WebCore/CMakeLists.txt 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/CMakeLists.txt 2015-10-19 10:36:42 UTC (rev 191287)
@@ -3363,6 +3363,7 @@
set(IDL_ATTRIBUTES_FILE ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
set(WEBCORE_JS_BUILTINS
+ ${WEBCORE_DIR}/Modules/mediastream/MediaDevices.js
${WEBCORE_DIR}/Modules/streams/ByteLengthQueuingStrategy.js
${WEBCORE_DIR}/Modules/streams/CountQueuingStrategy.js
${WEBCORE_DIR}/Modules/streams/ReadableStream.js
Modified: trunk/Source/WebCore/ChangeLog (191286 => 191287)
--- trunk/Source/WebCore/ChangeLog 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/ChangeLog 2015-10-19 10:36:42 UTC (rev 191287)
@@ -1,5 +1,48 @@
2015-10-19 Youenn Fablet <youenn.fab...@crf.canon.fr>
+ Binding generator should allow generating private JS functions
+ https://bugs.webkit.org/show_bug.cgi?id=150167
+
+ Reviewed by Darin Adler.
+
+ Introducing the "Private" keyword for that purpose.
+ Applying it to MediaDevices.getUserMedia which can be used directly or through navigator.webkitGetUserMedia
+ which could be implemented as JS builtin based on it.
+
+ "Private" functions are added to the prototype with a corresponding private symbol.
+ This symbol must be defined in bindings/js/WebCoreBuiltinNames.h.
+
+ Adding a getUserMediaFromJS function visible from builtins script.
+ Implementing MediaDevices.getUserMedia as a JS builtin based on it.
+
+ Adding binding generator test.
+
+ * CMakeLists.txt: Adding MediaDevices.js.
+ * DerivedSources.make: Ditto.
+ * Modules/mediastream/MediaDevices.h:
+ (WebCore::MediaDevices::getUserMediaFromJS):
+ * Modules/mediastream/MediaDevices.idl: Marking getUserMediaFromJS private and getUserMedia JSBuiltin.
+ * Modules/mediastream/MediaDevices.js: Added.
+ (getUserMedia):
+ * bindings/js/WebCoreBuiltinNames.h:
+ * bindings/js/WebCoreJSBuiltins.cpp:
+ * bindings/js/WebCoreJSBuiltins.h:
+ (WebCore::JSBuiltinFunctions::JSBuiltinFunctions):
+ (WebCore::JSBuiltinFunctions::mediaDevicesBuiltins):
+ * bindings/scripts/CodeGeneratorGObject.pm: Skipping generation of Private functions.
+ (SkipFunction):
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementation): Disabling addition of private function in table and adding private member field to the prototype.
+ * bindings/scripts/CodeGeneratorObjC.pm: Skipping generation of Private functions.
+ (SkipFunction):
+ * bindings/scripts/IDLAttributes.txt: Adding Private keyword.
+ * bindings/scripts/test/JS/JSTestObj.cpp: Adding Private keyword test.
+ (WebCore::JSTestObjPrototype::finishCreation):
+ (WebCore::jsTestObjPrototypeFunctionPrivateMethod):
+ * bindings/scripts/test/TestObj.idl:
+
+2015-10-19 Youenn Fablet <youenn.fab...@crf.canon.fr>
+
[Streams API] Implement ReadableStream tee
https://bugs.webkit.org/show_bug.cgi?id=146315
Modified: trunk/Source/WebCore/DerivedSources.make (191286 => 191287)
--- trunk/Source/WebCore/DerivedSources.make 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/DerivedSources.make 2015-10-19 10:36:42 UTC (rev 191287)
@@ -1255,6 +1255,7 @@
# WebCore JS Builtins
WEBCORE_JS_BUILTINS = \
+ $(WebCore)/Modules/mediastream/MediaDevices.js \
$(WebCore)/Modules/streams/ByteLengthQueuingStrategy.js \
$(WebCore)/Modules/streams/CountQueuingStrategy.js \
$(WebCore)/Modules/streams/ReadableStream.js \
Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.h (191286 => 191287)
--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.h 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.h 2015-10-19 10:36:42 UTC (rev 191287)
@@ -63,6 +63,8 @@
void getUserMedia(const Dictionary&, Promise&&, ExceptionCode&) const;
void enumerateDevices(EnumerateDevicesPromise&&, ExceptionCode&) const;
+ void getUserMediaFromJS(const Dictionary& dictionary, Promise&& promise, ExceptionCode& ec) const { getUserMedia(dictionary, WTF::move(promise), ec); }
+
private:
explicit MediaDevices(ScriptExecutionContext*);
};
Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl (191286 => 191287)
--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl 2015-10-19 10:36:42 UTC (rev 191287)
@@ -32,6 +32,8 @@
NoInterfaceObject,
Conditional=MEDIA_STREAM
] interface MediaDevices {
- [RaisesException] Promise getUserMedia(Dictionary options);
+ [JSBuiltin] Promise getUserMedia(Dictionary options);
[RaisesException] Promise enumerateDevices();
+
+ [Private, RaisesException] Promise getUserMediaFromJS(Dictionary options);
};
Added: trunk/Source/WebCore/Modules/mediastream/MediaDevices.js (0 => 191287)
--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.js (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.js 2015-10-19 10:36:42 UTC (rev 191287)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "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 CANON INC. AND ITS 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=MEDIA_STREAM
+
+function getUserMedia(options)
+{
+ if (!this.@getUserMediaFromJS)
+ throw new @TypeError("Function should be called on a MediaDevices");
+ return this.@getUserMediaFromJS.@apply(this, arguments);
+}
Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (191286 => 191287)
--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2015-10-19 10:36:42 UTC (rev 191287)
@@ -38,17 +38,18 @@
macro(closedPromiseReject) \
macro(controlledReadableStream) \
macro(controller) \
+ macro(getUserMediaFromJS) \
macro(highWaterMark) \
macro(ownerReadableStream) \
+ macro(pulling) \
macro(pullAgain) \
- macro(pulling) \
macro(queue) \
macro(queueSize) \
macro(readableStreamClosed) \
macro(readableStreamErrored) \
macro(readableStreamReadable) \
+ macro(reader) \
macro(readRequests) \
- macro(reader) \
macro(state) \
macro(started) \
macro(storedError) \
Modified: trunk/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp (191286 => 191287)
--- trunk/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp 2015-10-19 10:36:42 UTC (rev 191287)
@@ -26,6 +26,10 @@
#include "config.h"
+#if ENABLE(MEDIA_STREAM)
+#include "MediaDevicesBuiltins.cpp"
+#endif
+
#if ENABLE(STREAMS_API)
#include "ByteLengthQueuingStrategyBuiltins.cpp"
#include "CountQueuingStrategyBuiltins.cpp"
Modified: trunk/Source/WebCore/bindings/js/WebCoreJSBuiltins.h (191286 => 191287)
--- trunk/Source/WebCore/bindings/js/WebCoreJSBuiltins.h 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/js/WebCoreJSBuiltins.h 2015-10-19 10:36:42 UTC (rev 191287)
@@ -27,6 +27,10 @@
#ifndef WebCoreJSBuiltins_h
#define WebCoreJSBuiltins_h
+#if ENABLE(MEDIA_STREAM)
+#include "MediaDevicesBuiltinsWrapper.h"
+#endif
+
#if ENABLE(STREAMS_API)
#include "ByteLengthQueuingStrategyBuiltinsWrapper.h"
#include "CountQueuingStrategyBuiltinsWrapper.h"
@@ -37,7 +41,6 @@
#include "WritableStreamBuiltinsWrapper.h"
#endif
-
#include <runtime/VM.h>
namespace WebCore {
@@ -55,6 +58,9 @@
, m_readableStreamReaderBuiltins(&vm)
, m_writableStreamBuiltins(&vm)
#endif
+#if ENABLE(MEDIA_STREAM)
+ , m_mediaDevicesBuiltins(&vm)
+#endif
{
#if ENABLE(STREAMS_API)
m_readableStreamInternalsBuiltins.exportNames();
@@ -69,6 +75,9 @@
ReadableStreamReaderBuiltinsWrapper& readableStreamReaderBuiltins() { return m_readableStreamReaderBuiltins; }
WritableStreamBuiltinsWrapper& writableStreamBuiltins() { return m_writableStreamBuiltins; }
#endif
+#if ENABLE(MEDIA_STREAM)
+ MediaDevicesBuiltinsWrapper& mediaDevicesBuiltins() { return m_mediaDevicesBuiltins; }
+#endif
private:
JSC::VM& vm;
@@ -81,6 +90,9 @@
ReadableStreamReaderBuiltinsWrapper m_readableStreamReaderBuiltins;
WritableStreamBuiltinsWrapper m_writableStreamBuiltins;
#endif
+#if ENABLE(MEDIA_STREAM)
+ MediaDevicesBuiltinsWrapper m_mediaDevicesBuiltins;
+#endif
};
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (191286 => 191287)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2015-10-19 10:36:42 UTC (rev 191287)
@@ -369,18 +369,14 @@
return 1;
}
- if ($function->signature->type eq "Promise") {
- return 1;
- }
+ return 1 if $function->signature->type eq "Promise";
- if ($function->signature->type eq "Date") {
- return 1;
- }
+ return 1 if $function->signature->type eq "Date";
- if ($function->signature->extendedAttributes->{"JSBuiltin"}) {
- return 1;
- }
+ return 1 if $function->signature->extendedAttributes->{"JSBuiltin"};
+ return 1 if $function->signature->extendedAttributes->{"Private"};
+
return 0;
}
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (191286 => 191287)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2015-10-19 10:36:42 UTC (rev 191287)
@@ -2028,6 +2028,7 @@
my @runtimeEnabledFunctions = ();
foreach my $function (@{$interface->functions}) {
+ next if ($function->signature->extendedAttributes->{"Private"});
next if ($function->isStatic);
next if $function->{overloadIndex} && $function->{overloadIndex} > 1;
my $name = $function->signature->name;
@@ -2102,6 +2103,16 @@
push(@implContent, " }\n");
push(@implContent, "#endif\n") if $conditionalString;
}
+
+ my $firstPrivateFunction = 1;
+ foreach my $function (@{$interface->functions}) {
+ next unless ($function->signature->extendedAttributes->{"Private"});
+ AddToImplIncludes("WebCoreJSClientData.h");
+ push(@implContent, " JSVMClientData& clientData = *static_cast<JSVMClientData*>(vm.clientData);\n") if $firstPrivateFunction;
+ $firstPrivateFunction = 0;
+ push(@implContent, " putDirect(vm, clientData.builtinNames()." . $function->signature->name . "PrivateName(), JSFunction::create(vm, globalObject(), 0, String(), " . GetFunctionName($className, $function) . "), ReadOnly | DontEnum);\n");
+ }
+
push(@implContent, "}\n\n");
} else {
push(@implContent, "void ${className}Prototype::finishCreation(VM& vm)\n");
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm (191286 => 191287)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2015-10-19 10:36:42 UTC (rev 191287)
@@ -547,6 +547,8 @@
return 1 if $param->extendedAttributes->{"Clamp"};
}
+ return 1 if $function->signature->extendedAttributes->{"Private"};
+
return 0;
}
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (191286 => 191287)
--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2015-10-19 10:36:42 UTC (rev 191287)
@@ -103,6 +103,7 @@
ObjCUseDefaultView
OverrideBuiltins
PassContext
+Private
PutForwards=*
RaisesException
Reflect=*
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (191286 => 191287)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2015-10-19 10:36:42 UTC (rev 191287)
@@ -53,6 +53,7 @@
#include "TestNode.h"
#include "TestObj.h"
#include "URL.h"
+#include "WebCoreJSClientData.h"
#include "bool.h"
#include <bindings/ScriptValue.h>
#include <inspector/ScriptArguments.h>
@@ -104,6 +105,7 @@
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionPrivateMethod(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*);
@@ -687,6 +689,8 @@
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTestObjPrototypeTableValues, *this);
+ JSVMClientData& clientData = *static_cast<JSVMClientData*>(vm.clientData);
+ putDirect(vm, clientData.builtinNames().privateMethodPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsTestObjPrototypeFunctionPrivateMethod), ReadOnly | DontEnum);
}
const ClassInfo JSTestObj::s_info = { "TestObject", &Base::s_info, &JSTestObjTable, CREATE_METHOD_TABLE(JSTestObj) };
@@ -3484,6 +3488,23 @@
return JSValue::encode(castedThis->customMethodWithArgs(*state));
}
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionPrivateMethod(ExecState* state)
+{
+ JSValue thisValue = state->thisValue();
+ JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+ if (UNLIKELY(!castedThis))
+ return throwThisTypeError(*state, "TestObj", "privateMethod");
+ ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+ auto& impl = castedThis->impl();
+ if (UNLIKELY(state->argumentCount() < 1))
+ return throwVMError(state, createNotEnoughArgumentsError(state));
+ String argument = state->argument(0).toString(state)->value(state);
+ if (UNLIKELY(state->hadException()))
+ return JSValue::encode(jsUndefined());
+ JSValue result = jsStringWithCache(state, impl.privateMethod(argument));
+ return JSValue::encode(result);
+}
+
EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(ExecState* state)
{
JSValue thisValue = state->thisValue();
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (191286 => 191287)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2015-10-19 10:16:58 UTC (rev 191286)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2015-10-19 10:36:42 UTC (rev 191287)
@@ -123,6 +123,9 @@
[Conditional=Condition4, JSBuiltin] attribute TestObj jsBuiltinAttribute;
[Conditional=Condition4, JSBuiltin] readonly attribute TestObj jsBuiltinReadOnlyAttribute;
+ // Private extended attribute
+ [Private] DOMString privateMethod(DOMString argument);
+
void addEventListener(DOMString type, EventListener listener, optional boolean useCapture);
void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture);
attribute EventHandler onfoo;