michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsTreeContentView_h__ michael@0: #define nsTreeContentView_h__ michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsTArray.h" michael@0: #include "nsStubDocumentObserver.h" michael@0: #include "nsITreeBoxObject.h" michael@0: #include "nsITreeColumns.h" michael@0: #include "nsITreeView.h" michael@0: #include "nsITreeContentView.h" michael@0: #include "nsITreeSelection.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsIDocument; michael@0: class Row; michael@0: michael@0: nsresult NS_NewTreeContentView(nsITreeView** aResult); michael@0: michael@0: class nsTreeContentView MOZ_FINAL : public nsINativeTreeView, michael@0: public nsITreeContentView, michael@0: public nsStubDocumentObserver michael@0: { michael@0: public: michael@0: nsTreeContentView(void); michael@0: michael@0: ~nsTreeContentView(void); michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTreeContentView, michael@0: nsINativeTreeView) michael@0: michael@0: NS_DECL_NSITREEVIEW michael@0: // nsINativeTreeView: Untrusted code can use us michael@0: NS_IMETHOD EnsureNative() MOZ_OVERRIDE { return NS_OK; } michael@0: michael@0: NS_DECL_NSITREECONTENTVIEW michael@0: michael@0: // nsIDocumentObserver michael@0: NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED michael@0: NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED michael@0: michael@0: static bool CanTrustTreeSelection(nsISupports* aValue); michael@0: michael@0: protected: michael@0: // Recursive methods which deal with serializing of nested content. michael@0: void Serialize(nsIContent* aContent, int32_t aParentIndex, int32_t* aIndex, michael@0: nsTArray >& aRows); michael@0: michael@0: void SerializeItem(nsIContent* aContent, int32_t aParentIndex, michael@0: int32_t* aIndex, nsTArray >& aRows); michael@0: michael@0: void SerializeSeparator(nsIContent* aContent, int32_t aParentIndex, michael@0: int32_t* aIndex, nsTArray >& aRows); michael@0: michael@0: void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, int32_t* aResult); michael@0: michael@0: // Helper methods which we use to manage our plain array of rows. michael@0: int32_t EnsureSubtree(int32_t aIndex); michael@0: michael@0: int32_t RemoveSubtree(int32_t aIndex); michael@0: michael@0: int32_t InsertRow(int32_t aParentIndex, int32_t aIndex, nsIContent* aContent); michael@0: michael@0: void InsertRowFor(nsIContent* aParent, nsIContent* aChild); michael@0: michael@0: int32_t RemoveRow(int32_t aIndex); michael@0: michael@0: void ClearRows(); michael@0: michael@0: void OpenContainer(int32_t aIndex); michael@0: michael@0: void CloseContainer(int32_t aIndex); michael@0: michael@0: int32_t FindContent(nsIContent* aContent); michael@0: michael@0: void UpdateSubtreeSizes(int32_t aIndex, int32_t aCount); michael@0: michael@0: void UpdateParentIndexes(int32_t aIndex, int32_t aSkip, int32_t aCount); michael@0: michael@0: // Content helpers. michael@0: nsIContent* GetCell(nsIContent* aContainer, nsITreeColumn* aCol); michael@0: michael@0: private: michael@0: nsCOMPtr mBoxObject; michael@0: nsCOMPtr mSelection; michael@0: nsCOMPtr mRoot; michael@0: nsCOMPtr mBody; michael@0: nsIDocument* mDocument; // WEAK michael@0: nsTArray > mRows; michael@0: }; michael@0: michael@0: #endif // nsTreeContentView_h__