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

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

Issue 2824973002: Split StyleSurroundData::margin into four individual Lengths. (Closed)
Patch Set: Rebase 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/style/ComputedStyle.cpp » ('j') | 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) 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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 return static_cast<EIsolation>(rare_non_inherited_data_->isolation_); 1087 return static_cast<EIsolation>(rare_non_inherited_data_->isolation_);
1088 } 1088 }
1089 void SetIsolation(EIsolation v) { 1089 void SetIsolation(EIsolation v) {
1090 rare_non_inherited_data_.Access()->isolation_ = v; 1090 rare_non_inherited_data_.Access()->isolation_ = v;
1091 } 1091 }
1092 1092
1093 // Margin properties. 1093 // Margin properties.
1094 1094
1095 // margin-top 1095 // margin-top
1096 static Length InitialMarginTop() { return Length(kFixed); } 1096 static Length InitialMarginTop() { return Length(kFixed); }
1097 const Length& MarginTop() const { return surround_->margin_.Top(); } 1097 const Length& MarginTop() const { return surround_->margin_top_; }
1098 void SetMarginTop(const Length& v) { SET_VAR(surround_, margin_.top_, v); } 1098 void SetMarginTop(const Length& v) { SET_VAR(surround_, margin_top_, v); }
1099 1099
1100 // margin-bottom 1100 // margin-bottom
1101 static Length InitialMarginBottom() { return Length(kFixed); } 1101 static Length InitialMarginBottom() { return Length(kFixed); }
1102 const Length& MarginBottom() const { return surround_->margin_.Bottom(); } 1102 const Length& MarginBottom() const { return surround_->margin_bottom_; }
1103 void SetMarginBottom(const Length& v) { 1103 void SetMarginBottom(const Length& v) {
1104 SET_VAR(surround_, margin_.bottom_, v); 1104 SET_VAR(surround_, margin_bottom_, v);
1105 } 1105 }
1106 1106
1107 // margin-left 1107 // margin-left
1108 static Length InitialMarginLeft() { return Length(kFixed); } 1108 static Length InitialMarginLeft() { return Length(kFixed); }
1109 const Length& MarginLeft() const { return surround_->margin_.Left(); } 1109 const Length& MarginLeft() const { return surround_->margin_left_; }
1110 void SetMarginLeft(const Length& v) { SET_VAR(surround_, margin_.left_, v); } 1110 void SetMarginLeft(const Length& v) { SET_VAR(surround_, margin_left_, v); }
1111 1111
1112 // margin-right 1112 // margin-right
1113 static Length InitialMarginRight() { return Length(kFixed); } 1113 static Length InitialMarginRight() { return Length(kFixed); }
1114 const Length& MarginRight() const { return surround_->margin_.Right(); } 1114 const Length& MarginRight() const { return surround_->margin_right_; }
1115 void SetMarginRight(const Length& v) { 1115 void SetMarginRight(const Length& v) { SET_VAR(surround_, margin_right_, v); }
1116 SET_VAR(surround_, margin_.right_, v);
1117 }
1118 1116
1119 // -webkit-margin-before-collapse (aka -webkit-margin-top-collapse) 1117 // -webkit-margin-before-collapse (aka -webkit-margin-top-collapse)
1120 static EMarginCollapse InitialMarginBeforeCollapse() { 1118 static EMarginCollapse InitialMarginBeforeCollapse() {
1121 return kMarginCollapseCollapse; 1119 return kMarginCollapseCollapse;
1122 } 1120 }
1123 EMarginCollapse MarginAfterCollapse() const { 1121 EMarginCollapse MarginAfterCollapse() const {
1124 return static_cast<EMarginCollapse>( 1122 return static_cast<EMarginCollapse>(
1125 rare_non_inherited_data_->margin_after_collapse); 1123 rare_non_inherited_data_->margin_after_collapse);
1126 } 1124 }
1127 void SetMarginBeforeCollapse(EMarginCollapse c) { 1125 void SetMarginBeforeCollapse(EMarginCollapse c) {
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 return IsHorizontalWritingMode() ? MaxHeight() : MaxWidth(); 2823 return IsHorizontalWritingMode() ? MaxHeight() : MaxWidth();
2826 } 2824 }
2827 const Length& LogicalMinWidth() const { 2825 const Length& LogicalMinWidth() const {
2828 return IsHorizontalWritingMode() ? MinWidth() : MinHeight(); 2826 return IsHorizontalWritingMode() ? MinWidth() : MinHeight();
2829 } 2827 }
2830 const Length& LogicalMinHeight() const { 2828 const Length& LogicalMinHeight() const {
2831 return IsHorizontalWritingMode() ? MinHeight() : MinWidth(); 2829 return IsHorizontalWritingMode() ? MinHeight() : MinWidth();
2832 } 2830 }
2833 2831
2834 // Margin utility functions. 2832 // Margin utility functions.
2835 bool HasMargin() const { return Margin().NonZero(); } 2833 bool HasMargin() const {
2834 return !MarginLeft().IsZero() || !MarginRight().IsZero() ||
2835 !MarginTop().IsZero() || !MarginBottom().IsZero();
2836 }
2836 bool HasMarginBeforeQuirk() const { return MarginBefore().Quirk(); } 2837 bool HasMarginBeforeQuirk() const { return MarginBefore().Quirk(); }
2837 bool HasMarginAfterQuirk() const { return MarginAfter().Quirk(); } 2838 bool HasMarginAfterQuirk() const { return MarginAfter().Quirk(); }
2838 const LengthBox& Margin() const { return surround_->margin_; } 2839 const Length& MarginBefore() const { return MarginBeforeUsing(this); }
2839 const Length& MarginBefore() const { 2840 const Length& MarginAfter() const { return MarginAfterUsing(this); }
2840 return Margin().Before(GetWritingMode()); 2841 const Length& MarginStart() const { return MarginStartUsing(this); }
2842 const Length& MarginEnd() const { return MarginEndUsing(this); }
2843 const Length& MarginOver() const {
2844 return LengthBox::Over(GetWritingMode(), MarginTop(), MarginRight());
2841 } 2845 }
2842 const Length& MarginAfter() const { return Margin().After(GetWritingMode()); } 2846 const Length& MarginUnder() const {
2843 const Length& MarginStart() const { 2847 return LengthBox::Under(GetWritingMode(), MarginBottom(), MarginLeft());
2844 return Margin().Start(GetWritingMode(), Direction());
2845 } 2848 }
2846 const Length& MarginEnd() const { 2849 const Length& MarginStartUsing(const ComputedStyle* other) const {
2847 return Margin().end(GetWritingMode(), Direction()); 2850 return LengthBox::Start(other->GetWritingMode(), other->Direction(),
2851 MarginTop(), MarginLeft(), MarginRight(),
2852 MarginBottom());
2848 } 2853 }
2849 const Length& MarginOver() const { return Margin().Over(GetWritingMode()); } 2854 const Length& MarginEndUsing(const ComputedStyle* other) const {
2850 const Length& MarginUnder() const { return Margin().Under(GetWritingMode()); } 2855 return LengthBox::End(other->GetWritingMode(), other->Direction(),
2851 const Length& MarginStartUsing(const ComputedStyle* other_style) const { 2856 MarginTop(), MarginLeft(), MarginRight(),
2852 return Margin().Start(other_style->GetWritingMode(), 2857 MarginBottom());
2853 other_style->Direction());
2854 } 2858 }
2855 const Length& MarginEndUsing(const ComputedStyle* other_style) const { 2859 const Length& MarginBeforeUsing(const ComputedStyle* other) const {
2856 return Margin().end(other_style->GetWritingMode(), 2860 return LengthBox::Before(other->GetWritingMode(), MarginTop(), MarginLeft(),
2857 other_style->Direction()); 2861 MarginRight());
2858 } 2862 }
2859 const Length& MarginBeforeUsing(const ComputedStyle* other_style) const { 2863 const Length& MarginAfterUsing(const ComputedStyle* other) const {
2860 return Margin().Before(other_style->GetWritingMode()); 2864 return LengthBox::After(other->GetWritingMode(), MarginBottom(),
2861 } 2865 MarginLeft(), MarginRight());
2862 const Length& MarginAfterUsing(const ComputedStyle* other_style) const {
2863 return Margin().After(other_style->GetWritingMode());
2864 } 2866 }
2865 void SetMarginStart(const Length&); 2867 void SetMarginStart(const Length&);
2866 void SetMarginEnd(const Length&); 2868 void SetMarginEnd(const Length&);
2869 bool MarginEqual(const ComputedStyle& other) const {
2870 return MarginTop() == other.MarginTop() &&
2871 MarginLeft() == other.MarginLeft() &&
2872 MarginRight() == other.MarginRight() &&
2873 MarginBottom() == other.MarginBottom();
2874 }
2867 2875
2868 // Padding utility functions. 2876 // Padding utility functions.
2869 const LengthBox& Padding() const { return surround_->padding_; } 2877 const LengthBox& Padding() const { return surround_->padding_; }
2870 const Length& PaddingBefore() const { 2878 const Length& PaddingBefore() const {
2871 return Padding().Before(GetWritingMode()); 2879 return Padding().Before(GetWritingMode());
2872 } 2880 }
2873 const Length& PaddingAfter() const { 2881 const Length& PaddingAfter() const {
2874 return Padding().After(GetWritingMode()); 2882 return Padding().After(GetWritingMode());
2875 } 2883 }
2876 const Length& PaddingStart() const { 2884 const Length& PaddingStart() const {
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
3706 pseudo_bits_ |= 1 << (pseudo - kFirstPublicPseudoId); 3714 pseudo_bits_ |= 1 << (pseudo - kFirstPublicPseudoId);
3707 } 3715 }
3708 3716
3709 inline bool ComputedStyle::HasPseudoElementStyle() const { 3717 inline bool ComputedStyle::HasPseudoElementStyle() const {
3710 return pseudo_bits_ & kElementPseudoIdMask; 3718 return pseudo_bits_ & kElementPseudoIdMask;
3711 } 3719 }
3712 3720
3713 } // namespace blink 3721 } // namespace blink
3714 3722
3715 #endif // ComputedStyle_h 3723 #endif // ComputedStyle_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/style/ComputedStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698