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 #include "core/paint/RarePaintData.h" | 5 #include "core/paint/RarePaintData.h" |
6 | 6 |
7 #include "core/paint/ObjectPaintProperties.h" | 7 #include "core/paint/FragmentData.h" |
8 #include "core/paint/PaintLayer.h" | 8 #include "core/paint/PaintLayer.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 RarePaintData::RarePaintData() {} | 12 RarePaintData::RarePaintData() {} |
13 | 13 |
14 RarePaintData::~RarePaintData() {} | 14 RarePaintData::~RarePaintData() {} |
15 | 15 |
16 void RarePaintData::SetLayer(std::unique_ptr<PaintLayer> layer) { | 16 void RarePaintData::SetLayer(std::unique_ptr<PaintLayer> layer) { |
17 layer_ = std::move(layer); | 17 layer_ = std::move(layer); |
18 }; | 18 }; |
19 | 19 |
20 ObjectPaintProperties& RarePaintData::EnsurePaintProperties() { | 20 FragmentData& RarePaintData::EnsureFragment() { |
21 if (!paint_properties_) | 21 if (!fragment_data_) |
22 paint_properties_ = ObjectPaintProperties::Create(); | 22 fragment_data_ = FragmentData::Create(); |
23 return *paint_properties_.get(); | 23 return *fragment_data_.get(); |
24 } | |
25 | |
26 void RarePaintData::ClearPaintProperties() { | |
27 paint_properties_.reset(nullptr); | |
28 } | 24 } |
29 | 25 |
30 void RarePaintData::ClearLocalBorderBoxProperties() { | 26 void RarePaintData::ClearLocalBorderBoxProperties() { |
31 local_border_box_properties_ = nullptr; | 27 local_border_box_properties_ = nullptr; |
32 } | 28 } |
33 | 29 |
34 void RarePaintData::SetLocalBorderBoxProperties(PropertyTreeState& state) { | 30 void RarePaintData::SetLocalBorderBoxProperties(PropertyTreeState& state) { |
35 if (!local_border_box_properties_) | 31 if (!local_border_box_properties_) |
36 local_border_box_properties_ = WTF::MakeUnique<PropertyTreeState>(state); | 32 local_border_box_properties_ = WTF::MakeUnique<PropertyTreeState>(state); |
37 else | 33 else |
38 *local_border_box_properties_ = state; | 34 *local_border_box_properties_ = state; |
39 } | 35 } |
40 | 36 |
41 PropertyTreeState RarePaintData::ContentsProperties() const { | 37 PropertyTreeState RarePaintData::ContentsProperties() const { |
42 DCHECK(local_border_box_properties_); | 38 DCHECK(local_border_box_properties_); |
43 PropertyTreeState contents(*local_border_box_properties_); | 39 PropertyTreeState contents(*local_border_box_properties_); |
44 if (paint_properties_) { | 40 if (fragment_data_) { |
45 if (paint_properties_->ScrollTranslation()) | 41 if (auto* properties = fragment_data_->PaintProperties()) { |
46 contents.SetTransform(paint_properties_->ScrollTranslation()); | 42 if (properties->ScrollTranslation()) |
47 if (paint_properties_->OverflowClip()) | 43 contents.SetTransform(properties->ScrollTranslation()); |
48 contents.SetClip(paint_properties_->OverflowClip()); | 44 if (properties->OverflowClip()) |
49 else if (paint_properties_->CssClip()) | 45 contents.SetClip(properties->OverflowClip()); |
50 contents.SetClip(paint_properties_->CssClip()); | 46 else if (properties->CssClip()) |
| 47 contents.SetClip(properties->CssClip()); |
| 48 } |
51 } | 49 } |
52 | 50 |
53 // TODO(chrishtr): cssClipFixedPosition needs to be handled somehow. | 51 // TODO(chrishtr): cssClipFixedPosition needs to be handled somehow. |
54 | 52 |
55 return contents; | 53 return contents; |
56 } | 54 } |
57 | 55 |
58 } // namespace blink | 56 } // namespace blink |
OLD | NEW |