Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/core/paint/RarePaintData.cpp

Issue 2812593003: Remove caching of contents paint properties (Closed)
Patch Set: Address reviewer comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ObjectPaintProperties.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 RarePaintData::RarePaintData() {} 11 RarePaintData::RarePaintData() {}
12 12
13 RarePaintData::~RarePaintData() {} 13 RarePaintData::~RarePaintData() {}
14 14
15 ObjectPaintProperties& RarePaintData::EnsurePaintProperties() { 15 ObjectPaintProperties& RarePaintData::EnsurePaintProperties() {
16 if (!paint_properties_) 16 if (!paint_properties_)
17 paint_properties_ = ObjectPaintProperties::Create(); 17 paint_properties_ = ObjectPaintProperties::Create();
18 return *paint_properties_.get(); 18 return *paint_properties_.get();
19 } 19 }
20 20
21 void RarePaintData::ClearLocalBorderBoxProperties() { 21 void RarePaintData::ClearLocalBorderBoxProperties() {
22 local_border_box_properties_ = nullptr; 22 local_border_box_properties_ = nullptr;
23
24 // The contents properties are based on the border box so we need to clear
25 // the cached value.
26 contents_properties_ = nullptr;
27 } 23 }
28 24
29 void RarePaintData::SetLocalBorderBoxProperties(PropertyTreeState& state) { 25 void RarePaintData::SetLocalBorderBoxProperties(PropertyTreeState& state) {
30 if (!local_border_box_properties_) 26 if (!local_border_box_properties_)
31 local_border_box_properties_ = WTF::MakeUnique<PropertyTreeState>(state); 27 local_border_box_properties_ = WTF::MakeUnique<PropertyTreeState>(state);
32 else 28 else
33 *local_border_box_properties_ = state; 29 *local_border_box_properties_ = state;
34
35 // The contents properties are based on the border box so we need to clear
36 // the cached value.
37 contents_properties_ = nullptr;
38 } 30 }
39 31
40 static std::unique_ptr<PropertyTreeState> ComputeContentsProperties( 32 PropertyTreeState RarePaintData::ContentsProperties() const {
41 PropertyTreeState* local_border_box_properties, 33 DCHECK(local_border_box_properties_);
42 ObjectPaintProperties* paint_properties) { 34 if (!local_border_box_properties_)
chrishtr 2017/04/10 20:50:30 Get rid of this.
pdr. 2017/04/10 20:56:34 Done
43 if (!local_border_box_properties) 35 return PropertyTreeState::Root();
44 return nullptr;
45 36
46 std::unique_ptr<PropertyTreeState> contents = 37 PropertyTreeState contents(*local_border_box_properties_);
47 WTF::MakeUnique<PropertyTreeState>(*local_border_box_properties); 38 if (paint_properties_) {
48 39 if (paint_properties_->ScrollTranslation())
49 if (paint_properties) { 40 contents.SetTransform(paint_properties_->ScrollTranslation());
50 if (paint_properties->ScrollTranslation()) 41 if (paint_properties_->OverflowClip())
51 contents->SetTransform(paint_properties->ScrollTranslation()); 42 contents.SetClip(paint_properties_->OverflowClip());
52 if (paint_properties->OverflowClip()) 43 else if (paint_properties_->CssClip())
53 contents->SetClip(paint_properties->OverflowClip()); 44 contents.SetClip(paint_properties_->CssClip());
54 else if (paint_properties->CssClip())
55 contents->SetClip(paint_properties->CssClip());
56 } 45 }
57 46
58 // TODO(chrishtr): cssClipFixedPosition needs to be handled somehow. 47 // TODO(chrishtr): cssClipFixedPosition needs to be handled somehow.
59 48
60 return contents; 49 return contents;
61 } 50 }
62 51
63 const PropertyTreeState* RarePaintData::ContentsProperties() const {
64 if (!contents_properties_) {
65 if (local_border_box_properties_) {
66 contents_properties_ = ComputeContentsProperties(
67 local_border_box_properties_.get(), paint_properties_.get());
68 }
69 } else {
70 #if DCHECK_IS_ON()
71 // Check that the cached contents properties are valid by checking that they
72 // do not change if recalculated.
73 DCHECK(local_border_box_properties_);
74 std::unique_ptr<PropertyTreeState> old_properties =
75 std::move(contents_properties_);
76 contents_properties_ = ComputeContentsProperties(
77 local_border_box_properties_.get(), paint_properties_.get());
78 DCHECK(*contents_properties_ == *old_properties);
79 #endif
80 }
81 return contents_properties_.get();
82 }
83
84 } // namespace blink 52 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698