Next batch of conversions to use C++ enum class instead of strings for enumerations
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Apr 2016 19:16:00 +0000 (19:16 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Apr 2016 19:16:00 +0000 (19:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157232

Reviewed by Chris Dumez.

Source/WebCore:

* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::error): Use ResponseType.
(WebCore::FetchResponse::redirect): Ditto.
(WebCore::FetchResponse::FetchResponse): Ditto.
(WebCore::FetchResponse::clone): Ditto.
(WebCore::FetchResponse::type): Return ResponseType.
(WebCore::FetchResponse::startFetching): Use auto.
* Modules/fetch/FetchResponse.h: Added ResponseType and used it for the return value
of the type function, and also to replace FetchResponse::Type.

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::externalDeviceType): Return DeviceType.
* Modules/mediacontrols/MediaControlsHost.h: Added DeviceType and use it for the
return value for the externalDeviceType function.

* Modules/mediasession/MediaSession.cpp:
(WebCore::MediaSession::parseKind): Deleted.
(WebCore::MediaSession::MediaSession): Use MediaSessionKind.
(WebCore::MediaSession::kind): Deleted.
* Modules/mediasession/MediaSession.h: Added MediaSessionKind and use it as the
argument to MediaSession::create and the return type for the kind function.
Probably didn't get this 100% right because this code does not seem to be compiled.
* Modules/mediasession/MediaSession.idl: Added default value for kind, as specified
in the current version of the specification for this class.
* Modules/mediasession/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::didReceiveStartOfInterruptionNotification):
Tried to update for changes above.
(WebCore::MediaSessionManager::didReceiveEndOfInterruptionNotification): Ditto.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::endOfStream): Changed to take Optional<EndOfStreamError>
instead of overloading and taking const AtomicString&.
(WebCore::MediaSource::streamEndedWithError): Ditto. Also removed exception code.
(WebCore::MediaSource::addSourceBuffer): Updated to use EndOfStreamError. Also
used an if statement.
(WebCore::MediaSource::sourceBufferDidChangeActiveState): Updated to take a reference
instead of a pointer.
* Modules/mediasource/MediaSource.h: Added EndOfStreamError and changed as above.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::segmentsKeyword): Deleted.
(WebCore::SourceBuffer::sequenceKeyword): Deleted.
(WebCore::SourceBuffer::TrackBuffer::TrackBuffer): Initialize booleans where they are
defined rather than in this constructor.
(WebCore::SourceBuffer::create): Use Ref instead of RefPtr.
(WebCore::SourceBuffer::SourceBuffer): Initialize many data members where they are
defined rather than in this constructor.
(WebCore::SourceBuffer::setTimestampOffset): Use AppendMode.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveRenderingError): Ditto.
(WebCore::SourceBuffer::decodeError): Deleted.
(WebCore::SourceBuffer::networkError): Deleted.
(WebCore::SourceBuffer::setActive): Pass reference instead of pointer.
(WebCore::SourceBuffer::sourceBufferPrivateDidEndStream): Deleted. No callers.
(WebCore::SourceBuffer::appendError): Use AppendMode.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Ditto.
(WebCore::SourceBuffer::setMode): Take AppendMode.
* Modules/mediasource/SourceBuffer.h: Added AppendMode, removed various string
constant functions, initialize more data emebers in this header. Removed unused
sourceBufferPrivateDidEndStream function.

* Modules/mediastream/MediaDeviceInfo.cpp:
(WebCore::MediaDeviceInfo::MediaDeviceInfo): Take MediaDeviceKind instead of string.
(WebCore::MediaDeviceInfo::create): Ditto.
(WebCore::MediaDeviceInfo::audioInputType): Deleted.
(WebCore::MediaDeviceInfo::audioOutputType): Deleted.
(WebCore::MediaDeviceInfo::videoInputType): Deleted.
* Modules/mediastream/MediaDeviceInfo.h: Aedded MediaDeviceKind and used it.
* Modules/mediastream/MediaDeviceInfo.idl: Changed type of the kind attribute
to be MediaDeviceKind as in the specification.

* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): Fix loop to not
churn the reference countds. Also updated to use String instead of AtomicString for
label, and MediaDeviceKind instead of string for kind.

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::readyState): Return MediaStreamTrackState.
* Modules/mediastream/MediaStreamTrack.h: Added MediaStreamTrackState and used it
for the return value from the readyState function.

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::state): Return AudioContextState.
* Modules/webaudio/AudioContext.h: Added AudioContextState and used it.

* Modules/webaudio/WaveShaperNode.cpp:
(WebCore::processorType): Added.
(WebCore::WaveShaperNode::setOversample): Take OverSampletype instead of a string.
(WebCore::WaveShaperNode::oversample): Return OverSampleType.
* Modules/webaudio/WaveShaperNode.h: Added OverSampleType and used it.
* Modules/webaudio/WaveShaperNode.idl: Removed unneeded [SetterRaisesException].

* bindings/scripts/CodeGenerator.pm: Removed special cases for 18 enumerations that
either don't exist or were converted to no longer pass strings in to the C++ DOM.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeaderContentHeader): Use #pragma once instead of header guards.
(GetEnumerationValueName): Added logic to handle names with "-" and starting with
a numeric digit.
(GetEnumerationImplementationContent): Changed functions so they do more of the
binding work. Added JSValueTraits specialization so we can generate bindings for
a vector of any enumeration. Added special cases for null string. Removed special
case to keep the style checker happy.
(GenerateHeader): Removed the #endif that matched the header guards in
GenerateHeaderContentHeader.
(GenerateImplementation): Use the $type local variable rather than writing out
$attribute->signature->type or $attributeType. Fixed code path that checks for
valid enumeration values to work for non-string-based enumerations.
(CanUseWTFOptionalForParameter): Turn this function off for the new enumerations.
For now, leave it on for the old string-based enumerations.
(GenerateParametersCheck): Added appropriate parameter checking for the new
enumerations.
(GenerateCallbackHeader): Removed the #endif that matched the header guards in
GenerateHeaderContentHeader.
(GetNativeType): Use "auto" instead of the enumeration name in generated code.
(JSValueToNative): Updated since the name of enumerationValueMyEnum was changed
to parseMyEnum.
(NativeToJSValue): Took out call to stringValue, since we now overload the
jsStringWithCache function instead.

* bindings/scripts/test/JS/JSTestActiveDOMObject.h:
* bindings/scripts/test/JS/JSTestCallback.h:
* bindings/scripts/test/JS/JSTestCallbackFunction.h:
* bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h:
* bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h:
* bindings/scripts/test/JS/JSTestCustomNamedGetter.h:
* bindings/scripts/test/JS/JSTestEventConstructor.h:
* bindings/scripts/test/JS/JSTestEventTarget.h:
* bindings/scripts/test/JS/JSTestException.h:
* bindings/scripts/test/JS/JSTestGenerateIsReachable.h:
* bindings/scripts/test/JS/JSTestGlobalObject.h:
* bindings/scripts/test/JS/JSTestInterface.h:
* bindings/scripts/test/JS/JSTestJSBuiltinConstructor.h:
* bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
* bindings/scripts/test/JS/JSTestNamedConstructor.h:
* bindings/scripts/test/JS/JSTestNode.h:
* bindings/scripts/test/JS/JSTestNondeterministic.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/JS/JSTestOverloadedConstructors.h:
* bindings/scripts/test/JS/JSTestOverrideBuiltins.h:
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
* bindings/scripts/test/JS/JSTestTypedefs.h:
* bindings/scripts/test/JS/JSattribute.h:
* bindings/scripts/test/JS/JSreadonly.h:
Regenerated.

* crypto/CryptoKey.cpp:
(WebCore::CryptoKey::type): Use CryptoKeyType.
(WebCore::CryptoKey::usages): Use KeyUsage.
* crypto/CryptoKey.h: Added KeyUsage and use CryptoKeyType.

* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::status): Use FontFaceSetLoadStatus.
* css/FontFaceSet.h: Added FontFaceSetLoadStatus and used it.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::playInternal): Use kind instead of kindEnum.

* html/HTMLVideoElement.cpp:
(WebCore::presentationModeFullscreen): Deleted.
(WebCore::presentationModePictureInPicture): Deleted.
(WebCore::presentationModeInline): Deleted.
(WebCore::HTMLVideoElement::webkitSupportsPresentationMode): Use VideoPresentationMode.
(WebCore::toFullscreenMode): Ditto.
(WebCore::HTMLVideoElement::webkitSetPresentationMode): Ditto.
(WebCore::toPresentationMode): Ditto.
(WebCore::HTMLVideoElement::webkitPresentationMode): Ditto.
* html/HTMLVideoElement.h: Added VideoPresentationMode and used it.

* html/canvas/CanvasRenderingContext2D.cpp: Tweaked formatting. Changed
DefaultSmoothingQuality macro to a constant.
(WebCore::toWindRule): Replaces parseWinding.
(WebCore::CanvasRenderingContext2D::fill): Use CanvasWindingRule instead of string.
(WebCore::CanvasRenderingContext2D::clip): Ditto.
(WebCore::CanvasRenderingContext2D::fillInternal): Ditto.
(WebCore::CanvasRenderingContext2D::clipInternal): Ditto.
(WebCore::CanvasRenderingContext2D::isPointInPath): Ditto.
(WebCore::CanvasRenderingContext2D::isPointInStroke): Ditto.
(WebCore::CanvasRenderingContext2D::isPointInPathInternal): Ditto.
(WebCore::smoothingToInterpolationQuality): Ditto.
(WebCore::CanvasRenderingContext2D::imageSmoothingQuality): Ditto.
(WebCore::CanvasRenderingContext2D::setImageSmoothingQuality): Ditto.
* html/canvas/CanvasRenderingContext2D.h: Added CanvasWindingRule and
ImageSmoothingQuality, and use them throughout the class.

* platform/graphics/SourceBufferPrivateClient.h: Removed unused
sourceBufferPrivateDidEndStream function.

Tools:

* Scripts/webkitpy/style/checker.py: Skip the bindings script tests when doing style
checking. We don't want to waste time trying to make our generated code match our style.

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

64 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
Source/WebCore/Modules/mediacontrols/MediaControlsHost.h
Source/WebCore/Modules/mediasession/MediaSession.cpp
Source/WebCore/Modules/mediasession/MediaSession.h
Source/WebCore/Modules/mediasession/MediaSession.idl
Source/WebCore/Modules/mediasession/MediaSessionManager.cpp
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/MediaSource.h
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/Modules/mediastream/MediaDeviceInfo.cpp
Source/WebCore/Modules/mediastream/MediaDeviceInfo.h
Source/WebCore/Modules/mediastream/MediaDeviceInfo.idl
Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/Modules/webaudio/WaveShaperNode.cpp
Source/WebCore/Modules/webaudio/WaveShaperNode.h
Source/WebCore/Modules/webaudio/WaveShaperNode.idl
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.h
Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h
Source/WebCore/bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h
Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h
Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.h
Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h
Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h
Source/WebCore/bindings/scripts/test/JS/JSTestException.h
Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.h
Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.h
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h
Source/WebCore/bindings/scripts/test/JS/JSTestJSBuiltinConstructor.h
Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h
Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.h
Source/WebCore/bindings/scripts/test/JS/JSTestNode.h
Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.h
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.h
Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.h
Source/WebCore/bindings/scripts/test/JS/JSattribute.h
Source/WebCore/bindings/scripts/test/JS/JSreadonly.h
Source/WebCore/crypto/CryptoKey.cpp
Source/WebCore/crypto/CryptoKey.h
Source/WebCore/css/FontFaceSet.cpp
Source/WebCore/css/FontFaceSet.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/html/HTMLVideoElement.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.h
Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm
Source/WebCore/platform/graphics/SourceBufferPrivateClient.h
Tools/ChangeLog
Tools/Scripts/webkitpy/style/checker.py

index 51bef76..76e22c2 100644 (file)
@@ -1,3 +1,198 @@
+2016-04-30  Darin Adler  <darin@apple.com>
+
+        Next batch of conversions to use C++ enum class instead of strings for enumerations
+        https://bugs.webkit.org/show_bug.cgi?id=157232
+
+        Reviewed by Chris Dumez.
+
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::error): Use ResponseType.
+        (WebCore::FetchResponse::redirect): Ditto.
+        (WebCore::FetchResponse::FetchResponse): Ditto.
+        (WebCore::FetchResponse::clone): Ditto.
+        (WebCore::FetchResponse::type): Return ResponseType.
+        (WebCore::FetchResponse::startFetching): Use auto.
+        * Modules/fetch/FetchResponse.h: Added ResponseType and used it for the return value
+        of the type function, and also to replace FetchResponse::Type.
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsHost::externalDeviceType): Return DeviceType.
+        * Modules/mediacontrols/MediaControlsHost.h: Added DeviceType and use it for the
+        return value for the externalDeviceType function.
+
+        * Modules/mediasession/MediaSession.cpp:
+        (WebCore::MediaSession::parseKind): Deleted.
+        (WebCore::MediaSession::MediaSession): Use MediaSessionKind.
+        (WebCore::MediaSession::kind): Deleted.
+        * Modules/mediasession/MediaSession.h: Added MediaSessionKind and use it as the
+        argument to MediaSession::create and the return type for the kind function.
+        Probably didn't get this 100% right because this code does not seem to be compiled.
+        * Modules/mediasession/MediaSession.idl: Added default value for kind, as specified
+        in the current version of the specification for this class.
+        * Modules/mediasession/MediaSessionManager.cpp:
+        (WebCore::MediaSessionManager::didReceiveStartOfInterruptionNotification):
+        Tried to update for changes above.
+        (WebCore::MediaSessionManager::didReceiveEndOfInterruptionNotification): Ditto.
+
+        * Modules/mediasource/MediaSource.cpp:
+        (WebCore::MediaSource::endOfStream): Changed to take Optional<EndOfStreamError>
+        instead of overloading and taking const AtomicString&.
+        (WebCore::MediaSource::streamEndedWithError): Ditto. Also removed exception code.
+        (WebCore::MediaSource::addSourceBuffer): Updated to use EndOfStreamError. Also
+        used an if statement.
+        (WebCore::MediaSource::sourceBufferDidChangeActiveState): Updated to take a reference
+        instead of a pointer.
+        * Modules/mediasource/MediaSource.h: Added EndOfStreamError and changed as above.
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::segmentsKeyword): Deleted.
+        (WebCore::SourceBuffer::sequenceKeyword): Deleted.
+        (WebCore::SourceBuffer::TrackBuffer::TrackBuffer): Initialize booleans where they are
+        defined rather than in this constructor.
+        (WebCore::SourceBuffer::create): Use Ref instead of RefPtr.
+        (WebCore::SourceBuffer::SourceBuffer): Initialize many data members where they are
+        defined rather than in this constructor.
+        (WebCore::SourceBuffer::setTimestampOffset): Use AppendMode.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveRenderingError): Ditto.
+        (WebCore::SourceBuffer::decodeError): Deleted.
+        (WebCore::SourceBuffer::networkError): Deleted.
+        (WebCore::SourceBuffer::setActive): Pass reference instead of pointer.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidEndStream): Deleted. No callers.
+        (WebCore::SourceBuffer::appendError): Use AppendMode.
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Ditto.
+        (WebCore::SourceBuffer::setMode): Take AppendMode.
+        * Modules/mediasource/SourceBuffer.h: Added AppendMode, removed various string
+        constant functions, initialize more data emebers in this header. Removed unused
+        sourceBufferPrivateDidEndStream function.
+
+        * Modules/mediastream/MediaDeviceInfo.cpp:
+        (WebCore::MediaDeviceInfo::MediaDeviceInfo): Take MediaDeviceKind instead of string.
+        (WebCore::MediaDeviceInfo::create): Ditto.
+        (WebCore::MediaDeviceInfo::audioInputType): Deleted.
+        (WebCore::MediaDeviceInfo::audioOutputType): Deleted.
+        (WebCore::MediaDeviceInfo::videoInputType): Deleted.
+        * Modules/mediastream/MediaDeviceInfo.h: Aedded MediaDeviceKind and used it.
+        * Modules/mediastream/MediaDeviceInfo.idl: Changed type of the kind attribute
+        to be MediaDeviceKind as in the specification.
+
+        * Modules/mediastream/MediaDevicesRequest.cpp:
+        (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): Fix loop to not
+        churn the reference countds. Also updated to use String instead of AtomicString for
+        label, and MediaDeviceKind instead of string for kind.
+
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::readyState): Return MediaStreamTrackState.
+        * Modules/mediastream/MediaStreamTrack.h: Added MediaStreamTrackState and used it
+        for the return value from the readyState function.
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::state): Return AudioContextState.
+        * Modules/webaudio/AudioContext.h: Added AudioContextState and used it.
+
+        * Modules/webaudio/WaveShaperNode.cpp:
+        (WebCore::processorType): Added.
+        (WebCore::WaveShaperNode::setOversample): Take OverSampletype instead of a string.
+        (WebCore::WaveShaperNode::oversample): Return OverSampleType.
+        * Modules/webaudio/WaveShaperNode.h: Added OverSampleType and used it.
+        * Modules/webaudio/WaveShaperNode.idl: Removed unneeded [SetterRaisesException].
+
+        * bindings/scripts/CodeGenerator.pm: Removed special cases for 18 enumerations that
+        either don't exist or were converted to no longer pass strings in to the C++ DOM.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeaderContentHeader): Use #pragma once instead of header guards.
+        (GetEnumerationValueName): Added logic to handle names with "-" and starting with
+        a numeric digit.
+        (GetEnumerationImplementationContent): Changed functions so they do more of the
+        binding work. Added JSValueTraits specialization so we can generate bindings for
+        a vector of any enumeration. Added special cases for null string. Removed special
+        case to keep the style checker happy.
+        (GenerateHeader): Removed the #endif that matched the header guards in
+        GenerateHeaderContentHeader.
+        (GenerateImplementation): Use the $type local variable rather than writing out
+        $attribute->signature->type or $attributeType. Fixed code path that checks for
+        valid enumeration values to work for non-string-based enumerations.
+        (CanUseWTFOptionalForParameter): Turn this function off for the new enumerations.
+        For now, leave it on for the old string-based enumerations.
+        (GenerateParametersCheck): Added appropriate parameter checking for the new
+        enumerations.
+        (GenerateCallbackHeader): Removed the #endif that matched the header guards in
+        GenerateHeaderContentHeader.
+        (GetNativeType): Use "auto" instead of the enumeration name in generated code.
+        (JSValueToNative): Updated since the name of enumerationValueMyEnum was changed
+        to parseMyEnum.
+        (NativeToJSValue): Took out call to stringValue, since we now overload the
+        jsStringWithCache function instead.
+
+        * bindings/scripts/test/JS/JSTestActiveDOMObject.h:
+        * bindings/scripts/test/JS/JSTestCallback.h:
+        * bindings/scripts/test/JS/JSTestCallbackFunction.h:
+        * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h:
+        * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h:
+        * bindings/scripts/test/JS/JSTestCustomNamedGetter.h:
+        * bindings/scripts/test/JS/JSTestEventConstructor.h:
+        * bindings/scripts/test/JS/JSTestEventTarget.h:
+        * bindings/scripts/test/JS/JSTestException.h:
+        * bindings/scripts/test/JS/JSTestGenerateIsReachable.h:
+        * bindings/scripts/test/JS/JSTestGlobalObject.h:
+        * bindings/scripts/test/JS/JSTestInterface.h:
+        * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.h:
+        * bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
+        * bindings/scripts/test/JS/JSTestNamedConstructor.h:
+        * bindings/scripts/test/JS/JSTestNode.h:
+        * bindings/scripts/test/JS/JSTestNondeterministic.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/JS/JSTestObj.h:
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.h:
+        * bindings/scripts/test/JS/JSTestOverrideBuiltins.h:
+        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
+        * bindings/scripts/test/JS/JSTestTypedefs.h:
+        * bindings/scripts/test/JS/JSattribute.h:
+        * bindings/scripts/test/JS/JSreadonly.h:
+        Regenerated.
+
+        * crypto/CryptoKey.cpp:
+        (WebCore::CryptoKey::type): Use CryptoKeyType.
+        (WebCore::CryptoKey::usages): Use KeyUsage.
+        * crypto/CryptoKey.h: Added KeyUsage and use CryptoKeyType.
+
+        * css/FontFaceSet.cpp:
+        (WebCore::FontFaceSet::status): Use FontFaceSetLoadStatus.
+        * css/FontFaceSet.h: Added FontFaceSetLoadStatus and used it.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::playInternal): Use kind instead of kindEnum.
+
+        * html/HTMLVideoElement.cpp:
+        (WebCore::presentationModeFullscreen): Deleted.
+        (WebCore::presentationModePictureInPicture): Deleted.
+        (WebCore::presentationModeInline): Deleted.
+        (WebCore::HTMLVideoElement::webkitSupportsPresentationMode): Use VideoPresentationMode.
+        (WebCore::toFullscreenMode): Ditto.
+        (WebCore::HTMLVideoElement::webkitSetPresentationMode): Ditto.
+        (WebCore::toPresentationMode): Ditto.
+        (WebCore::HTMLVideoElement::webkitPresentationMode): Ditto.
+        * html/HTMLVideoElement.h: Added VideoPresentationMode and used it.
+
+        * html/canvas/CanvasRenderingContext2D.cpp: Tweaked formatting. Changed
+        DefaultSmoothingQuality macro to a constant.
+        (WebCore::toWindRule): Replaces parseWinding.
+        (WebCore::CanvasRenderingContext2D::fill): Use CanvasWindingRule instead of string.
+        (WebCore::CanvasRenderingContext2D::clip): Ditto.
+        (WebCore::CanvasRenderingContext2D::fillInternal): Ditto.
+        (WebCore::CanvasRenderingContext2D::clipInternal): Ditto.
+        (WebCore::CanvasRenderingContext2D::isPointInPath): Ditto.
+        (WebCore::CanvasRenderingContext2D::isPointInStroke): Ditto.
+        (WebCore::CanvasRenderingContext2D::isPointInPathInternal): Ditto.
+        (WebCore::smoothingToInterpolationQuality): Ditto.
+        (WebCore::CanvasRenderingContext2D::imageSmoothingQuality): Ditto.
+        (WebCore::CanvasRenderingContext2D::setImageSmoothingQuality): Ditto.
+        * html/canvas/CanvasRenderingContext2D.h: Added CanvasWindingRule and
+        ImageSmoothingQuality, and use them throughout the class.
+
+        * platform/graphics/SourceBufferPrivateClient.h: Removed unused
+        sourceBufferPrivateDidEndStream function.
+
 2016-04-30  Nan Wang  <n_wang@apple.com>
 
         AX: @aria-label attribute should work on <label> element
         * accessibility/AccessibilityRenderObject.cpp:
         (WebCore::AccessibilityRenderObject::exposesTitleUIElement):
 
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
+        (WebCore::WebPlaybackSessionModelMediaElement::updateForEventName):
+        Use DeviceType instead of String for externalDeviceType.
+
 2016-04-29  Chris Dumez  <cdumez@apple.com>
 
         [Web IDL] Specify default parameter values for callback parameters
