[DataCue] Un-prefix DataCue and remove custom bindings
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Dec 2016 18:52:56 +0000 (18:52 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Dec 2016 18:52:56 +0000 (18:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166087

Reviewed by Eric Carlson.

Source/WebCore:

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
* bindings/js/JSDataCueCustom.cpp: Removed.
Remove JSDataCueCustom.cpp

* bindings/js/JSTextTrackCueCustom.cpp:
(WebCore::toJSNewlyCreated):
Remove out of date comment.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorDefinition):
Update constructor generation code to use JSDOMConvert.

* html/track/DataCue.cpp:
(WebCore::DataCue::DataCue):
(WebCore::DataCue::~DataCue):
(WebCore::DataCue::data):
(WebCore::DataCue::setData):
(WebCore::DataCue::cueContentsMatch):
(WebCore::DataCue::value):
(WebCore::DataCue::setValue):
(WebCore::DataCue::valueOrNull):
* html/track/DataCue.h:
* html/track/DataCue.idl:
* platform/SerializedPlatformRepresentation.h:
Remove DATACUE_VALUE define from web exposed classes, so the interface can
be the same on all platforms. Platforms that don't support DATACUE_VALUE will
just never have any value. Also remove custom annotations.

LayoutTests:

* media/track/track-datacue-value-expected.txt:
* media/track/track-datacue-value.html:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:
Update tests for unprefixed DataCue.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210025 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/ChangeLog
LayoutTests/media/track/track-datacue-value-expected.txt
LayoutTests/media/track/track-datacue-value.html
LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSDataCueCustom.cpp [deleted file]
Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/html/track/DataCue.cpp
Source/WebCore/html/track/DataCue.h
Source/WebCore/html/track/DataCue.idl
Source/WebCore/platform/SerializedPlatformRepresentation.h

index 3331a8a..d3f9201 100644 (file)
@@ -1,3 +1,15 @@
+2016-12-20  Sam Weinig  <sam@webkit.org>
+
+        [DataCue] Un-prefix DataCue and remove custom bindings
+        https://bugs.webkit.org/show_bug.cgi?id=166087
+
+        Reviewed by Eric Carlson.
+
+        * media/track/track-datacue-value-expected.txt:
+        * media/track/track-datacue-value.html:
+        * platform/mac/js/dom/global-constructors-attributes-expected.txt:
+        Update tests for unprefixed DataCue.
+
 2016-12-20  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Implement the updated port/area-based Scroll Snap Module Level 1 Spec
index 2cf3473..1cae8ef 100644 (file)
@@ -1,8 +1,8 @@
-Tests WebKitDataCue.value
+Tests DataCue.value
 
 
 *** Initialize with string.
-RUN(cue = new WebKitDataCue(2, 6, 'test'))
+RUN(cue = new DataCue(2, 6, 'test'))
 EXPECTED (cue.id == '') OK
 EXPECTED (cue.startTime == '2') OK
 EXPECTED (cue.endTime == '6') OK
@@ -13,7 +13,7 @@ EXPECTED (cue.data == 'null') OK
 EXPECTED (cue.type == '') OK
 
 *** Initialize with an object.
-RUN(cue = new WebKitDataCue(9, 16, { data: [1, 2, 3] }, 'org.test'))
+RUN(cue = new DataCue(9, 16, { data: [1, 2, 3] }, 'org.test'))
 EXPECTED (cue.id == '') OK
 EXPECTED (cue.startTime == '9') OK
 EXPECTED (cue.endTime == '16') OK
index 339863c..4ce3039 100644 (file)
@@ -9,7 +9,7 @@
             function loaded()
             {
                 consoleWrite("<br>*** Initialize with string.");
-                run("cue = new WebKitDataCue(2, 6, 'test')");
+                run("cue = new DataCue(2, 6, 'test')");
                 testExpected("cue.id", "");
                 testExpected("cue.startTime", 2);
                 testExpected("cue.endTime", 6);
@@ -20,7 +20,7 @@
                 testExpected("cue.type", '');
 
                 consoleWrite("<br>*** Initialize with an object.");
-                run("cue = new WebKitDataCue(9, 16, { data: [1, 2, 3] }, 'org.test')");
+                run("cue = new DataCue(9, 16, { data: [1, 2, 3] }, 'org.test')");
                 testExpected("cue.id", "");
                 testExpected("cue.startTime", 9);
                 testExpected("cue.endTime", 16);
@@ -45,6 +45,6 @@
         </script>
     </head>
     <body onload="loaded()">
-        <p>Tests WebKitDataCue.value</p>
+        <p>Tests DataCue.value</p>
     </body>
 </html>
index fb3bea9..8bdefff 100644 (file)
@@ -373,6 +373,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'DOMTokenList').hasOwnProperty('get
 PASS Object.getOwnPropertyDescriptor(global, 'DOMTokenList').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'DOMTokenList').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'DOMTokenList').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'DataCue').value is DataCue
