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" |
11 #include "core/paint/FindPropertiesNeedingUpdate.h" | 11 #include "core/paint/FindPropertiesNeedingUpdate.h" |
12 #include "core/paint/ObjectPaintInvalidator.h" | 12 #include "core/paint/ObjectPaintInvalidator.h" |
13 #include "core/paint/PaintInvalidator.h" | 13 #include "core/paint/PaintInvalidator.h" |
14 #include "core/paint/PaintLayer.h" | 14 #include "core/paint/PaintLayer.h" |
15 #include "core/paint/PaintPropertyTreeBuilder.h" | 15 #include "core/paint/PaintPropertyTreeBuilder.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 // This file contains scope classes for catching cases where paint offset or | 19 // This file contains scope classes for catching cases where paint offset or |
20 // visual rect needed an update but were not marked as such. If paint offset or | 20 // visual rect needed an update but were not marked as such. If paint offset or |
21 // any visual rect (including visual rect of the object itself, scroll controls, | 21 // any visual rect (including visual rect of the object itself, scroll controls, |
22 // caret, selection, etc.) will change, the object must be marked as such by | 22 // caret, selection, etc.) will change, the object must be marked as such by |
23 // LayoutObject::setNeedsPaintOffsetAndVisualRectUpdate() (which is a private | 23 // LayoutObject::setNeedsPaintOffsetAndVisualRectUpdate() (which is a private |
24 // function called by several public paint-invalidation-flag setting functions). | 24 // function called by several public paint-invalidation-flag setting functions). |
25 | 25 |
26 class FindPaintOffsetNeedingUpdateScope { | 26 class FindPaintOffsetNeedingUpdateScope { |
27 public: | 27 public: |
28 FindPaintOffsetNeedingUpdateScope( | 28 FindPaintOffsetNeedingUpdateScope(const LayoutObject& object, |
29 const LayoutObject& object, | 29 bool& is_actually_needed) |
30 const PaintPropertyTreeBuilderContext& context) | |
31 : object_(object), | 30 : object_(object), |
32 context_(context), | 31 is_actually_needed_(is_actually_needed), |
33 old_paint_offset_(object.PaintOffset()) { | 32 old_paint_offset_(object.PaintOffset()) { |
34 if (object.PaintProperties() && | 33 if (object.PaintProperties() && |
35 object.PaintProperties()->PaintOffsetTranslation()) { | 34 object.PaintProperties()->PaintOffsetTranslation()) { |
36 old_paint_offset_translation_ = | 35 old_paint_offset_translation_ = |
37 object.PaintProperties()->PaintOffsetTranslation()->Clone(); | 36 object.PaintProperties()->PaintOffsetTranslation()->Clone(); |
38 } | 37 } |
39 } | 38 } |
40 | 39 |
41 ~FindPaintOffsetNeedingUpdateScope() { | 40 ~FindPaintOffsetNeedingUpdateScope() { |
42 if (context_.is_actually_needed) | 41 if (is_actually_needed_) |
43 return; | 42 return; |
44 DCHECK_OBJECT_PROPERTY_EQ(object_, &old_paint_offset_, | 43 DCHECK_OBJECT_PROPERTY_EQ(object_, &old_paint_offset_, |
45 &object_.PaintOffset()); | 44 &object_.PaintOffset()); |
46 const auto* paint_offset_translation = | 45 const auto* paint_offset_translation = |
47 object_.PaintProperties() | 46 object_.PaintProperties() |
48 ? object_.PaintProperties()->PaintOffsetTranslation() | 47 ? object_.PaintProperties()->PaintOffsetTranslation() |
49 : nullptr; | 48 : nullptr; |
50 DCHECK_OBJECT_PROPERTY_EQ(object_, old_paint_offset_translation_.Get(), | 49 DCHECK_OBJECT_PROPERTY_EQ(object_, old_paint_offset_translation_.Get(), |
51 paint_offset_translation); | 50 paint_offset_translation); |
52 } | 51 } |
53 | 52 |
54 private: | 53 private: |
55 const LayoutObject& object_; | 54 const LayoutObject& object_; |
56 const PaintPropertyTreeBuilderContext& context_; | 55 const bool& is_actually_needed_; |
57 LayoutPoint old_paint_offset_; | 56 LayoutPoint old_paint_offset_; |
58 RefPtr<const TransformPaintPropertyNode> old_paint_offset_translation_; | 57 RefPtr<const TransformPaintPropertyNode> old_paint_offset_translation_; |
59 }; | 58 }; |
60 | 59 |
61 class FindVisualRectNeedingUpdateScopeBase { | 60 class FindVisualRectNeedingUpdateScopeBase { |
62 protected: | 61 protected: |
63 FindVisualRectNeedingUpdateScopeBase(const LayoutObject& object, | 62 FindVisualRectNeedingUpdateScopeBase(const LayoutObject& object, |
64 const PaintInvalidatorContext& context, | 63 const PaintInvalidatorContext& context, |
65 const LayoutRect& old_visual_rect) | 64 const LayoutRect& old_visual_rect) |
66 : object_(object), | 65 : object_(object), |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 171 |
173 private: | 172 private: |
174 LayoutPoint old_location_; | 173 LayoutPoint old_location_; |
175 }; | 174 }; |
176 | 175 |
177 } // namespace blink | 176 } // namespace blink |
178 | 177 |
179 #endif // DCHECK_IS_ON() | 178 #endif // DCHECK_IS_ON() |
180 | 179 |
181 #endif // FindPaintOffsetAndVisualRectNeedingUpdate_h | 180 #endif // FindPaintOffsetAndVisualRectNeedingUpdate_h |
OLD | NEW |