OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/PaintInvalidator.h" | 5 #include "core/paint/PaintInvalidator.h" |
6 | 6 |
7 #include "core/editing/FrameSelection.h" | 7 #include "core/editing/FrameSelection.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/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 context.treeBuilderContext.current.clip, nullptr); | 130 context.treeBuilderContext.current.clip, nullptr); |
131 | 131 |
132 FloatRect floatRect(rect); | 132 FloatRect floatRect(rect); |
133 geometryMapper.sourceToDestinationVisualRect( | 133 geometryMapper.sourceToDestinationVisualRect( |
134 currentTreeState, *containerContentsProperties, floatRect); | 134 currentTreeState, *containerContentsProperties, floatRect); |
135 result = LayoutRect(floatRect); | 135 result = LayoutRect(floatRect); |
136 } | 136 } |
137 | 137 |
138 // Convert the result to the container's contents space. | 138 // Convert the result to the container's contents space. |
139 result.moveBy(-context.paintInvalidationContainer->paintOffset()); | 139 result.moveBy(-context.paintInvalidationContainer->paintOffset()); |
| 140 result.move(context.scrollAdjustment); |
140 } | 141 } |
141 | 142 |
142 object.adjustVisualRectForRasterEffects(result); | 143 object.adjustVisualRectForRasterEffects(result); |
143 | 144 |
144 PaintLayer::mapRectInPaintInvalidationContainerToBacking( | 145 PaintLayer::mapRectInPaintInvalidationContainerToBacking( |
145 *context.paintInvalidationContainer, result); | 146 *context.paintInvalidationContainer, result); |
146 | 147 |
147 result.move(object.scrollAdjustmentForPaintInvalidation( | |
148 *context.paintInvalidationContainer)); | |
149 | |
150 return result; | 148 return result; |
151 } | 149 } |
152 | 150 |
153 void PaintInvalidatorContext::mapLocalRectToVisualRectInBacking( | 151 void PaintInvalidatorContext::mapLocalRectToVisualRectInBacking( |
154 const LayoutObject& object, | 152 const LayoutObject& object, |
155 LayoutRect& rect) const { | 153 LayoutRect& rect) const { |
156 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | 154 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); |
157 rect = blink::mapLocalRectToVisualRectInBacking<LayoutRect, LayoutPoint>( | 155 rect = blink::mapLocalRectToVisualRectInBacking<LayoutRect, LayoutPoint>( |
158 object, rect, *this, *geometryMapper); | 156 object, rect, *this, *geometryMapper); |
159 } | 157 } |
(...skipping 28 matching lines...) Expand all Loading... |
188 if (context.treeBuilderContext.current.transform != containerTransform) { | 186 if (context.treeBuilderContext.current.transform != containerTransform) { |
189 FloatRect rect = FloatRect(FloatPoint(point), FloatSize()); | 187 FloatRect rect = FloatRect(FloatPoint(point), FloatSize()); |
190 m_geometryMapper.sourceToDestinationRect( | 188 m_geometryMapper.sourceToDestinationRect( |
191 context.treeBuilderContext.current.transform, containerTransform, | 189 context.treeBuilderContext.current.transform, containerTransform, |
192 rect); | 190 rect); |
193 point = LayoutPoint(rect.location()); | 191 point = LayoutPoint(rect.location()); |
194 } | 192 } |
195 | 193 |
196 // Convert the result to the container's contents space. | 194 // Convert the result to the container's contents space. |
197 point.moveBy(-context.paintInvalidationContainer->paintOffset()); | 195 point.moveBy(-context.paintInvalidationContainer->paintOffset()); |
| 196 point.move(context.scrollAdjustment); |
198 } | 197 } |
199 | 198 |
200 if (context.paintInvalidationContainer->layer()->groupedMapping()) { | 199 if (context.paintInvalidationContainer->layer()->groupedMapping()) { |
201 FloatPoint floatPoint(point); | 200 FloatPoint floatPoint(point); |
202 PaintLayer::mapPointInPaintInvalidationContainerToBacking( | 201 PaintLayer::mapPointInPaintInvalidationContainerToBacking( |
203 *context.paintInvalidationContainer, floatPoint); | 202 *context.paintInvalidationContainer, floatPoint); |
204 point = LayoutPoint(floatPoint); | 203 point = LayoutPoint(floatPoint); |
205 } | 204 } |
206 | 205 |
207 point.move(object.scrollAdjustmentForPaintInvalidation( | |
208 *context.paintInvalidationContainer)); | |
209 | |
210 return point; | 206 return point; |
211 } | 207 } |
212 | 208 |
213 void PaintInvalidator::updatePaintingLayer(const LayoutObject& object, | 209 void PaintInvalidator::updatePaintingLayer(const LayoutObject& object, |
214 PaintInvalidatorContext& context) { | 210 PaintInvalidatorContext& context) { |
215 if (object.hasLayer() && | 211 if (object.hasLayer() && |
216 toLayoutBoxModelObject(object).hasSelfPaintingLayer()) { | 212 toLayoutBoxModelObject(object).hasSelfPaintingLayer()) { |
217 context.paintingLayer = toLayoutBoxModelObject(object).layer(); | 213 context.paintingLayer = toLayoutBoxModelObject(object).layer(); |
218 } else if (object.isColumnSpanAll() || | 214 } else if (object.isColumnSpanAll() || |
219 object.isFloatingWithNonContainingBlockParent()) { | 215 object.isFloatingWithNonContainingBlockParent()) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 private: | 279 private: |
284 PaintPropertyTreeBuilderContext& m_treeBuilderContext; | 280 PaintPropertyTreeBuilderContext& m_treeBuilderContext; |
285 PaintPropertyTreeBuilderContext::ContainingBlockContext m_savedContext; | 281 PaintPropertyTreeBuilderContext::ContainingBlockContext m_savedContext; |
286 }; | 282 }; |
287 | 283 |
288 } // namespace | 284 } // namespace |
289 | 285 |
290 void PaintInvalidator::updatePaintInvalidationContainer( | 286 void PaintInvalidator::updatePaintInvalidationContainer( |
291 const LayoutObject& object, | 287 const LayoutObject& object, |
292 PaintInvalidatorContext& context) { | 288 PaintInvalidatorContext& context) { |
| 289 const auto* oldPaintInvalidationContainer = |
| 290 context.paintInvalidationContainer; |
293 if (object.isPaintInvalidationContainer()) { | 291 if (object.isPaintInvalidationContainer()) { |
294 context.paintInvalidationContainer = toLayoutBoxModelObject(&object); | 292 context.paintInvalidationContainer = toLayoutBoxModelObject(&object); |
295 if (object.styleRef().isStackingContext()) | 293 if (object.styleRef().isStackingContext()) |
296 context.paintInvalidationContainerForStackedContents = | 294 context.paintInvalidationContainerForStackedContents = |
297 toLayoutBoxModelObject(&object); | 295 toLayoutBoxModelObject(&object); |
298 } else if (object.isLayoutView()) { | 296 } else if (object.isLayoutView()) { |
299 // paintInvalidationContainerForStackedContents is only for stacked | 297 // paintInvalidationContainerForStackedContents is only for stacked |
300 // descendants in its own frame, because it doesn't establish stacking | 298 // descendants in its own frame, because it doesn't establish stacking |
301 // context for stacked contents in sub-frames. | 299 // context for stacked contents in sub-frames. |
302 // Contents stacked in the root stacking context in this frame should use | 300 // Contents stacked in the root stacking context in this frame should use |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 // However, we need to keep the | 334 // However, we need to keep the |
337 // ForcedSubtreeFullInvalidationForStackedContents flag if the current | 335 // ForcedSubtreeFullInvalidationForStackedContents flag if the current |
338 // object isn't the paint invalidation container of stacked contents. | 336 // object isn't the paint invalidation container of stacked contents. |
339 context.forcedSubtreeInvalidationFlags &= PaintInvalidatorContext:: | 337 context.forcedSubtreeInvalidationFlags &= PaintInvalidatorContext:: |
340 ForcedSubtreeFullInvalidationForStackedContents; | 338 ForcedSubtreeFullInvalidationForStackedContents; |
341 } else { | 339 } else { |
342 context.forcedSubtreeInvalidationFlags = 0; | 340 context.forcedSubtreeInvalidationFlags = 0; |
343 } | 341 } |
344 } | 342 } |
345 | 343 |
| 344 if (context.paintInvalidationContainer != oldPaintInvalidationContainer) { |
| 345 context.scrollAdjustment = context.paintInvalidationContainer |
| 346 ->scrollAdjustmentForPaintInvalidation(); |
| 347 } else { |
| 348 DCHECK(context.scrollAdjustment == |
| 349 context.paintInvalidationContainer |
| 350 ->scrollAdjustmentForPaintInvalidation()); |
| 351 } |
| 352 |
346 DCHECK(context.paintInvalidationContainer == | 353 DCHECK(context.paintInvalidationContainer == |
347 object.containerForPaintInvalidation()); | 354 object.containerForPaintInvalidation()); |
348 DCHECK(context.paintingLayer == object.paintingLayer()); | 355 DCHECK(context.paintingLayer == object.paintingLayer()); |
349 } | 356 } |
350 | 357 |
351 void PaintInvalidator::updateVisualRect(const LayoutObject& object, | 358 void PaintInvalidator::updateVisualRect(const LayoutObject& object, |
352 PaintInvalidatorContext& context) { | 359 PaintInvalidatorContext& context) { |
353 Optional<ScopedUndoFrameViewContentClipAndScroll> | 360 Optional<ScopedUndoFrameViewContentClipAndScroll> |
354 undoFrameViewContentClipAndScroll; | 361 undoFrameViewContentClipAndScroll; |
355 | 362 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 399 |
393 void PaintInvalidator::invalidatePaintIfNeeded( | 400 void PaintInvalidator::invalidatePaintIfNeeded( |
394 FrameView& frameView, | 401 FrameView& frameView, |
395 PaintInvalidatorContext& context) { | 402 PaintInvalidatorContext& context) { |
396 LayoutView* layoutView = frameView.layoutView(); | 403 LayoutView* layoutView = frameView.layoutView(); |
397 CHECK(layoutView); | 404 CHECK(layoutView); |
398 | 405 |
399 context.paintInvalidationContainer = | 406 context.paintInvalidationContainer = |
400 context.paintInvalidationContainerForStackedContents = | 407 context.paintInvalidationContainerForStackedContents = |
401 &layoutView->containerForPaintInvalidation(); | 408 &layoutView->containerForPaintInvalidation(); |
| 409 context.scrollAdjustment = context.paintInvalidationContainer |
| 410 ->scrollAdjustmentForPaintInvalidation(); |
402 context.paintingLayer = layoutView->layer(); | 411 context.paintingLayer = layoutView->layer(); |
403 | 412 |
404 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 413 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
405 ScopedUndoFrameViewContentClipAndScroll undo(frameView, context); | 414 ScopedUndoFrameViewContentClipAndScroll undo(frameView, context); |
406 frameView.invalidatePaintOfScrollControlsIfNeeded(context); | 415 frameView.invalidatePaintOfScrollControlsIfNeeded(context); |
407 } | 416 } |
408 } | 417 } |
409 | 418 |
410 void PaintInvalidator::invalidatePaintIfNeeded( | 419 void PaintInvalidator::invalidatePaintIfNeeded( |
411 const LayoutObject& object, | 420 const LayoutObject& object, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 500 } |
492 } | 501 } |
493 | 502 |
494 void PaintInvalidator::processPendingDelayedPaintInvalidations() { | 503 void PaintInvalidator::processPendingDelayedPaintInvalidations() { |
495 for (auto target : m_pendingDelayedPaintInvalidations) | 504 for (auto target : m_pendingDelayedPaintInvalidations) |
496 target->getMutableForPainting().setShouldDoFullPaintInvalidation( | 505 target->getMutableForPainting().setShouldDoFullPaintInvalidation( |
497 PaintInvalidationDelayedFull); | 506 PaintInvalidationDelayedFull); |
498 } | 507 } |
499 | 508 |
500 } // namespace blink | 509 } // namespace blink |
OLD | NEW |