+PASS Object.getOwnPropertyDescriptor(global, 'DataCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'DataCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'DataCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'DataCue').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'DataTransfer').value is DataTransfer
 PASS Object.getOwnPropertyDescriptor(global, 'DataTransfer').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'DataTransfer').hasOwnProperty('set') is false
@@ -2393,11 +2398,6 @@ PASS Object.getOwnPropertyDescriptor(global, 'WebKitCSSRegionRule').hasOwnProper
 PASS Object.getOwnPropertyDescriptor(global, 'WebKitCSSRegionRule').hasOwnProperty('set') is false
 PASS Object.getOwnPropertyDescriptor(global, 'WebKitCSSRegionRule').enumerable is false
 PASS Object.getOwnPropertyDescriptor(global, 'WebKitCSSRegionRule').configurable is true
-PASS Object.getOwnPropertyDescriptor(global, 'WebKitDataCue').value is WebKitDataCue
-PASS Object.getOwnPropertyDescriptor(global, 'WebKitDataCue').hasOwnProperty('get') is false
-PASS Object.getOwnPropertyDescriptor(global, 'WebKitDataCue').hasOwnProperty('set') is false
-PASS Object.getOwnPropertyDescriptor(global, 'WebKitDataCue').enumerable is false
-PASS Object.getOwnPropertyDescriptor(global, 'WebKitDataCue').configurable is true
 PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaKeyError').value is WebKitMediaKeyError
 PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaKeyError').hasOwnProperty('get') is false
 PASS Object.getOwnPropertyDescriptor(global, 'WebKitMediaKeyError').hasOwnProperty('set') is false
index e8e0c58..83c0359 100644 (file)
@@ -1119,7 +1119,6 @@ set(WebCore_SOURCES
     bindings/js/JSDOMWindowProperties.cpp
     bindings/js/JSDOMWindowShell.cpp
     bindings/js/JSDOMWrapper.cpp
-    bindings/js/JSDataCueCustom.cpp
     bindings/js/JSDeviceMotionEventCustom.cpp
     bindings/js/JSDeviceOrientationEventCustom.cpp
     bindings/js/JSDocumentCustom.cpp
index 090047a..8d4615d 100644 (file)
@@ -1,3 +1,40 @@
+2016-12-20  Sam Weinig  <sam@webkit.org>
+
+        [DataCue] Un-prefix DataCue and remove custom bindings
+        https://bugs.webkit.org/show_bug.cgi?id=166087
+
+        Reviewed by Eric Carlson.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        * bindings/js/JSDataCueCustom.cpp: Removed.
+        Remove JSDataCueCustom.cpp
+
+        * bindings/js/JSTextTrackCueCustom.cpp:
+        (WebCore::toJSNewlyCreated):
+        Remove out of date comment.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateConstructorDefinition):
+        Update constructor generation code to use JSDOMConvert.
+
+        * html/track/DataCue.cpp:
+        (WebCore::DataCue::DataCue):
+        (WebCore::DataCue::~DataCue):
+        (WebCore::DataCue::data):
+        (WebCore::DataCue::setData):
+        (WebCore::DataCue::cueContentsMatch):
+        (WebCore::DataCue::value):
+        (WebCore::DataCue::setValue):
+        (WebCore::DataCue::valueOrNull):
+        * html/track/DataCue.h:
+        * html/track/DataCue.idl:
+        * platform/SerializedPlatformRepresentation.h:
+        Remove DATACUE_VALUE define from web exposed classes, so the interface can
+        be the same on all platforms. Platforms that don't support DATACUE_VALUE will
+        just never have any value. Also remove custom annotations.
+
 2016-12-20  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Implement the updated port/area-based Scroll Snap Module Level 1 Spec
