Bug 1640839 - Add IPC serializer for WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,dom-storage-reviewers,janv,padenot

Differential Revision: https://phabricator.services.mozilla.com/D201339
This commit is contained in:
Peter Van der Beken 2024-03-02 07:50:22 +00:00
Родитель cc2209dab3
Коммит 2c8bf85445
16 изменённых файлов: 93 добавлений и 128 удалений

Просмотреть файл

@ -20,6 +20,7 @@
#endif #endif
#include "mozilla/AppShutdown.h" #include "mozilla/AppShutdown.h"
#include "mozilla/dom/CanonicalBrowsingContext.h" #include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/BrowserHost.h" #include "mozilla/dom/BrowserHost.h"
#include "mozilla/dom/BrowserChild.h" #include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/BrowserParent.h" #include "mozilla/dom/BrowserParent.h"
@ -96,23 +97,17 @@ namespace IPC {
// Allow serialization and deserialization of OrientationType over IPC // Allow serialization and deserialization of OrientationType over IPC
template <> template <>
struct ParamTraits<mozilla::dom::OrientationType> struct ParamTraits<mozilla::dom::OrientationType>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::OrientationType> {
mozilla::dom::OrientationType, };
mozilla::dom::OrientationType::Portrait_primary,
mozilla::dom::OrientationType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::DisplayMode> struct ParamTraits<mozilla::dom::DisplayMode>
: public ContiguousEnumSerializer<mozilla::dom::DisplayMode, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::DisplayMode> {};
mozilla::dom::DisplayMode::Browser,
mozilla::dom::DisplayMode::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::PrefersColorSchemeOverride> struct ParamTraits<mozilla::dom::PrefersColorSchemeOverride>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::PrefersColorSchemeOverride, mozilla::dom::PrefersColorSchemeOverride> {};
mozilla::dom::PrefersColorSchemeOverride::None,
mozilla::dom::PrefersColorSchemeOverride::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::ExplicitActiveStatus> struct ParamTraits<mozilla::dom::ExplicitActiveStatus>
@ -124,10 +119,8 @@ struct ParamTraits<mozilla::dom::ExplicitActiveStatus>
// Allow serialization and deserialization of TouchEventsOverride over IPC // Allow serialization and deserialization of TouchEventsOverride over IPC
template <> template <>
struct ParamTraits<mozilla::dom::TouchEventsOverride> struct ParamTraits<mozilla::dom::TouchEventsOverride>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::TouchEventsOverride, mozilla::dom::TouchEventsOverride> {};
mozilla::dom::TouchEventsOverride::Disabled,
mozilla::dom::TouchEventsOverride::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::EmbedderColorSchemes> { struct ParamTraits<mozilla::dom::EmbedderColorSchemes> {

Просмотреть файл

@ -20,7 +20,7 @@
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
#include "mozilla/PresState.h" #include "mozilla/PresState.h"
#include "mozilla/StaticPrefs_fission.h" #include "mozilla/StaticPrefs_fission.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/BrowserParent.h" #include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/CanonicalBrowsingContext.h" #include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentChild.h"
@ -1797,10 +1797,8 @@ namespace IPC {
// Allow sending mozilla::dom::WireframeRectType enums over IPC. // Allow sending mozilla::dom::WireframeRectType enums over IPC.
template <> template <>
struct ParamTraits<mozilla::dom::WireframeRectType> struct ParamTraits<mozilla::dom::WireframeRectType>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::WireframeRectType, mozilla::dom::WireframeRectType> {};
mozilla::dom::WireframeRectType::Image,
mozilla::dom::WireframeRectType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::WireframeTaggedRect> { struct ParamTraits<mozilla::dom::WireframeTaggedRect> {

Просмотреть файл

@ -6,9 +6,18 @@
#ifndef _mozilla_dom_BindingIPCUtils_h #ifndef _mozilla_dom_BindingIPCUtils_h
#define _mozilla_dom_BindingIPCUtils_h #define _mozilla_dom_BindingIPCUtils_h
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
namespace mozilla::dom {
template <class Enum>
using WebIDLEnumSerializer = IPC::ContiguousEnumSerializerInclusive<
Enum, ContiguousEnumValues<Enum>::min, ContiguousEnumValues<Enum>::max>;
} // namespace mozilla::dom
namespace IPC { namespace IPC {
template <> template <>
struct ParamTraits<mozilla::dom::CallerType> struct ParamTraits<mozilla::dom::CallerType>

Просмотреть файл

@ -323,7 +323,9 @@ struct ParamTraits<mozilla::dom::PredefinedColorSpace> final
mozilla::dom::PredefinedColorSpace> { mozilla::dom::PredefinedColorSpace> {
using T = mozilla::dom::PredefinedColorSpace; using T = mozilla::dom::PredefinedColorSpace;
static bool Validate(const T& val) { return val < T::EndGuard_; } static bool Validate(const T& val) {
return val <= mozilla::ContiguousEnumValues<T>::max;
}
}; };
template <> template <>

Просмотреть файл

@ -9,6 +9,7 @@
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
#include "X11UndefineNone.h" #include "X11UndefineNone.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/ClientBinding.h" #include "mozilla/dom/ClientBinding.h"
#include "mozilla/dom/ClientsBinding.h" #include "mozilla/dom/ClientsBinding.h"
#include "mozilla/dom/DocumentBinding.h" #include "mozilla/dom/DocumentBinding.h"
@ -17,21 +18,16 @@
namespace IPC { namespace IPC {
template <> template <>
struct ParamTraits<mozilla::dom::ClientType> struct ParamTraits<mozilla::dom::ClientType>
: public ContiguousEnumSerializer<mozilla::dom::ClientType, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::ClientType> {};
mozilla::dom::ClientType::Window,
mozilla::dom::ClientType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::FrameType> struct ParamTraits<mozilla::dom::FrameType>
: public ContiguousEnumSerializer<mozilla::dom::FrameType, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::FrameType> {};
mozilla::dom::FrameType::Auxiliary,
mozilla::dom::FrameType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::VisibilityState> struct ParamTraits<mozilla::dom::VisibilityState>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::VisibilityState> {
mozilla::dom::VisibilityState, mozilla::dom::VisibilityState::Hidden, };
mozilla::dom::VisibilityState::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::StorageAccess> struct ParamTraits<mozilla::StorageAccess>

Просмотреть файл

@ -938,6 +938,13 @@ value passed to it as an argument is not one of the string values for the enum
then it returns `mozilla::Nothing()`, else it returns the right enum value in then it returns `mozilla::Nothing()`, else it returns the right enum value in
the `mozilla::Maybe`. the `mozilla::Maybe`.
`mozilla::dom::WebIDLEnumSerializer` is a templated alias in
[`BindingIPCUtils.h`](https://searchfox.org/mozilla-central/source/dom/bindings/BindingIPCUtils.h)
exported to `mozilla/dom/BindingIPCUtils.h` to implement an IPC serializer with
the right validation for WebIDL enums. It uses a
`mozilla::MaxContinuousEnumValue` that is generated for every WebIDL enum to
implement the validation.
#### Callback function types #### Callback function types
Callback functions are represented as an object, inheriting from Callback functions are represented as an object, inheriting from

Просмотреть файл

@ -9,6 +9,7 @@
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/HeadersBinding.h" #include "mozilla/dom/HeadersBinding.h"
#include "mozilla/dom/RequestBinding.h" #include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/ResponseBinding.h" #include "mozilla/dom/ResponseBinding.h"
@ -17,41 +18,30 @@
namespace IPC { namespace IPC {
template <> template <>
struct ParamTraits<mozilla::dom::HeadersGuardEnum> struct ParamTraits<mozilla::dom::HeadersGuardEnum>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::HeadersGuardEnum, mozilla::dom::HeadersGuardEnum::None, mozilla::dom::HeadersGuardEnum> {};
mozilla::dom::HeadersGuardEnum::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::ReferrerPolicy> struct ParamTraits<mozilla::dom::ReferrerPolicy>
: public ContiguousEnumSerializer<mozilla::dom::ReferrerPolicy, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::ReferrerPolicy> {
mozilla::dom::ReferrerPolicy::_empty,
mozilla::dom::ReferrerPolicy::EndGuard_> {
}; };
template <> template <>
struct ParamTraits<mozilla::dom::RequestMode> struct ParamTraits<mozilla::dom::RequestMode>
: public ContiguousEnumSerializer<mozilla::dom::RequestMode, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RequestMode> {};
mozilla::dom::RequestMode::Same_origin,
mozilla::dom::RequestMode::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::RequestCredentials> struct ParamTraits<mozilla::dom::RequestCredentials>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::RequestCredentials, mozilla::dom::RequestCredentials> {};
mozilla::dom::RequestCredentials::Omit,
mozilla::dom::RequestCredentials::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::RequestCache> struct ParamTraits<mozilla::dom::RequestCache>
: public ContiguousEnumSerializer<mozilla::dom::RequestCache, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RequestCache> {};
mozilla::dom::RequestCache::Default,
mozilla::dom::RequestCache::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::RequestRedirect> struct ParamTraits<mozilla::dom::RequestRedirect>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RequestRedirect> {
mozilla::dom::RequestRedirect, mozilla::dom::RequestRedirect::Follow, };
mozilla::dom::RequestRedirect::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::ResponseType> struct ParamTraits<mozilla::dom::ResponseType>
: public ContiguousEnumSerializer<mozilla::dom::ResponseType, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::ResponseType> {};
mozilla::dom::ResponseType::Basic,
mozilla::dom::ResponseType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::FetchDriverObserver::EndReason> struct ParamTraits<mozilla::dom::FetchDriverObserver::EndReason>
: public ContiguousEnumSerializerInclusive< : public ContiguousEnumSerializerInclusive<

Просмотреть файл

@ -8,6 +8,7 @@
#define mozilla_dom_gamepad_GamepadMessageUtils_h #define mozilla_dom_gamepad_GamepadMessageUtils_h
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/GamepadBinding.h" #include "mozilla/dom/GamepadBinding.h"
#include "mozilla/dom/GamepadHandle.h" #include "mozilla/dom/GamepadHandle.h"
#include "mozilla/dom/GamepadLightIndicatorBinding.h" #include "mozilla/dom/GamepadLightIndicatorBinding.h"
@ -18,24 +19,17 @@ namespace IPC {
template <> template <>
struct ParamTraits<mozilla::dom::GamepadLightIndicatorType> struct ParamTraits<mozilla::dom::GamepadLightIndicatorType>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::GamepadLightIndicatorType, mozilla::dom::GamepadLightIndicatorType> {};
mozilla::dom::GamepadLightIndicatorType(0),
mozilla::dom::GamepadLightIndicatorType(
mozilla::dom::GamepadLightIndicatorType::EndGuard_)> {};
template <> template <>
struct ParamTraits<mozilla::dom::GamepadMappingType> struct ParamTraits<mozilla::dom::GamepadMappingType>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::GamepadMappingType, mozilla::dom::GamepadMappingType(0), mozilla::dom::GamepadMappingType> {};
mozilla::dom::GamepadMappingType(
mozilla::dom::GamepadMappingType::EndGuard_)> {};
template <> template <>
struct ParamTraits<mozilla::dom::GamepadHand> struct ParamTraits<mozilla::dom::GamepadHand>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::GamepadHand> {};
mozilla::dom::GamepadHand, mozilla::dom::GamepadHand(0),
mozilla::dom::GamepadHand(mozilla::dom::GamepadHand::EndGuard_)> {};
template <> template <>
struct ParamTraits<mozilla::dom::GamepadCapabilityFlags> struct ParamTraits<mozilla::dom::GamepadCapabilityFlags>

Просмотреть файл

@ -10,6 +10,7 @@
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
#include "ipc/IPCMessageUtilsSpecializations.h" #include "ipc/IPCMessageUtilsSpecializations.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/indexedDB/Key.h" #include "mozilla/dom/indexedDB/Key.h"
#include "mozilla/dom/indexedDB/KeyPath.h" #include "mozilla/dom/indexedDB/KeyPath.h"
#include "mozilla/dom/IDBCursor.h" #include "mozilla/dom/IDBCursor.h"
@ -61,10 +62,8 @@ struct ParamTraits<mozilla::dom::indexedDB::KeyPath> {
template <> template <>
struct ParamTraits<mozilla::dom::IDBCursor::Direction> struct ParamTraits<mozilla::dom::IDBCursor::Direction>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::IDBCursor::Direction, mozilla::dom::IDBCursor::Direction> {};
mozilla::dom::IDBCursor::Direction::Next,
mozilla::dom::IDBCursor::Direction::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::IDBTransaction::Mode> struct ParamTraits<mozilla::dom::IDBTransaction::Mode>

Просмотреть файл

@ -5,9 +5,9 @@
#ifndef DOM_MEDIA_IPC_MFCDMSERIALIZERS_H_ #ifndef DOM_MEDIA_IPC_MFCDMSERIALIZERS_H_
#define DOM_MEDIA_IPC_MFCDMSERIALIZERS_H_ #define DOM_MEDIA_IPC_MFCDMSERIALIZERS_H_
#include "ipc/EnumSerializer.h"
#include "MediaData.h" #include "MediaData.h"
#include "mozilla/KeySystemConfig.h" #include "mozilla/KeySystemConfig.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/MediaKeyMessageEventBinding.h" #include "mozilla/dom/MediaKeyMessageEventBinding.h"
#include "mozilla/dom/MediaKeyStatusMapBinding.h" #include "mozilla/dom/MediaKeyStatusMapBinding.h"
@ -35,23 +35,17 @@ struct ParamTraits<mozilla::CryptoScheme>
template <> template <>
struct ParamTraits<mozilla::dom::MediaKeyMessageType> struct ParamTraits<mozilla::dom::MediaKeyMessageType>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::MediaKeyMessageType, mozilla::dom::MediaKeyMessageType> {};
mozilla::dom::MediaKeyMessageType::License_request,
mozilla::dom::MediaKeyMessageType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::MediaKeyStatus> struct ParamTraits<mozilla::dom::MediaKeyStatus>
: public ContiguousEnumSerializer<mozilla::dom::MediaKeyStatus, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::MediaKeyStatus> {
mozilla::dom::MediaKeyStatus::Usable,
mozilla::dom::MediaKeyStatus::EndGuard_> {
}; };
template <> template <>
struct ParamTraits<mozilla::dom::HDCPVersion> struct ParamTraits<mozilla::dom::HDCPVersion>
: public ContiguousEnumSerializer<mozilla::dom::HDCPVersion, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::HDCPVersion> {};
mozilla::dom::HDCPVersion::_1_0,
mozilla::dom::HDCPVersion::EndGuard_> {};
} // namespace IPC } // namespace IPC

Просмотреть файл

@ -6,6 +6,7 @@
#define DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_ #define DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "MediaMetadata.h" #include "MediaMetadata.h"
#include "mozilla/dom/MediaSession.h" #include "mozilla/dom/MediaSession.h"
#include "mozilla/dom/MediaSessionBinding.h" #include "mozilla/dom/MediaSessionBinding.h"
@ -87,17 +88,13 @@ struct ParamTraits<mozilla::dom::PositionState> {
template <> template <>
struct ParamTraits<mozilla::dom::MediaSessionPlaybackState> struct ParamTraits<mozilla::dom::MediaSessionPlaybackState>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::MediaSessionPlaybackState, mozilla::dom::MediaSessionPlaybackState> {};
mozilla::dom::MediaSessionPlaybackState::None,
mozilla::dom::MediaSessionPlaybackState::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::MediaSessionAction> struct ParamTraits<mozilla::dom::MediaSessionAction>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::MediaSessionAction, mozilla::dom::MediaSessionAction> {};
mozilla::dom::MediaSessionAction::Play,
mozilla::dom::MediaSessionAction::EndGuard_> {};
} // namespace IPC } // namespace IPC

Просмотреть файл

@ -8,6 +8,7 @@
#include "WebrtcIPCTraits.h" #include "WebrtcIPCTraits.h"
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
#include "ipc/IPCMessageUtilsSpecializations.h" #include "ipc/IPCMessageUtilsSpecializations.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/RTCDataChannelBinding.h" #include "mozilla/dom/RTCDataChannelBinding.h"
#include "mozilla/dom/RTCStatsReportBinding.h" #include "mozilla/dom/RTCStatsReportBinding.h"
@ -62,30 +63,22 @@ namespace IPC {
template <> template <>
struct ParamTraits<mozilla::dom::RTCStatsType> struct ParamTraits<mozilla::dom::RTCStatsType>
: public ContiguousEnumSerializer<mozilla::dom::RTCStatsType, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RTCStatsType> {};
mozilla::dom::RTCStatsType::Codec,
mozilla::dom::RTCStatsType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::RTCStatsIceCandidatePairState> struct ParamTraits<mozilla::dom::RTCStatsIceCandidatePairState>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::RTCStatsIceCandidatePairState, mozilla::dom::RTCStatsIceCandidatePairState> {};
mozilla::dom::RTCStatsIceCandidatePairState::Frozen,
mozilla::dom::RTCStatsIceCandidatePairState::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::RTCIceCandidateType> struct ParamTraits<mozilla::dom::RTCIceCandidateType>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::RTCIceCandidateType, mozilla::dom::RTCIceCandidateType> {};
mozilla::dom::RTCIceCandidateType::Host,
mozilla::dom::RTCIceCandidateType::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::RTCBundlePolicy> struct ParamTraits<mozilla::dom::RTCBundlePolicy>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RTCBundlePolicy> {
mozilla::dom::RTCBundlePolicy, };
mozilla::dom::RTCBundlePolicy::Balanced,
mozilla::dom::RTCBundlePolicy::EndGuard_> {};
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCIceServerInternal, mUrls, DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCIceServerInternal, mUrls,
mCredentialProvided, mUserNameProvided); mCredentialProvided, mUserNameProvided);
@ -218,10 +211,8 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCDataChannelStats, mId,
template <> template <>
struct ParamTraits<mozilla::dom::RTCDataChannelState> struct ParamTraits<mozilla::dom::RTCDataChannelState>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::RTCDataChannelState, mozilla::dom::RTCDataChannelState> {};
mozilla::dom::RTCDataChannelState::Connecting,
mozilla::dom::RTCDataChannelState::EndGuard_> {};
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCCodecStats, mTimestamp, DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCCodecStats, mTimestamp,
mType, mId, mPayloadType, mCodecType, mType, mId, mPayloadType, mCodecType,
@ -230,9 +221,7 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCCodecStats, mTimestamp,
template <> template <>
struct ParamTraits<mozilla::dom::RTCCodecType> struct ParamTraits<mozilla::dom::RTCCodecType>
: public ContiguousEnumSerializer<mozilla::dom::RTCCodecType, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RTCCodecType> {};
mozilla::dom::RTCCodecType::Encode,
mozilla::dom::RTCCodecType::EndGuard_> {};
} // namespace IPC } // namespace IPC
#endif // _WEBRTC_GLOBAL_H_ #endif // _WEBRTC_GLOBAL_H_

Просмотреть файл

@ -9,6 +9,7 @@
#include "ipc/IPCMessageUtils.h" #include "ipc/IPCMessageUtils.h"
#include "ipc/IPCMessageUtilsSpecializations.h" #include "ipc/IPCMessageUtilsSpecializations.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/RTCConfigurationBinding.h" #include "mozilla/dom/RTCConfigurationBinding.h"
#include "mozilla/media/webrtc/WebrtcGlobal.h" #include "mozilla/media/webrtc/WebrtcGlobal.h"
#include "mozilla/dom/CandidateInfo.h" #include "mozilla/dom/CandidateInfo.h"
@ -62,17 +63,15 @@ struct ParamTraits<mozilla::dom::OwningStringOrStringSequence> {
} }
}; };
template <typename T>
struct WebidlEnumSerializer
: public ContiguousEnumSerializer<T, T(0), T::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::RTCIceCredentialType> struct ParamTraits<mozilla::dom::RTCIceCredentialType>
: public WebidlEnumSerializer<mozilla::dom::RTCIceCredentialType> {}; : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::RTCIceCredentialType> {};
template <> template <>
struct ParamTraits<mozilla::dom::RTCIceTransportPolicy> struct ParamTraits<mozilla::dom::RTCIceTransportPolicy>
: public WebidlEnumSerializer<mozilla::dom::RTCIceTransportPolicy> {}; : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::RTCIceTransportPolicy> {};
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCIceServer, mCredential, DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCIceServer, mCredential,
mCredentialType, mUrl, mUrls, mUsername) mCredentialType, mUrl, mUrls, mUsername)

Просмотреть файл

@ -11,6 +11,7 @@
// Undo X11/X.h's definition of None // Undo X11/X.h's definition of None
#undef None #undef None
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/ServiceWorkerBinding.h" #include "mozilla/dom/ServiceWorkerBinding.h"
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h" #include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
@ -18,17 +19,13 @@ namespace IPC {
template <> template <>
struct ParamTraits<mozilla::dom::ServiceWorkerState> struct ParamTraits<mozilla::dom::ServiceWorkerState>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::ServiceWorkerState, mozilla::dom::ServiceWorkerState> {};
mozilla::dom::ServiceWorkerState::Parsed,
mozilla::dom::ServiceWorkerState::EndGuard_> {};
template <> template <>
struct ParamTraits<mozilla::dom::ServiceWorkerUpdateViaCache> struct ParamTraits<mozilla::dom::ServiceWorkerUpdateViaCache>
: public ContiguousEnumSerializer< : public mozilla::dom::WebIDLEnumSerializer<
mozilla::dom::ServiceWorkerUpdateViaCache, mozilla::dom::ServiceWorkerUpdateViaCache> {};
mozilla::dom::ServiceWorkerUpdateViaCache::Imports,
mozilla::dom::ServiceWorkerUpdateViaCache::EndGuard_> {};
} // namespace IPC } // namespace IPC

Просмотреть файл

@ -9,6 +9,7 @@
#include "WebGPUTypes.h" #include "WebGPUTypes.h"
#include "ipc/EnumSerializer.h" #include "ipc/EnumSerializer.h"
#include "ipc/IPCMessageUtils.h" #include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/WebGPUBinding.h" #include "mozilla/dom/WebGPUBinding.h"
#include "mozilla/webgpu/ffi/wgpu.h" #include "mozilla/webgpu/ffi/wgpu.h"
@ -20,7 +21,9 @@ namespace IPC {
: public ContiguousEnumSerializer<something, something(0), guard> {} : public ContiguousEnumSerializer<something, something(0), guard> {}
#define DEFINE_IPC_SERIALIZER_DOM_ENUM(something) \ #define DEFINE_IPC_SERIALIZER_DOM_ENUM(something) \
DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, something::EndGuard_) template <> \
struct ParamTraits<something> \
: public mozilla::dom::WebIDLEnumSerializer<something> {}
#define DEFINE_IPC_SERIALIZER_FFI_ENUM(something) \ #define DEFINE_IPC_SERIALIZER_FFI_ENUM(something) \
DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, something##_Sentinel) DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, something##_Sentinel)

Просмотреть файл

@ -6,7 +6,7 @@
#ifndef _mozilla_dom_WorkerIPCUtils_h #ifndef _mozilla_dom_WorkerIPCUtils_h
#define _mozilla_dom_WorkerIPCUtils_h #define _mozilla_dom_WorkerIPCUtils_h
#include "ipc/EnumSerializer.h" #include "mozilla/dom/BindingIPCUtils.h"
// Undo X11/X.h's definition of None // Undo X11/X.h's definition of None
#undef None #undef None
@ -17,9 +17,7 @@ namespace IPC {
template <> template <>
struct ParamTraits<mozilla::dom::WorkerType> struct ParamTraits<mozilla::dom::WorkerType>
: public ContiguousEnumSerializer<mozilla::dom::WorkerType, : public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::WorkerType> {};
mozilla::dom::WorkerType::Classic,
mozilla::dom::WorkerType::EndGuard_> {};
} // namespace IPC } // namespace IPC