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

Side by Side Diff: third_party/WebKit/Source/platform/Length.cpp

Issue 1746283002: Rename enums/functions that collide in chromium style in platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get-names-13-platform: . Created 4 years, 9 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 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) 4 * (C) 2001 Dirk Mueller ( mueller@kde.org )
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 , m_type(Calculated) 95 , m_type(Calculated)
96 , m_isFloat(false) 96 , m_isFloat(false)
97 { 97 {
98 m_intValue = calcHandles().insert(calc); 98 m_intValue = calcHandles().insert(calc);
99 } 99 }
100 100
101 Length Length::blendMixedTypes(const Length& from, double progress, ValueRange r ange) const 101 Length Length::blendMixedTypes(const Length& from, double progress, ValueRange r ange) const
102 { 102 {
103 ASSERT(from.isSpecified()); 103 ASSERT(from.isSpecified());
104 ASSERT(isSpecified()); 104 ASSERT(isSpecified());
105 PixelsAndPercent fromPixelsAndPercent = from.pixelsAndPercent(); 105 PixelsAndPercent fromPixelsAndPercent = from.getPixelsAndPercent();
106 PixelsAndPercent toPixelsAndPercent = pixelsAndPercent(); 106 PixelsAndPercent toPixelsAndPercent = getPixelsAndPercent();
107 const float pixels = blink::blend(fromPixelsAndPercent.pixels, toPixelsAndPe rcent.pixels, progress); 107 const float pixels = blink::blend(fromPixelsAndPercent.pixels, toPixelsAndPe rcent.pixels, progress);
108 const float percent = blink::blend(fromPixelsAndPercent.percent, toPixelsAnd Percent.percent, progress); 108 const float percent = blink::blend(fromPixelsAndPercent.percent, toPixelsAnd Percent.percent, progress);
109 return Length(CalculationValue::create(PixelsAndPercent(pixels, percent), ra nge)); 109 return Length(CalculationValue::create(PixelsAndPercent(pixels, percent), ra nge));
110 } 110 }
111 111
112 PixelsAndPercent Length::pixelsAndPercent() const 112 PixelsAndPercent Length::getPixelsAndPercent() const
113 { 113 {
114 switch (type()) { 114 switch (type()) {
115 case Fixed: 115 case Fixed:
116 return PixelsAndPercent(value(), 0); 116 return PixelsAndPercent(value(), 0);
117 case Percent: 117 case Percent:
118 return PixelsAndPercent(0, value()); 118 return PixelsAndPercent(0, value());
119 case Calculated: 119 case Calculated:
120 return calculationValue().pixelsAndPercent(); 120 return getCalculationValue().getPixelsAndPercent();
121 default: 121 default:
122 ASSERT_NOT_REACHED(); 122 ASSERT_NOT_REACHED();
123 return PixelsAndPercent(0, 0); 123 return PixelsAndPercent(0, 0);
124 } 124 }
125 } 125 }
126 126
127 Length Length::subtractFromOneHundredPercent() const 127 Length Length::subtractFromOneHundredPercent() const
128 { 128 {
129 PixelsAndPercent result = pixelsAndPercent(); 129 PixelsAndPercent result = getPixelsAndPercent();
130 result.pixels = -result.pixels; 130 result.pixels = -result.pixels;
131 result.percent = 100 - result.percent; 131 result.percent = 100 - result.percent;
132 if (result.pixels && result.percent) 132 if (result.pixels && result.percent)
133 return Length(CalculationValue::create(result, ValueRangeAll)); 133 return Length(CalculationValue::create(result, ValueRangeAll));
134 if (result.percent) 134 if (result.percent)
135 return Length(result.percent, Percent); 135 return Length(result.percent, Percent);
136 return Length(result.pixels, Fixed); 136 return Length(result.pixels, Fixed);
137 } 137 }
138 138
139 Length Length::zoom(double factor) const 139 Length Length::zoom(double factor) const
140 { 140 {
141 switch (type()) { 141 switch (type()) {
142 case Fixed: 142 case Fixed:
143 return Length(getFloatValue() * factor, Fixed); 143 return Length(getFloatValue() * factor, Fixed);
144 case Calculated: { 144 case Calculated: {
145 PixelsAndPercent result = pixelsAndPercent(); 145 PixelsAndPercent result = getPixelsAndPercent();
146 result.pixels *= factor; 146 result.pixels *= factor;
147 return Length(CalculationValue::create(result, calculationValue().valueR ange())); 147 return Length(CalculationValue::create(result, getCalculationValue().get ValueRange()));
148 } 148 }
149 default: 149 default:
150 return *this; 150 return *this;
151 } 151 }
152 } 152 }
153 153
154 CalculationValue& Length::calculationValue() const 154 CalculationValue& Length::getCalculationValue() const
155 { 155 {
156 ASSERT(isCalculated()); 156 ASSERT(isCalculated());
157 return calcHandles().get(calculationHandle()); 157 return calcHandles().get(calculationHandle());
158 } 158 }
159 159
160 void Length::incrementCalculatedRef() const 160 void Length::incrementCalculatedRef() const
161 { 161 {
162 ASSERT(isCalculated()); 162 ASSERT(isCalculated());
163 calculationValue().ref(); 163 getCalculationValue().ref();
164 } 164 }
165 165
166 void Length::decrementCalculatedRef() const 166 void Length::decrementCalculatedRef() const
167 { 167 {
168 ASSERT(isCalculated()); 168 ASSERT(isCalculated());
169 calcHandles().decrementRef(calculationHandle()); 169 calcHandles().decrementRef(calculationHandle());
170 } 170 }
171 171
172 float Length::nonNanCalculatedValue(LayoutUnit maxValue) const 172 float Length::nonNanCalculatedValue(LayoutUnit maxValue) const
173 { 173 {
174 ASSERT(isCalculated()); 174 ASSERT(isCalculated());
175 float result = calculationValue().evaluate(maxValue.toFloat()); 175 float result = getCalculationValue().evaluate(maxValue.toFloat());
176 if (std::isnan(result)) 176 if (std::isnan(result))
177 return 0; 177 return 0;
178 return result; 178 return result;
179 } 179 }
180 180
181 bool Length::isCalculatedEqual(const Length& o) const 181 bool Length::isCalculatedEqual(const Length& o) const
182 { 182 {
183 return isCalculated() && (&calculationValue() == &o.calculationValue() || ca lculationValue() == o.calculationValue()); 183 return isCalculated() && (&getCalculationValue() == &o.getCalculationValue() || getCalculationValue() == o.getCalculationValue());
184 } 184 }
185 185
186 struct SameSizeAsLength { 186 struct SameSizeAsLength {
187 int32_t value; 187 int32_t value;
188 int32_t metaData; 188 int32_t metaData;
189 }; 189 };
190 static_assert(sizeof(Length) == sizeof(SameSizeAsLength), "length should stay sm all"); 190 static_assert(sizeof(Length) == sizeof(SameSizeAsLength), "length should stay sm all");
191 191
192 } // namespace blink 192 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Length.h ('k') | third_party/WebKit/Source/platform/PODRedBlackTree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698