| 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/paint/ObjectPaintInvalidator.h" | 9 #include "core/paint/ObjectPaintInvalidator.h" |
| 10 #include "core/paint/PaintInvalidator.h" | 10 #include "core/paint/PaintInvalidator.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool BoxPaintInvalidator::incrementallyInvalidatePaint() { | 67 bool BoxPaintInvalidator::incrementallyInvalidatePaint() { |
| 68 LayoutRect rightDelta; | 68 LayoutRect rightDelta; |
| 69 LayoutRect bottomDelta; | 69 LayoutRect bottomDelta; |
| 70 if (m_box.isLayoutView()) { | 70 if (m_box.isLayoutView()) { |
| 71 // This corresponds to the special case in computePaintInvalidationReason() | 71 // This corresponds to the special case in computePaintInvalidationReason() |
| 72 // for LayoutView in non-rootLayerScrolling mode. In rootLayerScrolling | 72 // for LayoutView in non-rootLayerScrolling mode. In rootLayerScrolling |
| 73 // mode, we'll do full paint invalidation (see crbug.com/660156). | 73 // mode, we'll do full paint invalidation (see crbug.com/660156). |
| 74 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 74 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 75 DCHECK(m_context.oldBounds.location() == m_context.newBounds.location()); | 75 DCHECK(m_context.oldVisualRect.location() == |
| 76 rightDelta = computeRightDelta(m_context.newBounds.location(), | 76 m_context.newVisualRect.location()); |
| 77 m_context.oldBounds.size(), | 77 rightDelta = computeRightDelta(m_context.newVisualRect.location(), |
| 78 m_context.newBounds.size(), 0); | 78 m_context.oldVisualRect.size(), |
| 79 bottomDelta = computeBottomDelta(m_context.newBounds.location(), | 79 m_context.newVisualRect.size(), 0); |
| 80 m_context.oldBounds.size(), | 80 bottomDelta = computeBottomDelta(m_context.newVisualRect.location(), |
| 81 m_context.newBounds.size(), 0); | 81 m_context.oldVisualRect.size(), |
| 82 m_context.newVisualRect.size(), 0); |
| 82 } else { | 83 } else { |
| 83 LayoutSize oldBorderBoxSize = | 84 LayoutSize oldBorderBoxSize = |
| 84 computePreviousBorderBoxSize(m_context.oldBounds.size()); | 85 computePreviousBorderBoxSize(m_context.oldVisualRect.size()); |
| 85 LayoutSize newBorderBoxSize = m_box.size(); | 86 LayoutSize newBorderBoxSize = m_box.size(); |
| 86 DCHECK(m_context.oldLocation == m_context.newLocation); | 87 DCHECK(m_context.oldLocation == m_context.newLocation); |
| 87 rightDelta = computeRightDelta(m_context.newLocation, oldBorderBoxSize, | 88 rightDelta = computeRightDelta(m_context.newLocation, oldBorderBoxSize, |
| 88 newBorderBoxSize, m_box.borderRight()); | 89 newBorderBoxSize, m_box.borderRight()); |
| 89 bottomDelta = computeBottomDelta(m_context.newLocation, oldBorderBoxSize, | 90 bottomDelta = computeBottomDelta(m_context.newLocation, oldBorderBoxSize, |
| 90 newBorderBoxSize, m_box.borderBottom()); | 91 newBorderBoxSize, m_box.borderBottom()); |
| 91 } | 92 } |
| 92 | 93 |
| 93 if (rightDelta.isEmpty() && bottomDelta.isEmpty()) | 94 if (rightDelta.isEmpty() && bottomDelta.isEmpty()) |
| 94 return false; | 95 return false; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return PaintInvalidationContentBoxChange; | 152 return PaintInvalidationContentBoxChange; |
| 152 } | 153 } |
| 153 | 154 |
| 154 if (style.backgroundLayers().thisOrNextLayersHaveLocalAttachment()) { | 155 if (style.backgroundLayers().thisOrNextLayersHaveLocalAttachment()) { |
| 155 if (previousBoxSizesMap().get(&m_box).layoutOverflowRect != | 156 if (previousBoxSizesMap().get(&m_box).layoutOverflowRect != |
| 156 m_box.layoutOverflowRect()) | 157 m_box.layoutOverflowRect()) |
| 157 return PaintInvalidationLayoutOverflowBoxChange; | 158 return PaintInvalidationLayoutOverflowBoxChange; |
| 158 } | 159 } |
| 159 | 160 |
| 160 LayoutSize oldBorderBoxSize = | 161 LayoutSize oldBorderBoxSize = |
| 161 computePreviousBorderBoxSize(m_context.oldBounds.size()); | 162 computePreviousBorderBoxSize(m_context.oldVisualRect.size()); |
| 162 LayoutSize newBorderBoxSize = m_box.size(); | 163 LayoutSize newBorderBoxSize = m_box.size(); |
| 163 bool borderBoxChanged = oldBorderBoxSize != newBorderBoxSize; | 164 bool borderBoxChanged = oldBorderBoxSize != newBorderBoxSize; |
| 164 | 165 |
| 165 if (!borderBoxChanged && m_context.oldBounds == m_context.newBounds) | 166 if (!borderBoxChanged && m_context.oldVisualRect == m_context.newVisualRect) |
| 166 return PaintInvalidationNone; | 167 return PaintInvalidationNone; |
| 167 | 168 |
| 168 // If either border box changed or bounds changed, and old or new border box | 169 // If either border box changed or bounds changed, and old or new border box |
| 169 // doesn't equal old or new bounds, incremental invalidation is not | 170 // doesn't equal old or new bounds, incremental invalidation is not |
| 170 // applicable. This captures the following cases: | 171 // applicable. This captures the following cases: |
| 171 // - pixel snapping of paint invalidation bounds, | 172 // - pixel snapping of paint invalidation bounds, |
| 172 // - scale, rotate, skew etc. transforms, | 173 // - scale, rotate, skew etc. transforms, |
| 173 // - visual overflows. | 174 // - visual overflows. |
| 174 if (m_context.oldBounds != | 175 if (m_context.oldVisualRect != |
| 175 LayoutRect(m_context.oldLocation, oldBorderBoxSize) || | 176 LayoutRect(m_context.oldLocation, oldBorderBoxSize) || |
| 176 m_context.newBounds != | 177 m_context.newVisualRect != |
| 177 LayoutRect(m_context.newLocation, newBorderBoxSize)) { | 178 LayoutRect(m_context.newLocation, newBorderBoxSize)) { |
| 178 return borderBoxChanged ? PaintInvalidationBorderBoxChange | 179 return borderBoxChanged ? PaintInvalidationBorderBoxChange |
| 179 : PaintInvalidationBoundsChange; | 180 : PaintInvalidationBoundsChange; |
| 180 } | 181 } |
| 181 | 182 |
| 182 DCHECK(borderBoxChanged); | 183 DCHECK(borderBoxChanged); |
| 183 | 184 |
| 184 if (m_box.hasNonCompositedScrollbars()) | 185 if (m_box.hasNonCompositedScrollbars()) |
| 185 return PaintInvalidationBorderBoxChange; | 186 return PaintInvalidationBorderBoxChange; |
| 186 | 187 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 if (PaintLayerScrollableArea* area = m_box.getScrollableArea()) | 227 if (PaintLayerScrollableArea* area = m_box.getScrollableArea()) |
| 227 area->invalidatePaintOfScrollControlsIfNeeded(m_context); | 228 area->invalidatePaintOfScrollControlsIfNeeded(m_context); |
| 228 | 229 |
| 229 // This is for the next invalidatePaintIfNeeded so must be at the end. | 230 // This is for the next invalidatePaintIfNeeded so must be at the end. |
| 230 savePreviousBoxSizesIfNeeded(); | 231 savePreviousBoxSizesIfNeeded(); |
| 231 | 232 |
| 232 return reason; | 233 return reason; |
| 233 } | 234 } |
| 234 | 235 |
| 235 bool BoxPaintInvalidator::needsToSavePreviousBoxSizes() { | 236 bool BoxPaintInvalidator::needsToSavePreviousBoxSizes() { |
| 236 LayoutSize paintInvalidationSize = m_context.newBounds.size(); | 237 LayoutSize paintInvalidationSize = m_context.newVisualRect.size(); |
| 237 // Don't save old box sizes if the paint rect is empty because we'll | 238 // Don't save old box sizes if the paint rect is empty because we'll |
| 238 // full invalidate once the paint rect becomes non-empty. | 239 // full invalidate once the paint rect becomes non-empty. |
| 239 if (paintInvalidationSize.isEmpty()) | 240 if (paintInvalidationSize.isEmpty()) |
| 240 return false; | 241 return false; |
| 241 | 242 |
| 242 if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) | 243 if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) |
| 243 return false; | 244 return false; |
| 244 | 245 |
| 245 const ComputedStyle& style = m_box.styleRef(); | 246 const ComputedStyle& style = m_box.styleRef(); |
| 246 | 247 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 275 previousBoxSizesMap().set(&m_box, sizes); | 276 previousBoxSizesMap().set(&m_box, sizes); |
| 276 } | 277 } |
| 277 | 278 |
| 278 LayoutSize BoxPaintInvalidator::computePreviousBorderBoxSize( | 279 LayoutSize BoxPaintInvalidator::computePreviousBorderBoxSize( |
| 279 const LayoutSize& previousBoundsSize) { | 280 const LayoutSize& previousBoundsSize) { |
| 280 auto it = previousBoxSizesMap().find(&m_box); | 281 auto it = previousBoxSizesMap().find(&m_box); |
| 281 if (it != previousBoxSizesMap().end()) | 282 if (it != previousBoxSizesMap().end()) |
| 282 return it->value.borderBoxSize; | 283 return it->value.borderBoxSize; |
| 283 | 284 |
| 284 // We didn't save the old border box size because it was the same as the size | 285 // We didn't save the old border box size because it was the same as the size |
| 285 // of oldBounds. | 286 // of oldVisualRect. |
| 286 return previousBoundsSize; | 287 return previousBoundsSize; |
| 287 } | 288 } |
| 288 | 289 |
| 289 } // namespace blink | 290 } // namespace blink |
| OLD | NEW |