1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/base/nsDisplayListInvalidation.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,133 @@ 1.4 +/*-*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef NSDISPLAYLISTINVALIDATION_H_ 1.10 +#define NSDISPLAYLISTINVALIDATION_H_ 1.11 + 1.12 +#include "mozilla/Attributes.h" 1.13 +#include "nsRect.h" 1.14 +#include "nsColor.h" 1.15 + 1.16 +class nsDisplayItem; 1.17 +class nsDisplayListBuilder; 1.18 +class nsDisplayBackgroundImage; 1.19 +class nsDisplayThemedBackground; 1.20 + 1.21 +/** 1.22 + * This stores the geometry of an nsDisplayItem, and the area 1.23 + * that will be affected when painting the item. 1.24 + * 1.25 + * It is used to retain information about display items so they 1.26 + * can be compared against new display items in the next paint. 1.27 + */ 1.28 +class nsDisplayItemGeometry 1.29 +{ 1.30 +public: 1.31 + nsDisplayItemGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); 1.32 + virtual ~nsDisplayItemGeometry(); 1.33 + 1.34 + /** 1.35 + * Compute the area required to be invalidated if this 1.36 + * display item is removed. 1.37 + */ 1.38 + const nsRect& ComputeInvalidationRegion() { return mBounds; } 1.39 + 1.40 + /** 1.41 + * Shifts all retained areas of the nsDisplayItemGeometry by the given offset. 1.42 + * 1.43 + * This is used to compensate for scrolling, since the destination buffer 1.44 + * can scroll without requiring a full repaint. 1.45 + * 1.46 + * @param aOffset Offset to shift by. 1.47 + */ 1.48 + virtual void MoveBy(const nsPoint& aOffset) = 0; 1.49 + 1.50 + /** 1.51 + * Bounds of the display item 1.52 + */ 1.53 + nsRect mBounds; 1.54 +}; 1.55 + 1.56 +/** 1.57 + * A default geometry implementation, used by nsDisplayItem. Retains 1.58 + * and compares the bounds, and border rect. 1.59 + * 1.60 + * This should be sufficient for the majority of display items. 1.61 + */ 1.62 +class nsDisplayItemGenericGeometry : public nsDisplayItemGeometry 1.63 +{ 1.64 +public: 1.65 + nsDisplayItemGenericGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); 1.66 + 1.67 + virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; 1.68 + 1.69 + nsRect mBorderRect; 1.70 +}; 1.71 + 1.72 +class nsDisplayItemBoundsGeometry : public nsDisplayItemGeometry 1.73 +{ 1.74 +public: 1.75 + nsDisplayItemBoundsGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); 1.76 + 1.77 + virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; 1.78 + 1.79 + bool mHasRoundedCorners; 1.80 +}; 1.81 + 1.82 +class nsDisplayBorderGeometry : public nsDisplayItemGeometry 1.83 +{ 1.84 +public: 1.85 + nsDisplayBorderGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); 1.86 + 1.87 + virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; 1.88 + 1.89 + nsRect mContentRect; 1.90 +}; 1.91 + 1.92 +class nsDisplayBackgroundGeometry : public nsDisplayItemGeometry 1.93 +{ 1.94 +public: 1.95 + nsDisplayBackgroundGeometry(nsDisplayBackgroundImage* aItem, nsDisplayListBuilder* aBuilder); 1.96 + 1.97 + virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; 1.98 + 1.99 + nsRect mPositioningArea; 1.100 +}; 1.101 + 1.102 +class nsDisplayThemedBackgroundGeometry : public nsDisplayItemGeometry 1.103 +{ 1.104 +public: 1.105 + nsDisplayThemedBackgroundGeometry(nsDisplayThemedBackground* aItem, nsDisplayListBuilder* aBuilder); 1.106 + 1.107 + virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; 1.108 + 1.109 + nsRect mPositioningArea; 1.110 + bool mWindowIsActive; 1.111 +}; 1.112 + 1.113 +class nsDisplayBoxShadowInnerGeometry : public nsDisplayItemGeometry 1.114 +{ 1.115 +public: 1.116 + nsDisplayBoxShadowInnerGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder); 1.117 + 1.118 + virtual void MoveBy(const nsPoint& aOffset) MOZ_OVERRIDE; 1.119 + 1.120 + nsRect mPaddingRect; 1.121 +}; 1.122 + 1.123 +class nsDisplaySolidColorGeometry : public nsDisplayItemBoundsGeometry 1.124 +{ 1.125 +public: 1.126 + nsDisplaySolidColorGeometry(nsDisplayItem* aItem, 1.127 + nsDisplayListBuilder* aBuilder, 1.128 + nscolor aColor) 1.129 + : nsDisplayItemBoundsGeometry(aItem, aBuilder) 1.130 + , mColor(aColor) 1.131 + { } 1.132 + 1.133 + nscolor mColor; 1.134 +}; 1.135 + 1.136 +#endif /*NSDISPLAYLISTINVALIDATION_H_*/