Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp

Issue 2829673002: Don't update descendant visual rects on border radius change (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "core/paint/PrePaintTreeWalk.h" 5 #include "core/paint/PrePaintTreeWalk.h"
6 6
7 #include "core/dom/DocumentLifecycle.h" 7 #include "core/dom/DocumentLifecycle.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // sticky layer position, so we need to update it again here. 121 // sticky layer position, so we need to update it again here.
122 // TODO(flackr): This should be refactored in the future to be clearer (i.e. 122 // TODO(flackr): This should be refactored in the future to be clearer (i.e.
123 // update layer position and ancestor inputs updates in the same walk). 123 // update layer position and ancestor inputs updates in the same walk).
124 paint_layer->UpdateLayerPosition(); 124 paint_layer->UpdateLayerPosition();
125 } 125 }
126 126
127 if (paint_layer->IsRootLayer() || object.HasOverflowClip()) 127 if (paint_layer->IsRootLayer() || object.HasOverflowClip())
128 context.ancestor_overflow_paint_layer = paint_layer; 128 context.ancestor_overflow_paint_layer = paint_layer;
129 } 129 }
130 130
131 void PrePaintTreeWalk::ComputeClipRectForContext( 131 LayoutRect PrePaintTreeWalk::ComputeClipRectForContext(
132 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, 132 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context,
133 const EffectPaintPropertyNode* effect, 133 const EffectPaintPropertyNode* effect,
134 const PropertyTreeState& ancestor_state, 134 const PropertyTreeState& ancestor_state,
135 const LayoutPoint& ancestor_paint_offset, 135 const LayoutPoint& ancestor_paint_offset) {
136 FloatClipRect& clip_rect) {
137 PropertyTreeState local_state(context.transform, context.clip, effect); 136 PropertyTreeState local_state(context.transform, context.clip, effect);
138 137
139 clip_rect = 138 const auto& clip_rect =
140 GeometryMapper::SourceToDestinationClipRect(local_state, ancestor_state); 139 GeometryMapper::SourceToDestinationClipRect(local_state, ancestor_state);
141 clip_rect.MoveBy(-FloatPoint(ancestor_paint_offset)); 140 // HasRadius() is ignored because it doesn't affect descendants' visual rects.
141 LayoutRect result(clip_rect.Rect());
142 if (!clip_rect.IsInfinite())
143 result.MoveBy(-ancestor_paint_offset);
144 return result;
142 } 145 }
143 146
144 void PrePaintTreeWalk::InvalidatePaintLayerOptimizationsIfNeeded( 147 void PrePaintTreeWalk::InvalidatePaintLayerOptimizationsIfNeeded(
145 const LayoutObject& object, 148 const LayoutObject& object,
146 PrePaintTreeWalkContext& context) { 149 PrePaintTreeWalkContext& context) {
147 if (!object.HasLayer()) 150 if (!object.HasLayer())
148 return; 151 return;
149 152
150 PaintLayer& paint_layer = *ToLayoutBoxModelObject(object).Layer(); 153 PaintLayer& paint_layer = *ToLayoutBoxModelObject(object).Layer();
151 if (object.StyleRef().HasTransform() || 154 if (object.StyleRef().HasTransform() ||
152 &object == 155 &object ==
153 context.paint_invalidator_context.paint_invalidation_container) { 156 context.paint_invalidator_context.paint_invalidation_container) {
154 context.ancestor_transformed_or_root_paint_layer = &paint_layer; 157 context.ancestor_transformed_or_root_paint_layer = &paint_layer;
155 } 158 }
156 159
157 const auto& ancestor = 160 const auto& ancestor =
158 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject(); 161 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject();
159 PropertyTreeState ancestor_state = *ancestor.LocalBorderBoxProperties(); 162 PropertyTreeState ancestor_state = *ancestor.LocalBorderBoxProperties();
160 163
161 #ifdef CHECK_CLIP_RECTS 164 #ifdef CHECK_CLIP_RECTS
162 ShouldRespectOverflowClipType respectOverflowClip = RespectOverflowClip; 165 auto respect_overflow_clip = kRespectOverflowClip;
163 #endif 166 #endif
164 if (context.ancestor_transformed_or_root_paint_layer->GetCompositingState() == 167 if (context.ancestor_transformed_or_root_paint_layer->GetCompositingState() ==
165 kPaintsIntoOwnBacking) { 168 kPaintsIntoOwnBacking) {
166 const auto* ancestor_properties = ancestor.PaintProperties(); 169 const auto* ancestor_properties = ancestor.PaintProperties();
167 if (ancestor_properties && ancestor_properties->OverflowClip()) { 170 if (ancestor_properties && ancestor_properties->OverflowClip()) {
168 ancestor_state.SetClip(ancestor_properties->OverflowClip()); 171 ancestor_state.SetClip(ancestor_properties->OverflowClip());
169 #ifdef CHECK_CLIP_RECTS 172 #ifdef CHECK_CLIP_RECTS
170 respectOverflowClip = IgnoreOverflowClip; 173 respect_overflow_clip = kIgnoreOverflowClip;
171 #endif 174 #endif
172 } 175 }
173 } 176 }
174 177
175 #ifdef CHECK_CLIP_RECTS 178 #ifdef CHECK_CLIP_RECTS
176 ClipRects& oldClipRects = 179 const auto& old_clip_rects =
177 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) 180 paint_layer.Clipper(PaintLayer::kDoNotUseGeometryMapper)
178 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, 181 .PaintingClipRects(context.ancestor_transformed_or_root_paint_layer,
179 respectOverflowClip, LayoutSize()); 182 respect_overflow_clip, LayoutSize());
180 #endif 183 #endif
181 184
182 RefPtr<ClipRects> clip_rects = ClipRects::Create();
183 const LayoutPoint& ancestor_paint_offset = 185 const LayoutPoint& ancestor_paint_offset =
184 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject() 186 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject()
185 .PaintOffset(); 187 .PaintOffset();
186 188
187 FloatClipRect clip_rect; 189 const auto* effect = context.tree_builder_context->current_effect;
188 const EffectPaintPropertyNode* effect = 190 auto overflow_clip_rect =
189 context.tree_builder_context->current_effect; 191 ComputeClipRectForContext(context.tree_builder_context->current, effect,
190 ComputeClipRectForContext(context.tree_builder_context->current, effect, 192 ancestor_state, ancestor_paint_offset);
191 ancestor_state, ancestor_paint_offset, clip_rect);
192 clip_rects->SetOverflowClipRect(clip_rect);
193 #ifdef CHECK_CLIP_RECTS 193 #ifdef CHECK_CLIP_RECTS
194 CHECK(clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) 194 CHECK(overflow_clip_rect == old_clip_rects.OverflowClipRect().Rect())
195 << "rect= " << clipRects->overflowClipRect().toString(); 195 << " new=" << overflow_clip_rect.ToString()
196 << " old=" << old_clip_rects.OverflowClipRect().Rect().ToString();
196 #endif 197 #endif
197 198
198 ComputeClipRectForContext(context.tree_builder_context->fixed_position, 199 auto fixed_clip_rect =
199 effect, ancestor_state, ancestor_paint_offset, 200 ComputeClipRectForContext(context.tree_builder_context->fixed_position,
200 clip_rect); 201 effect, ancestor_state, ancestor_paint_offset);
201 clip_rects->SetFixedClipRect(clip_rect);
202 #ifdef CHECK_CLIP_RECTS 202 #ifdef CHECK_CLIP_RECTS
203 CHECK(clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) 203 CHECK(fixed_clip_rect == old_clip_rects.FixedClipRect().Rect())
204 << " fixed=" << clipRects->fixedClipRect().toString(); 204 << " new=" << fixed_clip_rect.ToString()
205 << " old=" << old_clip_rects.FixedClipRect().Rect().ToString();
205 #endif 206 #endif
206 207
207 ComputeClipRectForContext(context.tree_builder_context->absolute_position, 208 auto pos_clip_rect =
208 effect, ancestor_state, ancestor_paint_offset, 209 ComputeClipRectForContext(context.tree_builder_context->absolute_position,
209 clip_rect); 210 effect, ancestor_state, ancestor_paint_offset);
210 clip_rects->SetPosClipRect(clip_rect);
211 #ifdef CHECK_CLIP_RECTS 211 #ifdef CHECK_CLIP_RECTS
212 CHECK(clipRects->posClipRect() == oldClipRects.posClipRect()) 212 CHECK(pos_clip_rect == old_clip_rects.PosClipRect().Rect())
213 << " abs=" << clipRects->posClipRect().toString(); 213 << " new=" << pos_clip_rect.ToString()
214 << " old=" << old_clip_rects.PosClipRect().Rect().ToString();
214 #endif 215 #endif
215 216
216 ClipRects* previous_clip_rects = paint_layer.PreviousPaintingClipRects(); 217 const auto* previous_clip_rects = paint_layer.PreviousPaintingClipRects();
218 if (!previous_clip_rects ||
219 overflow_clip_rect != previous_clip_rects->OverflowClipRect().Rect() ||
220 fixed_clip_rect != previous_clip_rects->FixedClipRect().Rect() ||
221 pos_clip_rect != previous_clip_rects->PosClipRect().Rect()) {
222 RefPtr<ClipRects> clip_rects = ClipRects::Create();
223 clip_rects->SetOverflowClipRect(overflow_clip_rect);
224 clip_rects->SetFixedClipRect(fixed_clip_rect);
225 clip_rects->SetPosClipRect(pos_clip_rect);
226 paint_layer.SetPreviousPaintingClipRects(*clip_rects);
217 227
218 if (!previous_clip_rects || *clip_rects != *previous_clip_rects) {
219 paint_layer.SetNeedsRepaint(); 228 paint_layer.SetNeedsRepaint();
220 paint_layer.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); 229 paint_layer.SetPreviousPaintPhaseDescendantOutlinesEmpty(false);
221 paint_layer.SetPreviousPaintPhaseFloatEmpty(false); 230 paint_layer.SetPreviousPaintPhaseFloatEmpty(false);
222 paint_layer.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); 231 paint_layer.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false);
223 // All subsequences which are contained below this paintLayer must also 232 // All subsequences which are contained below this paintLayer must also
224 // be checked. 233 // be checked.
225 context.paint_invalidator_context.forced_subtree_invalidation_flags |= 234 context.paint_invalidator_context.forced_subtree_invalidation_flags |=
226 PaintInvalidatorContext::kForcedSubtreeVisualRectUpdate; 235 PaintInvalidatorContext::kForcedSubtreeVisualRectUpdate;
227 } 236 }
228
229 paint_layer.SetPreviousPaintingClipRects(*clip_rects);
230 } 237 }
231 238
232 bool PrePaintTreeWalk::NeedsTreeBuilderContextUpdate( 239 bool PrePaintTreeWalk::NeedsTreeBuilderContextUpdate(
233 const FrameView& frame_view, 240 const FrameView& frame_view,
234 const PrePaintTreeWalkContext& context) { 241 const PrePaintTreeWalkContext& context) {
235 return frame_view.NeedsPaintPropertyUpdate() || 242 return frame_view.NeedsPaintPropertyUpdate() ||
236 (frame_view.GetLayoutView() && 243 (frame_view.GetLayoutView() &&
237 NeedsTreeBuilderContextUpdate(*frame_view.GetLayoutView(), context)); 244 NeedsTreeBuilderContextUpdate(*frame_view.GetLayoutView(), context));
238 } 245 }
239 246
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 309 }
303 Walk(*frame_view, context); 310 Walk(*frame_view, context);
304 } 311 }
305 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). 312 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281).
306 } 313 }
307 314
308 object.GetMutableForPainting().ClearPaintFlags(); 315 object.GetMutableForPainting().ClearPaintFlags();
309 } 316 }
310 317
311 } // namespace blink 318 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PrePaintTreeWalk.h ('k') | third_party/WebKit/Source/core/paint/PrePaintTreeWalkTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698