index 483773e..21a841f 100644 (file)
@@ -51,7 +51,7 @@ static inline bool isNullBodyStatus(int status)
 
 Ref<FetchResponse> FetchResponse::error(ScriptExecutionContext& context)
 {
-    return adoptRef(*new FetchResponse(context, Type::Error, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
+    return adoptRef(*new FetchResponse(context, ResponseType::Error, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), { }));
 }
 
 RefPtr<FetchResponse> FetchResponse::redirect(ScriptExecutionContext& context, const String& url, int status, ExceptionCode& ec)
@@ -66,10 +66,10 @@ RefPtr<FetchResponse> FetchResponse::redirect(ScriptExecutionContext& context, c
         ec = TypeError;
         return nullptr;
     }
-    RefPtr<FetchResponse> redirectResponse = adoptRef(*new FetchResponse(context, Type::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
+    auto redirectResponse = adoptRef(*new FetchResponse(context, ResponseType::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), { }));
     redirectResponse->m_response.setHTTPStatusCode(status);
     redirectResponse->m_headers->fastSet(HTTPHeaderName::Location, requestURL.string());
-    return redirectResponse;
+    return WTFMove(redirectResponse);
 }
 
 void FetchResponse::initializeWith(const Dictionary& init, ExceptionCode& ec)
@@ -109,7 +109,7 @@ void FetchResponse::initializeWith(const Dictionary& init, ExceptionCode& ec)
     }
 }
 
-FetchResponse::FetchResponse(ScriptExecutionContext& context, Type type, FetchBody&& body, Ref<FetchHeaders>&& headers, ResourceResponse&& response)
+FetchResponse::FetchResponse(ScriptExecutionContext& context, ResponseType type, FetchBody&& body, Ref<FetchHeaders>&& headers, ResourceResponse&& response)
     : FetchBodyOwner(context, WTFMove(body))
     , m_type(type)
     , m_response(WTFMove(response))
@@ -123,34 +123,14 @@ RefPtr<FetchResponse> FetchResponse::clone(ScriptExecutionContext& context, Exce
         ec = TypeError;
         return nullptr;
     }
-    RefPtr<FetchResponse> cloned = adoptRef(*new FetchResponse(context, m_type, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response)));
+    auto cloned = adoptRef(*new FetchResponse(context, m_type, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response)));
     cloned->m_isRedirected = m_isRedirected;
