michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsTreeImageListener_h__ michael@0: #define nsTreeImageListener_h__ michael@0: michael@0: #include "nsString.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsITreeColumns.h" michael@0: #include "nsTreeBodyFrame.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: // This class handles image load observation. michael@0: class nsTreeImageListener MOZ_FINAL : public imgINotificationObserver michael@0: { michael@0: public: michael@0: nsTreeImageListener(nsTreeBodyFrame *aTreeFrame); michael@0: ~nsTreeImageListener(); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_IMGINOTIFICATIONOBSERVER michael@0: michael@0: NS_IMETHOD ClearFrame(); michael@0: michael@0: friend class nsTreeBodyFrame; michael@0: michael@0: protected: michael@0: void UnsuppressInvalidation() { mInvalidationSuppressed = false; } michael@0: void Invalidate(); michael@0: void AddCell(int32_t aIndex, nsITreeColumn* aCol); michael@0: michael@0: private: michael@0: nsTreeBodyFrame* mTreeFrame; michael@0: michael@0: // A guard that prevents us from recursive painting. michael@0: bool mInvalidationSuppressed; michael@0: michael@0: class InvalidationArea { michael@0: public: michael@0: InvalidationArea(nsITreeColumn* aCol); michael@0: ~InvalidationArea() { delete mNext; } michael@0: michael@0: friend class nsTreeImageListener; michael@0: michael@0: protected: michael@0: void AddRow(int32_t aIndex); michael@0: nsITreeColumn* GetCol() { return mCol.get(); } michael@0: int32_t GetMin() { return mMin; } michael@0: int32_t GetMax() { return mMax; } michael@0: InvalidationArea* GetNext() { return mNext; } michael@0: void SetNext(InvalidationArea* aNext) { mNext = aNext; } michael@0: michael@0: private: michael@0: nsCOMPtr mCol; michael@0: int32_t mMin; michael@0: int32_t mMax; michael@0: InvalidationArea* mNext; michael@0: }; michael@0: michael@0: InvalidationArea* mInvalidationArea; michael@0: }; michael@0: michael@0: #endif // nsTreeImageListener_h__