nsXULCommandDispatcher.h (2126B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 /* 7 8 This is the focus manager for XUL documents. 9 10 */ 11 12 #ifndef nsXULCommandDispatcher_h__ 13 #define nsXULCommandDispatcher_h__ 14 15 #include "mozilla/RefPtr.h" 16 #include "nsCOMPtr.h" 17 #include "nsCycleCollectionParticipant.h" 18 #include "nsIDOMXULCommandDispatcher.h" 19 #include "nsString.h" 20 #include "nsTArray.h" 21 #include "nsWeakReference.h" 22 23 class nsPIDOMWindowOuter; 24 class nsPIWindowRoot; 25 26 namespace mozilla::dom { 27 class Document; 28 class Element; 29 } // namespace mozilla::dom 30 31 class nsXULCommandDispatcher : public nsIDOMXULCommandDispatcher, 32 public nsSupportsWeakReference { 33 using Document = mozilla::dom::Document; 34 using Element = mozilla::dom::Element; 35 36 public: 37 explicit nsXULCommandDispatcher(Document* aDocument); 38 39 // nsISupports 40 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 41 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXULCommandDispatcher, 42 nsIDOMXULCommandDispatcher) 43 44 // nsIDOMXULCommandDispatcher interface 45 NS_DECL_NSIDOMXULCOMMANDDISPATCHER 46 47 void Disconnect(); 48 49 protected: 50 virtual ~nsXULCommandDispatcher(); 51 52 already_AddRefed<nsPIWindowRoot> GetWindowRoot(); 53 54 Element* GetRootFocusedContentAndWindow(nsPIDOMWindowOuter** aWindow); 55 nsresult MoveFocusIntoSubtree(Element*, bool aForward); 56 57 RefPtr<Document> mDocument; 58 59 class Updater { 60 public: 61 Updater(Element* aElement, const nsAString& aEvents, 62 const nsAString& aTargets) 63 : mElement(aElement), 64 mEvents(aEvents), 65 mTargets(aTargets), 66 mNext(nullptr) {} 67 68 RefPtr<Element> mElement; 69 nsString mEvents; 70 nsString mTargets; 71 Updater* mNext; 72 }; 73 74 Updater* mUpdaters; 75 76 bool Matches(const nsString& aList, const nsAString& aElement); 77 78 bool mLocked; 79 nsTArray<nsString> mPendingUpdates; 80 }; 81 82 #endif // nsXULCommandDispatcher_h__