-    return cloned;
-}
-
-String FetchResponse::type() const
-{
-    switch (m_type) {
-    case Type::Basic:
-        return ASCIILiteral("basic");
-    case Type::Cors:
-        return ASCIILiteral("cors");
-    case Type::Default:
-        return ASCIILiteral("default");
-    case Type::Error:
-        return ASCIILiteral("error");
-    case Type::Opaque:
-        return ASCIILiteral("opaque");
-    case Type::OpaqueRedirect:
-        return ASCIILiteral("opaqueredirect");
-    };
-    ASSERT_NOT_REACHED();
-    return String();
+    return WTFMove(cloned);
 }
 
 void FetchResponse::startFetching(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise)
 {
-    Ref<FetchResponse> response = adoptRef(*new FetchResponse(context, Type::Basic, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
+    auto response = adoptRef(*new FetchResponse(context, ResponseType::Basic, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
 
     // Setting pending activity until BodyLoader didFail or didSucceed callback is called.
     response->setPendingActivity(response.ptr());
index 08f971f..d9ef38d 100644 (file)
@@ -26,8 +26,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef FetchResponse_h
-#define FetchResponse_h
+#pragma once
 
 #if ENABLE(FETCH_API)
 
@@ -47,9 +46,11 @@ class ReadableStreamSource;
 
 typedef int ExceptionCode;
 
+enum class ResponseType { Basic, Cors, Default, Error, Opaque, Opaqueredirect };
+
 class FetchResponse final : public FetchBodyOwner {
 public:
-    static Ref<FetchResponse> create(ScriptExecutionContext& context) { return adoptRef(*new FetchResponse(context, Type::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Response), ResourceResponse())); }
+    static Ref<FetchResponse> create(ScriptExecutionContext& context) { return adoptRef(*new FetchResponse(context, ResponseType::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Response), ResourceResponse())); }
     static Ref<FetchResponse> error(ScriptExecutionContext&);
     static RefPtr<FetchResponse> redirect(ScriptExecutionContext&, const String&, int, ExceptionCode&);
 
@@ -59,7 +60,7 @@ public:
 
     void initializeWith(const Dictionary&, ExceptionCode&);
 
-    String type() const;
+    ResponseType type() const;
     const String& url() const { return m_response.url().string(); }
     bool redirected() const { return m_isRedirected; }
     int status() const { return m_response.httpStatusCode(); }
@@ -75,9 +76,7 @@ public:
 #endif
 
 private:
-    enum class Type { Basic, Cors, Default, Error, Opaque, OpaqueRedirect };
-
-    FetchResponse(ScriptExecutionContext&, Type, FetchBody&&, Ref<FetchHeaders>&&, ResourceResponse&&);
+    FetchResponse(ScriptExecutionContext&, ResponseType, FetchBody&&, Ref<FetchHeaders>&&, ResourceResponse&&);
 
     static void startFetching(ScriptExecutionContext&, const FetchRequest&, FetchPromise&&);
 
@@ -110,15 +109,18 @@ private:
         std::unique_ptr<FetchLoader> m_loader;
     };
 
-    Type m_type;
+    ResponseType m_type;
     ResourceResponse m_response;
     Ref<FetchHeaders> m_headers;
     bool m_isRedirected = false;
     Optional<BodyLoader> m_bodyLoader;
 };
 
+inline ResponseType FetchResponse::type() const
+{
+    return m_type;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(FETCH_API)
-
-#endif // FetchResponse_h
index cc7ca9d..66c5f19 100644 (file)
@@ -233,37 +233,29 @@ String MediaControlsHost::externalDeviceDisplayName() const
 #endif
 }
 
-String MediaControlsHost::externalDeviceType() const
+DeviceType MediaControlsHost::externalDeviceType() const
 {
-    static NeverDestroyed<String> none(ASCIILiteral("none"));
-    String type = none;
-    
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    static NeverDestroyed<String> airplay(ASCIILiteral("airplay"));
-    static NeverDestroyed<String> tvout(ASCIILiteral("tvout"));
-    
+#if !ENABLE(WIRELESS_PLAYBACK_TARGET)
+    return DeviceType::None;
+#else
     MediaPlayer* player = m_mediaElement->player();
     if (!player) {
         LOG(Media, "MediaControlsHost::externalDeviceType - returning \"none\" because player is NULL");
-        return none;
+        return DeviceType::None;
     }
     
     switch (player->wirelessPlaybackTargetType()) {
     case MediaPlayer::TargetTypeNone:
-        type = none;
-        break;
+        return DeviceType::None;
     case MediaPlayer::TargetTypeAirPlay:
-        type = airplay;
-        break;
+        return DeviceType::Airplay;
     case MediaPlayer::TargetTypeTVOut:
-        type = tvout;
-        break;
+        return DeviceType::Tvout;
     }
+
+    ASSERT_NOT_REACHED();
+    return DeviceType::None;
 #endif
-    
-    LOG(Media, "MediaControlsHost::externalDeviceType - returning \"%s\"", type.utf8().data());
-    
-    return type;
 }
 
 bool MediaControlsHost::controlsDependOnPageScaleFactor() const
index 750c5ec..c0a7829 100644 (file)
@@ -42,6 +42,8 @@ class MediaControlTextTrackContainerElement;
 class TextTrack;
 class TextTrackList;
 
+enum class DeviceType { None, Airplay, Tvout };
+
 class MediaControlsHost : public RefCounted<MediaControlsHost> {
 public:
     static Ref<MediaControlsHost> create(HTMLMediaElement*);
@@ -71,7 +73,7 @@ public:
     void exitedFullscreen();
 
     String externalDeviceDisplayName() const;
-    String externalDeviceType() const;
+    DeviceType externalDeviceType() const;
 
     bool controlsDependOnPageScaleFactor() const;
     void setControlsDependOnPageScaleFactor(bool v);
index 9e54dd7..780bd09 100644 (file)
 
 namespace WebCore {
 
-static const char* defaultKind = "";
-static const char* ambientKind = "ambient";
-static const char* transientKind = "transient";
-static const char* transientSoloKind = "transient-solo";
-static const char* contentKind = "content";
-
-MediaSession::Kind MediaSession::parseKind(const String& kind)
-{
-    // 4. Media Session
-    // 2. Set media session's current media session type to the corresponding media session type of media session category.
-
-    if (kind.isNull() || kind == contentKind)
-        return MediaSession::Kind::Content;
-    if (kind == ambientKind)
-        return MediaSession::Kind::Ambient;
-    if (kind == transientKind)
-        return MediaSession::Kind::Transient;
-    if (kind == transientSoloKind)
-        return MediaSession::Kind::TransientSolo;
-
-    ASSERT_NOT_REACHED();
-    return MediaSession::Kind::Content;
-}
-
-MediaSession::MediaSession(ScriptExecutionContext& context, const String& kind)
+MediaSession::MediaSession(ScriptExecutionContext& context, MediaSessionKind kind)
     : m_document(downcast<Document>(context))
-    , m_kind(parseKind(kind))
+    , m_kind(kind)
 {
     // 4. Media Sessions
     // 3. If media session's current media session type is "content", then create a new media remote controller for media
@@ -82,22 +58,6 @@ MediaSession::~MediaSession()
         m_controls->clearSession();
 }
 
-String MediaSession::kind() const
-{
-    switch (m_kind) {
-    case MediaSession::Kind::Default:
-        return defaultKind;
-    case MediaSession::Kind::Ambient:
-        return ambientKind;
-    case MediaSession::Kind::Transient:
-        return transientKind;
-    case MediaSession::Kind::TransientSolo:
-        return transientSoloKind;
-    case MediaSession::Kind::Content:
-        return contentKind;
-    }
-}
-
 MediaRemoteControls* MediaSession::controls()
 {
     return m_controls.get();
index 2a76be8..67dd393 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaSession_h
-#define MediaSession_h
+#pragma once
 
 #if ENABLE(MEDIA_SESSION)
 
@@ -37,31 +36,20 @@ class Dictionary;
 class Document;
 class HTMLMediaElement;
 
+enum class MediaSessionKind { Content, Transient, TransientSolo, Ambient };
+
 class MediaSession final : public RefCounted<MediaSession> {
 public:
-    enum class State {
-        Idle,
-        Active,
-        Interrupted
-    };
-
-    enum class Kind {
-        Default,
-        Content,
-        Transient,
-        TransientSolo,
-        Ambient
-    };
-
-    static Ref<MediaSession> create(ScriptExecutionContext& context, const String& kind = String())
+    enum class State { Idle, Active, Interrupted };
+
+    static Ref<MediaSession> create(ScriptExecutionContext& context, MediaSessionKind kind)
     {
         return adoptRef(*new MediaSession(context, kind));
     }
 
     ~MediaSession();
 
-    String kind() const;
-    Kind kindEnum() const { return m_kind; }
+    MediaSessionKind kind() const { return m_kind; }
     MediaRemoteControls* controls();
 
     WEBCORE_EXPORT State currentState() const { return m_currentState; }
@@ -91,8 +79,6 @@ private:
 
     MediaSession(ScriptExecutionContext&, const String&);
 
-    static Kind parseKind(const String&);
-
     void addMediaElement(HTMLMediaElement&);
     void removeMediaElement(HTMLMediaElement&);
 
@@ -109,7 +95,7 @@ private:
     HashSet<HTMLMediaElement*>* m_iteratedActiveParticipatingElements { nullptr };
 
     Document& m_document;
-    const Kind m_kind { Kind::Default };
+    const MediaSessionKind m_kind;
     RefPtr<MediaRemoteControls> m_controls;
     MediaSessionMetadata m_metadata;
 };
@@ -117,5 +103,3 @@ private:
 } // namespace WebCore
 
 #endif /* ENABLE(MEDIA_SESSION) */
-
-#endif /* MediaSession_h */
index 38daec8..499c19a 100644 (file)
@@ -25,7 +25,7 @@
 
 [
     Conditional=MEDIA_SESSION,
-    CustomConstructor(optional MediaSessionKind kind),
+    CustomConstructor(optional MediaSessionKind kind = "content"),
     ConstructorCallWith=ScriptExecutionContext,
     ImplementationLacksVTable,
     ExportMacro=WEBCORE_EXPORT,
index 1c400cc..dd901a2 100644 (file)
@@ -118,19 +118,19 @@ void MediaSessionManager::didReceiveStartOfInterruptionNotification(MediaSession
             // -  If interrupting media session category is Content:
             //    If media session's current media session type is Default or Content then indefinitely pause all of media
             //    session's active audio-producing participants and set media session's current state to idle.
-            if (session->kindEnum() == MediaSession::Kind::Default || session->kindEnum() == MediaSession::Kind::Content)
+            if (session->kind() == MediaSessionKind::Default || session->kind() == MediaSessionKind::Content)
                 session->handleIndefinitePauseInterruption();
         } else if (interruptingCategory == MediaSessionInterruptingCategory::Transient) {
             // - If interrupting media session category is Transient:
             //   If media session's current media session type is Default or Content then duck all of media session's active
             //   audio-producing participants and set media session's current state to interrupted.
-            if (session->kindEnum() == MediaSession::Kind::Default || session->kindEnum() == MediaSession::Kind::Content)
+            if (session->kind() == MediaSessionKind::Default || session->kind() == MediaSessionKind::Content)
                 session->handleDuckInterruption();
         } else if (interruptingCategory == MediaSessionInterruptingCategory::TransientSolo) {
             // - If interrupting media session category is Transient Solo:
             //   If media session's current media session type is Default, Content, Transient or Transient Solo then pause
             //   all of media session's active audio-producing participants and set current media session's current state to interrupted.
-            if (session->kindEnum() != MediaSession::Kind::Ambient)
+            if (session->kind() != MediaSessionKind::Ambient)
                 session->handlePauseInterruption();
         }
     }
@@ -154,13 +154,13 @@ void MediaSessionManager::didReceiveEndOfInterruptionNotification(MediaSessionIn
             // - If interrupting media session category is Transient:
             //   If media session's current media session type is Default or Content, then unduck all of media session's
             //   active audio-producing participants and set media session's current state to active.
-            if (session->kindEnum() == MediaSession::Kind::Default || session->kindEnum() == MediaSession::Kind::Content)
+            if (session->kind() == MediaSessionKind::Default || session->kind() == MediaSessionKind::Content)
                 session->handleUnduckInterruption();
         } else if (interruptingCategory == MediaSessionInterruptingCategory::TransientSolo) {
             // - If interrupting media session category is Transient Solo:
             //   If media session's current media session type is Default, Content, Transient, or Transient Solo, then
             //   unpause the media session's active audio-producing participants and set media session's current state to active.
-            if (session->kindEnum() != MediaSession::Kind::Ambient)
+            if (session->kind() != MediaSessionKind::Ambient)
                 session->handleUnpauseInterruption();
         }
     }
index b62367b..c1bd88b 100644 (file)
@@ -414,12 +414,7 @@ void MediaSource::setReadyState(const AtomicString& state)
     onReadyStateChange(oldState, state);
 }
 
-void MediaSource::endOfStream(ExceptionCode& ec)
-{
-    endOfStream(emptyAtom, ec);
-}
-
-void MediaSource::endOfStream(const AtomicString& error, ExceptionCode& ec)
+void MediaSource::endOfStream(Optional<EndOfStreamError> error, ExceptionCode& ec)
 {
     // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-MediaSource-endOfStream-void-EndOfStreamError-error
     // 1. If the readyState attribute is not in the "open" state then throw an
@@ -437,15 +432,12 @@ void MediaSource::endOfStream(const AtomicString& error, ExceptionCode& ec)
     }
 
     // 3. Run the end of stream algorithm with the error parameter set to error.
-    streamEndedWithError(error, ec);
+    streamEndedWithError(error);
 }
 
-void MediaSource::streamEndedWithError(const AtomicString& error, ExceptionCode& ec)
+void MediaSource::streamEndedWithError(Optional<EndOfStreamError> error)
 {
-    static NeverDestroyed<const AtomicString> network("network", AtomicString::ConstructFromLiteral);
-    static NeverDestroyed<const AtomicString> decode("decode", AtomicString::ConstructFromLiteral);
-
-    LOG(MediaSource, "MediaSource::streamEndedWithError(%p) : %s", this, error.string().ascii().data());
+    LOG(MediaSource, "MediaSource::streamEndedWithError(%p)", this);
 
     // 2.4.7 https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#end-of-stream-algorithm
 
@@ -454,7 +446,7 @@ void MediaSource::streamEndedWithError(const AtomicString& error, ExceptionCode&
     setReadyState(endedKeyword());
 
     // 3.
-    if (error.isEmpty()) {
+    if (!error) {
         // ↳ If error is not set, is null, or is an empty string
         // 1. Run the duration change algorithm with new duration set to the highest end time reported by
         // the buffered attribute across all SourceBuffer objects in sourceBuffers.
@@ -467,9 +459,7 @@ void MediaSource::streamEndedWithError(const AtomicString& error, ExceptionCode&
 
         // 2. Notify the media element that it now has all of the media data.
         m_private->markEndOfStream(MediaSourcePrivate::EosNoError);
-    }
-
-    if (error == network) {
+    } else if (error == EndOfStreamError::Network) {
         // ↳ If error is set to "network"
         ASSERT(m_mediaElement);
         if (m_mediaElement->readyState() == HTMLMediaElement::HAVE_NOTHING) {
@@ -485,8 +475,9 @@ void MediaSource::streamEndedWithError(const AtomicString& error, ExceptionCode&
             //    NOTE: This step is handled by HTMLMediaElement::mediaLoadingFailedFatally().
             m_mediaElement->mediaLoadingFailedFatally(MediaPlayer::NetworkError);
         }
-    } else if (error == decode) {
+    } else {
         // ↳ If error is set to "decode"
+        ASSERT(error == EndOfStreamError::Decode);
         ASSERT(m_mediaElement);
         if (m_mediaElement->readyState() == HTMLMediaElement::HAVE_NOTHING) {
             //  ↳ If the HTMLMediaElement.readyState attribute equals HAVE_NOTHING
@@ -500,10 +491,6 @@ void MediaSource::streamEndedWithError(const AtomicString& error, ExceptionCode&
             //    NOTE: This step is handled by HTMLMediaElement::mediaLoadingFailedFatally().
             m_mediaElement->mediaLoadingFailedFatally(MediaPlayer::DecodeError);
         }
-    } else if (!error.isEmpty()) {
-        // ↳ Otherwise
-        //   Throw an INVALID_ACCESS_ERR exception.
-        ec = INVALID_ACCESS_ERR;
     }
 }
 
@@ -558,7 +545,7 @@ SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec
     // ↳ Set the mode attribute on the new object to "sequence".
     // Otherwise:
     // ↳ Set the mode attribute on the new object to "segments".
-    buffer->setMode(shouldGenerateTimestamps ? SourceBuffer::sequenceKeyword() : SourceBuffer::segmentsKeyword(), IGNORE_EXCEPTION);
+    buffer->setMode(shouldGenerateTimestamps ? AppendMode::Sequence : AppendMode::Segments, IGNORE_EXCEPTION);
 
     SourceBuffer* result = buffer.ptr();
 
@@ -771,7 +758,7 @@ void MediaSource::close()
     setReadyState(closedKeyword());
 }
 
-void MediaSource::sourceBufferDidChangeAcitveState(SourceBuffer*, bool)
+void MediaSource::sourceBufferDidChangeActiveState(SourceBuffer&, bool)
 {
     regenerateActiveSourceBuffers();
 }
index 848b8f9..5971c86 100644 (file)
@@ -28,8 +28,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaSource_h
-#define MediaSource_h
+#pragma once
 
 #if ENABLE(MEDIA_SOURCE)
 
@@ -49,6 +48,8 @@ namespace WebCore {
 
 class GenericEventQueue;
 
+enum class EndOfStreamError { Network, Decode };
+
 class MediaSource : public MediaSourcePrivateClient, public ActiveDOMObject, public EventTargetWithInlineData, public URLRegistrable {
 public:
     static void setRegistry(URLRegistry*);
@@ -67,8 +68,8 @@ public:
     bool isOpen() const;
     bool isClosed() const;
     bool isEnded() const;
-    void sourceBufferDidChangeAcitveState(SourceBuffer*, bool);
-    void streamEndedWithError(const AtomicString& error, ExceptionCode&);
+    void sourceBufferDidChangeActiveState(SourceBuffer&, bool);
+    void streamEndedWithError(Optional<EndOfStreamError>);
 
     // MediaSourcePrivateClient
     void setPrivateAndOpen(Ref<MediaSourcePrivate>&&) override;
@@ -87,8 +88,7 @@ public:
     MediaTime currentTime() const;
     const AtomicString& readyState() const { return m_readyState; }
     void setReadyState(const AtomicString&);
-    void endOfStream(ExceptionCode&);
-    void endOfStream(const AtomicString& error, ExceptionCode&);
+    void endOfStream(Optional<EndOfStreamError>, ExceptionCode&);
 
     HTMLMediaElement* mediaElement() const { return m_mediaElement; }
 
@@ -147,5 +147,3 @@ protected:
 }
 
 #endif
-
-#endif
index 78fae2b..0507a95 100644 (file)
@@ -71,27 +71,15 @@ static const MediaTime& currentTimeFudgeFactor()
     return fudgeFactor;
 }
 
-const AtomicString& SourceBuffer::segmentsKeyword()
-{
-    static NeverDestroyed<AtomicString> segments("segments");
-    return segments.get();
-}
-
-const AtomicString& SourceBuffer::sequenceKeyword()
-{
-    static NeverDestroyed<AtomicString> segments("sequence");
-    return segments.get();
-}
-
 struct SourceBuffer::TrackBuffer {
     MediaTime lastDecodeTimestamp;
     MediaTime lastFrameDuration;
     MediaTime highestPresentationTimestamp;
     MediaTime lastEnqueuedPresentationTime;
     MediaTime lastEnqueuedDecodeEndTime;
-    bool needRandomAccessFlag;
-    bool enabled;
-    bool needsReenqueueing;
+    bool needRandomAccessFlag { true };
+    bool enabled { false };
+    bool needsReenqueueing { false };
     SampleMap samples;
     DecodeOrderSampleMap::MapType decodeQueue;
     RefPtr<MediaDescription> description;
@@ -102,18 +90,15 @@ struct SourceBuffer::TrackBuffer {
         , highestPresentationTimestamp(MediaTime::invalidTime())
         , lastEnqueuedPresentationTime(MediaTime::invalidTime())
         , lastEnqueuedDecodeEndTime(MediaTime::invalidTime())
-        , needRandomAccessFlag(true)
-        , enabled(false)
-        , needsReenqueueing(false)
     {
     }
 };
 
 Ref<SourceBuffer> SourceBuffer::create(Ref<SourceBufferPrivate>&& sourceBufferPrivate, MediaSource* source)
 {
-    RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(WTFMove(sourceBufferPrivate), source)));
+    auto sourceBuffer = adoptRef(*new SourceBuffer(WTFMove(sourceBufferPrivate), source));
     sourceBuffer->suspendIfNeeded();
-    return sourceBuffer.releaseNonNull();
+    return sourceBuffer;
 }
 
 SourceBuffer::SourceBuffer(Ref<SourceBufferPrivate>&& sourceBufferPrivate, MediaSource* source)
@@ -121,7 +106,6 @@ SourceBuffer::SourceBuffer(Ref<SourceBufferPrivate>&& sourceBufferPrivate, Media
     , m_private(WTFMove(sourceBufferPrivate))
     , m_source(source)
     , m_asyncEventQueue(*this)
-    , m_mode(segmentsKeyword())
     , m_appendBufferTimer(*this, &SourceBuffer::appendBufferTimerFired)
     , m_appendWindowStart(MediaTime::zeroTime())
     , m_appendWindowEnd(MediaTime::positiveInfiniteTime())
@@ -130,17 +114,9 @@ SourceBuffer::SourceBuffer(Ref<SourceBufferPrivate>&& sourceBufferPrivate, Media
     , m_buffered(TimeRanges::create())
     , m_appendState(WaitingForSegment)
     , m_timeOfBufferingMonitor(monotonicallyIncreasingTime())
-    , m_bufferedSinceLastMonitor(0)
-    , m_averageBufferRate(0)
-    , m_reportedExtraMemoryCost(0)
     , m_pendingRemoveStart(MediaTime::invalidTime())
     , m_pendingRemoveEnd(MediaTime::invalidTime())
     , m_removeTimer(*this, &SourceBuffer::removeTimerFired)
-    , m_updating(false)
-    , m_receivedFirstInitializationSegment(false)
-    , m_active(false)
-    , m_bufferFull(false)
-    , m_shouldGenerateTimestamps(false)
 {
     ASSERT(m_source);
 
@@ -206,7 +182,7 @@ void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
     MediaTime newTimestampOffset = MediaTime::createWithDouble(offset);
 
     // 6. If the mode attribute equals "sequence", then set the group start timestamp to new timestamp offset.
-    if (m_mode == sequenceKeyword())
+    if (m_mode == AppendMode::Sequence)
         m_groupStartTimestamp = newTimestampOffset;
 
     // 7. Update the attribute to the new value.
@@ -672,7 +648,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(SourceBufferPriva
     LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(%p) - result = %i", this, error);
 
     if (!isRemoved())
-        m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
+        m_source->streamEndedWithError(EndOfStreamError::Decode);
 }
 
 static bool decodeTimeComparator(const PresentationOrderSampleMap::MapType::value_type& a, const PresentationOrderSampleMap::MapType::value_type& b)
@@ -926,18 +902,6 @@ size_t SourceBuffer::maximumBufferSize() const
     return element->maximumSourceBufferSize(*this);
 }
 
-const AtomicString& SourceBuffer::decodeError()
-{
-    static NeverDestroyed<AtomicString> decode("decode", AtomicString::ConstructFromLiteral);
-    return decode;
-}
-
-const AtomicString& SourceBuffer::networkError()
-{
-    static NeverDestroyed<AtomicString> network("network", AtomicString::ConstructFromLiteral);
-    return network;
-}
-
 VideoTrackList* SourceBuffer::videoTracks()
 {
     if (!m_source || !m_source->mediaElement())
@@ -979,15 +943,7 @@ void SourceBuffer::setActive(bool active)
     m_active = active;
     m_private->setActive(active);
     if (!isRemoved())
-        m_source->sourceBufferDidChangeAcitveState(this, active);
-}
-
-void SourceBuffer::sourceBufferPrivateDidEndStream(SourceBufferPrivate*, const WTF::AtomicString& error)
-{
-    LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidEndStream(%p) - result = %s", this, String(error).utf8().data());
-
-    if (!isRemoved())
-        m_source->streamEndedWithError(error, IgnorableExceptionCode());
+        m_source->sourceBufferDidChangeActiveState(*this, active);
 }
 
 void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivate*, const InitializationSegment& segment)
@@ -1319,7 +1275,7 @@ void SourceBuffer::appendError(bool decodeErrorParam)
 
     // 5. If decode error is true, then run the end of stream algorithm with the error parameter set to "decode".
     if (decodeErrorParam)
-        m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
+        m_source->streamEndedWithError(EndOfStreamError::Decode);
 }
 
 void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, PassRefPtr<MediaSample> prpSample)
@@ -1374,7 +1330,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, Pas
         MediaTime frameDuration = sample->duration();
 
         // 1.3 If mode equals "sequence" and group start timestamp is set, then run the following steps:
-        if (m_mode == sequenceKeyword() && m_groupStartTimestamp.isValid()) {
+        if (m_mode == AppendMode::Sequence && m_groupStartTimestamp.isValid()) {
             // 1.3.1 Set timestampOffset equal to group start timestamp - presentation timestamp.
             m_timestampOffset = m_groupStartTimestamp;
 
@@ -1414,11 +1370,11 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, Pas
             || abs(decodeTimestamp - trackBuffer.lastDecodeTimestamp) > (trackBuffer.lastFrameDuration * 2))) {
 
             // 1.6.1:
-            if (m_mode == segmentsKeyword()) {
+            if (m_mode == AppendMode::Segments) {
                 // ↳ If mode equals "segments":
                 // Set group end timestamp to presentation timestamp.
                 m_groupEndTimestamp = presentationTimestamp;
-            } else if (m_mode == sequenceKeyword()) {
+            } else {
                 // ↳ If mode equals "sequence":
                 // Set group start timestamp equal to the group end timestamp.
                 m_groupStartTimestamp = m_groupEndTimestamp;
@@ -1439,7 +1395,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, Pas
             continue;
         }
 
-        if (m_mode == sequenceKeyword()) {
+        if (m_mode == AppendMode::Sequence) {
             // Use the generated timestamps instead of the sample's timestamps.
             sample->setTimestamps(presentationTimestamp, decodeTimestamp);
         } else if (m_timestampOffset) {
@@ -1470,7 +1426,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, Pas
         MediaTime presentationStartTime = MediaTime::zeroTime();
         if (presentationTimestamp < presentationStartTime) {
             LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidReceiveSample(%p) - failing because presentationTimestamp < presentationStartTime", this);
-            m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
+            m_source->streamEndedWithError(EndOfStreamError::Decode);
             return;
         }
 
@@ -2022,7 +1978,7 @@ Document& SourceBuffer::document() const
     return downcast<Document>(*scriptExecutionContext());
 }
 
-void SourceBuffer::setMode(const AtomicString& newMode, ExceptionCode& ec)
+void SourceBuffer::setMode(AppendMode newMode, ExceptionCode& ec)
 {
     // 3.1 Attributes - mode
     // http://www.w3.org/TR/media-source/#widl-SourceBuffer-mode
@@ -2031,7 +1987,7 @@ void SourceBuffer::setMode(const AtomicString& newMode, ExceptionCode& ec)
 
     // 1. Let new mode equal the new value being assigned to this attribute.
     // 2. If generate timestamps flag equals true and new mode equals "segments", then throw an INVALID_ACCESS_ERR exception and abort these steps.
-    if (m_shouldGenerateTimestamps && newMode == segmentsKeyword()) {
+    if (m_shouldGenerateTimestamps && newMode == AppendMode::Segments) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
@@ -2057,7 +2013,7 @@ void SourceBuffer::setMode(const AtomicString& newMode, ExceptionCode& ec)
     }
 
     // 7. If the new mode equals "sequence", then set the group start timestamp to the group end timestamp.
-    if (newMode == sequenceKeyword())
+    if (newMode == AppendMode::Sequence)
         m_groupStartTimestamp = m_groupEndTimestamp;
 
     // 8. Update the attribute to new mode.
index 0f997f3..6bcb64a 100644 (file)
@@ -29,8 +29,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef SourceBuffer_h
-#define SourceBuffer_h
+#pragma once
 
 #if ENABLE(MEDIA_SOURCE)
 
@@ -59,13 +58,14 @@ class TextTrackList;
 class TimeRanges;
 class VideoTrackList;
 
+enum class EndOfStreamError;
+
+enum class AppendMode { Segments, Sequence };
+
 class SourceBuffer final : public RefCounted<SourceBuffer>, public ActiveDOMObject, public EventTargetWithInlineData, public SourceBufferPrivateClient, public AudioTrackClient, public VideoTrackClient, public TextTrackClient {
 public:
     static Ref<SourceBuffer> create(Ref<SourceBufferPrivate>&&, MediaSource*);
 
-    static const AtomicString& segmentsKeyword();
-    static const AtomicString& sequenceKeyword();
-
     virtual ~SourceBuffer();
 
     // SourceBuffer.idl methods
@@ -117,8 +117,8 @@ public:
 
     Document& document() const;
 
-    const AtomicString& mode() const { return m_mode; }
-    void setMode(const AtomicString&, ExceptionCode&);
+    AppendMode mode() const { return m_mode; }
+    void setMode(AppendMode, ExceptionCode&);
 
     bool shouldGenerateTimestamps() const { return m_shouldGenerateTimestamps; }
     void setShouldGenerateTimestamps(bool flag) { m_shouldGenerateTimestamps = flag; }
@@ -145,7 +145,6 @@ private:
     bool canSuspendForDocumentSuspension() const override;
 
     // SourceBufferPrivateClient
-    void sourceBufferPrivateDidEndStream(SourceBufferPrivate*, const WTF::AtomicString&) override;
     void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivate*, const InitializationSegment&) override;
     void sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, PassRefPtr<MediaSample>) override;
     bool sourceBufferPrivateHasAudio(const SourceBufferPrivate*) const override;
@@ -169,9 +168,6 @@ private:
     void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>) override;
     void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) override;
 
-    static const WTF::AtomicString& decodeError();
-    static const WTF::AtomicString& networkError();
-
     bool isRemoved() const;
     void scheduleEvent(const AtomicString& eventName);
 
@@ -206,7 +202,7 @@ private:
     Ref<SourceBufferPrivate> m_private;
     MediaSource* m_source;
     GenericEventQueue m_asyncEventQueue;
-    AtomicString m_mode;
+    AppendMode m_mode { AppendMode::Segments };
 
     Vector<unsigned char> m_pendingAppendData;
     Timer m_appendBufferTimer;
@@ -234,24 +230,22 @@ private:
     AppendStateType m_appendState;
 
     double m_timeOfBufferingMonitor;
-    double m_bufferedSinceLastMonitor;
-    double m_averageBufferRate;
+    double m_bufferedSinceLastMonitor { 0 };
+    double m_averageBufferRate { 0 };
 
-    size_t m_reportedExtraMemoryCost;
+    size_t m_reportedExtraMemoryCost { 0 };
 
     MediaTime m_pendingRemoveStart;
     MediaTime m_pendingRemoveEnd;
     Timer m_removeTimer;
 
-    bool m_updating;
-    bool m_receivedFirstInitializationSegment;
-    bool m_active;
-    bool m_bufferFull;
-    bool m_shouldGenerateTimestamps;
+    bool m_updating { false };
+    bool m_receivedFirstInitializationSegment { false };
+    bool m_active { false };
+    bool m_bufferFull { false };
+    bool m_shouldGenerateTimestamps { false };
 };
 
 } // namespace WebCore
 
 #endif
-
-#endif
index 81890dd..4b8278e 100644 (file)
 
 #if ENABLE(MEDIA_STREAM)
 
-#include "ContextDestructionObserver.h"
-#include "ScriptWrappable.h"
-#include <wtf/NeverDestroyed.h>
-
 namespace WebCore {
 
-Ref<MediaDeviceInfo> MediaDeviceInfo::create(ScriptExecutionContext* context, const String& label, const String& deviceId, const String& groupId, const String& kind)
-{
-    return adoptRef(*new MediaDeviceInfo(context, label, deviceId, groupId, kind));
-}
-
-MediaDeviceInfo::MediaDeviceInfo(ScriptExecutionContext* context, const String& label, const String& deviceId, const String& groupId, const String& kind)
+inline MediaDeviceInfo::MediaDeviceInfo(ScriptExecutionContext* context, const String& label, const String& deviceId, const String& groupId, MediaDeviceKind kind)
     : ContextDestructionObserver(context)
     , m_label(label)
     , m_deviceId(deviceId)
@@ -48,22 +39,9 @@ MediaDeviceInfo::MediaDeviceInfo(ScriptExecutionContext* context, const String&
 {
 }
 
-const AtomicString& MediaDeviceInfo::audioInputType()
-{
-    static NeverDestroyed<AtomicString> audioinput("audioinput");
-    return audioinput;
-}
-
-const AtomicString& MediaDeviceInfo::audioOutputType()
-{
-    static NeverDestroyed<AtomicString> audiooutput("audiooutput");
-    return audiooutput;
-}
-
-const AtomicString& MediaDeviceInfo::videoInputType()
+Ref<MediaDeviceInfo> MediaDeviceInfo::create(ScriptExecutionContext* context, const String& label, const String& deviceId, const String& groupId, MediaDeviceKind kind)
 {
-    static NeverDestroyed<AtomicString> videoinput("videoinput");
-    return videoinput;
+    return adoptRef(*new MediaDeviceInfo(context, label, deviceId, groupId, kind));
 }
 
 } // namespace WebCore
index 4c86524..c659f52 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaDeviceInfo_h
-#define MediaDeviceInfo_h
+#pragma once
 
 #if ENABLE(MEDIA_STREAM)
 
 #include "ContextDestructionObserver.h"
 #include "ScriptWrappable.h"
-#include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class MediaDeviceInfo : public RefCounted<MediaDeviceInfo>, public ScriptWrappable, public ContextDestructionObserver {
+enum class MediaDeviceKind { Audioinput, Audiooutput, Videoinput };
+
+class MediaDeviceInfo : public RefCounted<MediaDeviceInfo>, public ScriptWrappable, private ContextDestructionObserver {
 public:
-    static Ref<MediaDeviceInfo> create(ScriptExecutionContext*, const String&, const String&, const String&, const String&);
+    static Ref<MediaDeviceInfo> create(ScriptExecutionContext*, const String&, const String&, const String&, MediaDeviceKind);
 
-    virtual ~MediaDeviceInfo() { }
-    
     const String& label() const { return m_label; }
     const String& deviceId() const { return m_deviceId; }
     const String& groupId() const { return m_groupId; }
-    const String& kind() const { return m_kind; }
-
-    static const AtomicString& audioInputType();
-    static const AtomicString& audioOutputType();
-    static const AtomicString& videoInputType();
+    MediaDeviceKind kind() const { return m_kind; }
 
 private:
-    MediaDeviceInfo(ScriptExecutionContext*, const String&, const String&, const String&, const String&);
+    MediaDeviceInfo(ScriptExecutionContext*, const String&, const String&, const String&, MediaDeviceKind);
 
     const String m_label;
     const String m_deviceId;
     const String m_groupId;
-    const String m_kind;
+    const MediaDeviceKind m_kind;
 };
 
 typedef Vector<RefPtr<MediaDeviceInfo>> MediaDeviceInfoVector;
@@ -64,5 +58,3 @@ typedef Vector<RefPtr<MediaDeviceInfo>> MediaDeviceInfoVector;
 }
 
 #endif
-
-#endif /* MediaDeviceInfo_h */
index cf111f7..927cd72 100644 (file)
 */
 
 [
-NoInterfaceObject,
-Conditional=MEDIA_STREAM,
-Constructor(DOMString deviceId, DOMString label, DOMString groupId, MediaDeviceKind kind),
-JSGenerateToJSObject,
+    Conditional=MEDIA_STREAM,
+    Constructor(DOMString deviceId, DOMString label, DOMString groupId, MediaDeviceKind kind),
+    JSGenerateToJSObject,
+    NoInterfaceObject,
 ] interface MediaDeviceInfo {
-    readonly    attribute DOMString deviceId;
-    readonly    attribute DOMString groupId;
-    readonly    attribute DOMString kind;
-    readonly    attribute DOMString label;
+    readonly attribute DOMString deviceId;
+    readonly attribute DOMString groupId;
+    readonly attribute MediaDeviceKind kind;
+    readonly attribute DOMString label;
 };
 
 enum MediaDeviceKind {
     "audioinput",
     "audiooutput",
     "videoinput"
-};
\ No newline at end of file
+};
index 29deff4..848ec80 100644 (file)
@@ -144,9 +144,8 @@ void MediaDevicesRequest::didCompleteTrackSourceInfoRequest(const TrackSourceInf
     }
 
     Vector<RefPtr<MediaDeviceInfo>> devices;
-    for (auto deviceInfo : captureDevices) {
-        String deviceType = deviceInfo->kind() == TrackSourceInfo::SourceKind::Audio ? MediaDeviceInfo::audioInputType() : MediaDeviceInfo::videoInputType();
-        AtomicString label = emptyAtom;
+    for (auto& deviceInfo : captureDevices) {
+        String label = emptyString();
         if (m_havePersistentPermission || document.hasHadActiveMediaStreamTrack())
             label = deviceInfo->label();
 
@@ -156,6 +155,8 @@ void MediaDevicesRequest::didCompleteTrackSourceInfoRequest(const TrackSourceInf
 
         String groupId = hashID(deviceInfo->groupId());
 
+        auto deviceType = deviceInfo->kind() == TrackSourceInfo::SourceKind::Audio ? MediaDeviceKind::Audioinput : MediaDeviceKind::Videoinput;
+
         devices.append(MediaDeviceInfo::create(scriptExecutionContext(), label, id, groupId, deviceType));
     }
 
@@ -164,7 +165,6 @@ void MediaDevicesRequest::didCompleteTrackSourceInfoRequest(const TrackSourceInf
         protectedThis->m_promise.resolve(devices);
     });
     m_protector = nullptr;
-
 }
 
 const String& MediaDevicesRequest::requestOrigin() const
index 76cc057..15fc98e 100644 (file)
@@ -111,12 +111,9 @@ bool MediaStreamTrack::remote() const
     return m_private->remote();
 }
 
