зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1640839 - Make WebIDL enum helper function to convert to string return an actual string. r=mccr8,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D201337
This commit is contained in:
Родитель
675a8f65a9
Коммит
6d4c6fde36
|
@ -2077,7 +2077,7 @@ void ChromeUtils::GetAllPossibleUtilityActorNames(GlobalObject& aGlobal,
|
||||||
aNames.Clear();
|
aNames.Clear();
|
||||||
for (size_t i = 0; i < WebIDLUtilityActorNameValues::Count; ++i) {
|
for (size_t i = 0; i < WebIDLUtilityActorNameValues::Count; ++i) {
|
||||||
auto idlName = static_cast<UtilityActorName>(i);
|
auto idlName = static_cast<UtilityActorName>(i);
|
||||||
aNames.AppendElement(WebIDLUtilityActorNameValues::GetString(idlName));
|
aNames.AppendElement(GetEnumString(idlName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,12 +181,10 @@ already_AddRefed<Document> DOMParser::ParseFromStream(nsIInputStream* aStream,
|
||||||
|
|
||||||
// Create a fake channel
|
// Create a fake channel
|
||||||
nsCOMPtr<nsIChannel> parserChannel;
|
nsCOMPtr<nsIChannel> parserChannel;
|
||||||
NS_NewInputStreamChannel(
|
NS_NewInputStreamChannel(getter_AddRefs(parserChannel), mDocumentURI,
|
||||||
getter_AddRefs(parserChannel), mDocumentURI,
|
nullptr, // aStream
|
||||||
nullptr, // aStream
|
mPrincipal, nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
|
||||||
mPrincipal, nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
|
nsIContentPolicy::TYPE_OTHER, GetEnumString(aType));
|
||||||
nsIContentPolicy::TYPE_OTHER,
|
|
||||||
nsDependentCSubstring(SupportedTypeValues::GetString(aType)));
|
|
||||||
if (NS_WARN_IF(!parserChannel)) {
|
if (NS_WARN_IF(!parserChannel)) {
|
||||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -131,11 +131,6 @@ template <class T>
|
||||||
constexpr bool is_dom_union_with_typedarray_members =
|
constexpr bool is_dom_union_with_typedarray_members =
|
||||||
std::is_base_of_v<UnionWithTypedArraysBase, T>;
|
std::is_base_of_v<UnionWithTypedArraysBase, T>;
|
||||||
|
|
||||||
struct EnumEntry {
|
|
||||||
const char* value;
|
|
||||||
size_t length;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class CallerType : uint32_t;
|
enum class CallerType : uint32_t;
|
||||||
|
|
||||||
class MOZ_STACK_CLASS GlobalObject {
|
class MOZ_STACK_CLASS GlobalObject {
|
||||||
|
@ -562,6 +557,13 @@ JS::Handle<JSObject*> GetPerInterfaceObjectHandle(
|
||||||
JSContext* aCx, size_t aSlotId, CreateInterfaceObjectsMethod aCreator,
|
JSContext* aCx, size_t aSlotId, CreateInterfaceObjectsMethod aCreator,
|
||||||
bool aDefineOnGlobal);
|
bool aDefineOnGlobal);
|
||||||
|
|
||||||
|
namespace binding_detail {
|
||||||
|
|
||||||
|
template <typename Enum>
|
||||||
|
struct EnumStrings;
|
||||||
|
|
||||||
|
} // namespace binding_detail
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|
|
@ -1345,24 +1345,23 @@ inline bool EnumValueNotFound<true>(BindingCallContext& cx,
|
||||||
|
|
||||||
template <typename CharT>
|
template <typename CharT>
|
||||||
inline int FindEnumStringIndexImpl(const CharT* chars, size_t length,
|
inline int FindEnumStringIndexImpl(const CharT* chars, size_t length,
|
||||||
const EnumEntry* values) {
|
const Span<const nsLiteralCString>& values) {
|
||||||
int i = 0;
|
for (size_t i = 0; i < values.Length(); ++i) {
|
||||||
for (const EnumEntry* value = values; value->value; ++value, ++i) {
|
const nsLiteralCString& value = values[i];
|
||||||
if (length != value->length) {
|
if (length != value.Length()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool equal = true;
|
bool equal = true;
|
||||||
const char* val = value->value;
|
|
||||||
for (size_t j = 0; j != length; ++j) {
|
for (size_t j = 0; j != length; ++j) {
|
||||||
if (unsigned(val[j]) != unsigned(chars[j])) {
|
if (unsigned(value.CharAt(j)) != unsigned(chars[j])) {
|
||||||
equal = false;
|
equal = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equal) {
|
if (equal) {
|
||||||
return i;
|
return (int)i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1371,8 +1370,9 @@ inline int FindEnumStringIndexImpl(const CharT* chars, size_t length,
|
||||||
|
|
||||||
template <bool InvalidValueFatal>
|
template <bool InvalidValueFatal>
|
||||||
inline bool FindEnumStringIndex(BindingCallContext& cx, JS::Handle<JS::Value> v,
|
inline bool FindEnumStringIndex(BindingCallContext& cx, JS::Handle<JS::Value> v,
|
||||||
const EnumEntry* values, const char* type,
|
const Span<const nsLiteralCString>& values,
|
||||||
const char* sourceDescription, int* index) {
|
const char* type, const char* sourceDescription,
|
||||||
|
int* index) {
|
||||||
// JS_StringEqualsAscii is slow as molasses, so don't use it here.
|
// JS_StringEqualsAscii is slow as molasses, so don't use it here.
|
||||||
JS::Rooted<JSString*> str(cx, JS::ToString(cx, v));
|
JS::Rooted<JSString*> str(cx, JS::ToString(cx, v));
|
||||||
if (!str) {
|
if (!str) {
|
||||||
|
@ -1405,6 +1405,18 @@ inline bool FindEnumStringIndex(BindingCallContext& cx, JS::Handle<JS::Value> v,
|
||||||
return EnumValueNotFound<InvalidValueFatal>(cx, str, type, sourceDescription);
|
return EnumValueNotFound<InvalidValueFatal>(cx, str, type, sourceDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Enum>
|
||||||
|
inline const nsCString& GetEnumString(Enum stringId) {
|
||||||
|
if (stringId == Enum::EndGuard_) {
|
||||||
|
return EmptyCString();
|
||||||
|
}
|
||||||
|
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)];
|
||||||
|
}
|
||||||
|
|
||||||
inline nsWrapperCache* GetWrapperCache(const ParentObject& aParentObject) {
|
inline nsWrapperCache* GetWrapperCache(const ParentObject& aParentObject) {
|
||||||
return aParentObject.mWrapperCache;
|
return aParentObject.mWrapperCache;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ LEGACYCALLER_HOOK_NAME = "_legacycaller"
|
||||||
RESOLVE_HOOK_NAME = "_resolve"
|
RESOLVE_HOOK_NAME = "_resolve"
|
||||||
MAY_RESOLVE_HOOK_NAME = "_mayResolve"
|
MAY_RESOLVE_HOOK_NAME = "_mayResolve"
|
||||||
NEW_ENUMERATE_HOOK_NAME = "_newEnumerate"
|
NEW_ENUMERATE_HOOK_NAME = "_newEnumerate"
|
||||||
ENUM_ENTRY_VARIABLE_NAME = "strings"
|
|
||||||
INSTANCE_RESERVED_SLOTS = 1
|
INSTANCE_RESERVED_SLOTS = 1
|
||||||
|
|
||||||
# This size is arbitrary. It is a power of 2 to make using it as a modulo
|
# This size is arbitrary. It is a power of 2 to make using it as a modulo
|
||||||
|
@ -7046,7 +7045,10 @@ def getJSToNativeConversionInfo(
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
if (!FindEnumStringIndex<${invalidEnumValueFatal}>(cx, $${val}, ${values}, "${enumtype}", "${sourceDescription}", &index)) {
|
if (!FindEnumStringIndex<${invalidEnumValueFatal}>(cx, $${val},
|
||||||
|
binding_detail::EnumStrings<${enumtype}>::Values,
|
||||||
|
"${enumtype}", "${sourceDescription}",
|
||||||
|
&index)) {
|
||||||
$*{exceptionCode}
|
$*{exceptionCode}
|
||||||
}
|
}
|
||||||
$*{handleInvalidEnumValueCode}
|
$*{handleInvalidEnumValueCode}
|
||||||
|
@ -7054,7 +7056,6 @@ def getJSToNativeConversionInfo(
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
enumtype=enumName,
|
enumtype=enumName,
|
||||||
values=enumName + "Values::" + ENUM_ENTRY_VARIABLE_NAME,
|
|
||||||
invalidEnumValueFatal=toStringBool(invalidEnumValueFatal),
|
invalidEnumValueFatal=toStringBool(invalidEnumValueFatal),
|
||||||
handleInvalidEnumValueCode=handleInvalidEnumValueCode,
|
handleInvalidEnumValueCode=handleInvalidEnumValueCode,
|
||||||
exceptionCode=exceptionCode,
|
exceptionCode=exceptionCode,
|
||||||
|
@ -12343,7 +12344,7 @@ def getEnumValueName(value):
|
||||||
class CGEnumToJSValue(CGAbstractMethod):
|
class CGEnumToJSValue(CGAbstractMethod):
|
||||||
def __init__(self, enum):
|
def __init__(self, enum):
|
||||||
enumType = enum.identifier.name
|
enumType = enum.identifier.name
|
||||||
self.stringsArray = enumType + "Values::" + ENUM_ENTRY_VARIABLE_NAME
|
self.stringsArray = "binding_detail::EnumStrings<" + enumType + ">::Values"
|
||||||
CGAbstractMethod.__init__(
|
CGAbstractMethod.__init__(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
|
@ -12361,8 +12362,8 @@ class CGEnumToJSValue(CGAbstractMethod):
|
||||||
"""
|
"""
|
||||||
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(${strings}));
|
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(${strings}));
|
||||||
JSString* resultStr =
|
JSString* resultStr =
|
||||||
JS_NewStringCopyN(aCx, ${strings}[uint32_t(aArgument)].value,
|
JS_NewStringCopyN(aCx, ${strings}[uint32_t(aArgument)].BeginReading(),
|
||||||
${strings}[uint32_t(aArgument)].length);
|
${strings}[uint32_t(aArgument)].Length());
|
||||||
if (!resultStr) {
|
if (!resultStr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -12379,48 +12380,54 @@ class CGEnum(CGThing):
|
||||||
self.enum = enum
|
self.enum = enum
|
||||||
entryDecl = fill(
|
entryDecl = fill(
|
||||||
"""
|
"""
|
||||||
extern const EnumEntry ${entry_array}[${entry_count}];
|
static constexpr size_t Count = ${count};
|
||||||
|
|
||||||
static constexpr size_t Count = ${real_entry_count};
|
static_assert(mozilla::ArrayLength(binding_detail::EnumStrings<${name}>::Values) == 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");
|
"Mismatch between enum strings and enum count");
|
||||||
|
|
||||||
static_assert(static_cast<size_t>(${name}::EndGuard_) == Count,
|
static_assert(static_cast<size_t>(${name}::EndGuard_) == Count,
|
||||||
"Mismatch between enum value and enum 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,
|
count=self.nEnumStrings(),
|
||||||
entry_count=self.nEnumStrings(),
|
|
||||||
# -1 because nEnumStrings() includes a string for EndGuard_
|
|
||||||
real_entry_count=self.nEnumStrings() - 1,
|
|
||||||
name=self.enum.identifier.name,
|
name=self.enum.identifier.name,
|
||||||
type=CGEnum.underlyingType(enum),
|
type=CGEnum.underlyingType(enum),
|
||||||
)
|
)
|
||||||
strings = CGNamespace(
|
strings = CGList(
|
||||||
self.stringsNamespace(),
|
[
|
||||||
CGGeneric(
|
CGNamespace(
|
||||||
declare=entryDecl,
|
"binding_detail",
|
||||||
define=fill(
|
CGGeneric(
|
||||||
"""
|
declare=fill(
|
||||||
extern const EnumEntry ${name}[${count}] = {
|
"""
|
||||||
$*{entries}
|
template <> struct EnumStrings<${name}> {
|
||||||
{ nullptr, 0 }
|
static const nsLiteralCString Values[${count}];
|
||||||
};
|
};
|
||||||
""",
|
""",
|
||||||
name=ENUM_ENTRY_VARIABLE_NAME,
|
name=self.enum.identifier.name,
|
||||||
count=self.nEnumStrings(),
|
count=self.nEnumStrings(),
|
||||||
entries="".join(
|
),
|
||||||
'{"%s", %d},\n' % (val, len(val)) for val in self.enum.values()
|
define=fill(
|
||||||
|
"""
|
||||||
|
const nsLiteralCString EnumStrings<${name}>::Values[${count}] = {
|
||||||
|
$*{entries}
|
||||||
|
};
|
||||||
|
""",
|
||||||
|
name=self.enum.identifier.name,
|
||||||
|
count=self.nEnumStrings(),
|
||||||
|
entries="".join(
|
||||||
|
'"%s"_ns,\n' % val for val in self.enum.values()
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
CGNamespace(
|
||||||
|
self.stringsNamespace(),
|
||||||
|
CGGeneric(
|
||||||
|
declare=entryDecl,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
"\n",
|
||||||
)
|
)
|
||||||
toJSValue = CGEnumToJSValue(enum)
|
toJSValue = CGEnumToJSValue(enum)
|
||||||
self.cgThings = CGList([strings, toJSValue], "\n")
|
self.cgThings = CGList([strings, toJSValue], "\n")
|
||||||
|
@ -12429,7 +12436,7 @@ class CGEnum(CGThing):
|
||||||
return self.enum.identifier.name + "Values"
|
return self.enum.identifier.name + "Values"
|
||||||
|
|
||||||
def nEnumStrings(self):
|
def nEnumStrings(self):
|
||||||
return len(self.enum.values()) + 1
|
return len(self.enum.values())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def underlyingType(enum):
|
def underlyingType(enum):
|
||||||
|
|
|
@ -81,13 +81,12 @@ static bool IsValidPutResponseStatus(Response& aResponse,
|
||||||
ErrorResult& aRv) {
|
ErrorResult& aRv) {
|
||||||
if ((aPolicy == PutStatusPolicy::RequireOK && !aResponse.Ok()) ||
|
if ((aPolicy == PutStatusPolicy::RequireOK && !aResponse.Ok()) ||
|
||||||
aResponse.Status() == 206) {
|
aResponse.Status() == 206) {
|
||||||
nsCString type(ResponseTypeValues::GetString(aResponse.Type()));
|
|
||||||
|
|
||||||
nsAutoString url;
|
nsAutoString url;
|
||||||
aResponse.GetUrl(url);
|
aResponse.GetUrl(url);
|
||||||
|
|
||||||
aRv.ThrowTypeError<MSG_CACHE_ADD_FAILED_RESPONSE>(
|
aRv.ThrowTypeError<MSG_CACHE_ADD_FAILED_RESPONSE>(
|
||||||
type, IntToCString(aResponse.Status()), NS_ConvertUTF16toUTF8(url));
|
GetEnumString(aResponse.Type()), IntToCString(aResponse.Status()),
|
||||||
|
NS_ConvertUTF16toUTF8(url));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,9 @@ ConsoleLogLevel PrefToValue(const nsACString& aPref,
|
||||||
return aLevel;
|
return aLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = FindEnumStringIndexImpl(value.get(), value.Length(),
|
int index = FindEnumStringIndexImpl(
|
||||||
ConsoleLogLevelValues::strings);
|
value.get(), value.Length(),
|
||||||
|
binding_detail::EnumStrings<ConsoleLogLevel>::Values);
|
||||||
if (NS_WARN_IF(index < 0)) {
|
if (NS_WARN_IF(index < 0)) {
|
||||||
nsString message;
|
nsString message;
|
||||||
message.AssignLiteral("Invalid Console.maxLogLevelPref value: ");
|
message.AssignLiteral("Invalid Console.maxLogLevelPref value: ");
|
||||||
|
|
|
@ -894,10 +894,7 @@ which becomes the value `_empty`.
|
||||||
|
|
||||||
For a Web IDL enum named `MyEnum`, the C++ enum is named `MyEnum` and
|
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
|
placed in the `mozilla::dom` namespace, while the values are placed in
|
||||||
the `mozilla::dom::MyEnum` namespace. There is also a
|
the `mozilla::dom::MyEnum` namespace.
|
||||||
`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
|
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
|
unsigned integer type that can hold all the values. In practice, this
|
||||||
|
@ -924,12 +921,14 @@ enum class MyEnum : uint8_t {
|
||||||
_empty,
|
_empty,
|
||||||
Another
|
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.
|
||||||
|
|
||||||
#### Callback function types
|
#### Callback function types
|
||||||
|
|
||||||
Callback functions are represented as an object, inheriting from
|
Callback functions are represented as an object, inheriting from
|
||||||
|
|
|
@ -493,8 +493,8 @@ SafeRefPtr<Request> Request::Constructor(nsIGlobalObject* aGlobal,
|
||||||
if (cache != RequestCache::EndGuard_) {
|
if (cache != RequestCache::EndGuard_) {
|
||||||
if (cache == RequestCache::Only_if_cached &&
|
if (cache == RequestCache::Only_if_cached &&
|
||||||
request->Mode() != RequestMode::Same_origin) {
|
request->Mode() != RequestMode::Same_origin) {
|
||||||
nsCString modeString(RequestModeValues::GetString(request->Mode()));
|
aRv.ThrowTypeError<MSG_ONLY_IF_CACHED_WITHOUT_SAME_ORIGIN>(
|
||||||
aRv.ThrowTypeError<MSG_ONLY_IF_CACHED_WITHOUT_SAME_ORIGIN>(modeString);
|
GetEnumString(request->Mode()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
request->SetCacheMode(cache);
|
request->SetCacheMode(cache);
|
||||||
|
|
|
@ -1269,25 +1269,24 @@ bool nsGenericHTMLElement::ParseImageAttribute(nsAtom* aAttribute,
|
||||||
bool nsGenericHTMLElement::ParseReferrerAttribute(const nsAString& aString,
|
bool nsGenericHTMLElement::ParseReferrerAttribute(const nsAString& aString,
|
||||||
nsAttrValue& aResult) {
|
nsAttrValue& aResult) {
|
||||||
using mozilla::dom::ReferrerInfo;
|
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[] = {
|
static const nsAttrValue::EnumTable kReferrerPolicyTable[] = {
|
||||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::No_referrer),
|
{GetEnumString(ReferrerPolicy::No_referrer).get(),
|
||||||
static_cast<int16_t>(ReferrerPolicy::No_referrer)},
|
static_cast<int16_t>(ReferrerPolicy::No_referrer)},
|
||||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Origin),
|
{GetEnumString(ReferrerPolicy::Origin).get(),
|
||||||
static_cast<int16_t>(ReferrerPolicy::Origin)},
|
static_cast<int16_t>(ReferrerPolicy::Origin)},
|
||||||
{ReferrerInfo::ReferrerPolicyToString(
|
{GetEnumString(ReferrerPolicy::Origin_when_cross_origin).get(),
|
||||||
ReferrerPolicy::Origin_when_cross_origin),
|
|
||||||
static_cast<int16_t>(ReferrerPolicy::Origin_when_cross_origin)},
|
static_cast<int16_t>(ReferrerPolicy::Origin_when_cross_origin)},
|
||||||
{ReferrerInfo::ReferrerPolicyToString(
|
{GetEnumString(ReferrerPolicy::No_referrer_when_downgrade).get(),
|
||||||
ReferrerPolicy::No_referrer_when_downgrade),
|
|
||||||
static_cast<int16_t>(ReferrerPolicy::No_referrer_when_downgrade)},
|
static_cast<int16_t>(ReferrerPolicy::No_referrer_when_downgrade)},
|
||||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Unsafe_url),
|
{GetEnumString(ReferrerPolicy::Unsafe_url).get(),
|
||||||
static_cast<int16_t>(ReferrerPolicy::Unsafe_url)},
|
static_cast<int16_t>(ReferrerPolicy::Unsafe_url)},
|
||||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Strict_origin),
|
{GetEnumString(ReferrerPolicy::Strict_origin).get(),
|
||||||
static_cast<int16_t>(ReferrerPolicy::Strict_origin)},
|
static_cast<int16_t>(ReferrerPolicy::Strict_origin)},
|
||||||
{ReferrerInfo::ReferrerPolicyToString(ReferrerPolicy::Same_origin),
|
{GetEnumString(ReferrerPolicy::Same_origin).get(),
|
||||||
static_cast<int16_t>(ReferrerPolicy::Same_origin)},
|
static_cast<int16_t>(ReferrerPolicy::Same_origin)},
|
||||||
{ReferrerInfo::ReferrerPolicyToString(
|
{GetEnumString(ReferrerPolicy::Strict_origin_when_cross_origin).get(),
|
||||||
ReferrerPolicy::Strict_origin_when_cross_origin),
|
|
||||||
static_cast<int16_t>(ReferrerPolicy::Strict_origin_when_cross_origin)},
|
static_cast<int16_t>(ReferrerPolicy::Strict_origin_when_cross_origin)},
|
||||||
{nullptr, ReferrerPolicy::_empty}};
|
{nullptr, ReferrerPolicy::_empty}};
|
||||||
return aResult.ParseEnumValue(aString, kReferrerPolicyTable, false);
|
return aResult.ParseEnumValue(aString, kReferrerPolicyTable, false);
|
||||||
|
|
|
@ -550,7 +550,7 @@ already_AddRefed<Promise> MediaDevices::GetDisplayMedia(
|
||||||
// for us.
|
// for us.
|
||||||
vc.mMediaSource.Reset();
|
vc.mMediaSource.Reset();
|
||||||
vc.mMediaSource.Construct().AssignASCII(
|
vc.mMediaSource.Construct().AssignASCII(
|
||||||
dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Screen));
|
dom::GetEnumString(MediaSourceEnum::Screen));
|
||||||
|
|
||||||
RefPtr<MediaDevices> self(this);
|
RefPtr<MediaDevices> self(this);
|
||||||
MediaManager::Get()
|
MediaManager::Get()
|
||||||
|
|
|
@ -872,8 +872,7 @@ MediaDevice::MediaDevice(MediaEngine* aEngine, MediaSourceEnum aMediaSource,
|
||||||
mCanRequestOsLevelPrompt(canRequestOsLevelPrompt == OsPromptable::Yes),
|
mCanRequestOsLevelPrompt(canRequestOsLevelPrompt == OsPromptable::Yes),
|
||||||
mIsFake(mEngine->IsFake()),
|
mIsFake(mEngine->IsFake()),
|
||||||
mIsPlaceholder(aIsPlaceholder == IsPlaceholder::Yes),
|
mIsPlaceholder(aIsPlaceholder == IsPlaceholder::Yes),
|
||||||
mType(
|
mType(NS_ConvertASCIItoUTF16(dom::GetEnumString(mKind))),
|
||||||
NS_ConvertASCIItoUTF16(dom::MediaDeviceKindValues::GetString(mKind))),
|
|
||||||
mRawID(aRawID),
|
mRawID(aRawID),
|
||||||
mRawGroupID(aRawGroupID),
|
mRawGroupID(aRawGroupID),
|
||||||
mRawName(aRawName) {
|
mRawName(aRawName) {
|
||||||
|
@ -895,8 +894,7 @@ MediaDevice::MediaDevice(MediaEngine* aEngine,
|
||||||
mCanRequestOsLevelPrompt(false),
|
mCanRequestOsLevelPrompt(false),
|
||||||
mIsFake(false),
|
mIsFake(false),
|
||||||
mIsPlaceholder(false),
|
mIsPlaceholder(false),
|
||||||
mType(
|
mType(NS_ConvertASCIItoUTF16(dom::GetEnumString(mKind))),
|
||||||
NS_ConvertASCIItoUTF16(dom::MediaDeviceKindValues::GetString(mKind))),
|
|
||||||
mRawID(aRawID),
|
mRawID(aRawID),
|
||||||
mRawGroupID(mAudioDeviceInfo->GroupID()),
|
mRawGroupID(mAudioDeviceInfo->GroupID()),
|
||||||
mRawName(mAudioDeviceInfo->Name()) {}
|
mRawName(mAudioDeviceInfo->Name()) {}
|
||||||
|
@ -1064,8 +1062,7 @@ LocalMediaDevice::GetMediaSource(nsAString& aMediaSource) {
|
||||||
if (Kind() == MediaDeviceKind::Audiooutput) {
|
if (Kind() == MediaDeviceKind::Audiooutput) {
|
||||||
aMediaSource.Truncate();
|
aMediaSource.Truncate();
|
||||||
} else {
|
} else {
|
||||||
aMediaSource.AssignASCII(
|
aMediaSource.AssignASCII(dom::GetEnumString(GetMediaSource()));
|
||||||
dom::MediaSourceEnumValues::GetString(GetMediaSource()));
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -2747,10 +2744,11 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
||||||
auto& vc = c.mVideo.GetAsMediaTrackConstraints();
|
auto& vc = c.mVideo.GetAsMediaTrackConstraints();
|
||||||
if (!vc.mMediaSource.WasPassed()) {
|
if (!vc.mMediaSource.WasPassed()) {
|
||||||
vc.mMediaSource.Construct().AssignASCII(
|
vc.mMediaSource.Construct().AssignASCII(
|
||||||
dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Camera));
|
dom::GetEnumString(MediaSourceEnum::Camera));
|
||||||
}
|
}
|
||||||
videoType = StringToEnum(dom::MediaSourceEnumValues::strings,
|
videoType = StringToEnum(
|
||||||
vc.mMediaSource.Value(), MediaSourceEnum::Other);
|
dom::binding_detail::EnumStrings<dom::MediaSourceEnum>::Values,
|
||||||
|
vc.mMediaSource.Value(), MediaSourceEnum::Other);
|
||||||
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
|
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
|
||||||
(uint32_t)videoType);
|
(uint32_t)videoType);
|
||||||
switch (videoType) {
|
switch (videoType) {
|
||||||
|
@ -2815,8 +2813,7 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
||||||
if (videoType == MediaSourceEnum::Screen ||
|
if (videoType == MediaSourceEnum::Screen ||
|
||||||
videoType == MediaSourceEnum::Browser) {
|
videoType == MediaSourceEnum::Browser) {
|
||||||
videoType = MediaSourceEnum::Window;
|
videoType = MediaSourceEnum::Window;
|
||||||
vc.mMediaSource.Value().AssignASCII(
|
vc.mMediaSource.Value().AssignASCII(dom::GetEnumString(videoType));
|
||||||
dom::MediaSourceEnumValues::GetString(videoType));
|
|
||||||
}
|
}
|
||||||
// only allow privileged content to set the window id
|
// only allow privileged content to set the window id
|
||||||
if (vc.mBrowserWindow.WasPassed()) {
|
if (vc.mBrowserWindow.WasPassed()) {
|
||||||
|
@ -2840,10 +2837,11 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
||||||
auto& ac = c.mAudio.GetAsMediaTrackConstraints();
|
auto& ac = c.mAudio.GetAsMediaTrackConstraints();
|
||||||
if (!ac.mMediaSource.WasPassed()) {
|
if (!ac.mMediaSource.WasPassed()) {
|
||||||
ac.mMediaSource.Construct(NS_ConvertASCIItoUTF16(
|
ac.mMediaSource.Construct(NS_ConvertASCIItoUTF16(
|
||||||
dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Microphone)));
|
dom::GetEnumString(MediaSourceEnum::Microphone)));
|
||||||
}
|
}
|
||||||
audioType = StringToEnum(dom::MediaSourceEnumValues::strings,
|
audioType = StringToEnum(
|
||||||
ac.mMediaSource.Value(), MediaSourceEnum::Other);
|
dom::binding_detail::EnumStrings<dom::MediaSourceEnum>::Values,
|
||||||
|
ac.mMediaSource.Value(), MediaSourceEnum::Other);
|
||||||
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
|
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
|
||||||
(uint32_t)audioType);
|
(uint32_t)audioType);
|
||||||
|
|
||||||
|
@ -4004,8 +4002,7 @@ void DeviceListener::Activate(RefPtr<LocalMediaDevice> aDevice,
|
||||||
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
|
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
|
||||||
|
|
||||||
LOG("DeviceListener %p activating %s device %p", this,
|
LOG("DeviceListener %p activating %s device %p", this,
|
||||||
nsCString(dom::MediaDeviceKindValues::GetString(aDevice->Kind())).get(),
|
dom::GetEnumString(aDevice->Kind()).get(), aDevice.get());
|
||||||
aDevice.get());
|
|
||||||
|
|
||||||
MOZ_ASSERT(!mStopped, "Cannot activate stopped device listener");
|
MOZ_ASSERT(!mStopped, "Cannot activate stopped device listener");
|
||||||
MOZ_ASSERT(!Activated(), "Already activated");
|
MOZ_ASSERT(!Activated(), "Already activated");
|
||||||
|
@ -4061,18 +4058,15 @@ DeviceListener::InitializeAsync() {
|
||||||
}
|
}
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
nsCString log;
|
nsCString log;
|
||||||
log.AppendPrintf(
|
log.AppendPrintf("Starting %s failed",
|
||||||
"Starting %s failed",
|
dom::GetEnumString(kind).get());
|
||||||
nsCString(dom::MediaDeviceKindValues::GetString(kind))
|
|
||||||
.get());
|
|
||||||
aHolder.Reject(
|
aHolder.Reject(
|
||||||
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError,
|
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError,
|
||||||
std::move(log)),
|
std::move(log)),
|
||||||
__func__);
|
__func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG("started %s device %p",
|
LOG("started %s device %p", dom::GetEnumString(kind).get(),
|
||||||
nsCString(dom::MediaDeviceKindValues::GetString(kind)).get(),
|
|
||||||
device.get());
|
device.get());
|
||||||
aHolder.Resolve(true, __func__);
|
aHolder.Resolve(true, __func__);
|
||||||
})
|
})
|
||||||
|
@ -4180,9 +4174,7 @@ auto DeviceListener::UpdateDevice(bool aOn) -> RefPtr<DeviceOperationPromise> {
|
||||||
}
|
}
|
||||||
LOG("DeviceListener %p turning %s %s input device %s", this,
|
LOG("DeviceListener %p turning %s %s input device %s", this,
|
||||||
aOn ? "on" : "off",
|
aOn ? "on" : "off",
|
||||||
nsCString(
|
dom::GetEnumString(GetDevice()->Kind()).get(),
|
||||||
dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
|
||||||
.get(),
|
|
||||||
NS_SUCCEEDED(aResult) ? "succeeded" : "failed");
|
NS_SUCCEEDED(aResult) ? "succeeded" : "failed");
|
||||||
|
|
||||||
if (NS_FAILED(aResult) && aResult != NS_ERROR_ABORT) {
|
if (NS_FAILED(aResult) && aResult != NS_ERROR_ABORT) {
|
||||||
|
@ -4215,8 +4207,7 @@ void DeviceListener::SetDeviceEnabled(bool aEnable) {
|
||||||
|
|
||||||
LOG("DeviceListener %p %s %s device", this,
|
LOG("DeviceListener %p %s %s device", this,
|
||||||
aEnable ? "enabling" : "disabling",
|
aEnable ? "enabling" : "disabling",
|
||||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||||
.get());
|
|
||||||
|
|
||||||
state.mTrackEnabled = aEnable;
|
state.mTrackEnabled = aEnable;
|
||||||
|
|
||||||
|
@ -4272,9 +4263,7 @@ void DeviceListener::SetDeviceEnabled(bool aEnable) {
|
||||||
|
|
||||||
LOG("DeviceListener %p %s %s device - starting device operation",
|
LOG("DeviceListener %p %s %s device - starting device operation",
|
||||||
this, aEnable ? "enabling" : "disabling",
|
this, aEnable ? "enabling" : "disabling",
|
||||||
nsCString(
|
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||||
dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
|
||||||
.get());
|
|
||||||
|
|
||||||
if (state.mStopped) {
|
if (state.mStopped) {
|
||||||
// Source was stopped between timer resolving and this runnable.
|
// Source was stopped between timer resolving and this runnable.
|
||||||
|
@ -4343,8 +4332,7 @@ void DeviceListener::SetDeviceMuted(bool aMute) {
|
||||||
DeviceState& state = *mDeviceState;
|
DeviceState& state = *mDeviceState;
|
||||||
|
|
||||||
LOG("DeviceListener %p %s %s device", this, aMute ? "muting" : "unmuting",
|
LOG("DeviceListener %p %s %s device", this, aMute ? "muting" : "unmuting",
|
||||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||||
.get());
|
|
||||||
|
|
||||||
if (state.mStopped) {
|
if (state.mStopped) {
|
||||||
// Device terminally stopped. Updating device state is pointless.
|
// Device terminally stopped. Updating device state is pointless.
|
||||||
|
@ -4358,8 +4346,7 @@ void DeviceListener::SetDeviceMuted(bool aMute) {
|
||||||
|
|
||||||
LOG("DeviceListener %p %s %s device - starting device operation", this,
|
LOG("DeviceListener %p %s %s device - starting device operation", this,
|
||||||
aMute ? "muting" : "unmuting",
|
aMute ? "muting" : "unmuting",
|
||||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
dom::GetEnumString(GetDevice()->Kind()).get());
|
||||||
.get());
|
|
||||||
|
|
||||||
state.mDeviceMuted = aMute;
|
state.mDeviceMuted = aMute;
|
||||||
|
|
||||||
|
@ -4465,9 +4452,7 @@ RefPtr<DeviceListener::DeviceListenerPromise> DeviceListener::ApplyConstraints(
|
||||||
|
|
||||||
if (mStopped || mDeviceState->mStopped) {
|
if (mStopped || mDeviceState->mStopped) {
|
||||||
LOG("DeviceListener %p %s device applyConstraints, but device is stopped",
|
LOG("DeviceListener %p %s device applyConstraints, but device is stopped",
|
||||||
this,
|
this, dom::GetEnumString(GetDevice()->Kind()).get());
|
||||||
nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
|
|
||||||
.get());
|
|
||||||
return DeviceListenerPromise::CreateAndResolve(false, __func__);
|
return DeviceListenerPromise::CreateAndResolve(false, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,7 +324,7 @@ void MediaStreamTrack::GetSettings(dom::MediaTrackSettings& aResult,
|
||||||
}
|
}
|
||||||
if (aResult.mFacingMode.WasPassed()) {
|
if (aResult.mFacingMode.WasPassed()) {
|
||||||
aResult.mFacingMode.Value().AssignASCII(
|
aResult.mFacingMode.Value().AssignASCII(
|
||||||
VideoFacingModeEnumValues::GetString(VideoFacingModeEnum::User));
|
GetEnumString(VideoFacingModeEnum::User));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,8 @@ void MediaKeySession::UpdateKeyStatusMap() {
|
||||||
nsPrintfCString("MediaKeySession[%p,'%s'] key statuses change {", this,
|
nsPrintfCString("MediaKeySession[%p,'%s'] key statuses change {", this,
|
||||||
NS_ConvertUTF16toUTF8(mSessionId).get()));
|
NS_ConvertUTF16toUTF8(mSessionId).get()));
|
||||||
for (const CDMCaps::KeyStatus& status : keyStatuses) {
|
for (const CDMCaps::KeyStatus& status : keyStatuses) {
|
||||||
message.AppendPrintf(
|
message.AppendPrintf(" (%s,%s)", ToHexString(status.mId).get(),
|
||||||
" (%s,%s)", ToHexString(status.mId).get(),
|
GetEnumString(status.mStatus).get());
|
||||||
nsCString(MediaKeyStatusValues::GetString(status.mStatus)).get());
|
|
||||||
}
|
}
|
||||||
message.AppendLiteral(" }");
|
message.AppendLiteral(" }");
|
||||||
// Use %s so we aren't exposing random strings to printf interpolation.
|
// Use %s so we aren't exposing random strings to printf interpolation.
|
||||||
|
@ -542,8 +541,7 @@ void MediaKeySession::DispatchKeyMessage(MediaKeyMessageType aMessageType,
|
||||||
EME_LOG(
|
EME_LOG(
|
||||||
"MediaKeySession[%p,'%s'] DispatchKeyMessage() type=%s message='%s'",
|
"MediaKeySession[%p,'%s'] DispatchKeyMessage() type=%s message='%s'",
|
||||||
this, NS_ConvertUTF16toUTF8(mSessionId).get(),
|
this, NS_ConvertUTF16toUTF8(mSessionId).get(),
|
||||||
nsCString(MediaKeyMessageTypeValues::GetString(aMessageType)).get(),
|
GetEnumString(aMessageType).get(), ToHexString(aMessage).get());
|
||||||
ToHexString(aMessage).get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<MediaKeyMessageEvent> event(
|
RefPtr<MediaKeyMessageEvent> event(
|
||||||
|
@ -611,12 +609,8 @@ void MediaKeySession::SetOnmessage(EventHandlerNonNull* aCallback) {
|
||||||
SetEventHandler(nsGkAtoms::onmessage, aCallback);
|
SetEventHandler(nsGkAtoms::onmessage, aCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCString ToCString(MediaKeySessionType aType) {
|
|
||||||
return nsCString(MediaKeySessionTypeValues::GetString(aType));
|
|
||||||
}
|
|
||||||
|
|
||||||
nsString ToString(MediaKeySessionType aType) {
|
nsString ToString(MediaKeySessionType aType) {
|
||||||
return NS_ConvertUTF8toUTF16(ToCString(aType));
|
return NS_ConvertUTF8toUTF16(GetEnumString(aType));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
|
@ -36,8 +36,6 @@ class ArrayBufferViewOrArrayBuffer;
|
||||||
class MediaKeyError;
|
class MediaKeyError;
|
||||||
class MediaKeyStatusMap;
|
class MediaKeyStatusMap;
|
||||||
|
|
||||||
nsCString ToCString(MediaKeySessionType aType);
|
|
||||||
|
|
||||||
nsString ToString(MediaKeySessionType aType);
|
nsString ToString(MediaKeySessionType aType);
|
||||||
|
|
||||||
class MediaKeySession final : public DOMEventTargetHelper,
|
class MediaKeySession final : public DOMEventTargetHelper,
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ static nsCString ToCString(const nsString& aString) {
|
||||||
|
|
||||||
static nsCString ToCString(const MediaKeysRequirement aValue) {
|
static nsCString ToCString(const MediaKeysRequirement aValue) {
|
||||||
nsCString str("'");
|
nsCString str("'");
|
||||||
str.AppendASCII(MediaKeysRequirementValues::GetString(aValue));
|
str.AppendASCII(GetEnumString(aValue));
|
||||||
str.AppendLiteral("'");
|
str.AppendLiteral("'");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,8 +412,7 @@ void MediaKeySystemAccessManager::RequestMediaKeySystemAccess(
|
||||||
"MediaKeySystemAccess::GetKeySystemStatus(%s) "
|
"MediaKeySystemAccess::GetKeySystemStatus(%s) "
|
||||||
"result=%s msg='%s'",
|
"result=%s msg='%s'",
|
||||||
NS_ConvertUTF16toUTF8(aRequest->mKeySystem).get(),
|
NS_ConvertUTF16toUTF8(aRequest->mKeySystem).get(),
|
||||||
nsCString(MediaKeySystemStatusValues::GetString(status)).get(),
|
GetEnumString(status).get(), message.get());
|
||||||
message.get());
|
|
||||||
LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg));
|
LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg));
|
||||||
EME_LOG("%s", msg.get());
|
EME_LOG("%s", msg.get());
|
||||||
|
|
||||||
|
|
|
@ -792,8 +792,7 @@ void MediaKeys::GetSessionsInfo(nsString& sessionsInfo) {
|
||||||
sessionsInfo.AppendLiteral("(kid=");
|
sessionsInfo.AppendLiteral("(kid=");
|
||||||
sessionsInfo.Append(keyID);
|
sessionsInfo.Append(keyID);
|
||||||
sessionsInfo.AppendLiteral(" status=");
|
sessionsInfo.AppendLiteral(" status=");
|
||||||
sessionsInfo.AppendASCII(
|
sessionsInfo.AppendASCII(GetEnumString(keyStatusMap->GetValueAtIndex(i)));
|
||||||
MediaKeyStatusValues::GetString(keyStatusMap->GetValueAtIndex(i)));
|
|
||||||
sessionsInfo.AppendLiteral(")");
|
sessionsInfo.AppendLiteral(")");
|
||||||
}
|
}
|
||||||
sessionsInfo.AppendLiteral(")");
|
sessionsInfo.AppendLiteral(")");
|
||||||
|
@ -824,7 +823,7 @@ already_AddRefed<Promise> MediaKeys::GetStatusForPolicy(
|
||||||
}
|
}
|
||||||
|
|
||||||
EME_LOG("GetStatusForPolicy minHdcpVersion = %s.",
|
EME_LOG("GetStatusForPolicy minHdcpVersion = %s.",
|
||||||
HDCPVersionValues::GetString(aPolicy.mMinHdcpVersion.Value()).data());
|
GetEnumString(aPolicy.mMinHdcpVersion.Value()).get());
|
||||||
mProxy->GetStatusForPolicy(StorePromise(promise),
|
mProxy->GetStatusForPolicy(StorePromise(promise),
|
||||||
aPolicy.mMinHdcpVersion.Value());
|
aPolicy.mMinHdcpVersion.Value());
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
|
|
|
@ -381,8 +381,7 @@ void WMFCDMProxy::GetStatusForPolicy(PromiseId aPromiseId,
|
||||||
RETURN_IF_SHUTDOWN();
|
RETURN_IF_SHUTDOWN();
|
||||||
EME_LOG("WMFCDMProxy::GetStatusForPolicy(this=%p, pid=%" PRIu32
|
EME_LOG("WMFCDMProxy::GetStatusForPolicy(this=%p, pid=%" PRIu32
|
||||||
", minHDCP=%s)",
|
", minHDCP=%s)",
|
||||||
this, aPromiseId,
|
this, aPromiseId, dom::GetEnumString(aMinHdcpVersion).get());
|
||||||
dom::HDCPVersionValues::GetString(aMinHdcpVersion).data());
|
|
||||||
mCDM->GetStatusForPolicy(aPromiseId, aMinHdcpVersion)
|
mCDM->GetStatusForPolicy(aPromiseId, aMinHdcpVersion)
|
||||||
->Then(
|
->Then(
|
||||||
mMainThread, __func__,
|
mMainThread, __func__,
|
||||||
|
|
|
@ -605,8 +605,7 @@ void ChromiumCDMProxy::GetStatusForPolicy(
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
EME_LOG("ChromiumCDMProxy::GetStatusForPolicy(this=%p, pid=%" PRIu32
|
EME_LOG("ChromiumCDMProxy::GetStatusForPolicy(this=%p, pid=%" PRIu32
|
||||||
") minHdcpVersion=%s",
|
") minHdcpVersion=%s",
|
||||||
this, aPromiseId,
|
this, aPromiseId, dom::GetEnumString(aMinHdcpVersion).get());
|
||||||
dom::HDCPVersionValues::GetString(aMinHdcpVersion).data());
|
|
||||||
|
|
||||||
RefPtr<gmp::ChromiumCDMParent> cdm = GetCDMParent();
|
RefPtr<gmp::ChromiumCDMParent> cdm = GetCDMParent();
|
||||||
if (!cdm) {
|
if (!cdm) {
|
||||||
|
|
|
@ -45,21 +45,6 @@ static nsCString VideoConfigurationToStr(const VideoConfiguration* aConfig) {
|
||||||
return nsCString();
|
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(
|
auto str = nsPrintfCString(
|
||||||
"[contentType:%s width:%d height:%d bitrate:%" PRIu64
|
"[contentType:%s width:%d height:%d bitrate:%" PRIu64
|
||||||
" framerate:%lf hasAlphaChannel:%s hdrMetadataType:%s colorGamut:%s "
|
" framerate:%lf hasAlphaChannel:%s hdrMetadataType:%s colorGamut:%s "
|
||||||
|
@ -69,7 +54,15 @@ static nsCString VideoConfigurationToStr(const VideoConfiguration* aConfig) {
|
||||||
aConfig->mHasAlphaChannel.WasPassed()
|
aConfig->mHasAlphaChannel.WasPassed()
|
||||||
? aConfig->mHasAlphaChannel.Value() ? "true" : "false"
|
? aConfig->mHasAlphaChannel.Value() ? "true" : "false"
|
||||||
: "?",
|
: "?",
|
||||||
hdrMetaType.get(), colorGamut.get(), transferFunction.get(),
|
aConfig->mHdrMetadataType.WasPassed()
|
||||||
|
? GetEnumString(aConfig->mHdrMetadataType.Value()).get()
|
||||||
|
: "?",
|
||||||
|
aConfig->mColorGamut.WasPassed()
|
||||||
|
? GetEnumString(aConfig->mColorGamut.Value()).get()
|
||||||
|
: "?",
|
||||||
|
aConfig->mTransferFunction.WasPassed()
|
||||||
|
? GetEnumString(aConfig->mTransferFunction.Value()).get()
|
||||||
|
: "?",
|
||||||
aConfig->mScalabilityMode.WasPassed()
|
aConfig->mScalabilityMode.WasPassed()
|
||||||
? NS_ConvertUTF16toUTF8(aConfig->mScalabilityMode.Value()).get()
|
? NS_ConvertUTF16toUTF8(aConfig->mScalabilityMode.Value()).get()
|
||||||
: "?");
|
: "?");
|
||||||
|
|
|
@ -170,9 +170,7 @@ nsString VideoDecoderConfigInternal::ToString() const {
|
||||||
if (mDescription.isSome()) {
|
if (mDescription.isSome()) {
|
||||||
rv.AppendPrintf("extradata: %zu bytes", mDescription.value()->Length());
|
rv.AppendPrintf("extradata: %zu bytes", mDescription.value()->Length());
|
||||||
}
|
}
|
||||||
rv.AppendPrintf(
|
rv.AppendPrintf("hw accel: %s", GetEnumString(mHardwareAcceleration).get());
|
||||||
"hw accel: %s",
|
|
||||||
HardwareAccelerationValues::GetString(mHardwareAcceleration).data());
|
|
||||||
if (mOptimizeForLatency.isSome()) {
|
if (mOptimizeForLatency.isSome()) {
|
||||||
rv.AppendPrintf("optimize for latency: %s",
|
rv.AppendPrintf("optimize for latency: %s",
|
||||||
mOptimizeForLatency.value() ? "true" : "false");
|
mOptimizeForLatency.value() ? "true" : "false");
|
||||||
|
|
|
@ -135,26 +135,20 @@ nsString VideoEncoderConfigInternal::ToString() const {
|
||||||
if (mFramerate.isSome()) {
|
if (mFramerate.isSome()) {
|
||||||
rv.AppendPrintf(", %lfHz", mFramerate.value());
|
rv.AppendPrintf(", %lfHz", mFramerate.value());
|
||||||
}
|
}
|
||||||
rv.AppendPrintf(
|
rv.AppendPrintf(" hw: %s", GetEnumString(mHardwareAcceleration).get());
|
||||||
" hw: %s",
|
rv.AppendPrintf(", alpha: %s", GetEnumString(mAlpha).get());
|
||||||
HardwareAccelerationValues::GetString(mHardwareAcceleration).data());
|
|
||||||
rv.AppendPrintf(", alpha: %s", AlphaOptionValues::GetString(mAlpha).data());
|
|
||||||
if (mScalabilityMode.isSome()) {
|
if (mScalabilityMode.isSome()) {
|
||||||
rv.AppendPrintf(", scalability mode: %s",
|
rv.AppendPrintf(", scalability mode: %s",
|
||||||
NS_ConvertUTF16toUTF8(mScalabilityMode.value()).get());
|
NS_ConvertUTF16toUTF8(mScalabilityMode.value()).get());
|
||||||
}
|
}
|
||||||
rv.AppendPrintf(
|
rv.AppendPrintf(", bitrate mode: %s", GetEnumString(mBitrateMode).get());
|
||||||
", bitrate mode: %s",
|
rv.AppendPrintf(", latency mode: %s", GetEnumString(mLatencyMode).get());
|
||||||
VideoEncoderBitrateModeValues::GetString(mBitrateMode).data());
|
|
||||||
rv.AppendPrintf(", latency mode: %s",
|
|
||||||
LatencyModeValues::GetString(mLatencyMode).data());
|
|
||||||
if (mContentHint.isSome()) {
|
if (mContentHint.isSome()) {
|
||||||
rv.AppendPrintf(", content hint: %s",
|
rv.AppendPrintf(", content hint: %s",
|
||||||
NS_ConvertUTF16toUTF8(mContentHint.value()).get());
|
NS_ConvertUTF16toUTF8(mContentHint.value()).get());
|
||||||
}
|
}
|
||||||
if (mAvc.isSome()) {
|
if (mAvc.isSome()) {
|
||||||
rv.AppendPrintf(", avc-specific: %s",
|
rv.AppendPrintf(", avc-specific: %s", GetEnumString(mAvc->mFormat).get());
|
||||||
AvcBitstreamFormatValues::GetString(mAvc->mFormat).data());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -1789,15 +1789,13 @@ nsCString VideoFrame::ToString() const {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv.AppendPrintf(
|
rv.AppendPrintf("VideoFrame ts: %" PRId64
|
||||||
"VideoFrame ts: %" PRId64
|
", %s, coded[%dx%d] visible[%dx%d], display[%dx%d] color: %s",
|
||||||
", %s, coded[%dx%d] visible[%dx%d], display[%dx%d] color: %s",
|
mTimestamp,
|
||||||
mTimestamp,
|
dom::GetEnumString(mResource->mFormat->PixelFormat()).get(),
|
||||||
dom::VideoPixelFormatValues::GetString(mResource->mFormat->PixelFormat())
|
mCodedSize.width, mCodedSize.height, mVisibleRect.width,
|
||||||
.data(),
|
mVisibleRect.height, mDisplaySize.width, mDisplaySize.height,
|
||||||
mCodedSize.width, mCodedSize.height, mVisibleRect.width,
|
ColorSpaceInitToString(mColorSpace).get());
|
||||||
mVisibleRect.height, mDisplaySize.width, mDisplaySize.height,
|
|
||||||
ColorSpaceInitToString(mColorSpace).get());
|
|
||||||
|
|
||||||
if (mDuration) {
|
if (mDuration) {
|
||||||
rv.AppendPrintf(" dur: %" PRId64, mDuration.value());
|
rv.AppendPrintf(" dur: %" PRId64, mDuration.value());
|
||||||
|
|
|
@ -364,15 +364,13 @@ struct ConfigurationChangeToString {
|
||||||
}
|
}
|
||||||
nsCString operator()(
|
nsCString operator()(
|
||||||
const HardwareAccelerationChange& aHardwareAccelerationChange) {
|
const HardwareAccelerationChange& aHardwareAccelerationChange) {
|
||||||
return nsPrintfCString("HW acceleration: %s",
|
return nsPrintfCString(
|
||||||
dom::HardwareAccelerationValues::GetString(
|
"HW acceleration: %s",
|
||||||
aHardwareAccelerationChange.get())
|
dom::GetEnumString(aHardwareAccelerationChange.get()).get());
|
||||||
.data());
|
|
||||||
}
|
}
|
||||||
nsCString operator()(const AlphaChange& aAlphaChange) {
|
nsCString operator()(const AlphaChange& aAlphaChange) {
|
||||||
return nsPrintfCString(
|
return nsPrintfCString("Alpha: %s",
|
||||||
"Alpha: %s",
|
dom::GetEnumString(aAlphaChange.get()).get());
|
||||||
dom::AlphaOptionValues::GetString(aAlphaChange.get()).data());
|
|
||||||
}
|
}
|
||||||
nsCString operator()(const ScalabilityModeChange& aScalabilityModeChange) {
|
nsCString operator()(const ScalabilityModeChange& aScalabilityModeChange) {
|
||||||
if (aScalabilityModeChange.get().isNothing()) {
|
if (aScalabilityModeChange.get().isNothing()) {
|
||||||
|
@ -383,15 +381,12 @@ struct ConfigurationChangeToString {
|
||||||
NS_ConvertUTF16toUTF8(aScalabilityModeChange.get().value()).get());
|
NS_ConvertUTF16toUTF8(aScalabilityModeChange.get().value()).get());
|
||||||
}
|
}
|
||||||
nsCString operator()(const BitrateModeChange& aBitrateModeChange) {
|
nsCString operator()(const BitrateModeChange& aBitrateModeChange) {
|
||||||
return nsPrintfCString(
|
return nsPrintfCString("Bitrate mode: %s",
|
||||||
"Bitrate mode: %s",
|
dom::GetEnumString(aBitrateModeChange.get()).get());
|
||||||
dom::VideoEncoderBitrateModeValues::GetString(aBitrateModeChange.get())
|
|
||||||
.data());
|
|
||||||
}
|
}
|
||||||
nsCString operator()(const LatencyModeChange& aLatencyModeChange) {
|
nsCString operator()(const LatencyModeChange& aLatencyModeChange) {
|
||||||
return nsPrintfCString(
|
return nsPrintfCString("Latency mode: %s",
|
||||||
"Latency mode: %s",
|
dom::GetEnumString(aLatencyModeChange.get()).get());
|
||||||
dom::LatencyModeValues::GetString(aLatencyModeChange.get()).data());
|
|
||||||
}
|
}
|
||||||
nsCString operator()(const ContentHintChange& aContentHintChange) {
|
nsCString operator()(const ContentHintChange& aContentHintChange) {
|
||||||
return nsPrintfCString("Content hint: %s",
|
return nsPrintfCString("Content hint: %s",
|
||||||
|
@ -489,9 +484,6 @@ WebCodecsConfigurationChangeList::ToPEMChangeList() const {
|
||||||
return rv.forget();
|
return rv.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ENUM_TO_STRING(enumType, enumValue) \
|
|
||||||
enumType##Values::GetString(enumValue).data()
|
|
||||||
|
|
||||||
nsCString ColorSpaceInitToString(
|
nsCString ColorSpaceInitToString(
|
||||||
const dom::VideoColorSpaceInit& aColorSpaceInit) {
|
const dom::VideoColorSpaceInit& aColorSpaceInit) {
|
||||||
nsCString rv("VideoColorSpace");
|
nsCString rv("VideoColorSpace");
|
||||||
|
@ -502,18 +494,15 @@ nsCString ColorSpaceInitToString(
|
||||||
}
|
}
|
||||||
if (!aColorSpaceInit.mMatrix.IsNull()) {
|
if (!aColorSpaceInit.mMatrix.IsNull()) {
|
||||||
rv.AppendPrintf(" matrix: %s",
|
rv.AppendPrintf(" matrix: %s",
|
||||||
ENUM_TO_STRING(dom::VideoMatrixCoefficients,
|
GetEnumString(aColorSpaceInit.mMatrix.Value()).get());
|
||||||
aColorSpaceInit.mMatrix.Value()));
|
|
||||||
}
|
}
|
||||||
if (!aColorSpaceInit.mTransfer.IsNull()) {
|
if (!aColorSpaceInit.mTransfer.IsNull()) {
|
||||||
rv.AppendPrintf(" transfer: %s",
|
rv.AppendPrintf(" transfer: %s",
|
||||||
ENUM_TO_STRING(dom::VideoTransferCharacteristics,
|
GetEnumString(aColorSpaceInit.mTransfer.Value()).get());
|
||||||
aColorSpaceInit.mTransfer.Value()));
|
|
||||||
}
|
}
|
||||||
if (!aColorSpaceInit.mPrimaries.IsNull()) {
|
if (!aColorSpaceInit.mPrimaries.IsNull()) {
|
||||||
rv.AppendPrintf(" primaries: %s",
|
rv.AppendPrintf(" primaries: %s",
|
||||||
ENUM_TO_STRING(dom::VideoColorPrimaries,
|
GetEnumString(aColorSpaceInit.mPrimaries.Value()).get());
|
||||||
aColorSpaceInit.mPrimaries.Value()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -136,10 +136,8 @@ MediaEngineFakeVideoSource::MediaEngineFakeVideoSource()
|
||||||
mSettings->mHeight.Construct(
|
mSettings->mHeight.Construct(
|
||||||
int32_t(MediaEnginePrefs::DEFAULT_43_VIDEO_HEIGHT));
|
int32_t(MediaEnginePrefs::DEFAULT_43_VIDEO_HEIGHT));
|
||||||
mSettings->mFrameRate.Construct(double(MediaEnginePrefs::DEFAULT_VIDEO_FPS));
|
mSettings->mFrameRate.Construct(double(MediaEnginePrefs::DEFAULT_VIDEO_FPS));
|
||||||
mSettings->mFacingMode.Construct(
|
mSettings->mFacingMode.Construct(NS_ConvertASCIItoUTF16(
|
||||||
NS_ConvertASCIItoUTF16(dom::VideoFacingModeEnumValues::strings
|
dom::GetEnumString(VideoFacingModeEnum::Environment)));
|
||||||
[uint8_t(VideoFacingModeEnum::Environment)]
|
|
||||||
.value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString MediaEngineFakeVideoSource::GetGroupId() {
|
nsString MediaEngineFakeVideoSource::GetGroupId() {
|
||||||
|
|
|
@ -108,8 +108,7 @@ MediaEngineRemoteVideoSource::MediaEngineRemoteVideoSource(
|
||||||
Maybe<VideoFacingModeEnum> facingMode =
|
Maybe<VideoFacingModeEnum> facingMode =
|
||||||
GetFacingMode(mMediaDevice->mRawName);
|
GetFacingMode(mMediaDevice->mRawName);
|
||||||
if (facingMode.isSome()) {
|
if (facingMode.isSome()) {
|
||||||
NS_ConvertASCIItoUTF16 facingString(
|
NS_ConvertASCIItoUTF16 facingString(dom::GetEnumString(*facingMode));
|
||||||
dom::VideoFacingModeEnumValues::GetString(*facingMode));
|
|
||||||
mSettings->mFacingMode.Construct(facingString);
|
mSettings->mFacingMode.Construct(facingString);
|
||||||
mFacingMode.emplace(facingString);
|
mFacingMode.emplace(facingString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ class MediaDevice;
|
||||||
template <class EnumValuesStrings, class Enum>
|
template <class EnumValuesStrings, class Enum>
|
||||||
static Enum StringToEnum(const EnumValuesStrings& aStrings,
|
static Enum StringToEnum(const EnumValuesStrings& aStrings,
|
||||||
const nsAString& aValue, Enum aDefaultValue) {
|
const nsAString& aValue, Enum aDefaultValue) {
|
||||||
for (size_t i = 0; aStrings[i].value; i++) {
|
for (size_t i = 0; i < ArrayLength(aStrings); i++) {
|
||||||
if (aValue.EqualsASCII(aStrings[i].value)) {
|
if (aValue.EqualsASCII(aStrings[i].get())) {
|
||||||
return Enum(i);
|
return Enum(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,14 +104,14 @@ bool MIDIPort::Initialize(const MIDIPortInfo& aPortInfo, bool aSysexEnabled,
|
||||||
mPortHolder.Init(port.forget());
|
mPortHolder.Init(port.forget());
|
||||||
LOG("MIDIPort::Initialize (%s, %s)",
|
LOG("MIDIPort::Initialize (%s, %s)",
|
||||||
NS_ConvertUTF16toUTF8(Port()->Name()).get(),
|
NS_ConvertUTF16toUTF8(Port()->Name()).get(),
|
||||||
MIDIPortTypeValues::strings[uint32_t(Port()->Type())].value);
|
GetEnumString(Port()->Type()).get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIDIPort::UnsetIPCPort() {
|
void MIDIPort::UnsetIPCPort() {
|
||||||
LOG("MIDIPort::UnsetIPCPort (%s, %s)",
|
LOG("MIDIPort::UnsetIPCPort (%s, %s)",
|
||||||
NS_ConvertUTF16toUTF8(Port()->Name()).get(),
|
NS_ConvertUTF16toUTF8(Port()->Name()).get(),
|
||||||
MIDIPortTypeValues::strings[uint32_t(Port()->Type())].value);
|
GetEnumString(Port()->Type()).get());
|
||||||
mPortHolder.Clear();
|
mPortHolder.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,8 +220,7 @@ void ConvertDetailsUpdate(JSContext* aCx, const PaymentDetailsUpdate& aDetails,
|
||||||
|
|
||||||
void ConvertOptions(const PaymentOptions& aOptions,
|
void ConvertOptions(const PaymentOptions& aOptions,
|
||||||
IPCPaymentOptions& aIPCOption) {
|
IPCPaymentOptions& aIPCOption) {
|
||||||
NS_ConvertASCIItoUTF16 shippingType(
|
NS_ConvertASCIItoUTF16 shippingType(GetEnumString(aOptions.mShippingType));
|
||||||
PaymentShippingTypeValues::GetString(aOptions.mShippingType));
|
|
||||||
aIPCOption =
|
aIPCOption =
|
||||||
IPCPaymentOptions(aOptions.mRequestPayerName, aOptions.mRequestPayerEmail,
|
IPCPaymentOptions(aOptions.mRequestPayerName, aOptions.mRequestPayerEmail,
|
||||||
aOptions.mRequestPayerPhone, aOptions.mRequestShipping,
|
aOptions.mRequestPayerPhone, aOptions.mRequestShipping,
|
||||||
|
@ -548,8 +547,7 @@ void PaymentRequestManager::CompletePayment(PaymentRequest* aRequest,
|
||||||
if (aTimedOut) {
|
if (aTimedOut) {
|
||||||
completeStatusString.AssignLiteral("timeout");
|
completeStatusString.AssignLiteral("timeout");
|
||||||
} else {
|
} else {
|
||||||
completeStatusString.AssignASCII(
|
completeStatusString.AssignASCII(GetEnumString(aComplete));
|
||||||
PaymentCompleteValues::GetString(aComplete));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString requestId;
|
nsAutoString requestId;
|
||||||
|
|
|
@ -133,8 +133,11 @@ ReferrerPolicy ReferrerPolicyFromToken(const nsAString& aContent,
|
||||||
|
|
||||||
// Supported tokes - ReferrerPolicyValues, are generated from
|
// Supported tokes - ReferrerPolicyValues, are generated from
|
||||||
// ReferrerPolicy.webidl
|
// ReferrerPolicy.webidl
|
||||||
for (uint8_t i = 0; ReferrerPolicyValues::strings[i].value; i++) {
|
for (size_t i = 0;
|
||||||
if (lowerContent.EqualsASCII(ReferrerPolicyValues::strings[i].value)) {
|
i < ArrayLength(binding_detail::EnumStrings<ReferrerPolicy>::Values);
|
||||||
|
i++) {
|
||||||
|
if (lowerContent.EqualsASCII(
|
||||||
|
binding_detail::EnumStrings<ReferrerPolicy>::Values[i].get())) {
|
||||||
return static_cast<enum ReferrerPolicy>(i);
|
return static_cast<enum ReferrerPolicy>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,18 +190,6 @@ ReferrerPolicy ReferrerInfo::ReferrerPolicyFromHeaderString(
|
||||||
return referrerPolicy;
|
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 */
|
/* static */
|
||||||
uint32_t ReferrerInfo::GetUserReferrerSendingPolicy() {
|
uint32_t ReferrerInfo::GetUserReferrerSendingPolicy() {
|
||||||
return clamped<uint32_t>(
|
return clamped<uint32_t>(
|
||||||
|
@ -831,11 +822,8 @@ bool ReferrerInfo::ShouldIgnoreLessRestrictedPolicies(
|
||||||
nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
|
nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
|
||||||
NS_ENSURE_SUCCESS(rv, true);
|
NS_ENSURE_SUCCESS(rv, true);
|
||||||
|
|
||||||
uint32_t idx = static_cast<uint32_t>(aPolicy);
|
|
||||||
|
|
||||||
AutoTArray<nsString, 2> params = {
|
AutoTArray<nsString, 2> params = {
|
||||||
NS_ConvertUTF8toUTF16(
|
NS_ConvertUTF8toUTF16(GetEnumString(aPolicy)),
|
||||||
nsDependentCString(ReferrerPolicyValues::strings[idx].value)),
|
|
||||||
NS_ConvertUTF8toUTF16(uri->GetSpecOrDefault())};
|
NS_ConvertUTF8toUTF16(uri->GetSpecOrDefault())};
|
||||||
LogMessageToConsole(aChannel, "ReferrerPolicyDisallowRelaxingMessage",
|
LogMessageToConsole(aChannel, "ReferrerPolicyDisallowRelaxingMessage",
|
||||||
params);
|
params);
|
||||||
|
@ -1051,7 +1039,7 @@ ReferrerInfo::GetReferrerPolicy(
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
ReferrerInfo::GetReferrerPolicyString(nsACString& aResult) {
|
ReferrerInfo::GetReferrerPolicyString(nsACString& aResult) {
|
||||||
aResult.AssignASCII(ReferrerPolicyToString(mPolicy));
|
aResult.AssignASCII(GetEnumString(mPolicy));
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,13 +258,6 @@ class ReferrerInfo : public nsIReferrerInfo {
|
||||||
static ReferrerPolicyEnum ReferrerPolicyFromHeaderString(
|
static ReferrerPolicyEnum ReferrerPolicyFromHeaderString(
|
||||||
const nsAString& aContent);
|
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
|
* Hash function for this object
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -624,8 +624,7 @@ void RespondWithHandler::ResolvedCallback(JSContext* aCx,
|
||||||
|
|
||||||
if (response->Type() == ResponseType::Opaque &&
|
if (response->Type() == ResponseType::Opaque &&
|
||||||
mRequestMode != RequestMode::No_cors) {
|
mRequestMode != RequestMode::No_cors) {
|
||||||
NS_ConvertASCIItoUTF16 modeString(
|
NS_ConvertASCIItoUTF16 modeString(GetEnumString(mRequestMode));
|
||||||
RequestModeValues::GetString(mRequestMode));
|
|
||||||
|
|
||||||
autoCancel.SetCancelMessage("BadOpaqueInterceptionRequestModeWithURL"_ns,
|
autoCancel.SetCancelMessage("BadOpaqueInterceptionRequestModeWithURL"_ns,
|
||||||
mRequestURL, modeString);
|
mRequestURL, modeString);
|
||||||
|
|
|
@ -1428,8 +1428,7 @@ void FetchEventOp::ResolvedCallback(JSContext* aCx,
|
||||||
|
|
||||||
if (response->Type() == ResponseType::Opaque &&
|
if (response->Type() == ResponseType::Opaque &&
|
||||||
requestMode != RequestMode::No_cors) {
|
requestMode != RequestMode::No_cors) {
|
||||||
NS_ConvertASCIItoUTF16 modeString(
|
NS_ConvertASCIItoUTF16 modeString(GetEnumString(requestMode));
|
||||||
RequestModeValues::GetString(requestMode));
|
|
||||||
|
|
||||||
nsAutoString requestURL;
|
nsAutoString requestURL;
|
||||||
GetRequestURL(requestURL);
|
GetRequestURL(requestURL);
|
||||||
|
|
|
@ -168,8 +168,9 @@ already_AddRefed<Promise> XRSystem::RequestSession(
|
||||||
|
|
||||||
if (aOptions.mRequiredFeatures.WasPassed()) {
|
if (aOptions.mRequiredFeatures.WasPassed()) {
|
||||||
for (const nsString& val : aOptions.mRequiredFeatures.Value()) {
|
for (const nsString& val : aOptions.mRequiredFeatures.Value()) {
|
||||||
int index = FindEnumStringIndexImpl(val.BeginReading(), val.Length(),
|
int index = FindEnumStringIndexImpl(
|
||||||
XRReferenceSpaceTypeValues::strings);
|
val.BeginReading(), val.Length(),
|
||||||
|
binding_detail::EnumStrings<XRReferenceSpaceType>::Values);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
promise->MaybeRejectWithNotSupportedError(
|
promise->MaybeRejectWithNotSupportedError(
|
||||||
"A required feature for the XRSession is not available.");
|
"A required feature for the XRSession is not available.");
|
||||||
|
@ -182,8 +183,9 @@ already_AddRefed<Promise> XRSystem::RequestSession(
|
||||||
|
|
||||||
if (aOptions.mOptionalFeatures.WasPassed()) {
|
if (aOptions.mOptionalFeatures.WasPassed()) {
|
||||||
for (const nsString& val : aOptions.mOptionalFeatures.Value()) {
|
for (const nsString& val : aOptions.mOptionalFeatures.Value()) {
|
||||||
int index = FindEnumStringIndexImpl(val.BeginReading(), val.Length(),
|
int index = FindEnumStringIndexImpl(
|
||||||
XRReferenceSpaceTypeValues::strings);
|
val.BeginReading(), val.Length(),
|
||||||
|
binding_detail::EnumStrings<XRReferenceSpaceType>::Values);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
optionalReferenceSpaceTypes.AppendElement(
|
optionalReferenceSpaceTypes.AppendElement(
|
||||||
static_cast<XRReferenceSpaceType>(index));
|
static_cast<XRReferenceSpaceType>(index));
|
||||||
|
|
|
@ -141,11 +141,11 @@ static Maybe<ffi::WGPUFeatures> MakeFeatureBits(
|
||||||
for (const auto& feature : aFeatures) {
|
for (const auto& feature : aFeatures) {
|
||||||
const auto bit = ToWGPUFeatures(feature);
|
const auto bit = ToWGPUFeatures(feature);
|
||||||
if (!bit) {
|
if (!bit) {
|
||||||
const auto featureStr = dom::GPUFeatureNameValues::GetString(feature);
|
const auto featureStr = dom::GetEnumString(feature);
|
||||||
(void)featureStr;
|
(void)featureStr;
|
||||||
NS_WARNING(
|
NS_WARNING(
|
||||||
nsPrintfCString("Requested feature bit for '%s' is not implemented.",
|
nsPrintfCString("Requested feature bit for '%s' is not implemented.",
|
||||||
featureStr.data())
|
featureStr.get())
|
||||||
.get());
|
.get());
|
||||||
return Nothing();
|
return Nothing();
|
||||||
}
|
}
|
||||||
|
@ -363,12 +363,12 @@ already_AddRefed<dom::Promise> Adapter::RequestDevice(
|
||||||
for (const auto requested : aDesc.mRequiredFeatures) {
|
for (const auto requested : aDesc.mRequiredFeatures) {
|
||||||
const bool supported = mFeatures->Features().count(requested);
|
const bool supported = mFeatures->Features().count(requested);
|
||||||
if (!supported) {
|
if (!supported) {
|
||||||
const auto fstr = dom::GPUFeatureNameValues::GetString(requested);
|
const auto fstr = dom::GetEnumString(requested);
|
||||||
const auto astr = this->LabelOrId();
|
const auto astr = this->LabelOrId();
|
||||||
nsPrintfCString msg(
|
nsPrintfCString msg(
|
||||||
"requestDevice: Feature '%s' requested must be supported by "
|
"requestDevice: Feature '%s' requested must be supported by "
|
||||||
"adapter %s",
|
"adapter %s",
|
||||||
fstr.data(), astr.get());
|
fstr.get(), astr.get());
|
||||||
promise->MaybeRejectWithTypeError(msg);
|
promise->MaybeRejectWithTypeError(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "SupportedFeatures.h"
|
#include "SupportedFeatures.h"
|
||||||
#include "Adapter.h"
|
#include "Adapter.h"
|
||||||
|
#include "mozilla/dom/BindingUtils.h"
|
||||||
#include "mozilla/dom/WebGPUBinding.h"
|
#include "mozilla/dom/WebGPUBinding.h"
|
||||||
|
|
||||||
namespace mozilla::webgpu {
|
namespace mozilla::webgpu {
|
||||||
|
@ -17,7 +18,7 @@ SupportedFeatures::SupportedFeatures(Adapter* const aParent)
|
||||||
|
|
||||||
void SupportedFeatures::Add(const dom::GPUFeatureName aFeature,
|
void SupportedFeatures::Add(const dom::GPUFeatureName aFeature,
|
||||||
ErrorResult& aRv) {
|
ErrorResult& aRv) {
|
||||||
const auto u8 = dom::GPUFeatureNameValues::GetString(aFeature);
|
const auto u8 = dom::GetEnumString(aFeature);
|
||||||
const auto u16 = NS_ConvertUTF8toUTF16(u8);
|
const auto u16 = NS_ConvertUTF8toUTF16(u8);
|
||||||
dom::GPUSupportedFeatures_Binding::SetlikeHelpers::Add(this, u16, aRv);
|
dom::GPUSupportedFeatures_Binding::SetlikeHelpers::Add(this, u16, aRv);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "mozilla/ProcInfo.h"
|
#include "mozilla/ProcInfo.h"
|
||||||
#include "mozilla/ipc/UtilityAudioDecoder.h"
|
#include "mozilla/ipc/UtilityAudioDecoder.h"
|
||||||
|
#include "mozilla/dom/BindingUtils.h"
|
||||||
#include "mozilla/ipc/UtilityProcessChild.h"
|
#include "mozilla/ipc/UtilityProcessChild.h"
|
||||||
|
|
||||||
namespace mozilla::ipc {
|
namespace mozilla::ipc {
|
||||||
|
@ -34,8 +35,7 @@ UtilityActorName GetAudioActorName(const SandboxingKind aSandbox) {
|
||||||
nsCString GetChildAudioActorName() {
|
nsCString GetChildAudioActorName() {
|
||||||
RefPtr<ipc::UtilityProcessChild> s = ipc::UtilityProcessChild::Get();
|
RefPtr<ipc::UtilityProcessChild> s = ipc::UtilityProcessChild::Get();
|
||||||
MOZ_ASSERT(s, "Has UtilityProcessChild");
|
MOZ_ASSERT(s, "Has UtilityProcessChild");
|
||||||
return nsCString(dom::WebIDLUtilityActorNameValues::GetString(
|
return dom::GetEnumString(GetAudioActorName(s->mSandbox));
|
||||||
GetAudioActorName(s->mSandbox)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla::ipc
|
} // namespace mozilla::ipc
|
||||||
|
|
|
@ -31,9 +31,7 @@ static UtilityActorName UtilityActorNameFromString(
|
||||||
// for iteration.
|
// for iteration.
|
||||||
for (size_t i = 0; i < WebIDLUtilityActorNameValues::Count; ++i) {
|
for (size_t i = 0; i < WebIDLUtilityActorNameValues::Count; ++i) {
|
||||||
auto idlName = static_cast<UtilityActorName>(i);
|
auto idlName = static_cast<UtilityActorName>(i);
|
||||||
const nsDependentCSubstring idlNameString(
|
if (GetEnumString(idlName).Equals(aStringName)) {
|
||||||
WebIDLUtilityActorNameValues::GetString(idlName));
|
|
||||||
if (idlNameString.Equals(aStringName)) {
|
|
||||||
return idlName;
|
return idlName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче