|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef __inDOMView_h__ |
|
6 #define __inDOMView_h__ |
|
7 |
|
8 #include "inIDOMView.h" |
|
9 #include "inIDOMUtils.h" |
|
10 |
|
11 #include "nsITreeView.h" |
|
12 #include "nsITreeSelection.h" |
|
13 #include "nsStubMutationObserver.h" |
|
14 #include "nsIDOMNode.h" |
|
15 #include "nsIDOMDocument.h" |
|
16 #include "nsTArray.h" |
|
17 #include "nsCOMArray.h" |
|
18 #include "nsCOMPtr.h" |
|
19 |
|
20 class inDOMViewNode; |
|
21 class nsIDOMMozNamedAttrMap; |
|
22 |
|
23 class inDOMView : public inIDOMView, |
|
24 public nsITreeView, |
|
25 public nsStubMutationObserver |
|
26 { |
|
27 public: |
|
28 NS_DECL_ISUPPORTS |
|
29 NS_DECL_INIDOMVIEW |
|
30 NS_DECL_NSITREEVIEW |
|
31 |
|
32 inDOMView(); |
|
33 virtual ~inDOMView(); |
|
34 |
|
35 // nsIMutationObserver |
|
36 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED |
|
37 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED |
|
38 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED |
|
39 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED |
|
40 NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED |
|
41 |
|
42 protected: |
|
43 nsCOMPtr<nsITreeBoxObject> mTree; |
|
44 nsCOMPtr<nsITreeSelection> mSelection; |
|
45 nsCOMPtr<inIDOMUtils> mDOMUtils; |
|
46 |
|
47 bool mShowAnonymous; |
|
48 bool mShowSubDocuments; |
|
49 bool mShowWhitespaceNodes; |
|
50 bool mShowAccessibleNodes; |
|
51 uint32_t mWhatToShow; |
|
52 |
|
53 nsCOMPtr<nsIDOMNode> mRootNode; |
|
54 nsCOMPtr<nsIDOMDocument> mRootDocument; |
|
55 |
|
56 nsTArray<inDOMViewNode*> mNodes; |
|
57 |
|
58 inDOMViewNode* GetNodeAt(int32_t aIndex); |
|
59 int32_t GetRowCount(); |
|
60 int32_t NodeToRow(inDOMViewNode* aNode); |
|
61 bool RowOutOfBounds(int32_t aRow, int32_t aCount); |
|
62 inDOMViewNode* CreateNode(nsIDOMNode* aNode, inDOMViewNode* aParent); |
|
63 void AppendNode(inDOMViewNode* aNode); |
|
64 void InsertNode(inDOMViewNode* aNode, int32_t aIndex); |
|
65 void RemoveNode(int32_t aIndex); |
|
66 void ReplaceNode(inDOMViewNode* aNode, int32_t aIndex); |
|
67 void InsertNodes(nsTArray<inDOMViewNode*>& aNodes, int32_t aIndex); |
|
68 void RemoveNodes(int32_t aIndex, int32_t aCount); |
|
69 void RemoveAllNodes(); |
|
70 void ExpandNode(int32_t aRow); |
|
71 void CollapseNode(int32_t aRow); |
|
72 |
|
73 nsresult RowToNode(int32_t aRow, inDOMViewNode** aNode); |
|
74 nsresult NodeToRow(nsIDOMNode* aNode, int32_t* aRow); |
|
75 |
|
76 void InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter); |
|
77 void InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore); |
|
78 void RemoveLink(inDOMViewNode* aNode); |
|
79 void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode); |
|
80 |
|
81 nsresult GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult); |
|
82 nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsCOMArray<nsIDOMNode>& aArray); |
|
83 nsresult AppendAttrsToArray(nsIDOMMozNamedAttrMap* aKids, nsCOMArray<nsIDOMNode>& aArray); |
|
84 nsresult GetFirstDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult); |
|
85 nsresult GetLastDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult); |
|
86 nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling); |
|
87 }; |
|
88 |
|
89 // {FB5C1775-1BBD-4b9c-ABB0-AE7ACD29E87E} |
|
90 #define IN_DOMVIEW_CID \ |
|
91 { 0xfb5c1775, 0x1bbd, 0x4b9c, { 0xab, 0xb0, 0xae, 0x7a, 0xcd, 0x29, 0xe8, 0x7e } } |
|
92 |
|
93 #endif // __inDOMView_h__ |
|
94 |
|
95 |