Bug 1814985 - part2 : change 'DocumentAutoplayPolicy' to an internal enum class. r=media-playback-reviewers,emilio,padenot

Depends on D168856

Differential Revision: https://phabricator.services.mozilla.com/D168857
This commit is contained in:
alwu 2023-02-06 18:10:00 +00:00
Родитель 4b66bff559
Коммит 65fb054407
3 изменённых файлов: 11 добавлений и 17 удалений

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

@ -307,9 +307,14 @@ bool AutoplayPolicy::IsAllowedToPlay(const AudioContext& aContext) {
return IsWindowAllowedToPlay(window);
}
enum class DocumentAutoplayPolicy : uint8_t {
Allowed,
Allowed_muted,
Disallowed
};
/* static */
DocumentAutoplayPolicy AutoplayPolicy::IsAllowedToPlay(
const Document& aDocument) {
DocumentAutoplayPolicy IsDocAllowedToPlay(const Document& aDocument) {
const bool isWindowAllowedToPlay =
IsWindowAllowedToPlay(aDocument.GetInnerWindow());
@ -453,18 +458,18 @@ dom::AutoplayPolicy AutoplayPolicy::GetAutoplayPolicy(
/* static */
dom::AutoplayPolicy AutoplayPolicy::GetAutoplayPolicy(
const dom::AutoplayPolicyMediaType& aType, const dom::Document& aDoc) {
dom::DocumentAutoplayPolicy policy = AutoplayPolicy::IsAllowedToPlay(aDoc);
DocumentAutoplayPolicy policy = IsDocAllowedToPlay(aDoc);
// https://w3c.github.io/autoplay/#query-by-a-media-type
if (aType == dom::AutoplayPolicyMediaType::Audiocontext) {
return policy == dom::DocumentAutoplayPolicy::Allowed
return policy == DocumentAutoplayPolicy::Allowed
? dom::AutoplayPolicy::Allowed
: dom::AutoplayPolicy::Disallowed;
}
MOZ_ASSERT(aType == dom::AutoplayPolicyMediaType::Mediaelement);
if (policy == dom::DocumentAutoplayPolicy::Allowed) {
if (policy == DocumentAutoplayPolicy::Allowed) {
return dom::AutoplayPolicy::Allowed;
}
if (policy == dom::DocumentAutoplayPolicy::Allowed_muted) {
if (policy == DocumentAutoplayPolicy::Allowed_muted) {
return dom::AutoplayPolicy::Allowed_muted;
}
return dom::AutoplayPolicy::Disallowed;

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

@ -18,7 +18,6 @@ class AudioContext;
class Document;
enum class AutoplayPolicy : uint8_t;
enum class AutoplayPolicyMediaType : uint8_t;
enum class DocumentAutoplayPolicy : uint8_t;
} // namespace mozilla::dom
@ -37,10 +36,6 @@ namespace mozilla::media {
*/
class AutoplayPolicy {
public:
// Returns a DocumentAutoplayPolicy for given document.
static dom::DocumentAutoplayPolicy IsAllowedToPlay(
const dom::Document& aDocument);
// Returns whether a given media element is allowed to play.
static bool IsAllowedToPlay(const dom::HTMLMediaElement& aElement);

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

@ -559,12 +559,6 @@ partial interface Document {
Promise<undefined> requestStorageAccessForOrigin(DOMString thirdPartyOrigin, optional boolean requireUserInteraction = true);
};
enum DocumentAutoplayPolicy {
"allowed", // autoplay is currently allowed
"allowed-muted", // muted video autoplay is currently allowed
"disallowed" // autoplay is not current allowed
};
// Extension to give chrome JS the ability to determine whether
// the user has interacted with the document or not.
partial interface Document {