-const AtomicString& MediaStreamTrack::readyState() const
+MediaStreamTrackState MediaStreamTrack::readyState() const
 {
-    static NeverDestroyed<AtomicString> endedState("ended", AtomicString::ConstructFromLiteral);
-    static NeverDestroyed<AtomicString> liveState("live", AtomicString::ConstructFromLiteral);
-
-    return ended() ? endedState : liveState;
+    return ended() ? MediaStreamTrackState::Ended : MediaStreamTrackState::Live;
 }
 
 bool MediaStreamTrack::ended() const
index da73830..c8dfae4 100644 (file)
@@ -25,8 +25,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaStreamTrack_h
-#define MediaStreamTrack_h
+#pragma once
 
 #if ENABLE(MEDIA_STREAM)
 
@@ -35,7 +34,6 @@
 #include "MediaStreamTrackPrivate.h"
 #include "RealtimeMediaSource.h"
 #include "ScriptWrappable.h"
-#include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -48,7 +46,9 @@ class MediaConstraintsImpl;
 class MediaSourceSettings;
 class MediaTrackConstraints;
 
-class MediaStreamTrack final : public RefCounted<MediaStreamTrack>, public ActiveDOMObject, public EventTargetWithInlineData, public MediaStreamTrackPrivate::Observer {
+enum class MediaStreamTrackState { New, Live, Ended };
+
+class MediaStreamTrack final : public RefCounted<MediaStreamTrack>, public ActiveDOMObject, public EventTargetWithInlineData, private MediaStreamTrackPrivate::Observer {
 public:
     class Observer {
     public:
@@ -70,7 +70,7 @@ public:
     bool readonly() const;
     bool remote() const;
 
-    const AtomicString& readyState() const;
+    MediaStreamTrackState readyState() const;
 
     bool ended() const;
 
@@ -132,5 +132,3 @@ typedef Vector<RefPtr<MediaStreamTrack>> MediaStreamTrackVector;
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
-
-#endif // MediaStreamTrack_h
index ed29b55..f9003a2 100644 (file)
@@ -309,28 +309,6 @@ void AudioContext::setState(State state)
         promise.resolve(nullptr);
 }
 
-const AtomicString& AudioContext::state() const
-{
-    static NeverDestroyed<AtomicString> suspended("suspended");
-    static NeverDestroyed<AtomicString> running("running");
-    static NeverDestroyed<AtomicString> interrupted("interrupted");
-    static NeverDestroyed<AtomicString> closed("closed");
-
-    switch (m_state) {
-    case State::Suspended:
-        return suspended;
-    case State::Running:
-        return running;
-    case State::Interrupted:
-        return interrupted;
-    case State::Closed:
-        return closed;
-    }
-
-    ASSERT_NOT_REACHED();
-    return suspended;
-}
-
 void AudioContext::stop()
 {
     ASSERT(isMainThread());
index 17e16f7..f1ded8e 100644 (file)
@@ -23,8 +23,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef AudioContext_h
-#define AudioContext_h
+#pragma once
 
 #include "ActiveDOMObject.h"
 #include "AsyncAudioDecoder.h"
@@ -39,7 +38,6 @@
 #include <atomic>
 #include <wtf/HashSet.h>
 #include <wtf/MainThread.h>
-#include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/Threading.h>
 
 namespace WebCore {
 
+class AnalyserNode;
 class AudioBuffer;
 class AudioBufferCallback;
 class AudioBufferSourceNode;
-class MediaElementAudioSourceNode;
-class MediaStreamAudioDestinationNode;
-class MediaStreamAudioSourceNode;
-class HRTFDatabaseLoader;
-class HTMLMediaElement;
-class ChannelMergerNode;
-class ChannelSplitterNode;
-class GainNode;
-class GenericEventQueue;
-class PannerNode;
 class AudioListener;
 class AudioSummingJunction;
 class BiquadFilterNode;
+class ChannelMergerNode;
+class ChannelSplitterNode;
+class ConvolverNode;
 class DelayNode;
 class Document;
-class ConvolverNode;
 class DynamicsCompressorNode;
-class AnalyserNode;
-class WaveShaperNode;
-class ScriptProcessorNode;
+class GainNode;
+class GenericEventQueue;
+class HTMLMediaElement;
+class MediaElementAudioSourceNode;
+class MediaStreamAudioDestinationNode;
+class MediaStreamAudioSourceNode;
 class OscillatorNode;
+class PannerNode;
 class PeriodicWave;
+class ScriptProcessorNode;
+class WaveShaperNode;
+
+enum class AudioContextState { Suspended, Running, Interrupted, Closed };
 
 // AudioContext is the cornerstone of the web audio API and all AudioNodes are created from it.
 // For thread safety between the audio thread and the main thread, it has a rendering graph locking mechanism. 
@@ -118,7 +117,8 @@ public:
     void resume(Promise&&);
     void close(Promise&&);
 
-    const AtomicString& state() const;
+    using State = AudioContextState;
+    State state() const;
 
     // The AudioNode create methods are called on the main thread (from JavaScript).
     Ref<AudioBufferSourceNode> createBufferSource();
@@ -239,8 +239,8 @@ public:
     ScriptExecutionContext* scriptExecutionContext() const final;
 
     // Reconcile ref/deref which are defined both in ThreadSafeRefCounted and EventTarget.
-    using ThreadSafeRefCounted<AudioContext>::ref;
-    using ThreadSafeRefCounted<AudioContext>::deref;
+    using ThreadSafeRefCounted::ref;
+    using ThreadSafeRefCounted::deref;
 
     void startRendering();
     void fireCompletionEvent();
@@ -281,7 +281,6 @@ private:
     bool userGestureRequiredForAudioStart() const { return m_restrictions & RequireUserGestureForAudioStartRestriction; }
     bool pageConsentRequiredForAudioStart() const { return m_restrictions & RequirePageConsentForAudioStartRestriction; }
 
-    enum class State { Suspended, Running, Interrupted, Closed };
     void setState(State);
 
     void clear();
@@ -394,14 +393,21 @@ private:
     State m_state { State::Suspended };
 };
 
-inline bool operator==(const AudioContext& lhs, const AudioContext& rhs) {
+// FIXME: Find out why these ==/!= functions are needed and remove them if possible.
+
+inline bool operator==(const AudioContext& lhs, const AudioContext& rhs)
+{
     return &lhs == &rhs;
 }
 
-inline bool operator!=(const AudioContext& lhs, const AudioContext& rhs) {
+inline bool operator!=(const AudioContext& lhs, const AudioContext& rhs)
+{
     return &lhs != &rhs;
 }
 
-} // WebCore
+inline AudioContextState AudioContext::state() const
+{
+    return m_state;
+}
 
-#endif // AudioContext_h
+} // WebCore
index 965254f..ecd3f47 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "WaveShaperNode.h"
 
+#include "AudioContext.h"
 #include "ExceptionCode.h"
 #include <wtf/MainThread.h>
 
@@ -53,36 +54,41 @@ Float32Array* WaveShaperNode::curve()
     return waveShaperProcessor()->curve();
 }
 
-void WaveShaperNode::setOversample(const String& type, ExceptionCode& ec)
+static inline WaveShaperProcessor::OverSampleType processorType(OverSampleType type)
+{
+    switch (type) {
+    case OverSampleType::None:
+        return WaveShaperProcessor::OverSampleNone;
+    case OverSampleType::_2x:
+        return WaveShaperProcessor::OverSample2x;
+    case OverSampleType::_4x:
+        return WaveShaperProcessor::OverSample4x;
+    }
+    ASSERT_NOT_REACHED();
+    return WaveShaperProcessor::OverSampleNone;
+}
+
+void WaveShaperNode::setOversample(OverSampleType type)
 {
     ASSERT(isMainThread());
 
     // Synchronize with any graph changes or changes to channel configuration.
     AudioContext::AutoLocker contextLocker(context());
-
-    if (type == "none")
-        waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSampleNone);
-    else if (type == "2x")
-        waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample2x);
-    else if (type == "4x")
-        waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample4x);
-    else
-        ec = INVALID_STATE_ERR;
+    waveShaperProcessor()->setOversample(processorType(type));
 }
 
