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 file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef NSDISPLAYLISTINVALIDATION_H_ michael@0: #define NSDISPLAYLISTINVALIDATION_H_ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsRect.h" michael@0: #include "nsColor.h" michael@0: michael@0: class nsDisplayItem; michael@0: class nsDisplayListBuilder; michael@0: class nsDisplayBackgroundImage; michael@0: class nsDisplayThemedBackground; michael@0: michael@0: /** michael@0: * This stores the geometry of an nsDisplayItem, and the area michael@0: * that will be affected when painting the item. michael@0: * michael@0: * It is used to retain information about display items so they michael@0: * can be compared against new display items in the next paint. michael@0: */ michael@0: class nsDisplayItemGeometry michael@0: { michael@0: public: michael@0: nsDisplayItemGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); michael@0: virtual ~nsDisplayItemGeometry(); michael@0: michael@0: /** michael@0: * Compute the area required to be invalidated if this michael@0: * display item is removed. michael@0: */ michael@0: const nsRect& ComputeInvalidationRegion() { return mBounds; } michael@0: michael@0: /** michael@0: * Shifts all retained areas of the nsDisplayItemGeometry by the given offset. michael@0: * michael@0: * This is used to compensate for scrolling, since the destination buffer michael@0: * can scroll without requiring a full repaint. michael@0: * michael@0: * @param aOffset Offset to shift by. michael@0: */ michael@0: virtual void MoveBy(const nsPoint& aOffset) = 0; michael@0: michael@0: /** michael@0: * Bounds of the display item michael@0: */ michael@0: nsRect mBounds; michael@0: }; michael@0: michael@0: /** michael@0: * A default geometry implementation, used by nsDisplayItem. Retains michael@0: * and compares the bounds, and border rect. michael@0: * michael@0: * This should be sufficient for the majority of display items. michael@0: */ michael@0: class nsDisplayItemGenericGeometry : public nsDisplayItemGeometry michael@0: { michael@0: public: michael@0: nsDisplayItemGenericGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); michael@0: michael@0: virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; michael@0: michael@0: nsRect mBorderRect; michael@0: }; michael@0: michael@0: class nsDisplayItemBoundsGeometry : public nsDisplayItemGeometry michael@0: { michael@0: public: michael@0: nsDisplayItemBoundsGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); michael@0: michael@0: virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; michael@0: michael@0: bool mHasRoundedCorners; michael@0: }; michael@0: michael@0: class nsDisplayBorderGeometry : public nsDisplayItemGeometry michael@0: { michael@0: public: michael@0: nsDisplayBorderGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); michael@0: michael@0: virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; michael@0: michael@0: nsRect mContentRect; michael@0: }; michael@0: michael@0: class nsDisplayBackgroundGeometry : public nsDisplayItemGeometry michael@0: { michael@0: public: michael@0: nsDisplayBackgroundGeometry(nsDisplayBackgroundImage* aItem, nsDisplayListBuilder* aBuilder); michael@0: michael@0: virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; michael@0: michael@0: nsRect mPositioningArea; michael@0: }; michael@0: michael@0: class nsDisplayThemedBackgroundGeometry : public nsDisplayItemGeometry michael@0: { michael@0: public: michael@0: nsDisplayThemedBackgroundGeometry(nsDisplayThemedBackground* aItem, nsDisplayListBuilder* aBuilder); michael@0: michael@0: virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; michael@0: michael@0: nsRect mPositioningArea; michael@0: bool mWindowIsActive; michael@0: }; michael@0: michael@0: class nsDisplayBoxShadowInnerGeometry : public nsDisplayItemGeometry michael@0: { michael@0: public: michael@0: nsDisplayBoxShadowInnerGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); michael@0: michael@0: virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; michael@0: michael@0: nsRect mPaddingRect; michael@0: }; michael@0: michael@0: class nsDisplaySolidColorGeometry : public nsDisplayItemBoundsGeometry michael@0: { michael@0: public: michael@0: nsDisplaySolidColorGeometry(nsDisplayItem* aItem, michael@0: nsDisplayListBuilder* aBuilder, michael@0: nscolor aColor) michael@0: : nsDisplayItemBoundsGeometry(aItem, aBuilder) michael@0: , mColor(aColor) michael@0: { } michael@0: michael@0: nscolor mColor; michael@0: }; michael@0: michael@0: #endif /*NSDISPLAYLISTINVALIDATION_H_*/