| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef FindPaintOffsetAndVisualRectNeedingUpdate_h | 5 #ifndef FindPaintOffsetAndVisualRectNeedingUpdate_h |
| 6 #define FindPaintOffsetAndVisualRectNeedingUpdate_h | 6 #define FindPaintOffsetAndVisualRectNeedingUpdate_h |
| 7 | 7 |
| 8 #if DCHECK_IS_ON() | 8 #if DCHECK_IS_ON() |
| 9 | 9 |
| 10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 static LayoutRect InflatedRect(const LayoutRect& r) { | 85 static LayoutRect InflatedRect(const LayoutRect& r) { |
| 86 LayoutRect result = r; | 86 LayoutRect result = r; |
| 87 result.Inflate(1); | 87 result.Inflate(1); |
| 88 return result; | 88 return result; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void CheckVisualRect(const LayoutRect& new_visual_rect) { | 91 void CheckVisualRect(const LayoutRect& new_visual_rect) { |
| 92 if (needed_visual_rect_update_) | 92 if (needed_visual_rect_update_) |
| 93 return; | 93 return; |
| 94 if (context_.forced_subtree_invalidation_flags & |
| 95 PaintInvalidatorContext::kForcedSubtreeNoRasterInvalidation) |
| 96 return; |
| 97 |
| 94 DCHECK((old_visual_rect_.IsEmpty() && new_visual_rect.IsEmpty()) || | 98 DCHECK((old_visual_rect_.IsEmpty() && new_visual_rect.IsEmpty()) || |
| 95 object_.EnclosingLayer()->SubtreeIsInvisible() || | 99 object_.EnclosingLayer()->SubtreeIsInvisible() || |
| 96 old_visual_rect_ == new_visual_rect || | 100 old_visual_rect_ == new_visual_rect || |
| 97 // The following check is to tolerate the differences caused by | 101 // The following check is to tolerate the differences caused by |
| 98 // pixel snapping that may happen for one rect but not for another | 102 // pixel snapping that may happen for one rect but not for another |
| 99 // while we need neither paint invalidation nor raster invalidation | 103 // while we need neither paint invalidation nor raster invalidation |
| 100 // for the change. This may miss some real subpixel changes of visual | 104 // for the change. This may miss some real subpixel changes of visual |
| 101 // rects. TODO(wangxianzhu): Look into whether we can tighten this | 105 // rects. TODO(wangxianzhu): Look into whether we can tighten this |
| 102 // for SPv2. | 106 // for SPv2. |
| 103 (InflatedRect(old_visual_rect_).Contains(new_visual_rect) && | 107 (InflatedRect(old_visual_rect_).Contains(new_visual_rect) && |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 old_location_(ObjectPaintInvalidator(object).LocationInBacking()) {} | 155 old_location_(ObjectPaintInvalidator(object).LocationInBacking()) {} |
| 152 | 156 |
| 153 ~FindObjectVisualRectNeedingUpdateScope() { | 157 ~FindObjectVisualRectNeedingUpdateScope() { |
| 154 CheckVisualRect(object_.VisualRect()); | 158 CheckVisualRect(object_.VisualRect()); |
| 155 CheckLocation(); | 159 CheckLocation(); |
| 156 } | 160 } |
| 157 | 161 |
| 158 void CheckLocation() { | 162 void CheckLocation() { |
| 159 if (needed_visual_rect_update_) | 163 if (needed_visual_rect_update_) |
| 160 return; | 164 return; |
| 165 if (context_.forced_subtree_invalidation_flags & |
| 166 PaintInvalidatorContext::kForcedSubtreeNoRasterInvalidation) |
| 167 return; |
| 168 |
| 161 LayoutPoint new_location = | 169 LayoutPoint new_location = |
| 162 ObjectPaintInvalidator(object_).LocationInBacking(); | 170 ObjectPaintInvalidator(object_).LocationInBacking(); |
| 163 // Location of LayoutText and non-root SVG is location of the visual rect | 171 // Location of LayoutText and non-root SVG is location of the visual rect |
| 164 // which have been checked above. | 172 // which have been checked above. |
| 165 DCHECK(object_.IsText() || object_.IsSVGChild() || | 173 DCHECK(object_.IsText() || object_.IsSVGChild() || |
| 166 new_location == old_location_ || | 174 new_location == old_location_ || |
| 167 object_.EnclosingLayer()->SubtreeIsInvisible() || | 175 object_.EnclosingLayer()->SubtreeIsInvisible() || |
| 168 // See checkVisualRect for the issue of approximation. | 176 // See checkVisualRect for the issue of approximation. |
| 169 LayoutRect(-1, -1, 2, 2) | 177 LayoutRect(-1, -1, 2, 2) |
| 170 .Contains(LayoutRect(LayoutPoint(new_location - old_location_), | 178 .Contains(LayoutRect(LayoutPoint(new_location - old_location_), |
| 171 LayoutSize()))) | 179 LayoutSize()))) |
| 172 << "Location changed without needing update" | 180 << "Location changed without needing update" |
| 173 << " object=" << object_.DebugName() | 181 << " object=" << object_.DebugName() |
| 174 << " old=" << old_location_.ToString() | 182 << " old=" << old_location_.ToString() |
| 175 << " new=" << new_location.ToString(); | 183 << " new=" << new_location.ToString(); |
| 176 } | 184 } |
| 177 | 185 |
| 178 private: | 186 private: |
| 179 LayoutPoint old_location_; | 187 LayoutPoint old_location_; |
| 180 }; | 188 }; |
| 181 | 189 |
| 182 } // namespace blink | 190 } // namespace blink |
| 183 | 191 |
| 184 #endif // DCHECK_IS_ON() | 192 #endif // DCHECK_IS_ON() |
| 185 | 193 |
| 186 #endif // FindPaintOffsetAndVisualRectNeedingUpdate_h | 194 #endif // FindPaintOffsetAndVisualRectNeedingUpdate_h |
| OLD | NEW |