AnimationFrameProvider.h (1332B)
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 #ifndef mozilla_dom_AnimationFrameProvider_h 8 #define mozilla_dom_AnimationFrameProvider_h 9 10 #include "mozilla/dom/AnimationFrameProviderBinding.h" 11 #include "mozilla/dom/RequestCallbackManager.h" 12 13 namespace mozilla::dom { 14 15 class HTMLVideoElement; 16 17 using FrameRequest = RequestCallbackEntry<FrameRequestCallback>; 18 using FrameRequestManagerBase = RequestCallbackManager<FrameRequestCallback>; 19 20 class FrameRequestManager final : public FrameRequestManagerBase { 21 public: 22 FrameRequestManager(); 23 ~FrameRequestManager(); 24 25 using FrameRequestManagerBase::Cancel; 26 using FrameRequestManagerBase::Schedule; 27 28 void Schedule(HTMLVideoElement*); 29 bool Cancel(HTMLVideoElement*); 30 bool IsEmpty() const { 31 return FrameRequestManagerBase::IsEmpty() && mVideoCallbacks.IsEmpty(); 32 } 33 void Take(nsTArray<RefPtr<HTMLVideoElement>>&); 34 void Unlink(); 35 void Traverse(nsCycleCollectionTraversalCallback&); 36 37 private: 38 nsTArray<RefPtr<HTMLVideoElement>> mVideoCallbacks; 39 }; 40 41 } // namespace mozilla::dom 42 43 #endif