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 namespace WebCore { | |
9 | |
10 // The difference between two styles. It has the following types of flags: | |
11 class StyleDifference { | |
12 public: | |
13 StyleDifference() | |
14 : m_needsRecompositeLayer(0) | |
15 , m_repaintType(NoRepaint) | |
16 , m_layoutType(NoLayout) | |
17 , m_contextSensitiveFlags(NotContextSensitive) { } | |
18 | |
19 // The two styles are identical. | |
20 bool noChange() const | |
Julien - ping for review
2014/04/18 16:37:00
Our coding style mandates a verb in boolean getter
Xianzhu
2014/04/18 17:46:56
Done.
| |
21 { | |
22 return !m_needsRecompositeLayer | |
23 && m_repaintType == NoRepaint | |
24 && m_layoutType == NoLayout | |
25 && !isContextSensitive(); | |
26 } | |
27 | |
28 // The layer needs its position and transform updated. Only meaningful when | |
29 // no other flags are set because it's implied by other flags. | |
Julien - ping for review
2014/04/18 16:37:00
It's weird that the getter doesn't check the other
Xianzhu
2014/04/18 17:46:56
Added other checks.
However for other implication
| |
30 bool needsRecompositeLayer() const { return m_needsRecompositeLayer; } | |
31 void setNeedsRecompositeLayer() { m_needsRecompositeLayer = 1; } | |
32 | |
33 bool needsRepaint() const { return m_repaintType != NoRepaint; } | |
34 | |
35 // The object just needs to be repainted. | |
36 bool needsRepaintSelf() const { return m_repaintType == RepaintSelf; } | |
37 void setNeedsRepaintSelf() { m_repaintType = RepaintSelf; } | |
38 | |
39 // Sub flag of needsRepaint. The layer and its descendant layers needs to be repainted. | |
40 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } | |
41 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } | |
42 | |
43 bool needsLayout() const { return m_layoutType != NoLayout; } | |
44 | |
45 // The position of this positioned object has been updated. | |
46 bool needsPositionedMovementLayout() const { return m_layoutType & Positione dMovement; } | |
47 void setNeedsPositionedMovementLayout() | |
48 { | |
49 if (!needsFullLayout()) | |
50 m_layoutType |= PositionedMovement; | |
51 } | |
52 | |
53 // Overflow needs to be recomputed. | |
54 bool needsSimplifiedLayout() const { return m_layoutType & SimplifiedLayout; } | |
55 void setNeedsSimplifiedLayout() | |
56 { | |
57 if (!needsFullLayout()) | |
58 m_layoutType |= SimplifiedLayout; | |
59 } | |
60 | |
61 // A full layout is required. | |
62 bool needsFullLayout() const { return m_layoutType == FullLayout; } | |
63 void setNeedsFullLayout() { m_layoutType = FullLayout; } | |
64 | |
65 // When some style properties change, different amounts of work have to be d one depending on | |
66 // context (e.g. whether the property is changing on an element which has a compositing layer). | |
67 // Caller of RenderStyle::visualInvalidationDiff() needs to check the contex t and determine | |
68 // what work is needed. | |
69 bool isContextSensitive() const { return m_contextSensitiveFlags != NotConte xtSensitive; } | |
70 void resetContextSensitiveFlags() { m_contextSensitiveFlags = NotContextSens itive; } | |
71 | |
72 bool transformChanged() const { return m_contextSensitiveFlags & TransformCh anged; } | |
73 void setTransformChanged() { m_contextSensitiveFlags |= TransformChanged; } | |
74 | |
75 bool opacityChanged() const { return m_contextSensitiveFlags & OpacityChange d; } | |
76 void setOpacityChanged() { m_contextSensitiveFlags |= OpacityChanged; } | |
77 | |
78 bool zIndexChanged() const { return m_contextSensitiveFlags & ZIndexChanged; } | |
79 void setZIndexChanged() { m_contextSensitiveFlags |= ZIndexChanged; } | |
80 | |
81 bool filterChanged() const { return m_contextSensitiveFlags & FilterChanged; } | |
82 void setFilterChanged() { m_contextSensitiveFlags |= FilterChanged; } | |
83 | |
84 // Text decoration or color changed. Needs repaint if the object contains te xt or properties dependent or color (e.g., border or outline). | |
85 bool textOrColorChanged() const { return m_contextSensitiveFlags & TextOrCol orChanged; } | |
86 void setTextOrColorChanged() { m_contextSensitiveFlags |= TextOrColorChanged ; } | |
87 | |
88 private: | |
89 unsigned m_needsRecompositeLayer : 1; | |
90 | |
91 enum RepaintType { | |
92 NoRepaint, | |
93 RepaintSelf, | |
94 RepaintLayer | |
95 }; | |
96 unsigned m_repaintType : 2; | |
97 | |
98 enum LayoutType { | |
99 NoLayout = 0, | |
100 PositionedMovement = 1 << 0, | |
101 SimplifiedLayout = 1 << 1, | |
102 FullLayout = 1 << 2 | |
103 }; | |
Julien - ping for review
2014/04/18 16:37:00
We are going to change the code to not allow both
Xianzhu
2014/04/18 17:46:56
Glad to see the change has been landed :)
Rebasing
| |
104 unsigned m_layoutType : 3; | |
105 | |
106 enum ContextSensitiveFlags { | |
107 NotContextSensitive = 0, | |
108 TransformChanged = 1 << 0, | |
109 OpacityChanged = 1 << 1, | |
110 ZIndexChanged = 1 << 2, | |
111 FilterChanged = 1 << 3, | |
112 TextOrColorChanged = 1 << 4 | |
113 }; | |
114 unsigned m_contextSensitiveFlags : 5; | |
115 }; | |
116 | |
117 } // namespace WebCore | |
118 | |
119 #endif // StyleDifference_h | |
OLD | NEW |