-String WaveShaperNode::oversample() const
+OverSampleType WaveShaperNode::oversample() const
 {
     switch (const_cast<WaveShaperNode*>(this)->waveShaperProcessor()->oversample()) {
     case WaveShaperProcessor::OverSampleNone:
-        return "none";
+        return OverSampleType::None;
     case WaveShaperProcessor::OverSample2x:
-        return "2x";
+        return OverSampleType::_2x;
     case WaveShaperProcessor::OverSample4x:
-        return "4x";
-    default:
-        ASSERT_NOT_REACHED();
-        return "none";
+        return OverSampleType::_4x;
     }
+    ASSERT_NOT_REACHED();
+    return OverSampleType::None;
 }
 
 } // namespace WebCore
index d1f7966..94f2596 100644 (file)
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WaveShaperNode_h
-#define WaveShaperNode_h
+#pragma once
 
 #include "AudioBasicProcessorNode.h"
-#include "BiquadProcessor.h"
 #include "WaveShaperProcessor.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
-    
-class WaveShaperNode : public AudioBasicProcessorNode {
+
+enum class OverSampleType { None, _2x, _4x };
+
+class WaveShaperNode final : public AudioBasicProcessorNode {
 public:
     static Ref<WaveShaperNode> create(AudioContext& context)
     {
@@ -43,8 +43,8 @@ public:
     void setCurve(Float32Array*);
     Float32Array* curve();
 
-    void setOversample(const String& , ExceptionCode&);
-    String oversample() const;
+    void setOversample(OverSampleType);
+    OverSampleType oversample() const;
 
     double latency() const { return latencyTime(); }
 
@@ -55,5 +55,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // WaveShaperNode_h
index 8a37753..965656a 100644 (file)
@@ -33,5 +33,5 @@ enum OverSampleType {
     JSGenerateToJSObject
 ] interface WaveShaperNode : AudioNode {
     attribute Float32Array curve;
-    [SetterRaisesException] attribute OverSampleType oversample;
+    attribute OverSampleType oversample;
 };
index 9dcaf91..ec309e3 100644 (file)
@@ -120,26 +120,10 @@ my %svgTypeWithWritablePropertiesNeedingTearOff = (
 # enumeration to using an actual enum class in the C++. Once that is done, we should
 # remove this hash and the function that calls it.
 my %stringBasedEnumerationHash = (
-    "AppendMode" => 1,
-    "AudioContextState" => 1,
     "AutoFillButtonType" => 1,
     "CachePolicy" => 1,
-    "CanvasWindingRule" => 1,
-    "DeviceType" => 1,
-    "EndOfStreamError" => 1,
-    "FontFaceSetLoadStatus" => 1,
-    "IDBCursorDirection" => 1,
-    "IDBRequestReadyState" => 1,
-    "IDBTransactionMode" => 1,
-    "ImageSmoothingQuality" => 1,
-    "KeyType" => 1,
-    "KeyUsage" => 1,
     "MediaControlEvent" => 1,
-    "MediaDeviceKind" => 1,
     "MediaSessionInterruptingCategory" => 1,
-    "MediaSessionKind" => 1,
-    "MediaStreamTrackState" => 1,
-    "OverSampleType" => 1,
     "PageOverlayType" => 1,
     "RTCBundlePolicyEnum" => 1,
     "RTCIceTransportPolicyEnum" => 1,
@@ -151,10 +135,8 @@ my %stringBasedEnumerationHash = (
     "RequestRedirect" => 1,
     "RequestType" => 1,
     "ResourceLoadPriority" => 1,
-    "ResponseType" => 1,
     "TextTrackKind" => 1,
     "TextTrackMode" => 1,
-    "VideoPresentationMode" => 1,
     "XMLHttpRequestResponseType" => 1,
 );
 
index 535f451..f0371b5 100644 (file)
@@ -442,9 +442,7 @@ sub GenerateHeaderContentHeader
         @headerContentHeader = split("\r", $headerTemplate);
     }
 
-    # - Add header protection
-    push(@headerContentHeader, "\n#ifndef $className" . "_h");
-    push(@headerContentHeader, "\n#define $className" . "_h\n\n");
+    push(@headerContentHeader, "\n#pragma once\n\n");
 
     my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
     push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString;
@@ -839,13 +837,18 @@ sub GetEnumerationClassName {
 sub GetEnumerationValueName {
     my ($name) = @_;
     return "EmptyString" if $name eq "";
-    return $codeGenerator->WK_ucfirst($name);
+    $name = join("", map { $codeGenerator->WK_ucfirst($_) } split("-", $name));
+    $name = "_$name" if $name =~ /^\d/;
+    return $name;
 };
 
 sub GetEnumerationImplementationContent
 {
     my ($enumerations) = @_;
 
+    # FIXME: Could optimize this to only generate things that are used, which would require
+    # iterating over everything in the interface.
+
     my $result = "";
     foreach my $enumeration (@$enumerations) {
         my $name = $enumeration->name;
@@ -853,12 +856,18 @@ sub GetEnumerationImplementationContent
 
         my $className = GetEnumerationClassName($name);
 
-        # Declare these instead of using "static" because these functions may be unused
-        # and we don't want to get warnings about unused static functions.
-        $result .= "const String& stringValue($className);\n";
-        $result .= "Optional<$className> enumerationValue$className(const String&);\n\n";
+        # FIXME: A little ugly to have this be a side effect instead of a return value.
+        AddToImplIncludes("<runtime/JSString.h>");
+
+        # Declare these instead of using "static" because these may be unused and we don't
+        # want to get warnings about them.
+        $result .= "JSString* jsStringWithCache(ExecState*, $className);\n";
+        $result .= "Optional<$className> parse$className(ExecState&, JSValue);\n";
+        $result .= "extern const char expectedEnumerationValues${className}[];\n\n";
 
-        $result .= "const String& stringValue($className enumerationValue)\n";
+        # Take an ExecState* instead of an ExecState& to match the jsStringWithCache from JSString.h.
+        # FIXME: Change to take VM& instead of ExecState*.
+        $result .= "JSString* jsStringWithCache(ExecState* state, $className enumerationValue)\n";
         $result .= "{\n";
         # FIXME: Might be nice to make this global be "const", but NeverDestroyed does not currently support that.
         # FIXME: Might be nice to make the entire array be NeverDestroyed instead of each value, but not sure the syntax for that.
@@ -870,27 +879,36 @@ sub GetEnumerationImplementationContent
         my $index = 0;
         foreach my $value (@{$enumeration->values}) {
             my $enumerationValueName = GetEnumerationValueName($value);
-            if ($index) {
-                $result .= "    static_assert(static_cast<size_t>($className::$enumerationValueName) == $index, \"$className::$enumerationValueName is not $index as expected\");\n";
-            } else {
-                # Keep the style checker happy. Not sure I still love this style guideline.
-                $result .= "    static_assert(!static_cast<size_t>($className::$enumerationValueName), \"$className::$enumerationValueName is not $index as expected\");\n";
-            }
+            $result .= "    static_assert(static_cast<size_t>($className::$enumerationValueName) == $index, \"$className::$enumerationValueName is not $index as expected\");\n";
             $index++;
         }
         $result .= "    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n";
-        $result .= "    return values[static_cast<size_t>(enumerationValue)];\n";
+        $result .= "    return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);\n";
         $result .= "}\n\n";
 
-        $result .= "Optional<$className> enumerationValue$className(const String& stringValue)\n";
+        $result .= "template<> struct JSValueTraits<$className> {\n";
+        $result .= "    static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, $className value) { return jsStringWithCache(state, value); }\n";
+        $result .= "};\n\n";
+
+        # FIXME: Change to take VM& instead of ExecState&.
+        # FIXME: Consider using toStringOrNull to make exception checking faster.
+        # FIXME: Consider finding a more efficient way to match against all the strings quickly.
+        $result .= "Optional<$className> parse$className(ExecState& state, JSValue value)\n";
         $result .= "{\n";
+        $result .= "    auto stringValue = value.toWTFString(&state);\n";
         foreach my $value (@{$enumeration->values}) {
             my $enumerationValueName = GetEnumerationValueName($value);
-            $result .= "    if (stringValue == \"$value\")\n";
+            if ($value eq "") {
+                $result .= "    if (stringValue.isEmpty())\n";
+            } else {
+                $result .= "    if (stringValue == \"$value\")\n";
+            }
             $result .= "        return $className::$enumerationValueName;\n";
         }
         $result .= "    return Nullopt;\n";
         $result .= "}\n\n";
+
+        $result .= "const char expectedEnumerationValues${className}[] = \"\\\"" . join ("\\\", \\\"", @{$enumeration->values}) . "\\\"\";\n\n";
     }
     return $result;
 }
@@ -1399,11 +1417,11 @@ sub GenerateHeader
     }
 
     my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
-    push(@headerContent, "\n} // namespace WebCore\n\n");
-    push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString;
-    push(@headerContent, "#endif\n");
+    push(@headerContent, "\n} // namespace WebCore\n");
+    push(@headerContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
 
     if ($interface->extendedAttributes->{"AppleCopyright"}) {
+        push(@headerContent, "\n");
         push(@headerContent, split("\r", $endAppleCopyright));
     }
 }
@@ -2778,8 +2796,8 @@ sub GenerateImplementation
                     push(@implContent, "    $setter(*state, *castedThis, castedThis->wrapped(), $eventName, value);\n");
                 }
                 push(@implContent, "    return true;\n");
-            } elsif ($attribute->signature->type =~ /Constructor$/) {
-                my $constructorType = $attribute->signature->type;
+            } elsif ($type =~ /Constructor$/) {
+                my $constructorType = $type;
                 $constructorType =~ s/Constructor$//;
                 # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor.
                 # We do not generate the header file for NamedConstructor of class XXXX,
@@ -2797,18 +2815,17 @@ sub GenerateImplementation
                     my $putForwards = $attribute->signature->extendedAttributes->{"PutForwards"};
                     if ($putForwards) {
                         my $implGetterFunctionName = $codeGenerator->WK_lcfirst($attribute->signature->extendedAttributes->{"ImplementedAs"} || $name);
-                        my $attributeType = $attribute->signature->type;
                         if ($attribute->signature->isNullable) {
-                            push(@implContent, "    RefPtr<${attributeType}> forwardedImpl = castedThis->wrapped().${implGetterFunctionName}();\n");
+                            push(@implContent, "    RefPtr<${type}> forwardedImpl = castedThis->wrapped().${implGetterFunctionName}();\n");
                             push(@implContent, "    if (!forwardedImpl)\n");
                             push(@implContent, "        return false;\n");
                             push(@implContent, "    auto& impl = *forwardedImpl;\n");
                         } else {
                             # Attribute is not nullable, the implementation is expected to return a reference.
-                            push(@implContent, "    Ref<${attributeType}> forwardedImpl = castedThis->wrapped().${implGetterFunctionName}();\n");
+                            push(@implContent, "    Ref<${type}> forwardedImpl = castedThis->wrapped().${implGetterFunctionName}();\n");
                             push(@implContent, "    auto& impl = forwardedImpl.get();\n");
                         }
-                        $attribute = $codeGenerator->GetAttributeFromInterface($interface, $attribute->signature->type, $putForwards);
+                        $attribute = $codeGenerator->GetAttributeFromInterface($interface, $type, $putForwards);
                     } else {
                         push(@implContent, "    auto& impl = castedThis->wrapped();\n");
                     }
@@ -2827,10 +2844,9 @@ sub GenerateImplementation
                 if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) {
                     $implIncludes{"<runtime/Error.h>"} = 1;
 
-                    my $argType = $attribute->signature->type;
-                    if ($codeGenerator->IsWrapperType($argType)) {
-                        push(@implContent, "    if (UNLIKELY(!value.isUndefinedOrNull() && !value.inherits(JS${argType}::info()))) {\n");
-                        push(@implContent, "        throwAttributeTypeError(*state, \"$interfaceName\", \"$name\", \"$argType\");\n");
+                    if ($codeGenerator->IsWrapperType($type)) {
+                        push(@implContent, "    if (UNLIKELY(!value.isUndefinedOrNull() && !value.inherits(JS${type}::info()))) {\n");
+                        push(@implContent, "        throwAttributeTypeError(*state, \"$interfaceName\", \"$name\", \"$type\");\n");
                         push(@implContent, "        return false;\n");
                         push(@implContent, "    };\n");
                     }
@@ -2840,7 +2856,7 @@ sub GenerateImplementation
                 push(@implContent, "    if (UNLIKELY(state->hadException()))\n");
                 push(@implContent, "        return false;\n");
 
-                if ($codeGenerator->IsEnumType($type)) {
+                if ($codeGenerator->IsStringBasedEnumType($type)) {
                     my @enumValues = $codeGenerator->ValidEnumValues($type);
                     my @enumChecks = ();
                     foreach my $enumValue (@enumValues) {
@@ -2850,7 +2866,12 @@ sub GenerateImplementation
                     push (@implContent, "        return false;\n");
                 }
 
-                if ($attribute->signature->type eq "double" or $attribute->signature->type eq "float") {
+                if ($codeGenerator->IsEnumType($type)) {
+                    push (@implContent, "    if (UNLIKELY(!nativeValue))\n");
+                    push (@implContent, "        return false;\n");
+                }
+
+                if ($type eq "double" or $type eq "float") {
                     push(@implContent, "    if (UNLIKELY(!std::isfinite(nativeValue))) {\n");
                     push(@implContent, "        throwVMTypeError(state);\n");
                     push(@implContent, "        return false;\n");
@@ -2888,8 +2909,10 @@ sub GenerateImplementation
                     push(@implContent, "    return true;\n");
                 } else {
                     my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
-                    if ($codeGenerator->IsTypedArrayType($attribute->signature->type) and not $attribute->signature->type eq "ArrayBuffer") {
+                    if ($codeGenerator->IsTypedArrayType($type) and not $type eq "ArrayBuffer") {
                         push(@arguments, "nativeValue.get()");
+                    } elsif ($codeGenerator->IsEnumType($type) and not $codeGenerator->IsStringBasedEnumType($type)) {
+                        push(@arguments, "nativeValue.value()");
                     } else {
                         push(@arguments, "nativeValue");
                     }
@@ -3444,7 +3467,7 @@ sub CanUseWTFOptionalForParameter
     # FIXME: We should progressively stop blacklisting each type below
     # and eventually get rid of this function entirely.
     return 0 if $parameter->isVariadic;
-    return 0 if $codeGenerator->IsEnumType($type);
+    return 0 if $codeGenerator->IsStringBasedEnumType($type);
 
     return 1;
 }
@@ -3638,7 +3661,7 @@ sub GenerateParametersCheck
                 push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
                 push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
             }
-        } elsif ($codeGenerator->IsEnumType($argType)) {
+        } elsif ($codeGenerator->IsStringBasedEnumType($argType)) {
             $implIncludes{"<runtime/Error.h>"} = 1;
 
             my $exceptionCheck = sub {
@@ -3681,6 +3704,42 @@ sub GenerateParametersCheck
                 &$exceptionCheck("");
                 &$enumValueCheck("");
             }
+        } elsif ($codeGenerator->IsEnumType($argType)) {
+            my $className = GetEnumerationClassName($argType);
+            $implIncludes{"<runtime/Error.h>"} = 1;
+
+            my $nativeType = $className;
+            my $optionalValue = "optionalValue";
+            my $defineOptionalValue = "auto optionalValue";
+            my $indent = "";
+
+            if ($parameter->isOptional && !defined($parameter->default)) {
+                $nativeType = "Optional<$className>";
+                $optionalValue = $name;
+                $defineOptionalValue = $name;
+            }
+
+            push(@$outputArray, "    auto ${name}Value = state->argument($argsIndex);\n");
+            push(@$outputArray, "    $nativeType $name;\n");
+
+            if ($parameter->isOptional) {
+                push(@$outputArray, "    if (${name}Value.isUndefined()) {\n");
+                if (defined($parameter->default)) {
+                    my $enumerationValueName = GetEnumerationValueName(substr($parameter->default, 1, -1));
+                    push(@$outputArray, "        $name = $className::$enumerationValueName;\n");
+                }
+                push(@$outputArray, "    } else {\n");
+                $indent = "    ";
+            }
+
+            push(@$outputArray, "$indent    $defineOptionalValue = parse$className(*state, ${name}Value);\n");
+            push(@$outputArray, "$indent    if (UNLIKELY(state->hadException()))\n");
+            push(@$outputArray, "$indent        return JSValue::encode(jsUndefined());\n");
+            push(@$outputArray, "$indent    if (UNLIKELY(!$optionalValue))\n");
+            push(@$outputArray, "$indent        return throwArgumentMustBeEnumError(*state, $argsIndex, \"$name\", \"$interfaceName\", $quotedFunctionName, expectedEnumerationValues$className);\n");
+            push(@$outputArray, "$indent    $name = optionalValue.value();\n") if $optionalValue ne $name;
+
+            push(@$outputArray, "    }\n") if $indent ne "";
         } else {
             # If the "StrictTypeChecking" extended attribute is present, and the argument's type is an
             # interface type, then if the incoming value does not implement that interface, a TypeError
@@ -3835,8 +3894,7 @@ sub GenerateCallbackHeader
         push(@headerContent, "\n    // Functions\n");
         foreach my $function (@{$interface->functions}) {
             my @params = @{$function->parameters};
-            if (!$function->signature->extendedAttributes->{"Custom"} &&
-                !(GetNativeType($function->signature->type) eq "bool")) {
+            if (!$function->signature->extendedAttributes->{"Custom"} && GetNativeType($function->signature->type) ne "bool") {
                 push(@headerContent, "    COMPILE_ASSERT(false)");
             }
 
@@ -3865,10 +3923,10 @@ sub GenerateCallbackHeader
     push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $interfaceName*);\n");
     push(@headerContent, "inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, $interfaceName& impl) { return toJS(state, globalObject, &impl); }\n\n");
 
-    push(@headerContent, "} // namespace WebCore\n\n");
+    push(@headerContent, "} // namespace WebCore\n");
+
     my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
-    push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString;
-    push(@headerContent, "#endif\n");
+    push(@headerContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
 }
 
 sub GenerateCallbackImplementation
@@ -3980,8 +4038,7 @@ sub GenerateCallbackImplementation
         push(@implContent, "\n// Functions\n");
         foreach my $function (@{$interface->functions}) {
             my @params = @{$function->parameters};
-            if ($function->signature->extendedAttributes->{"Custom"} ||
-                !(GetNativeType($function->signature->type) eq "bool")) {
+            if ($function->signature->extendedAttributes->{"Custom"} || GetNativeType($function->signature->type) ne "bool") {
                 next;
             }
 
@@ -4237,6 +4294,8 @@ sub GetNativeType
 {
     my $type = shift;
 
+    # FIXME: Maybe we can start using "auto" for most of these?
+
     my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($type);
     return "${svgNativeType}*" if $svgNativeType;
     return "RefPtr<DOMStringList>" if $type eq "DOMStringList";
@@ -4249,7 +4308,7 @@ sub GetNativeType
 
     return "Vector<" . GetNativeVectorInnerType($arrayOrSequenceType) . ">" if $arrayOrSequenceType;
     return "String" if $codeGenerator->IsStringBasedEnumType($type);
-    return GetEnumerationClassName($type) if $codeGenerator->IsEnumType($type);
+    return "auto" if $codeGenerator->IsEnumType($type);
 
     # For all other types, the native type is a pointer with same type name as the IDL type.
     return "${type}*";
@@ -4416,7 +4475,7 @@ sub JSValueToNative
 
     if ($codeGenerator->IsEnumType($type)) {
         my $className = GetEnumerationClassName($type);
-        return "enumerationValue$className($value.toWTFString(state)).value()";
+        return "parse$className(*state, $value)";
     }
 
     # Default, assume autogenerated type conversion routines
@@ -4467,7 +4526,6 @@ sub NativeToJSValue
 
     if ($codeGenerator->IsEnumType($type)) {
         AddToImplIncludes("<runtime/JSString.h>", $conditional);
-        $value = "stringValue($value)" unless $codeGenerator->IsStringBasedEnumType($type);
         return "jsStringWithCache(state, $value)";
     }
 
index f6810f5..fb98b29 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestActiveDOMObject_h
-#define JSTestActiveDOMObject_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestActiveDOMObject.h"
@@ -89,5 +88,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestActiveDOM
 
 
 } // namespace WebCore
-
-#endif
index 03f5768..c62f014 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestCallback_h
-#define JSTestCallback_h
+#pragma once
 
 #if ENABLE(SPEECH_SYNTHESIS)
 
@@ -65,5 +64,3 @@ inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject,
 } // namespace WebCore
 
 #endif // ENABLE(SPEECH_SYNTHESIS)
-
-#endif
index 9cc34d1..e865407 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestCallbackFunction_h
-#define JSTestCallbackFunction_h
+#pragma once
 
 #if ENABLE(SPEECH_SYNTHESIS)
 
@@ -64,5 +63,3 @@ inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject,
 } // namespace WebCore
 
 #endif // ENABLE(SPEECH_SYNTHESIS)
-
-#endif
index 86af57d..99352e2 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestClassWithJSBuiltinConstructor_h
-#define JSTestClassWithJSBuiltinConstructor_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestClassWithJSBuiltinConstructor.h"
@@ -88,5 +87,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestClassWith
 
 
 } // namespace WebCore
-
-#endif
index e41b16c..fd246df 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestCustomConstructorWithNoInterfaceObject_h
-#define JSTestCustomConstructorWithNoInterfaceObject_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestCustomConstructorWithNoInterfaceObject.h"
@@ -88,5 +87,3 @@ JSC::EncodedJSValue JSC_HOST_CALL constructJSTestCustomConstructorWithNoInterfac
 
 
 } // namespace WebCore
-
-#endif
index 278eb7c..610ab9e 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestCustomNamedGetter_h
-#define JSTestCustomNamedGetter_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestCustomNamedGetter.h"
@@ -92,5 +91,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestCustomNam
 
 
 } // namespace WebCore
-
-#endif
index dbd65c0..b7e4016 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestEventConstructor_h
-#define JSTestEventConstructor_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestEventConstructor.h"
@@ -90,5 +89,3 @@ bool fillTestEventConstructorInit(TestEventConstructorInit&, JSDictionary&);
 
 
 } // namespace WebCore
-
-#endif
index 1959986..2b86219 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestEventTarget_h
-#define JSTestEventTarget_h
+#pragma once
 
 #include "JSEventTarget.h"
 #include "TestEventTarget.h"
@@ -81,5 +80,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestEventTarg
 
 
 } // namespace WebCore
-
-#endif
index ab96dfa..afc3aed 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestException_h
-#define JSTestException_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestException.h"
@@ -90,5 +89,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestException
 
 
 } // namespace WebCore
-
-#endif
index 1456680..a8af96c 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestGenerateIsReachable_h
-#define JSTestGenerateIsReachable_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestGenerateIsReachable.h"
@@ -86,5 +85,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestGenerateI
 
 
 } // namespace WebCore
-
-#endif
index a705eed..2a21fe8 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestGlobalObject_h
-#define JSTestGlobalObject_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestGlobalObject.h"
@@ -119,5 +118,3 @@ public:
 
 
 } // namespace WebCore
