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
This commit is contained in:
Emilio Cobos Álvarez 2024-08-01 20:12:23 +00:00
parent b4e311c23c
commit 4ecaba1a91
3 changed files with 56 additions and 34 deletions

View File

@ -0,0 +1,46 @@
/* -*- 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

View File

@ -7,58 +7,33 @@
#ifndef mozilla_dom_AnimationFrameProvider_h
#define mozilla_dom_AnimationFrameProvider_h
#include "MainThreadUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/AnimationFrameProviderBinding.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/RequestCallbackManager.h"
namespace mozilla::dom {
class HTMLVideoElement;
using FrameRequest = RequestCallbackEntry<FrameRequestCallback>;
using FrameRequestManagerBase = RequestCallbackManager<FrameRequestCallback>;
class FrameRequestManager final : public FrameRequestManagerBase {
public:
FrameRequestManager() = default;
~FrameRequestManager() = default;
FrameRequestManager();
~FrameRequestManager();
using FrameRequestManagerBase::Cancel;
using FrameRequestManagerBase::Schedule;
using FrameRequestManagerBase::Take;
void Schedule(HTMLVideoElement* aElement) {
if (!mVideoCallbacks.Contains(aElement)) {
mVideoCallbacks.AppendElement(aElement);
}
}
bool Cancel(HTMLVideoElement* aElement) {
return mVideoCallbacks.RemoveElement(aElement);
}
void Schedule(HTMLVideoElement*);
bool Cancel(HTMLVideoElement*);
bool IsEmpty() const {
return FrameRequestManagerBase::IsEmpty() && mVideoCallbacks.IsEmpty();
}
void Take(nsTArray<RefPtr<HTMLVideoElement>>& aVideoCallbacks) {
MOZ_ASSERT(NS_IsMainThread());
aVideoCallbacks = std::move(mVideoCallbacks);
}
void Unlink() {
FrameRequestManagerBase::Unlink();
mVideoCallbacks.Clear();
}
void 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 Take(nsTArray<RefPtr<HTMLVideoElement>>&);
void Unlink();
void Traverse(nsCycleCollectionTraversalCallback&);
private:
nsTArray<RefPtr<HTMLVideoElement>> mVideoCallbacks;

View File

@ -322,6 +322,7 @@ if CONFIG["COMPILE_ENVIRONMENT"]:
UNIFIED_SOURCES += [
"!UseCounterMetrics.cpp",
"AbstractRange.cpp",
"AnimationFrameProvider.cpp",
"AnonymousContent.cpp",
"Attr.cpp",
"AttrArray.cpp",