| 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 RarePaintData_h | 5 #ifndef RarePaintData_h |
| 6 #define RarePaintData_h | 6 #define RarePaintData_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/paint/FragmentData.h" |
| 9 #include "platform/wtf/Allocator.h" | 10 #include "platform/wtf/Allocator.h" |
| 10 #include "platform/wtf/Noncopyable.h" | 11 #include "platform/wtf/Noncopyable.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 class PropertyTreeState; | 15 class PropertyTreeState; |
| 15 class ObjectPaintProperties; | |
| 16 class PaintLayer; | 16 class PaintLayer; |
| 17 | 17 |
| 18 // This is for paint-related data on LayoutObject that is not needed on all | 18 // This is for paint-related data on LayoutObject that is not needed on all |
| 19 // objects. | 19 // objects. |
| 20 class CORE_EXPORT RarePaintData { | 20 class CORE_EXPORT RarePaintData { |
| 21 WTF_MAKE_NONCOPYABLE(RarePaintData); | 21 WTF_MAKE_NONCOPYABLE(RarePaintData); |
| 22 USING_FAST_MALLOC(RarePaintData); | 22 USING_FAST_MALLOC(RarePaintData); |
| 23 | 23 |
| 24 public: | 24 public: |
| 25 RarePaintData(); | 25 RarePaintData(); |
| 26 ~RarePaintData(); | 26 ~RarePaintData(); |
| 27 | 27 |
| 28 PaintLayer* Layer() { return layer_.get(); } | 28 PaintLayer* Layer() { return layer_.get(); } |
| 29 void SetLayer(std::unique_ptr<PaintLayer>); | 29 void SetLayer(std::unique_ptr<PaintLayer>); |
| 30 | 30 |
| 31 FragmentData* Fragment() const { return fragment_data_.get(); } |
| 32 |
| 33 FragmentData& EnsureFragment() const; |
| 34 |
| 31 ObjectPaintProperties* PaintProperties() const { | 35 ObjectPaintProperties* PaintProperties() const { |
| 32 return paint_properties_.get(); | 36 return fragment_data_->PaintProperties(); |
| 33 } | 37 } |
| 34 ObjectPaintProperties& EnsurePaintProperties(); | |
| 35 void ClearPaintProperties(); | |
| 36 | 38 |
| 37 PropertyTreeState* LocalBorderBoxProperties() const { | 39 PropertyTreeState* LocalBorderBoxProperties() const { |
| 38 return local_border_box_properties_.get(); | 40 return local_border_box_properties_.get(); |
| 39 } | 41 } |
| 40 | 42 |
| 41 void ClearLocalBorderBoxProperties(); | 43 void ClearLocalBorderBoxProperties(); |
| 42 void SetLocalBorderBoxProperties(PropertyTreeState&); | 44 void SetLocalBorderBoxProperties(PropertyTreeState&); |
| 43 | 45 |
| 44 // This is the complete set of property nodes that can be used to paint the | 46 // This is the complete set of property nodes that can be used to paint the |
| 45 // contents of this object. It is similar to local_border_box_properties_ but | 47 // contents of this object. It is similar to local_border_box_properties_ but |
| 46 // includes properties (e.g., overflow clip, scroll translation) that apply | 48 // includes properties (e.g., overflow clip, scroll translation) that apply |
| 47 // to contents. | 49 // to contents. |
| 48 PropertyTreeState ContentsProperties() const; | 50 PropertyTreeState ContentsProperties() const; |
| 49 | 51 |
| 50 private: | 52 private: |
| 51 // The PaintLayer associated with this LayoutBoxModelObject. This can be null | 53 // The PaintLayer associated with this LayoutBoxModelObject. This can be null |
| 52 // depending on the return value of LayoutBoxModelObject::layerTypeRequired(). | 54 // depending on the return value of LayoutBoxModelObject::layerTypeRequired(). |
| 53 std::unique_ptr<PaintLayer> layer_; | 55 std::unique_ptr<PaintLayer> layer_; |
| 54 | 56 |
| 55 // Holds references to the paint property nodes created by this object. | 57 std::unique_ptr<FragmentData> fragment_data_; |
| 56 std::unique_ptr<ObjectPaintProperties> paint_properties_; | |
| 57 | 58 |
| 58 // This is a complete set of property nodes that should be used as a | 59 // This is a complete set of property nodes that should be used as a |
| 59 // starting point to paint a LayoutObject. This data is cached because some | 60 // starting point to paint a LayoutObject. This data is cached because some |
| 60 // properties inherit from the containing block chain instead of the | 61 // properties inherit from the containing block chain instead of the |
| 61 // painting parent and cannot be derived in O(1) during the paint walk. | 62 // painting parent and cannot be derived in O(1) during the paint walk. |
| 62 // | 63 // |
| 63 // For example: <div style='opacity: 0.3;'/> | 64 // For example: <div style='opacity: 0.3;'/> |
| 64 // The div's local border box properties would have an opacity 0.3 effect | 65 // The div's local border box properties would have an opacity 0.3 effect |
| 65 // node. Even though the div has no transform, its local border box | 66 // node. Even though the div has no transform, its local border box |
| 66 // properties would have a transform node that points to the div's | 67 // properties would have a transform node that points to the div's |
| 67 // ancestor transform space. | 68 // ancestor transform space. |
| 68 std::unique_ptr<PropertyTreeState> local_border_box_properties_; | 69 std::unique_ptr<PropertyTreeState> local_border_box_properties_; |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 } // namespace blink | 72 } // namespace blink |
| 72 | 73 |
| 73 #endif | 74 #endif |
| OLD | NEW |