gecko-dev/dom/base/AnimationFrameProvider.cpp
Emilio Cobos Álvarez 4ecaba1a91 Bug 1800882 - Keep includes in AnimationFrameProvider.h down. r=aosmond
This fixes rusttests. Otherwise we include HTMLVideoElement.h from
Document.h, which includes a bunch of media headers, which causes
rusttest failures because
https://searchfox.org/mozilla-central/rev/d353cfa1fbd207e13dc974f30e5f88535a4303ae/dom/media/platforms/EncoderConfig.h#95
hits https://github.com/rust-lang/rust-bindgen/issues/380.

We could hide those types from rust but it seems slightly nicer to keep
Document.h lean, since it's included in a gazillion places.

Differential Revision: https://phabricator.services.mozilla.com/D217733
2024-08-01 20:12:23 +00:00

46 lines
1.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AnimationFrameProvider.h"
#include "MainThreadUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/HTMLVideoElement.h"
namespace mozilla::dom {
FrameRequestManager::FrameRequestManager() = default;
FrameRequestManager::~FrameRequestManager() = default;
void FrameRequestManager::Schedule(HTMLVideoElement* aElement) {
if (!mVideoCallbacks.Contains(aElement)) {
mVideoCallbacks.AppendElement(aElement);
}
}
bool FrameRequestManager::Cancel(HTMLVideoElement* aElement) {
return mVideoCallbacks.RemoveElement(aElement);
}
void FrameRequestManager::Unlink() {
FrameRequestManagerBase::Unlink();
mVideoCallbacks.Clear();
}
void FrameRequestManager::Traverse(nsCycleCollectionTraversalCallback& aCB) {
FrameRequestManagerBase::Traverse(aCB);
for (auto& i : mVideoCallbacks) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(
aCB, "FrameRequestManager::mVideoCallbacks[i]");
aCB.NoteXPCOMChild(ToSupports(i));
}
}
void FrameRequestManager::Take(
nsTArray<RefPtr<HTMLVideoElement>>& aVideoCallbacks) {
MOZ_ASSERT(NS_IsMainThread());
aVideoCallbacks = std::move(mVideoCallbacks);
}
} // namespace mozilla::dom