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)
commit1f2e6cada3486b8c5329e2c2044ffec6f42e3255
tree6d1101419c305c597fdc7ed8a9544524c1970187
parent3dc25ab79ba9480c49b5884ea5dde95e9661d7ae
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.

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