layout/xul/tree/nsTreeContentView.h

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

mercurial