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 nsTreeSelection_h__ 8 #define nsTreeSelection_h__ 9 10 #include "nsITreeSelection.h" 11 #include "nsITimer.h" 12 #include "nsCycleCollectionParticipant.h" 13 #include "mozilla/Attributes.h" 14 #include "XULTreeElement.h" 15 16 class nsTreeColumn; 17 struct nsTreeRange; 18 19 class nsTreeSelection final : public nsINativeTreeSelection { 20 public: 21 explicit nsTreeSelection(mozilla::dom::XULTreeElement* aTree); 22 23 NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeSelection)24 NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeSelection) 25 NS_DECL_NSITREESELECTION 26 27 // nsINativeTreeSelection: Untrusted code can use us 28 NS_IMETHOD EnsureNative() override { return NS_OK; } 29 30 friend struct nsTreeRange; 31 32 protected: 33 ~nsTreeSelection(); 34 35 nsresult FireOnSelectHandler(); 36 static void SelectCallback(nsITimer* aTimer, void* aClosure); 37 38 protected: 39 // The tree will hold on to us through the view and let go when it dies. 40 RefPtr<mozilla::dom::XULTreeElement> mTree; 41 42 bool mSuppressed; // Whether or not we should be firing onselect events. 43 int32_t mCurrentIndex; // The item to draw the rect around. The last one 44 // clicked, etc. 45 int32_t mShiftSelectPivot; // Used when multiple SHIFT+selects are performed 46 // to pivot on. 47 48 nsTreeRange* mFirstRange; // Our list of ranges. 49 50 nsCOMPtr<nsITimer> mSelectTimer; 51 }; 52 53 nsresult NS_NewTreeSelection(mozilla::dom::XULTreeElement* aTree, 54 nsITreeSelection** aResult); 55 56 #endif 57