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 34 // nsIMutationObserver 35 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED 36 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED 37 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED 38 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED 39 NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED 40 41 protected: 42 virtual ~inDOMView(); 43 44 nsCOMPtr<nsITreeBoxObject> mTree; 45 nsCOMPtr<nsITreeSelection> mSelection; 46 nsCOMPtr<inIDOMUtils> mDOMUtils; 47 48 bool mShowAnonymous; 49 bool mShowSubDocuments; 50 bool mShowWhitespaceNodes; 51 bool mShowAccessibleNodes; 52 uint32_t mWhatToShow; 53 54 nsCOMPtr<nsIDOMNode> mRootNode; 55 nsCOMPtr<nsIDOMDocument> mRootDocument; 56 57 nsTArray<inDOMViewNode*> mNodes; 58 59 inDOMViewNode* GetNodeAt(int32_t aIndex); 60 int32_t GetRowCount(); 61 int32_t NodeToRow(inDOMViewNode* aNode); 62 bool RowOutOfBounds(int32_t aRow, int32_t aCount); 63 inDOMViewNode* CreateNode(nsIDOMNode* aNode, inDOMViewNode* aParent); 64 void AppendNode(inDOMViewNode* aNode); 65 void InsertNode(inDOMViewNode* aNode, int32_t aIndex); 66 void RemoveNode(int32_t aIndex); 67 void ReplaceNode(inDOMViewNode* aNode, int32_t aIndex); 68 void InsertNodes(nsTArray<inDOMViewNode*>& aNodes, int32_t aIndex); 69 void RemoveNodes(int32_t aIndex, int32_t aCount); 70 void RemoveAllNodes(); 71 void ExpandNode(int32_t aRow); 72 void CollapseNode(int32_t aRow); 73 74 nsresult RowToNode(int32_t aRow, inDOMViewNode** aNode); 75 nsresult NodeToRow(nsIDOMNode* aNode, int32_t* aRow); 76 77 void InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter); 78 void InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore); 79 void RemoveLink(inDOMViewNode* aNode); 80 void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode); 81 82 nsresult GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult); 83 nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsCOMArray<nsIDOMNode>& aArray); 84 nsresult AppendAttrsToArray(nsIDOMMozNamedAttrMap* aKids, nsCOMArray<nsIDOMNode>& aArray); 85 nsresult GetFirstDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult); 86 nsresult GetLastDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult); 87 nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling); 88 }; 89 90 // {FB5C1775-1BBD-4b9c-ABB0-AE7ACD29E87E} 91 #define IN_DOMVIEW_CID \ 92 { 0xfb5c1775, 0x1bbd, 0x4b9c, { 0xab, 0xb0, 0xae, 0x7a, 0xcd, 0x29, 0xe8, 0x7e } } 93 94 #endif // __inDOMView_h__ 95 96 97