-
-#endif
index f0b60b4..11d01ec 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestInterface_h
-#define JSTestInterface_h
+#pragma once
 
 #if ENABLE(Condition1) || ENABLE(Condition2)
 
@@ -115,5 +114,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestInterface
 } // namespace WebCore
 
 #endif // ENABLE(Condition1) || ENABLE(Condition2)
-
-#endif
index a28f657..b663ec1 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestJSBuiltinConstructor_h
-#define JSTestJSBuiltinConstructor_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 
@@ -67,5 +66,3 @@ protected:
 
 
 } // namespace WebCore
-
-#endif
index e6be1ee..310ca65 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestMediaQueryListListener_h
-#define JSTestMediaQueryListListener_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestMediaQueryListListener.h"
@@ -86,5 +85,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestMediaQuer
 
 
 } // namespace WebCore
-
-#endif
index e13a758..63a9a33 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestNamedConstructor_h
-#define JSTestNamedConstructor_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestNamedConstructor.h"
@@ -87,5 +86,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestNamedCons
 
 
 } // namespace WebCore
-
-#endif
index 59b12b4..5e6b107 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestNode_h
-#define JSTestNode_h
+#pragma once
 
 #include "JSNode.h"
 #include "TestNode.h"
@@ -69,5 +68,3 @@ protected:
 
 
 } // namespace WebCore
-
-#endif
index 00d2864..78f3b86 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestNondeterministic_h
-#define JSTestNondeterministic_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestNondeterministic.h"
@@ -86,5 +85,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestNondeterm
 
 
 } // namespace WebCore
-
-#endif
index ba23981..f14e691 100644 (file)
@@ -89,10 +89,11 @@ using namespace JSC;
 
 namespace WebCore {
 
-const String& stringValue(TestEnumType);
-Optional<TestEnumType> enumerationValueTestEnumType(const String&);
+JSString* jsStringWithCache(ExecState*, TestEnumType);
+Optional<TestEnumType> parseTestEnumType(ExecState&, JSValue);
+extern const char* const expectedEnumerationValuesTestEnumType;
 
-const String& stringValue(TestEnumType enumerationValue)
+JSString* jsStringWithCache(ExecState* state, TestEnumType enumerationValue)
 {
     static NeverDestroyed<const String> values[] = {
         ASCIILiteral(""),
@@ -100,17 +101,22 @@ const String& stringValue(TestEnumType enumerationValue)
         ASCIILiteral("EnumValue2"),
         ASCIILiteral("EnumValue3"),
     };
-    static_assert(!static_cast<size_t>(TestEnumType::EmptyString), "TestEnumType::EmptyString is not 0 as expected");
+    static_assert(static_cast<size_t>(TestEnumType::EmptyString) == 0, "TestEnumType::EmptyString is not 0 as expected");
     static_assert(static_cast<size_t>(TestEnumType::EnumValue1) == 1, "TestEnumType::EnumValue1 is not 1 as expected");
     static_assert(static_cast<size_t>(TestEnumType::EnumValue2) == 2, "TestEnumType::EnumValue2 is not 2 as expected");
     static_assert(static_cast<size_t>(TestEnumType::EnumValue3) == 3, "TestEnumType::EnumValue3 is not 3 as expected");
     ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
-    return values[static_cast<size_t>(enumerationValue)];
+    return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
 }
 
-Optional<TestEnumType> enumerationValueTestEnumType(const String& stringValue)
+template<> struct JSValueTraits<TestEnumType> {
+    static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, TestEnumType value) { return jsStringWithCache(state, value); }
+};
+
+Optional<TestEnumType> parseTestEnumType(ExecState& state, JSValue value)
 {
-    if (stringValue == "")
+    auto stringValue = value.toWTFString(&state);
+    if (stringValue.isEmpty())
         return TestEnumType::EmptyString;
     if (stringValue == "EnumValue1")
         return TestEnumType::EnumValue1;
@@ -121,10 +127,13 @@ Optional<TestEnumType> enumerationValueTestEnumType(const String& stringValue)
     return Nullopt;
 }
 
-const String& stringValue(Optional);
-Optional<Optional> enumerationValueOptional(const String&);
+const char* const expectedEnumerationValuesTestEnumType = "\"\", \"EnumValue1\", \"EnumValue2\", \"EnumValue3\"";
+
+JSString* jsStringWithCache(ExecState*, Optional);
+Optional<Optional> parseOptional(ExecState&, JSValue);
+extern const char* const expectedEnumerationValuesOptional;
 
-const String& stringValue(Optional enumerationValue)
+JSString* jsStringWithCache(ExecState* state, Optional enumerationValue)
 {
     static NeverDestroyed<const String> values[] = {
         ASCIILiteral(""),
@@ -132,17 +141,22 @@ const String& stringValue(Optional enumerationValue)
         ASCIILiteral("OptionalValue2"),
         ASCIILiteral("OptionalValue3"),
     };
-    static_assert(!static_cast<size_t>(Optional::EmptyString), "Optional::EmptyString is not 0 as expected");
+    static_assert(static_cast<size_t>(Optional::EmptyString) == 0, "Optional::EmptyString is not 0 as expected");
     static_assert(static_cast<size_t>(Optional::OptionalValue1) == 1, "Optional::OptionalValue1 is not 1 as expected");
     static_assert(static_cast<size_t>(Optional::OptionalValue2) == 2, "Optional::OptionalValue2 is not 2 as expected");
     static_assert(static_cast<size_t>(Optional::OptionalValue3) == 3, "Optional::OptionalValue3 is not 3 as expected");
     ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
-    return values[static_cast<size_t>(enumerationValue)];
+    return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
 }
 
-Optional<Optional> enumerationValueOptional(const String& stringValue)
+template<> struct JSValueTraits<Optional> {
+    static JSString* arrayJSValue(ExecState* state, JSDOMGlobalObject*, Optional value) { return jsStringWithCache(state, value); }
+};
+
+Optional<Optional> parseOptional(ExecState& state, JSValue value)
 {
-    if (stringValue == "")
+    auto stringValue = value.toWTFString(&state);
+    if (stringValue.isEmpty())
         return Optional::EmptyString;
     if (stringValue == "OptionalValue1")
         return Optional::OptionalValue1;
@@ -153,6 +167,8 @@ Optional<Optional> enumerationValueOptional(const String& stringValue)
     return Nullopt;
 }
 
+const char* const expectedEnumerationValuesOptional = "\"\", \"OptionalValue1\", \"OptionalValue2\", \"OptionalValue3\"";
+
 // Functions
 
 #if ENABLE(TEST_FEATURE)
@@ -1054,7 +1070,7 @@ EncodedJSValue jsTestObjEnumAttr(ExecState* state, EncodedJSValue thisValue, Pro
         return throwGetterTypeError(*state, "TestObj", "enumAttr");
     }
     auto& impl = castedThis->wrapped();
-    JSValue result = jsStringWithCache(state, stringValue(impl.enumAttr()));
+    JSValue result = jsStringWithCache(state, impl.enumAttr());
     return JSValue::encode(result);
 }
 
@@ -2211,7 +2227,7 @@ EncodedJSValue jsTestObjAttributeWithReservedEnumType(ExecState* state, EncodedJ
         return throwGetterTypeError(*state, "TestObj", "attributeWithReservedEnumType");
     }
     auto& impl = castedThis->wrapped();
-    JSValue result = jsStringWithCache(state, stringValue(impl.attributeWithReservedEnumType()));
+    JSValue result = jsStringWithCache(state, impl.attributeWithReservedEnumType());
     return JSValue::encode(result);
 }
 
@@ -2299,12 +2315,12 @@ bool setJSTestObjEnumAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSV
         return throwSetterTypeError(*state, "TestObj", "enumAttr");
     }
     auto& impl = castedThis->wrapped();
-    TestEnumType nativeValue = enumerationValueTestEnumType(value.toWTFString(state)).value();
+    auto nativeValue = parseTestEnumType(*state, value);
     if (UNLIKELY(state->hadException()))
         return false;
-    if (nativeValue != "" && nativeValue != "EnumValue1" && nativeValue != "EnumValue2" && nativeValue != "EnumValue3")
+    if (UNLIKELY(!nativeValue))
         return false;
-    impl.setEnumAttr(nativeValue);
+    impl.setEnumAttr(nativeValue.value());
     return true;
 }
 
@@ -3366,12 +3382,12 @@ bool setJSTestObjAttributeWithReservedEnumType(ExecState* state, EncodedJSValue
         return throwSetterTypeError(*state, "TestObj", "attributeWithReservedEnumType");
     }
     auto& impl = castedThis->wrapped();
-    Optional nativeValue = enumerationValueOptional(value.toWTFString(state)).value();
+    auto nativeValue = parseOptional(*state, value);
     if (UNLIKELY(state->hadException()))
         return false;
-    if (nativeValue != "" && nativeValue != "OptionalValue1" && nativeValue != "OptionalValue2" && nativeValue != "OptionalValue3")
+    if (UNLIKELY(!nativeValue))
         return false;
-    impl.setAttributeWithReservedEnumType(nativeValue);
+    impl.setAttributeWithReservedEnumType(nativeValue.value());
     return true;
 }
 
@@ -3779,13 +3795,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithEnumArg(ExecSta
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    // Keep pointer to the JSString in a local so we don't need to ref the String.
-    auto* enumArgString = state->argument(0).toString(state);
-    auto& enumArg = enumArgString->value(state);
+    auto enumArgValue = state->argument(0);
+    TestEnumType enumArg;
+    auto optionalValue = parseTestEnumType(*state, enumArgValue);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
-    if (enumArg != "" && enumArg != "EnumValue1" && enumArg != "EnumValue2" && enumArg != "EnumValue3")
-        return throwArgumentMustBeEnumError(*state, 0, "enumArg", "TestObj", "methodWithEnumArg", "\"\", \"EnumValue1\", \"EnumValue2\", \"EnumValue3\"");
+    if (!optionalValue)
+        return throwArgumentMustBeEnumError(*state, 0, "enumArg", "TestObj", "methodWithEnumArg", expectedEnumerationValuesTestEnumType);
+    enumArg = optionalValue.value();
     impl.methodWithEnumArg(enumArg);
     return JSValue::encode(jsUndefined());
 }
