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

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

Issue 2844183002: Generate StyleBoxData in ComputedStyleBase. (Closed)
Patch Set: Rebase 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 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[3]; 75 void* data_refs[4];
76 unsigned bitfields_[4]; 76 unsigned bitfields_[4];
77 } base_; 77 } base_;
78 78
79 void* data_refs[4]; 79 void* data_refs[3];
80 void* own_ptrs[1]; 80 void* own_ptrs[1];
81 void* data_ref_svg_style; 81 void* data_ref_svg_style;
82 }; 82 };
83 83
84 // If this assert fails, it means that size of ComputedStyle has changed. Please 84 // 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 85 // check that you really *do* what to increase the size of ComputedStyle, then
86 // update the SameSizeAsComputedStyle struct to match the updated storage of 86 // update the SameSizeAsComputedStyle struct to match the updated storage of
87 // ComputedStyle. 87 // ComputedStyle.
88 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); 88 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle);
89 89
(...skipping 18 matching lines...) Expand all
108 new_style->SetDisplay(display); 108 new_style->SetDisplay(display);
109 return new_style; 109 return new_style;
110 } 110 }
111 111
112 PassRefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) { 112 PassRefPtr<ComputedStyle> ComputedStyle::Clone(const ComputedStyle& other) {
113 return AdoptRef(new ComputedStyle(other)); 113 return AdoptRef(new ComputedStyle(other));
114 } 114 }
115 115
116 ALWAYS_INLINE ComputedStyle::ComputedStyle() 116 ALWAYS_INLINE ComputedStyle::ComputedStyle()
117 : ComputedStyleBase(), RefCounted<ComputedStyle>() { 117 : ComputedStyleBase(), RefCounted<ComputedStyle>() {
118 box_data_.Init();
119 rare_non_inherited_data_.Init(); 118 rare_non_inherited_data_.Init();
120 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init(); 119 rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init();
121 rare_non_inherited_data_.Access()->flexible_box_.Init(); 120 rare_non_inherited_data_.Access()->flexible_box_.Init();
122 rare_non_inherited_data_.Access()->multi_col_.Init(); 121 rare_non_inherited_data_.Access()->multi_col_.Init();
123 rare_non_inherited_data_.Access()->transform_.Init(); 122 rare_non_inherited_data_.Access()->transform_.Init();
124 rare_non_inherited_data_.Access()->will_change_.Init(); 123 rare_non_inherited_data_.Access()->will_change_.Init();
125 rare_non_inherited_data_.Access()->filter_.Init(); 124 rare_non_inherited_data_.Access()->filter_.Init();
126 rare_non_inherited_data_.Access()->backdrop_filter_.Init(); 125 rare_non_inherited_data_.Access()->backdrop_filter_.Init();
127 rare_non_inherited_data_.Access()->grid_.Init(); 126 rare_non_inherited_data_.Access()->grid_.Init();
128 rare_non_inherited_data_.Access()->grid_item_.Init(); 127 rare_non_inherited_data_.Access()->grid_item_.Init();
129 rare_non_inherited_data_.Access()->scroll_snap_.Init(); 128 rare_non_inherited_data_.Access()->scroll_snap_.Init();
130 rare_inherited_data_.Init(); 129 rare_inherited_data_.Init();
131 inherited_data_.Init(); 130 inherited_data_.Init();
132 svg_style_.Init(); 131 svg_style_.Init();
133 } 132 }
134 133
135 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) 134 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
136 : ComputedStyleBase(o), 135 : ComputedStyleBase(o),
137 RefCounted<ComputedStyle>(), 136 RefCounted<ComputedStyle>(),
138 box_data_(o.box_data_),
139 rare_non_inherited_data_(o.rare_non_inherited_data_), 137 rare_non_inherited_data_(o.rare_non_inherited_data_),
140 rare_inherited_data_(o.rare_inherited_data_), 138 rare_inherited_data_(o.rare_inherited_data_),
141 inherited_data_(o.inherited_data_), 139 inherited_data_(o.inherited_data_),
142 svg_style_(o.svg_style_) {} 140 svg_style_(o.svg_style_) {}
143 141
144 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style, 142 static StyleRecalcChange DiffPseudoStyles(const ComputedStyle& old_style,
145 const ComputedStyle& new_style) { 143 const ComputedStyle& new_style) {
146 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle. 144 // If the pseudoStyles have changed, ensure layoutObject triggers setStyle.
147 if (!old_style.HasAnyPublicPseudoStyles() && 145 if (!old_style.HasAnyPublicPseudoStyles() &&
148 !new_style.HasAnyPublicPseudoStyles()) 146 !new_style.HasAnyPublicPseudoStyles())
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 319
322 if (is_at_shadow_boundary == kAtShadowBoundary) { 320 if (is_at_shadow_boundary == kAtShadowBoundary) {
323 // Even if surrounding content is user-editable, shadow DOM should act as a 321 // Even if surrounding content is user-editable, shadow DOM should act as a
324 // single unit, and not necessarily be editable 322 // single unit, and not necessarily be editable
325 SetUserModify(current_user_modify); 323 SetUserModify(current_user_modify);
326 } 324 }
327 } 325 }
328 326
329 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { 327 void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) {
330 ComputedStyleBase::CopyNonInheritedFromCached(other); 328 ComputedStyleBase::CopyNonInheritedFromCached(other);
331 box_data_ = other.box_data_;
332 rare_non_inherited_data_ = other.rare_non_inherited_data_; 329 rare_non_inherited_data_ = other.rare_non_inherited_data_;
333 330
334 // The flags are copied one-by-one because they contain 331 // The flags are copied one-by-one because they contain
335 // bunch of stuff other than real style data. 332 // bunch of stuff other than real style data.
336 // See comments for each skipped flag below. 333 // See comments for each skipped flag below.
337 334
338 // These are not generated in ComputedStyleBase 335 // These are not generated in ComputedStyleBase
339 SetHasViewportUnits(other.HasViewportUnits()); 336 SetHasViewportUnits(other.HasViewportUnits());
340 SetHasRemUnitsInternal(other.HasRemUnits()); 337 SetHasRemUnitsInternal(other.HasRemUnits());
341 338
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 rare_inherited_data_ == other.rare_inherited_data_; 458 rare_inherited_data_ == other.rare_inherited_data_;
462 } 459 }
463 460
464 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const { 461 bool ComputedStyle::LoadingCustomFontsEqual(const ComputedStyle& other) const {
465 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts(); 462 return GetFont().LoadingCustomFonts() == other.GetFont().LoadingCustomFonts();
466 } 463 }
467 464
468 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const { 465 bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const {
469 // compare everything except the pseudoStyle pointer 466 // compare everything except the pseudoStyle pointer
470 return ComputedStyleBase::NonInheritedEqual(other) && 467 return ComputedStyleBase::NonInheritedEqual(other) &&
471 box_data_ == other.box_data_ &&
472 rare_non_inherited_data_ == other.rare_non_inherited_data_ && 468 rare_non_inherited_data_ == other.rare_non_inherited_data_ &&
473 svg_style_->NonInheritedEqual(*other.svg_style_); 469 svg_style_->NonInheritedEqual(*other.svg_style_);
474 } 470 }
475 471
476 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const { 472 bool ComputedStyle::InheritedDataShared(const ComputedStyle& other) const {
477 // This is a fast check that only looks if the data structures are shared. 473 // This is a fast check that only looks if the data structures are shared.
478 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method? 474 // TODO(sashab): Should ComputedStyleBase have an inheritedDataShared method?
479 return ComputedStyleBase::InheritedEqual(other) && 475 return ComputedStyleBase::InheritedEqual(other) &&
480 inherited_data_.Get() == other.inherited_data_.Get() && 476 inherited_data_.Get() == other.inherited_data_.Get() &&
481 svg_style_.Get() == other.svg_style_.Get() && 477 svg_style_.Get() == other.svg_style_.Get() &&
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 if (value < 0) 2524 if (value < 0)
2529 fvalue -= 0.5f; 2525 fvalue -= 0.5f;
2530 else 2526 else
2531 fvalue += 0.5f; 2527 fvalue += 0.5f;
2532 } 2528 }
2533 2529
2534 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2530 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2535 } 2531 }
2536 2532
2537 } // namespace blink 2533 } // 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