mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 06:09:19 +00:00
Backed out 13 changesets (bug 1640839) for causing bustage on Element.cpp CLOSED TREE
Backed out changeset 179ceb82c9e5 (bug 1640839) Backed out changeset 73f498a821f0 (bug 1640839) Backed out changeset dc2d3d0e0365 (bug 1640839) Backed out changeset ddc989ac0509 (bug 1640839) Backed out changeset e595bb3feea8 (bug 1640839) Backed out changeset c85aca04e27f (bug 1640839) Backed out changeset 98e8e3a4047a (bug 1640839) Backed out changeset 59ef180517db (bug 1640839) Backed out changeset af2f5e293662 (bug 1640839) Backed out changeset 89aa6d9dc598 (bug 1640839) Backed out changeset 67b722a722f9 (bug 1640839) Backed out changeset 24a9665c6ced (bug 1640839) Backed out changeset d93f199385e9 (bug 1640839)
This commit is contained in:
parent
d8c28c253d
commit
8c2521e9d5
@ -20,7 +20,6 @@
|
||||
#endif
|
||||
#include "mozilla/AppShutdown.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/BrowserHost.h"
|
||||
#include "mozilla/dom/BrowserChild.h"
|
||||
#include "mozilla/dom/BrowserParent.h"
|
||||
@ -97,17 +96,23 @@ namespace IPC {
|
||||
// Allow serialization and deserialization of OrientationType over IPC
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::OrientationType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::OrientationType> {
|
||||
};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::OrientationType,
|
||||
mozilla::dom::OrientationType::Portrait_primary,
|
||||
mozilla::dom::OrientationType::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::DisplayMode>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::DisplayMode> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::DisplayMode,
|
||||
mozilla::dom::DisplayMode::Browser,
|
||||
mozilla::dom::DisplayMode::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::PrefersColorSchemeOverride>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::PrefersColorSchemeOverride> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::PrefersColorSchemeOverride,
|
||||
mozilla::dom::PrefersColorSchemeOverride::None,
|
||||
mozilla::dom::PrefersColorSchemeOverride::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ExplicitActiveStatus>
|
||||
@ -119,8 +124,10 @@ struct ParamTraits<mozilla::dom::ExplicitActiveStatus>
|
||||
// Allow serialization and deserialization of TouchEventsOverride over IPC
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::TouchEventsOverride>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::TouchEventsOverride> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::TouchEventsOverride,
|
||||
mozilla::dom::TouchEventsOverride::Disabled,
|
||||
mozilla::dom::TouchEventsOverride::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::EmbedderColorSchemes> {
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/PresState.h"
|
||||
#include "mozilla/StaticPrefs_fission.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
|
||||
#include "mozilla/dom/BrowserParent.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
@ -1797,8 +1797,10 @@ namespace IPC {
|
||||
// Allow sending mozilla::dom::WireframeRectType enums over IPC.
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::WireframeRectType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::WireframeRectType> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::WireframeRectType,
|
||||
mozilla::dom::WireframeRectType::Image,
|
||||
mozilla::dom::WireframeRectType::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::WireframeTaggedRect> {
|
||||
|
@ -244,8 +244,8 @@ class EffectCompositor {
|
||||
// animations that can be throttled, we will add an entry to the hashtable to
|
||||
// indicate that the style rule on the element is out of date but without
|
||||
// posting a restyle to update it.
|
||||
EnumeratedArray<CascadeLevel, nsTHashMap<PseudoElementHashEntry, bool>,
|
||||
kCascadeLevelCount>
|
||||
EnumeratedArray<CascadeLevel, CascadeLevel(kCascadeLevelCount),
|
||||
nsTHashMap<PseudoElementHashEntry, bool>>
|
||||
mElementsToRestyle;
|
||||
|
||||
bool mIsInPreTraverse = false;
|
||||
|
@ -1368,8 +1368,7 @@ void ChromeUtils::ClearStyleSheetCache(GlobalObject&) {
|
||||
static WebIDLProcType ProcTypeToWebIDL(mozilla::ProcType aType) {
|
||||
// Max is the value of the last enum, not the length, so add one.
|
||||
static_assert(
|
||||
static_cast<size_t>(MaxContiguousEnumValue<WebIDLProcType>::value) ==
|
||||
static_cast<size_t>(ProcType::Max),
|
||||
WebIDLProcTypeValues::Count == static_cast<size_t>(ProcType::Max) + 1,
|
||||
"In order for this static cast to be okay, "
|
||||
"WebIDLProcType must match ProcType exactly");
|
||||
|
||||
@ -2076,9 +2075,9 @@ unsigned ChromeUtils::AliveUtilityProcesses(const GlobalObject&) {
|
||||
void ChromeUtils::GetAllPossibleUtilityActorNames(GlobalObject& aGlobal,
|
||||
nsTArray<nsCString>& aNames) {
|
||||
aNames.Clear();
|
||||
for (UtilityActorName idlName :
|
||||
MakeWebIDLEnumeratedRange<WebIDLUtilityActorName>()) {
|
||||
aNames.AppendElement(GetEnumString(idlName));
|
||||
for (size_t i = 0; i < WebIDLUtilityActorNameValues::Count; ++i) {
|
||||
auto idlName = static_cast<UtilityActorName>(i);
|
||||
aNames.AppendElement(WebIDLUtilityActorNameValues::GetString(idlName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,10 +181,12 @@ already_AddRefed<Document> DOMParser::ParseFromStream(nsIInputStream* aStream,
|
||||
|
||||
// Create a fake channel
|
||||
nsCOMPtr<nsIChannel> parserChannel;
|
||||
NS_NewInputStreamChannel(getter_AddRefs(parserChannel), mDocumentURI,
|
||||
nullptr, // aStream
|
||||
mPrincipal, nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
|
||||
nsIContentPolicy::TYPE_OTHER, GetEnumString(aType));
|
||||
NS_NewInputStreamChannel(
|
||||
getter_AddRefs(parserChannel), mDocumentURI,
|
||||
nullptr, // aStream
|
||||
mPrincipal, nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nsDependentCSubstring(SupportedTypeValues::GetString(aType)));
|
||||
if (NS_WARN_IF(!parserChannel)) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
|
@ -781,9 +781,12 @@ void Element::ScrollIntoView(const ScrollIntoViewOptions& aOptions) {
|
||||
return WhereToScroll::Center;
|
||||
case ScrollLogicalPosition::End:
|
||||
return WhereToScroll::End;
|
||||
case ScrollLogicalPosition::EndGuard_:
|
||||
MOZ_FALLTHROUGH_ASSERT("Unexpected block direction value");
|
||||
case ScrollLogicalPosition::Nearest:
|
||||
return WhereToScroll::Nearest;
|
||||
break;
|
||||
}
|
||||
return WhereToScroll::Nearest;
|
||||
};
|
||||
|
||||
const auto block = ToWhereToScroll(aOptions.mBlock);
|
||||
|
@ -40,7 +40,7 @@ enum class FlushType : uint8_t {
|
||||
|
||||
// Flush type strings that will be displayed in the profiler
|
||||
// clang-format off
|
||||
const EnumeratedArray<FlushType, const char*, size_t(FlushType::Count)>
|
||||
const EnumeratedArray<FlushType, FlushType::Count, const char*>
|
||||
kFlushTypeNames = {
|
||||
"",
|
||||
"Event",
|
||||
|
@ -131,6 +131,11 @@ template <class T>
|
||||
constexpr bool is_dom_union_with_typedarray_members =
|
||||
std::is_base_of_v<UnionWithTypedArraysBase, T>;
|
||||
|
||||
struct EnumEntry {
|
||||
const char* value;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
enum class CallerType : uint32_t;
|
||||
|
||||
class MOZ_STACK_CLASS GlobalObject {
|
||||
@ -557,13 +562,6 @@ JS::Handle<JSObject*> GetPerInterfaceObjectHandle(
|
||||
JSContext* aCx, size_t aSlotId, CreateInterfaceObjectsMethod aCreator,
|
||||
bool aDefineOnGlobal);
|
||||
|
||||
namespace binding_detail {
|
||||
|
||||
template <typename Enum>
|
||||
struct EnumStrings;
|
||||
|
||||
} // namespace binding_detail
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -6,18 +6,9 @@
|
||||
#ifndef _mozilla_dom_BindingIPCUtils_h
|
||||
#define _mozilla_dom_BindingIPCUtils_h
|
||||
|
||||
#include "mozilla/EnumTypeTraits.h"
|
||||
#include "mozilla/dom/BindingDeclarations.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 {
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::CallerType>
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include "mozilla/Array.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/DeferredFinalize.h"
|
||||
#include "mozilla/EnumTypeTraits.h"
|
||||
#include "mozilla/EnumeratedRange.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/dom/BindingCallContext.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
@ -1345,27 +1343,26 @@ inline bool EnumValueNotFound<true>(BindingCallContext& cx,
|
||||
deflated.get(), type);
|
||||
}
|
||||
|
||||
namespace binding_detail {
|
||||
|
||||
template <typename CharT>
|
||||
inline int FindEnumStringIndexImpl(const CharT* chars, size_t length,
|
||||
const Span<const nsLiteralCString>& values) {
|
||||
for (size_t i = 0; i < values.Length(); ++i) {
|
||||
const nsLiteralCString& value = values[i];
|
||||
if (length != value.Length()) {
|
||||
const EnumEntry* values) {
|
||||
int i = 0;
|
||||
for (const EnumEntry* value = values; value->value; ++value, ++i) {
|
||||
if (length != value->length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool equal = true;
|
||||
const char* val = value->value;
|
||||
for (size_t j = 0; j != length; ++j) {
|
||||
if (unsigned(value.CharAt(j)) != unsigned(chars[j])) {
|
||||
if (unsigned(val[j]) != unsigned(chars[j])) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (equal) {
|
||||
return (int)i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1374,9 +1371,8 @@ inline int FindEnumStringIndexImpl(const CharT* chars, size_t length,
|
||||
|
||||
template <bool InvalidValueFatal>
|
||||
inline bool FindEnumStringIndex(BindingCallContext& cx, JS::Handle<JS::Value> v,
|
||||
const Span<const nsLiteralCString>& values,
|
||||
const char* type, const char* sourceDescription,
|
||||
int* index) {
|
||||
const EnumEntry* values, const char* type,
|
||||
const char* sourceDescription, int* index) {
|
||||
// JS_StringEqualsAscii is slow as molasses, so don't use it here.
|
||||
JS::Rooted<JSString*> str(cx, JS::ToString(cx, v));
|
||||
if (!str) {
|
||||
@ -1409,31 +1405,6 @@ inline bool FindEnumStringIndex(BindingCallContext& cx, JS::Handle<JS::Value> v,
|
||||
return EnumValueNotFound<InvalidValueFatal>(cx, str, type, sourceDescription);
|
||||
}
|
||||
|
||||
} // namespace binding_detail
|
||||
|
||||
template <typename Enum, class StringT>
|
||||
inline Maybe<Enum> StringToEnum(const StringT& aString) {
|
||||
int index = binding_detail::FindEnumStringIndexImpl(
|
||||
aString.BeginReading(), aString.Length(),
|
||||
binding_detail::EnumStrings<Enum>::Values);
|
||||
return index >= 0 ? Some(static_cast<Enum>(index)) : Nothing();
|
||||
}
|
||||
|
||||
template <typename Enum>
|
||||
inline const nsCString& GetEnumString(Enum stringId) {
|
||||
MOZ_RELEASE_ASSERT(
|
||||
static_cast<size_t>(stringId) <
|
||||
mozilla::ArrayLength(binding_detail::EnumStrings<Enum>::Values));
|
||||
return binding_detail::EnumStrings<Enum>::Values[static_cast<size_t>(
|
||||
stringId)];
|
||||
}
|
||||
|
||||
template <typename Enum>
|
||||
constexpr mozilla::detail::EnumeratedRange<Enum> MakeWebIDLEnumeratedRange() {
|
||||
return MakeInclusiveEnumeratedRange(ContiguousEnumValues<Enum>::min,
|
||||
ContiguousEnumValues<Enum>::max);
|
||||
}
|
||||
|
||||
inline nsWrapperCache* GetWrapperCache(const ParentObject& aParentObject) {
|
||||
return aParentObject.mWrapperCache;
|
||||
}
|
||||
@ -3284,7 +3255,6 @@ already_AddRefed<Promise> CreateRejectedPromiseFromThrownException(
|
||||
} // namespace binding_detail
|
||||
|
||||
} // namespace dom
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_BindingUtils_h__ */
|
||||
|
@ -51,6 +51,7 @@ LEGACYCALLER_HOOK_NAME = "_legacycaller"
|
||||
RESOLVE_HOOK_NAME = "_resolve"
|
||||
MAY_RESOLVE_HOOK_NAME = "_mayResolve"
|
||||
NEW_ENUMERATE_HOOK_NAME = "_newEnumerate"
|
||||
ENUM_ENTRY_VARIABLE_NAME = "strings"
|
||||
INSTANCE_RESERVED_SLOTS = 1
|
||||
|
||||
# This size is arbitrary. It is a power of 2 to make using it as a modulo
|
||||
@ -7045,10 +7046,7 @@ def getJSToNativeConversionInfo(
|
||||
"""
|
||||
{
|
||||
int index;
|
||||
if (!binding_detail::FindEnumStringIndex<${invalidEnumValueFatal}>(cx, $${val},
|
||||
binding_detail::EnumStrings<${enumtype}>::Values,
|
||||
"${enumtype}", "${sourceDescription}",
|
||||
&index)) {
|
||||
if (!FindEnumStringIndex<${invalidEnumValueFatal}>(cx, $${val}, ${values}, "${enumtype}", "${sourceDescription}", &index)) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
$*{handleInvalidEnumValueCode}
|
||||
@ -7056,6 +7054,7 @@ def getJSToNativeConversionInfo(
|
||||
}
|
||||
""",
|
||||
enumtype=enumName,
|
||||
values=enumName + "Values::" + ENUM_ENTRY_VARIABLE_NAME,
|
||||
invalidEnumValueFatal=toStringBool(invalidEnumValueFatal),
|
||||
handleInvalidEnumValueCode=handleInvalidEnumValueCode,
|
||||
exceptionCode=exceptionCode,
|
||||
@ -12331,13 +12330,20 @@ def getEnumValueName(value):
|
||||
raise SyntaxError('"_empty" is not an IDL enum value we support yet')
|
||||
if value == "":
|
||||
return "_empty"
|
||||
return MakeNativeName(value)
|
||||
nativeName = MakeNativeName(value)
|
||||
if nativeName == "EndGuard_":
|
||||
raise SyntaxError(
|
||||
'Enum value "' + value + '" cannot be used because it'
|
||||
" collides with our internal EndGuard_ value. Please"
|
||||
" rename our internal EndGuard_ to something else"
|
||||
)
|
||||
return nativeName
|
||||
|
||||
|
||||
class CGEnumToJSValue(CGAbstractMethod):
|
||||
def __init__(self, enum):
|
||||
enumType = enum.identifier.name
|
||||
self.stringsArray = "binding_detail::EnumStrings<" + enumType + ">::Values"
|
||||
self.stringsArray = enumType + "Values::" + ENUM_ENTRY_VARIABLE_NAME
|
||||
CGAbstractMethod.__init__(
|
||||
self,
|
||||
None,
|
||||
@ -12355,8 +12361,8 @@ class CGEnumToJSValue(CGAbstractMethod):
|
||||
"""
|
||||
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(${strings}));
|
||||
JSString* resultStr =
|
||||
JS_NewStringCopyN(aCx, ${strings}[uint32_t(aArgument)].BeginReading(),
|
||||
${strings}[uint32_t(aArgument)].Length());
|
||||
JS_NewStringCopyN(aCx, ${strings}[uint32_t(aArgument)].value,
|
||||
${strings}[uint32_t(aArgument)].length);
|
||||
if (!resultStr) {
|
||||
return false;
|
||||
}
|
||||
@ -12371,54 +12377,80 @@ class CGEnum(CGThing):
|
||||
def __init__(self, enum):
|
||||
CGThing.__init__(self)
|
||||
self.enum = enum
|
||||
entryDecl = fill(
|
||||
"""
|
||||
extern const EnumEntry ${entry_array}[${entry_count}];
|
||||
|
||||
static constexpr size_t Count = ${real_entry_count};
|
||||
|
||||
// Our "${entry_array}" contains an extra entry with a null string.
|
||||
static_assert(mozilla::ArrayLength(${entry_array}) - 1 == Count,
|
||||
"Mismatch between enum strings and enum count");
|
||||
|
||||
static_assert(static_cast<size_t>(${name}::EndGuard_) == Count,
|
||||
"Mismatch between enum value and enum count");
|
||||
|
||||
inline auto GetString(${name} stringId) {
|
||||
MOZ_ASSERT(static_cast<${type}>(stringId) < Count);
|
||||
const EnumEntry& entry = ${entry_array}[static_cast<${type}>(stringId)];
|
||||
return Span<const char>{entry.value, entry.length};
|
||||
}
|
||||
""",
|
||||
entry_array=ENUM_ENTRY_VARIABLE_NAME,
|
||||
entry_count=self.nEnumStrings(),
|
||||
# -1 because nEnumStrings() includes a string for EndGuard_
|
||||
real_entry_count=self.nEnumStrings() - 1,
|
||||
name=self.enum.identifier.name,
|
||||
type=self.underlyingType(),
|
||||
)
|
||||
strings = CGNamespace(
|
||||
"binding_detail",
|
||||
self.stringsNamespace(),
|
||||
CGGeneric(
|
||||
declare=fill(
|
||||
"""
|
||||
template <> struct EnumStrings<${name}> {
|
||||
static const nsLiteralCString Values[${count}];
|
||||
};
|
||||
""",
|
||||
name=self.enum.identifier.name,
|
||||
count=self.nEnumStrings(),
|
||||
),
|
||||
declare=entryDecl,
|
||||
define=fill(
|
||||
"""
|
||||
const nsLiteralCString EnumStrings<${name}>::Values[${count}] = {
|
||||
$*{entries}
|
||||
};
|
||||
""",
|
||||
name=self.enum.identifier.name,
|
||||
extern const EnumEntry ${name}[${count}] = {
|
||||
$*{entries}
|
||||
{ nullptr, 0 }
|
||||
};
|
||||
""",
|
||||
name=ENUM_ENTRY_VARIABLE_NAME,
|
||||
count=self.nEnumStrings(),
|
||||
entries="".join('"%s"_ns,\n' % val for val in self.enum.values()),
|
||||
entries="".join(
|
||||
'{"%s", %d},\n' % (val, len(val)) for val in self.enum.values()
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
toJSValue = CGEnumToJSValue(enum)
|
||||
self.cgThings = CGList([strings, toJSValue], "\n")
|
||||
|
||||
def nEnumStrings(self):
|
||||
return len(self.enum.values())
|
||||
def stringsNamespace(self):
|
||||
return self.enum.identifier.name + "Values"
|
||||
|
||||
@staticmethod
|
||||
def underlyingType(enum):
|
||||
count = len(enum.values())
|
||||
def nEnumStrings(self):
|
||||
return len(self.enum.values()) + 1
|
||||
|
||||
def underlyingType(self):
|
||||
count = self.nEnumStrings()
|
||||
if count <= 256:
|
||||
return "uint8_t"
|
||||
if count <= 65536:
|
||||
return "uint16_t"
|
||||
raise ValueError("Enum " + enum.identifier.name + " has more than 65536 values")
|
||||
raise ValueError(
|
||||
"Enum " + self.enum.identifier.name + " has more than 65536 values"
|
||||
)
|
||||
|
||||
def declare(self):
|
||||
decl = fill(
|
||||
"""
|
||||
enum class ${name} : ${ty} {
|
||||
$*{enums}
|
||||
EndGuard_
|
||||
};
|
||||
""",
|
||||
name=self.enum.identifier.name,
|
||||
ty=CGEnum.underlyingType(self.enum),
|
||||
ty=self.underlyingType(),
|
||||
enums=",\n".join(map(getEnumValueName, self.enum.values())) + ",\n",
|
||||
)
|
||||
|
||||
@ -12431,39 +12463,6 @@ class CGEnum(CGThing):
|
||||
return self.enum.getDeps()
|
||||
|
||||
|
||||
class CGMaxContiguousEnumValue(CGThing):
|
||||
def __init__(self, enum):
|
||||
CGThing.__init__(self)
|
||||
self.enum = enum
|
||||
|
||||
def declare(self):
|
||||
enumValues = self.enum.values()
|
||||
return fill(
|
||||
"""
|
||||
template <>
|
||||
struct MaxContiguousEnumValue<dom::${name}>
|
||||
{
|
||||
static constexpr dom::${name} value = dom::${name}::${maxValue};
|
||||
|
||||
static_assert(static_cast<${ty}>(dom::${name}::${minValue}) == 0,
|
||||
"We rely on this in ContiguousEnumValues");
|
||||
static_assert(mozilla::ArrayLength(dom::binding_detail::EnumStrings<dom::${name}>::Values) - 1 == UnderlyingValue(value),
|
||||
"Mismatch between enum strings and enum count");
|
||||
};
|
||||
""",
|
||||
name=self.enum.identifier.name,
|
||||
ty=CGEnum.underlyingType(self.enum),
|
||||
maxValue=getEnumValueName(enumValues[-1]),
|
||||
minValue=getEnumValueName(enumValues[0]),
|
||||
)
|
||||
|
||||
def define(self):
|
||||
return ""
|
||||
|
||||
def deps(self):
|
||||
return self.enum.getDeps()
|
||||
|
||||
|
||||
def getUnionAccessorSignatureType(type, descriptorProvider):
|
||||
"""
|
||||
Returns the types that are used in the getter and setter signatures for
|
||||
@ -19074,11 +19073,9 @@ class CGBindingRoot(CGThing):
|
||||
# Do codegen for all the enums
|
||||
enums = config.getEnums(webIDLFile)
|
||||
cgthings.extend(CGEnum(e) for e in enums)
|
||||
maxEnumValues = CGList([CGMaxContiguousEnumValue(e) for e in enums], "\n")
|
||||
|
||||
bindingDeclareHeaders["mozilla/Span.h"] = enums
|
||||
bindingDeclareHeaders["mozilla/ArrayUtils.h"] = enums
|
||||
bindingDeclareHeaders["mozilla/EnumTypeTraits.h"] = enums
|
||||
|
||||
hasCode = descriptors or callbackDescriptors or dictionaries or callbacks
|
||||
bindingHeaders["mozilla/dom/BindingUtils.h"] = hasCode
|
||||
@ -19178,13 +19175,7 @@ class CGBindingRoot(CGThing):
|
||||
curr = CGWrapper(CGList(cgthings, "\n\n"), post="\n\n")
|
||||
|
||||
# Wrap all of that in our namespaces.
|
||||
|
||||
if len(maxEnumValues) > 0:
|
||||
curr = CGNamespace("dom", CGWrapper(curr, pre="\n"))
|
||||
curr = CGWrapper(CGList([curr, maxEnumValues], "\n\n"), post="\n\n")
|
||||
curr = CGNamespace("mozilla", CGWrapper(curr, pre="\n"))
|
||||
else:
|
||||
curr = CGNamespace.build(["mozilla", "dom"], CGWrapper(curr, pre="\n"))
|
||||
curr = CGNamespace.build(["mozilla", "dom"], CGWrapper(curr, pre="\n"))
|
||||
|
||||
curr = CGList(
|
||||
[
|
||||
|
5
dom/cache/Cache.cpp
vendored
5
dom/cache/Cache.cpp
vendored
@ -81,12 +81,13 @@ static bool IsValidPutResponseStatus(Response& aResponse,
|
||||
ErrorResult& aRv) {
|
||||
if ((aPolicy == PutStatusPolicy::RequireOK && !aResponse.Ok()) ||
|
||||
aResponse.Status() == 206) {
|
||||
nsCString type(ResponseTypeValues::GetString(aResponse.Type()));
|
||||
|
||||
nsAutoString url;
|
||||
aResponse.GetUrl(url);
|
||||
|
||||
aRv.ThrowTypeError<MSG_CACHE_ADD_FAILED_RESPONSE>(
|
||||
GetEnumString(aResponse.Type()), IntToCString(aResponse.Status()),
|
||||
NS_ConvertUTF16toUTF8(url));
|
||||
type, IntToCString(aResponse.Status()), NS_ConvertUTF16toUTF8(url));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
5
dom/cache/CacheStorage.cpp
vendored
5
dom/cache/CacheStorage.cpp
vendored
@ -467,9 +467,8 @@ already_AddRefed<CacheStorage> CacheStorage::Constructor(
|
||||
static_assert(
|
||||
CHROME_ONLY_NAMESPACE == (uint32_t)CacheStorageNamespace::Chrome,
|
||||
"Chrome namespace should match webidl Chrome enum");
|
||||
static_assert(
|
||||
NUMBER_OF_NAMESPACES == ContiguousEnumSize<CacheStorageNamespace>::value,
|
||||
"Number of namespace should match webidl count");
|
||||
static_assert(NUMBER_OF_NAMESPACES == CacheStorageNamespaceValues::Count,
|
||||
"Number of namespace should match webidl count");
|
||||
|
||||
Namespace ns = static_cast<Namespace>(aNamespace);
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
14
dom/cache/DBSchema.cpp
vendored
14
dom/cache/DBSchema.cpp
vendored
@ -278,7 +278,7 @@ static_assert(int(HeadersGuardEnum::None) == 0 &&
|
||||
int(HeadersGuardEnum::Request_no_cors) == 2 &&
|
||||
int(HeadersGuardEnum::Response) == 3 &&
|
||||
int(HeadersGuardEnum::Immutable) == 4 &&
|
||||
ContiguousEnumSize<HeadersGuardEnum>::value == 5,
|
||||
HeadersGuardEnumValues::Count == 5,
|
||||
"HeadersGuardEnum values are as expected");
|
||||
static_assert(int(ReferrerPolicy::_empty) == 0 &&
|
||||
int(ReferrerPolicy::No_referrer) == 1 &&
|
||||
@ -289,18 +289,18 @@ static_assert(int(ReferrerPolicy::_empty) == 0 &&
|
||||
int(ReferrerPolicy::Same_origin) == 6 &&
|
||||
int(ReferrerPolicy::Strict_origin) == 7 &&
|
||||
int(ReferrerPolicy::Strict_origin_when_cross_origin) == 8 &&
|
||||
ContiguousEnumSize<ReferrerPolicy>::value == 9,
|
||||
ReferrerPolicyValues::Count == 9,
|
||||
"ReferrerPolicy values are as expected");
|
||||
static_assert(int(RequestMode::Same_origin) == 0 &&
|
||||
int(RequestMode::No_cors) == 1 &&
|
||||
int(RequestMode::Cors) == 2 &&
|
||||
int(RequestMode::Navigate) == 3 &&
|
||||
ContiguousEnumSize<RequestMode>::value == 4,
|
||||
RequestModeValues::Count == 4,
|
||||
"RequestMode values are as expected");
|
||||
static_assert(int(RequestCredentials::Omit) == 0 &&
|
||||
int(RequestCredentials::Same_origin) == 1 &&
|
||||
int(RequestCredentials::Include) == 2 &&
|
||||
ContiguousEnumSize<RequestCredentials>::value == 3,
|
||||
RequestCredentialsValues::Count == 3,
|
||||
"RequestCredentials values are as expected");
|
||||
static_assert(int(RequestCache::Default) == 0 &&
|
||||
int(RequestCache::No_store) == 1 &&
|
||||
@ -308,19 +308,19 @@ static_assert(int(RequestCache::Default) == 0 &&
|
||||
int(RequestCache::No_cache) == 3 &&
|
||||
int(RequestCache::Force_cache) == 4 &&
|
||||
int(RequestCache::Only_if_cached) == 5 &&
|
||||
ContiguousEnumSize<RequestCache>::value == 6,
|
||||
RequestCacheValues::Count == 6,
|
||||
"RequestCache values are as expected");
|
||||
static_assert(int(RequestRedirect::Follow) == 0 &&
|
||||
int(RequestRedirect::Error) == 1 &&
|
||||
int(RequestRedirect::Manual) == 2 &&
|
||||
ContiguousEnumSize<RequestRedirect>::value == 3,
|
||||
RequestRedirectValues::Count == 3,
|
||||
"RequestRedirect values are as expected");
|
||||
static_assert(int(ResponseType::Basic) == 0 && int(ResponseType::Cors) == 1 &&
|
||||
int(ResponseType::Default) == 2 &&
|
||||
int(ResponseType::Error) == 3 &&
|
||||
int(ResponseType::Opaque) == 4 &&
|
||||
int(ResponseType::Opaqueredirect) == 5 &&
|
||||
ContiguousEnumSize<ResponseType>::value == 6,
|
||||
ResponseTypeValues::Count == 6,
|
||||
"ResponseType values are as expected");
|
||||
|
||||
// If the static_asserts below fails, it means that you have changed the
|
||||
|
@ -1008,11 +1008,9 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
|
||||
RefPtr<nsAtom> fontLanguage;
|
||||
nsFont fontFont;
|
||||
|
||||
EnumeratedArray<Style, RefPtr<CanvasGradient>, size_t(Style::MAX)>
|
||||
gradientStyles;
|
||||
EnumeratedArray<Style, RefPtr<CanvasPattern>, size_t(Style::MAX)>
|
||||
patternStyles;
|
||||
EnumeratedArray<Style, nscolor, size_t(Style::MAX)> colorStyles;
|
||||
EnumeratedArray<Style, Style::MAX, RefPtr<CanvasGradient>> gradientStyles;
|
||||
EnumeratedArray<Style, Style::MAX, RefPtr<CanvasPattern>> patternStyles;
|
||||
EnumeratedArray<Style, Style::MAX, nscolor> colorStyles;
|
||||
|
||||
nsCString font;
|
||||
CanvasTextAlign textAlign = CanvasTextAlign::Start;
|
||||
|
@ -15,27 +15,27 @@ using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
static Maybe<ImageBitmapFormat> GetImageBitmapFormatFromSurfaceFromat(
|
||||
static ImageBitmapFormat GetImageBitmapFormatFromSurfaceFromat(
|
||||
SurfaceFormat aSurfaceFormat) {
|
||||
switch (aSurfaceFormat) {
|
||||
case SurfaceFormat::B8G8R8A8:
|
||||
case SurfaceFormat::B8G8R8X8:
|
||||
return Some(ImageBitmapFormat::BGRA32);
|
||||
return ImageBitmapFormat::BGRA32;
|
||||
case SurfaceFormat::R8G8B8A8:
|
||||
case SurfaceFormat::R8G8B8X8:
|
||||
return Some(ImageBitmapFormat::RGBA32);
|
||||
return ImageBitmapFormat::RGBA32;
|
||||
case SurfaceFormat::R8G8B8:
|
||||
return Some(ImageBitmapFormat::RGB24);
|
||||
return ImageBitmapFormat::RGB24;
|
||||
case SurfaceFormat::B8G8R8:
|
||||
return Some(ImageBitmapFormat::BGR24);
|
||||
return ImageBitmapFormat::BGR24;
|
||||
case SurfaceFormat::HSV:
|
||||
return Some(ImageBitmapFormat::HSV);
|
||||
return ImageBitmapFormat::HSV;
|
||||
case SurfaceFormat::Lab:
|
||||
return Some(ImageBitmapFormat::Lab);
|
||||
return ImageBitmapFormat::Lab;
|
||||
case SurfaceFormat::Depth:
|
||||
return Some(ImageBitmapFormat::DEPTH);
|
||||
return ImageBitmapFormat::DEPTH;
|
||||
case SurfaceFormat::A8:
|
||||
return Some(ImageBitmapFormat::GRAY8);
|
||||
return ImageBitmapFormat::GRAY8;
|
||||
case SurfaceFormat::R5G6B5_UINT16:
|
||||
case SurfaceFormat::YUV:
|
||||
case SurfaceFormat::NV12:
|
||||
@ -43,11 +43,11 @@ static Maybe<ImageBitmapFormat> GetImageBitmapFormatFromSurfaceFromat(
|
||||
case SurfaceFormat::P016:
|
||||
case SurfaceFormat::UNKNOWN:
|
||||
default:
|
||||
return Nothing();
|
||||
return ImageBitmapFormat::EndGuard_;
|
||||
}
|
||||
}
|
||||
|
||||
static Maybe<ImageBitmapFormat> GetImageBitmapFormatFromPlanarYCbCrData(
|
||||
static ImageBitmapFormat GetImageBitmapFormatFromPlanarYCbCrData(
|
||||
layers::PlanarYCbCrData const* aData) {
|
||||
MOZ_ASSERT(aData);
|
||||
|
||||
@ -68,11 +68,11 @@ static Maybe<ImageBitmapFormat> GetImageBitmapFormatFromPlanarYCbCrData(
|
||||
!CbInterval.Intersects(CrInterval)) { // Three planes.
|
||||
switch (aData->mChromaSubsampling) {
|
||||
case ChromaSubsampling::FULL:
|
||||
return Some(ImageBitmapFormat::YUV444P);
|
||||
return ImageBitmapFormat::YUV444P;
|
||||
case ChromaSubsampling::HALF_WIDTH:
|
||||
return Some(ImageBitmapFormat::YUV422P);
|
||||
return ImageBitmapFormat::YUV422P;
|
||||
case ChromaSubsampling::HALF_WIDTH_AND_HEIGHT:
|
||||
return Some(ImageBitmapFormat::YUV420P);
|
||||
return ImageBitmapFormat::YUV420P;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -83,14 +83,14 @@ static Maybe<ImageBitmapFormat> GetImageBitmapFormatFromPlanarYCbCrData(
|
||||
// planes.
|
||||
if (!YInterval.Intersects(CbInterval) &&
|
||||
aData->mCbChannel == aData->mCrChannel - 1) { // Two planes.
|
||||
return Some(ImageBitmapFormat::YUV420SP_NV12); // Y-Cb-Cr
|
||||
return ImageBitmapFormat::YUV420SP_NV12; // Y-Cb-Cr
|
||||
} else if (!YInterval.Intersects(CrInterval) &&
|
||||
aData->mCrChannel == aData->mCbChannel - 1) { // Two planes.
|
||||
return Some(ImageBitmapFormat::YUV420SP_NV21); // Y-Cr-Cb
|
||||
return ImageBitmapFormat::YUV420SP_NV21; // Y-Cr-Cb
|
||||
}
|
||||
}
|
||||
|
||||
return Nothing();
|
||||
return ImageBitmapFormat::EndGuard_;
|
||||
}
|
||||
|
||||
// ImageUtils::Impl implements the _generic_ algorithm which always readback
|
||||
@ -104,7 +104,7 @@ class ImageUtils::Impl {
|
||||
|
||||
virtual ~Impl() = default;
|
||||
|
||||
virtual Maybe<ImageBitmapFormat> GetFormat() const {
|
||||
virtual ImageBitmapFormat GetFormat() const {
|
||||
return GetImageBitmapFormatFromSurfaceFromat(Surface()->GetFormat());
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ class YUVImpl final : public ImageUtils::Impl {
|
||||
aImage->GetFormat() == ImageFormat::NV_IMAGE);
|
||||
}
|
||||
|
||||
Maybe<ImageBitmapFormat> GetFormat() const override {
|
||||
ImageBitmapFormat GetFormat() const override {
|
||||
return GetImageBitmapFormatFromPlanarYCbCrData(GetPlanarYCbCrData());
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ ImageUtils::~ImageUtils() {
|
||||
}
|
||||
}
|
||||
|
||||
Maybe<ImageBitmapFormat> ImageUtils::GetFormat() const {
|
||||
ImageBitmapFormat ImageUtils::GetFormat() const {
|
||||
MOZ_ASSERT(mImpl);
|
||||
return mImpl->GetFormat();
|
||||
}
|
||||
|
@ -13,9 +13,6 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
template <typename T>
|
||||
class Maybe;
|
||||
|
||||
namespace layers {
|
||||
class Image;
|
||||
}
|
||||
@ -54,7 +51,7 @@ class ImageUtils {
|
||||
explicit ImageUtils(layers::Image* aImage);
|
||||
~ImageUtils();
|
||||
|
||||
Maybe<ImageBitmapFormat> GetFormat() const;
|
||||
ImageBitmapFormat GetFormat() const;
|
||||
|
||||
uint32_t GetBufferLength() const;
|
||||
|
||||
|
@ -968,8 +968,8 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
|
||||
// -------------------------------------------------------------------------
|
||||
// WebGL extensions (implemented in WebGLContextExtensions.cpp)
|
||||
|
||||
EnumeratedArray<WebGLExtensionID, std::unique_ptr<WebGLExtensionBase>,
|
||||
size_t(WebGLExtensionID::Max)>
|
||||
EnumeratedArray<WebGLExtensionID, WebGLExtensionID::Max,
|
||||
std::unique_ptr<WebGLExtensionBase>>
|
||||
mExtensions;
|
||||
|
||||
public:
|
||||
|
@ -323,9 +323,7 @@ struct ParamTraits<mozilla::dom::PredefinedColorSpace> final
|
||||
mozilla::dom::PredefinedColorSpace> {
|
||||
using T = mozilla::dom::PredefinedColorSpace;
|
||||
|
||||
static bool Validate(const T& val) {
|
||||
return val <= mozilla::ContiguousEnumValues<T>::max;
|
||||
}
|
||||
static bool Validate(const T& val) { return val < T::EndGuard_; }
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -67,6 +67,8 @@ inline constexpr bool IsEnumCase(const dom::WebGLPowerPreference raw) {
|
||||
case dom::WebGLPowerPreference::Low_power:
|
||||
case dom::WebGLPowerPreference::High_performance:
|
||||
return true;
|
||||
case dom::WebGLPowerPreference::EndGuard_:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -76,6 +78,8 @@ inline constexpr bool IsEnumCase(const dom::PredefinedColorSpace raw) {
|
||||
case dom::PredefinedColorSpace::Srgb:
|
||||
case dom::PredefinedColorSpace::Display_p3:
|
||||
return true;
|
||||
case dom::PredefinedColorSpace::EndGuard_:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -408,6 +408,8 @@ inline ColorSpace2 ToColorSpace2(const dom::PredefinedColorSpace cs) {
|
||||
return ColorSpace2::SRGB;
|
||||
case dom::PredefinedColorSpace::Display_p3:
|
||||
return ColorSpace2::DISPLAY_P3;
|
||||
case dom::PredefinedColorSpace::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_CRASH("Exhaustive switch");
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "ipc/EnumSerializer.h"
|
||||
|
||||
#include "X11UndefineNone.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/ClientBinding.h"
|
||||
#include "mozilla/dom/ClientsBinding.h"
|
||||
#include "mozilla/dom/DocumentBinding.h"
|
||||
@ -18,16 +17,21 @@
|
||||
namespace IPC {
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ClientType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::ClientType> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::ClientType,
|
||||
mozilla::dom::ClientType::Window,
|
||||
mozilla::dom::ClientType::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::FrameType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::FrameType> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::FrameType,
|
||||
mozilla::dom::FrameType::Auxiliary,
|
||||
mozilla::dom::FrameType::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::VisibilityState>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::VisibilityState> {
|
||||
};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::VisibilityState, mozilla::dom::VisibilityState::Hidden,
|
||||
mozilla::dom::VisibilityState::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::StorageAccess>
|
||||
|
@ -106,8 +106,9 @@ ConsoleLogLevel PrefToValue(const nsACString& aPref,
|
||||
return aLevel;
|
||||
}
|
||||
|
||||
Maybe<ConsoleLogLevel> level = StringToEnum<ConsoleLogLevel>(value);
|
||||
if (NS_WARN_IF(level.isNothing())) {
|
||||
int index = FindEnumStringIndexImpl(value.get(), value.Length(),
|
||||
ConsoleLogLevelValues::strings);
|
||||
if (NS_WARN_IF(index < 0)) {
|
||||
nsString message;
|
||||
message.AssignLiteral("Invalid Console.maxLogLevelPref value: ");
|
||||
message.Append(NS_ConvertUTF8toUTF16(value));
|
||||
@ -117,7 +118,8 @@ ConsoleLogLevel PrefToValue(const nsACString& aPref,
|
||||
return aLevel;
|
||||
}
|
||||
|
||||
return level.value();
|
||||
MOZ_ASSERT(index < (int)ConsoleLogLevelValues::Count);
|
||||
return static_cast<ConsoleLogLevel>(index);
|
||||
}
|
||||
|
||||
void ConsoleInstance::SetLogLevel() {
|
||||
|
@ -894,7 +894,10 @@ which becomes the value `_empty`.
|
||||
|
||||
For a Web IDL enum named `MyEnum`, the C++ enum is named `MyEnum` and
|
||||
placed in the `mozilla::dom` namespace, while the values are placed in
|
||||
the `mozilla::dom::MyEnum` namespace.
|
||||
the `mozilla::dom::MyEnum` namespace. There is also a
|
||||
`mozilla::dom::MyEnumValues::strings` which is an array of
|
||||
`mozilla::dom::EnumEntry` structs that gives access to the string
|
||||
representations of the values.
|
||||
|
||||
The type of the enum class is automatically selected to be the smallest
|
||||
unsigned integer type that can hold all the values. In practice, this
|
||||
@ -921,35 +924,12 @@ enum class MyEnum : uint8_t {
|
||||
_empty,
|
||||
Another
|
||||
};
|
||||
|
||||
namespace MyEnumValues {
|
||||
extern const EnumEntry strings[10];
|
||||
} // namespace MyEnumValues
|
||||
```
|
||||
|
||||
`mozilla::dom::GetEnumString` is a templated helper function declared in
|
||||
[`BindingUtils.h`](https://searchfox.org/mozilla-central/source/dom/bindings/BindingUtils.h)
|
||||
and exported to `mozilla/dom/BindingUtils.h` that can be used to convert an enum
|
||||
value to its corresponding string value. It returns a `const nsCString&`
|
||||
containing the string value.
|
||||
|
||||
`mozilla::dom::StringToEnum` is a templated helper function in
|
||||
[`BindingUtils.h`](https://searchfox.org/mozilla-central/source/dom/bindings/BindingUtils.h)
|
||||
and exported to `mozilla/dom/BindingUtils.h` that can be used to convert a
|
||||
string to the corresponding enum value. It needs to be supplied with the enum
|
||||
class as a template argument, and returns a `mozilla::Maybe<Enum>`. If the string
|
||||
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
|
||||
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.
|
||||
|
||||
`mozilla::dom::MakeWebIDLEnumeratedRange` is a templated helper function in
|
||||
[`BindingUtils.h`](https://searchfox.org/mozilla-central/source/dom/bindings/BindingUtils.h)
|
||||
and exported to `mozilla/dom/BindingUtils.h` that can be used to create a
|
||||
`mozilla::EnumeratedRange` for a WebIDL enum.
|
||||
|
||||
#### Callback function types
|
||||
|
||||
Callback functions are represented as an object, inheriting from
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "ipc/EnumSerializer.h"
|
||||
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/HeadersBinding.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/ResponseBinding.h"
|
||||
@ -18,30 +17,41 @@
|
||||
namespace IPC {
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::HeadersGuardEnum>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::HeadersGuardEnum> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::HeadersGuardEnum, mozilla::dom::HeadersGuardEnum::None,
|
||||
mozilla::dom::HeadersGuardEnum::EndGuard_> {};
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ReferrerPolicy>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::ReferrerPolicy> {
|
||||
: public ContiguousEnumSerializer<mozilla::dom::ReferrerPolicy,
|
||||
mozilla::dom::ReferrerPolicy::_empty,
|
||||
mozilla::dom::ReferrerPolicy::EndGuard_> {
|
||||
};
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RequestMode>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RequestMode> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::RequestMode,
|
||||
mozilla::dom::RequestMode::Same_origin,
|
||||
mozilla::dom::RequestMode::EndGuard_> {};
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RequestCredentials>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::RequestCredentials> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::RequestCredentials,
|
||||
mozilla::dom::RequestCredentials::Omit,
|
||||
mozilla::dom::RequestCredentials::EndGuard_> {};
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RequestCache>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RequestCache> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::RequestCache,
|
||||
mozilla::dom::RequestCache::Default,
|
||||
mozilla::dom::RequestCache::EndGuard_> {};
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RequestRedirect>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RequestRedirect> {
|
||||
};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::RequestRedirect, mozilla::dom::RequestRedirect::Follow,
|
||||
mozilla::dom::RequestRedirect::EndGuard_> {};
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ResponseType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::ResponseType> {};
|
||||
|
||||
: public ContiguousEnumSerializer<mozilla::dom::ResponseType,
|
||||
mozilla::dom::ResponseType::Basic,
|
||||
mozilla::dom::ResponseType::EndGuard_> {};
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::FetchDriverObserver::EndReason>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
|
@ -329,37 +329,27 @@ SafeRefPtr<Request> Request::Constructor(nsIGlobalObject* aGlobal,
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
Maybe<RequestMode> mode;
|
||||
if (aInit.mMode.WasPassed()) {
|
||||
if (aInit.mMode.Value() == RequestMode::Navigate) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_REQUEST_MODE>("navigate");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mode.emplace(aInit.mMode.Value());
|
||||
}
|
||||
Maybe<RequestCredentials> credentials;
|
||||
if (aInit.mCredentials.WasPassed()) {
|
||||
credentials.emplace(aInit.mCredentials.Value());
|
||||
}
|
||||
Maybe<RequestCache> cache;
|
||||
if (aInit.mCache.WasPassed()) {
|
||||
cache.emplace(aInit.mCache.Value());
|
||||
}
|
||||
RequestMode fallbackMode = RequestMode::EndGuard_;
|
||||
RequestCredentials fallbackCredentials = RequestCredentials::EndGuard_;
|
||||
RequestCache fallbackCache = RequestCache::EndGuard_;
|
||||
if (aInput.IsUSVString()) {
|
||||
if (mode.isNothing()) {
|
||||
mode.emplace(RequestMode::Cors);
|
||||
}
|
||||
if (credentials.isNothing()) {
|
||||
credentials.emplace(RequestCredentials::Same_origin);
|
||||
}
|
||||
if (cache.isNothing()) {
|
||||
cache.emplace(RequestCache::Default);
|
||||
}
|
||||
fallbackMode = RequestMode::Cors;
|
||||
fallbackCredentials = RequestCredentials::Same_origin;
|
||||
fallbackCache = RequestCache::Default;
|
||||
}
|
||||
|
||||
RequestMode mode =
|
||||
aInit.mMode.WasPassed() ? aInit.mMode.Value() : fallbackMode;
|
||||
RequestCredentials credentials = aInit.mCredentials.WasPassed()
|
||||
? aInit.mCredentials.Value()
|
||||
: fallbackCredentials;
|
||||
|
||||
if (mode == RequestMode::Navigate) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_REQUEST_MODE>("navigate");
|
||||
return nullptr;
|
||||
}
|
||||
if (aInit.IsAnyMemberPresent() && request->Mode() == RequestMode::Navigate) {
|
||||
mode = Some(RequestMode::Same_origin);
|
||||
mode = RequestMode::Same_origin;
|
||||
}
|
||||
|
||||
if (aInit.IsAnyMemberPresent()) {
|
||||
@ -490,22 +480,24 @@ SafeRefPtr<Request> Request::Constructor(nsIGlobalObject* aGlobal,
|
||||
request->SetPrincipalInfo(std::move(principalInfo));
|
||||
request->SetEmbedderPolicy(coep);
|
||||
|
||||
if (mode.isSome()) {
|
||||
request->SetMode(mode.value());
|
||||
if (mode != RequestMode::EndGuard_) {
|
||||
request->SetMode(mode);
|
||||
}
|
||||
|
||||
if (credentials.isSome()) {
|
||||
request->SetCredentialsMode(credentials.value());
|
||||
if (credentials != RequestCredentials::EndGuard_) {
|
||||
request->SetCredentialsMode(credentials);
|
||||
}
|
||||
|
||||
if (cache.isSome()) {
|
||||
if (cache.value() == RequestCache::Only_if_cached &&
|
||||
RequestCache cache =
|
||||
aInit.mCache.WasPassed() ? aInit.mCache.Value() : fallbackCache;
|
||||
if (cache != RequestCache::EndGuard_) {
|
||||
if (cache == RequestCache::Only_if_cached &&
|
||||
request->Mode() != RequestMode::Same_origin) {
|
||||
aRv.ThrowTypeError<MSG_ONLY_IF_CACHED_WITHOUT_SAME_ORIGIN>(
|
||||
GetEnumString(request->Mode()));
|
||||
nsCString modeString(RequestModeValues::GetString(request->Mode()));
|
||||
aRv.ThrowTypeError<MSG_ONLY_IF_CACHED_WITHOUT_SAME_ORIGIN>(modeString);
|
||||
return nullptr;
|
||||
}
|
||||
request->SetCacheMode(cache.value());
|
||||
request->SetCacheMode(cache);
|
||||
}
|
||||
|
||||
if (aInit.mRedirect.WasPassed()) {
|
||||
|
@ -6,8 +6,6 @@
|
||||
|
||||
#include "FileSystemDirectoryHandle.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "FileSystemDirectoryIteratorFactory.h"
|
||||
#include "fs/FileSystemRequestHandler.h"
|
||||
#include "js/StructuredClone.h"
|
||||
@ -155,7 +153,7 @@ already_AddRefed<FileSystemDirectoryHandle>
|
||||
FileSystemDirectoryHandle::ReadStructuredClone(
|
||||
JSContext* aCx, nsIGlobalObject* aGlobal,
|
||||
JSStructuredCloneReader* aReader) {
|
||||
uint32_t kind = UINT32_MAX;
|
||||
uint32_t kind = static_cast<uint32_t>(FileSystemHandleKind::EndGuard_);
|
||||
|
||||
if (!JS_ReadBytes(aReader, reinterpret_cast<void*>(&kind),
|
||||
sizeof(uint32_t))) {
|
||||
|
@ -99,7 +99,7 @@ already_AddRefed<FileSystemFileHandle>
|
||||
FileSystemFileHandle::ReadStructuredClone(JSContext* aCx,
|
||||
nsIGlobalObject* aGlobal,
|
||||
JSStructuredCloneReader* aReader) {
|
||||
uint32_t kind = UINT32_MAX;
|
||||
uint32_t kind = static_cast<uint32_t>(FileSystemHandleKind::EndGuard_);
|
||||
|
||||
if (!JS_ReadBytes(aReader, reinterpret_cast<void*>(&kind),
|
||||
sizeof(uint32_t))) {
|
||||
|
@ -210,7 +210,7 @@ already_AddRefed<FileSystemHandle> FileSystemHandle::ReadStructuredClone(
|
||||
JSStructuredCloneReader* aReader) {
|
||||
LOG_VERBOSE(("Reading File/DirectoryHandle"));
|
||||
|
||||
uint32_t kind = UINT32_MAX;
|
||||
uint32_t kind = static_cast<uint32_t>(FileSystemHandleKind::EndGuard_);
|
||||
|
||||
if (!JS_ReadBytes(aReader, reinterpret_cast<void*>(&kind),
|
||||
sizeof(uint32_t))) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define mozilla_dom_gamepad_GamepadMessageUtils_h
|
||||
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/GamepadBinding.h"
|
||||
#include "mozilla/dom/GamepadHandle.h"
|
||||
#include "mozilla/dom/GamepadLightIndicatorBinding.h"
|
||||
@ -19,17 +18,24 @@ namespace IPC {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::GamepadLightIndicatorType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::GamepadLightIndicatorType> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::GamepadLightIndicatorType,
|
||||
mozilla::dom::GamepadLightIndicatorType(0),
|
||||
mozilla::dom::GamepadLightIndicatorType(
|
||||
mozilla::dom::GamepadLightIndicatorType::EndGuard_)> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::GamepadMappingType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::GamepadMappingType> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::GamepadMappingType, mozilla::dom::GamepadMappingType(0),
|
||||
mozilla::dom::GamepadMappingType(
|
||||
mozilla::dom::GamepadMappingType::EndGuard_)> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::GamepadHand>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::GamepadHand> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::GamepadHand, mozilla::dom::GamepadHand(0),
|
||||
mozilla::dom::GamepadHand(mozilla::dom::GamepadHand::EndGuard_)> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::GamepadCapabilityFlags>
|
||||
|
@ -1269,24 +1269,25 @@ bool nsGenericHTMLElement::ParseImageAttribute(nsAtom* aAttribute,
|
||||
bool nsGenericHTMLElement::ParseReferrerAttribute(const nsAString& aString,
|
||||
nsAttrValue& aResult) {
|
||||
using mozilla::dom::ReferrerInfo;
|
||||
// This is a bit sketchy, we assume GetEnumString(…).get() points to a static
|
||||
// buffer, relying on the fact that GetEnumString(…) returns a literal string.
|
||||
static const nsAttrValue::EnumTable kReferrerPolicyTable[] = {
|
||||
{GetEnumString(ReferrerPolicy::No_referrer).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::No_referrer),
|
||||
static_cast<int16_t>(ReferrerPolicy::No_referrer)},
|
||||
{GetEnumString(ReferrerPolicy::Origin).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Origin),
|
||||
static_cast<int16_t>(ReferrerPolicy::Origin)},
|
||||
{GetEnumString(ReferrerPolicy::Origin_when_cross_origin).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(
|
||||
ReferrerPolicy::Origin_when_cross_origin),
|
||||
static_cast<int16_t>(ReferrerPolicy::Origin_when_cross_origin)},
|
||||
{GetEnumString(ReferrerPolicy::No_referrer_when_downgrade).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(
|
||||
ReferrerPolicy::No_referrer_when_downgrade),
|
||||
static_cast<int16_t>(ReferrerPolicy::No_referrer_when_downgrade)},
|
||||
{GetEnumString(ReferrerPolicy::Unsafe_url).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Unsafe_url),
|
||||
static_cast<int16_t>(ReferrerPolicy::Unsafe_url)},
|
||||
{GetEnumString(ReferrerPolicy::Strict_origin).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Strict_origin),
|
||||
static_cast<int16_t>(ReferrerPolicy::Strict_origin)},
|
||||
{GetEnumString(ReferrerPolicy::Same_origin).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Same_origin),
|
||||
static_cast<int16_t>(ReferrerPolicy::Same_origin)},
|
||||
{GetEnumString(ReferrerPolicy::Strict_origin_when_cross_origin).get(),
|
||||
{ReferrerInfo::ReferrerPolicyToString(
|
||||
ReferrerPolicy::Strict_origin_when_cross_origin),
|
||||
static_cast<int16_t>(ReferrerPolicy::Strict_origin_when_cross_origin)},
|
||||
{nullptr, ReferrerPolicy::_empty}};
|
||||
return aResult.ParseEnumValue(aString, kReferrerPolicyTable, false);
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "ipc/IPCMessageUtilsSpecializations.h"
|
||||
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/indexedDB/Key.h"
|
||||
#include "mozilla/dom/indexedDB/KeyPath.h"
|
||||
#include "mozilla/dom/IDBCursor.h"
|
||||
@ -62,8 +61,10 @@ struct ParamTraits<mozilla::dom::indexedDB::KeyPath> {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::IDBCursor::Direction>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::IDBCursor::Direction> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::IDBCursor::Direction,
|
||||
mozilla::dom::IDBCursor::Direction::Next,
|
||||
mozilla::dom::IDBCursor::Direction::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::IDBTransaction::Mode>
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "mozilla/dom/ImageUtils.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
using mozilla::ImageFormat;
|
||||
@ -76,12 +75,7 @@ nsresult ConvertToI420(Image* aImage, uint8_t* aDestY, int aDestStrideY,
|
||||
|
||||
if (const PlanarYCbCrData* data = GetPlanarYCbCrData(aImage)) {
|
||||
const ImageUtils imageUtils(aImage);
|
||||
Maybe<dom::ImageBitmapFormat> format = imageUtils.GetFormat();
|
||||
if (format.isNothing()) {
|
||||
MOZ_ASSERT_UNREACHABLE("YUV format conversion not implemented");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
switch (format.value()) {
|
||||
switch (imageUtils.GetFormat()) {
|
||||
case ImageBitmapFormat::YUV420P:
|
||||
return MapRv(libyuv::I420ToI420(
|
||||
data->mYChannel, data->mYStride, data->mCbChannel,
|
||||
|
@ -315,6 +315,8 @@ RefPtr<MediaDeviceSetRefCnt> MediaDevices::FilterExposedDevices(
|
||||
}
|
||||
haveDefaultOutput = true;
|
||||
break;
|
||||
case MediaDeviceKind::EndGuard_:
|
||||
continue;
|
||||
// Avoid `default:` so that `-Wswitch` catches missing
|
||||
// enumerators at compile time.
|
||||
}
|
||||
@ -332,6 +334,8 @@ bool MediaDevices::CanExposeInfo(MediaDeviceKind aKind) const {
|
||||
case MediaDeviceKind::Audiooutput:
|
||||
// Assumes caller has used FilterExposedDevices()
|
||||
return true;
|
||||
case MediaDeviceKind::EndGuard_:
|
||||
break;
|
||||
// Avoid `default:` so that `-Wswitch` catches missing enumerators at
|
||||
// compile time.
|
||||
}
|
||||
@ -546,7 +550,7 @@ already_AddRefed<Promise> MediaDevices::GetDisplayMedia(
|
||||
// for us.
|
||||
vc.mMediaSource.Reset();
|
||||
vc.mMediaSource.Construct().AssignASCII(
|
||||
dom::GetEnumString(MediaSourceEnum::Screen));
|
||||
dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Screen));
|
||||
|
||||
RefPtr<MediaDevices> self(this);
|
||||
MediaManager::Get()
|
||||
|
@ -872,7 +872,8 @@ MediaDevice::MediaDevice(MediaEngine* aEngine, MediaSourceEnum aMediaSource,
|
||||
mCanRequestOsLevelPrompt(canRequestOsLevelPrompt == OsPromptable::Yes),
|
||||
mIsFake(mEngine->IsFake()),
|
||||
mIsPlaceholder(aIsPlaceholder == IsPlaceholder::Yes),
|
||||
mType(NS_ConvertASCIItoUTF16(dom::GetEnumString(mKind))),
|
||||
mType(
|
||||
NS_ConvertASCIItoUTF16(dom::MediaDeviceKindValues::GetString(mKind))),
|
||||
mRawID(aRawID),
|
||||
mRawGroupID(aRawGroupID),
|
||||
mRawName(aRawName) {
|
||||
@ -894,7 +895,8 @@ MediaDevice::MediaDevice(MediaEngine* aEngine,
|
||||
mCanRequestOsLevelPrompt(false),
|
||||
mIsFake(false),
|
||||
mIsPlaceholder(false),
|
||||
mType(NS_ConvertASCIItoUTF16(dom::GetEnumString(mKind))),
|
||||
mType(
|
||||
NS_ConvertASCIItoUTF16(dom::MediaDeviceKindValues::GetString(mKind))),
|
||||
mRawID(aRawID),
|
||||
mRawGroupID(mAudioDeviceInfo->GroupID()),
|
||||
mRawName(mAudioDeviceInfo->Name()) {}
|
||||
@ -1062,7 +1064,8 @@ LocalMediaDevice::GetMediaSource(nsAString& aMediaSource) {
|
||||
if (Kind() == MediaDeviceKind::Audiooutput) {
|
||||
aMediaSource.Truncate();
|
||||
} else {
|
||||
aMediaSource.AssignASCII(dom::GetEnumString(GetMediaSource()));
|
||||
aMediaSource.AssignASCII(
|
||||
dom::MediaSourceEnumValues::GetString(GetMediaSource()));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2744,10 +2747,10 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
||||
auto& vc = c.mVideo.GetAsMediaTrackConstraints();
|
||||
if (!vc.mMediaSource.WasPassed()) {
|
||||
vc.mMediaSource.Construct().AssignASCII(
|
||||
dom::GetEnumString(MediaSourceEnum::Camera));
|
||||
dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Camera));
|
||||
}
|
||||
videoType = dom::StringToEnum<MediaSourceEnum>(vc.mMediaSource.Value())
|
||||
.valueOr(MediaSourceEnum::Other);
|
||||
videoType = StringToEnum(dom::MediaSourceEnumValues::strings,
|
||||
vc.mMediaSource.Value(), MediaSourceEnum::Other);
|
||||
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
|
||||
(uint32_t)videoType);
|
||||
switch (videoType) {
|
||||
@ -2812,7 +2815,8 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
||||
if (videoType == MediaSourceEnum::Screen ||
|
||||
videoType == MediaSourceEnum::Browser) {
|
||||
videoType = MediaSourceEnum::Window;
|
||||
vc.mMediaSource.Value().AssignASCII(dom::GetEnumString(videoType));
|
||||
vc.mMediaSource.Value().AssignASCII(
|
||||
dom::MediaSourceEnumValues::GetString(videoType));
|
||||
}
|
||||
// only allow privileged content to set the window id
|
||||
if (vc.mBrowserWindow.WasPassed()) {
|
||||
@ -2836,10 +2840,10 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
||||
auto& ac = c.mAudio.GetAsMediaTrackConstraints();
|
||||
if (!ac.mMediaSource.WasPassed()) {
|
||||
ac.mMediaSource.Construct(NS_ConvertASCIItoUTF16(
|
||||
dom::GetEnumString(MediaSourceEnum::Microphone)));
|
||||
dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Microphone)));
|
||||
}
|
||||
audioType = dom::StringToEnum<MediaSourceEnum>(ac.mMediaSource.Value())
|
||||
.valueOr(MediaSourceEnum::Other);
|
||||
audioType = StringToEnum(dom::MediaSourceEnumValues::strings,
|
||||
ac.mMediaSource.Value(), MediaSourceEnum::Other);
|
||||
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
|
||||
(uint32_t)audioType);
|
||||
|
||||
@ -4000,7 +4004,8 @@ void DeviceListener::Activate(RefPtr<LocalMediaDevice> aDevice,
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
LOG("DeviceListener %p activating %s device %p", this,
|
||||
dom::GetEnumString(aDevice->Kind()).get(), aDevice.get());
|
||||
nsCString(dom::MediaDeviceKindValues::GetString(aDevice->Kind())).get(),
|
||||
aDevice.get());
|
||||
|
||||
MOZ_ASSERT(!mStopped, "Cannot activate stopped device listener");
|
||||
MOZ_ASSERT(!Activated(), "Already activated");
|
||||
@ -4056,15 +4061,18 @@ DeviceListener::InitializeAsync() {
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCString log;
|
||||
log.AppendPrintf("Starting %s failed",
|
||||
dom::GetEnumString(kind).get());
|
||||
log.AppendPrintf(
|
||||
"Starting %s failed",
|
||||
nsCString(dom::MediaDeviceKindValues::GetString(kind))
|
||||
.get());
|
||||
aHolder.Reject(
|
||||
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError,
|
||||
std::move(log)),
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
LOG("started %s device %p", dom::GetEnumString(kind).get(),
|
||||
LOG("started %s device %p",
|
||||
nsCString(dom::MediaDeviceKindValues::GetString(kind)).get(),
|
||||
device.get());
|
||||
aHolder.Resolve(true, __func__);
|
||||
})
|
||||
@ -4172,7 +4180,9 @@ auto DeviceListener::UpdateDevice(bool aOn) -> RefPtr<DeviceOperationPromise> {
|
||||
}
|
||||
LOG("DeviceListener %p turning %s %s input device %s", this,
|
||||
aOn ? "on" : "off",
|
||||
dom::GetEnumString(GetDevice()->Kind()).get(),
|
||||
nsCString(
|
||||
dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
||||
.get(),
|
||||
NS_SUCCEEDED(aResult) ? "succeeded" : "failed");
|
||||
|
||||
if (NS_FAILED(aResult) && aResult != NS_ERROR_ABORT) {
|
||||
@ -4205,7 +4215,8 @@ void DeviceListener::SetDeviceEnabled(bool aEnable) {
|
||||
|
||||
LOG("DeviceListener %p %s %s device", this,
|
||||
aEnable ? "enabling" : "disabling",
|
||||
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
||||
.get());
|
||||
|
||||
state.mTrackEnabled = aEnable;
|
||||
|
||||
@ -4261,7 +4272,9 @@ void DeviceListener::SetDeviceEnabled(bool aEnable) {
|
||||
|
||||
LOG("DeviceListener %p %s %s device - starting device operation",
|
||||
this, aEnable ? "enabling" : "disabling",
|
||||
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||
nsCString(
|
||||
dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
||||
.get());
|
||||
|
||||
if (state.mStopped) {
|
||||
// Source was stopped between timer resolving and this runnable.
|
||||
@ -4330,7 +4343,8 @@ void DeviceListener::SetDeviceMuted(bool aMute) {
|
||||
DeviceState& state = *mDeviceState;
|
||||
|
||||
LOG("DeviceListener %p %s %s device", this, aMute ? "muting" : "unmuting",
|
||||
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
||||
.get());
|
||||
|
||||
if (state.mStopped) {
|
||||
// Device terminally stopped. Updating device state is pointless.
|
||||
@ -4344,7 +4358,8 @@ void DeviceListener::SetDeviceMuted(bool aMute) {
|
||||
|
||||
LOG("DeviceListener %p %s %s device - starting device operation", this,
|
||||
aMute ? "muting" : "unmuting",
|
||||
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
||||
.get());
|
||||
|
||||
state.mDeviceMuted = aMute;
|
||||
|
||||
@ -4450,7 +4465,9 @@ RefPtr<DeviceListener::DeviceListenerPromise> DeviceListener::ApplyConstraints(
|
||||
|
||||
if (mStopped || mDeviceState->mStopped) {
|
||||
LOG("DeviceListener %p %s device applyConstraints, but device is stopped",
|
||||
this, dom::GetEnumString(GetDevice()->Kind()).get());
|
||||
this,
|
||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
||||
.get());
|
||||
return DeviceListenerPromise::CreateAndResolve(false, __func__);
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ void MediaStreamTrack::GetSettings(dom::MediaTrackSettings& aResult,
|
||||
}
|
||||
if (aResult.mFacingMode.WasPassed()) {
|
||||
aResult.mFacingMode.Value().AssignASCII(
|
||||
GetEnumString(VideoFacingModeEnum::User));
|
||||
VideoFacingModeEnumValues::GetString(VideoFacingModeEnum::User));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,9 +364,7 @@ class VideoFrameConverter {
|
||||
aFrame.mImage->AsPlanarYCbCrImage();
|
||||
if (image) {
|
||||
dom::ImageUtils utils(image);
|
||||
Maybe<dom::ImageBitmapFormat> format = utils.GetFormat();
|
||||
if (format.isSome() &&
|
||||
format.value() == dom::ImageBitmapFormat::YUV420P &&
|
||||
if (utils.GetFormat() == dom::ImageBitmapFormat::YUV420P &&
|
||||
image->GetData()) {
|
||||
const layers::PlanarYCbCrData* data = image->GetData();
|
||||
rtc::scoped_refptr<webrtc::I420BufferInterface> video_frame_buffer =
|
||||
|
@ -123,8 +123,9 @@ void MediaKeySession::UpdateKeyStatusMap() {
|
||||
nsPrintfCString("MediaKeySession[%p,'%s'] key statuses change {", this,
|
||||
NS_ConvertUTF16toUTF8(mSessionId).get()));
|
||||
for (const CDMCaps::KeyStatus& status : keyStatuses) {
|
||||
message.AppendPrintf(" (%s,%s)", ToHexString(status.mId).get(),
|
||||
GetEnumString(status.mStatus).get());
|
||||
message.AppendPrintf(
|
||||
" (%s,%s)", ToHexString(status.mId).get(),
|
||||
nsCString(MediaKeyStatusValues::GetString(status.mStatus)).get());
|
||||
}
|
||||
message.AppendLiteral(" }");
|
||||
// Use %s so we aren't exposing random strings to printf interpolation.
|
||||
@ -541,7 +542,8 @@ void MediaKeySession::DispatchKeyMessage(MediaKeyMessageType aMessageType,
|
||||
EME_LOG(
|
||||
"MediaKeySession[%p,'%s'] DispatchKeyMessage() type=%s message='%s'",
|
||||
this, NS_ConvertUTF16toUTF8(mSessionId).get(),
|
||||
GetEnumString(aMessageType).get(), ToHexString(aMessage).get());
|
||||
nsCString(MediaKeyMessageTypeValues::GetString(aMessageType)).get(),
|
||||
ToHexString(aMessage).get());
|
||||
}
|
||||
|
||||
RefPtr<MediaKeyMessageEvent> event(
|
||||
@ -609,8 +611,12 @@ void MediaKeySession::SetOnmessage(EventHandlerNonNull* aCallback) {
|
||||
SetEventHandler(nsGkAtoms::onmessage, aCallback);
|
||||
}
|
||||
|
||||
nsCString ToCString(MediaKeySessionType aType) {
|
||||
return nsCString(MediaKeySessionTypeValues::GetString(aType));
|
||||
}
|
||||
|
||||
nsString ToString(MediaKeySessionType aType) {
|
||||
return NS_ConvertUTF8toUTF16(GetEnumString(aType));
|
||||
return NS_ConvertUTF8toUTF16(ToCString(aType));
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -36,6 +36,8 @@ class ArrayBufferViewOrArrayBuffer;
|
||||
class MediaKeyError;
|
||||
class MediaKeyStatusMap;
|
||||
|
||||
nsCString ToCString(MediaKeySessionType aType);
|
||||
|
||||
nsString ToString(MediaKeySessionType aType);
|
||||
|
||||
class MediaKeySession final : public DOMEventTargetHelper,
|
||||
|
@ -352,13 +352,15 @@ static bool SupportsEncryptionScheme(
|
||||
|
||||
static bool ToSessionType(const nsAString& aSessionType,
|
||||
MediaKeySessionType& aOutType) {
|
||||
Maybe<MediaKeySessionType> type =
|
||||
StringToEnum<MediaKeySessionType>(aSessionType);
|
||||
if (type.isNothing()) {
|
||||
return false;
|
||||
if (aSessionType.Equals(ToString(MediaKeySessionType::Temporary))) {
|
||||
aOutType = MediaKeySessionType::Temporary;
|
||||
return true;
|
||||
}
|
||||
aOutType = type.value();
|
||||
return true;
|
||||
if (aSessionType.Equals(ToString(MediaKeySessionType::Persistent_license))) {
|
||||
aOutType = MediaKeySessionType::Persistent_license;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 5.1.1 Is persistent session type?
|
||||
@ -1080,7 +1082,7 @@ static nsCString ToCString(const nsString& aString) {
|
||||
|
||||
static nsCString ToCString(const MediaKeysRequirement aValue) {
|
||||
nsCString str("'");
|
||||
str.AppendASCII(GetEnumString(aValue));
|
||||
str.AppendASCII(MediaKeysRequirementValues::GetString(aValue));
|
||||
str.AppendLiteral("'");
|
||||
return str;
|
||||
}
|
||||
|
@ -412,7 +412,8 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
|
||||
"MediaKeySystemAccess::GetKeySystemStatus(%s) "
|
||||
"result=%s msg='%s'",
|
||||
NS_ConvertUTF16toUTF8(aRequest->mKeySystem).get(),
|
||||
GetEnumString(status).get(), message.get());
|
||||
nsCString(MediaKeySystemStatusValues::GetString(status)).get(),
|
||||
message.get());
|
||||
LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg));
|
||||
EME_LOG("%s", msg.get());
|
||||
|
||||
|
@ -792,7 +792,8 @@ void MediaKeys::GetSessionsInfo(nsString& sessionsInfo) {
|
||||
sessionsInfo.AppendLiteral("(kid=");
|
||||
sessionsInfo.Append(keyID);
|
||||
sessionsInfo.AppendLiteral(" status=");
|
||||
sessionsInfo.AppendASCII(GetEnumString(keyStatusMap->GetValueAtIndex(i)));
|
||||
sessionsInfo.AppendASCII(
|
||||
MediaKeyStatusValues::GetString(keyStatusMap->GetValueAtIndex(i)));
|
||||
sessionsInfo.AppendLiteral(")");
|
||||
}
|
||||
sessionsInfo.AppendLiteral(")");
|
||||
@ -823,7 +824,7 @@ already_AddRefed<Promise> MediaKeys::GetStatusForPolicy(
|
||||
}
|
||||
|
||||
EME_LOG("GetStatusForPolicy minHdcpVersion = %s.",
|
||||
GetEnumString(aPolicy.mMinHdcpVersion.Value()).get());
|
||||
HDCPVersionValues::GetString(aPolicy.mMinHdcpVersion.Value()).data());
|
||||
mProxy->GetStatusForPolicy(StorePromise(promise),
|
||||
aPolicy.mMinHdcpVersion.Value());
|
||||
return promise.forget();
|
||||
|
@ -381,7 +381,8 @@ void WMFCDMProxy::GetStatusForPolicy(PromiseId aPromiseId,
|
||||
RETURN_IF_SHUTDOWN();
|
||||
EME_LOG("WMFCDMProxy::GetStatusForPolicy(this=%p, pid=%" PRIu32
|
||||
", minHDCP=%s)",
|
||||
this, aPromiseId, dom::GetEnumString(aMinHdcpVersion).get());
|
||||
this, aPromiseId,
|
||||
dom::HDCPVersionValues::GetString(aMinHdcpVersion).data());
|
||||
mCDM->GetStatusForPolicy(aPromiseId, aMinHdcpVersion)
|
||||
->Then(
|
||||
mMainThread, __func__,
|
||||
|
@ -605,7 +605,8 @@ void ChromiumCDMProxy::GetStatusForPolicy(
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
EME_LOG("ChromiumCDMProxy::GetStatusForPolicy(this=%p, pid=%" PRIu32
|
||||
") minHdcpVersion=%s",
|
||||
this, aPromiseId, dom::GetEnumString(aMinHdcpVersion).get());
|
||||
this, aPromiseId,
|
||||
dom::HDCPVersionValues::GetString(aMinHdcpVersion).data());
|
||||
|
||||
RefPtr<gmp::ChromiumCDMParent> cdm = GetCDMParent();
|
||||
if (!cdm) {
|
||||
|
@ -5,9 +5,9 @@
|
||||
#ifndef DOM_MEDIA_IPC_MFCDMSERIALIZERS_H_
|
||||
#define DOM_MEDIA_IPC_MFCDMSERIALIZERS_H_
|
||||
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "MediaData.h"
|
||||
#include "mozilla/KeySystemConfig.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/MediaKeyMessageEventBinding.h"
|
||||
#include "mozilla/dom/MediaKeyStatusMapBinding.h"
|
||||
|
||||
@ -35,17 +35,23 @@ struct ParamTraits<mozilla::CryptoScheme>
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::MediaKeyMessageType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::MediaKeyMessageType> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::MediaKeyMessageType,
|
||||
mozilla::dom::MediaKeyMessageType::License_request,
|
||||
mozilla::dom::MediaKeyMessageType::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::MediaKeyStatus>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::MediaKeyStatus> {
|
||||
: public ContiguousEnumSerializer<mozilla::dom::MediaKeyStatus,
|
||||
mozilla::dom::MediaKeyStatus::Usable,
|
||||
mozilla::dom::MediaKeyStatus::EndGuard_> {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::HDCPVersion>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::HDCPVersion> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::HDCPVersion,
|
||||
mozilla::dom::HDCPVersion::_1_0,
|
||||
mozilla::dom::HDCPVersion::EndGuard_> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
|
@ -50,8 +50,8 @@ using namespace gfx;
|
||||
// Used so that we only ever attempt to check if the RDD/GPU/Utility processes
|
||||
// should be launched serially. Protects sLaunchPromise
|
||||
StaticMutex sLaunchMutex;
|
||||
static EnumeratedArray<RemoteDecodeIn, StaticRefPtr<GenericNonExclusivePromise>,
|
||||
size_t(RemoteDecodeIn::SENTINEL)>
|
||||
static EnumeratedArray<RemoteDecodeIn, RemoteDecodeIn::SENTINEL,
|
||||
StaticRefPtr<GenericNonExclusivePromise>>
|
||||
sLaunchPromises MOZ_GUARDED_BY(sLaunchMutex);
|
||||
|
||||
// Only modified on the main-thread, read on any thread. While it could be read
|
||||
@ -61,8 +61,8 @@ static StaticDataMutex<StaticRefPtr<nsIThread>>
|
||||
sRemoteDecoderManagerChildThread("sRemoteDecoderManagerChildThread");
|
||||
|
||||
// Only accessed from sRemoteDecoderManagerChildThread
|
||||
static EnumeratedArray<RemoteDecodeIn, StaticRefPtr<RemoteDecoderManagerChild>,
|
||||
size_t(RemoteDecodeIn::SENTINEL)>
|
||||
static EnumeratedArray<RemoteDecodeIn, RemoteDecodeIn::SENTINEL,
|
||||
StaticRefPtr<RemoteDecoderManagerChild>>
|
||||
sRemoteDecoderManagerChildForProcesses;
|
||||
|
||||
static StaticAutoPtr<nsTArray<RefPtr<Runnable>>> sRecreateTasks;
|
||||
@ -70,8 +70,8 @@ static StaticAutoPtr<nsTArray<RefPtr<Runnable>>> sRecreateTasks;
|
||||
// Used for protecting codec support information collected from different remote
|
||||
// processes.
|
||||
StaticMutex sProcessSupportedMutex;
|
||||
static EnumeratedArray<RemoteDecodeIn, Maybe<media::MediaCodecsSupported>,
|
||||
size_t(RemoteDecodeIn::SENTINEL)>
|
||||
static EnumeratedArray<RemoteDecodeIn, RemoteDecodeIn::SENTINEL,
|
||||
Maybe<media::MediaCodecsSupported>>
|
||||
sProcessSupported MOZ_GUARDED_BY(sProcessSupportedMutex);
|
||||
|
||||
class ShutdownObserver final : public nsIObserver {
|
||||
|
@ -45,6 +45,21 @@ static nsCString VideoConfigurationToStr(const VideoConfiguration* aConfig) {
|
||||
return nsCString();
|
||||
}
|
||||
|
||||
nsCString hdrMetaType(
|
||||
aConfig->mHdrMetadataType.WasPassed()
|
||||
? HdrMetadataTypeValues::GetString(aConfig->mHdrMetadataType.Value())
|
||||
: "?");
|
||||
|
||||
nsCString colorGamut(
|
||||
aConfig->mColorGamut.WasPassed()
|
||||
? ColorGamutValues::GetString(aConfig->mColorGamut.Value())
|
||||
: "?");
|
||||
|
||||
nsCString transferFunction(aConfig->mTransferFunction.WasPassed()
|
||||
? TransferFunctionValues::GetString(
|
||||
aConfig->mTransferFunction.Value())
|
||||
: "?");
|
||||
|
||||
auto str = nsPrintfCString(
|
||||
"[contentType:%s width:%d height:%d bitrate:%" PRIu64
|
||||
" framerate:%lf hasAlphaChannel:%s hdrMetadataType:%s colorGamut:%s "
|
||||
@ -54,15 +69,7 @@ static nsCString VideoConfigurationToStr(const VideoConfiguration* aConfig) {
|
||||
aConfig->mHasAlphaChannel.WasPassed()
|
||||
? aConfig->mHasAlphaChannel.Value() ? "true" : "false"
|
||||
: "?",
|
||||
aConfig->mHdrMetadataType.WasPassed()
|
||||
? GetEnumString(aConfig->mHdrMetadataType.Value()).get()
|
||||
: "?",
|
||||
aConfig->mColorGamut.WasPassed()
|
||||
? GetEnumString(aConfig->mColorGamut.Value()).get()
|
||||
: "?",
|
||||
aConfig->mTransferFunction.WasPassed()
|
||||
? GetEnumString(aConfig->mTransferFunction.Value()).get()
|
||||
: "?",
|
||||
hdrMetaType.get(), colorGamut.get(), transferFunction.get(),
|
||||
aConfig->mScalabilityMode.WasPassed()
|
||||
? NS_ConvertUTF16toUTF8(aConfig->mScalabilityMode.Value()).get()
|
||||
: "?");
|
||||
|
@ -168,12 +168,8 @@ void ContentMediaControlKeyHandler::HandleMediaControlAction(
|
||||
if (!aContext->GetDocShell()) {
|
||||
return;
|
||||
}
|
||||
if (aAction.mKey.isNothing()) {
|
||||
MOZ_ASSERT_UNREACHABLE("Invalid media control key.");
|
||||
return;
|
||||
}
|
||||
ContentPlaybackController controller(aContext);
|
||||
switch (aAction.mKey.value()) {
|
||||
switch (aAction.mKey) {
|
||||
case MediaControlKey::Focus:
|
||||
controller.Focus();
|
||||
return;
|
||||
@ -183,9 +179,6 @@ void ContentMediaControlKeyHandler::HandleMediaControlAction(
|
||||
case MediaControlKey::Pause:
|
||||
controller.Pause();
|
||||
return;
|
||||
case MediaControlKey::Playpause:
|
||||
MOZ_ASSERT_UNREACHABLE("Invalid media control key.");
|
||||
return;
|
||||
case MediaControlKey::Stop:
|
||||
controller.Stop();
|
||||
return;
|
||||
|
@ -36,11 +36,7 @@ void MediaControlKeyHandler::OnActionPerformed(
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAction.mKey.isNothing()) {
|
||||
MOZ_ASSERT_UNREACHABLE("Error : undefined media key!");
|
||||
return;
|
||||
}
|
||||
switch (aAction.mKey.value()) {
|
||||
switch (aAction.mKey) {
|
||||
case MediaControlKey::Focus:
|
||||
controller->Focus();
|
||||
return;
|
||||
|
@ -28,10 +28,10 @@ struct SeekDetails {
|
||||
|
||||
struct MediaControlAction {
|
||||
MediaControlAction() = default;
|
||||
explicit MediaControlAction(MediaControlKey aKey) : mKey(Some(aKey)) {}
|
||||
explicit MediaControlAction(MediaControlKey aKey) : mKey(aKey) {}
|
||||
MediaControlAction(MediaControlKey aKey, const SeekDetails& aDetails)
|
||||
: mKey(Some(aKey)), mDetails(Some(aDetails)) {}
|
||||
Maybe<MediaControlKey> mKey;
|
||||
: mKey(aKey), mDetails(Some(aDetails)) {}
|
||||
MediaControlKey mKey = MediaControlKey::EndGuard_;
|
||||
Maybe<SeekDetails> mDetails;
|
||||
};
|
||||
|
||||
|
@ -50,14 +50,6 @@ inline const char* ToMediaControlKeyStr(MediaControlKey aKey) {
|
||||
}
|
||||
}
|
||||
|
||||
inline const char* ToMediaControlKeyStr(const Maybe<MediaControlKey>& aKey) {
|
||||
if (aKey.isNothing()) {
|
||||
MOZ_ASSERT_UNREACHABLE("Invalid action.");
|
||||
return "Unknown";
|
||||
}
|
||||
return ToMediaControlKeyStr(aKey.value());
|
||||
}
|
||||
|
||||
inline const char* ToMediaSessionActionStr(MediaSessionAction aAction) {
|
||||
switch (aAction) {
|
||||
case MediaSessionAction::Play:
|
||||
@ -107,6 +99,11 @@ inline MediaControlKey ConvertMediaSessionActionToControlKey(
|
||||
}
|
||||
}
|
||||
|
||||
inline MediaSessionAction ConvertToMediaSessionAction(uint8_t aActionValue) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aActionValue < uint8_t(MediaSessionAction::EndGuard_));
|
||||
return static_cast<MediaSessionAction>(aActionValue);
|
||||
}
|
||||
|
||||
inline const char* ToMediaPlaybackStateStr(MediaPlaybackState aState) {
|
||||
switch (aState) {
|
||||
case MediaPlaybackState::eStarted:
|
||||
|
@ -186,10 +186,9 @@ bool MediaController::ShouldPropagateActionToAllContexts(
|
||||
// These three actions have default action handler for each frame, so we
|
||||
// need to propagate to all contexts. We would handle default handlers in
|
||||
// `ContentMediaController::HandleMediaKey`.
|
||||
return aAction.mKey.isSome() &&
|
||||
(aAction.mKey.value() == MediaControlKey::Play ||
|
||||
aAction.mKey.value() == MediaControlKey::Pause ||
|
||||
aAction.mKey.value() == MediaControlKey::Stop);
|
||||
return aAction.mKey == MediaControlKey::Play ||
|
||||
aAction.mKey == MediaControlKey::Pause ||
|
||||
aAction.mKey == MediaControlKey::Stop;
|
||||
}
|
||||
|
||||
void MediaController::UpdateMediaControlActionToContentMediaIfNeeded(
|
||||
|
@ -401,8 +401,9 @@ CopyableTArray<MediaSessionAction> MediaStatusManager::GetSupportedActions()
|
||||
|
||||
MediaSessionInfo info =
|
||||
mMediaSessionInfoMap.Get(*mActiveMediaSessionContextId);
|
||||
for (MediaSessionAction action :
|
||||
MakeWebIDLEnumeratedRange<MediaSessionAction>()) {
|
||||
const uint8_t actionNums = uint8_t(MediaSessionAction::EndGuard_);
|
||||
for (uint8_t actionValue = 0; actionValue < actionNums; actionValue++) {
|
||||
MediaSessionAction action = ConvertToMediaSessionAction(actionValue);
|
||||
if (info.IsActionSupported(action)) {
|
||||
supportedActions.AppendElement(action);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class MediaKeyListenerTest : public MediaControlKeyListener {
|
||||
void Clear() { mReceivedKey = mozilla::Nothing(); }
|
||||
|
||||
void OnActionPerformed(const MediaControlAction& aAction) override {
|
||||
mReceivedKey = aAction.mKey;
|
||||
mReceivedKey = mozilla::Some(aAction.mKey);
|
||||
}
|
||||
bool IsResultEqualTo(MediaControlKey aResult) const {
|
||||
if (mReceivedKey) {
|
||||
|
@ -120,7 +120,8 @@ class MediaSession final : public nsIDocumentActivity, public nsWrapperCache {
|
||||
|
||||
RefPtr<MediaMetadata> mMediaMetadata;
|
||||
|
||||
EnumeratedArray<MediaSessionAction, RefPtr<MediaSessionActionHandler>>
|
||||
EnumeratedArray<MediaSessionAction, MediaSessionAction::EndGuard_,
|
||||
RefPtr<MediaSessionActionHandler>>
|
||||
mActionHandlers;
|
||||
|
||||
// This is used as is a hint for the user agent to determine whether the
|
||||
|
@ -6,7 +6,6 @@
|
||||
#define DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_
|
||||
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "MediaMetadata.h"
|
||||
#include "mozilla/dom/MediaSession.h"
|
||||
#include "mozilla/dom/MediaSessionBinding.h"
|
||||
@ -88,13 +87,17 @@ struct ParamTraits<mozilla::dom::PositionState> {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::MediaSessionPlaybackState>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::MediaSessionPlaybackState> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::MediaSessionPlaybackState,
|
||||
mozilla::dom::MediaSessionPlaybackState::None,
|
||||
mozilla::dom::MediaSessionPlaybackState::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::MediaSessionAction>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::MediaSessionAction> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::MediaSessionAction,
|
||||
mozilla::dom::MediaSessionAction::Play,
|
||||
mozilla::dom::MediaSessionAction::EndGuard_> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
|
@ -304,7 +304,8 @@ void MFCDMSession::OnSessionKeyMessage(
|
||||
case MF_MEDIAKEYSESSION_MESSAGETYPE_INDIVIDUALIZATION_REQUEST:
|
||||
return dom::MediaKeyMessageType::Individualization_request;
|
||||
default:
|
||||
MOZ_CRASH("Unknown session message type");
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown session message type");
|
||||
return dom::MediaKeyMessageType::EndGuard_;
|
||||
}
|
||||
};
|
||||
LOG("Notify 'keymessage' for %s", NS_ConvertUTF16toUTF8(*mSessionId).get());
|
||||
|
@ -329,8 +329,10 @@ class OscillatorNodeEngine final : public AudioNodeEngine {
|
||||
case OscillatorType::Custom:
|
||||
ComputeCustom(output, start, end, frequency, detune);
|
||||
break;
|
||||
// Avoid `default:` so that `-Wswitch` catches missing enumerators at
|
||||
// compile time.
|
||||
case OscillatorType::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("end guard");
|
||||
// Avoid `default:` so that `-Wswitch` catches missing enumerators
|
||||
// at compile time.
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,9 @@ nsString VideoDecoderConfigInternal::ToString() const {
|
||||
if (mDescription.isSome()) {
|
||||
rv.AppendPrintf("extradata: %zu bytes", mDescription.value()->Length());
|
||||
}
|
||||
rv.AppendPrintf("hw accel: %s", GetEnumString(mHardwareAcceleration).get());
|
||||
rv.AppendPrintf(
|
||||
"hw accel: %s",
|
||||
HardwareAccelerationValues::GetString(mHardwareAcceleration).data());
|
||||
if (mOptimizeForLatency.isSome()) {
|
||||
rv.AppendPrintf("optimize for latency: %s",
|
||||
mOptimizeForLatency.value() ? "true" : "false");
|
||||
@ -326,10 +328,8 @@ static Maybe<VideoPixelFormat> GuessPixelFormat(layers::Image* aImage) {
|
||||
// DMABUFSurfaceImage?
|
||||
if (aImage->AsPlanarYCbCrImage() || aImage->AsNVImage()) {
|
||||
const ImageUtils imageUtils(aImage);
|
||||
Maybe<dom::ImageBitmapFormat> format = imageUtils.GetFormat();
|
||||
Maybe<VideoPixelFormat> f =
|
||||
format.isSome() ? ImageBitmapFormatToVideoPixelFormat(format.value())
|
||||
: Nothing();
|
||||
ImageBitmapFormatToVideoPixelFormat(imageUtils.GetFormat());
|
||||
|
||||
// ImageBitmapFormat cannot distinguish YUV420 or YUV420A.
|
||||
bool hasAlpha = aImage->AsPlanarYCbCrImage() &&
|
||||
@ -385,6 +385,8 @@ static VideoColorSpaceInternal GuessColorSpace(
|
||||
// Make an educated guess based on the coefficients.
|
||||
colorSpace.mPrimaries = colorSpace.mMatrix.map([](const auto& aMatrix) {
|
||||
switch (aMatrix) {
|
||||
case VideoMatrixCoefficients::EndGuard_:
|
||||
MOZ_CRASH("This should not happen");
|
||||
case VideoMatrixCoefficients::Bt2020_ncl:
|
||||
return VideoColorPrimaries::Bt2020;
|
||||
case VideoMatrixCoefficients::Rgb:
|
||||
@ -521,6 +523,9 @@ static VideoColorSpaceInternal GuessColorSpace(layers::Image* aImage) {
|
||||
case VideoMatrixCoefficients::Bt2020_ncl:
|
||||
colorSpace.mPrimaries = Some(VideoColorPrimaries::Bt2020);
|
||||
break;
|
||||
case VideoMatrixCoefficients::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("bad enum value");
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -135,20 +135,26 @@ nsString VideoEncoderConfigInternal::ToString() const {
|
||||
if (mFramerate.isSome()) {
|
||||
rv.AppendPrintf(", %lfHz", mFramerate.value());
|
||||
}
|
||||
rv.AppendPrintf(" hw: %s", GetEnumString(mHardwareAcceleration).get());
|
||||
rv.AppendPrintf(", alpha: %s", GetEnumString(mAlpha).get());
|
||||
rv.AppendPrintf(
|
||||
" hw: %s",
|
||||
HardwareAccelerationValues::GetString(mHardwareAcceleration).data());
|
||||
rv.AppendPrintf(", alpha: %s", AlphaOptionValues::GetString(mAlpha).data());
|
||||
if (mScalabilityMode.isSome()) {
|
||||
rv.AppendPrintf(", scalability mode: %s",
|
||||
NS_ConvertUTF16toUTF8(mScalabilityMode.value()).get());
|
||||
}
|
||||
rv.AppendPrintf(", bitrate mode: %s", GetEnumString(mBitrateMode).get());
|
||||
rv.AppendPrintf(", latency mode: %s", GetEnumString(mLatencyMode).get());
|
||||
rv.AppendPrintf(
|
||||
", bitrate mode: %s",
|
||||
VideoEncoderBitrateModeValues::GetString(mBitrateMode).data());
|
||||
rv.AppendPrintf(", latency mode: %s",
|
||||
LatencyModeValues::GetString(mLatencyMode).data());
|
||||
if (mContentHint.isSome()) {
|
||||
rv.AppendPrintf(", content hint: %s",
|
||||
NS_ConvertUTF16toUTF8(mContentHint.value()).get());
|
||||
}
|
||||
if (mAvc.isSome()) {
|
||||
rv.AppendPrintf(", avc-specific: %s", GetEnumString(mAvc->mFormat).get());
|
||||
rv.AppendPrintf(", avc-specific: %s",
|
||||
AvcBitstreamFormatValues::GetString(mAvc->mFormat).data());
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -598,6 +598,8 @@ static bool IsYUVFormat(const VideoPixelFormat& aFormat) {
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return false;
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -639,6 +641,8 @@ static VideoColorSpaceInit PickColorSpace(
|
||||
colorSpace.mPrimaries.SetValue(VideoColorPrimaries::Bt709);
|
||||
colorSpace.mTransfer.SetValue(VideoTransferCharacteristics::Iec61966_2_1);
|
||||
break;
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
}
|
||||
|
||||
return colorSpace;
|
||||
@ -877,6 +881,8 @@ static Result<RefPtr<layers::Image>, nsCString> CreateImageFromBuffer(
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return CreateRGBAImageFromBuffer(aFormat, aSize, aBuffer);
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
}
|
||||
return Err(nsCString("Invalid image format"));
|
||||
}
|
||||
@ -1384,9 +1390,8 @@ already_AddRefed<VideoFrame> VideoFrame::Constructor(
|
||||
}
|
||||
|
||||
const ImageUtils imageUtils(image);
|
||||
Maybe<dom::ImageBitmapFormat> f = imageUtils.GetFormat();
|
||||
Maybe<VideoPixelFormat> format =
|
||||
f.isSome() ? ImageBitmapFormatToVideoPixelFormat(f.value()) : Nothing();
|
||||
ImageBitmapFormatToVideoPixelFormat(imageUtils.GetFormat());
|
||||
|
||||
// TODO: Retrive/infer the duration, and colorspace.
|
||||
auto r = InitializeFrameFromOtherFrame(
|
||||
@ -1784,13 +1789,15 @@ nsCString VideoFrame::ToString() const {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv.AppendPrintf("VideoFrame ts: %" PRId64
|
||||
", %s, coded[%dx%d] visible[%dx%d], display[%dx%d] color: %s",
|
||||
mTimestamp,
|
||||
dom::GetEnumString(mResource->mFormat->PixelFormat()).get(),
|
||||
mCodedSize.width, mCodedSize.height, mVisibleRect.width,
|
||||
mVisibleRect.height, mDisplaySize.width, mDisplaySize.height,
|
||||
ColorSpaceInitToString(mColorSpace).get());
|
||||
rv.AppendPrintf(
|
||||
"VideoFrame ts: %" PRId64
|
||||
", %s, coded[%dx%d] visible[%dx%d], display[%dx%d] color: %s",
|
||||
mTimestamp,
|
||||
dom::VideoPixelFormatValues::GetString(mResource->mFormat->PixelFormat())
|
||||
.data(),
|
||||
mCodedSize.width, mCodedSize.height, mVisibleRect.width,
|
||||
mVisibleRect.height, mDisplaySize.width, mDisplaySize.height,
|
||||
ColorSpaceInitToString(mColorSpace).get());
|
||||
|
||||
if (mDuration) {
|
||||
rv.AppendPrintf(" dur: %" PRId64, mDuration.value());
|
||||
@ -2025,6 +2032,8 @@ gfx::SurfaceFormat VideoFrame::Format::ToSurfaceFormat() const {
|
||||
case VideoPixelFormat::BGRX:
|
||||
format = gfx::SurfaceFormat::B8G8R8X8;
|
||||
break;
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
}
|
||||
return format;
|
||||
}
|
||||
@ -2047,6 +2056,8 @@ void VideoFrame::Format::MakeOpaque() {
|
||||
case VideoPixelFormat::RGBX:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return;
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
}
|
||||
@ -2066,6 +2077,8 @@ nsTArray<VideoFrame::Format::Plane> VideoFrame::Format::Planes() const {
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return {Plane::RGBA};
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
return {};
|
||||
@ -2112,6 +2125,8 @@ uint32_t VideoFrame::Format::SampleBytes(const Plane& aPlane) const {
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return 4; // 8 bits/sample, 32 bits/pixel
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
return 0;
|
||||
@ -2139,6 +2154,7 @@ gfx::IntSize VideoFrame::Format::SampleSize(const Plane& aPlane) const {
|
||||
case VideoPixelFormat::RGBX:
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("invalid format");
|
||||
return {0, 0};
|
||||
}
|
||||
@ -2161,6 +2177,8 @@ bool VideoFrame::Format::IsValidSize(const gfx::IntSize& aSize) const {
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return true;
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
return false;
|
||||
@ -2187,6 +2205,8 @@ size_t VideoFrame::Format::SampleCount(const gfx::IntSize& aSize) const {
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return (count * 4).value();
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
break;
|
||||
}
|
||||
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported format");
|
||||
@ -2232,6 +2252,8 @@ uint32_t VideoFrame::Resource::Stride(const Format::Plane& aPlane) const {
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
return (width * mFormat->SampleBytes(aPlane)).value();
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("invalid format");
|
||||
}
|
||||
return 0;
|
||||
case Format::Plane::U: // and UV
|
||||
@ -2247,6 +2269,7 @@ uint32_t VideoFrame::Resource::Stride(const Format::Plane& aPlane) const {
|
||||
case VideoPixelFormat::RGBX:
|
||||
case VideoPixelFormat::BGRA:
|
||||
case VideoPixelFormat::BGRX:
|
||||
case VideoPixelFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE("invalid format");
|
||||
}
|
||||
return 0;
|
||||
|
@ -151,6 +151,8 @@ gfx::YUVColorSpace ToColorSpace(VideoMatrixCoefficients aMatrix) {
|
||||
return gfx::YUVColorSpace::BT601;
|
||||
case VideoMatrixCoefficients::Bt2020_ncl:
|
||||
return gfx::YUVColorSpace::BT2020;
|
||||
case VideoMatrixCoefficients::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported VideoMatrixCoefficients");
|
||||
return gfx::YUVColorSpace::Default;
|
||||
@ -169,7 +171,8 @@ gfx::TransferFunction ToTransferFunction(
|
||||
case VideoTransferCharacteristics::Hlg:
|
||||
return gfx::TransferFunction::HLG;
|
||||
case VideoTransferCharacteristics::Linear:
|
||||
return gfx::TransferFunction::Default;
|
||||
case VideoTransferCharacteristics::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported VideoTransferCharacteristics");
|
||||
return gfx::TransferFunction::Default;
|
||||
@ -187,6 +190,8 @@ gfx::ColorSpace2 ToPrimaries(VideoColorPrimaries aPrimaries) {
|
||||
return gfx::ColorSpace2::BT2020;
|
||||
case VideoColorPrimaries::Smpte432:
|
||||
return gfx::ColorSpace2::DISPLAY_P3;
|
||||
case VideoColorPrimaries::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unsupported VideoTransferCharacteristics");
|
||||
return gfx::ColorSpace2::UNKNOWN;
|
||||
@ -359,13 +364,15 @@ struct ConfigurationChangeToString {
|
||||
}
|
||||
nsCString operator()(
|
||||
const HardwareAccelerationChange& aHardwareAccelerationChange) {
|
||||
return nsPrintfCString(
|
||||
"HW acceleration: %s",
|
||||
dom::GetEnumString(aHardwareAccelerationChange.get()).get());
|
||||
return nsPrintfCString("HW acceleration: %s",
|
||||
dom::HardwareAccelerationValues::GetString(
|
||||
aHardwareAccelerationChange.get())
|
||||
.data());
|
||||
}
|
||||
nsCString operator()(const AlphaChange& aAlphaChange) {
|
||||
return nsPrintfCString("Alpha: %s",
|
||||
dom::GetEnumString(aAlphaChange.get()).get());
|
||||
return nsPrintfCString(
|
||||
"Alpha: %s",
|
||||
dom::AlphaOptionValues::GetString(aAlphaChange.get()).data());
|
||||
}
|
||||
nsCString operator()(const ScalabilityModeChange& aScalabilityModeChange) {
|
||||
if (aScalabilityModeChange.get().isNothing()) {
|
||||
@ -376,12 +383,15 @@ struct ConfigurationChangeToString {
|
||||
NS_ConvertUTF16toUTF8(aScalabilityModeChange.get().value()).get());
|
||||
}
|
||||
nsCString operator()(const BitrateModeChange& aBitrateModeChange) {
|
||||
return nsPrintfCString("Bitrate mode: %s",
|
||||
dom::GetEnumString(aBitrateModeChange.get()).get());
|
||||
return nsPrintfCString(
|
||||
"Bitrate mode: %s",
|
||||
dom::VideoEncoderBitrateModeValues::GetString(aBitrateModeChange.get())
|
||||
.data());
|
||||
}
|
||||
nsCString operator()(const LatencyModeChange& aLatencyModeChange) {
|
||||
return nsPrintfCString("Latency mode: %s",
|
||||
dom::GetEnumString(aLatencyModeChange.get()).get());
|
||||
return nsPrintfCString(
|
||||
"Latency mode: %s",
|
||||
dom::LatencyModeValues::GetString(aLatencyModeChange.get()).data());
|
||||
}
|
||||
nsCString operator()(const ContentHintChange& aContentHintChange) {
|
||||
return nsPrintfCString("Content hint: %s",
|
||||
@ -479,6 +489,9 @@ WebCodecsConfigurationChangeList::ToPEMChangeList() const {
|
||||
return rv.forget();
|
||||
}
|
||||
|
||||
#define ENUM_TO_STRING(enumType, enumValue) \
|
||||
enumType##Values::GetString(enumValue).data()
|
||||
|
||||
nsCString ColorSpaceInitToString(
|
||||
const dom::VideoColorSpaceInit& aColorSpaceInit) {
|
||||
nsCString rv("VideoColorSpace");
|
||||
@ -489,15 +502,18 @@ nsCString ColorSpaceInitToString(
|
||||
}
|
||||
if (!aColorSpaceInit.mMatrix.IsNull()) {
|
||||
rv.AppendPrintf(" matrix: %s",
|
||||
GetEnumString(aColorSpaceInit.mMatrix.Value()).get());
|
||||
ENUM_TO_STRING(dom::VideoMatrixCoefficients,
|
||||
aColorSpaceInit.mMatrix.Value()));
|
||||
}
|
||||
if (!aColorSpaceInit.mTransfer.IsNull()) {
|
||||
rv.AppendPrintf(" transfer: %s",
|
||||
GetEnumString(aColorSpaceInit.mTransfer.Value()).get());
|
||||
ENUM_TO_STRING(dom::VideoTransferCharacteristics,
|
||||
aColorSpaceInit.mTransfer.Value()));
|
||||
}
|
||||
if (!aColorSpaceInit.mPrimaries.IsNull()) {
|
||||
rv.AppendPrintf(" primaries: %s",
|
||||
GetEnumString(aColorSpaceInit.mPrimaries.Value()).get());
|
||||
ENUM_TO_STRING(dom::VideoColorPrimaries,
|
||||
aColorSpaceInit.mPrimaries.Value()));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -136,8 +136,10 @@ MediaEngineFakeVideoSource::MediaEngineFakeVideoSource()
|
||||
mSettings->mHeight.Construct(
|
||||
int32_t(MediaEnginePrefs::DEFAULT_43_VIDEO_HEIGHT));
|
||||
mSettings->mFrameRate.Construct(double(MediaEnginePrefs::DEFAULT_VIDEO_FPS));
|
||||
mSettings->mFacingMode.Construct(NS_ConvertASCIItoUTF16(
|
||||
dom::GetEnumString(VideoFacingModeEnum::Environment)));
|
||||
mSettings->mFacingMode.Construct(
|
||||
NS_ConvertASCIItoUTF16(dom::VideoFacingModeEnumValues::strings
|
||||
[uint8_t(VideoFacingModeEnum::Environment)]
|
||||
.value));
|
||||
}
|
||||
|
||||
nsString MediaEngineFakeVideoSource::GetGroupId() {
|
||||
|
@ -108,7 +108,8 @@ MediaEngineRemoteVideoSource::MediaEngineRemoteVideoSource(
|
||||
Maybe<VideoFacingModeEnum> facingMode =
|
||||
GetFacingMode(mMediaDevice->mRawName);
|
||||
if (facingMode.isSome()) {
|
||||
NS_ConvertASCIItoUTF16 facingString(dom::GetEnumString(*facingMode));
|
||||
NS_ConvertASCIItoUTF16 facingString(
|
||||
dom::VideoFacingModeEnumValues::GetString(*facingMode));
|
||||
mSettings->mFacingMode.Construct(facingString);
|
||||
mFacingMode.emplace(facingString);
|
||||
}
|
||||
|
@ -20,6 +20,17 @@ namespace mozilla {
|
||||
class LocalMediaDevice;
|
||||
class MediaDevice;
|
||||
|
||||
template <class EnumValuesStrings, class Enum>
|
||||
static Enum StringToEnum(const EnumValuesStrings& aStrings,
|
||||
const nsAString& aValue, Enum aDefaultValue) {
|
||||
for (size_t i = 0; aStrings[i].value; i++) {
|
||||
if (aValue.EqualsASCII(aStrings[i].value)) {
|
||||
return Enum(i);
|
||||
}
|
||||
}
|
||||
return aDefaultValue;
|
||||
}
|
||||
|
||||
// Helper classes for orthogonal constraints without interdependencies.
|
||||
// Instead of constraining values, constrain the constraints themselves.
|
||||
class NormalizedConstraintSet {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "WebrtcIPCTraits.h"
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "ipc/IPCMessageUtilsSpecializations.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/RTCDataChannelBinding.h"
|
||||
#include "mozilla/dom/RTCStatsReportBinding.h"
|
||||
@ -63,22 +62,30 @@ namespace IPC {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCStatsType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RTCStatsType> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::RTCStatsType,
|
||||
mozilla::dom::RTCStatsType::Codec,
|
||||
mozilla::dom::RTCStatsType::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCStatsIceCandidatePairState>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::RTCStatsIceCandidatePairState> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::RTCStatsIceCandidatePairState,
|
||||
mozilla::dom::RTCStatsIceCandidatePairState::Frozen,
|
||||
mozilla::dom::RTCStatsIceCandidatePairState::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCIceCandidateType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::RTCIceCandidateType> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::RTCIceCandidateType,
|
||||
mozilla::dom::RTCIceCandidateType::Host,
|
||||
mozilla::dom::RTCIceCandidateType::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCBundlePolicy>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RTCBundlePolicy> {
|
||||
};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::RTCBundlePolicy,
|
||||
mozilla::dom::RTCBundlePolicy::Balanced,
|
||||
mozilla::dom::RTCBundlePolicy::EndGuard_> {};
|
||||
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCIceServerInternal, mUrls,
|
||||
mCredentialProvided, mUserNameProvided);
|
||||
@ -211,8 +218,10 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCDataChannelStats, mId,
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCDataChannelState>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::RTCDataChannelState> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::RTCDataChannelState,
|
||||
mozilla::dom::RTCDataChannelState::Connecting,
|
||||
mozilla::dom::RTCDataChannelState::EndGuard_> {};
|
||||
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCCodecStats, mTimestamp,
|
||||
mType, mId, mPayloadType, mCodecType,
|
||||
@ -221,7 +230,9 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCCodecStats, mTimestamp,
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCCodecType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::RTCCodecType> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::RTCCodecType,
|
||||
mozilla::dom::RTCCodecType::Encode,
|
||||
mozilla::dom::RTCCodecType::EndGuard_> {};
|
||||
} // namespace IPC
|
||||
|
||||
#endif // _WEBRTC_GLOBAL_H_
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "ipc/IPCMessageUtilsSpecializations.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/RTCConfigurationBinding.h"
|
||||
#include "mozilla/media/webrtc/WebrtcGlobal.h"
|
||||
#include "mozilla/dom/CandidateInfo.h"
|
||||
@ -63,15 +62,17 @@ struct ParamTraits<mozilla::dom::OwningStringOrStringSequence> {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct WebidlEnumSerializer
|
||||
: public ContiguousEnumSerializer<T, T(0), T::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCIceCredentialType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::RTCIceCredentialType> {};
|
||||
: public WebidlEnumSerializer<mozilla::dom::RTCIceCredentialType> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::RTCIceTransportPolicy>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::RTCIceTransportPolicy> {};
|
||||
: public WebidlEnumSerializer<mozilla::dom::RTCIceTransportPolicy> {};
|
||||
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCIceServer, mCredential,
|
||||
mCredentialType, mUrl, mUrls, mUsername)
|
||||
|
@ -1671,6 +1671,7 @@ JsepSdpType ToJsepSdpType(dom::RTCSdpType aType) {
|
||||
return kJsepSdpAnswer;
|
||||
case dom::RTCSdpType::Rollback:
|
||||
return kJsepSdpRollback;
|
||||
case dom::RTCSdpType::EndGuard_:;
|
||||
}
|
||||
|
||||
MOZ_CRASH("Nonexistent dom::RTCSdpType");
|
||||
@ -3648,6 +3649,8 @@ RTCIceGatheringState PeerConnectionImpl::GetNewIceGatheringState() const {
|
||||
case RTCIceGathererState::Complete:
|
||||
foundComplete = true;
|
||||
break;
|
||||
case RTCIceGathererState::EndGuard_:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1502,6 +1502,7 @@ Maybe<RTCRtpSender::VideoConfig> RTCRtpSender::GetNewVideoConfig() {
|
||||
|
||||
case dom::MediaSourceEnum::Microphone:
|
||||
case dom::MediaSourceEnum::AudioCapture:
|
||||
case dom::MediaSourceEnum::EndGuard_:
|
||||
MOZ_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
@ -239,6 +239,7 @@ SdpDirectionAttribute::Direction ToSdpDirection(
|
||||
case dom::RTCRtpTransceiverDirection::Inactive:
|
||||
case dom::RTCRtpTransceiverDirection::Stopped:
|
||||
return SdpDirectionAttribute::Direction::kInactive;
|
||||
case dom::RTCRtpTransceiverDirection::EndGuard_:;
|
||||
}
|
||||
MOZ_CRASH("Invalid transceiver direction!");
|
||||
}
|
||||
|
@ -104,14 +104,14 @@ bool MIDIPort::Initialize(const MIDIPortInfo& aPortInfo, bool aSysexEnabled,
|
||||
mPortHolder.Init(port.forget());
|
||||
LOG("MIDIPort::Initialize (%s, %s)",
|
||||
NS_ConvertUTF16toUTF8(Port()->Name()).get(),
|
||||
GetEnumString(Port()->Type()).get());
|
||||
MIDIPortTypeValues::strings[uint32_t(Port()->Type())].value);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MIDIPort::UnsetIPCPort() {
|
||||
LOG("MIDIPort::UnsetIPCPort (%s, %s)",
|
||||
NS_ConvertUTF16toUTF8(Port()->Name()).get(),
|
||||
GetEnumString(Port()->Type()).get());
|
||||
MIDIPortTypeValues::strings[uint32_t(Port()->Type())].value);
|
||||
mPortHolder.Clear();
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,8 @@ void ConvertDetailsUpdate(JSContext* aCx, const PaymentDetailsUpdate& aDetails,
|
||||
|
||||
void ConvertOptions(const PaymentOptions& aOptions,
|
||||
IPCPaymentOptions& aIPCOption) {
|
||||
NS_ConvertASCIItoUTF16 shippingType(GetEnumString(aOptions.mShippingType));
|
||||
NS_ConvertASCIItoUTF16 shippingType(
|
||||
PaymentShippingTypeValues::GetString(aOptions.mShippingType));
|
||||
aIPCOption =
|
||||
IPCPaymentOptions(aOptions.mRequestPayerName, aOptions.mRequestPayerEmail,
|
||||
aOptions.mRequestPayerPhone, aOptions.mRequestShipping,
|
||||
@ -547,7 +548,8 @@ void PaymentRequestManager::CompletePayment(PaymentRequest* aRequest,
|
||||
if (aTimedOut) {
|
||||
completeStatusString.AssignLiteral("timeout");
|
||||
} else {
|
||||
completeStatusString.AssignASCII(GetEnumString(aComplete));
|
||||
completeStatusString.AssignASCII(
|
||||
PaymentCompleteValues::GetString(aComplete));
|
||||
}
|
||||
|
||||
nsAutoString requestId;
|
||||
|
@ -24,7 +24,7 @@ static const nsLiteralCString kPermissionTypes[] = {
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const size_t kPermissionNameCount = ContiguousEnumSize<PermissionName>::value;
|
||||
const size_t kPermissionNameCount = PermissionNameValues::Count;
|
||||
|
||||
static_assert(MOZ_ARRAY_LENGTH(kPermissionTypes) == kPermissionNameCount,
|
||||
"kPermissionTypes and PermissionName count should match");
|
||||
|
@ -727,8 +727,7 @@ class QuotaManager final : public BackgroundThreadObject {
|
||||
|
||||
nsCOMPtr<mozIStorageConnection> mStorageConnection;
|
||||
|
||||
EnumeratedArray<Client::Type, nsCString, size_t(Client::TYPE_MAX)>
|
||||
mShutdownSteps;
|
||||
EnumeratedArray<Client::Type, Client::TYPE_MAX, nsCString> mShutdownSteps;
|
||||
LazyInitializedOnce<const TimeStamp> mShutdownStartedAt;
|
||||
|
||||
// Accesses to mQuotaManagerShutdownSteps must be protected by mQuotaMutex.
|
||||
|
@ -131,9 +131,16 @@ ReferrerPolicy ReferrerPolicyFromToken(const nsAString& aContent,
|
||||
}
|
||||
}
|
||||
|
||||
// Return no referrer policy (empty string) if it's not a valid enum value.
|
||||
return StringToEnum<ReferrerPolicy>(lowerContent)
|
||||
.valueOr(ReferrerPolicy::_empty);
|
||||
// Supported tokes - ReferrerPolicyValues, are generated from
|
||||
// ReferrerPolicy.webidl
|
||||
for (uint8_t i = 0; ReferrerPolicyValues::strings[i].value; i++) {
|
||||
if (lowerContent.EqualsASCII(ReferrerPolicyValues::strings[i].value)) {
|
||||
return static_cast<enum ReferrerPolicy>(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Return no referrer policy (empty string) if none of the previous match
|
||||
return ReferrerPolicy::_empty;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -180,6 +187,18 @@ ReferrerPolicy ReferrerInfo::ReferrerPolicyFromHeaderString(
|
||||
return referrerPolicy;
|
||||
}
|
||||
|
||||
// static
|
||||
const char* ReferrerInfo::ReferrerPolicyToString(ReferrerPolicyEnum aPolicy) {
|
||||
uint8_t index = static_cast<uint8_t>(aPolicy);
|
||||
uint8_t referrerPolicyCount = ArrayLength(ReferrerPolicyValues::strings);
|
||||
MOZ_ASSERT(index < referrerPolicyCount);
|
||||
if (index >= referrerPolicyCount) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return ReferrerPolicyValues::strings[index].value;
|
||||
}
|
||||
|
||||
/* static */
|
||||
uint32_t ReferrerInfo::GetUserReferrerSendingPolicy() {
|
||||
return clamped<uint32_t>(
|
||||
@ -812,8 +831,11 @@ bool ReferrerInfo::ShouldIgnoreLessRestrictedPolicies(
|
||||
nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
|
||||
uint32_t idx = static_cast<uint32_t>(aPolicy);
|
||||
|
||||
AutoTArray<nsString, 2> params = {
|
||||
NS_ConvertUTF8toUTF16(GetEnumString(aPolicy)),
|
||||
NS_ConvertUTF8toUTF16(
|
||||
nsDependentCString(ReferrerPolicyValues::strings[idx].value)),
|
||||
NS_ConvertUTF8toUTF16(uri->GetSpecOrDefault())};
|
||||
LogMessageToConsole(aChannel, "ReferrerPolicyDisallowRelaxingMessage",
|
||||
params);
|
||||
@ -1029,7 +1051,7 @@ ReferrerInfo::GetReferrerPolicy(
|
||||
|
||||
NS_IMETHODIMP
|
||||
ReferrerInfo::GetReferrerPolicyString(nsACString& aResult) {
|
||||
aResult.AssignASCII(GetEnumString(mPolicy));
|
||||
aResult.AssignASCII(ReferrerPolicyToString(mPolicy));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1697,9 +1719,7 @@ void ReferrerInfo::RecordTelemetry(nsIHttpChannel* aChannel) {
|
||||
// requests and the rest 9 buckets are for cross-site requests.
|
||||
uint32_t telemetryOffset =
|
||||
IsCrossSiteRequest(aChannel)
|
||||
? UnderlyingValue(
|
||||
MaxContiguousEnumValue<dom::ReferrerPolicy>::value) +
|
||||
1
|
||||
? static_cast<uint32_t>(ReferrerPolicy::EndGuard_)
|
||||
: 0;
|
||||
|
||||
Telemetry::Accumulate(Telemetry::REFERRER_POLICY_COUNT,
|
||||
|
@ -258,6 +258,13 @@ class ReferrerInfo : public nsIReferrerInfo {
|
||||
static ReferrerPolicyEnum ReferrerPolicyFromHeaderString(
|
||||
const nsAString& aContent);
|
||||
|
||||
/*
|
||||
* Helper function to convert ReferrerPolicy enum to string
|
||||
*
|
||||
* @param aPolicy referrer policy to convert.
|
||||
*/
|
||||
static const char* ReferrerPolicyToString(ReferrerPolicyEnum aPolicy);
|
||||
|
||||
/**
|
||||
* Hash function for this object
|
||||
*/
|
||||
|
@ -624,7 +624,8 @@ void RespondWithHandler::ResolvedCallback(JSContext* aCx,
|
||||
|
||||
if (response->Type() == ResponseType::Opaque &&
|
||||
mRequestMode != RequestMode::No_cors) {
|
||||
NS_ConvertASCIItoUTF16 modeString(GetEnumString(mRequestMode));
|
||||
NS_ConvertASCIItoUTF16 modeString(
|
||||
RequestModeValues::GetString(mRequestMode));
|
||||
|
||||
autoCancel.SetCancelMessage("BadOpaqueInterceptionRequestModeWithURL"_ns,
|
||||
mRequestURL, modeString);
|
||||
|
@ -11,7 +11,6 @@
|
||||
// Undo X11/X.h's definition of None
|
||||
#undef None
|
||||
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/ServiceWorkerBinding.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
|
||||
|
||||
@ -19,13 +18,17 @@ namespace IPC {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ServiceWorkerState>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::ServiceWorkerState> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::ServiceWorkerState,
|
||||
mozilla::dom::ServiceWorkerState::Parsed,
|
||||
mozilla::dom::ServiceWorkerState::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ServiceWorkerUpdateViaCache>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<
|
||||
mozilla::dom::ServiceWorkerUpdateViaCache> {};
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::ServiceWorkerUpdateViaCache,
|
||||
mozilla::dom::ServiceWorkerUpdateViaCache::Imports,
|
||||
mozilla::dom::ServiceWorkerUpdateViaCache::EndGuard_> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
|
@ -43,7 +43,7 @@ static_assert(nsIServiceWorkerInfo::STATE_REDUNDANT ==
|
||||
"ServiceWorkerState enumeration value should match state values "
|
||||
"from nsIServiceWorkerInfo.");
|
||||
static_assert(nsIServiceWorkerInfo::STATE_UNKNOWN ==
|
||||
ContiguousEnumSize<ServiceWorkerState>::value,
|
||||
ServiceWorkerStateValues::Count,
|
||||
"ServiceWorkerState enumeration value should match state values "
|
||||
"from nsIServiceWorkerInfo.");
|
||||
|
||||
@ -165,6 +165,8 @@ void ServiceWorkerInfo::UpdateState(ServiceWorkerState aState) {
|
||||
// Any state can directly transition to redundant, but everything else is
|
||||
// ordered.
|
||||
if (aState != ServiceWorkerState::Redundant) {
|
||||
MOZ_ASSERT_IF(State() == ServiceWorkerState::EndGuard_,
|
||||
aState == ServiceWorkerState::Installing);
|
||||
MOZ_ASSERT_IF(State() == ServiceWorkerState::Installing,
|
||||
aState == ServiceWorkerState::Installed);
|
||||
MOZ_ASSERT_IF(State() == ServiceWorkerState::Installed,
|
||||
|
@ -127,7 +127,7 @@ static_assert(
|
||||
static_cast<uint32_t>(RequestRedirect::Manual),
|
||||
"RequestRedirect enumeration value should make Necko Redirect mode value.");
|
||||
static_assert(
|
||||
3 == ContiguousEnumSize<RequestRedirect>::value,
|
||||
3 == RequestRedirectValues::Count,
|
||||
"RequestRedirect enumeration value should make Necko Redirect mode value.");
|
||||
|
||||
static_assert(
|
||||
@ -155,7 +155,7 @@ static_assert(
|
||||
static_cast<uint32_t>(RequestCache::Only_if_cached),
|
||||
"RequestCache enumeration value should match Necko Cache mode value.");
|
||||
static_assert(
|
||||
6 == ContiguousEnumSize<RequestCache>::value,
|
||||
6 == RequestCacheValues::Count,
|
||||
"RequestCache enumeration value should match Necko Cache mode value.");
|
||||
|
||||
static_assert(static_cast<uint16_t>(ServiceWorkerUpdateViaCache::Imports) ==
|
||||
|
@ -1428,7 +1428,8 @@ void FetchEventOp::ResolvedCallback(JSContext* aCx,
|
||||
|
||||
if (response->Type() == ResponseType::Opaque &&
|
||||
requestMode != RequestMode::No_cors) {
|
||||
NS_ConvertASCIItoUTF16 modeString(GetEnumString(requestMode));
|
||||
NS_ConvertASCIItoUTF16 modeString(
|
||||
RequestModeValues::GetString(requestMode));
|
||||
|
||||
nsAutoString requestURL;
|
||||
GetRequestURL(requestURL);
|
||||
|
@ -69,8 +69,8 @@ class IOUtils final {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using PhaseArray = EnumeratedArray<IOUtils::ShutdownPhase, T,
|
||||
size_t(IOUtils::ShutdownPhase::Count)>;
|
||||
using PhaseArray =
|
||||
EnumeratedArray<IOUtils::ShutdownPhase, IOUtils::ShutdownPhase::Count, T>;
|
||||
|
||||
static already_AddRefed<Promise> Read(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
|
@ -241,8 +241,7 @@ class PathUtils::DirectoryCache final {
|
||||
void ResolveWithDirectory(Promise* aPromise, const Directory aRequestedDir);
|
||||
|
||||
template <typename T>
|
||||
using DirectoryArray =
|
||||
EnumeratedArray<Directory, T, size_t(Directory::Count)>;
|
||||
using DirectoryArray = EnumeratedArray<Directory, Directory::Count, T>;
|
||||
|
||||
DirectoryArray<nsString> mDirectories;
|
||||
DirectoryArray<MozPromiseHolder<PopulateDirectoriesPromise>> mPromises;
|
||||
|
@ -122,8 +122,8 @@ already_AddRefed<Promise> XRSystem::IsSessionSupported(XRSessionMode aMode,
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> XRSystem::RequestSession(
|
||||
XRSessionMode aMode, const XRSessionInit& aOptions, CallerType aCallerType,
|
||||
ErrorResult& aRv) {
|
||||
JSContext* aCx, XRSessionMode aMode, const XRSessionInit& aOptions,
|
||||
CallerType aCallerType, ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIGlobalObject> global = GetParentObject();
|
||||
NS_ENSURE_TRUE(global, nullptr);
|
||||
|
||||
@ -166,25 +166,49 @@ already_AddRefed<Promise> XRSystem::RequestSession(
|
||||
requiredReferenceSpaceTypes.AppendElement(XRReferenceSpaceType::Local);
|
||||
}
|
||||
|
||||
BindingCallContext callCx(aCx, "XRSystem.requestSession");
|
||||
|
||||
if (aOptions.mRequiredFeatures.WasPassed()) {
|
||||
for (const nsString& val : aOptions.mRequiredFeatures.Value()) {
|
||||
Maybe<XRReferenceSpaceType> type =
|
||||
StringToEnum<XRReferenceSpaceType>(val);
|
||||
if (type.isNothing()) {
|
||||
promise->MaybeRejectWithNotSupportedError(
|
||||
"A required feature for the XRSession is not available.");
|
||||
return promise.forget();
|
||||
const Sequence<JS::Value>& arr = (aOptions.mRequiredFeatures.Value());
|
||||
for (const JS::Value& val : arr) {
|
||||
if (!val.isNull() && !val.isUndefined()) {
|
||||
bool bFound = false;
|
||||
JS::Rooted<JS::Value> v(aCx, val);
|
||||
int index = 0;
|
||||
if (FindEnumStringIndex<false>(
|
||||
callCx, v, XRReferenceSpaceTypeValues::strings,
|
||||
"XRReferenceSpaceType", "Argument 2 of XR.requestSession",
|
||||
&index)) {
|
||||
if (index >= 0) {
|
||||
requiredReferenceSpaceTypes.AppendElement(
|
||||
static_cast<XRReferenceSpaceType>(index));
|
||||
bFound = true;
|
||||
}
|
||||
}
|
||||
if (!bFound) {
|
||||
promise->MaybeRejectWithNotSupportedError(
|
||||
"A required feature for the XRSession is not available.");
|
||||
return promise.forget();
|
||||
}
|
||||
}
|
||||
requiredReferenceSpaceTypes.AppendElement(type.value());
|
||||
}
|
||||
}
|
||||
|
||||
if (aOptions.mOptionalFeatures.WasPassed()) {
|
||||
for (const nsString& val : aOptions.mOptionalFeatures.Value()) {
|
||||
Maybe<XRReferenceSpaceType> type =
|
||||
StringToEnum<XRReferenceSpaceType>(val);
|
||||
if (type.isSome()) {
|
||||
optionalReferenceSpaceTypes.AppendElement(type.value());
|
||||
const Sequence<JS::Value>& arr = (aOptions.mOptionalFeatures.Value());
|
||||
for (const JS::Value& val : arr) {
|
||||
if (!val.isNull() && !val.isUndefined()) {
|
||||
JS::Rooted<JS::Value> v(aCx, val);
|
||||
int index = 0;
|
||||
if (FindEnumStringIndex<false>(
|
||||
callCx, v, XRReferenceSpaceTypeValues::strings,
|
||||
"XRReferenceSpaceType", "Argument 2 of XR.requestSession",
|
||||
&index)) {
|
||||
if (index >= 0) {
|
||||
optionalReferenceSpaceTypes.AppendElement(
|
||||
static_cast<XRReferenceSpaceType>(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class XRSystem final : public DOMEventTargetHelper,
|
||||
// WebIDL Members
|
||||
already_AddRefed<Promise> IsSessionSupported(XRSessionMode aMode,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<Promise> RequestSession(XRSessionMode aMode,
|
||||
already_AddRefed<Promise> RequestSession(JSContext* aCx, XRSessionMode aMode,
|
||||
const XRSessionInit& aOptions,
|
||||
CallerType aCallerType,
|
||||
ErrorResult& aRv);
|
||||
|
@ -128,6 +128,9 @@ static Maybe<ffi::WGPUFeatures> ToWGPUFeatures(
|
||||
|
||||
case dom::GPUFeatureName::Float32_filterable:
|
||||
return Some(WGPUFeatures_FLOAT32_FILTERABLE);
|
||||
|
||||
case dom::GPUFeatureName::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_CRASH("Bad GPUFeatureName.");
|
||||
}
|
||||
@ -138,11 +141,11 @@ static Maybe<ffi::WGPUFeatures> MakeFeatureBits(
|
||||
for (const auto& feature : aFeatures) {
|
||||
const auto bit = ToWGPUFeatures(feature);
|
||||
if (!bit) {
|
||||
const auto featureStr = dom::GetEnumString(feature);
|
||||
const auto featureStr = dom::GPUFeatureNameValues::GetString(feature);
|
||||
(void)featureStr;
|
||||
NS_WARNING(
|
||||
nsPrintfCString("Requested feature bit for '%s' is not implemented.",
|
||||
featureStr.get())
|
||||
featureStr.data())
|
||||
.get());
|
||||
return Nothing();
|
||||
}
|
||||
@ -166,7 +169,7 @@ Adapter::Adapter(Instance* const aParent, WebGPUChild* const aBridge,
|
||||
auto ret = std::unordered_map<ffi::WGPUFeatures, dom::GPUFeatureName>{};
|
||||
|
||||
for (const auto feature :
|
||||
dom::MakeWebIDLEnumeratedRange<dom::GPUFeatureName>()) {
|
||||
MakeEnumeratedRange(dom::GPUFeatureName::EndGuard_)) {
|
||||
const auto bitForFeature = ToWGPUFeatures(feature);
|
||||
if (!bitForFeature) {
|
||||
// There are some features that don't have bits.
|
||||
@ -360,12 +363,12 @@ already_AddRefed<dom::Promise> Adapter::RequestDevice(
|
||||
for (const auto requested : aDesc.mRequiredFeatures) {
|
||||
const bool supported = mFeatures->Features().count(requested);
|
||||
if (!supported) {
|
||||
const auto fstr = dom::GetEnumString(requested);
|
||||
const auto fstr = dom::GPUFeatureNameValues::GetString(requested);
|
||||
const auto astr = this->LabelOrId();
|
||||
nsPrintfCString msg(
|
||||
"requestDevice: Feature '%s' requested must be supported by "
|
||||
"adapter %s",
|
||||
fstr.get(), astr.get());
|
||||
fstr.data(), astr.get());
|
||||
promise->MaybeRejectWithTypeError(msg);
|
||||
return;
|
||||
}
|
||||
|
@ -321,6 +321,8 @@ already_AddRefed<BindGroupLayout> Device::CreateBindGroupLayout(
|
||||
case dom::GPUTextureSampleType::Depth:
|
||||
data.type = ffi::WGPURawTextureSampleType_Depth;
|
||||
break;
|
||||
case dom::GPUTextureSampleType::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
if (entry.mStorageTexture.WasPassed()) {
|
||||
@ -348,6 +350,8 @@ already_AddRefed<BindGroupLayout> Device::CreateBindGroupLayout(
|
||||
case dom::GPUBufferBindingType::Read_only_storage:
|
||||
e.ty = ffi::WGPURawBindingType_ReadonlyStorageBuffer;
|
||||
break;
|
||||
case dom::GPUBufferBindingType::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE();
|
||||
}
|
||||
e.has_dynamic_offset = entry.mBuffer.Value().mHasDynamicOffset;
|
||||
}
|
||||
@ -389,6 +393,8 @@ already_AddRefed<BindGroupLayout> Device::CreateBindGroupLayout(
|
||||
case dom::GPUSamplerBindingType::Comparison:
|
||||
e.sampler_compare = true;
|
||||
break;
|
||||
case dom::GPUSamplerBindingType::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
entries.AppendElement(e);
|
||||
|
@ -30,6 +30,8 @@ static ffi::WGPULoadOp ConvertLoadOp(const dom::GPULoadOp& aOp) {
|
||||
return ffi::WGPULoadOp_Load;
|
||||
case dom::GPULoadOp::Clear:
|
||||
return ffi::WGPULoadOp_Clear;
|
||||
case dom::GPULoadOp::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_CRASH("bad GPULoadOp");
|
||||
}
|
||||
@ -40,6 +42,8 @@ static ffi::WGPUStoreOp ConvertStoreOp(const dom::GPUStoreOp& aOp) {
|
||||
return ffi::WGPUStoreOp_Store;
|
||||
case dom::GPUStoreOp::Discard:
|
||||
return ffi::WGPUStoreOp_Discard;
|
||||
case dom::GPUStoreOp::EndGuard_:
|
||||
break;
|
||||
}
|
||||
MOZ_CRASH("bad GPUStoreOp");
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "SupportedFeatures.h"
|
||||
#include "Adapter.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/WebGPUBinding.h"
|
||||
|
||||
namespace mozilla::webgpu {
|
||||
@ -18,7 +17,7 @@ SupportedFeatures::SupportedFeatures(Adapter* const aParent)
|
||||
|
||||
void SupportedFeatures::Add(const dom::GPUFeatureName aFeature,
|
||||
ErrorResult& aRv) {
|
||||
const auto u8 = dom::GetEnumString(aFeature);
|
||||
const auto u8 = dom::GPUFeatureNameValues::GetString(aFeature);
|
||||
const auto u16 = NS_ConvertUTF8toUTF16(u8);
|
||||
dom::GPUSupportedFeatures_Binding::SetlikeHelpers::Add(this, u16, aRv);
|
||||
|
||||
|
@ -228,6 +228,8 @@ ffi::WGPUTextureFormat ConvertTextureFormat(
|
||||
case dom::GPUTextureFormat::Depth32float_stencil8:
|
||||
result.tag = ffi::WGPUTextureFormat_Depth32FloatStencil8;
|
||||
break;
|
||||
case dom::GPUTextureFormat::EndGuard_:
|
||||
MOZ_ASSERT_UNREACHABLE();
|
||||
}
|
||||
|
||||
// Clang will check for us that the switch above is exhaustive,
|
||||
|
@ -1452,6 +1452,8 @@ ipc::IPCResult WebGPUParent::RecvDevicePopErrorScope(
|
||||
case dom::GPUErrorFilter::Internal:
|
||||
ret.resultType = PopErrorScopeResultType::InternalError;
|
||||
break;
|
||||
case dom::GPUErrorFilter::EndGuard_:
|
||||
MOZ_CRASH("Bad GPUErrorFilter");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "WebGPUTypes.h"
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "mozilla/dom/WebGPUBinding.h"
|
||||
#include "mozilla/webgpu/ffi/wgpu.h"
|
||||
|
||||
@ -21,9 +20,7 @@ namespace IPC {
|
||||
: public ContiguousEnumSerializer<something, something(0), guard> {}
|
||||
|
||||
#define DEFINE_IPC_SERIALIZER_DOM_ENUM(something) \
|
||||
template <> \
|
||||
struct ParamTraits<something> \
|
||||
: public mozilla::dom::WebIDLEnumSerializer<something> {}
|
||||
DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, something::EndGuard_)
|
||||
#define DEFINE_IPC_SERIALIZER_FFI_ENUM(something) \
|
||||
DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, something##_Sentinel)
|
||||
|
||||
|
@ -27,8 +27,8 @@ enum XRSessionMode {
|
||||
};
|
||||
|
||||
dictionary XRSessionInit {
|
||||
sequence<DOMString> requiredFeatures;
|
||||
sequence<DOMString> optionalFeatures;
|
||||
sequence<any> requiredFeatures;
|
||||
sequence<any> optionalFeatures;
|
||||
};
|
||||
|
||||
enum XRVisibilityState {
|
||||
|
@ -291,8 +291,9 @@ WebTask* WebTaskScheduler::GetNextTask() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (TaskPriority priority : MakeWebIDLEnumeratedRange<TaskPriority>()) {
|
||||
if (auto queues = allQueues.Lookup(UnderlyingValue(priority))) {
|
||||
for (uint32_t priority = static_cast<uint32_t>(TaskPriority::User_blocking);
|
||||
priority < static_cast<uint32_t>(TaskPriority::EndGuard_); ++priority) {
|
||||
if (auto queues = allQueues.Lookup(priority)) {
|
||||
WebTaskQueue* oldestQueue = nullptr;
|
||||
MOZ_ASSERT(!queues.Data().IsEmpty());
|
||||
for (auto& webTaskQueue : queues.Data()) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
#ifndef _mozilla_dom_WorkerIPCUtils_h
|
||||
#define _mozilla_dom_WorkerIPCUtils_h
|
||||
|
||||
#include "mozilla/dom/BindingIPCUtils.h"
|
||||
#include "ipc/EnumSerializer.h"
|
||||
|
||||
// Undo X11/X.h's definition of None
|
||||
#undef None
|
||||
@ -17,7 +17,9 @@ namespace IPC {
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::WorkerType>
|
||||
: public mozilla::dom::WebIDLEnumSerializer<mozilla::dom::WorkerType> {};
|
||||
: public ContiguousEnumSerializer<mozilla::dom::WorkerType,
|
||||
mozilla::dom::WorkerType::Classic,
|
||||
mozilla::dom::WorkerType::EndGuard_> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
|
@ -189,8 +189,8 @@ struct txEXSLTFunctionDescriptor {
|
||||
int32_t mNamespaceID;
|
||||
};
|
||||
|
||||
static EnumeratedArray<txEXSLTType, txEXSLTFunctionDescriptor,
|
||||
size_t(txEXSLTType::_LIMIT)>
|
||||
static EnumeratedArray<txEXSLTType, txEXSLTType::_LIMIT,
|
||||
txEXSLTFunctionDescriptor>
|
||||
descriptTable;
|
||||
|
||||
class txEXSLTFunctionCall : public FunctionCall {
|
||||
|
@ -191,8 +191,8 @@ class Image {
|
||||
virtual ~Image() = default;
|
||||
|
||||
mozilla::EnumeratedArray<mozilla::layers::LayersBackend,
|
||||
UniquePtr<ImageBackendData>,
|
||||
size_t(mozilla::layers::LayersBackend::LAYERS_LAST)>
|
||||
mozilla::layers::LayersBackend::LAYERS_LAST,
|
||||
UniquePtr<ImageBackendData>>
|
||||
mBackendData;
|
||||
|
||||
void* mImplData;
|
||||
|
@ -17,8 +17,9 @@ namespace mozilla::layers {
|
||||
using namespace mozilla::ipc;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
using VideoBridgeTable = EnumeratedArray<VideoBridgeSource, VideoBridgeParent*,
|
||||
size_t(VideoBridgeSource::_Count)>;
|
||||
using VideoBridgeTable =
|
||||
EnumeratedArray<VideoBridgeSource, VideoBridgeSource::_Count,
|
||||
VideoBridgeParent*>;
|
||||
|
||||
static StaticDataMutex<VideoBridgeTable> sVideoBridgeFromProcess(
|
||||
"VideoBridges");
|
||||
|
@ -1010,14 +1010,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
||||
|
||||
// When system-wide font lookup fails for a character, cache it to skip future
|
||||
// searches. This is an array of bitsets, one for each FontVisibility level.
|
||||
mozilla::EnumeratedArray<FontVisibility, gfxSparseBitSet,
|
||||
size_t(FontVisibility::Count)>
|
||||
mozilla::EnumeratedArray<FontVisibility, FontVisibility::Count,
|
||||
gfxSparseBitSet>
|
||||
mCodepointsWithNoFonts MOZ_GUARDED_BY(mLock);
|
||||
|
||||
// the family to use for U+FFFD fallback, to avoid expensive search every time
|
||||
// on pages with lots of problems
|
||||
mozilla::EnumeratedArray<FontVisibility, FontFamily,
|
||||
size_t(FontVisibility::Count)>
|
||||
mozilla::EnumeratedArray<FontVisibility, FontVisibility::Count, FontFamily>
|
||||
mReplacementCharFallbackFamily MOZ_GUARDED_BY(mLock);
|
||||
|
||||
// Sorted array of lowercased family names; use ContainsSorted to test
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "mozilla/ProcInfo.h"
|
||||
#include "mozilla/ipc/UtilityAudioDecoder.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/ipc/UtilityProcessChild.h"
|
||||
|
||||
namespace mozilla::ipc {
|
||||
@ -35,7 +34,8 @@ UtilityActorName GetAudioActorName(const SandboxingKind aSandbox) {
|
||||
nsCString GetChildAudioActorName() {
|
||||
RefPtr<ipc::UtilityProcessChild> s = ipc::UtilityProcessChild::Get();
|
||||
MOZ_ASSERT(s, "Has UtilityProcessChild");
|
||||
return dom::GetEnumString(GetAudioActorName(s->mSandbox));
|
||||
return nsCString(dom::WebIDLUtilityActorNameValues::GetString(
|
||||
GetAudioActorName(s->mSandbox)));
|
||||
}
|
||||
|
||||
} // namespace mozilla::ipc
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user