@@ -3798,15 +3815,17 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalEnumArg
         return throwThisTypeError(*state, "TestObj", "methodWithOptionalEnumArgAndDefaultValue");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
-    String enumArg;
-    if (state->argument(0).isUndefined())
-        enumArg = ASCIILiteral("EnumValue1");
-    else {
-        enumArg = state->uncheckedArgument(0).toWTFString(state);
+    auto enumArgValue = state->argument(0);
+    TestEnumType enumArg;
+    if (enumArgValue.isUndefined()) {
+        enumArg = TestEnumType::EnumValue1;
+    } else {
+        auto optionalValue = parseTestEnumType(*state, enumArgValue);
         if (UNLIKELY(state->hadException()))
             return JSValue::encode(jsUndefined());
-        if (enumArg != "" && enumArg != "EnumValue1" && enumArg != "EnumValue2" && enumArg != "EnumValue3")
-            return throwArgumentMustBeEnumError(*state, 0, "enumArg", "TestObj", "methodWithOptionalEnumArgAndDefaultValue", "\"\", \"EnumValue1\", \"EnumValue2\", \"EnumValue3\"");
+        if (!optionalValue)
+            return throwArgumentMustBeEnumError(*state, 0, "enumArg", "TestObj", "methodWithOptionalEnumArgAndDefaultValue", expectedEnumerationValuesTestEnumType);
+        enumArg = optionalValue.value();
     }
     impl.methodWithOptionalEnumArgAndDefaultValue(enumArg);
     return JSValue::encode(jsUndefined());
index f7c87a0..7fd7ece 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestObj_h
-#define JSTestObj_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestObj.h"
@@ -104,5 +103,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestObj*);
 
 
 } // namespace WebCore
-
-#endif
index 26537e9..7de9c4f 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestOverloadedConstructors_h
-#define JSTestOverloadedConstructors_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestOverloadedConstructors.h"
@@ -86,5 +85,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestOverloade
 
 
 } // namespace WebCore
-
-#endif
index 0fac545..f273ac1 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestOverrideBuiltins_h
-#define JSTestOverrideBuiltins_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestOverrideBuiltins.h"
@@ -93,5 +92,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestOverrideB
 
 
 } // namespace WebCore
-
-#endif
index 55a0b72..500ad59 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestSerializedScriptValueInterface_h
-#define JSTestSerializedScriptValueInterface_h
+#pragma once
 
 #if ENABLE(Condition1) || ENABLE(Condition2)
 
@@ -94,5 +93,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestSerialize
 } // namespace WebCore
 
 #endif // ENABLE(Condition1) || ENABLE(Condition2)
-
-#endif
index 5e2416a..33f1359 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSTestTypedefs_h
-#define JSTestTypedefs_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "TestTypedefs.h"
@@ -89,5 +88,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, TestTypedefs*
 
 
 } // namespace WebCore
-
-#endif
index 2e6a5b8..243c51b 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSattribute_h
-#define JSattribute_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "attribute.h"
@@ -90,5 +89,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, attribute*);
 
 
 } // namespace WebCore
-
-#endif
index ec841e4..c9ddd32 100644 (file)
@@ -18,8 +18,7 @@
     Boston, MA 02110-1301, USA.
 */
 
-#ifndef JSreadonly_h
-#define JSreadonly_h
+#pragma once
 
 #include "JSDOMWrapper.h"
 #include "readonly.h"
@@ -86,5 +85,3 @@ JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, readonly*);
 
 
 } // namespace WebCore
-
-#endif
index 53d1c1e..df67c29 100644 (file)
@@ -47,47 +47,32 @@ CryptoKey::~CryptoKey()
 {
 }
 
-String CryptoKey::type() const
-{
-    switch (m_type) {
-    case CryptoKeyType::Secret:
-        return ASCIILiteral("secret");
-    case CryptoKeyType::Public:
-        return ASCIILiteral("public");
-    case CryptoKeyType::Private:
-        return ASCIILiteral("private");
-    }
-    RELEASE_ASSERT_NOT_REACHED();
-    return emptyString();
-}
-
 void CryptoKey::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const
 {
     builder.add("name", CryptoAlgorithmRegistry::singleton().nameForIdentifier(m_algorithm));
     // Subclasses will add other keys.
 }
 
-Vector<String> CryptoKey::usages() const
+Vector<KeyUsage> CryptoKey::usages() const
 {
     // The result is ordered alphabetically.
-    Vector<String> result;
+    Vector<KeyUsage> result;
     if (m_usages & CryptoKeyUsageDecrypt)
-        result.append(ASCIILiteral("decrypt"));
+        result.append(KeyUsage::Decrypt);
     if (m_usages & CryptoKeyUsageDeriveBits)
-        result.append(ASCIILiteral("deriveBits"));
+        result.append(KeyUsage::DeriveBits);
     if (m_usages & CryptoKeyUsageDeriveKey)
-        result.append(ASCIILiteral("deriveKey"));
+        result.append(KeyUsage::DeriveKey);
     if (m_usages & CryptoKeyUsageEncrypt)
-        result.append(ASCIILiteral("encrypt"));
+        result.append(KeyUsage::Encrypt);
     if (m_usages & CryptoKeyUsageSign)
-        result.append(ASCIILiteral("sign"));
+        result.append(KeyUsage::Sign);
     if (m_usages & CryptoKeyUsageUnwrapKey)
-        result.append(ASCIILiteral("unwrapKey"));
+        result.append(KeyUsage::UnwrapKey);
     if (m_usages & CryptoKeyUsageVerify)
-        result.append(ASCIILiteral("verify"));
+        result.append(KeyUsage::Verify);
     if (m_usages & CryptoKeyUsageWrapKey)
-        result.append(ASCIILiteral("wrapKey"));
-
+        result.append(KeyUsage::WrapKey);
     return result;
 }
 
index 7df9e1a..07fb7d9 100644 (file)
@@ -47,6 +47,10 @@ enum class CryptoKeyClass {
     RSA
 };
 
+enum class KeyUsage { Encrypt, Decrypt, Sign, Verify, DeriveKey, DeriveBits, WrapKey, UnwrapKey };
+
+using KeyType = CryptoKeyType;
+
 class CryptoKey : public RefCounted<CryptoKey> {
 public:
     CryptoKey(CryptoAlgorithmIdentifier, CryptoKeyType, bool extractable, CryptoKeyUsage);
@@ -54,10 +58,10 @@ public:
 
     virtual CryptoKeyClass keyClass() const = 0;
 
-    String type() const;
+    CryptoKeyType type() const;
     bool extractable() const { return m_extractable; }
     virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&) const;
-    Vector<String> usages() const;
+    Vector<KeyUsage> usages() const;
 
     CryptoAlgorithmIdentifier algorithmIdentifier() const { return m_algorithm; }
     CryptoKeyUsage usagesBitmap() const { return m_usages; }
@@ -74,6 +78,11 @@ private:
     CryptoKeyUsage m_usages;
 };
 
+inline CryptoKeyType CryptoKey::type() const
+{
+    return m_type;
+}
+
 } // namespace WebCore
 
 #define SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(ToClassName, KeyClass) \
index 747666b..0050993 100644 (file)
@@ -182,16 +182,16 @@ auto FontFaceSet::promise(JSC::ExecState& execState) -> Promise&
     return m_promise.value();
 }
     
-String FontFaceSet::status() const
+FontFaceSetLoadStatus FontFaceSet::status() const
 {
     switch (m_backing->status()) {
     case CSSFontFaceSet::Status::Loading:
-        return ASCIILiteral("loading");
+        return FontFaceSetLoadStatus::Loading;
     case CSSFontFaceSet::Status::Loaded:
-        return ASCIILiteral("loaded");
+        return FontFaceSetLoadStatus::Loaded;
     }
     ASSERT_NOT_REACHED();
-    return ASCIILiteral("loaded");
+    return FontFaceSetLoadStatus::Loaded;
 }
 
 bool FontFaceSet::canSuspendForDocumentSuspension() const
