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

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

Issue 2830573002: Use generated getters/setters in ComputedStyle instead of directly accessing fields (Closed)
Patch Set: nits 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 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 StyleSelfAlignmentData ResolvedJustifySelf( 250 StyleSelfAlignmentData ResolvedJustifySelf(
251 ItemPosition normal_value_behaviour, 251 ItemPosition normal_value_behaviour,
252 const ComputedStyle* parent_style = nullptr) const; 252 const ComputedStyle* parent_style = nullptr) const;
253 253
254 StyleDifference VisualInvalidationDiff(const ComputedStyle&) const; 254 StyleDifference VisualInvalidationDiff(const ComputedStyle&) const;
255 255
256 void InheritFrom(const ComputedStyle& inherit_parent, 256 void InheritFrom(const ComputedStyle& inherit_parent,
257 IsAtShadowBoundary = kNotAtShadowBoundary); 257 IsAtShadowBoundary = kNotAtShadowBoundary);
258 void CopyNonInheritedFromCached(const ComputedStyle&); 258 void CopyNonInheritedFromCached(const ComputedStyle&);
259 259
260 PseudoId StyleType() const { return static_cast<PseudoId>(style_type_); } 260 PseudoId StyleType() const { return StyleTypeInternal(); }
261 void SetStyleType(PseudoId style_type) { style_type_ = style_type; } 261 void SetStyleType(PseudoId style_type) { SetStyleTypeInternal(style_type); }
262 262
263 ComputedStyle* GetCachedPseudoStyle(PseudoId) const; 263 ComputedStyle* GetCachedPseudoStyle(PseudoId) const;
264 ComputedStyle* AddCachedPseudoStyle(PassRefPtr<ComputedStyle>); 264 ComputedStyle* AddCachedPseudoStyle(PassRefPtr<ComputedStyle>);
265 void RemoveCachedPseudoStyle(PseudoId); 265 void RemoveCachedPseudoStyle(PseudoId);
266 266
267 const PseudoStyleCache* CachedPseudoStyles() const { 267 const PseudoStyleCache* CachedPseudoStyles() const {
268 return cached_pseudo_styles_.get(); 268 return cached_pseudo_styles_.get();
269 } 269 }
270 270
271 /** 271 /**
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 return static_cast<TouchAction>(rare_non_inherited_data_->touch_action_); 1626 return static_cast<TouchAction>(rare_non_inherited_data_->touch_action_);
1627 } 1627 }
1628 void SetTouchAction(TouchAction t) { 1628 void SetTouchAction(TouchAction t) {
1629 SET_VAR(rare_non_inherited_data_, touch_action_, t); 1629 SET_VAR(rare_non_inherited_data_, touch_action_, t);
1630 } 1630 }
1631 1631
1632 // vertical-align 1632 // vertical-align
1633 static EVerticalAlign InitialVerticalAlign() { 1633 static EVerticalAlign InitialVerticalAlign() {
1634 return EVerticalAlign::kBaseline; 1634 return EVerticalAlign::kBaseline;
1635 } 1635 }
1636 EVerticalAlign VerticalAlign() const { 1636 EVerticalAlign VerticalAlign() const { return VerticalAlignInternal(); }
1637 return static_cast<EVerticalAlign>(vertical_align_);
1638 }
1639 const Length& GetVerticalAlignLength() const { return box_->VerticalAlign(); } 1637 const Length& GetVerticalAlignLength() const { return box_->VerticalAlign(); }
1640 void SetVerticalAlign(EVerticalAlign v) { 1638 void SetVerticalAlign(EVerticalAlign v) { SetVerticalAlignInternal(v); }
1641 vertical_align_ = static_cast<unsigned>(v);
1642 }
1643 void SetVerticalAlignLength(const Length& length) { 1639 void SetVerticalAlignLength(const Length& length) {
1644 SetVerticalAlign(EVerticalAlign::kLength); 1640 SetVerticalAlignInternal(EVerticalAlign::kLength);
1645 SET_VAR(box_, vertical_align_, length); 1641 SET_VAR(box_, vertical_align_, length);
1646 } 1642 }
1647 1643
1648 // will-change 1644 // will-change
1649 const Vector<CSSPropertyID>& WillChangeProperties() const { 1645 const Vector<CSSPropertyID>& WillChangeProperties() const {
1650 return rare_non_inherited_data_->will_change_->properties_; 1646 return rare_non_inherited_data_->will_change_->properties_;
1651 } 1647 }
1652 bool WillChangeContents() const { 1648 bool WillChangeContents() const {
1653 return rare_non_inherited_data_->will_change_->contents_; 1649 return rare_non_inherited_data_->will_change_->contents_;
1654 } 1650 }
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 } 2227 }
2232 2228
2233 bool InheritedEqual(const ComputedStyle&) const; 2229 bool InheritedEqual(const ComputedStyle&) const;
2234 bool NonInheritedEqual(const ComputedStyle&) const; 2230 bool NonInheritedEqual(const ComputedStyle&) const;
2235 inline bool IndependentInheritedEqual(const ComputedStyle&) const; 2231 inline bool IndependentInheritedEqual(const ComputedStyle&) const;
2236 inline bool NonIndependentInheritedEqual(const ComputedStyle&) const; 2232 inline bool NonIndependentInheritedEqual(const ComputedStyle&) const;
2237 bool LoadingCustomFontsEqual(const ComputedStyle&) const; 2233 bool LoadingCustomFontsEqual(const ComputedStyle&) const;
2238 bool InheritedDataShared(const ComputedStyle&) const; 2234 bool InheritedDataShared(const ComputedStyle&) const;
2239 2235
2240 bool HasChildDependentFlags() const { 2236 bool HasChildDependentFlags() const {
2241 return EmptyState() || HasExplicitlyInheritedProperties(); 2237 return EmptyStateInternal() || HasExplicitlyInheritedProperties();
2242 } 2238 }
2243 void CopyChildDependentFlagsFrom(const ComputedStyle&); 2239 void CopyChildDependentFlagsFrom(const ComputedStyle&);
2244 2240
2245 // Counters. 2241 // Counters.
2246 const CounterDirectiveMap* GetCounterDirectives() const; 2242 const CounterDirectiveMap* GetCounterDirectives() const;
2247 CounterDirectiveMap& AccessCounterDirectives(); 2243 CounterDirectiveMap& AccessCounterDirectives();
2248 const CounterDirectives GetCounterDirectives( 2244 const CounterDirectives GetCounterDirectives(
2249 const AtomicString& identifier) const; 2245 const AtomicString& identifier) const;
2250 void ClearIncrementDirectives(); 2246 void ClearIncrementDirectives();
2251 void ClearResetDirectives(); 2247 void ClearResetDirectives();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 } 2296 }
2301 CSSTransitionData& AccessTransitions(); 2297 CSSTransitionData& AccessTransitions();
2302 2298
2303 // Callback selectors. 2299 // Callback selectors.
2304 const Vector<String>& CallbackSelectors() const { 2300 const Vector<String>& CallbackSelectors() const {
2305 return rare_non_inherited_data_->callback_selectors_; 2301 return rare_non_inherited_data_->callback_selectors_;
2306 } 2302 }
2307 void AddCallbackSelector(const String& selector); 2303 void AddCallbackSelector(const String& selector);
2308 2304
2309 // Non-property flags. 2305 // Non-property flags.
2310 bool EmptyState() const { return empty_state_; } 2306 bool EmptyState() const { return EmptyStateInternal(); }
2311 void SetEmptyState(bool b) { 2307 void SetEmptyState(bool b) {
2312 SetUnique(); 2308 SetUnique();
2313 empty_state_ = b; 2309 SetEmptyStateInternal(b);
2314 } 2310 }
2315 2311
2316 bool HasInlineTransform() const { 2312 bool HasInlineTransform() const {
2317 return rare_non_inherited_data_->has_inline_transform_; 2313 return rare_non_inherited_data_->has_inline_transform_;
2318 } 2314 }
2319 void SetHasInlineTransform(bool b) { 2315 void SetHasInlineTransform(bool b) {
2320 SET_VAR(rare_non_inherited_data_, has_inline_transform_, b); 2316 SET_VAR(rare_non_inherited_data_, has_inline_transform_, b);
2321 } 2317 }
2322 2318
2323 bool HasCompositorProxy() const { 2319 bool HasCompositorProxy() const {
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
3691 inline bool ComputedStyle::SetTextOrientation( 3687 inline bool ComputedStyle::SetTextOrientation(
3692 TextOrientation text_orientation) { 3688 TextOrientation text_orientation) {
3693 if (compareEqual(rare_inherited_data_->text_orientation_, text_orientation)) 3689 if (compareEqual(rare_inherited_data_->text_orientation_, text_orientation))
3694 return false; 3690 return false;
3695 3691
3696 rare_inherited_data_.Access()->text_orientation_ = text_orientation; 3692 rare_inherited_data_.Access()->text_orientation_ = text_orientation;
3697 return true; 3693 return true;
3698 } 3694 }
3699 3695
3700 inline bool ComputedStyle::HasAnyPublicPseudoStyles() const { 3696 inline bool ComputedStyle::HasAnyPublicPseudoStyles() const {
3701 return pseudo_bits_; 3697 return PseudoBitsInternal();
suzyh_UTC10 (ex-contributor) 2017/04/20 00:30:46 It looks like pseudo_bits_ is a PseudoId, not a bo
nainar 2017/04/20 03:06:16 Do you mean cast PseudoBitsInternal() to a bool?
suzyh_UTC10 (ex-contributor) 2017/04/20 03:40:26 I'm actually not sure what the right way to do it
nainar 2017/04/20 05:21:49 That works. Done
3702 } 3698 }
3703 3699
3704 inline bool ComputedStyle::HasPseudoStyle(PseudoId pseudo) const { 3700 inline bool ComputedStyle::HasPseudoStyle(PseudoId pseudo) const {
3705 DCHECK(pseudo >= kFirstPublicPseudoId); 3701 DCHECK(pseudo >= kFirstPublicPseudoId);
3706 DCHECK(pseudo < kFirstInternalPseudoId); 3702 DCHECK(pseudo < kFirstInternalPseudoId);
3707 return (1 << (pseudo - kFirstPublicPseudoId)) & pseudo_bits_; 3703 return (1 << (pseudo - kFirstPublicPseudoId)) & PseudoBitsInternal();
3708 } 3704 }
3709 3705
3710 inline void ComputedStyle::SetHasPseudoStyle(PseudoId pseudo) { 3706 inline void ComputedStyle::SetHasPseudoStyle(PseudoId pseudo) {
3711 DCHECK(pseudo >= kFirstPublicPseudoId); 3707 DCHECK(pseudo >= kFirstPublicPseudoId);
3712 DCHECK(pseudo < kFirstInternalPseudoId); 3708 DCHECK(pseudo < kFirstInternalPseudoId);
3713 pseudo_bits_ |= 1 << (pseudo - kFirstPublicPseudoId); 3709 SetPseudoBitsInternal(static_cast<PseudoId>(
3710 PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
suzyh_UTC10 (ex-contributor) 2017/04/20 00:30:46 This is getting nasty. Consider adding a TODO to m
nainar 2017/04/20 03:06:16 Added a comment explaining what the code represent
suzyh_UTC10 (ex-contributor) 2017/04/20 03:40:26 Hmm nope that's not really much more helpful. Befo
nainar 2017/04/20 05:21:49 Done.
3714 } 3711 }
3715 3712
3716 inline bool ComputedStyle::HasPseudoElementStyle() const { 3713 inline bool ComputedStyle::HasPseudoElementStyle() const {
3717 return pseudo_bits_ & kElementPseudoIdMask; 3714 return PseudoBitsInternal() & kElementPseudoIdMask;
3718 } 3715 }
3719 3716
3720 } // namespace blink 3717 } // namespace blink
3721 3718
3722 #endif // ComputedStyle_h 3719 #endif // ComputedStyle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698