1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef nsTreeImageListener_h__ 8 #define nsTreeImageListener_h__ 9 10 #include "nsString.h" 11 #include "nsCOMPtr.h" 12 #include "nsTreeBodyFrame.h" 13 #include "mozilla/Attributes.h" 14 15 class nsTreeColumn; 16 17 // This class handles image load observation. 18 class nsTreeImageListener final : public imgINotificationObserver { 19 public: 20 explicit nsTreeImageListener(nsTreeBodyFrame* aTreeFrame); 21 22 NS_DECL_ISUPPORTS 23 NS_DECL_IMGINOTIFICATIONOBSERVER 24 25 NS_IMETHOD ClearFrame(); 26 27 friend class nsTreeBodyFrame; 28 29 protected: 30 ~nsTreeImageListener(); 31 UnsuppressInvalidation()32 void UnsuppressInvalidation() { mInvalidationSuppressed = false; } 33 void Invalidate(); 34 void AddCell(int32_t aIndex, nsTreeColumn* aCol); 35 36 private: 37 nsTreeBodyFrame* mTreeFrame; 38 39 // A guard that prevents us from recursive painting. 40 bool mInvalidationSuppressed; 41 42 class InvalidationArea { 43 public: 44 explicit InvalidationArea(nsTreeColumn* aCol); ~InvalidationArea()45 ~InvalidationArea() { delete mNext; } 46 47 friend class nsTreeImageListener; 48 49 protected: 50 void AddRow(int32_t aIndex); GetCol()51 nsTreeColumn* GetCol() { return mCol.get(); } GetMin()52 int32_t GetMin() { return mMin; } GetMax()53 int32_t GetMax() { return mMax; } GetNext()54 InvalidationArea* GetNext() { return mNext; } SetNext(InvalidationArea * aNext)55 void SetNext(InvalidationArea* aNext) { mNext = aNext; } 56 57 private: 58 RefPtr<nsTreeColumn> mCol; 59 int32_t mMin; 60 int32_t mMax; 61 InvalidationArea* mNext; 62 }; 63 64 InvalidationArea* mInvalidationArea; 65 }; 66 67 #endif // nsTreeImageListener_h__ 68