index 0c088c4..1a97689 100644 (file)
                07F0B97C1AC5DB4600E535D9 /* AVFoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07F876841AD580F900905849 /* MediaPlaybackTargetContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07F944161864D046005D31CB /* PlatformMediaSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAE8C081746B95700532D78 /* PlatformMediaSessionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               07FBDE2C18FED178001A7CFF /* JSDataCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */; };
                07FE99DC18807A7D00256648 /* MediaElementSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FE99DA18807A7D00256648 /* MediaElementSession.cpp */; };
                07FE99DD18807A7D00256648 /* MediaElementSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FE99DB18807A7D00256648 /* MediaElementSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07FFDE68181AED420072D409 /* MediaStreamTrackPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */; };
                07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVKitSPI.h; sourceTree = "<group>"; };
                07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationSPI.h; sourceTree = "<group>"; };
                07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetContext.h; sourceTree = "<group>"; };
-               07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataCueCustom.cpp; sourceTree = "<group>"; };
                07FE99DA18807A7D00256648 /* MediaElementSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaElementSession.cpp; sourceTree = "<group>"; };
                07FE99DB18807A7D00256648 /* MediaElementSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaElementSession.h; sourceTree = "<group>"; };
                07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamTrackPrivate.cpp; sourceTree = "<group>"; };
                                AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */,
                                9BC5F9DF1D5AAF6A002B749D /* JSCustomElementRegistryCustom.cpp */,
                                DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
-                               07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */,
                                31FB1A6B120A5D6900DC02A0 /* JSDeviceMotionEventCustom.cpp */,
                                590E1B4A11E4EF700069F784 /* JSDeviceOrientationEventCustom.cpp */,
                                49C7BA8C1042F5B10009D447 /* JSDocumentCustom.cpp */,
                                1AE82F8F0CAAFA9D002237AE /* JSDatabase.cpp in Sources */,
                                B59DD69A119029E5007E9684 /* JSDatabaseCallback.cpp in Sources */,
                                BE61039D18A9D65200DD50D7 /* JSDataCue.cpp in Sources */,
-                               07FBDE2C18FED178001A7CFF /* JSDataCueCustom.cpp in Sources */,
                                BCA83E4F0D7CE1E9003421A8 /* JSDataTransfer.cpp in Sources */,
                                4162A4571011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp in Sources */,
                                FDA15ED112B03F94003A583A /* JSDelayNode.cpp in Sources */,
index e2a3cd9..10144eb 100644 (file)
@@ -60,7 +60,6 @@
 #include "JSDOMWindowProperties.cpp"
 #include "JSDOMWindowShell.cpp"
 #include "JSDOMWrapper.cpp"
-#include "JSDataCueCustom.cpp"
 #include "JSDeviceOrientationEventCustom.cpp"
 #include "JSDocumentCustom.cpp"
 #include "JSDocumentFragmentCustom.cpp"
