2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsTreeContentView_h__
|
|
|
|
#define nsTreeContentView_h__
|
|
|
|
|
2013-04-15 16:14:43 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2013-03-21 17:05:20 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2009-02-03 06:42:18 -08:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsStubDocumentObserver.h"
|
|
|
|
#include "nsITreeBoxObject.h"
|
|
|
|
#include "nsITreeColumns.h"
|
|
|
|
#include "nsITreeView.h"
|
|
|
|
#include "nsITreeContentView.h"
|
|
|
|
#include "nsITreeSelection.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-21 17:05:19 -07:00
|
|
|
class nsIDocument;
|
2009-02-03 06:42:18 -08:00
|
|
|
class Row;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult NS_NewTreeContentView(nsITreeView** aResult);
|
|
|
|
|
2012-06-18 19:30:09 -07:00
|
|
|
class nsTreeContentView MOZ_FINAL : public nsINativeTreeView,
|
|
|
|
public nsITreeContentView,
|
|
|
|
public nsStubDocumentObserver
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsTreeContentView(void);
|
|
|
|
|
|
|
|
~nsTreeContentView(void);
|
|
|
|
|
2009-08-21 05:50:15 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTreeContentView,
|
|
|
|
nsINativeTreeView)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_NSITREEVIEW
|
|
|
|
// nsINativeTreeView: Untrusted code can use us
|
|
|
|
NS_IMETHOD EnsureNative() { return NS_OK; }
|
|
|
|
|
|
|
|
NS_DECL_NSITREECONTENTVIEW
|
|
|
|
|
|
|
|
// nsIDocumentObserver
|
2007-07-12 13:05:45 -07:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool CanTrustTreeSelection(nsISupports* aValue);
|
2010-07-31 11:22:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
// Recursive methods which deal with serializing of nested content.
|
2012-08-22 08:56:38 -07:00
|
|
|
void Serialize(nsIContent* aContent, int32_t aParentIndex, int32_t* aIndex,
|
2013-04-15 16:14:43 -07:00
|
|
|
nsTArray<nsAutoPtr<Row> >& aRows);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SerializeItem(nsIContent* aContent, int32_t aParentIndex,
|
2013-04-15 16:14:43 -07:00
|
|
|
int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SerializeSeparator(nsIContent* aContent, int32_t aParentIndex,
|
2013-04-15 16:14:43 -07:00
|
|
|
int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, int32_t* aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Helper methods which we use to manage our plain array of rows.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t EnsureSubtree(int32_t aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t RemoveSubtree(int32_t aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t InsertRow(int32_t aParentIndex, int32_t aIndex, nsIContent* aContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void InsertRowFor(nsIContent* aParent, nsIContent* aChild);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t RemoveRow(int32_t aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void ClearRows();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void OpenContainer(int32_t aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void CloseContainer(int32_t aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t FindContent(nsIContent* aContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void UpdateSubtreeSizes(int32_t aIndex, int32_t aCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void UpdateParentIndexes(int32_t aIndex, int32_t aSkip, int32_t aCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Content helpers.
|
|
|
|
nsIContent* GetCell(nsIContent* aContainer, nsITreeColumn* aCol);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsITreeBoxObject> mBoxObject;
|
|
|
|
nsCOMPtr<nsITreeSelection> mSelection;
|
|
|
|
nsCOMPtr<nsIContent> mRoot;
|
2007-05-17 13:55:03 -07:00
|
|
|
nsCOMPtr<nsIContent> mBody;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDocument* mDocument; // WEAK
|
2013-04-15 16:14:43 -07:00
|
|
|
nsTArray<nsAutoPtr<Row> > mRows;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsTreeContentView_h__
|