layout/xul/tree/nsTreeContentView.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsTreeContentView_h__
     7 #define nsTreeContentView_h__
     9 #include "nsAutoPtr.h"
    10 #include "nsCycleCollectionParticipant.h"
    11 #include "nsTArray.h"
    12 #include "nsStubDocumentObserver.h"
    13 #include "nsITreeBoxObject.h"
    14 #include "nsITreeColumns.h"
    15 #include "nsITreeView.h"
    16 #include "nsITreeContentView.h"
    17 #include "nsITreeSelection.h"
    18 #include "mozilla/Attributes.h"
    20 class nsIDocument;
    21 class Row;
    23 nsresult NS_NewTreeContentView(nsITreeView** aResult);
    25 class nsTreeContentView MOZ_FINAL : public nsINativeTreeView,
    26                                     public nsITreeContentView,
    27                                     public nsStubDocumentObserver
    28 {
    29   public:
    30     nsTreeContentView(void);
    32     ~nsTreeContentView(void);
    34     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    35     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTreeContentView,
    36                                              nsINativeTreeView)
    38     NS_DECL_NSITREEVIEW
    39     // nsINativeTreeView: Untrusted code can use us
    40     NS_IMETHOD EnsureNative() MOZ_OVERRIDE { return NS_OK; }
    42     NS_DECL_NSITREECONTENTVIEW
    44     // nsIDocumentObserver
    45     NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
    46     NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
    47     NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
    48     NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
    49     NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
    51     static bool CanTrustTreeSelection(nsISupports* aValue);
    53   protected:
    54     // Recursive methods which deal with serializing of nested content.
    55     void Serialize(nsIContent* aContent, int32_t aParentIndex, int32_t* aIndex,
    56                    nsTArray<nsAutoPtr<Row> >& aRows);
    58     void SerializeItem(nsIContent* aContent, int32_t aParentIndex,
    59                        int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows);
    61     void SerializeSeparator(nsIContent* aContent, int32_t aParentIndex,
    62                             int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows);
    64     void GetIndexInSubtree(nsIContent* aContainer, nsIContent* aContent, int32_t* aResult);
    66     // Helper methods which we use to manage our plain array of rows.
    67     int32_t EnsureSubtree(int32_t aIndex);
    69     int32_t RemoveSubtree(int32_t aIndex);
    71     int32_t InsertRow(int32_t aParentIndex, int32_t aIndex, nsIContent* aContent);
    73     void InsertRowFor(nsIContent* aParent, nsIContent* aChild);
    75     int32_t RemoveRow(int32_t aIndex);
    77     void ClearRows();
    79     void OpenContainer(int32_t aIndex);
    81     void CloseContainer(int32_t aIndex);
    83     int32_t FindContent(nsIContent* aContent);
    85     void UpdateSubtreeSizes(int32_t aIndex, int32_t aCount);
    87     void UpdateParentIndexes(int32_t aIndex, int32_t aSkip, int32_t aCount);
    89     // Content helpers.
    90     nsIContent* GetCell(nsIContent* aContainer, nsITreeColumn* aCol);
    92   private:
    93     nsCOMPtr<nsITreeBoxObject>          mBoxObject;
    94     nsCOMPtr<nsITreeSelection>          mSelection;
    95     nsCOMPtr<nsIContent>                mRoot;
    96     nsCOMPtr<nsIContent>                mBody;
    97     nsIDocument*                        mDocument;      // WEAK
    98     nsTArray<nsAutoPtr<Row> >           mRows;
    99 };
   101 #endif // nsTreeContentView_h__

mercurial