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 #include "core/rendering/style/RenderStyleConstants.h" | |
Julien - ping for review
2014/04/18 20:35:15
Once you've removed the legacy type shouldn't this
Xianzhu
2014/04/18 22:02:27
Done.
| |
9 | |
10 namespace WebCore { | |
11 | |
12 // The difference between two styles. | |
Julien - ping for review
2014/04/18 20:35:15
Let's have more class comments:
// This class rep
Xianzhu
2014/04/18 22:02:27
Done.
| |
13 class StyleDifference { | |
14 public: | |
15 StyleDifference() | |
16 : m_needsRecompositeLayer(0) | |
Julien - ping for review
2014/04/18 20:35:15
Let's use false here.
Xianzhu
2014/04/18 22:02:27
Done.
| |
17 , m_repaintType(NoRepaint) | |
18 , m_layoutType(NoLayout) | |
19 , m_contextSensitiveFlags(NotContextSensitive) { } | |
20 | |
21 // Temporary constructor to convert StyleDifferenceLegacy to new StyleDiffer ence. | |
22 // At this step, implicit requirements (e.g. StyleDifferenceLayout implies S tyleDifferenceRepaint), | |
23 // is not handled by StyleDifference but need to be handled by the callers. | |
24 StyleDifference(StyleDifferenceLegacy legacyDiff, unsigned context) | |
25 : m_needsRecompositeLayer(0) | |
26 , m_repaintType(NoRepaint) | |
27 , m_layoutType(NoLayout) | |
28 , m_contextSensitiveFlags(NotContextSensitive) | |
29 { | |
30 switch (legacyDiff) { | |
31 case StyleDifferenceEqual: | |
32 break; | |
33 case StyleDifferenceRecompositeLayer: | |
34 m_needsRecompositeLayer = 1; | |
35 break; | |
36 case StyleDifferenceRepaint: | |
37 m_repaintType = RepaintObjectOnly; | |
38 break; | |
39 case StyleDifferenceRepaintLayer: | |
40 m_repaintType = RepaintLayer; | |
41 break; | |
42 case StyleDifferenceLayoutPositionedMovementOnly: | |
43 m_layoutType = PositionedMovementOnly; | |
44 break; | |
45 case StyleDifferenceLayout: | |
46 m_layoutType = FullLayout; | |
47 break; | |
48 } | |
49 | |
50 if (context & ContextSensitivePropertyTransform) | |
51 m_contextSensitiveFlags |= TransformChanged; | |
52 if (context & ContextSensitivePropertyOpacity) | |
53 m_contextSensitiveFlags |= OpacityChanged; | |
54 if (context & ContextSensitivePropertyFilter) | |
55 m_contextSensitiveFlags |= FilterChanged; | |
56 if (context & ContextSensitivePropertyTextOrColor) | |
57 m_contextSensitiveFlags |= TextOrColorChanged; | |
Julien - ping for review
2014/04/18 20:35:15
Why do we need an extra enum instead of reusing th
Xianzhu
2014/04/18 22:02:27
This change was reduced from my original whole big
| |
58 } | |
59 | |
60 // The two styles are identical. | |
61 bool hasNoChange() const | |
62 { | |
63 return !m_needsRecompositeLayer | |
64 && m_repaintType == NoRepaint | |
65 && m_layoutType == NoLayout | |
66 && !isContextSensitive(); | |
Julien - ping for review
2014/04/18 20:35:15
The context sensitive flags are really not differe
Xianzhu
2014/04/18 22:02:27
Actually directly treating StyleDifferenceEqual as
| |
67 } | |
68 | |
69 // The layer needs its position and transform updated. Implied by other repa int and layout flags. | |
70 bool needsRecompositeLayer() const { return m_needsRecompositeLayer || needs Repaint() || needsLayout(); } | |
71 void setNeedsRecompositeLayer() { m_needsRecompositeLayer = 1; } | |
Julien - ping for review
2014/04/18 20:35:15
Please use the boolean 'true' here.
Xianzhu
2014/04/18 22:02:27
Done.
| |
72 | |
73 bool needsRepaint() const { return m_repaintType != NoRepaint; } | |
74 void resetNeedsRepaint() { m_repaintType = NoRepaint; } | |
Julien - ping for review
2014/04/18 20:35:15
See comment below.
Xianzhu
2014/04/18 22:02:27
Done.
| |
75 | |
76 // The object just needs to be repainted. | |
77 bool needsRepaintObjectOnly() const { return m_repaintType == RepaintObjectO nly; } | |
78 void setNeedsRepaintObject() | |
79 { | |
80 if (!needsRepaintLayer()) | |
81 m_repaintType = RepaintObjectOnly; | |
82 } | |
83 | |
84 // The layer and its descendant layers need to be repainted. | |
85 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } | |
86 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } | |
87 | |
88 bool needsLayout() const { return m_layoutType != NoLayout; } | |
89 void resetNeedsLayout() { m_layoutType = NoLayout; } | |
Julien - ping for review
2014/04/18 20:35:15
These getters are named needsLayout / clearNeedsLa
Xianzhu
2014/04/18 22:02:27
Done.
| |
90 | |
91 // The position of this positioned object has been updated. | |
Julien - ping for review
2014/04/18 20:35:15
I would change position to "offset" as this is wha
Xianzhu
2014/04/18 22:02:27
Done.
| |
92 bool needsPositionedMovementLayoutOnly() const { return m_layoutType == Posi tionedMovementOnly; } | |
93 void setNeedsPositionedMovementLayout() | |
94 { | |
95 if (!needsFullLayout()) | |
96 m_layoutType = PositionedMovementOnly; | |
97 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior. | |
98 m_repaintType = NoRepaint; | |
99 } | |
100 | |
101 // A full layout is required. | |
Julien - ping for review
2014/04/18 20:35:15
Not really a helpful comment. A "full layout" is k
Xianzhu
2014/04/18 22:02:27
Removed. The function name seems descriptive enoug
| |
102 bool needsFullLayout() const { return m_layoutType == FullLayout; } | |
103 void setNeedsFullLayout() | |
104 { | |
105 m_layoutType = FullLayout; | |
106 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior. | |
107 m_repaintType = NoRepaint; | |
108 } | |
109 | |
110 // When some style properties change, different amounts of work have to be d one depending on | |
111 // context (e.g. whether the property is changing on an element which has a compositing layer). | |
112 // Caller of RenderStyle::visualInvalidationDiff() needs to check the contex t and determine | |
113 // what work is needed. | |
Julien - ping for review
2014/04/18 20:35:15
I really think this should be a FIXME: these flags
Xianzhu
2014/04/18 22:02:27
Reverted changes about context sensitive propertie
| |
114 bool isContextSensitive() const { return m_contextSensitiveFlags != NotConte xtSensitive; } | |
115 void resetContextSensitiveFlags() { m_contextSensitiveFlags = NotContextSens itive; } | |
116 | |
117 bool transformChanged() const { return m_contextSensitiveFlags & TransformCh anged; } | |
118 void setTransformChanged() { m_contextSensitiveFlags |= TransformChanged; } | |
119 | |
120 bool opacityChanged() const { return m_contextSensitiveFlags & OpacityChange d; } | |
Julien - ping for review
2014/04/18 20:35:15
Again those getters should have a conjugated verb:
| |
121 void setOpacityChanged() { m_contextSensitiveFlags |= OpacityChanged; } | |
122 | |
123 bool filterChanged() const { return m_contextSensitiveFlags & FilterChanged; } | |
124 void setFilterChanged() { m_contextSensitiveFlags |= FilterChanged; } | |
Julien - ping for review
2014/04/18 20:35:15
The setters for these properties are unused so we
| |
125 | |
126 // Text decoration or color changed. Needs repaint if the object contains te xt or properties dependent or color (e.g., border or outline). | |
127 bool textOrColorChanged() const { return m_contextSensitiveFlags & TextOrCol orChanged; } | |
128 void setTextOrColorChanged() { m_contextSensitiveFlags |= TextOrColorChanged ; } | |
129 | |
130 private: | |
131 unsigned m_needsRecompositeLayer : 1; | |
132 | |
133 enum RepaintType { | |
134 NoRepaint, | |
Julien - ping for review
2014/04/18 20:35:15
We should probably make these start at 0, it would
Xianzhu
2014/04/18 22:02:27
Done.
| |
135 RepaintObjectOnly, | |
136 RepaintLayer | |
137 }; | |
138 unsigned m_repaintType : 2; | |
139 | |
140 enum LayoutType { | |
141 NoLayout, | |
Julien - ping for review
2014/04/18 20:35:15
Same comment.
Xianzhu
2014/04/18 22:02:27
Done.
| |
142 PositionedMovementOnly, | |
143 FullLayout | |
144 }; | |
145 unsigned m_layoutType : 2; | |
146 | |
147 enum ContextSensitiveFlags { | |
148 NotContextSensitive = 0, | |
149 TransformChanged = 1 << 0, | |
150 OpacityChanged = 1 << 1, | |
151 FilterChanged = 1 << 2, | |
152 TextOrColorChanged = 1 << 3 | |
153 }; | |
154 unsigned m_contextSensitiveFlags : 4; | |
Julien - ping for review
2014/04/18 20:35:15
I think this is my biggest gripe with the change (
Xianzhu
2014/04/18 22:02:27
Agreed. Reverted the changes about context sensiti
| |
155 }; | |
156 | |
157 } // namespace WebCore | |
158 | |
159 #endif // StyleDifference_h | |
OLD | NEW |