PopupQueue.h (1358B)
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 PopupQueue_h 8 #define PopupQueue_h 9 10 #include "mozilla/MoveOnlyFunction.h" 11 #include "nsTArray.h" 12 13 namespace mozilla::dom { 14 class Element; 15 } 16 17 class PopupQueue final { 18 NS_INLINE_DECL_REFCOUNTING(PopupQueue) 19 20 typedef class mozilla::dom::Element Element; 21 22 public: 23 PopupQueue() = default; 24 25 void Enqueue(Element* aPopup, 26 mozilla::MoveOnlyFunction<void(Element*)>&& aCallback); 27 28 void Show(Element* aPopup, 29 mozilla::MoveOnlyFunction<void(Element*)>&& aCallback); 30 31 void NotifyDismissed(Element* aPopup, bool aRemoveAll = false); 32 33 Element* RetrieveQueueableShownPopup() const; 34 35 private: 36 ~PopupQueue() = default; 37 38 bool Store(Element* aPopup, bool aShown, 39 mozilla::MoveOnlyFunction<void(Element*)>&& aCallback); 40 41 struct PendingPopup { 42 RefPtr<Element> mPopup; 43 bool mQueueable; 44 bool mShown; 45 mozilla::MoveOnlyFunction<void(Element*)> mCallback; 46 }; 47 48 void MaybeShowNext(); 49 50 nsTArray<PendingPopup> mQueue; 51 uint32_t mShowing = 0; 52 }; 53 54 #endif // PopupQueue_h