diff --git a/Source/WebCore/bindings/js/JSDataCueCustom.cpp b/Source/WebCore/bindings/js/JSDataCueCustom.cpp
deleted file mode 100644 (file)
index c7efc51..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#include "config.h"
-
-#if ENABLE(VIDEO_TRACK)
-
-#include "JSDataCue.h"
-
-#include "JSDOMBinding.h"
-
-using namespace JSC;
-
-namespace WebCore {
-
-#if ENABLE(DATACUE_VALUE)
-JSValue JSDataCue::value(ExecState& state) const
-{
-    return wrapped().value(&state);
-}
-
-void JSDataCue::setValue(ExecState& state, JSValue value)
-{
-    wrapped().setValue(&state, value);
-}
-#endif
-
-EncodedJSValue JSC_HOST_CALL constructJSDataCue(ExecState& exec)
-{
-    VM& vm = exec.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    DOMConstructorObject* castedThis = jsCast<DOMConstructorObject*>(exec.jsCallee());
-    ASSERT(castedThis);
-    if (exec.argumentCount() < 3)
-        return throwVMError(&exec, scope, createNotEnoughArgumentsError(&exec));
-
-    double startTime(exec.uncheckedArgument(0).toNumber(&exec));
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
-    double endTime(exec.uncheckedArgument(1).toNumber(&exec));
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
-    ScriptExecutionContext* context = castedThis->scriptExecutionContext();
-    if (!context)
-        return throwConstructorScriptExecutionContextUnavailableError(exec, scope, "DataCue");
-
-    String type;
-#if ENABLE(DATACUE_VALUE)
-    if (exec.argumentCount() > 3) {
-        if (!exec.uncheckedArgument(3).isString())
-            return throwArgumentTypeError(exec, scope, 3, "type", "DataCue", nullptr, "DOMString");
-        type = asString(exec.uncheckedArgument(3))->value(&exec);
-    }
-#endif
-
-    JSValue valueArgument = exec.uncheckedArgument(2);
-    if (valueArgument.isUndefinedOrNull()) {
-        setDOMException(&exec, TypeError);
-        return JSValue::encode(JSValue());
-    }
-
-    if (valueArgument.isCell() && valueArgument.asCell()->inherits(std::remove_pointer<JSArrayBuffer*>::type::info())) {
-
-        ArrayBuffer* data = toUnsharedArrayBuffer(valueArgument);
-        RETURN_IF_EXCEPTION(scope, encodedJSValue());
-
-        if (UNLIKELY(!data)) {
-            setDOMException(&exec, TypeError);
-            return JSValue::encode(jsUndefined());
-        }
-        return JSValue::encode(createWrapper<DataCue>(castedThis->globalObject(), DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), *data, type)));
-    }
-
-#if !ENABLE(DATACUE_VALUE)
-    return JSValue::encode(jsUndefined());
-#else
-    return JSValue::encode(createWrapper<DataCue>(castedThis->globalObject(), DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), valueArgument, type)));
-#endif
-}
-
-} // namespace WebCore
-
-#endif
index 6e7774e..a297e8d 100644 (file)
@@ -57,7 +57,6 @@ bool JSTextTrackCueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> h
 
 JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<TextTrackCue>&& cue)
 {
-    // This switch will make more sense once we support DataCue
     switch (cue->cueType()) {
     case TextTrackCue::Data:
         return createWrapper<DataCue>(globalObject, WTFMove(cue));
index 4894084..d80a8c0 100644 (file)
@@ -5884,11 +5884,16 @@ sub GenerateConstructorDefinition
             }
 
             push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{ConstructorCallWith}, "ScriptState");
-            if ($interface->extendedAttributes->{ConstructorMayThrowException}) {
-                push(@$outputArray, "    return JSValue::encode(toJSNewlyCreated(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));\n");
-            } else {
-                push(@$outputArray, "    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));\n");
-            }
+
+            my $IDLType = GetIDLType($interface, $interface->type);
+
+            my @constructionConversionArguments = ();
+            push(@constructionConversionArguments, "*state");
+            push(@constructionConversionArguments, "*castedThis->globalObject()");
+            push(@constructionConversionArguments, "throwScope") if $interface->extendedAttributes->{ConstructorMayThrowException};
+            push(@constructionConversionArguments, "WTFMove(object)");
+
+            push(@$outputArray, "    return JSValue::encode(toJSNewlyCreated<${IDLType}>(" . join(", ", @constructionConversionArguments) . "));\n");
             push(@$outputArray, "}\n\n");
         }
     }
index a60a908..0451c8a 100644 (file)
@@ -129,7 +129,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestEventConstructorConstructor::const
     auto eventInitDict = convert<IDLDictionary<TestEventConstructor::Init>>(*state, state->argument(1));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestEventConstructor::create(WTFMove(type), WTFMove(eventInitDict));
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestEventConstructor>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestEventConstructorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
index 04778b2..13984a8 100644 (file)
@@ -234,7 +234,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::construct(Ex
     if (UNLIKELY(!context))
         return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "TestInterface");
     auto object = TestInterface::create(*context, WTFMove(str1), WTFMove(str2));
-    return JSValue::encode(toJSNewlyCreated(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestInterface>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));
 }
 
 template<> JSValue JSTestInterfaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
index 260d8c3..bc17add 100644 (file)
@@ -96,7 +96,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::
     auto str3 = state->argument(2).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(2), StringConversionConfiguration::Normal);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestNamedConstructor::createForJSConstructor(*castedThis->document(), WTFMove(str1), WTFMove(str2), WTFMove(str3));
