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