OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 PaintPropertyTreeBuilder_h | 5 #ifndef PaintPropertyTreeBuilder_h |
6 #define PaintPropertyTreeBuilder_h | 6 #define PaintPropertyTreeBuilder_h |
7 | 7 |
8 #include "platform/geometry/LayoutPoint.h" | 8 #include "platform/geometry/LayoutPoint.h" |
9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
11 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 11 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
13 #include "platform/wtf/RefPtr.h" | 13 #include "platform/wtf/RefPtr.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class FrameView; | 17 class FrameView; |
18 class LayoutBoxModelObject; | 18 class LayoutBoxModelObject; |
19 class LayoutObject; | 19 class LayoutObject; |
20 | 20 |
21 // The context for PaintPropertyTreeBuilder. | 21 // The context for PaintPropertyTreeBuilder. |
22 // It's responsible for bookkeeping tree state in other order, for example, the | 22 // It's responsible for bookkeeping tree state in other order, for example, the |
23 // most recent position container seen. | 23 // most recent position container seen. |
24 struct PaintPropertyTreeBuilderContext { | 24 struct PaintPropertyTreeBuilderFragmentContext { |
25 USING_FAST_MALLOC(PaintPropertyTreeBuilderContext); | 25 USING_FAST_MALLOC(PaintPropertyTreeBuilderFragmentContext); |
26 | 26 |
27 public: | 27 public: |
28 // Initializes all property tree nodes to the roots. | 28 // Initializes all property tree nodes to the roots. |
29 PaintPropertyTreeBuilderContext(); | 29 PaintPropertyTreeBuilderFragmentContext(); |
30 | 30 |
31 // State that propagates on the containing block chain (and so is adjusted | 31 // State that propagates on the containing block chain (and so is adjusted |
32 // when an absolute or fixed position object is encountered). | 32 // when an absolute or fixed position object is encountered). |
33 struct ContainingBlockContext { | 33 struct ContainingBlockContext { |
34 // The combination of a transform and paint offset describes a linear space. | 34 // The combination of a transform and paint offset describes a linear space. |
35 // When a layout object recur to its children, the main context is expected | 35 // When a layout object recur to its children, the main context is expected |
36 // to refer the object's border box, then the callee will derive its own | 36 // to refer the object's border box, then the callee will derive its own |
37 // border box by translating the space with its own layout location. | 37 // border box by translating the space with its own layout location. |
38 const TransformPaintPropertyNode* transform = nullptr; | 38 const TransformPaintPropertyNode* transform = nullptr; |
39 LayoutPoint paint_offset; | 39 LayoutPoint paint_offset; |
(...skipping 21 matching lines...) Expand all Loading... |
61 ContainingBlockContext current; | 61 ContainingBlockContext current; |
62 | 62 |
63 // Separate context for out-of-flow positioned and fixed positioned elements | 63 // Separate context for out-of-flow positioned and fixed positioned elements |
64 // are needed because they don't use DOM parent as their containing block. | 64 // are needed because they don't use DOM parent as their containing block. |
65 // These additional contexts normally pass through untouched, and are only | 65 // These additional contexts normally pass through untouched, and are only |
66 // copied from the main context when the current element serves as the | 66 // copied from the main context when the current element serves as the |
67 // containing block of corresponding positioned descendants. Overflow clips | 67 // containing block of corresponding positioned descendants. Overflow clips |
68 // are also inherited by containing block tree instead of DOM tree, thus they | 68 // are also inherited by containing block tree instead of DOM tree, thus they |
69 // are included in the additional context too. | 69 // are included in the additional context too. |
70 ContainingBlockContext absolute_position; | 70 ContainingBlockContext absolute_position; |
71 const LayoutObject* container_for_absolute_position; | |
72 | 71 |
73 ContainingBlockContext fixed_position; | 72 ContainingBlockContext fixed_position; |
74 | 73 |
75 // This is the same as current.paintOffset except when a floating object has | 74 // This is the same as current.paintOffset except when a floating object has |
76 // non-block ancestors under its containing block. Paint offsets of the | 75 // non-block ancestors under its containing block. Paint offsets of the |
77 // non-block ancestors should not be accumulated for the floating object. | 76 // non-block ancestors should not be accumulated for the floating object. |
78 LayoutPoint paint_offset_for_float; | 77 LayoutPoint paint_offset_for_float; |
79 | 78 |
80 // The effect hierarchy is applied by the stacking context tree. It is | 79 // The effect hierarchy is applied by the stacking context tree. It is |
81 // guaranteed that every DOM descendant is also a stacking context descendant. | 80 // guaranteed that every DOM descendant is also a stacking context descendant. |
82 // Therefore, we don't need extra bookkeeping for effect nodes and can | 81 // Therefore, we don't need extra bookkeeping for effect nodes and can |
83 // generate the effect tree from a DOM-order traversal. | 82 // generate the effect tree from a DOM-order traversal. |
84 const EffectPaintPropertyNode* current_effect; | 83 const EffectPaintPropertyNode* current_effect; |
85 // Some effects are spatial, i.e. may refer to input pixels outside of output | 84 // Some effects are spatial, i.e. may refer to input pixels outside of output |
86 // clip. The cull rect for its input shall be derived from its output clip. | 85 // clip. The cull rect for its input shall be derived from its output clip. |
87 // This variable represents the input cull of current effect, also serves as | 86 // This variable represents the input cull of current effect, also serves as |
88 // output clip of child effects that don't have a hard clip. | 87 // output clip of child effects that don't have a hard clip. |
89 const ClipPaintPropertyNode* input_clip_of_current_effect; | 88 const ClipPaintPropertyNode* input_clip_of_current_effect; |
| 89 }; |
| 90 |
| 91 struct PaintPropertyTreeBuilderContext { |
| 92 USING_FAST_MALLOC(PaintPropertyTreeBuilderContext); |
| 93 |
| 94 public: |
| 95 PaintPropertyTreeBuilderContext() |
| 96 : container_for_absolute_position(nullptr), |
| 97 force_subtree_update(false) |
| 98 #if DCHECK_IS_ON() |
| 99 , |
| 100 is_actually_needed(true) |
| 101 #endif |
| 102 { |
| 103 } |
| 104 |
| 105 Vector<PaintPropertyTreeBuilderFragmentContext> fragments; |
| 106 const LayoutObject* container_for_absolute_position; |
90 | 107 |
91 // True if a change has forced all properties in a subtree to be updated. This | 108 // True if a change has forced all properties in a subtree to be updated. This |
92 // can be set due to paint offset changes or when the structure of the | 109 // can be set due to paint offset changes or when the structure of the |
93 // property tree changes (i.e., a node is added or removed). | 110 // property tree changes (i.e., a node is added or removed). |
94 bool force_subtree_update; | 111 bool force_subtree_update; |
95 | 112 |
96 #if DCHECK_IS_ON() | 113 #if DCHECK_IS_ON() |
97 // When DCHECK_IS_ON() we create PaintPropertyTreeBuilderContext even if not | 114 // When DCHECK_IS_ON() we create PaintPropertyTreeBuilderContext even if not |
98 // needed. See FindPaintOffsetAndVisualRectNeedingUpdate.h. | 115 // needed. See FindPaintOffsetAndVisualRectNeedingUpdate.h. |
99 bool is_actually_needed = true; | 116 bool is_actually_needed; |
100 #endif | 117 #endif |
101 }; | 118 }; |
102 | 119 |
103 // Creates paint property tree nodes for special things in the layout tree. | 120 // Creates paint property tree nodes for special things in the layout tree. |
104 // Special things include but not limit to: overflow clip, transform, fixed-pos, | 121 // Special things include but not limit to: overflow clip, transform, fixed-pos, |
105 // animation, mask, filter, ... etc. | 122 // animation, mask, filter, ... etc. |
106 // It expects to be invoked for each layout tree node in DOM order during | 123 // It expects to be invoked for each layout tree node in DOM order during |
107 // InPrePaint phase. | 124 // InPrePaint phase. |
108 class PaintPropertyTreeBuilder { | 125 class PaintPropertyTreeBuilder { |
109 public: | 126 public: |
110 // Update the paint properties for a frame and ensure the context is up to | 127 // Update the paint properties for a frame and ensure the context is up to |
111 // date. | 128 // date. |
112 void UpdateProperties(FrameView&, PaintPropertyTreeBuilderContext&); | 129 void UpdateProperties(FrameView&, PaintPropertyTreeBuilderContext&); |
113 | 130 |
114 // Update the paint properties that affect this object (e.g., properties like | 131 // Update the paint properties that affect this object (e.g., properties like |
115 // paint offset translation) and ensure the context is up to date. Also | 132 // paint offset translation) and ensure the context is up to date. Also |
116 // handles updating the object's paintOffset. | 133 // handles updating the object's paintOffset. |
117 void UpdatePropertiesForSelf(const LayoutObject&, | 134 void UpdatePropertiesForSelf(const LayoutObject&, |
118 PaintPropertyTreeBuilderContext&); | 135 PaintPropertyTreeBuilderContext&); |
119 // Update the paint properties that affect children of this object (e.g., | 136 // Update the paint properties that affect children of this object (e.g., |
120 // scroll offset transform) and ensure the context is up to date. | 137 // scroll offset transform) and ensure the context is up to date. |
121 void UpdatePropertiesForChildren(const LayoutObject&, | 138 void UpdatePropertiesForChildren(const LayoutObject&, |
122 PaintPropertyTreeBuilderContext&); | 139 PaintPropertyTreeBuilderContext&); |
123 | 140 |
124 private: | 141 private: |
125 ALWAYS_INLINE static void UpdatePaintOffset(const LayoutBoxModelObject&, | 142 ALWAYS_INLINE static void UpdatePaintOffset( |
126 PaintPropertyTreeBuilderContext&); | 143 const LayoutBoxModelObject&, |
| 144 PaintPropertyTreeBuilderFragmentContext&, |
| 145 const LayoutObject* container_for_absolute_position); |
127 ALWAYS_INLINE static void UpdatePaintOffsetTranslation( | 146 ALWAYS_INLINE static void UpdatePaintOffsetTranslation( |
128 const LayoutBoxModelObject&, | 147 const LayoutBoxModelObject&, |
129 PaintPropertyTreeBuilderContext&); | 148 PaintPropertyTreeBuilderFragmentContext&, |
| 149 bool& force_subtree_update); |
130 ALWAYS_INLINE static void UpdateForObjectLocationAndSize( | 150 ALWAYS_INLINE static void UpdateForObjectLocationAndSize( |
131 const LayoutObject&, | 151 const LayoutObject&, |
132 PaintPropertyTreeBuilderContext&); | 152 const LayoutObject* container_for_absolute_position, |
133 ALWAYS_INLINE static void UpdateTransform(const LayoutObject&, | 153 bool& is_actually_needed, |
134 PaintPropertyTreeBuilderContext&); | 154 PaintPropertyTreeBuilderFragmentContext&, |
| 155 bool& force_subtree_update); |
| 156 ALWAYS_INLINE static void UpdateTransform( |
| 157 const LayoutObject&, |
| 158 PaintPropertyTreeBuilderFragmentContext&, |
| 159 bool& force_subtree_update); |
135 ALWAYS_INLINE static void UpdateTransformForNonRootSVG( | 160 ALWAYS_INLINE static void UpdateTransformForNonRootSVG( |
136 const LayoutObject&, | 161 const LayoutObject&, |
137 PaintPropertyTreeBuilderContext&); | 162 PaintPropertyTreeBuilderFragmentContext&, |
138 ALWAYS_INLINE static void UpdateEffect(const LayoutObject&, | 163 bool& force_subtree_update); |
139 PaintPropertyTreeBuilderContext&); | 164 ALWAYS_INLINE static void UpdateEffect( |
140 ALWAYS_INLINE static void UpdateFilter(const LayoutObject&, | 165 const LayoutObject&, |
141 PaintPropertyTreeBuilderContext&); | 166 PaintPropertyTreeBuilderFragmentContext&, |
142 ALWAYS_INLINE static void UpdateCssClip(const LayoutObject&, | 167 bool& force_subtree_update); |
143 PaintPropertyTreeBuilderContext&); | 168 ALWAYS_INLINE static void UpdateFilter( |
| 169 const LayoutObject&, |
| 170 PaintPropertyTreeBuilderFragmentContext&, |
| 171 bool& force_subtree_update); |
| 172 ALWAYS_INLINE static void UpdateCssClip( |
| 173 const LayoutObject&, |
| 174 PaintPropertyTreeBuilderFragmentContext&, |
| 175 bool& force_subtree_update); |
144 ALWAYS_INLINE static void UpdateLocalBorderBoxContext( | 176 ALWAYS_INLINE static void UpdateLocalBorderBoxContext( |
145 const LayoutObject&, | 177 const LayoutObject&, |
146 PaintPropertyTreeBuilderContext&); | 178 PaintPropertyTreeBuilderFragmentContext&, |
| 179 bool& force_subtree_update); |
147 ALWAYS_INLINE static void UpdateScrollbarPaintOffset( | 180 ALWAYS_INLINE static void UpdateScrollbarPaintOffset( |
148 const LayoutObject&, | 181 const LayoutObject&, |
149 PaintPropertyTreeBuilderContext&); | 182 PaintPropertyTreeBuilderFragmentContext&, |
| 183 bool& force_subtree_update); |
150 ALWAYS_INLINE static void UpdateOverflowClip( | 184 ALWAYS_INLINE static void UpdateOverflowClip( |
151 const LayoutObject&, | 185 const LayoutObject&, |
152 PaintPropertyTreeBuilderContext&); | 186 PaintPropertyTreeBuilderFragmentContext&, |
153 ALWAYS_INLINE static void UpdatePerspective(const LayoutObject&, | 187 bool& force_subtree_update); |
154 PaintPropertyTreeBuilderContext&); | 188 ALWAYS_INLINE static void UpdatePerspective( |
| 189 const LayoutObject&, |
| 190 PaintPropertyTreeBuilderFragmentContext&, |
| 191 bool& force_subtree_update); |
155 ALWAYS_INLINE static void UpdateSvgLocalToBorderBoxTransform( | 192 ALWAYS_INLINE static void UpdateSvgLocalToBorderBoxTransform( |
156 const LayoutObject&, | 193 const LayoutObject&, |
157 PaintPropertyTreeBuilderContext&); | 194 PaintPropertyTreeBuilderFragmentContext&, |
| 195 bool& force_subtree_update); |
158 ALWAYS_INLINE static void UpdateScrollAndScrollTranslation( | 196 ALWAYS_INLINE static void UpdateScrollAndScrollTranslation( |
159 const LayoutObject&, | 197 const LayoutObject&, |
160 PaintPropertyTreeBuilderContext&); | 198 PaintPropertyTreeBuilderFragmentContext&, |
| 199 bool& force_subtree_update); |
161 ALWAYS_INLINE static void UpdateOutOfFlowContext( | 200 ALWAYS_INLINE static void UpdateOutOfFlowContext( |
162 const LayoutObject&, | 201 const LayoutObject&, |
163 PaintPropertyTreeBuilderContext&); | 202 PaintPropertyTreeBuilderFragmentContext&, |
| 203 bool& force_subtree_update); |
164 | 204 |
165 // Ensure the ObjectPaintProperties object is created if it will be needed, or | 205 // Ensure the ObjectPaintProperties object is created if it will be needed, or |
166 // cleared otherwise. | 206 // cleared otherwise. |
167 ALWAYS_INLINE static void UpdatePaintProperties( | 207 ALWAYS_INLINE static void UpdatePaintProperties( |
168 const LayoutObject&, | 208 const LayoutObject&, |
169 PaintPropertyTreeBuilderContext&); | 209 PaintPropertyTreeBuilderContext&); |
170 }; | 210 }; |
171 | 211 |
172 } // namespace blink | 212 } // namespace blink |
173 | 213 |
174 #endif // PaintPropertyTreeBuilder_h | 214 #endif // PaintPropertyTreeBuilder_h |
OLD | NEW |