Back to index

lightning-sunbird  0.9+nobinonly
inDOMView.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Joe Hewitt <hewitt@netscape.com> (original author)
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef __inDOMView_h__
00039 #define __inDOMView_h__
00040 
00041 #include "inIDOMView.h"
00042 #include "inIDOMUtils.h"
00043 
00044 #include "nsITreeView.h"
00045 #include "nsITreeSelection.h"
00046 #include "nsIDocumentObserver.h"
00047 #include "nsIDOMNode.h"
00048 #include "nsIDOMDocument.h"
00049 #include "nsVoidArray.h"
00050 #include "nsCOMArray.h"
00051 #include "nsStaticAtom.h"
00052 
00053 class inDOMViewNode;
00054 
00055 class inDOMView : public inIDOMView,
00056                   public nsITreeView,
00057                   public nsIDocumentObserver
00058 {
00059 public:
00060   NS_DECL_ISUPPORTS
00061   NS_DECL_INIDOMVIEW
00062   NS_DECL_NSITREEVIEW
00063 
00064   inDOMView();
00065   virtual ~inDOMView();
00066 
00067   // nsIDocumentObserver
00068   NS_DECL_NSIDOCUMENTOBSERVER
00069 
00070   static void InitAtoms();
00071 
00072 protected:
00073   static nsIAtom* kAnonymousAtom;
00074   static nsIAtom* kElementNodeAtom;
00075   static nsIAtom* kAttributeNodeAtom;
00076   static nsIAtom* kTextNodeAtom;
00077   static nsIAtom* kCDataSectionNodeAtom;
00078   static nsIAtom* kEntityReferenceNodeAtom;
00079   static nsIAtom* kEntityNodeAtom;
00080   static nsIAtom* kProcessingInstructionNodeAtom;
00081   static nsIAtom* kCommentNodeAtom;
00082   static nsIAtom* kDocumentNodeAtom;
00083   static nsIAtom* kDocumentTypeNodeAtom;
00084   static nsIAtom* kDocumentFragmentNodeAtom;
00085   static nsIAtom* kNotationNodeAtom;
00086 
00087   static const nsStaticAtom Atoms_info[]; 
00088 
00089   nsCOMPtr<nsITreeBoxObject> mTree;
00090   nsCOMPtr<nsITreeSelection> mSelection;
00091   nsCOMPtr<inIDOMUtils> mDOMUtils;
00092 
00093   PRPackedBool mShowAnonymous;
00094   PRPackedBool mShowSubDocuments;
00095   PRPackedBool mShowWhitespaceNodes;
00096   PRUint32 mWhatToShow;
00097 
00098   nsCOMPtr<nsIDOMNode> mRootNode;
00099   nsCOMPtr<nsIDOMDocument> mRootDocument;
00100 
00101   nsVoidArray mNodes;
00102 
00103   inDOMViewNode* GetNodeAt(PRInt32 aIndex);
00104   PRInt32 GetRowCount();
00105   PRBool RowOutOfBounds(PRInt32 aRow, PRInt32 aCount);
00106   inDOMViewNode* CreateNode(nsIDOMNode* aNode, inDOMViewNode* aParent);
00107   void AppendNode(inDOMViewNode* aNode);
00108   void InsertNode(inDOMViewNode* aNode, PRInt32 aIndex);
00109   void RemoveNode(PRInt32 aIndex);
00110   void ReplaceNode(inDOMViewNode* aNode, PRInt32 aIndex);
00111   void InsertNodes(nsVoidArray& aNodes, PRInt32 aIndex);
00112   void RemoveNodes(PRInt32 aIndex, PRInt32 aCount);
00113   void RemoveAllNodes();
00114   void ExpandNode(PRInt32 aRow);
00115   void CollapseNode(PRInt32 aRow);
00116 
00117   nsresult RowToNode(PRInt32 aRow, inDOMViewNode** aNode);
00118   nsresult NodeToRow(nsIDOMNode* aNode, PRInt32* aRow);
00119 
00120   void InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter);
00121   void InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore);
00122   void RemoveLink(inDOMViewNode* aNode);
00123   void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode);
00124 
00125   nsresult GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult);
00126   nsresult AppendKidsToArray(nsIDOMNodeList* aKids, nsCOMArray<nsIDOMNode>& aArray);
00127   nsresult AppendAttrsToArray(nsIDOMNamedNodeMap* aKids, nsCOMArray<nsIDOMNode>& aArray);
00128   nsresult GetFirstDescendantOf(inDOMViewNode* aNode, PRInt32 aRow, PRInt32* aResult);
00129   nsresult GetLastDescendantOf(inDOMViewNode* aNode, PRInt32 aRow, PRInt32* aResult);
00130   nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling);
00131 };
00132 
00133 // {FB5C1775-1BBD-4b9c-ABB0-AE7ACD29E87E}
00134 #define IN_DOMVIEW_CID \
00135 { 0xfb5c1775, 0x1bbd, 0x4b9c, { 0xab, 0xb0, 0xae, 0x7a, 0xcd, 0x29, 0xe8, 0x7e } }
00136 
00137 #endif // __inDOMView_h__
00138 
00139