| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef StyleDifference_h | |
| 6 #define StyleDifference_h | |
| 7 | |
| 8 // FIXME: Remove this include after we finish migrating from StyleDifferenceLega
cy. | |
| 9 #include "core/rendering/style/RenderStyleConstants.h" | |
| 10 | |
| 11 namespace WebCore { | |
| 12 | |
| 13 // This class represents the difference between two computed styles (RenderStyle
). | |
| 14 // The difference can be of 3 types: | |
| 15 // - Layout difference | |
| 16 // - Repaint difference | |
| 17 // - Recompositing difference | |
| 18 class StyleDifference { | |
| 19 public: | |
| 20 StyleDifference() | |
| 21 : m_needsRecompositeLayer(false) | |
| 22 , m_repaintType(NoRepaint) | |
| 23 , m_layoutType(NoLayout) { } | |
| 24 | |
| 25 // Temporary constructor to convert StyleDifferenceLegacy to new StyleDiffer
ence. | |
| 26 // At this step, implicit requirements (e.g. StyleDifferenceLayout implies S
tyleDifferenceRepaint), | |
| 27 // is not handled by StyleDifference but need to be handled by the callers. | |
| 28 StyleDifference(StyleDifferenceLegacy legacyDiff) | |
| 29 : m_needsRecompositeLayer(false) | |
| 30 , m_repaintType(NoRepaint) | |
| 31 , m_layoutType(NoLayout) | |
| 32 { | |
| 33 switch (legacyDiff) { | |
| 34 case StyleDifferenceEqual: | |
| 35 break; | |
| 36 case StyleDifferenceRecompositeLayer: | |
| 37 m_needsRecompositeLayer = true; | |
| 38 break; | |
| 39 case StyleDifferenceRepaint: | |
| 40 m_repaintType = RepaintObjectOnly; | |
| 41 break; | |
| 42 case StyleDifferenceRepaintLayer: | |
| 43 m_repaintType = RepaintLayer; | |
| 44 break; | |
| 45 case StyleDifferenceLayoutPositionedMovementOnly: | |
| 46 m_layoutType = PositionedMovementOnly; | |
| 47 break; | |
| 48 case StyleDifferenceLayout: | |
| 49 m_layoutType = FullLayout; | |
| 50 break; | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 // The two styles are identical. | |
| 55 bool hasNoChange() const { return !m_needsRecompositeLayer && !m_repaintType
&& !m_layoutType; } | |
| 56 | |
| 57 // The layer needs its position and transform updated. Implied by other repa
int and layout flags. | |
| 58 bool needsRecompositeLayer() const { return m_needsRecompositeLayer || needs
Repaint() || needsLayout(); } | |
| 59 void setNeedsRecompositeLayer() { m_needsRecompositeLayer = true; } | |
| 60 | |
| 61 bool needsRepaint() const { return m_repaintType != NoRepaint; } | |
| 62 void clearNeedsRepaint() { m_repaintType = NoRepaint; } | |
| 63 | |
| 64 // The object just needs to be repainted. | |
| 65 bool needsRepaintObjectOnly() const { return m_repaintType == RepaintObjectO
nly; } | |
| 66 void setNeedsRepaintObject() | |
| 67 { | |
| 68 if (!needsRepaintLayer()) | |
| 69 m_repaintType = RepaintObjectOnly; | |
| 70 } | |
| 71 | |
| 72 // The layer and its descendant layers need to be repainted. | |
| 73 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } | |
| 74 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } | |
| 75 | |
| 76 bool needsLayout() const { return m_layoutType != NoLayout; } | |
| 77 void clearNeedsLayout() { m_layoutType = NoLayout; } | |
| 78 | |
| 79 // The offset of this positioned object has been updated. | |
| 80 bool needsPositionedMovementLayoutOnly() const { return m_layoutType == Posi
tionedMovementOnly; } | |
| 81 void setNeedsPositionedMovementLayout() | |
| 82 { | |
| 83 if (!needsFullLayout()) | |
| 84 m_layoutType = PositionedMovementOnly; | |
| 85 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior. | |
| 86 m_repaintType = NoRepaint; | |
| 87 } | |
| 88 | |
| 89 bool needsFullLayout() const { return m_layoutType == FullLayout; } | |
| 90 void setNeedsFullLayout() | |
| 91 { | |
| 92 m_layoutType = FullLayout; | |
| 93 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior. | |
| 94 m_repaintType = NoRepaint; | |
| 95 } | |
| 96 | |
| 97 private: | |
| 98 unsigned m_needsRecompositeLayer : 1; | |
| 99 | |
| 100 enum RepaintType { | |
| 101 NoRepaint = 0, | |
| 102 RepaintObjectOnly, | |
| 103 RepaintLayer | |
| 104 }; | |
| 105 unsigned m_repaintType : 2; | |
| 106 | |
| 107 enum LayoutType { | |
| 108 NoLayout = 0, | |
| 109 PositionedMovementOnly, | |
| 110 FullLayout | |
| 111 }; | |
| 112 unsigned m_layoutType : 2; | |
| 113 }; | |
| 114 | |
| 115 } // namespace WebCore | |
| 116 | |
| 117 #endif // StyleDifference_h | |
| OLD | NEW |