1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/tree/nsTreeContentView.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsTreeContentView_h__ 1.10 +#define nsTreeContentView_h__ 1.11 + 1.12 +#include "nsAutoPtr.h" 1.13 +#include "nsCycleCollectionParticipant.h" 1.14 +#include "nsTArray.h" 1.15 +#include "nsStubDocumentObserver.h" 1.16 +#include "nsITreeBoxObject.h" 1.17 +#include "nsITreeColumns.h" 1.18 +#include "nsITreeView.h" 1.19 +#include "nsITreeContentView.h" 1.20 +#include "nsITreeSelection.h" 1.21 +#include "mozilla/Attributes.h" 1.22 + 1.23 +class nsIDocument; 1.24 +class Row; 1.25 + 1.26 +nsresult NS_NewTreeContentView(nsITreeView** aResult); 1.27 + 1.28 +class nsTreeContentView MOZ_FINAL : public nsINativeTreeView, 1.29 + public nsITreeContentView, 1.30 + public nsStubDocumentObserver 1.31 +{ 1.32 + public: 1.33 + nsTreeContentView(void); 1.34 + 1.35 + ~nsTreeContentView(void); 1.36 + 1.37 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.38 + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTreeContentView, 1.39 + nsINativeTreeView) 1.40 + 1.41 + NS_DECL_NSITREEVIEW 1.42 + // nsINativeTreeView: Untrusted code can use us 1.43 + NS_IMETHOD EnsureNative() MOZ_OVERRIDE { return NS_OK; } 1.44 + 1.45 + NS_DECL_NSITREECONTENTVIEW 1.46 + 1.47 + // nsIDocumentObserver 1.48 + NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED 1.49 + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED 1.50 + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED 1.51 + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED 1.52 + NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED 1.53 + 1.54 + static bool CanTrustTreeSelection(nsISupports* aValue); 1.55 + 1.56 + protected: 1.57 + // Recursive methods which deal with serializing of nested content. 1.58 + void Serialize(nsIContent* aContent, int32_t aParentIndex, int32_t* aIndex, 1.59 + nsTArray<nsAutoPtr<Row> >& aRows); 1.60 + 1.61 + void SerializeItem(nsIContent* aContent, int32_t aParentIndex, 1.62 + int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows); 1.63 + 1.64 + void SerializeSeparator(nsIContent* aContent, int32_t aParentIndex, 1.65 + int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows); 1.66 + 1.67 + void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, int32_t* aResult); 1.68 + 1.69 + // Helper methods which we use to manage our plain array of rows. 1.70 + int32_t EnsureSubtree(int32_t aIndex); 1.71 + 1.72 + int32_t RemoveSubtree(int32_t aIndex); 1.73 + 1.74 + int32_t InsertRow(int32_t aParentIndex, int32_t aIndex, nsIContent* aContent); 1.75 + 1.76 + void InsertRowFor(nsIContent* aParent, nsIContent* aChild); 1.77 + 1.78 + int32_t RemoveRow(int32_t aIndex); 1.79 + 1.80 + void ClearRows(); 1.81 + 1.82 + void OpenContainer(int32_t aIndex); 1.83 + 1.84 + void CloseContainer(int32_t aIndex); 1.85 + 1.86 + int32_t FindContent(nsIContent* aContent); 1.87 + 1.88 + void UpdateSubtreeSizes(int32_t aIndex, int32_t aCount); 1.89 + 1.90 + void UpdateParentIndexes(int32_t aIndex, int32_t aSkip, int32_t aCount); 1.91 + 1.92 + // Content helpers. 1.93 + nsIContent* GetCell(nsIContent* aContainer, nsITreeColumn* aCol); 1.94 + 1.95 + private: 1.96 + nsCOMPtr<nsITreeBoxObject> mBoxObject; 1.97 + nsCOMPtr<nsITreeSelection> mSelection; 1.98 + nsCOMPtr<nsIContent> mRoot; 1.99 + nsCOMPtr<nsIContent> mBody; 1.100 + nsIDocument* mDocument; // WEAK 1.101 + nsTArray<nsAutoPtr<Row> > mRows; 1.102 +}; 1.103 + 1.104 +#endif // nsTreeContentView_h__