| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef StyleDifference_h | 5 #ifndef StyleDifference_h |
| 6 #define StyleDifference_h | 6 #define StyleDifference_h |
| 7 | 7 |
| 8 #include "wtf/Assertions.h" | 8 #include "wtf/Assertions.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 class StyleDifference { | 12 class StyleDifference { |
| 13 public: | 13 public: |
| 14 enum PropertyDifference { | 14 enum PropertyDifference { |
| 15 TransformChanged = 1 << 0, | 15 TransformChanged = 1 << 0, |
| 16 OpacityChanged = 1 << 1, | 16 OpacityChanged = 1 << 1, |
| 17 ZIndexChanged = 1 << 2, | 17 ZIndexChanged = 1 << 2, |
| 18 FilterChanged = 1 << 3, | 18 FilterChanged = 1 << 3, |
| 19 // The object needs to be repainted if it contains text or properties de
pendent on color (e.g., border or outline). | 19 // The object needs to issue paint invalidations if it contains text or
properties dependent on color (e.g., border or outline). |
| 20 TextOrColorChanged = 1 << 4, | 20 TextOrColorChanged = 1 << 4, |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 StyleDifference() | 23 StyleDifference() |
| 24 : m_repaintType(NoRepaint) | 24 : m_paintInvalidationType(NoPaintInvalidation) |
| 25 , m_layoutType(NoLayout) | 25 , m_layoutType(NoLayout) |
| 26 , m_propertySpecificDifferences(0) | 26 , m_propertySpecificDifferences(0) |
| 27 { } | 27 { } |
| 28 | 28 |
| 29 bool hasDifference() const { return m_repaintType || m_layoutType || m_prope
rtySpecificDifferences; } | 29 bool hasDifference() const { return m_paintInvalidationType || m_layoutType
|| m_propertySpecificDifferences; } |
| 30 | 30 |
| 31 bool hasAtMostPropertySpecificDifferences(unsigned propertyDifferences) cons
t | 31 bool hasAtMostPropertySpecificDifferences(unsigned propertyDifferences) cons
t |
| 32 { | 32 { |
| 33 return !m_repaintType && !m_layoutType && !(m_propertySpecificDifference
s & ~propertyDifferences); | 33 return !m_paintInvalidationType && !m_layoutType && !(m_propertySpecific
Differences & ~propertyDifferences); |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool needsRepaint() const { return m_repaintType != NoRepaint; } | 36 bool needsPaintInvalidation() const { return m_paintInvalidationType != NoPa
intInvalidation; } |
| 37 void clearNeedsRepaint() { m_repaintType = NoRepaint; } | 37 void clearNeedsPaintInvalidation() { m_paintInvalidationType = NoPaintInvali
dation; } |
| 38 | 38 |
| 39 // The object just needs to be repainted. | 39 // The object just needs to issue paint invalidations. |
| 40 bool needsRepaintObject() const { return m_repaintType == RepaintObject; } | 40 bool needsPaintInvalidationObject() const { return m_paintInvalidationType =
= PaintInvalidationObject; } |
| 41 void setNeedsRepaintObject() | 41 void setNeedsPaintInvalidationObject() |
| 42 { | 42 { |
| 43 ASSERT(!needsRepaintLayer()); | 43 ASSERT(!needsPaintInvalidationLayer()); |
| 44 m_repaintType = RepaintObject; | 44 m_paintInvalidationType = PaintInvalidationObject; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // The layer and its descendant layers need to be repainted. | 47 // The layer and its descendant layers need to issue paint invalidations. |
| 48 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } | 48 bool needsPaintInvalidationLayer() const { return m_paintInvalidationType ==
PaintInvalidationLayer; } |
| 49 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } | 49 void setNeedsPaintInvalidationLayer() { m_paintInvalidationType = PaintInval
idationLayer; } |
| 50 | 50 |
| 51 bool needsLayout() const { return m_layoutType != NoLayout; } | 51 bool needsLayout() const { return m_layoutType != NoLayout; } |
| 52 void clearNeedsLayout() { m_layoutType = NoLayout; } | 52 void clearNeedsLayout() { m_layoutType = NoLayout; } |
| 53 | 53 |
| 54 // The offset of this positioned object has been updated. | 54 // The offset of this positioned object has been updated. |
| 55 bool needsPositionedMovementLayout() const { return m_layoutType == Position
edMovement; } | 55 bool needsPositionedMovementLayout() const { return m_layoutType == Position
edMovement; } |
| 56 void setNeedsPositionedMovementLayout() | 56 void setNeedsPositionedMovementLayout() |
| 57 { | 57 { |
| 58 ASSERT(!needsFullLayout()); | 58 ASSERT(!needsFullLayout()); |
| 59 m_layoutType = PositionedMovement; | 59 m_layoutType = PositionedMovement; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 71 bool zIndexChanged() const { return m_propertySpecificDifferences & ZIndexCh
anged; } | 71 bool zIndexChanged() const { return m_propertySpecificDifferences & ZIndexCh
anged; } |
| 72 void setZIndexChanged() { m_propertySpecificDifferences |= ZIndexChanged; } | 72 void setZIndexChanged() { m_propertySpecificDifferences |= ZIndexChanged; } |
| 73 | 73 |
| 74 bool filterChanged() const { return m_propertySpecificDifferences & FilterCh
anged; } | 74 bool filterChanged() const { return m_propertySpecificDifferences & FilterCh
anged; } |
| 75 void setFilterChanged() { m_propertySpecificDifferences |= FilterChanged; } | 75 void setFilterChanged() { m_propertySpecificDifferences |= FilterChanged; } |
| 76 | 76 |
| 77 bool textOrColorChanged() const { return m_propertySpecificDifferences & Tex
tOrColorChanged; } | 77 bool textOrColorChanged() const { return m_propertySpecificDifferences & Tex
tOrColorChanged; } |
| 78 void setTextOrColorChanged() { m_propertySpecificDifferences |= TextOrColorC
hanged; } | 78 void setTextOrColorChanged() { m_propertySpecificDifferences |= TextOrColorC
hanged; } |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 enum RepaintType { | 81 enum PaintInvalidationType { |
| 82 NoRepaint = 0, | 82 NoPaintInvalidation = 0, |
| 83 RepaintObject, | 83 PaintInvalidationObject, |
| 84 RepaintLayer | 84 PaintInvalidationLayer |
| 85 }; | 85 }; |
| 86 unsigned m_repaintType : 2; | 86 unsigned m_paintInvalidationType : 2; |
| 87 | 87 |
| 88 enum LayoutType { | 88 enum LayoutType { |
| 89 NoLayout = 0, | 89 NoLayout = 0, |
| 90 PositionedMovement, | 90 PositionedMovement, |
| 91 FullLayout | 91 FullLayout |
| 92 }; | 92 }; |
| 93 unsigned m_layoutType : 2; | 93 unsigned m_layoutType : 2; |
| 94 | 94 |
| 95 unsigned m_propertySpecificDifferences : 5; | 95 unsigned m_propertySpecificDifferences : 5; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 } // namespace blink | 98 } // namespace blink |
| 99 | 99 |
| 100 #endif // StyleDifference_h | 100 #endif // StyleDifference_h |
| OLD | NEW |