| 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/BoxPaintInvalidator.h" | 5 #include "core/paint/BoxPaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/frame/Settings.h" | 7 #include "core/frame/Settings.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/layout/compositing/CompositedLayerMapping.h" | 9 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 10 #include "core/paint/ObjectPaintInvalidator.h" | 10 #include "core/paint/ObjectPaintInvalidator.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const ComputedStyle& style = m_box.styleRef(); | 98 const ComputedStyle& style = m_box.styleRef(); |
| 99 | 99 |
| 100 if ((style.backgroundLayers().thisOrNextLayersUseContentBox() || | 100 if ((style.backgroundLayers().thisOrNextLayersUseContentBox() || |
| 101 style.maskLayers().thisOrNextLayersUseContentBox()) && | 101 style.maskLayers().thisOrNextLayersUseContentBox()) && |
| 102 m_box.previousContentBoxSize() != m_box.contentBoxRect().size()) | 102 m_box.previousContentBoxSize() != m_box.contentBoxRect().size()) |
| 103 return PaintInvalidationContentBoxChange; | 103 return PaintInvalidationContentBoxChange; |
| 104 | 104 |
| 105 LayoutSize oldBorderBoxSize = m_box.previousSize(); | 105 LayoutSize oldBorderBoxSize = m_box.previousSize(); |
| 106 LayoutSize newBorderBoxSize = m_box.size(); | 106 LayoutSize newBorderBoxSize = m_box.size(); |
| 107 bool borderBoxChanged = oldBorderBoxSize != newBorderBoxSize; | 107 bool borderBoxChanged = oldBorderBoxSize != newBorderBoxSize; |
| 108 if (!borderBoxChanged && m_context.oldVisualRect == m_context.newVisualRect) | 108 if (!borderBoxChanged && m_context.oldVisualRect == m_box.visualRect()) |
| 109 return PaintInvalidationNone; | 109 return PaintInvalidationNone; |
| 110 | 110 |
| 111 // If either border box changed or bounds changed, and old or new border box | 111 // If either border box changed or bounds changed, and old or new border box |
| 112 // doesn't equal old or new bounds, incremental invalidation is not | 112 // doesn't equal old or new bounds, incremental invalidation is not |
| 113 // applicable. This captures the following cases: | 113 // applicable. This captures the following cases: |
| 114 // - pixel snapping of paint invalidation bounds, | 114 // - pixel snapping of paint invalidation bounds, |
| 115 // - scale, rotate, skew etc. transforms, | 115 // - scale, rotate, skew etc. transforms, |
| 116 // - visual overflows. | 116 // - visual overflows. |
| 117 if (m_context.oldVisualRect != | 117 if (m_context.oldVisualRect != |
| 118 LayoutRect(m_context.oldLocation, oldBorderBoxSize) || | 118 LayoutRect(m_context.oldLocation, oldBorderBoxSize) || |
| 119 m_context.newVisualRect != | 119 m_box.visualRect() != |
| 120 LayoutRect(m_context.newLocation, newBorderBoxSize)) { | 120 LayoutRect(m_context.newLocation, newBorderBoxSize)) { |
| 121 return borderBoxChanged ? PaintInvalidationBorderBoxChange | 121 return borderBoxChanged ? PaintInvalidationBorderBoxChange |
| 122 : PaintInvalidationBoundsChange; | 122 : PaintInvalidationBoundsChange; |
| 123 } | 123 } |
| 124 | 124 |
| 125 DCHECK(borderBoxChanged); | 125 DCHECK(borderBoxChanged); |
| 126 | 126 |
| 127 if (style.hasVisualOverflowingEffect() || style.hasAppearance() || | 127 if (style.hasVisualOverflowingEffect() || style.hasAppearance() || |
| 128 style.hasFilterInducingProperty() || style.resize() != RESIZE_NONE || | 128 style.hasFilterInducingProperty() || style.resize() != RESIZE_NONE || |
| 129 style.hasMask()) | 129 style.hasMask()) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 PaintInvalidationReason BoxPaintInvalidator::invalidatePaintIfNeeded() { | 248 PaintInvalidationReason BoxPaintInvalidator::invalidatePaintIfNeeded() { |
| 249 invalidateScrollingContentsBackgroundIfNeeded(); | 249 invalidateScrollingContentsBackgroundIfNeeded(); |
| 250 | 250 |
| 251 PaintInvalidationReason reason = computePaintInvalidationReason(); | 251 PaintInvalidationReason reason = computePaintInvalidationReason(); |
| 252 if (reason == PaintInvalidationIncremental) { | 252 if (reason == PaintInvalidationIncremental) { |
| 253 bool invalidated; | 253 bool invalidated; |
| 254 if (m_box.isLayoutView() && | 254 if (m_box.isLayoutView() && |
| 255 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 255 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 256 invalidated = incrementallyInvalidatePaint( | 256 invalidated = incrementallyInvalidatePaint( |
| 257 reason, m_context.oldVisualRect, m_context.newVisualRect); | 257 reason, m_context.oldVisualRect, m_box.visualRect()); |
| 258 } else { | 258 } else { |
| 259 invalidated = incrementallyInvalidatePaint( | 259 invalidated = incrementallyInvalidatePaint( |
| 260 reason, LayoutRect(m_context.oldLocation, m_box.previousSize()), | 260 reason, LayoutRect(m_context.oldLocation, m_box.previousSize()), |
| 261 LayoutRect(m_context.newLocation, m_box.size())); | 261 LayoutRect(m_context.newLocation, m_box.size())); |
| 262 } | 262 } |
| 263 if (invalidated) { | 263 if (invalidated) { |
| 264 m_context.paintingLayer->setNeedsRepaint(); | 264 m_context.paintingLayer->setNeedsRepaint(); |
| 265 m_box.invalidateDisplayItemClients(reason); | 265 m_box.invalidateDisplayItemClients(reason); |
| 266 } else { | 266 } else { |
| 267 reason = PaintInvalidationNone; | 267 reason = PaintInvalidationNone; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 285 // This is for the next invalidatePaintIfNeeded so must be at the end. | 285 // This is for the next invalidatePaintIfNeeded so must be at the end. |
| 286 savePreviousBoxGeometriesIfNeeded(); | 286 savePreviousBoxGeometriesIfNeeded(); |
| 287 | 287 |
| 288 return reason; | 288 return reason; |
| 289 } | 289 } |
| 290 | 290 |
| 291 bool BoxPaintInvalidator:: | 291 bool BoxPaintInvalidator:: |
| 292 needsToSavePreviousContentBoxSizeOrLayoutOverflowRect() { | 292 needsToSavePreviousContentBoxSizeOrLayoutOverflowRect() { |
| 293 // Don't save old box geometries if the paint rect is empty because we'll | 293 // Don't save old box geometries if the paint rect is empty because we'll |
| 294 // fully invalidate once the paint rect becomes non-empty. | 294 // fully invalidate once the paint rect becomes non-empty. |
| 295 if (m_context.newVisualRect.isEmpty()) | 295 if (m_box.visualRect().isEmpty()) |
| 296 return false; | 296 return false; |
| 297 | 297 |
| 298 if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) | 298 if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) |
| 299 return false; | 299 return false; |
| 300 | 300 |
| 301 const ComputedStyle& style = m_box.styleRef(); | 301 const ComputedStyle& style = m_box.styleRef(); |
| 302 | 302 |
| 303 // Background and mask layers can depend on other boxes than border box. See | 303 // Background and mask layers can depend on other boxes than border box. See |
| 304 // crbug.com/490533 | 304 // crbug.com/490533 |
| 305 if ((style.backgroundLayers().thisOrNextLayersUseContentBox() || | 305 if ((style.backgroundLayers().thisOrNextLayersUseContentBox() || |
| (...skipping 14 matching lines...) Expand all Loading... |
| 320 if (needsToSavePreviousContentBoxSizeOrLayoutOverflowRect()) { | 320 if (needsToSavePreviousContentBoxSizeOrLayoutOverflowRect()) { |
| 321 m_box.getMutableForPainting() | 321 m_box.getMutableForPainting() |
| 322 .savePreviousContentBoxSizeAndLayoutOverflowRect(); | 322 .savePreviousContentBoxSizeAndLayoutOverflowRect(); |
| 323 } else { | 323 } else { |
| 324 m_box.getMutableForPainting() | 324 m_box.getMutableForPainting() |
| 325 .clearPreviousContentBoxSizeAndLayoutOverflowRect(); | 325 .clearPreviousContentBoxSizeAndLayoutOverflowRect(); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace blink | 329 } // namespace blink |
| OLD | NEW |