Skip to content

Commit 4ecaba1

Browse files
committed
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 rust-lang/rust-bindgen#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
1 parent b4e311c commit 4ecaba1

File tree

3 files changed

+56
-34
lines changed

3 files changed

+56
-34
lines changed

dom/base/AnimationFrameProvider.cpp

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2+
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3+
/* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6+
7+
#include "AnimationFrameProvider.h"
8+
#include "MainThreadUtils.h"
9+
#include "mozilla/Assertions.h"
10+
#include "mozilla/dom/HTMLVideoElement.h"
11+
12+
namespace mozilla::dom {
13+
14+
FrameRequestManager::FrameRequestManager() = default;
15+
FrameRequestManager::~FrameRequestManager() = default;
16+
17+
void FrameRequestManager::Schedule(HTMLVideoElement* aElement) {
18+
if (!mVideoCallbacks.Contains(aElement)) {
19+
mVideoCallbacks.AppendElement(aElement);
20+
}
21+
}
22+
23+
bool FrameRequestManager::Cancel(HTMLVideoElement* aElement) {
24+
return mVideoCallbacks.RemoveElement(aElement);
25+
}
26+
27+
void FrameRequestManager::Unlink() {
28+
FrameRequestManagerBase::Unlink();
29+
mVideoCallbacks.Clear();
30+
}
31+
32+
void FrameRequestManager::Traverse(nsCycleCollectionTraversalCallback& aCB) {
33+
FrameRequestManagerBase::Traverse(aCB);
34+
for (auto& i : mVideoCallbacks) {
35+
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(
36+
aCB, "FrameRequestManager::mVideoCallbacks[i]");
37+
aCB.NoteXPCOMChild(ToSupports(i));
38+
}
39+
}
40+
void FrameRequestManager::Take(
41+
nsTArray<RefPtr<HTMLVideoElement>>& aVideoCallbacks) {
42+
MOZ_ASSERT(NS_IsMainThread());
43+
aVideoCallbacks = std::move(mVideoCallbacks);
44+
}
45+
46+
} // namespace mozilla::dom

dom/base/AnimationFrameProvider.h

+9-34
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,33 @@
77
#ifndef mozilla_dom_AnimationFrameProvider_h
88
#define mozilla_dom_AnimationFrameProvider_h
99

10-
#include "MainThreadUtils.h"
11-
#include "mozilla/Assertions.h"
1210
#include "mozilla/dom/AnimationFrameProviderBinding.h"
13-
#include "mozilla/dom/HTMLVideoElement.h"
1411
#include "mozilla/dom/RequestCallbackManager.h"
1512

1613
namespace mozilla::dom {
1714

15+
class HTMLVideoElement;
16+
1817
using FrameRequest = RequestCallbackEntry<FrameRequestCallback>;
1918
using FrameRequestManagerBase = RequestCallbackManager<FrameRequestCallback>;
2019

2120
class FrameRequestManager final : public FrameRequestManagerBase {
2221
public:
23-
FrameRequestManager() = default;
24-
~FrameRequestManager() = default;
22+
FrameRequestManager();
23+
~FrameRequestManager();
2524

2625
using FrameRequestManagerBase::Cancel;
2726
using FrameRequestManagerBase::Schedule;
2827
using FrameRequestManagerBase::Take;
2928

30-
void Schedule(HTMLVideoElement* aElement) {
31-
if (!mVideoCallbacks.Contains(aElement)) {
32-
mVideoCallbacks.AppendElement(aElement);
33-
}
34-
}
35-
36-
bool Cancel(HTMLVideoElement* aElement) {
37-
return mVideoCallbacks.RemoveElement(aElement);
38-
}
39-
29+
void Schedule(HTMLVideoElement*);
30+
bool Cancel(HTMLVideoElement*);
4031
bool IsEmpty() const {
4132
return FrameRequestManagerBase::IsEmpty() && mVideoCallbacks.IsEmpty();
4233
}
43-
44-
void Take(nsTArray<RefPtr<HTMLVideoElement>>& aVideoCallbacks) {
45-
MOZ_ASSERT(NS_IsMainThread());
46-
aVideoCallbacks = std::move(mVideoCallbacks);
47-
}
48-
49-
void Unlink() {
50-
FrameRequestManagerBase::Unlink();
51-
mVideoCallbacks.Clear();
52-
}
53-
54-
void Traverse(nsCycleCollectionTraversalCallback& aCB) {
55-
FrameRequestManagerBase::Traverse(aCB);
56-
for (auto& i : mVideoCallbacks) {
57-
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(
58-
aCB, "FrameRequestManager::mVideoCallbacks[i]");
59-
aCB.NoteXPCOMChild(ToSupports(i));
60-
}
61-
}
34+
void Take(nsTArray<RefPtr<HTMLVideoElement>>&);
35+
void Unlink();
36+
void Traverse(nsCycleCollectionTraversalCallback&);
6237

6338
private:
6439
nsTArray<RefPtr<HTMLVideoElement>> mVideoCallbacks;

dom/base/moz.build

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ if CONFIG["COMPILE_ENVIRONMENT"]:
322322
UNIFIED_SOURCES += [
323323
"!UseCounterMetrics.cpp",
324324
"AbstractRange.cpp",
325+
"AnimationFrameProvider.cpp",
325326
"AnonymousContent.cpp",
326327
"Attr.cpp",
327328
"AttrArray.cpp",

0 commit comments

Comments
 (0)