AnimationFrameProvider.cpp (1488B)
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 9 #include "MainThreadUtils.h" 10 #include "mozilla/Assertions.h" 11 #include "mozilla/dom/HTMLVideoElement.h" 12 13 namespace mozilla::dom { 14 15 FrameRequestManager::FrameRequestManager() = default; 16 FrameRequestManager::~FrameRequestManager() = default; 17 18 void FrameRequestManager::Schedule(HTMLVideoElement* aElement) { 19 if (!mVideoCallbacks.Contains(aElement)) { 20 mVideoCallbacks.AppendElement(aElement); 21 } 22 } 23 24 bool FrameRequestManager::Cancel(HTMLVideoElement* aElement) { 25 return mVideoCallbacks.RemoveElement(aElement); 26 } 27 28 void FrameRequestManager::Unlink() { 29 FrameRequestManagerBase::Unlink(); 30 mVideoCallbacks.Clear(); 31 } 32 33 void FrameRequestManager::Traverse(nsCycleCollectionTraversalCallback& aCB) { 34 FrameRequestManagerBase::Traverse(aCB); 35 for (auto& i : mVideoCallbacks) { 36 NS_CYCLE_COLLECTION_NOTE_EDGE_NAME( 37 aCB, "FrameRequestManager::mVideoCallbacks[i]"); 38 aCB.NoteXPCOMChild(ToSupports(i)); 39 } 40 } 41 void FrameRequestManager::Take( 42 nsTArray<RefPtr<HTMLVideoElement>>& aVideoCallbacks) { 43 MOZ_ASSERT(NS_IsMainThread()); 44 aVideoCallbacks = std::move(mVideoCallbacks); 45 } 46 47 } // namespace mozilla::dom