|
1 /*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
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 file, |
|
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef NSDISPLAYLISTINVALIDATION_H_ |
|
7 #define NSDISPLAYLISTINVALIDATION_H_ |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsRect.h" |
|
11 #include "nsColor.h" |
|
12 |
|
13 class nsDisplayItem; |
|
14 class nsDisplayListBuilder; |
|
15 class nsDisplayBackgroundImage; |
|
16 class nsDisplayThemedBackground; |
|
17 |
|
18 /** |
|
19 * This stores the geometry of an nsDisplayItem, and the area |
|
20 * that will be affected when painting the item. |
|
21 * |
|
22 * It is used to retain information about display items so they |
|
23 * can be compared against new display items in the next paint. |
|
24 */ |
|
25 class nsDisplayItemGeometry |
|
26 { |
|
27 public: |
|
28 nsDisplayItemGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); |
|
29 virtual ~nsDisplayItemGeometry(); |
|
30 |
|
31 /** |
|
32 * Compute the area required to be invalidated if this |
|
33 * display item is removed. |
|
34 */ |
|
35 const nsRect& ComputeInvalidationRegion() { return mBounds; } |
|
36 |
|
37 /** |
|
38 * Shifts all retained areas of the nsDisplayItemGeometry by the given offset. |
|
39 * |
|
40 * This is used to compensate for scrolling, since the destination buffer |
|
41 * can scroll without requiring a full repaint. |
|
42 * |
|
43 * @param aOffset Offset to shift by. |
|
44 */ |
|
45 virtual void MoveBy(const nsPoint& aOffset) = 0; |
|
46 |
|
47 /** |
|
48 * Bounds of the display item |
|
49 */ |
|
50 nsRect mBounds; |
|
51 }; |
|
52 |
|
53 /** |
|
54 * A default geometry implementation, used by nsDisplayItem. Retains |
|
55 * and compares the bounds, and border rect. |
|
56 * |
|
57 * This should be sufficient for the majority of display items. |
|
58 */ |
|
59 class nsDisplayItemGenericGeometry : public nsDisplayItemGeometry |
|
60 { |
|
61 public: |
|
62 nsDisplayItemGenericGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); |
|
63 |
|
64 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; |
|
65 |
|
66 nsRect mBorderRect; |
|
67 }; |
|
68 |
|
69 class nsDisplayItemBoundsGeometry : public nsDisplayItemGeometry |
|
70 { |
|
71 public: |
|
72 nsDisplayItemBoundsGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); |
|
73 |
|
74 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; |
|
75 |
|
76 bool mHasRoundedCorners; |
|
77 }; |
|
78 |
|
79 class nsDisplayBorderGeometry : public nsDisplayItemGeometry |
|
80 { |
|
81 public: |
|
82 nsDisplayBorderGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); |
|
83 |
|
84 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; |
|
85 |
|
86 nsRect mContentRect; |
|
87 }; |
|
88 |
|
89 class nsDisplayBackgroundGeometry : public nsDisplayItemGeometry |
|
90 { |
|
91 public: |
|
92 nsDisplayBackgroundGeometry(nsDisplayBackgroundImage* aItem, nsDisplayListBuilder* aBuilder); |
|
93 |
|
94 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; |
|
95 |
|
96 nsRect mPositioningArea; |
|
97 }; |
|
98 |
|
99 class nsDisplayThemedBackgroundGeometry : public nsDisplayItemGeometry |
|
100 { |
|
101 public: |
|
102 nsDisplayThemedBackgroundGeometry(nsDisplayThemedBackground* aItem, nsDisplayListBuilder* aBuilder); |
|
103 |
|
104 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; |
|
105 |
|
106 nsRect mPositioningArea; |
|
107 bool mWindowIsActive; |
|
108 }; |
|
109 |
|
110 class nsDisplayBoxShadowInnerGeometry : public nsDisplayItemGeometry |
|
111 { |
|
112 public: |
|
113 nsDisplayBoxShadowInnerGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); |
|
114 |
|
115 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; |
|
116 |
|
117 nsRect mPaddingRect; |
|
118 }; |
|
119 |
|
120 class nsDisplaySolidColorGeometry : public nsDisplayItemBoundsGeometry |
|
121 { |
|
122 public: |
|
123 nsDisplaySolidColorGeometry(nsDisplayItem* aItem, |
|
124 nsDisplayListBuilder* aBuilder, |
|
125 nscolor aColor) |
|
126 : nsDisplayItemBoundsGeometry(aItem, aBuilder) |
|
127 , mColor(aColor) |
|
128 { } |
|
129 |
|
130 nscolor mColor; |
|
131 }; |
|
132 |
|
133 #endif /*NSDISPLAYLISTINVALIDATION_H_*/ |