-    return JSValue::encode(toJSNewlyCreated(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestNamedConstructor>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));
 }
 
 template<> JSValue JSTestNamedConstructorNamedConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
index eafc214..7aad33f 100644 (file)
@@ -87,7 +87,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::construct(ExecSta
     auto* castedThis = jsCast<JSTestNodeConstructor*>(state->jsCallee());
     ASSERT(castedThis);
     auto object = TestNode::create();
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestNode>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
index 049d868..81a530b 100644 (file)
@@ -1552,7 +1552,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestObjConstructor::construct(ExecStat
     ASSERT(context->isDocument());
     auto& document = downcast<Document>(*context);
     auto object = TestObj::create(document, testCallback.releaseNonNull(), testCallbackFunction.releaseNonNull());
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestObj>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestObjConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
index 2e286db..2df5792 100644 (file)
@@ -77,7 +77,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructors1(ExecState* s
     auto arrayBuffer = convert<IDLInterface<ArrayBuffer>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "arrayBuffer", "TestOverloadedConstructors", nullptr, "ArrayBuffer"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(*arrayBuffer);
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors2(ExecState* state)
@@ -92,7 +92,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructors2(ExecState* s
     auto arrayBufferView = convert<IDLInterface<ArrayBufferView>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "arrayBufferView", "TestOverloadedConstructors", nullptr, "ArrayBufferView"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(arrayBufferView.releaseNonNull());
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors3(ExecState* state)
@@ -107,7 +107,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructors3(ExecState* s
     auto blob = convert<IDLInterface<Blob>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "blob", "TestOverloadedConstructors", nullptr, "Blob"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(*blob);
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors4(ExecState* state)
@@ -122,7 +122,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructors4(ExecState* s
     auto string = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(WTFMove(string));
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors5(ExecState* state)
@@ -135,7 +135,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructors5(ExecState* s
     auto longArgs = convertVariadicArguments<IDLLong>(*state, 0);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(WTFMove(longArgs));
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructors>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::construct(ExecState* state)
index 4b2b9f6..ef97779 100644 (file)
@@ -75,7 +75,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence1(
     auto sequenceOfStrings = state->argument(0).isUndefined() ? Converter<IDLSequence<IDLDOMString>>::ReturnType{ } : convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(sequenceOfStrings));
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence2(ExecState* state)
@@ -90,7 +90,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence2(
     auto string = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(string));
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestOverloadedConstructorsWithSequence>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsWithSequenceConstructor::construct(ExecState* state)
index c7a0c8d..756b1cf 100644 (file)
@@ -139,7 +139,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestTypedefsConstructor::construct(Exe
     auto testCallbackInterface = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*state, state->uncheckedArgument(2), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 2, "testCallbackInterface", "TestTypedefs", nullptr); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestTypedefs::create(WTFMove(hello), testCallbackFunction.releaseNonNull(), testCallbackInterface.releaseNonNull());
-    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
+    return JSValue::encode(toJSNewlyCreated<IDLInterface<TestTypedefs>>(*state, *castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestTypedefsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
index 5d9e04e..3bc272a 100644 (file)
 #include "Logging.h"
 #include "TextTrack.h"
 #include "TextTrackCueList.h"
+#include <runtime/JSCInlines.h>
 #include <runtime/Protect.h>
 
+using namespace JSC;
+
 namespace WebCore {
 
 DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, ArrayBuffer& data, const String& type)
@@ -45,11 +48,10 @@ DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const
 
 DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, const void* data, unsigned length)
     : TextTrackCue(context, start, end)
+    , m_data(ArrayBuffer::create(data, length))
 {
-    m_data = ArrayBuffer::create(data, length);
 }
 
-#if ENABLE(DATACUE_VALUE)
 DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, RefPtr<SerializedPlatformRepresentation>&& platformValue, const String& type)
     : TextTrackCue(context, start, end)
     , m_type(type)
@@ -65,22 +67,17 @@ DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const
     if (m_value)
         JSC::gcProtect(m_value);
 }
-#endif
 
 DataCue::~DataCue()
 {
-#if ENABLE(DATACUE_VALUE)
     if (m_value)
         JSC::gcUnprotect(m_value);
-#endif
 }
 
 RefPtr<ArrayBuffer> DataCue::data() const
 {
-#if ENABLE(DATACUE_VALUE)
     if (m_platformValue)
         return m_platformValue->data();
-#endif
 
     if (!m_data)
         return nullptr;
@@ -90,12 +87,10 @@ RefPtr<ArrayBuffer> DataCue::data() const
 
 void DataCue::setData(ArrayBuffer& data)
 {
-#if ENABLE(DATACUE_VALUE)
     m_platformValue = nullptr;
     if (m_value)
         JSC::gcUnprotect(m_value);
     m_value = JSC::JSValue();
-#endif
 
     m_data = ArrayBuffer::create(data);
 }
@@ -126,20 +121,18 @@ bool DataCue::cueContentsMatch(const TextTrackCue& cue) const
     if (m_data && m_data->data() && memcmp(m_data->data(), otherData->data(), m_data->byteLength()))
         return false;
 
-#if ENABLE(DATACUE_VALUE)
     const SerializedPlatformRepresentation* otherPlatformValue = dataCue->platformValue();
     if ((otherPlatformValue && !m_platformValue) || (!otherPlatformValue && m_platformValue))
         return false;
     if (m_platformValue && !m_platformValue->isEqual(*otherPlatformValue))
         return false;
 
-    JSC::JSValue thisValue = value(nullptr);
-    JSC::JSValue otherValue = dataCue->value(nullptr);
+    JSC::JSValue thisValue = valueOrNull();
+    JSC::JSValue otherValue = dataCue->valueOrNull();
     if ((otherValue && !thisValue) || (!otherValue && thisValue))
         return false;
     if (!JSC::JSValue::strictEqual(nullptr, thisValue, otherValue))
         return false;
-#endif
 
     return true;
 }
@@ -163,11 +156,10 @@ bool DataCue::doesExtendCue(const TextTrackCue& cue) const
     return TextTrackCue::doesExtendCue(cue);
 }
 
-#if ENABLE(DATACUE_VALUE)
-JSC::JSValue DataCue::value(JSC::ExecState* exec) const
+JSC::JSValue DataCue::value(JSC::ExecState& state) const
 {
-    if (exec && m_platformValue)
-        return m_platformValue->deserialize(exec);
+    if (m_platformValue)
+        return m_platformValue->deserialize(&state);
 
     if (m_value)
         return m_value;
@@ -175,7 +167,7 @@ JSC::JSValue DataCue::value(JSC::ExecState* exec) const
     return JSC::jsNull();
 }
 
-void DataCue::setValue(JSC::ExecState*, JSC::JSValue value)
+void DataCue::setValue(JSC::ExecState&, JSC::JSValue value)
 {
     // FIXME: this should use a SerializedScriptValue.
     if (m_value)
@@ -187,7 +179,14 @@ void DataCue::setValue(JSC::ExecState*, JSC::JSValue value)
     m_platformValue = nullptr;
     m_data = nullptr;
 }
-#endif
+
+JSValue DataCue::valueOrNull() const
+{
+    if (m_value)
+        return m_value;
+
+    return jsNull();
+}
 
 } // namespace WebCore
 
index 0c867fa..ea32bcc 100644 (file)
 
 #if ENABLE(VIDEO_TRACK)
 
+#include "SerializedPlatformRepresentation.h"
 #include "TextTrackCue.h"
 #include <runtime/ArrayBuffer.h>
-#include <runtime/JSCInlines.h>
+#include <runtime/JSCJSValue.h>
 #include <wtf/MediaTime.h>
 
-#if ENABLE(DATACUE_VALUE)
-#include "SerializedPlatformRepresentation.h"
-#endif
-
 namespace WebCore {
 
 class ScriptExecutionContext;
@@ -58,53 +55,50 @@ public:
         return adoptRef(*new DataCue(context, start, end, data, type));
     }
 
-#if ENABLE(DATACUE_VALUE)
     static Ref<DataCue> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, RefPtr<SerializedPlatformRepresentation>&& platformValue, const String& type)
     {
         return adoptRef(*new DataCue(context, start, end, WTFMove(platformValue), type));
     }
 
-    static Ref<DataCue> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, JSC::JSValue value, const String& type)
+    static Ref<DataCue> create(ScriptExecutionContext& context, double start, double end, ArrayBuffer& data)
     {
-        return adoptRef(*new DataCue(context, start, end, value, type));
+        return adoptRef(*new DataCue(context, MediaTime::createWithDouble(start), MediaTime::createWithDouble(end), data, emptyString()));
+    }
+    static Ref<DataCue> create(ScriptExecutionContext& context, double start, double end, JSC::JSValue value, const String& type)
+    {
+        return adoptRef(*new DataCue(context, MediaTime::createWithDouble(start), MediaTime::createWithDouble(end), value, type));
     }
-#endif
 
     virtual ~DataCue();
     CueType cueType() const override { return Data; }
 
-    RefPtr<ArrayBuffer> data() const;
-    void setData(ArrayBuffer&);
+    RefPtr<JSC::ArrayBuffer> data() const;
+    void setData(JSC::ArrayBuffer&);
 
-#if ENABLE(DATACUE_VALUE)
     const SerializedPlatformRepresentation* platformValue() const { return m_platformValue.get(); }
 
-    JSC::JSValue value(JSC::ExecState*) const;
-    void setValue(JSC::ExecState*, JSC::JSValue);
+    JSC::JSValue value(JSC::ExecState&) const;
+    void setValue(JSC::ExecState&, JSC::JSValue);
 
     String type() const { return m_type; }
     void setType(const String& type) { m_type = type; }
-#endif
 
     bool isEqual(const TextTrackCue&, CueMatchRules) const override;
     bool cueContentsMatch(const TextTrackCue&) const override;
     bool doesExtendCue(const TextTrackCue&) const override;
 
-protected:
+private:
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, ArrayBuffer&, const String&);
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const void*, unsigned);
-#if ENABLE(DATACUE_VALUE)
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, RefPtr<SerializedPlatformRepresentation>&&, const String&);
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, JSC::JSValue, const String&);
-#endif
 
