Changeset 207462 in webkit
- Timestamp:
- Oct 18, 2016 6:15:40 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207460 r207462 1 2016-10-18 Zan Dobersek <zdobersek@igalia.com> 2 3 [WebIDL] Support BufferSource 4 https://bugs.webkit.org/show_bug.cgi?id=163541 5 6 Reviewed by Youenn Fablet. 7 8 Add support for the BufferSource typedef in WebIDL. The implementation 9 adds the necessary handling for this type in the generator scripts and 10 the specialization of the Converter<> template for the IDLBufferSource 11 struct that enables exposing ArrayBuffer or ArrayBufferView objects by 12 having WebCore::BufferSource objects pointing to their data. 13 14 The SourceBuffer interface in the MSE module has the appendBuffer() 15 operation modified to accept a BufferSource parameter, instead of 16 overloading it for ArrayBuffer and ArrayBufferView parameters. 17 18 The bindings generator tests cover BufferSource as both an operation 19 parameter and as a dictionary member. 20 21 * Modules/mediasource/SourceBuffer.cpp: 22 (WebCore::SourceBuffer::appendBuffer): 23 (WebCore::SourceBuffer::appendBufferInternal): 24 * Modules/mediasource/SourceBuffer.h: 25 * Modules/mediasource/SourceBuffer.idl: 26 * WebCore.xcodeproj/project.pbxproj: 27 * bindings/generic/IDLTypes.h: 28 * bindings/js/BufferSource.h: Added. 29 * bindings/js/JSDOMConvert.h: 30 (WebCore::Converter<IDLBufferSource>::convert): 31 * bindings/scripts/CodeGenerator.pm: 32 (SkipIncludeHeader): 33 (IsWrapperType): 34 * bindings/scripts/CodeGeneratorJS.pm: 35 (AddClassForwardIfNeeded): 36 (GetBaseIDLType): 37 (IsHandledByDOMConvert): 38 * bindings/scripts/test/JS/JSTestObj.cpp: 39 (WebCore::convertDictionary<TestObj::Dictionary>): 40 (WebCore::jsTestObjPrototypeFunctionBufferSourceParameter): 41 (WebCore::jsTestObjPrototypeFunctionBufferSourceParameterCaller): 42 * bindings/scripts/test/TestObj.idl: 43 1 44 2016-10-18 Javier Fernandez <jfernandez@igalia.com> 2 45 -
trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp
r207294 r207462 36 36 37 37 #include "AudioTrackList.h" 38 #include "BufferSource.h" 38 39 #include "Event.h" 39 40 #include "EventNames.h" … … 232 233 } 233 234 234 235 ExceptionOr<void> SourceBuffer::appendBuffer(ArrayBuffer& data) 236 { 237 return appendBufferInternal(static_cast<unsigned char*>(data.data()), data.byteLength()); 238 } 239 240 ExceptionOr<void> SourceBuffer::appendBuffer(ArrayBufferView& data) 241 { 242 return appendBufferInternal(static_cast<unsigned char*>(data.baseAddress()), data.byteLength()); 235 ExceptionOr<void> SourceBuffer::appendBuffer(const BufferSource& data) 236 { 237 return appendBufferInternal(static_cast<const unsigned char*>(data.data), data.length); 243 238 } 244 239 … … 497 492 } 498 493 499 ExceptionOr<void> SourceBuffer::appendBufferInternal( unsigned char* data, unsigned size)494 ExceptionOr<void> SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size) 500 495 { 501 496 // Section 3.2 appendBuffer() -
trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h
r207007 r207462 48 48 49 49 class AudioTrackList; 50 class BufferSource; 50 51 class MediaSource; 51 52 class PlatformTimeRanges; … … 75 76 ExceptionOr<void> setAppendWindowEnd(double); 76 77 77 ExceptionOr<void> appendBuffer(ArrayBuffer&); 78 ExceptionOr<void> appendBuffer(ArrayBufferView&); 78 ExceptionOr<void> appendBuffer(const BufferSource&); 79 79 ExceptionOr<void> abort(); 80 80 ExceptionOr<void> remove(double start, double end); … … 151 151 void scheduleEvent(const AtomicString& eventName); 152 152 153 ExceptionOr<void> appendBufferInternal( unsigned char*, unsigned);153 ExceptionOr<void> appendBufferInternal(const unsigned char*, unsigned); 154 154 void appendBufferTimerFired(); 155 155 void resetParserState(); -
trunk/Source/WebCore/Modules/mediasource/SourceBuffer.idl
r207007 r207462 58 58 59 59 // Append segment data. 60 [MayThrowException] void appendBuffer(ArrayBuffer data); 61 [MayThrowException] void appendBuffer(ArrayBufferView data); 60 [MayThrowException] void appendBuffer(BufferSource data); 62 61 63 62 // Abort the current segment append sequence. -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207458 r207462 1257 1257 2DF512CD1D873E47001D6780 /* ReplaceRangeWithTextCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DF512CB1D873E47001D6780 /* ReplaceRangeWithTextCommand.cpp */; }; 1258 1258 2DF512CE1D873E47001D6780 /* ReplaceRangeWithTextCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DF512CC1D873E47001D6780 /* ReplaceRangeWithTextCommand.h */; }; 1259 2DFA488F1DB541D000362B99 /* BufferSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DFA488E1DB541C200362B99 /* BufferSource.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1259 1260 2E0888D41148848A00AF4265 /* JSDOMFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */; }; 1260 1261 2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E0888D31148848A00AF4265 /* JSDOMFormData.h */; }; … … 5975 5976 E125F83D182411E700D84CD9 /* JSCryptoOperationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F83B182411E700D84CD9 /* JSCryptoOperationData.cpp */; }; 5976 5977 E125F83E182411E700D84CD9 /* JSCryptoOperationData.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F83C182411E700D84CD9 /* JSCryptoOperationData.h */; }; 5978 5977 5979 E125F8411824253A00D84CD9 /* CryptoAlgorithmAES_CBC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F83F1824253A00D84CD9 /* CryptoAlgorithmAES_CBC.cpp */; }; 5978 5980 E125F8421824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F8401824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h */; }; … … 8236 8238 2DF512CB1D873E47001D6780 /* ReplaceRangeWithTextCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReplaceRangeWithTextCommand.cpp; sourceTree = "<group>"; }; 8237 8239 2DF512CC1D873E47001D6780 /* ReplaceRangeWithTextCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReplaceRangeWithTextCommand.h; sourceTree = "<group>"; }; 8240 2DFA488E1DB541C200362B99 /* BufferSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BufferSource.h; sourceTree = "<group>"; }; 8238 8241 2E0888C3114883A900AF4265 /* DOMFormData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMFormData.idl; sourceTree = "<group>"; }; 8239 8242 2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMFormData.cpp; sourceTree = "<group>"; }; … … 21416 21419 49B3760A15C6C6840059131D /* ArrayValue.cpp */, 21417 21420 49B3760B15C6C6840059131D /* ArrayValue.h */, 21421 2DFA488E1DB541C200362B99 /* BufferSource.h */, 21418 21422 BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */, 21419 21423 93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */, … … 26799 26803 9391A991162746CB00297330 /* ScrollingCoordinatorMac.h in Headers */, 26800 26804 93C38BFF164473C700091EB2 /* ScrollingStateFixedNode.h in Headers */, 26805 2DFA488F1DB541D000362B99 /* BufferSource.h in Headers */, 26801 26806 0FEA3E7B191B2FC5000F1B55 /* ScrollingStateFrameScrollingNode.h in Headers */, 26802 26807 931CBD0D161A44E900E4C874 /* ScrollingStateNode.h in Headers */, -
trunk/Source/WebCore/bindings/generic/IDLTypes.h
r207381 r207462 36 36 namespace WebCore { 37 37 38 class BufferSource; 38 39 template <typename Value> class DOMPromise; 39 40 … … 119 120 }; 120 121 122 struct IDLBufferSource : IDLType<BufferSource> { }; 121 123 122 124 // Helper predicates -
trunk/Source/WebCore/bindings/js/JSDOMConvert.h
r207381 r207462 26 26 #pragma once 27 27 28 #include "BufferSource.h" 28 29 #include "IDLTypes.h" 29 30 #include "JSDOMBinding.h" … … 639 640 } 640 641 642 // MARK: - 643 // MARK: BufferSource type 644 645 template<> struct Converter<IDLBufferSource> : DefaultConverter<IDLBufferSource> { 646 using ReturnType = BufferSource; 647 648 static ReturnType convert(JSC::ExecState& state, JSC::JSValue value) 649 { 650 JSC::VM& vm = state.vm(); 651 auto scope = DECLARE_THROW_SCOPE(vm); 652 653 if (JSC::ArrayBuffer* buffer = JSC::toArrayBuffer(value)) 654 return { static_cast<uint8_t*>(buffer->data()), buffer->byteLength() }; 655 if (RefPtr<JSC::ArrayBufferView> bufferView = toArrayBufferView(value)) 656 return { static_cast<uint8_t*>(bufferView->baseAddress()), bufferView->byteLength() }; 657 658 throwTypeError(&state, scope, ASCIILiteral("Only ArrayBuffer and ArrayBufferView objects can be passed as BufferSource arguments")); 659 return { nullptr, 0 }; 660 } 661 }; 662 641 663 } // namespace WebCore -
trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm
r207302 r207462 372 372 return 1 if $object->IsTypedArrayType($type); 373 373 return 1 if $type eq "Array"; 374 return 1 if $type eq "BufferSource"; 374 375 return 1 if $type eq "DOMString" or $type eq "USVString"; 375 376 return 1 if $type eq "DOMTimeStamp"; … … 867 868 return 0 if !$object->IsRefPtrType($type); 868 869 return 0 if $object->IsTypedArrayType($type); 870 return 0 if $type eq "BufferSource"; 869 871 return 0 if $type eq "UNION"; 870 872 return 0 if $webCoreTypeHash{$type}; -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207417 r207462 320 320 # SVGAnimatedLength/Number/etc. are not classes so they can't be forward declared as classes. 321 321 return if $codeGenerator->IsSVGAnimatedType($interfaceName); 322 322 323 return if $codeGenerator->IsTypedArrayType($interfaceName); 324 return if $interfaceName eq "BufferSource"; 323 325 324 326 push(@headerContent, "class $interfaceName;\n\n"); … … 4994 4996 return "IDLFrozenArray<" . GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $codeGenerator->IsFrozenArrayType($idlType->name); 4995 4997 return "IDLUnion<" . join(", ", GetIDLUnionMemberTypes($interface, $idlType)) . ">" if $idlType->isUnion; 4998 return "IDLBufferSource" if $idlType->name eq "BufferSource"; 4996 4999 return "IDLInterface<" . $idlType->name . ">"; 4997 5000 } … … 5115 5118 5116 5119 return 1 if $idlType->isUnion; 5120 return 1 if $idlType->name eq "BufferSource"; 5117 5121 return 1 if $idlType->name eq "any"; 5118 5122 return 1 if $idlType->name eq "boolean"; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r207381 r207462 502 502 if (!booleanWithoutDefaultValue.isUndefined()) { 503 503 result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue); 504 RETURN_IF_EXCEPTION(throwScope, Nullopt); 505 } 506 JSValue bufferSourceValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "bufferSourceValue")); 507 if (!bufferSourceValueValue.isUndefined()) { 508 result.bufferSourceValue = convert<IDLBufferSource>(state, bufferSourceValueValue); 504 509 RETURN_IF_EXCEPTION(throwScope, Nullopt); 505 510 } … … 994 999 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAttachShadowRoot(JSC::ExecState*); 995 1000 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOperationWithExternalDictionaryParameter(JSC::ExecState*); 1001 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionBufferSourceParameter(JSC::ExecState*); 996 1002 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToString(JSC::ExecState*); 997 1003 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToJSON(JSC::ExecState*); … … 1605 1611 { "attachShadowRoot", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAttachShadowRoot), (intptr_t) (1) } }, 1606 1612 { "operationWithExternalDictionaryParameter", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOperationWithExternalDictionaryParameter), (intptr_t) (1) } }, 1613 { "bufferSourceParameter", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionBufferSourceParameter), (intptr_t) (1) } }, 1607 1614 { "toString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionToString), (intptr_t) (0) } }, 1608 1615 { "toJSON", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionToJSON), (intptr_t) (0) } }, … … 7730 7737 } 7731 7738 7739 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionBufferSourceParameterCaller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&); 7740 7741 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionBufferSourceParameter(ExecState* state) 7742 { 7743 return BindingCaller<JSTestObj>::callOperation<jsTestObjPrototypeFunctionBufferSourceParameterCaller>(state, "bufferSourceParameter"); 7744 } 7745 7746 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionBufferSourceParameterCaller(JSC::ExecState* state, JSTestObj* castedThis, JSC::ThrowScope& throwScope) 7747 { 7748 UNUSED_PARAM(state); 7749 UNUSED_PARAM(throwScope); 7750 auto& impl = castedThis->wrapped(); 7751 if (UNLIKELY(state->argumentCount() < 1)) 7752 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); 7753 auto data = convert<IDLBufferSource>(*state, state->uncheckedArgument(0)); 7754 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7755 impl.bufferSourceParameter(WTFMove(data)); 7756 return JSValue::encode(jsUndefined()); 7757 } 7758 7732 7759 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionToStringCaller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&); 7733 7760 -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r207381 r207462 416 416 417 417 serializer = {create, readOnlyStringAttr, enumAttr, longAttr}; 418 419 void bufferSourceParameter(BufferSource data); 418 420 }; 419 421 … … 461 463 (long or Node) unionMember; 462 464 (long or Node)? nullableUnionMember = null; 465 BufferSource bufferSourceValue; 463 466 }; 464 467
Note: See TracChangeset
for help on using the changeset viewer.