Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsTreeColumns_h__ |
michael@0 | 7 | #define nsTreeColumns_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsITreeColumns.h" |
michael@0 | 10 | #include "nsITreeBoxObject.h" |
michael@0 | 11 | #include "mozilla/Attributes.h" |
michael@0 | 12 | #include "nsCoord.h" |
michael@0 | 13 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 14 | #include "nsAutoPtr.h" |
michael@0 | 15 | #include "nsWrapperCache.h" |
michael@0 | 16 | #include "nsString.h" |
michael@0 | 17 | |
michael@0 | 18 | class nsTreeBodyFrame; |
michael@0 | 19 | class nsTreeColumns; |
michael@0 | 20 | class nsIFrame; |
michael@0 | 21 | class nsIContent; |
michael@0 | 22 | struct nsRect; |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | namespace dom { |
michael@0 | 26 | class Element; |
michael@0 | 27 | } // namespace dom |
michael@0 | 28 | } // namespace mozilla |
michael@0 | 29 | |
michael@0 | 30 | #define NS_TREECOLUMN_IMPL_CID \ |
michael@0 | 31 | { /* 02cd1963-4b5d-4a6c-9223-814d3ade93a3 */ \ |
michael@0 | 32 | 0x02cd1963, \ |
michael@0 | 33 | 0x4b5d, \ |
michael@0 | 34 | 0x4a6c, \ |
michael@0 | 35 | {0x92, 0x23, 0x81, 0x4d, 0x3a, 0xde, 0x93, 0xa3} \ |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | // This class is our column info. We use it to iterate our columns and to obtain |
michael@0 | 39 | // information about each column. |
michael@0 | 40 | class nsTreeColumn MOZ_FINAL : public nsITreeColumn { |
michael@0 | 41 | public: |
michael@0 | 42 | nsTreeColumn(nsTreeColumns* aColumns, nsIContent* aContent); |
michael@0 | 43 | ~nsTreeColumn(); |
michael@0 | 44 | |
michael@0 | 45 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID) |
michael@0 | 46 | |
michael@0 | 47 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 48 | NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeColumn) |
michael@0 | 49 | NS_DECL_NSITREECOLUMN |
michael@0 | 50 | |
michael@0 | 51 | friend class nsTreeBodyFrame; |
michael@0 | 52 | friend class nsTreeColumns; |
michael@0 | 53 | |
michael@0 | 54 | protected: |
michael@0 | 55 | nsIFrame* GetFrame(); |
michael@0 | 56 | nsIFrame* GetFrame(nsTreeBodyFrame* aBodyFrame); |
michael@0 | 57 | // Don't call this if GetWidthInTwips or GetRect fails |
michael@0 | 58 | bool IsLastVisible(nsTreeBodyFrame* aBodyFrame); |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Returns a rect with x and width taken from the frame's rect and specified |
michael@0 | 62 | * y and height. May fail in case there's no frame for the column. |
michael@0 | 63 | */ |
michael@0 | 64 | nsresult GetRect(nsTreeBodyFrame* aBodyFrame, nscoord aY, nscoord aHeight, |
michael@0 | 65 | nsRect* aResult); |
michael@0 | 66 | |
michael@0 | 67 | nsresult GetXInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult); |
michael@0 | 68 | nsresult GetWidthInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult); |
michael@0 | 69 | |
michael@0 | 70 | void SetColumns(nsTreeColumns* aColumns) { mColumns = aColumns; } |
michael@0 | 71 | |
michael@0 | 72 | const nsAString& GetId() { return mId; } |
michael@0 | 73 | nsIAtom* GetAtom() { return mAtom; } |
michael@0 | 74 | |
michael@0 | 75 | int32_t GetIndex() { return mIndex; } |
michael@0 | 76 | |
michael@0 | 77 | bool IsPrimary() { return mIsPrimary; } |
michael@0 | 78 | bool IsCycler() { return mIsCycler; } |
michael@0 | 79 | bool IsEditable() { return mIsEditable; } |
michael@0 | 80 | bool IsSelectable() { return mIsSelectable; } |
michael@0 | 81 | bool Overflow() { return mOverflow; } |
michael@0 | 82 | |
michael@0 | 83 | int16_t GetType() { return mType; } |
michael@0 | 84 | |
michael@0 | 85 | int8_t GetCropStyle() { return mCropStyle; } |
michael@0 | 86 | int32_t GetTextAlignment() { return mTextAlignment; } |
michael@0 | 87 | |
michael@0 | 88 | nsTreeColumn* GetNext() { return mNext; } |
michael@0 | 89 | nsTreeColumn* GetPrevious() { return mPrevious; } |
michael@0 | 90 | void SetNext(nsTreeColumn* aNext) { |
michael@0 | 91 | NS_ASSERTION(!mNext, "already have a next sibling"); |
michael@0 | 92 | mNext = aNext; |
michael@0 | 93 | } |
michael@0 | 94 | void SetPrevious(nsTreeColumn* aPrevious) { mPrevious = aPrevious; } |
michael@0 | 95 | |
michael@0 | 96 | private: |
michael@0 | 97 | /** |
michael@0 | 98 | * Non-null nsIContent for the associated <treecol> element. |
michael@0 | 99 | */ |
michael@0 | 100 | nsCOMPtr<nsIContent> mContent; |
michael@0 | 101 | |
michael@0 | 102 | nsTreeColumns* mColumns; |
michael@0 | 103 | |
michael@0 | 104 | nsString mId; |
michael@0 | 105 | nsCOMPtr<nsIAtom> mAtom; |
michael@0 | 106 | |
michael@0 | 107 | int32_t mIndex; |
michael@0 | 108 | |
michael@0 | 109 | bool mIsPrimary; |
michael@0 | 110 | bool mIsCycler; |
michael@0 | 111 | bool mIsEditable; |
michael@0 | 112 | bool mIsSelectable; |
michael@0 | 113 | bool mOverflow; |
michael@0 | 114 | |
michael@0 | 115 | int16_t mType; |
michael@0 | 116 | |
michael@0 | 117 | int8_t mCropStyle; |
michael@0 | 118 | int8_t mTextAlignment; |
michael@0 | 119 | |
michael@0 | 120 | nsRefPtr<nsTreeColumn> mNext; |
michael@0 | 121 | nsTreeColumn* mPrevious; |
michael@0 | 122 | }; |
michael@0 | 123 | |
michael@0 | 124 | NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeColumn, NS_TREECOLUMN_IMPL_CID) |
michael@0 | 125 | |
michael@0 | 126 | class nsTreeColumns MOZ_FINAL : public nsITreeColumns |
michael@0 | 127 | , public nsWrapperCache |
michael@0 | 128 | { |
michael@0 | 129 | public: |
michael@0 | 130 | nsTreeColumns(nsTreeBodyFrame* aTree); |
michael@0 | 131 | ~nsTreeColumns(); |
michael@0 | 132 | |
michael@0 | 133 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 134 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumns) |
michael@0 | 135 | NS_DECL_NSITREECOLUMNS |
michael@0 | 136 | |
michael@0 | 137 | nsIContent* GetParentObject() const; |
michael@0 | 138 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 139 | |
michael@0 | 140 | // WebIDL |
michael@0 | 141 | nsITreeBoxObject* GetTree() const; |
michael@0 | 142 | uint32_t Count(); |
michael@0 | 143 | uint32_t Length() |
michael@0 | 144 | { |
michael@0 | 145 | return Count(); |
michael@0 | 146 | } |
michael@0 | 147 | |
michael@0 | 148 | nsTreeColumn* GetFirstColumn() { EnsureColumns(); return mFirstColumn; } |
michael@0 | 149 | nsTreeColumn* GetLastColumn(); |
michael@0 | 150 | |
michael@0 | 151 | nsTreeColumn* GetPrimaryColumn(); |
michael@0 | 152 | nsTreeColumn* GetSortedColumn(); |
michael@0 | 153 | nsTreeColumn* GetKeyColumn(); |
michael@0 | 154 | |
michael@0 | 155 | nsTreeColumn* GetColumnFor(mozilla::dom::Element* aElement); |
michael@0 | 156 | |
michael@0 | 157 | nsTreeColumn* IndexedGetter(uint32_t aIndex, bool& aFound); |
michael@0 | 158 | nsTreeColumn* GetColumnAt(uint32_t aIndex); |
michael@0 | 159 | nsTreeColumn* NamedGetter(const nsAString& aId, bool& aFound); |
michael@0 | 160 | bool NameIsEnumerable(const nsAString& aName); |
michael@0 | 161 | nsTreeColumn* GetNamedColumn(const nsAString& aId); |
michael@0 | 162 | void GetSupportedNames(unsigned, nsTArray<nsString>& aNames); |
michael@0 | 163 | |
michael@0 | 164 | // Uses XPCOM InvalidateColumns(). |
michael@0 | 165 | // Uses XPCOM RestoreNaturalOrder(). |
michael@0 | 166 | |
michael@0 | 167 | friend class nsTreeBodyFrame; |
michael@0 | 168 | protected: |
michael@0 | 169 | void SetTree(nsTreeBodyFrame* aTree) { mTree = aTree; } |
michael@0 | 170 | |
michael@0 | 171 | // Builds our cache of column info. |
michael@0 | 172 | void EnsureColumns(); |
michael@0 | 173 | |
michael@0 | 174 | private: |
michael@0 | 175 | nsTreeBodyFrame* mTree; |
michael@0 | 176 | |
michael@0 | 177 | /** |
michael@0 | 178 | * The first column in the list of columns. All of the columns are supposed |
michael@0 | 179 | * to be "alive", i.e. have a frame. This is achieved by clearing the columns |
michael@0 | 180 | * list each time an nsTreeColFrame is destroyed. |
michael@0 | 181 | * |
michael@0 | 182 | * XXX this means that new nsTreeColumn objects are unnecessarily created |
michael@0 | 183 | * for untouched columns. |
michael@0 | 184 | */ |
michael@0 | 185 | nsTreeColumn* mFirstColumn; |
michael@0 | 186 | }; |
michael@0 | 187 | |
michael@0 | 188 | #endif // nsTreeColumns_h__ |