-private:
+    JSC::JSValue valueOrNull() const;
+
     RefPtr<ArrayBuffer> m_data;
     String m_type;
-#if ENABLE(DATACUE_VALUE)
     RefPtr<SerializedPlatformRepresentation> m_platformValue;
     JSC::JSValue m_value;
-#endif
 };
 
 DataCue* toDataCue(TextTrackCue*);
index 358f7a7..3ebc041 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
+
 [
     Conditional=VIDEO_TRACK,
-    CustomConstructor,
-#if defined(ENABLE_DATACUE_VALUE) && ENABLE_DATACUE_VALUE
-    CustomConstructor(unrestricted double startTime, unrestricted double endTime, any value, optional DOMString type),
-    InterfaceName=WebKitDataCue,
-#else
-    CustomConstructor(unrestricted double startTime, unrestricted double endTime, ArrayBuffer data),
-#endif
-    ConstructorMayThrowException,
+    Constructor(unrestricted double startTime, unrestricted double endTime, ArrayBuffer data),
+    Constructor(unrestricted double startTime, unrestricted double endTime, any value, optional DOMString type),
+    ConstructorCallWith=ScriptExecutionContext
 ] interface DataCue : TextTrackCue {
     attribute ArrayBuffer data;
 
-#if defined(ENABLE_DATACUE_VALUE) && ENABLE_DATACUE_VALUE
-    [CustomGetter, CustomSetter] attribute any value;
+    // Proposed extensions.
+    [CallWith=ScriptState] attribute any value;
     readonly attribute DOMString type;
-#endif
 };
index e257026..b7beb6d 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef SerializedPlatformRepresentation_h
-#define SerializedPlatformRepresentation_h
+#pragma once
 
-#if ENABLE(VIDEO) && ENABLE(DATACUE_VALUE)
+#if ENABLE(VIDEO)
 
 #include <runtime/JSCInlines.h>
 #include <wtf/RefCounted.h>
@@ -38,7 +37,7 @@ public:
     virtual ~SerializedPlatformRepresentation() { }
 
     virtual JSC::JSValue deserialize(JSC::ExecState*) const = 0;
-    virtual RefPtr<ArrayBuffer> data() const = 0;
+    virtual RefPtr<JSC::ArrayBuffer> data() const = 0;
     virtual bool isEqual(const SerializedPlatformRepresentation&) const = 0;
 
     enum PlatformType {
@@ -53,5 +52,3 @@ protected:
 } // namespace WebCore
 
 #endif
-#endif // SerializedPlatformRepresentation_h
-