| 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 #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 Loading... |
| 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 // This code below checks whether any clips have changed that might: | 160 // This code below checks whether any clips have changed that might: |
| 158 // (a) invalidate optimizations made for a PaintLayer that supports | 161 // (a) invalidate optimizations made for a PaintLayer that supports |
| 159 // subsequence caching, or | 162 // subsequence caching, or |
| 160 // (b) impact clipping of descendant visual rects. | 163 // (b) impact clipping of descendant visual rects. |
| 161 if (!paint_layer.SupportsSubsequenceCaching() && | 164 if (!paint_layer.SupportsSubsequenceCaching() && |
| 162 !paint_layer.GetLayoutObject().HasClipRelatedProperty()) | 165 !paint_layer.GetLayoutObject().HasClipRelatedProperty()) |
| 163 return; | 166 return; |
| 164 | 167 |
| 165 const auto& ancestor = | 168 const auto& ancestor = |
| 166 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject(); | 169 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject(); |
| 167 PropertyTreeState ancestor_state = *ancestor.LocalBorderBoxProperties(); | 170 PropertyTreeState ancestor_state = *ancestor.LocalBorderBoxProperties(); |
| 168 | 171 |
| 169 #ifdef CHECK_CLIP_RECTS | 172 #ifdef CHECK_CLIP_RECTS |
| 170 ShouldRespectOverflowClipType respectOverflowClip = RespectOverflowClip; | 173 auto respect_overflow_clip = kRespectOverflowClip; |
| 171 #endif | 174 #endif |
| 172 if (context.ancestor_transformed_or_root_paint_layer->GetCompositingState() == | 175 if (context.ancestor_transformed_or_root_paint_layer->GetCompositingState() == |
| 173 kPaintsIntoOwnBacking) { | 176 kPaintsIntoOwnBacking) { |
| 174 const auto* ancestor_properties = ancestor.PaintProperties(); | 177 const auto* ancestor_properties = ancestor.PaintProperties(); |
| 175 if (ancestor_properties && ancestor_properties->OverflowClip()) { | 178 if (ancestor_properties && ancestor_properties->OverflowClip()) { |
| 176 ancestor_state.SetClip(ancestor_properties->OverflowClip()); | 179 ancestor_state.SetClip(ancestor_properties->OverflowClip()); |
| 177 #ifdef CHECK_CLIP_RECTS | 180 #ifdef CHECK_CLIP_RECTS |
| 178 respectOverflowClip = IgnoreOverflowClip; | 181 respect_overflow_clip = kIgnoreOverflowClip; |
| 179 #endif | 182 #endif |
| 180 } | 183 } |
| 181 } | 184 } |
| 182 | 185 |
| 183 #ifdef CHECK_CLIP_RECTS | 186 #ifdef CHECK_CLIP_RECTS |
| 184 ClipRects& oldClipRects = | 187 const auto& old_clip_rects = |
| 185 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) | 188 paint_layer.Clipper(PaintLayer::kDoNotUseGeometryMapper) |
| 186 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, | 189 .PaintingClipRects(context.ancestor_transformed_or_root_paint_layer, |
| 187 respectOverflowClip, LayoutSize()); | 190 respect_overflow_clip, LayoutSize()); |
| 188 #endif | 191 #endif |
| 189 | 192 |
| 190 RefPtr<ClipRects> clip_rects = ClipRects::Create(); | |
| 191 const LayoutPoint& ancestor_paint_offset = | 193 const LayoutPoint& ancestor_paint_offset = |
| 192 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject() | 194 context.ancestor_transformed_or_root_paint_layer->GetLayoutObject() |
| 193 .PaintOffset(); | 195 .PaintOffset(); |
| 194 | 196 |
| 195 FloatClipRect clip_rect; | 197 const auto* effect = context.tree_builder_context->current_effect; |
| 196 const EffectPaintPropertyNode* effect = | 198 auto overflow_clip_rect = |
| 197 context.tree_builder_context->current_effect; | 199 ComputeClipRectForContext(context.tree_builder_context->current, effect, |
| 198 ComputeClipRectForContext(context.tree_builder_context->current, effect, | 200 ancestor_state, ancestor_paint_offset); |
| 199 ancestor_state, ancestor_paint_offset, clip_rect); | |
| 200 clip_rects->SetOverflowClipRect(clip_rect); | |
| 201 #ifdef CHECK_CLIP_RECTS | 201 #ifdef CHECK_CLIP_RECTS |
| 202 CHECK(clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) | 202 CHECK(overflow_clip_rect == old_clip_rects.OverflowClipRect().Rect()) |
| 203 << "rect= " << clipRects->overflowClipRect().toString(); | 203 << " new=" << overflow_clip_rect.ToString() |
| 204 << " old=" << old_clip_rects.OverflowClipRect().Rect().ToString(); |
| 204 #endif | 205 #endif |
| 205 | 206 |
| 206 ComputeClipRectForContext(context.tree_builder_context->fixed_position, | 207 auto fixed_clip_rect = |
| 207 effect, ancestor_state, ancestor_paint_offset, | 208 ComputeClipRectForContext(context.tree_builder_context->fixed_position, |
| 208 clip_rect); | 209 effect, ancestor_state, ancestor_paint_offset); |
| 209 clip_rects->SetFixedClipRect(clip_rect); | |
| 210 #ifdef CHECK_CLIP_RECTS | 210 #ifdef CHECK_CLIP_RECTS |
| 211 CHECK(clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) | 211 CHECK(fixed_clip_rect == old_clip_rects.FixedClipRect().Rect()) |
| 212 << " fixed=" << clipRects->fixedClipRect().toString(); | 212 << " new=" << fixed_clip_rect.ToString() |
| 213 << " old=" << old_clip_rects.FixedClipRect().Rect().ToString(); |
| 213 #endif | 214 #endif |
| 214 | 215 |
| 215 ComputeClipRectForContext(context.tree_builder_context->absolute_position, | 216 auto pos_clip_rect = |
| 216 effect, ancestor_state, ancestor_paint_offset, | 217 ComputeClipRectForContext(context.tree_builder_context->absolute_position, |
| 217 clip_rect); | 218 effect, ancestor_state, ancestor_paint_offset); |
| 218 clip_rects->SetPosClipRect(clip_rect); | |
| 219 #ifdef CHECK_CLIP_RECTS | 219 #ifdef CHECK_CLIP_RECTS |
| 220 CHECK(clipRects->posClipRect() == oldClipRects.posClipRect()) | 220 CHECK(pos_clip_rect == old_clip_rects.PosClipRect().Rect()) |
| 221 << " abs=" << clipRects->posClipRect().toString(); | 221 << " new=" << pos_clip_rect.ToString() |
| 222 << " old=" << old_clip_rects.PosClipRect().Rect().ToString(); |
| 222 #endif | 223 #endif |
| 223 | 224 |
| 224 ClipRects* previous_clip_rects = paint_layer.PreviousPaintingClipRects(); | 225 const auto* previous_clip_rects = paint_layer.PreviousPaintingClipRects(); |
| 226 if (!previous_clip_rects || |
| 227 overflow_clip_rect != previous_clip_rects->OverflowClipRect().Rect() || |
| 228 fixed_clip_rect != previous_clip_rects->FixedClipRect().Rect() || |
| 229 pos_clip_rect != previous_clip_rects->PosClipRect().Rect()) { |
| 230 RefPtr<ClipRects> clip_rects = ClipRects::Create(); |
| 231 clip_rects->SetOverflowClipRect(overflow_clip_rect); |
| 232 clip_rects->SetFixedClipRect(fixed_clip_rect); |
| 233 clip_rects->SetPosClipRect(pos_clip_rect); |
| 234 paint_layer.SetPreviousPaintingClipRects(*clip_rects); |
| 225 | 235 |
| 226 if (!previous_clip_rects || *clip_rects != *previous_clip_rects) { | |
| 227 paint_layer.SetNeedsRepaint(); | 236 paint_layer.SetNeedsRepaint(); |
| 228 paint_layer.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); | 237 paint_layer.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); |
| 229 paint_layer.SetPreviousPaintPhaseFloatEmpty(false); | 238 paint_layer.SetPreviousPaintPhaseFloatEmpty(false); |
| 230 paint_layer.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); | 239 paint_layer.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); |
| 231 // All subsequences which are contained below this paintLayer must also | 240 // All subsequences which are contained below this paintLayer must also |
| 232 // be checked. | 241 // be checked. |
| 233 context.paint_invalidator_context.forced_subtree_invalidation_flags |= | 242 context.paint_invalidator_context.forced_subtree_invalidation_flags |= |
| 234 PaintInvalidatorContext::kForcedSubtreeVisualRectUpdate; | 243 PaintInvalidatorContext::kForcedSubtreeVisualRectUpdate; |
| 235 } | 244 } |
| 236 | |
| 237 paint_layer.SetPreviousPaintingClipRects(*clip_rects); | |
| 238 } | 245 } |
| 239 | 246 |
| 240 bool PrePaintTreeWalk::NeedsTreeBuilderContextUpdate( | 247 bool PrePaintTreeWalk::NeedsTreeBuilderContextUpdate( |
| 241 const FrameView& frame_view, | 248 const FrameView& frame_view, |
| 242 const PrePaintTreeWalkContext& context) { | 249 const PrePaintTreeWalkContext& context) { |
| 243 return frame_view.NeedsPaintPropertyUpdate() || | 250 return frame_view.NeedsPaintPropertyUpdate() || |
| 244 (frame_view.GetLayoutView() && | 251 (frame_view.GetLayoutView() && |
| 245 NeedsTreeBuilderContextUpdate(*frame_view.GetLayoutView(), context)); | 252 NeedsTreeBuilderContextUpdate(*frame_view.GetLayoutView(), context)); |
| 246 } | 253 } |
| 247 | 254 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 317 } |
| 311 Walk(*frame_view, context); | 318 Walk(*frame_view, context); |
| 312 } | 319 } |
| 313 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 320 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
| 314 } | 321 } |
| 315 | 322 |
| 316 object.GetMutableForPainting().ClearPaintFlags(); | 323 object.GetMutableForPainting().ClearPaintFlags(); |
| 317 } | 324 } |
| 318 | 325 |
| 319 } // namespace blink | 326 } // namespace blink |
| OLD | NEW |