1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef StyleDifference_h
6 #define StyleDifference_h
8 #include "wtf/Allocator.h"
9 #include "wtf/Assertions.h"
13 class StyleDifference
{
16 enum PropertyDifference
{
17 TransformChanged
= 1 << 0,
18 OpacityChanged
= 1 << 1,
19 ZIndexChanged
= 1 << 2,
20 FilterChanged
= 1 << 3,
21 BackdropFilterChanged
= 1 << 4,
22 // The object needs to issue paint invalidations if it contains text or properties dependent on color (e.g., border or outline).
23 TextOrColorChanged
= 1 << 5,
24 // If you add a value here, be sure to update the number of bits on m_propertySpecificDifferences.
28 : m_paintInvalidationType(NoPaintInvalidation
)
29 , m_layoutType(NoLayout
)
30 , m_propertySpecificDifferences(0)
33 bool hasDifference() const { return m_paintInvalidationType
|| m_layoutType
|| m_propertySpecificDifferences
; }
35 bool hasAtMostPropertySpecificDifferences(unsigned propertyDifferences
) const
37 return !m_paintInvalidationType
&& !m_layoutType
&& !(m_propertySpecificDifferences
& ~propertyDifferences
);
40 bool needsPaintInvalidation() const { return m_paintInvalidationType
!= NoPaintInvalidation
; }
41 void clearNeedsPaintInvalidation() { m_paintInvalidationType
= NoPaintInvalidation
; }
43 // The object just needs to issue paint invalidations.
44 bool needsPaintInvalidationObject() const { return m_paintInvalidationType
== PaintInvalidationObject
; }
45 void setNeedsPaintInvalidationObject()
47 ASSERT(!needsPaintInvalidationLayer());
48 m_paintInvalidationType
= PaintInvalidationObject
;
51 // The layer and its descendant layers need to issue paint invalidations.
52 bool needsPaintInvalidationLayer() const { return m_paintInvalidationType
== PaintInvalidationLayer
; }
53 void setNeedsPaintInvalidationLayer() { m_paintInvalidationType
= PaintInvalidationLayer
; }
55 bool needsLayout() const { return m_layoutType
!= NoLayout
; }
56 void clearNeedsLayout() { m_layoutType
= NoLayout
; }
58 // The offset of this positioned object has been updated.
59 bool needsPositionedMovementLayout() const { return m_layoutType
== PositionedMovement
; }
60 void setNeedsPositionedMovementLayout()
62 ASSERT(!needsFullLayout());
63 m_layoutType
= PositionedMovement
;
66 bool needsFullLayout() const { return m_layoutType
== FullLayout
; }
67 void setNeedsFullLayout() { m_layoutType
= FullLayout
; }
69 bool transformChanged() const { return m_propertySpecificDifferences
& TransformChanged
; }
70 void setTransformChanged() { m_propertySpecificDifferences
|= TransformChanged
; }
72 bool opacityChanged() const { return m_propertySpecificDifferences
& OpacityChanged
; }
73 void setOpacityChanged() { m_propertySpecificDifferences
|= OpacityChanged
; }
75 bool zIndexChanged() const { return m_propertySpecificDifferences
& ZIndexChanged
; }
76 void setZIndexChanged() { m_propertySpecificDifferences
|= ZIndexChanged
; }
78 bool filterChanged() const { return m_propertySpecificDifferences
& FilterChanged
; }
79 void setFilterChanged() { m_propertySpecificDifferences
|= FilterChanged
; }
81 bool backdropFilterChanged() const { return m_propertySpecificDifferences
& BackdropFilterChanged
; }
82 void setBackdropFilterChanged() { m_propertySpecificDifferences
|= BackdropFilterChanged
; }
84 bool textOrColorChanged() const { return m_propertySpecificDifferences
& TextOrColorChanged
; }
85 void setTextOrColorChanged() { m_propertySpecificDifferences
|= TextOrColorChanged
; }
88 enum PaintInvalidationType
{
89 NoPaintInvalidation
= 0,
90 PaintInvalidationObject
,
91 PaintInvalidationLayer
93 unsigned m_paintInvalidationType
: 2;
100 unsigned m_layoutType
: 2;
102 unsigned m_propertySpecificDifferences
: 6;
107 #endif // StyleDifference_h