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

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

Issue 2923333002: Generate StyleRareNonInheritedData in ComputedStyleBase. (Closed)
Patch Set: Rebase Created 3 years, 6 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 /* 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 RGBA32 color_; 65 RGBA32 color_;
66 unsigned bitfield_; 66 unsigned bitfield_;
67 }; 67 };
68 68
69 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); 69 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue);
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 void* data_refs[6]; 75 void* data_refs[7];
76 unsigned bitfields_[4]; 76 unsigned bitfields_[4];
77 } base_; 77 } base_;
78 78
79 void* data_refs[1];
80 void* own_ptrs[1]; 79 void* own_ptrs[1];
81 void* data_ref_svg_style; 80 void* data_ref_svg_style;
82 }; 81 };
83 82
84 // 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
85 // 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
86 // update the SameSizeAsComputedStyle struct to match the updated storage of 85 // update the SameSizeAsComputedStyle struct to match the updated storage of
87 // ComputedStyle. 86 // ComputedStyle.
88 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); 87 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle);
89 88
(...skipping 25 matching lines...) Expand all
115 new_style->SetDisplay(display); 114 new_style->SetDisplay(display);
116 return new_style; 115 return new_style;
117 } 116 }
118 117
119 RefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) { 118 RefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) {
120 return AdoptRef(new ComputedStyle(other)); 119 return AdoptRef(new ComputedStyle(other));
121 } 120 }
122 121
123 ALWAYS_INLINE ComputedStyle::ComputedStyle() 122 ALWAYS_INLINE ComputedStyle::ComputedStyle()
124 : ComputedStyleBase(), RefCounted<ComputedStyle>() { 123 : ComputedStyleBase(), RefCounted<ComputedStyle>() {
125 rare_non_inherited_data_.Init(); 124 // TODO(shend): Generate these.
126 rare_non_inherited_data_.Access()->deprecated_flexible_box_data_.Init(); 125 rare_non_inherited_data_.Access()->deprecated_flexible_box_data_.Init();
127 rare_non_inherited_data_.Access()->flexible_box_data_.Init(); 126 rare_non_inherited_data_.Access()->flexible_box_data_.Init();
128 rare_non_inherited_data_.Access()->multi_col_data_.Init(); 127 rare_non_inherited_data_.Access()->multi_col_data_.Init();
129 rare_non_inherited_data_.Access()->transform_data_.Init(); 128 rare_non_inherited_data_.Access()->transform_data_.Init();
130 rare_non_inherited_data_.Access()->will_change_data_.Init(); 129 rare_non_inherited_data_.Access()->will_change_data_.Init();
131 rare_non_inherited_data_.Access()->filter_.Init(); 130 rare_non_inherited_data_.Access()->filter_.Init();
132 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); 131 rare_non_inherited_data_.Access()->backdrop_filter_.Init();
133 rare_non_inherited_data_.Access()->grid_data_.Init(); 132 rare_non_inherited_data_.Access()->grid_data_.Init();
134 rare_non_inherited_data_.Access()->grid_item_data_.Init(); 133 rare_non_inherited_data_.Access()->grid_item_data_.Init();
135 rare_non_inherited_data_.Access()->scroll_snap_data_.Init(); 134 rare_non_inherited_data_.Access()->scroll_snap_data_.Init();
136 svg_style_.Init(); 135 svg_style_.Init();
137 } 136 }
138 137
139 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) 138 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
140 : ComputedStyleBase(o), 139 : ComputedStyleBase(o),
141 RefCounted<ComputedStyle>(), 140 RefCounted<ComputedStyle>(),
142 rare_non_inherited_data_(o.rare_non_inherited_data_),
143 svg_style_(o.svg_style_) {} 141 svg_style_(o.svg_style_) {}
144 142
145 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, 143 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style,
146 const ComputedStyle& new_style) { 144 const ComputedStyle& new_style) {
147 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. 145 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle.
148 if (!old_style.HasAnyPublicPseudoStyles() && 146 if (!old_style.HasAnyPublicPseudoStyles() &&
149 !new_style.HasAnyPublicPseudoStyles()) 147 !new_style.HasAnyPublicPseudoStyles())
150 return kNoChange; 148 return kNoChange;
151 for (PseudoId pseudo_id = kFirstPublicPseudoId; 149 for (PseudoId pseudo_id = kFirstPublicPseudoId;
152 pseudo_id < kFirstInternalPseudoId; 150 pseudo_id < kFirstInternalPseudoId;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // Even if surrounding content is user-editable, shadow DOM should act as a 310 // Even if surrounding content is user-editable, shadow DOM should act as a
313 // single unit, and not necessarily be editable 311 // single unit, and not necessarily be editable
314 SetUserModify(current_user_modify); 312 SetUserModify(current_user_modify);
315 } 313 }
316 } 314 }
317 315
318 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { 316 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) {
319 DCHECK(MatchedPropertiesCache::IsStyleCacheable(other)); 317 DCHECK(MatchedPropertiesCache::IsStyleCacheable(other));
320 318
321 ComputedStyleBase::CopyNonInheritedFromCached(other); 319 ComputedStyleBase::CopyNonInheritedFromCached(other);
322 rare_non_inherited_data_ = other.rare_non_inherited_data_;
323 320
324 // The flags are copied one-by-one because they contain 321 // The flags are copied one-by-one because they contain
325 // bunch of stuff other than real style data. 322 // bunch of stuff other than real style data.
326 // See comments for each skipped flag below. 323 // See comments for each skipped flag below.
327 324
328 // Correctly set during selector matching: 325 // Correctly set during selector matching:
329 // m_styleType 326 // m_styleType
330 // m_pseudoBits 327 // m_pseudoBits
331 328
332 // Set correctly while computing style for children: 329 // Set correctly while computing style for children:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 svg_style_->InheritedEqual(*other.svg_style_); 434 svg_style_->InheritedEqual(*other.svg_style_);
438 } 435 }
439 436
440 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { 437 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const {
441 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); 438 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts();
442 } 439 }
443 440
444 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { 441 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const {
445 // compare everything except the pseudoStyle pointer 442 // compare everything except the pseudoStyle pointer
446 return ComputedStyleBase::NonInheritedEqual(other) && 443 return ComputedStyleBase::NonInheritedEqual(other) &&
447 rare_non_inherited_data_ == other.rare_non_inherited_data_ &&
448 svg_style_->NonInheritedEqual(*other.svg_style_); 444 svg_style_->NonInheritedEqual(*other.svg_style_);
449 } 445 }
450 446
451 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { 447 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const {
452 // This is a fast check that only looks if the data structures are shared. 448 // This is a fast check that only looks if the data structures are shared.
453 return ComputedStyleBase::InheritedDataShared(other) && 449 return ComputedStyleBase::InheritedDataShared(other) &&
454 svg_style_.Get() == other.svg_style_.Get(); 450 svg_style_.Get() == other.svg_style_.Get();
455 } 451 }
456 452
457 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a, 453 static bool DependenceOnContentHeightHasChanged(const ComputedStyle& a,
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 if (value < 0) 2347 if (value < 0)
2352 fvalue -= 0.5f; 2348 fvalue -= 0.5f;
2353 else 2349 else
2354 fvalue += 0.5f; 2350 fvalue += 0.5f;
2355 } 2351 }
2356 2352
2357 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2353 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2358 } 2354 }
2359 2355
2360 } // namespace blink 2356 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698