Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
6 #ifndef NSDISPLAYLISTINVALIDATION_H_
7 #define NSDISPLAYLISTINVALIDATION_H_
9 #include "mozilla/Attributes.h"
10 #include "nsRect.h"
11 #include "nsColor.h"
13 class nsDisplayItem;
14 class nsDisplayListBuilder;
15 class nsDisplayBackgroundImage;
16 class nsDisplayThemedBackground;
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();
31 /**
32 * Compute the area required to be invalidated if this
33 * display item is removed.
34 */
35 const nsRect& ComputeInvalidationRegion() { return mBounds; }
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;
47 /**
48 * Bounds of the display item
49 */
50 nsRect mBounds;
51 };
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);
64 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE;
66 nsRect mBorderRect;
67 };
69 class nsDisplayItemBoundsGeometry : public nsDisplayItemGeometry
70 {
71 public:
72 nsDisplayItemBoundsGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
74 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE;
76 bool mHasRoundedCorners;
77 };
79 class nsDisplayBorderGeometry : public nsDisplayItemGeometry
80 {
81 public:
82 nsDisplayBorderGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
84 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE;
86 nsRect mContentRect;
87 };
89 class nsDisplayBackgroundGeometry : public nsDisplayItemGeometry
90 {
91 public:
92 nsDisplayBackgroundGeometry(nsDisplayBackgroundImage* aItem, nsDisplayListBuilder* aBuilder);
94 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE;
96 nsRect mPositioningArea;
97 };
99 class nsDisplayThemedBackgroundGeometry : public nsDisplayItemGeometry
100 {
101 public:
102 nsDisplayThemedBackgroundGeometry(nsDisplayThemedBackground* aItem, nsDisplayListBuilder* aBuilder);
104 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE;
106 nsRect mPositioningArea;
107 bool mWindowIsActive;
108 };
110 class nsDisplayBoxShadowInnerGeometry : public nsDisplayItemGeometry
111 {
112 public:
113 nsDisplayBoxShadowInnerGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
115 virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE;
117 nsRect mPaddingRect;
118 };
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 { }
130 nscolor mColor;
131 };
133 #endif /*NSDISPLAYLISTINVALIDATION_H_*/