index 8d0610c..2953a9a 100644 (file)
@@ -35,6 +35,8 @@ namespace WebCore {
 
 class DOMCoreException;
 
+enum class FontFaceSetLoadStatus { Loading, Loaded };
+
 class FontFaceSet final : public RefCounted<FontFaceSet>, private CSSFontFaceSetClient, public EventTargetWithInlineData, private ActiveDOMObject {
 public:
     static Ref<FontFaceSet> create(Document&, const Vector<RefPtr<FontFace>>& initialFaces);
@@ -50,7 +52,7 @@ public:
     void load(JSC::ExecState&, const String& font, const String& text, DeferredWrapper&& promise, ExceptionCode&);
     bool check(const String& font, const String& text, ExceptionCode&);
 
-    String status() const;
+    FontFaceSetLoadStatus status() const;
 
     typedef DOMPromise<FontFaceSet&, DOMCoreException&> Promise;
     Promise& promise(JSC::ExecState&);
index 9ad2b9d..62b8b36 100644 (file)
@@ -3041,7 +3041,7 @@ void HTMLMediaElement::playInternal()
             if (m_session) {
                 m_session->addActiveMediaElement(*this);
 
-                if (m_session->kindEnum() == MediaSession::Kind::Content) {
+                if (m_session->kind() == MediaSessionKind::Content) {
                     if (Page* page = document().page())
                         page->chrome().client().focusedContentMediaElementDidChange(m_elementID);
                 }
index 9ed6117..18e0b6d 100644 (file)
@@ -381,30 +381,12 @@ URL HTMLVideoElement::posterImageURL() const
 
 #if ENABLE(VIDEO_PRESENTATION_MODE)
 
-static const AtomicString& presentationModeFullscreen()
+bool HTMLVideoElement::webkitSupportsPresentationMode(VideoPresentationMode mode) const
 {
-    static NeverDestroyed<AtomicString> fullscreen("fullscreen", AtomicString::ConstructFromLiteral);
-    return fullscreen;
-}
-
-static const AtomicString& presentationModePictureInPicture()
-{
-    static NeverDestroyed<AtomicString> pictureInPicture("picture-in-picture", AtomicString::ConstructFromLiteral);
-    return pictureInPicture;
-}
-
-static const AtomicString& presentationModeInline()
-{
-    static NeverDestroyed<AtomicString> inlineMode("inline", AtomicString::ConstructFromLiteral);
-    return inlineMode;
-}
-
-bool HTMLVideoElement::webkitSupportsPresentationMode(const String& mode) const
-{
-    if (mode == presentationModeFullscreen())
+    if (mode == VideoPresentationMode::Fullscreen)
         return mediaSession().fullscreenPermitted(*this) && supportsFullscreen(HTMLMediaElementEnums::VideoFullscreenModeStandard);
 
-    if (mode == presentationModePictureInPicture()) {
+    if (mode == VideoPresentationMode::PictureInPicture) {
 #if PLATFORM(COCOA)
         if (!supportsPictureInPicture())
             return false;
@@ -413,39 +395,29 @@ bool HTMLVideoElement::webkitSupportsPresentationMode(const String& mode) const
         return mediaSession().allowsPictureInPicture(*this) && supportsFullscreen(HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
     }
 
-    if (mode == presentationModeInline())
+    if (mode == VideoPresentationMode::Inline)
         return !mediaSession().requiresFullscreenForVideoPlayback(*this);
 
     return false;
 }
 
-static bool presentationModeToFullscreenMode(const String& presentationMode, HTMLMediaElementEnums::VideoFullscreenMode& fullscreenMode)
+static inline HTMLMediaElementEnums::VideoFullscreenMode toFullscreenMode(VideoPresentationMode mode)
 {
-    if (presentationMode == presentationModeFullscreen()) {
-        fullscreenMode = HTMLMediaElementEnums::VideoFullscreenModeStandard;
-        return true;
-    }
-
-    if (presentationMode == presentationModePictureInPicture()) {
-        fullscreenMode = HTMLMediaElementEnums::VideoFullscreenModePictureInPicture;
-        return true;
-    }
-
-    if (presentationMode == presentationModeInline()) {
-        fullscreenMode = HTMLMediaElementEnums::VideoFullscreenModeNone;
-        return true;
+    switch (mode) {
+    case VideoPresentationMode::Fullscreen:
+        return HTMLMediaElementEnums::VideoFullscreenModeStandard;
+    case VideoPresentationMode::PictureInPicture:
+        return HTMLMediaElementEnums::VideoFullscreenModePictureInPicture;
+    case VideoPresentationMode::Inline:
+        return HTMLMediaElementEnums::VideoFullscreenModeNone;
     }
-    return false;
+    ASSERT_NOT_REACHED();
+    return HTMLMediaElementEnums::VideoFullscreenModeNone;
 }
 
-void HTMLVideoElement::webkitSetPresentationMode(const String& mode)
+void HTMLVideoElement::webkitSetPresentationMode(VideoPresentationMode mode)
 {
-    VideoFullscreenMode fullscreenMode = VideoFullscreenModeNone;
-    if (!presentationModeToFullscreenMode(mode, fullscreenMode))
-        return;
-
-    LOG_WITH_STREAM(Media, stream << "HTMLVideoElement::webkitSetPresentationMode(" << this << ") - setting to \"" << mode << "\"");
-    setFullscreenMode(fullscreenMode);
+    setFullscreenMode(toFullscreenMode(mode));
 }
 
 void HTMLVideoElement::setFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
@@ -461,21 +433,24 @@ void HTMLVideoElement::setFullscreenMode(HTMLMediaElementEnums::VideoFullscreenM
     enterFullscreen(mode);
 }
 
-String HTMLVideoElement::webkitPresentationMode() const
+static VideoPresentationMode toPresentationMode(HTMLMediaElement::VideoFullscreenMode mode)
 {
-    HTMLMediaElement::VideoFullscreenMode mode = fullscreenMode();
-
-    if (mode == VideoFullscreenModeStandard)
-        return presentationModeFullscreen();
+    if (mode == HTMLMediaElementEnums::VideoFullscreenModeStandard)
+        return VideoPresentationMode::Fullscreen;
 
-    if (mode & VideoFullscreenModePictureInPicture)
-        return presentationModePictureInPicture();
+    if (mode & HTMLMediaElementEnums::VideoFullscreenModePictureInPicture)
+        return VideoPresentationMode::PictureInPicture;
 
-    if (mode == VideoFullscreenModeNone)
-        return presentationModeInline();
+    if (mode == HTMLMediaElementEnums::VideoFullscreenModeNone)
+        return VideoPresentationMode::Inline;
 
     ASSERT_NOT_REACHED();
-    return presentationModeInline();
+    return VideoPresentationMode::Inline;
+}
+
+VideoPresentationMode HTMLVideoElement::webkitPresentationMode() const
+{
+    return toPresentationMode(fullscreenMode());
 }
 
 void HTMLVideoElement::fullscreenModeChanged(VideoFullscreenMode mode)
index e8a9bc9..f493137 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef HTMLVideoElement_h
-#define HTMLVideoElement_h
+#pragma once
 
 #if ENABLE(VIDEO)
 
@@ -35,6 +34,8 @@ namespace WebCore {
 
 class HTMLImageLoader;
 
+enum class VideoPresentationMode { Fullscreen, PictureInPicture, Inline };
+
 class HTMLVideoElement final : public HTMLMediaElement {
 public:
     static Ref<HTMLVideoElement> create(const QualifiedName&, Document&, bool);
@@ -81,9 +82,9 @@ public:
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
 
 #if ENABLE(VIDEO_PRESENTATION_MODE)
-    bool webkitSupportsPresentationMode(const String&) const;
-    void webkitSetPresentationMode(const String&);
-    String webkitPresentationMode() const;
+    bool webkitSupportsPresentationMode(VideoPresentationMode) const;
+    void webkitSetPresentationMode(VideoPresentationMode);
+    VideoPresentationMode webkitPresentationMode() const;
     void setFullscreenMode(VideoFullscreenMode);
     void fullscreenModeChanged(VideoFullscreenMode) override;
 #endif
@@ -132,4 +133,3 @@ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLVideoElement)
 SPECIALIZE_TYPE_TRAITS_END()
 
 #endif // ENABLE(VIDEO)
-#endif // HTMLVideoElement_h
index b3c789f..6e6b2d5 100644 (file)
 #include "TextMetrics.h"
 #include "TextRun.h"
 #include "TextStream.h"
-
 #include <wtf/CheckedArithmetic.h>
 #include <wtf/MathExtras.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/StringBuilder.h>
 
-#if USE(CG)
-#if !PLATFORM(IOS)
+#if USE(CG) && !PLATFORM(IOS)
 #include <ApplicationServices/ApplicationServices.h>
-#endif // !PLATFORM(IOS)
 #endif
 
 #if PLATFORM(IOS)
 #include "Settings.h"
 #endif
 
-#if USE(CG)
-#define DefaultSmoothingQuality SmoothingQuality::Low
-#else
-#define DefaultSmoothingQuality SmoothingQuality::Medium
-#endif
-
 namespace WebCore {
 
 using namespace HTMLNames;
 
+#if USE(CG)
+const ImageSmoothingQuality defaultSmoothingQuality = ImageSmoothingQuality::Low;
+#else
+const ImageSmoothingQuality defaultSmoothingQuality = ImageSmoothingQuality::Medium;
+#endif
+
 static const int defaultFontSize = 10;
 static const char* const defaultFontFamily = "sans-serif";
 static const char* const defaultFont = "10px sans-serif";
@@ -207,7 +204,7 @@ CanvasRenderingContext2D::State::State()
     , hasInvertibleTransform(true)
     , lineDashOffset(0)
     , imageSmoothingEnabled(true)
-    , imageSmoothingQuality(DefaultSmoothingQuality)
+    , imageSmoothingQuality(defaultSmoothingQuality)
     , textAlign(StartTextAlign)
     , textBaseline(AlphabeticTextBaseline)
     , direction(Direction::Inherit)
@@ -933,21 +930,14 @@ static bool isFullCanvasCompositeMode(CompositeOperator op)
     return op == CompositeSourceIn || op == CompositeSourceOut || op == CompositeDestinationIn || op == CompositeDestinationAtop;
 }
 
-static bool parseWinding(const String& windingRuleString, WindRule& windRule)
+static WindRule toWindRule(CanvasWindingRule rule)
 {
-    if (windingRuleString == "nonzero")
-        windRule = RULE_NONZERO;
-    else if (windingRuleString == "evenodd")
-        windRule = RULE_EVENODD;
-    else
-        return false;
-    
-    return true;
+    return rule == CanvasWindingRule::Nonzero ? RULE_NONZERO : RULE_EVENODD;
 }
 
-void CanvasRenderingContext2D::fill(const String& windingRuleString)
+void CanvasRenderingContext2D::fill(CanvasWindingRule windingRule)
 {
-    fillInternal(m_path, windingRuleString);
+    fillInternal(m_path, windingRule);
 
 #if ENABLE(DASHBOARD_SUPPORT)
     clearPathForDashboardBackwardCompatibilityMode();
@@ -963,18 +953,18 @@ void CanvasRenderingContext2D::stroke()
 #endif
 }
 
-void CanvasRenderingContext2D::clip(const String& windingRuleString)
+void CanvasRenderingContext2D::clip(CanvasWindingRule windingRule)
 {
-    clipInternal(m_path, windingRuleString);
+    clipInternal(m_path, windingRule);
 
 #if ENABLE(DASHBOARD_SUPPORT)
     clearPathForDashboardBackwardCompatibilityMode();
 #endif
 }
 
-void CanvasRenderingContext2D::fill(DOMPath& path, const String& windingRuleString)
+void CanvasRenderingContext2D::fill(DOMPath& path, CanvasWindingRule windingRule)
 {
-    fillInternal(path.path(), windingRuleString);
+    fillInternal(path.path(), windingRule);
 }
 
 void CanvasRenderingContext2D::stroke(DOMPath& path)
@@ -982,12 +972,12 @@ void CanvasRenderingContext2D::stroke(DOMPath& path)
     strokeInternal(path.path());
 }
 
-void CanvasRenderingContext2D::clip(DOMPath& path, const String& windingRuleString)
+void CanvasRenderingContext2D::clip(DOMPath& path, CanvasWindingRule windingRule)
 {
-    clipInternal(path.path(), windingRuleString);
+    clipInternal(path.path(), windingRule);
 }
 
-void CanvasRenderingContext2D::fillInternal(const Path& path, const String& windingRuleString)
+void CanvasRenderingContext2D::fillInternal(const Path& path, CanvasWindingRule windingRule)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -1002,10 +992,7 @@ void CanvasRenderingContext2D::fillInternal(const Path& path, const String& wind
 
     if (!path.isEmpty()) {
         WindRule windRule = c->fillRule();
-        WindRule newWindRule = RULE_NONZERO;
-        if (!parseWinding(windingRuleString, newWindRule))
-            return;
-        c->setFillRule(newWindRule);
+        c->setFillRule(toWindRule(windingRule));
 
         if (isFullCanvasCompositeMode(state().globalComposite)) {
             beginCompositeLayer();
@@ -1057,7 +1044,7 @@ void CanvasRenderingContext2D::strokeInternal(const Path& path)
     }
 }
 
-void CanvasRenderingContext2D::clipInternal(const Path& path, const String& windingRuleString)
+void CanvasRenderingContext2D::clipInternal(const Path& path, CanvasWindingRule windingRule)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -1065,12 +1052,8 @@ void CanvasRenderingContext2D::clipInternal(const Path& path, const String& wind
     if (!state().hasInvertibleTransform)
         return;
 
-    WindRule newWindRule = RULE_NONZERO;
-    if (!parseWinding(windingRuleString, newWindRule))
-        return;
-
     realizeSaves();
-    c->canvasClip(path, newWindRule);
+    c->canvasClip(path, toWindRule(windingRule));
 }
 
 inline void CanvasRenderingContext2D::beginCompositeLayer()
@@ -1087,27 +1070,27 @@ inline void CanvasRenderingContext2D::endCompositeLayer()
 #endif
 }
 
-bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString)
+bool CanvasRenderingContext2D::isPointInPath(float x, float y, CanvasWindingRule windingRule)
 {
-    return isPointInPathInternal(m_path, x, y, windingRuleString);
+    return isPointInPathInternal(m_path, x, y, windingRule);
 }
 
-bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
+bool CanvasRenderingContext2D::isPointInStroke(float x, float y)
 {
     return isPointInStrokeInternal(m_path, x, y);
 }
 
-bool CanvasRenderingContext2D::isPointInPath(DOMPath& path, const float x, const float y, const String& windingRuleString)
+bool CanvasRenderingContext2D::isPointInPath(DOMPath& path, float x, float y, CanvasWindingRule windingRule)
 {
-    return isPointInPathInternal(path.path(), x, y, windingRuleString);
+    return isPointInPathInternal(path.path(), x, y, windingRule);
 }
 
-bool CanvasRenderingContext2D::isPointInStroke(DOMPath& path, const float x, const float y)
+bool CanvasRenderingContext2D::isPointInStroke(DOMPath& path, float x, float y)
 {
     return isPointInStrokeInternal(path.path(), x, y);
 }
 
-bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, float x, float y, const String& windingRuleString)
+bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, float x, float y, CanvasWindingRule windingRule)
 {
     GraphicsContext* c = drawingContext();
     if (!c)
@@ -1120,11 +1103,7 @@ bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, float x,
     if (!std::isfinite(transformedPoint.x()) || !std::isfinite(transformedPoint.y()))
         return false;
 
-    WindRule windRule = RULE_NONZERO;
-    if (!parseWinding(windingRuleString, windRule))
-        return false;
-    
-    return path.contains(transformedPoint, windRule);
+    return path.contains(transformedPoint, toWindRule(windingRule));
 }
 
 bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, float x, float y)
@@ -2558,14 +2537,14 @@ PlatformLayer* CanvasRenderingContext2D::platformLayer() const
 }
 #endif
 
-static InterpolationQuality smoothingToInterpolationQuality(CanvasRenderingContext2D::SmoothingQuality quality)
+static InterpolationQuality smoothingToInterpolationQuality(ImageSmoothingQuality quality)
 {
     switch (quality) {
-    case CanvasRenderingContext2D::SmoothingQuality::Low:
+    case ImageSmoothingQuality::Low:
         return InterpolationLow;
-    case CanvasRenderingContext2D::SmoothingQuality::Medium:
+    case ImageSmoothingQuality::Medium:
         return InterpolationMedium;
-    case CanvasRenderingContext2D::SmoothingQuality::High:
+    case ImageSmoothingQuality::High:
         return InterpolationHigh;
     }
 
@@ -2573,35 +2552,13 @@ static InterpolationQuality smoothingToInterpolationQuality(CanvasRenderingConte
     return InterpolationLow;
 };
 
-String CanvasRenderingContext2D::imageSmoothingQuality() const
+ImageSmoothingQuality CanvasRenderingContext2D::imageSmoothingQuality() const
 {
-    switch (state().imageSmoothingQuality) {
-    case SmoothingQuality::Low:
-        return ASCIILiteral("low");
-    case SmoothingQuality::Medium:
-        return ASCIILiteral("medium");
-    case SmoothingQuality::High:
-        return ASCIILiteral("high");
-    }
-
-    ASSERT_NOT_REACHED();
-    return ASCIILiteral("low");
+    return state().imageSmoothingQuality;
 }
 
-void CanvasRenderingContext2D::setImageSmoothingQuality(const String& smoothingQualityString)
+void CanvasRenderingContext2D::setImageSmoothingQuality(ImageSmoothingQuality quality)
 {
-    SmoothingQuality quality;
-    if (smoothingQualityString == "low")
-        quality = SmoothingQuality::Low;
-    else if (smoothingQualityString == "medium")
-        quality = SmoothingQuality::Medium;
-    else if (smoothingQualityString == "high")
-        quality = SmoothingQuality::High;
-    else {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-
     if (quality == state().imageSmoothingQuality)
         return;
 
index 00b9806..bc062ae 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef CanvasRenderingContext2D_h
-#define CanvasRenderingContext2D_h
+#pragma once
 
 #include "AffineTransform.h"
 #include "CanvasPathMethods.h"
@@ -58,6 +57,9 @@ class TextMetrics;
 
 typedef int ExceptionCode;
 
+enum class CanvasWindingRule { Nonzero, Evenodd };
+enum class ImageSmoothingQuality { Low, Medium, High };
+
 class CanvasRenderingContext2D final : public CanvasRenderingContext, public CanvasPathMethods {
 public:
     CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
@@ -129,19 +131,19 @@ public:
 
     void beginPath();
 
-    void fill(const String& winding = ASCIILiteral("nonzero"));
+    void fill(CanvasWindingRule = CanvasWindingRule::Nonzero);
     void stroke();
-    void clip(const String& winding = ASCIILiteral("nonzero"));
+    void clip(CanvasWindingRule = CanvasWindingRule::Nonzero);
 
-    void fill(DOMPath&, const String& winding = ASCIILiteral("nonzero"));
+    void fill(DOMPath&, CanvasWindingRule = CanvasWindingRule::Nonzero);
     void stroke(DOMPath&);
-    void clip(DOMPath&, const String& winding = ASCIILiteral("nonzero"));
+    void clip(DOMPath&, CanvasWindingRule = CanvasWindingRule::Nonzero);
 
-    bool isPointInPath(const float x, const float y, const String& winding = ASCIILiteral("nonzero"));
-    bool isPointInStroke(const float x, const float y);
+    bool isPointInPath(float x, float y, CanvasWindingRule = CanvasWindingRule::Nonzero);
+    bool isPointInStroke(float x, float y);
 
-    bool isPointInPath(DOMPath&, const float x, const float y, const String& winding = ASCIILiteral("nonzero"));
-    bool isPointInStroke(DOMPath&, const float x, const float y);
+    bool isPointInPath(DOMPath&, float x, float y, CanvasWindingRule = CanvasWindingRule::Nonzero);
+    bool isPointInStroke(DOMPath&, float x, float y);
 
     void clearRect(float x, float y, float width, float height);
     void fillRect(float x, float y, float width, float height);
@@ -220,14 +222,8 @@ public:
     bool imageSmoothingEnabled() const;
     void setImageSmoothingEnabled(bool);
 
-    String imageSmoothingQuality() const;
-    void setImageSmoothingQuality(const String&);
-
-    enum class SmoothingQuality {
-        Low,
-        Medium,
-        High
-    };
+    ImageSmoothingQuality imageSmoothingQuality() const;
+    void setImageSmoothingQuality(ImageSmoothingQuality);
 
     bool usesDisplayListDrawing() const { return m_usesDisplayListDrawing; };
     void setUsesDisplayListDrawing(bool flag) { m_usesDisplayListDrawing = flag; };
@@ -291,7 +287,7 @@ private:
         Vector<float> lineDash;
         float lineDashOffset;
         bool imageSmoothingEnabled;
-        SmoothingQuality imageSmoothingQuality;
+        ImageSmoothingQuality imageSmoothingQuality;
 
         // Text state.
         TextAlign textAlign;
@@ -349,11 +345,11 @@ private:
     void beginCompositeLayer();
     void endCompositeLayer();
 
-    void fillInternal(const Path&, const String& winding);
+    void fillInternal(const Path&, CanvasWindingRule);
     void strokeInternal(const Path&);
-    void clipInternal(const Path&, const String& winding);
+    void clipInternal(const Path&, CanvasWindingRule);
 
-    bool isPointInPathInternal(const Path&, float x, float y, const String& winding);
+    bool isPointInPathInternal(const Path&, float x, float y, CanvasWindingRule);
     bool isPointInStrokeInternal(const Path&, float x, float y);
 
     void drawFocusIfNeededInternal(const Path&, Element*);
@@ -401,5 +397,3 @@ private:
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::CanvasRenderingContext2D, is2d())
-
-#endif
index 7dda72e..48bdf94 100644 (file)
@@ -157,13 +157,10 @@ void WebPlaybackSessionModelMediaElement::updateForEventName(const WTF::AtomicSt
         String localizedDeviceName;
 
         if (m_mediaElement->mediaControlsHost()) {
-            static NeverDestroyed<String> airplay(ASCIILiteral("airplay"));
-            static NeverDestroyed<String> tvout(ASCIILiteral("tvout"));
-
-            String type = m_mediaElement->mediaControlsHost()->externalDeviceType();
-            if (type == airplay)
+            auto type = m_mediaElement->mediaControlsHost()->externalDeviceType();
+            if (type == DeviceType::Airplay)
                 targetType = WebPlaybackSessionInterface::TargetTypeAirPlay;
-            else if (type == tvout)
+            else if (type == DeviceType::Tvout)
                 targetType = WebPlaybackSessionInterface::TargetTypeTVOut;
             localizedDeviceName = m_mediaElement->mediaControlsHost()->externalDeviceDisplayName();
         }
index c32307d..33e6cc1 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef SourceBufferPrivateClient_h
-#define SourceBufferPrivateClient_h
+#pragma once
 
 #if ENABLE(MEDIA_SOURCE)
 
@@ -45,8 +44,6 @@ class SourceBufferPrivateClient {
 public:
     virtual ~SourceBufferPrivateClient() { }
 
-    virtual void sourceBufferPrivateDidEndStream(SourceBufferPrivate*, const WTF::AtomicString&) = 0;
-
     struct InitializationSegment {
         MediaTime duration;
 
@@ -90,5 +87,3 @@ public:
 }
 
 #endif // ENABLE(MEDIA_SOURCE)
-
-#endif
index f2ed428..e2db6e2 100644 (file)
@@ -1,3 +1,13 @@
+2016-04-30  Darin Adler  <darin@apple.com>
+
+        Next batch of conversions to use C++ enum class instead of strings for enumerations
+        https://bugs.webkit.org/show_bug.cgi?id=157232
+
+        Reviewed by Chris Dumez.
+
+        * Scripts/webkitpy/style/checker.py: Skip the bindings script tests when doing style
+        checking. We don't want to waste time trying to make our generated code match our style.
+
 2016-04-29  Srinivasan Vijayaraghavan  <svijayaraghavan@apple.com>
 
         Add JSC test results in JSON format to a Buildbot log.
index f9f2015..42d5a15 100644 (file)
@@ -154,7 +154,6 @@ _PATH_RULES_SPECIFIER = [
       os.path.join('Source', 'WebCore', 'bindings', 'gobject', 'WebKitDOMEventTarget.h'),
       os.path.join('Source', 'WebCore', 'bindings', 'gobject', 'WebKitDOMNodeFilter.h'),
       os.path.join('Source', 'WebCore', 'bindings', 'gobject', 'WebKitDOMXPathNSResolver.h'),
-      os.path.join('Source', 'WebCore', 'bindings', 'scripts', 'test', 'GObject'),
       os.path.join('Source', 'WebKit', 'gtk', 'webkit'),
       os.path.join('Tools', 'DumpRenderTree', 'gtk')],
      ["-readability/naming",
@@ -321,11 +320,11 @@ _CMAKE_FILE_EXTENSION = 'cmake'
 # future merges.
 _SKIPPED_FILES_WITH_WARNING = [
     os.path.join('Tools', 'TestWebKitAPI', 'Tests', 'WebKitGtk'),
-    # All WebKit*.h files in Source/WebKit2/UIProcess/API/gtk,
-    # except those ending in ...Private.h are GTK+ API headers,
-    # which differ greatly from WebKit coding style.
+
+    # WebKit*.h files in Source/WebKit2/UIProcess/API/gtk, except those ending in Private.h are GTK+ API headers, which do not follow WebKit coding style.
     re.compile(re.escape(os.path.join('Source', 'WebKit2', 'UIProcess', 'API', 'gtk') + os.path.sep) + r'WebKit(?!.*Private\.h).*\.h$'),
     re.compile(re.escape(os.path.join('Source', 'WebKit2', 'WebProcess', 'InjectedBundle', 'API', 'gtk') + os.path.sep) + r'WebKit(?!.*Private\.h).*\.h$'),
+
     os.path.join('Source', 'WebKit2', 'UIProcess', 'API', 'gtk', 'webkit2.h'),
     os.path.join('Source', 'WebKit2', 'WebProcess', 'InjectedBundle', 'API', 'gtk', 'webkit-web-extension.h')]
 
@@ -335,7 +334,8 @@ _SKIPPED_FILES_WITH_WARNING = [
 # with FileType.NONE are automatically skipped without warning.
 _SKIPPED_FILES_WITHOUT_WARNING = [
     "LayoutTests" + os.path.sep,
-    ]
+    # Files generated by the bindings script should not be checked for style.
+    os.path.join('Source', 'WebCore', 'bindings', 'scripts', 'test')]
 
 # Extensions of files which are allowed to contain carriage returns.
 _CARRIAGE_RETURN_ALLOWED_FILE_EXTENSIONS = [