| 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" |
| 9 |
| 8 namespace WebCore { | 10 namespace WebCore { |
| 9 | 11 |
| 10 // This class represents the difference between two computed styles (RenderStyle
). | 12 // This class represents the difference between two computed styles (RenderStyle
). |
| 11 // The difference can be of 3 types: | 13 // The difference can be combination of 3 types according to the actions needed: |
| 12 // - Layout difference | 14 // - Difference needing layout |
| 13 // - Repaint difference | 15 // - Difference needing repaint |
| 14 // - Recompositing difference | 16 // - Difference needing recompositing layers |
| 15 class StyleDifference { | 17 class StyleDifference { |
| 16 public: | 18 public: |
| 17 StyleDifference() | 19 StyleDifference() |
| 18 : m_needsRecompositeLayer(false) | 20 : m_needsRecompositeLayer(false) |
| 19 , m_repaintType(NoRepaint) | 21 , m_repaintType(NoRepaint) |
| 20 , m_layoutType(NoLayout) { } | 22 , m_layoutType(NoLayout) { } |
| 21 | 23 |
| 22 // The two styles are identical. | 24 // The two styles are identical. |
| 23 bool hasNoChange() const { return !m_needsRecompositeLayer && !m_repaintType
&& !m_layoutType; } | 25 bool hasNoChange() const { return !m_needsRecompositeLayer && !m_repaintType
&& !m_layoutType; } |
| 24 | 26 |
| 25 // The layer needs its position and transform updated. Implied by other repa
int and layout flags. | 27 // The layer needs its position and transform updated. Implied by other repa
int and layout flags. |
| 26 bool needsRecompositeLayer() const { return m_needsRecompositeLayer || needs
Repaint() || needsLayout(); } | 28 bool needsRecompositeLayer() const { return m_needsRecompositeLayer || needs
Repaint() || needsLayout(); } |
| 27 void setNeedsRecompositeLayer() { m_needsRecompositeLayer = true; } | 29 void setNeedsRecompositeLayer() { m_needsRecompositeLayer = true; } |
| 28 | 30 |
| 29 bool needsRepaint() const { return m_repaintType != NoRepaint; } | 31 bool needsRepaint() const { return m_repaintType != NoRepaint; } |
| 30 void clearNeedsRepaint() { m_repaintType = NoRepaint; } | 32 void clearNeedsRepaint() { m_repaintType = NoRepaint; } |
| 31 | 33 |
| 32 // The object just needs to be repainted. | 34 // The object just needs to be repainted. |
| 33 bool needsRepaintObjectOnly() const { return m_repaintType == RepaintObjectO
nly; } | 35 bool needsRepaintObject() const { return m_repaintType == RepaintObject; } |
| 34 void setNeedsRepaintObject() | 36 void setNeedsRepaintObject() |
| 35 { | 37 { |
| 36 if (!needsRepaintLayer()) | 38 ASSERT(!needsRepaintLayer()); |
| 37 m_repaintType = RepaintObjectOnly; | 39 m_repaintType = RepaintObject; |
| 38 } | 40 } |
| 39 | 41 |
| 40 // The layer and its descendant layers need to be repainted. | 42 // The layer and its descendant layers need to be repainted. |
| 41 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } | 43 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } |
| 42 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } | 44 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } |
| 43 | 45 |
| 44 bool needsLayout() const { return m_layoutType != NoLayout; } | 46 bool needsLayout() const { return m_layoutType != NoLayout; } |
| 45 void clearNeedsLayout() { m_layoutType = NoLayout; } | 47 void clearNeedsLayout() { m_layoutType = NoLayout; } |
| 46 | 48 |
| 47 // The offset of this positioned object has been updated. | 49 // The offset of this positioned object has been updated. |
| 48 bool needsPositionedMovementLayout() const { return m_layoutType & Positione
dMovement; } | 50 bool needsPositionedMovementLayout() const { return m_layoutType == Position
edMovement; } |
| 49 void setNeedsPositionedMovementLayout() | 51 void setNeedsPositionedMovementLayout() |
| 50 { | 52 { |
| 51 if (!needsFullLayout()) | 53 ASSERT(!needsFullLayout()); |
| 52 m_layoutType |= PositionedMovement; | 54 m_layoutType = PositionedMovement; |
| 53 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior. | |
| 54 m_repaintType = NoRepaint; | |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool needsFullLayout() const { return m_layoutType == FullLayout; } | 57 bool needsFullLayout() const { return m_layoutType == FullLayout; } |
| 58 void setNeedsFullLayout() | 58 void setNeedsFullLayout() { m_layoutType = FullLayout; } |
| 59 { | |
| 60 m_layoutType = FullLayout; | |
| 61 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior. | |
| 62 m_repaintType = NoRepaint; | |
| 63 } | |
| 64 | 59 |
| 65 private: | 60 private: |
| 66 unsigned m_needsRecompositeLayer : 1; | 61 unsigned m_needsRecompositeLayer : 1; |
| 67 | 62 |
| 68 enum RepaintType { | 63 enum RepaintType { |
| 69 NoRepaint = 0, | 64 NoRepaint = 0, |
| 70 RepaintObjectOnly, | 65 RepaintObject, |
| 71 RepaintLayer | 66 RepaintLayer |
| 72 }; | 67 }; |
| 73 unsigned m_repaintType : 2; | 68 unsigned m_repaintType : 2; |
| 74 | 69 |
| 75 enum LayoutType { | 70 enum LayoutType { |
| 76 NoLayout = 0, | 71 NoLayout = 0, |
| 77 PositionedMovement = 1 << 0, | 72 PositionedMovement, |
| 78 FullLayout = 1 << 1 | 73 FullLayout |
| 79 }; | 74 }; |
| 80 unsigned m_layoutType : 2; | 75 unsigned m_layoutType : 2; |
| 81 }; | 76 }; |
| 82 | 77 |
| 83 } // namespace WebCore | 78 } // namespace WebCore |
| 84 | 79 |
| 85 #endif // StyleDifference_h | 80 #endif // StyleDifference_h |
| OLD | NEW |