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

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2861623002: Generate StyleBackgroundData in ComputedStyleBase. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // Since different compilers/architectures pack ComputedStyle differently, 71 // Since different compilers/architectures pack ComputedStyle differently,
72 // re-create the same structure for an accurate size comparison. 72 // re-create the same structure for an accurate size comparison.
73 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> { 73 struct SameSizeAsComputedStyle : public RefCounted<SameSizeAsComputedStyle> {
74 struct ComputedStyleBase { 74 struct ComputedStyleBase {
75 unsigned bitfields_[4]; 75 unsigned bitfields_[4];
76 } base_; 76 } base_;
77 77
78 void* data_refs[7]; 78 void* data_refs[7];
79 void* own_ptrs[1]; 79 void* own_ptrs[1];
80 void* data_ref_svg_style; 80 void* data_ref_svg_style;
meade_UTC10 2017/05/04 04:54:38 This CL affects SameSizeAsComputedStyleBase but no
81 }; 81 };
82 82
83 // If this assert fails, it means that size of ComputedStyle has changed. Please 83 // If this assert fails, it means that size of ComputedStyle has changed. Please
84 // check that you really *do* what to increase the size of ComputedStyle, then 84 // check that you really *do* what to increase the size of ComputedStyle, then
85 // update the SameSizeAsComputedStyle struct to match the updated storage of 85 // update the SameSizeAsComputedStyle struct to match the updated storage of
86 // ComputedStyle. 86 // ComputedStyle.
87 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); 87 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle);
88 88
89 PassRefPtr<ComputedStyle> ComputedStyle::Create() { 89 PassRefPtr<ComputedStyle> ComputedStyle::Create() {
90 return AdoptRef(new ComputedStyle(InitialStyle())); 90 return AdoptRef(new ComputedStyle(InitialStyle()));
(...skipping 18 matching lines...) Expand all
109 } 109 }
110 110
111 PassRefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) { 111 PassRefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) {
112 return AdoptRef(new ComputedStyle(other)); 112 return AdoptRef(new ComputedStyle(other));
113 } 113 }
114 114
115 ALWAYS_INLINE ComputedStyle::ComputedStyle() 115 ALWAYS_INLINE ComputedStyle::ComputedStyle()
116 : ComputedStyleBase(), RefCounted<ComputedStyle>() { 116 : ComputedStyleBase(), RefCounted<ComputedStyle>() {
117 box_data_.Init(); 117 box_data_.Init();
118 visual_data_.Init(); 118 visual_data_.Init();
119 background_data_.Init();
120 rare_non_inherited_data_.Init(); 119 rare_non_inherited_data_.Init();
121 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init(); 120 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init();
122 rare_non_inherited_data_.Access()->flexible_box_.Init(); 121 rare_non_inherited_data_.Access()->flexible_box_.Init();
123 rare_non_inherited_data_.Access()->multi_col_.Init(); 122 rare_non_inherited_data_.Access()->multi_col_.Init();
124 rare_non_inherited_data_.Access()->transform_.Init(); 123 rare_non_inherited_data_.Access()->transform_.Init();
125 rare_non_inherited_data_.Access()->will_change_.Init(); 124 rare_non_inherited_data_.Access()->will_change_.Init();
126 rare_non_inherited_data_.Access()->filter_.Init(); 125 rare_non_inherited_data_.Access()->filter_.Init();
127 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); 126 rare_non_inherited_data_.Access()->backdrop_filter_.Init();
128 rare_non_inherited_data_.Access()->grid_.Init(); 127 rare_non_inherited_data_.Access()->grid_.Init();
129 rare_non_inherited_data_.Access()->grid_item_.Init(); 128 rare_non_inherited_data_.Access()->grid_item_.Init();
130 rare_non_inherited_data_.Access()->scroll_snap_.Init(); 129 rare_non_inherited_data_.Access()->scroll_snap_.Init();
131 rare_inherited_data_.Init(); 130 rare_inherited_data_.Init();
132 inherited_data_.Init(); 131 inherited_data_.Init();
133 svg_style_.Init(); 132 svg_style_.Init();
134 } 133 }
135 134
136 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) 135 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
137 : ComputedStyleBase(o), 136 : ComputedStyleBase(o),
138 RefCounted<ComputedStyle>(), 137 RefCounted<ComputedStyle>(),
139 box_data_(o.box_data_), 138 box_data_(o.box_data_),
140 visual_data_(o.visual_data_), 139 visual_data_(o.visual_data_),
141 background_data_(o.background_data_),
142 rare_non_inherited_data_(o.rare_non_inherited_data_), 140 rare_non_inherited_data_(o.rare_non_inherited_data_),
143 rare_inherited_data_(o.rare_inherited_data_), 141 rare_inherited_data_(o.rare_inherited_data_),
144 inherited_data_(o.inherited_data_), 142 inherited_data_(o.inherited_data_),
145 svg_style_(o.svg_style_) {} 143 svg_style_(o.svg_style_) {}
146 144
147 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, 145 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style,
148 const ComputedStyle& new_style) { 146 const ComputedStyle& new_style) {
149 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. 147 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle.
150 if (!old_style.HasAnyPublicPseudoStyles() && 148 if (!old_style.HasAnyPublicPseudoStyles() &&
151 !new_style.HasAnyPublicPseudoStyles()) 149 !new_style.HasAnyPublicPseudoStyles())
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 324 }
327 inherited_data_ = inherit_parent.inherited_data_; 325 inherited_data_ = inherit_parent.inherited_data_;
328 if (svg_style_ != inherit_parent.svg_style_) 326 if (svg_style_ != inherit_parent.svg_style_)
329 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); 327 svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get());
330 } 328 }
331 329
332 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { 330 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) {
333 ComputedStyleBase::CopyNonInheritedFromCached(other); 331 ComputedStyleBase::CopyNonInheritedFromCached(other);
334 box_data_ = other.box_data_; 332 box_data_ = other.box_data_;
335 visual_data_ = other.visual_data_; 333 visual_data_ = other.visual_data_;
336 background_data_ = other.background_data_;
337 rare_non_inherited_data_ = other.rare_non_inherited_data_; 334 rare_non_inherited_data_ = other.rare_non_inherited_data_;
338 335
339 // The flags are copied one-by-one because they contain 336 // The flags are copied one-by-one because they contain
340 // bunch of stuff other than real style data. 337 // bunch of stuff other than real style data.
341 // See comments for each skipped flag below. 338 // See comments for each skipped flag below.
342 339
343 // These are not generated in ComputedStyleBase 340 // These are not generated in ComputedStyleBase
344 SetHasViewportUnits(other.HasViewportUnits()); 341 SetHasViewportUnits(other.HasViewportUnits());
345 SetHasRemUnitsInternal(other.HasRemUnits()); 342 SetHasRemUnitsInternal(other.HasRemUnits());
346 343
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 465
469 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { 466 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const {
470 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); 467 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts();
471 } 468 }
472 469
473 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { 470 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const {
474 // compare everything except the pseudoStyle pointer 471 // compare everything except the pseudoStyle pointer
475 return ComputedStyleBase::NonInheritedEqual(other) && 472 return ComputedStyleBase::NonInheritedEqual(other) &&
476 box_data_ == other.box_data_ && 473 box_data_ == other.box_data_ &&
477 visual_data_ == other.visual_data_ && 474 visual_data_ == other.visual_data_ &&
478 background_data_ == other.background_data_ &&
479 rare_non_inherited_data_ == other.rare_non_inherited_data_ && 475 rare_non_inherited_data_ == other.rare_non_inherited_data_ &&
480 svg_style_->NonInheritedEqual(*other.svg_style_); 476 svg_style_->NonInheritedEqual(*other.svg_style_);
481 } 477 }
482 478
483 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { 479 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const {
484 // This is a fast check that only looks if the data structures are shared. 480 // This is a fast check that only looks if the data structures are shared.
485 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method? 481 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method?
486 return ComputedStyleBase::InheritedEqual(other) && 482 return ComputedStyleBase::InheritedEqual(other) &&
487 inherited_data_.Get() == other.inherited_data_.Get() && 483 inherited_data_.Get() == other.inherited_data_.Get() &&
488 svg_style_.Get() == other.svg_style_.Get() && 484 svg_style_.Get() == other.svg_style_.Get() &&
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 if (value < 0) 2490 if (value < 0)
2495 fvalue -= 0.5f; 2491 fvalue -= 0.5f;
2496 else 2492 else
2497 fvalue += 0.5f; 2493 fvalue += 0.5f;
2498 } 2494 }
2499 2495
2500 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2496 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2501 } 2497 }
2502 2498
2503 } // namespace blink 2499 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698