1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 2003
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Dave Hyatt <hyatt@mozilla.org> (Original Author)
24 : * Jan Varga <varga@ku.sk>
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef nsTreeImageListener_h__
41 : #define nsTreeImageListener_h__
42 :
43 : #include "nsString.h"
44 : #include "nsCOMPtr.h"
45 : #include "nsITreeColumns.h"
46 : #include "nsStubImageDecoderObserver.h"
47 : #include "nsTreeBodyFrame.h"
48 :
49 : // This class handles image load observation.
50 : class nsTreeImageListener : public nsStubImageDecoderObserver
51 : {
52 : public:
53 : nsTreeImageListener(nsTreeBodyFrame *aTreeFrame);
54 : ~nsTreeImageListener();
55 :
56 : NS_DECL_ISUPPORTS
57 : // imgIDecoderObserver (override nsStubImageDecoderObserver)
58 : NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
59 : NS_IMETHOD OnImageIsAnimated(imgIRequest* aRequest);
60 : NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, bool aCurrentFrame,
61 : const nsIntRect *aRect);
62 : // imgIContainerObserver (override nsStubImageDecoderObserver)
63 : NS_IMETHOD FrameChanged(imgIRequest *aRequest,
64 : imgIContainer *aContainer,
65 : const nsIntRect *aDirtyRect);
66 :
67 : NS_IMETHOD ClearFrame();
68 :
69 : friend class nsTreeBodyFrame;
70 :
71 : protected:
72 0 : void UnsuppressInvalidation() { mInvalidationSuppressed = false; }
73 : void Invalidate();
74 : void AddCell(PRInt32 aIndex, nsITreeColumn* aCol);
75 :
76 : private:
77 : nsTreeBodyFrame* mTreeFrame;
78 :
79 : // A guard that prevents us from recursive painting.
80 : bool mInvalidationSuppressed;
81 :
82 : class InvalidationArea {
83 : public:
84 : InvalidationArea(nsITreeColumn* aCol);
85 0 : ~InvalidationArea() { delete mNext; }
86 :
87 : friend class nsTreeImageListener;
88 :
89 : protected:
90 : void AddRow(PRInt32 aIndex);
91 0 : nsITreeColumn* GetCol() { return mCol.get(); }
92 0 : PRInt32 GetMin() { return mMin; }
93 0 : PRInt32 GetMax() { return mMax; }
94 0 : InvalidationArea* GetNext() { return mNext; }
95 0 : void SetNext(InvalidationArea* aNext) { mNext = aNext; }
96 :
97 : private:
98 : nsCOMPtr<nsITreeColumn> mCol;
99 : PRInt32 mMin;
100 : PRInt32 mMax;
101 : InvalidationArea* mNext;
102 : };
103 :
104 : InvalidationArea* mInvalidationArea;
105 : };
106 :
107 : #endif // nsTreeImageListener_h__
|