Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsTreeContentView_h__ |
michael@0 | 7 | #define nsTreeContentView_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsAutoPtr.h" |
michael@0 | 10 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 11 | #include "nsTArray.h" |
michael@0 | 12 | #include "nsStubDocumentObserver.h" |
michael@0 | 13 | #include "nsITreeBoxObject.h" |
michael@0 | 14 | #include "nsITreeColumns.h" |
michael@0 | 15 | #include "nsITreeView.h" |
michael@0 | 16 | #include "nsITreeContentView.h" |
michael@0 | 17 | #include "nsITreeSelection.h" |
michael@0 | 18 | #include "mozilla/Attributes.h" |
michael@0 | 19 | |
michael@0 | 20 | class nsIDocument; |
michael@0 | 21 | class Row; |
michael@0 | 22 | |
michael@0 | 23 | nsresult NS_NewTreeContentView(nsITreeView** aResult); |
michael@0 | 24 | |
michael@0 | 25 | class nsTreeContentView MOZ_FINAL : public nsINativeTreeView, |
michael@0 | 26 | public nsITreeContentView, |
michael@0 | 27 | public nsStubDocumentObserver |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | nsTreeContentView(void); |
michael@0 | 31 | |
michael@0 | 32 | ~nsTreeContentView(void); |
michael@0 | 33 | |
michael@0 | 34 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 35 | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTreeContentView, |
michael@0 | 36 | nsINativeTreeView) |
michael@0 | 37 | |
michael@0 | 38 | NS_DECL_NSITREEVIEW |
michael@0 | 39 | // nsINativeTreeView: Untrusted code can use us |
michael@0 | 40 | NS_IMETHOD EnsureNative() MOZ_OVERRIDE { return NS_OK; } |
michael@0 | 41 | |
michael@0 | 42 | NS_DECL_NSITREECONTENTVIEW |
michael@0 | 43 | |
michael@0 | 44 | // nsIDocumentObserver |
michael@0 | 45 | NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED |
michael@0 | 46 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED |
michael@0 | 47 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED |
michael@0 | 48 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED |
michael@0 | 49 | NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED |
michael@0 | 50 | |
michael@0 | 51 | static bool CanTrustTreeSelection(nsISupports* aValue); |
michael@0 | 52 | |
michael@0 | 53 | protected: |
michael@0 | 54 | // Recursive methods which deal with serializing of nested content. |
michael@0 | 55 | void Serialize(nsIContent* aContent, int32_t aParentIndex, int32_t* aIndex, |
michael@0 | 56 | nsTArray<nsAutoPtr<Row> >& aRows); |
michael@0 | 57 | |
michael@0 | 58 | void SerializeItem(nsIContent* aContent, int32_t aParentIndex, |
michael@0 | 59 | int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows); |
michael@0 | 60 | |
michael@0 | 61 | void SerializeSeparator(nsIContent* aContent, int32_t aParentIndex, |
michael@0 | 62 | int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows); |
michael@0 | 63 | |
michael@0 | 64 | void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, int32_t* aResult); |
michael@0 | 65 | |
michael@0 | 66 | // Helper methods which we use to manage our plain array of rows. |
michael@0 | 67 | int32_t EnsureSubtree(int32_t aIndex); |
michael@0 | 68 | |
michael@0 | 69 | int32_t RemoveSubtree(int32_t aIndex); |
michael@0 | 70 | |
michael@0 | 71 | int32_t InsertRow(int32_t aParentIndex, int32_t aIndex, nsIContent* aContent); |
michael@0 | 72 | |
michael@0 | 73 | void InsertRowFor(nsIContent* aParent, nsIContent* aChild); |
michael@0 | 74 | |
michael@0 | 75 | int32_t RemoveRow(int32_t aIndex); |
michael@0 | 76 | |
michael@0 | 77 | void ClearRows(); |
michael@0 | 78 | |
michael@0 | 79 | void OpenContainer(int32_t aIndex); |
michael@0 | 80 | |
michael@0 | 81 | void CloseContainer(int32_t aIndex); |
michael@0 | 82 | |
michael@0 | 83 | int32_t FindContent(nsIContent* aContent); |
michael@0 | 84 | |
michael@0 | 85 | void UpdateSubtreeSizes(int32_t aIndex, int32_t aCount); |
michael@0 | 86 | |
michael@0 | 87 | void UpdateParentIndexes(int32_t aIndex, int32_t aSkip, int32_t aCount); |
michael@0 | 88 | |
michael@0 | 89 | // Content helpers. |
michael@0 | 90 | nsIContent* GetCell(nsIContent* aContainer, nsITreeColumn* aCol); |
michael@0 | 91 | |
michael@0 | 92 | private: |
michael@0 | 93 | nsCOMPtr<nsITreeBoxObject> mBoxObject; |
michael@0 | 94 | nsCOMPtr<nsITreeSelection> mSelection; |
michael@0 | 95 | nsCOMPtr<nsIContent> mRoot; |
michael@0 | 96 | nsCOMPtr<nsIContent> mBody; |
michael@0 | 97 | nsIDocument* mDocument; // WEAK |
michael@0 | 98 | nsTArray<nsAutoPtr<Row> > mRows; |
michael@0 | 99 | }; |
michael@0 | 100 | |
michael@0 | 101 | #endif // nsTreeContentView_h__ |